webs-sdk 0.3.8 → 0.4.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/README.md +398 -398
- package/dist/libraries/auth.d.ts +1 -0
- package/dist/libraries/auth.d.ts.map +1 -1
- package/dist/libraries/auth.js +60 -0
- package/dist/libraries/auth.js.map +1 -1
- package/dist/libraries/corp_auth.d.ts +0 -1
- package/dist/libraries/corp_auth.d.ts.map +1 -1
- package/dist/libraries/corp_auth.js +0 -22
- package/dist/libraries/corp_auth.js.map +1 -1
- package/dist/libraries/networking.d.ts +37 -37
- package/dist/libraries/networking.js +293 -293
- package/dist/libraries/storage.d.ts +22 -22
- package/dist/libraries/storage.js +247 -247
- package/dist/libraries/utils.d.ts +34 -34
- package/dist/libraries/utils.js +256 -256
- package/index.js +1 -1
- package/package.json +37 -37
- package/types/index.d.ts +350 -351
package/dist/libraries/utils.js
CHANGED
|
@@ -1,257 +1,257 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Utils = void 0;
|
|
7
|
-
const config_1 = __importDefault(require("../config"));
|
|
8
|
-
class Utils {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.capitalize = (text) => {
|
|
11
|
-
let result = '';
|
|
12
|
-
if (typeof text === 'string') {
|
|
13
|
-
result = text.charAt(0).toUpperCase() + text.slice(1);
|
|
14
|
-
}
|
|
15
|
-
return result;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
formatDate(date, format = 'YYYY-MM-DD') {
|
|
19
|
-
const year = date.getFullYear();
|
|
20
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
21
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
22
|
-
return format
|
|
23
|
-
.replace('YYYY', year.toString())
|
|
24
|
-
.replace('MM', month)
|
|
25
|
-
.replace('DD', day);
|
|
26
|
-
}
|
|
27
|
-
generateId() {
|
|
28
|
-
return Math.random().toString(36).substr(2, 9);
|
|
29
|
-
}
|
|
30
|
-
debounce(func, wait) {
|
|
31
|
-
let timeout;
|
|
32
|
-
return (...args) => {
|
|
33
|
-
clearTimeout(timeout);
|
|
34
|
-
timeout = setTimeout(() => func.apply(this, args), wait);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
throttle(func, limit) {
|
|
38
|
-
let inThrottle;
|
|
39
|
-
return (...args) => {
|
|
40
|
-
if (!inThrottle) {
|
|
41
|
-
func.apply(this, args);
|
|
42
|
-
inThrottle = true;
|
|
43
|
-
setTimeout(() => inThrottle = false, limit);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
deepClone(obj) {
|
|
48
|
-
if (obj === null || typeof obj !== 'object')
|
|
49
|
-
return obj;
|
|
50
|
-
if (obj instanceof Date)
|
|
51
|
-
return new Date(obj.getTime());
|
|
52
|
-
if (obj instanceof Array)
|
|
53
|
-
return obj.map(item => this.deepClone(item));
|
|
54
|
-
if (typeof obj === 'object') {
|
|
55
|
-
const clonedObj = {};
|
|
56
|
-
for (const key in obj) {
|
|
57
|
-
if (obj.hasOwnProperty(key)) {
|
|
58
|
-
clonedObj[key] = this.deepClone(obj[key]);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return clonedObj;
|
|
62
|
-
}
|
|
63
|
-
return obj;
|
|
64
|
-
}
|
|
65
|
-
isValidEmail(email) {
|
|
66
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
67
|
-
return emailRegex.test(email);
|
|
68
|
-
}
|
|
69
|
-
isValidUrl(url) {
|
|
70
|
-
try {
|
|
71
|
-
new URL(url);
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
catch (_a) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
truncateText(text, maxLength, suffix = '...') {
|
|
79
|
-
if (text.length <= maxLength)
|
|
80
|
-
return text;
|
|
81
|
-
return text.substring(0, maxLength - suffix.length) + suffix;
|
|
82
|
-
}
|
|
83
|
-
capitalizeFirst(text) {
|
|
84
|
-
if (!text)
|
|
85
|
-
return text;
|
|
86
|
-
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
87
|
-
}
|
|
88
|
-
camelToKebab(str) {
|
|
89
|
-
return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
90
|
-
}
|
|
91
|
-
kebabToCamel(str) {
|
|
92
|
-
return str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
93
|
-
}
|
|
94
|
-
sleep(ms) {
|
|
95
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
96
|
-
}
|
|
97
|
-
getRandomInt(min, max) {
|
|
98
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
99
|
-
}
|
|
100
|
-
arrayChunk(array, size) {
|
|
101
|
-
const chunks = [];
|
|
102
|
-
for (let i = 0; i < array.length; i += size) {
|
|
103
|
-
chunks.push(array.slice(i, i + size));
|
|
104
|
-
}
|
|
105
|
-
return chunks;
|
|
106
|
-
}
|
|
107
|
-
arrayUnique(array) {
|
|
108
|
-
return [...new Set(array)];
|
|
109
|
-
}
|
|
110
|
-
objectPick(obj, keys) {
|
|
111
|
-
const result = {};
|
|
112
|
-
keys.forEach(key => {
|
|
113
|
-
if (key in obj) {
|
|
114
|
-
result[key] = obj[key];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
objectOmit(obj, keys) {
|
|
120
|
-
const result = Object.assign({}, obj);
|
|
121
|
-
keys.forEach(key => {
|
|
122
|
-
delete result[key];
|
|
123
|
-
});
|
|
124
|
-
return result;
|
|
125
|
-
}
|
|
126
|
-
isBase64(str) {
|
|
127
|
-
if (str === '' || str.trim() === '') {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
try {
|
|
131
|
-
return btoa(atob(str)) === str;
|
|
132
|
-
}
|
|
133
|
-
catch (err) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
isBase64Image(str) {
|
|
138
|
-
if (str === '' || str.trim() === '') {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
return str.startsWith('data:image/');
|
|
142
|
-
}
|
|
143
|
-
isSpecialEvent(eventKeyword) {
|
|
144
|
-
return config_1.default.SPECIAL_EVENTS.includes(eventKeyword);
|
|
145
|
-
}
|
|
146
|
-
downloadFile(data, filename, type = 'text/plain') {
|
|
147
|
-
const blob = new Blob([data], { type });
|
|
148
|
-
const url = window.URL.createObjectURL(blob);
|
|
149
|
-
const link = document.createElement('a');
|
|
150
|
-
link.href = url;
|
|
151
|
-
link.download = filename;
|
|
152
|
-
document.body.appendChild(link);
|
|
153
|
-
link.click();
|
|
154
|
-
document.body.removeChild(link);
|
|
155
|
-
window.URL.revokeObjectURL(url);
|
|
156
|
-
}
|
|
157
|
-
copyToClipboard(text) {
|
|
158
|
-
if (navigator.clipboard) {
|
|
159
|
-
return navigator.clipboard.writeText(text);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
const textArea = document.createElement('textarea');
|
|
163
|
-
textArea.value = text;
|
|
164
|
-
document.body.appendChild(textArea);
|
|
165
|
-
textArea.focus();
|
|
166
|
-
textArea.select();
|
|
167
|
-
try {
|
|
168
|
-
document.execCommand('copy');
|
|
169
|
-
}
|
|
170
|
-
catch (err) {
|
|
171
|
-
console.error('Error al copiar al portapapeles:', err);
|
|
172
|
-
}
|
|
173
|
-
document.body.removeChild(textArea);
|
|
174
|
-
return Promise.resolve();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
getDeviceInfo() {
|
|
178
|
-
const userAgent = navigator.userAgent;
|
|
179
|
-
return {
|
|
180
|
-
userAgent,
|
|
181
|
-
platform: navigator.platform,
|
|
182
|
-
language: navigator.language,
|
|
183
|
-
cookieEnabled: navigator.cookieEnabled,
|
|
184
|
-
onLine: navigator.onLine,
|
|
185
|
-
screenWidth: screen.width,
|
|
186
|
-
screenHeight: screen.height,
|
|
187
|
-
windowWidth: window.innerWidth,
|
|
188
|
-
windowHeight: window.innerHeight,
|
|
189
|
-
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
isMobile() {
|
|
193
|
-
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
194
|
-
}
|
|
195
|
-
isTablet() {
|
|
196
|
-
return /iPad|Android(?!.*Mobile)/i.test(navigator.userAgent);
|
|
197
|
-
}
|
|
198
|
-
isDesktop() {
|
|
199
|
-
return !this.isMobile() && !this.isTablet();
|
|
200
|
-
}
|
|
201
|
-
getBrowserInfo() {
|
|
202
|
-
var _a, _b, _c, _d;
|
|
203
|
-
const userAgent = navigator.userAgent;
|
|
204
|
-
let browserName = 'Unknown';
|
|
205
|
-
let browserVersion = 'Unknown';
|
|
206
|
-
if (userAgent.indexOf('Chrome') > -1) {
|
|
207
|
-
browserName = 'Chrome';
|
|
208
|
-
browserVersion = ((_a = userAgent.match(/Chrome\/(\d+)/)) === null || _a === void 0 ? void 0 : _a[1]) || 'Unknown';
|
|
209
|
-
}
|
|
210
|
-
else if (userAgent.indexOf('Firefox') > -1) {
|
|
211
|
-
browserName = 'Firefox';
|
|
212
|
-
browserVersion = ((_b = userAgent.match(/Firefox\/(\d+)/)) === null || _b === void 0 ? void 0 : _b[1]) || 'Unknown';
|
|
213
|
-
}
|
|
214
|
-
else if (userAgent.indexOf('Safari') > -1) {
|
|
215
|
-
browserName = 'Safari';
|
|
216
|
-
browserVersion = ((_c = userAgent.match(/Version\/(\d+)/)) === null || _c === void 0 ? void 0 : _c[1]) || 'Unknown';
|
|
217
|
-
}
|
|
218
|
-
else if (userAgent.indexOf('Edge') > -1) {
|
|
219
|
-
browserName = 'Edge';
|
|
220
|
-
browserVersion = ((_d = userAgent.match(/Edge\/(\d+)/)) === null || _d === void 0 ? void 0 : _d[1]) || 'Unknown';
|
|
221
|
-
}
|
|
222
|
-
return {
|
|
223
|
-
name: browserName,
|
|
224
|
-
version: browserVersion,
|
|
225
|
-
userAgent
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
formatBytes(bytes, decimals = 2) {
|
|
229
|
-
if (bytes === 0)
|
|
230
|
-
return '0 Bytes';
|
|
231
|
-
const k = 1024;
|
|
232
|
-
const dm = decimals < 0 ? 0 : decimals;
|
|
233
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
234
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
235
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
236
|
-
}
|
|
237
|
-
parseQueryString(queryString) {
|
|
238
|
-
const params = {};
|
|
239
|
-
const urlParams = new URLSearchParams(queryString);
|
|
240
|
-
for (const [key, value] of urlParams) {
|
|
241
|
-
params[key] = value;
|
|
242
|
-
}
|
|
243
|
-
return params;
|
|
244
|
-
}
|
|
245
|
-
buildQueryString(params) {
|
|
246
|
-
const urlParams = new URLSearchParams();
|
|
247
|
-
for (const [key, value] of Object.entries(params)) {
|
|
248
|
-
if (value !== null && value !== undefined) {
|
|
249
|
-
urlParams.append(key, String(value));
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return urlParams.toString();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
exports.Utils = Utils;
|
|
256
|
-
exports.default = Utils;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Utils = void 0;
|
|
7
|
+
const config_1 = __importDefault(require("../config"));
|
|
8
|
+
class Utils {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.capitalize = (text) => {
|
|
11
|
+
let result = '';
|
|
12
|
+
if (typeof text === 'string') {
|
|
13
|
+
result = text.charAt(0).toUpperCase() + text.slice(1);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
formatDate(date, format = 'YYYY-MM-DD') {
|
|
19
|
+
const year = date.getFullYear();
|
|
20
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
21
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
22
|
+
return format
|
|
23
|
+
.replace('YYYY', year.toString())
|
|
24
|
+
.replace('MM', month)
|
|
25
|
+
.replace('DD', day);
|
|
26
|
+
}
|
|
27
|
+
generateId() {
|
|
28
|
+
return Math.random().toString(36).substr(2, 9);
|
|
29
|
+
}
|
|
30
|
+
debounce(func, wait) {
|
|
31
|
+
let timeout;
|
|
32
|
+
return (...args) => {
|
|
33
|
+
clearTimeout(timeout);
|
|
34
|
+
timeout = setTimeout(() => func.apply(this, args), wait);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
throttle(func, limit) {
|
|
38
|
+
let inThrottle;
|
|
39
|
+
return (...args) => {
|
|
40
|
+
if (!inThrottle) {
|
|
41
|
+
func.apply(this, args);
|
|
42
|
+
inThrottle = true;
|
|
43
|
+
setTimeout(() => inThrottle = false, limit);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
deepClone(obj) {
|
|
48
|
+
if (obj === null || typeof obj !== 'object')
|
|
49
|
+
return obj;
|
|
50
|
+
if (obj instanceof Date)
|
|
51
|
+
return new Date(obj.getTime());
|
|
52
|
+
if (obj instanceof Array)
|
|
53
|
+
return obj.map(item => this.deepClone(item));
|
|
54
|
+
if (typeof obj === 'object') {
|
|
55
|
+
const clonedObj = {};
|
|
56
|
+
for (const key in obj) {
|
|
57
|
+
if (obj.hasOwnProperty(key)) {
|
|
58
|
+
clonedObj[key] = this.deepClone(obj[key]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return clonedObj;
|
|
62
|
+
}
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
isValidEmail(email) {
|
|
66
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
67
|
+
return emailRegex.test(email);
|
|
68
|
+
}
|
|
69
|
+
isValidUrl(url) {
|
|
70
|
+
try {
|
|
71
|
+
new URL(url);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
catch (_a) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
truncateText(text, maxLength, suffix = '...') {
|
|
79
|
+
if (text.length <= maxLength)
|
|
80
|
+
return text;
|
|
81
|
+
return text.substring(0, maxLength - suffix.length) + suffix;
|
|
82
|
+
}
|
|
83
|
+
capitalizeFirst(text) {
|
|
84
|
+
if (!text)
|
|
85
|
+
return text;
|
|
86
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
87
|
+
}
|
|
88
|
+
camelToKebab(str) {
|
|
89
|
+
return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
90
|
+
}
|
|
91
|
+
kebabToCamel(str) {
|
|
92
|
+
return str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
93
|
+
}
|
|
94
|
+
sleep(ms) {
|
|
95
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
96
|
+
}
|
|
97
|
+
getRandomInt(min, max) {
|
|
98
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
99
|
+
}
|
|
100
|
+
arrayChunk(array, size) {
|
|
101
|
+
const chunks = [];
|
|
102
|
+
for (let i = 0; i < array.length; i += size) {
|
|
103
|
+
chunks.push(array.slice(i, i + size));
|
|
104
|
+
}
|
|
105
|
+
return chunks;
|
|
106
|
+
}
|
|
107
|
+
arrayUnique(array) {
|
|
108
|
+
return [...new Set(array)];
|
|
109
|
+
}
|
|
110
|
+
objectPick(obj, keys) {
|
|
111
|
+
const result = {};
|
|
112
|
+
keys.forEach(key => {
|
|
113
|
+
if (key in obj) {
|
|
114
|
+
result[key] = obj[key];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
objectOmit(obj, keys) {
|
|
120
|
+
const result = Object.assign({}, obj);
|
|
121
|
+
keys.forEach(key => {
|
|
122
|
+
delete result[key];
|
|
123
|
+
});
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
isBase64(str) {
|
|
127
|
+
if (str === '' || str.trim() === '') {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
return btoa(atob(str)) === str;
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
isBase64Image(str) {
|
|
138
|
+
if (str === '' || str.trim() === '') {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return str.startsWith('data:image/');
|
|
142
|
+
}
|
|
143
|
+
isSpecialEvent(eventKeyword) {
|
|
144
|
+
return config_1.default.SPECIAL_EVENTS.includes(eventKeyword);
|
|
145
|
+
}
|
|
146
|
+
downloadFile(data, filename, type = 'text/plain') {
|
|
147
|
+
const blob = new Blob([data], { type });
|
|
148
|
+
const url = window.URL.createObjectURL(blob);
|
|
149
|
+
const link = document.createElement('a');
|
|
150
|
+
link.href = url;
|
|
151
|
+
link.download = filename;
|
|
152
|
+
document.body.appendChild(link);
|
|
153
|
+
link.click();
|
|
154
|
+
document.body.removeChild(link);
|
|
155
|
+
window.URL.revokeObjectURL(url);
|
|
156
|
+
}
|
|
157
|
+
copyToClipboard(text) {
|
|
158
|
+
if (navigator.clipboard) {
|
|
159
|
+
return navigator.clipboard.writeText(text);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
const textArea = document.createElement('textarea');
|
|
163
|
+
textArea.value = text;
|
|
164
|
+
document.body.appendChild(textArea);
|
|
165
|
+
textArea.focus();
|
|
166
|
+
textArea.select();
|
|
167
|
+
try {
|
|
168
|
+
document.execCommand('copy');
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
console.error('Error al copiar al portapapeles:', err);
|
|
172
|
+
}
|
|
173
|
+
document.body.removeChild(textArea);
|
|
174
|
+
return Promise.resolve();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
getDeviceInfo() {
|
|
178
|
+
const userAgent = navigator.userAgent;
|
|
179
|
+
return {
|
|
180
|
+
userAgent,
|
|
181
|
+
platform: navigator.platform,
|
|
182
|
+
language: navigator.language,
|
|
183
|
+
cookieEnabled: navigator.cookieEnabled,
|
|
184
|
+
onLine: navigator.onLine,
|
|
185
|
+
screenWidth: screen.width,
|
|
186
|
+
screenHeight: screen.height,
|
|
187
|
+
windowWidth: window.innerWidth,
|
|
188
|
+
windowHeight: window.innerHeight,
|
|
189
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
isMobile() {
|
|
193
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
194
|
+
}
|
|
195
|
+
isTablet() {
|
|
196
|
+
return /iPad|Android(?!.*Mobile)/i.test(navigator.userAgent);
|
|
197
|
+
}
|
|
198
|
+
isDesktop() {
|
|
199
|
+
return !this.isMobile() && !this.isTablet();
|
|
200
|
+
}
|
|
201
|
+
getBrowserInfo() {
|
|
202
|
+
var _a, _b, _c, _d;
|
|
203
|
+
const userAgent = navigator.userAgent;
|
|
204
|
+
let browserName = 'Unknown';
|
|
205
|
+
let browserVersion = 'Unknown';
|
|
206
|
+
if (userAgent.indexOf('Chrome') > -1) {
|
|
207
|
+
browserName = 'Chrome';
|
|
208
|
+
browserVersion = ((_a = userAgent.match(/Chrome\/(\d+)/)) === null || _a === void 0 ? void 0 : _a[1]) || 'Unknown';
|
|
209
|
+
}
|
|
210
|
+
else if (userAgent.indexOf('Firefox') > -1) {
|
|
211
|
+
browserName = 'Firefox';
|
|
212
|
+
browserVersion = ((_b = userAgent.match(/Firefox\/(\d+)/)) === null || _b === void 0 ? void 0 : _b[1]) || 'Unknown';
|
|
213
|
+
}
|
|
214
|
+
else if (userAgent.indexOf('Safari') > -1) {
|
|
215
|
+
browserName = 'Safari';
|
|
216
|
+
browserVersion = ((_c = userAgent.match(/Version\/(\d+)/)) === null || _c === void 0 ? void 0 : _c[1]) || 'Unknown';
|
|
217
|
+
}
|
|
218
|
+
else if (userAgent.indexOf('Edge') > -1) {
|
|
219
|
+
browserName = 'Edge';
|
|
220
|
+
browserVersion = ((_d = userAgent.match(/Edge\/(\d+)/)) === null || _d === void 0 ? void 0 : _d[1]) || 'Unknown';
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
name: browserName,
|
|
224
|
+
version: browserVersion,
|
|
225
|
+
userAgent
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
formatBytes(bytes, decimals = 2) {
|
|
229
|
+
if (bytes === 0)
|
|
230
|
+
return '0 Bytes';
|
|
231
|
+
const k = 1024;
|
|
232
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
233
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
234
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
235
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
236
|
+
}
|
|
237
|
+
parseQueryString(queryString) {
|
|
238
|
+
const params = {};
|
|
239
|
+
const urlParams = new URLSearchParams(queryString);
|
|
240
|
+
for (const [key, value] of urlParams) {
|
|
241
|
+
params[key] = value;
|
|
242
|
+
}
|
|
243
|
+
return params;
|
|
244
|
+
}
|
|
245
|
+
buildQueryString(params) {
|
|
246
|
+
const urlParams = new URLSearchParams();
|
|
247
|
+
for (const [key, value] of Object.entries(params)) {
|
|
248
|
+
if (value !== null && value !== undefined) {
|
|
249
|
+
urlParams.append(key, String(value));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return urlParams.toString();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
exports.Utils = Utils;
|
|
256
|
+
exports.default = Utils;
|
|
257
257
|
//# sourceMappingURL=utils.js.map
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./dist/index.js');
|
|
1
|
+
module.exports = require('./dist/index.js');
|
package/package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "webs-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"private": false,
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist/**/*",
|
|
9
|
-
"types/**/*",
|
|
10
|
-
"index.js"
|
|
11
|
-
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"dev": "next dev --turbopack",
|
|
14
|
-
"build": "tsc --project tsconfig.build.json",
|
|
15
|
-
"build:watch": "tsc --project tsconfig.build.json --watch",
|
|
16
|
-
"prepublishOnly": "npm run build",
|
|
17
|
-
"start": "next start",
|
|
18
|
-
"lint": "next lint"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"mixpanel-browser": "^2.47.0",
|
|
22
|
-
"next": "^15.5.2",
|
|
23
|
-
"react": "^19.0.0",
|
|
24
|
-
"react-dom": "^19.0.0"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@eslint/eslintrc": "^3",
|
|
28
|
-
"@tailwindcss/postcss": "^4",
|
|
29
|
-
"@types/node": "^24.3.0",
|
|
30
|
-
"@types/react": "^19",
|
|
31
|
-
"@types/react-dom": "^19",
|
|
32
|
-
"eslint": "^9",
|
|
33
|
-
"eslint-config-next": "^15.5.2",
|
|
34
|
-
"tailwindcss": "^4",
|
|
35
|
-
"typescript": "^5.9.3"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "webs-sdk",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*",
|
|
9
|
+
"types/**/*",
|
|
10
|
+
"index.js"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "next dev --turbopack",
|
|
14
|
+
"build": "tsc --project tsconfig.build.json",
|
|
15
|
+
"build:watch": "tsc --project tsconfig.build.json --watch",
|
|
16
|
+
"prepublishOnly": "npm run build",
|
|
17
|
+
"start": "next start",
|
|
18
|
+
"lint": "next lint"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"mixpanel-browser": "^2.47.0",
|
|
22
|
+
"next": "^15.5.2",
|
|
23
|
+
"react": "^19.0.0",
|
|
24
|
+
"react-dom": "^19.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@eslint/eslintrc": "^3",
|
|
28
|
+
"@tailwindcss/postcss": "^4",
|
|
29
|
+
"@types/node": "^24.3.0",
|
|
30
|
+
"@types/react": "^19",
|
|
31
|
+
"@types/react-dom": "^19",
|
|
32
|
+
"eslint": "^9",
|
|
33
|
+
"eslint-config-next": "^15.5.2",
|
|
34
|
+
"tailwindcss": "^4",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
|
+
}
|
|
37
|
+
}
|