tnp-core 16.0.15 → 16.0.17
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 +20 -20
- package/assets/shared/shared_folder_info.txt +1 -1
- package/browser/README.md +24 -24
- package/browser/esm2022/lib/core-config.mjs +1 -1
- package/browser/esm2022/lib/core-imports.mjs +10 -5
- package/browser/esm2022/lib/core-models.mjs +87 -2
- package/browser/esm2022/lib/framework-name.mjs +1 -1
- package/browser/esm2022/lib/helpers-isomorphic.mjs +1 -1
- package/browser/esm2022/lib/helpers-messages.mjs +12 -1
- package/browser/esm2022/lib/helpers.mjs +100 -27
- package/browser/esm2022/lib/index.mjs +2 -1
- package/browser/esm2022/lib/node-chalk-mock.mjs +3 -3
- package/browser/esm2022/lib/node-path-mock.mjs +1 -1
- package/browser/esm2022/lib/progress-data.mjs +1 -1
- package/browser/esm2022/lib/utils.mjs +274 -0
- package/browser/fesm2022/tnp-core.mjs +476 -32
- package/browser/fesm2022/tnp-core.mjs.map +1 -1
- package/browser/lib/core-imports.d.ts +4 -1
- package/browser/lib/core-models.d.ts +170 -1
- package/browser/lib/helpers-messages.d.ts +1 -0
- package/browser/lib/helpers.d.ts +24 -4
- package/browser/lib/index.d.ts +1 -0
- package/browser/lib/utils.d.ts +70 -0
- package/cli.backend.js +3 -3
- package/cli.backend.js.map +1 -1
- package/client/README.md +24 -24
- package/client/esm2022/lib/core-config.mjs +1 -1
- package/client/esm2022/lib/core-imports.mjs +10 -5
- package/client/esm2022/lib/core-models.mjs +87 -2
- package/client/esm2022/lib/framework-name.mjs +1 -1
- package/client/esm2022/lib/helpers-isomorphic.mjs +1 -1
- package/client/esm2022/lib/helpers-messages.mjs +12 -1
- package/client/esm2022/lib/helpers.mjs +100 -27
- package/client/esm2022/lib/index.mjs +2 -1
- package/client/esm2022/lib/node-chalk-mock.mjs +3 -3
- package/client/esm2022/lib/node-path-mock.mjs +1 -1
- package/client/esm2022/lib/progress-data.mjs +1 -1
- package/client/esm2022/lib/utils.mjs +274 -0
- package/client/fesm2022/tnp-core.mjs +476 -32
- package/client/fesm2022/tnp-core.mjs.map +1 -1
- package/client/lib/core-imports.d.ts +4 -1
- package/client/lib/core-models.d.ts +170 -1
- package/client/lib/helpers-messages.d.ts +1 -0
- package/client/lib/helpers.d.ts +24 -4
- package/client/lib/index.d.ts +1 -0
- package/client/lib/utils.d.ts +70 -0
- package/client/package.json +15 -8
- package/index.js.map +1 -1
- package/lib/core-config.js.map +1 -1
- package/lib/core-imports.d.ts +6 -2
- package/lib/core-imports.js +12 -6
- package/lib/core-imports.js.map +1 -1
- package/lib/core-models.d.ts +169 -0
- package/lib/core-models.js +88 -0
- package/lib/core-models.js.map +1 -1
- package/lib/framework-name.js.map +1 -1
- package/lib/helpers-isomorphic.js.map +1 -1
- package/lib/helpers-messages.d.ts +1 -0
- package/lib/helpers-messages.js +11 -0
- package/lib/helpers-messages.js.map +1 -1
- package/lib/helpers.d.ts +56 -17
- package/lib/helpers.js +228 -38
- package/lib/helpers.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/node-chalk-mock.js +3 -3
- package/lib/node-chalk-mock.js.map +1 -1
- package/lib/node-path-mock.js +3 -3
- package/lib/node-path-mock.js.map +1 -1
- package/lib/progress-data.js.map +1 -1
- package/lib/public-api.js.map +1 -1
- package/lib/utils.d.ts +79 -0
- package/lib/utils.js +562 -0
- package/lib/utils.js.map +1 -0
- package/package.json +2 -2
- package/package.json_devDependencies.json +202 -202
- package/package.json_tnp.json5 +69 -69
- package/tmp-environment.json +19 -12
- package/websql/README.md +24 -24
- package/websql/esm2022/lib/core-config.mjs +1 -1
- package/websql/esm2022/lib/core-imports.mjs +10 -5
- package/websql/esm2022/lib/core-models.mjs +87 -2
- package/websql/esm2022/lib/framework-name.mjs +1 -1
- package/websql/esm2022/lib/helpers-isomorphic.mjs +1 -1
- package/websql/esm2022/lib/helpers-messages.mjs +12 -1
- package/websql/esm2022/lib/helpers.mjs +100 -27
- package/websql/esm2022/lib/index.mjs +2 -1
- package/websql/esm2022/lib/node-chalk-mock.mjs +3 -3
- package/websql/esm2022/lib/node-path-mock.mjs +1 -1
- package/websql/esm2022/lib/progress-data.mjs +1 -1
- package/websql/esm2022/lib/utils.mjs +274 -0
- package/websql/fesm2022/tnp-core.mjs +476 -32
- package/websql/fesm2022/tnp-core.mjs.map +1 -1
- package/websql/lib/core-imports.d.ts +4 -1
- package/websql/lib/core-models.d.ts +170 -1
- package/websql/lib/helpers-messages.d.ts +1 -0
- package/websql/lib/helpers.d.ts +24 -4
- package/websql/lib/index.d.ts +1 -0
- package/websql/lib/utils.d.ts +70 -0
@@ -7,6 +7,7 @@ export { moment };
|
|
7
7
|
import * as dateformat from 'dateformat';
|
8
8
|
export { dateformat };
|
9
9
|
import { Subject } from 'rxjs';
|
10
|
+
import axios from 'axios';
|
10
11
|
|
11
12
|
let isBrowser = false;
|
12
13
|
isBrowser = true;
|
@@ -467,8 +468,8 @@ const all = Object.keys(allObj).map(key => {
|
|
467
468
|
for (let i = 0; i < all.length; i++) {
|
468
469
|
const e1 = all[i];
|
469
470
|
for (let j = 0; j < all.length; j++) {
|
470
|
-
const e2 = all[j];
|
471
|
-
e1
|
471
|
+
const e2 = all[j]; // @ts-ignore
|
472
|
+
e1[map.get(e2)] = e2;
|
472
473
|
}
|
473
474
|
}
|
474
475
|
const chalk$1 = allObj;
|
@@ -495,7 +496,10 @@ function win32Path(p) {
|
|
495
496
|
}
|
496
497
|
return path.win32.normalize(p);
|
497
498
|
}
|
498
|
-
|
499
|
+
/**
|
500
|
+
* This funciton will replace // to /
|
501
|
+
*/
|
502
|
+
const crossPlatformPath = (pathStringOrPathParts) => {
|
499
503
|
if (Array.isArray(pathStringOrPathParts)) {
|
500
504
|
pathStringOrPathParts = pathStringOrPathParts.join('/');
|
501
505
|
}
|
@@ -509,12 +513,98 @@ function crossPlatformPath(pathStringOrPathParts) {
|
|
509
513
|
const isExtendedLengthPath = /^\\\\\?\\/.test(pathStringOrPathParts);
|
510
514
|
const hasNonAscii = /[^\u0000-\u0080]+/.test(pathStringOrPathParts); // eslint-disable-line no-control-regex
|
511
515
|
if (isExtendedLengthPath || hasNonAscii) {
|
512
|
-
return pathStringOrPathParts;
|
516
|
+
return pathStringOrPathParts?.replace(/\/\//g, '/');
|
513
517
|
}
|
514
|
-
return pathStringOrPathParts.replace(/\\/g, '/');
|
515
|
-
}
|
518
|
+
return pathStringOrPathParts.replace(/\\/g, '/').replace(/\/\//g, '/');
|
519
|
+
};
|
516
520
|
({}); // @--end-of-file-for-module=tnp-core lib/core-imports.ts
|
517
521
|
|
522
|
+
const mimeTypes = {
|
523
|
+
".aac": "audio/aac",
|
524
|
+
".abw": "application/x-abiword",
|
525
|
+
".arc": "application/x-freearc",
|
526
|
+
".avi": "video/x-msvideo",
|
527
|
+
".azw": "application/vnd.amazon.ebook",
|
528
|
+
".bin": "application/octet-stream",
|
529
|
+
".bmp": "image/bmp",
|
530
|
+
".bz": "application/x-bzip",
|
531
|
+
".bz2": "application/x-bzip2",
|
532
|
+
".csh": "application/x-csh",
|
533
|
+
".css": "text/css",
|
534
|
+
".csv": "text/csv",
|
535
|
+
".doc": "application/msword",
|
536
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
537
|
+
".eot": "application/vnd.ms-fontobject",
|
538
|
+
".epub": "application/epub+zip",
|
539
|
+
".gz": "application/gzip",
|
540
|
+
".gif": "image/gif",
|
541
|
+
".htm": "text/html",
|
542
|
+
".html": "text/html",
|
543
|
+
".ico": "image/vnd.microsoft.icon",
|
544
|
+
".ics": "text/calendar",
|
545
|
+
".jar": "application/java-archive",
|
546
|
+
".jpeg": "image/jpeg",
|
547
|
+
".jpg": "image/jpeg",
|
548
|
+
".js": "text/javascript",
|
549
|
+
".json": "application/json",
|
550
|
+
".jsonld": "application/ld+json",
|
551
|
+
".mid": "application/midi",
|
552
|
+
".midi": "application/midi",
|
553
|
+
".mjs": "text/javascript",
|
554
|
+
".mp3": "audio/mpeg",
|
555
|
+
".mp4": "video/mp4",
|
556
|
+
".mpeg": "video/mpeg",
|
557
|
+
".mpkg": "application/vnd.apple.installer+xml",
|
558
|
+
".odp": "application/vnd.oasis.opendocument.presentation",
|
559
|
+
".ods": "application/vnd.oasis.opendocument.spreadsheet",
|
560
|
+
".odt": "application/vnd.oasis.opendocument.text",
|
561
|
+
".oga": "audio/ogg",
|
562
|
+
".ogg": "audio/ogg",
|
563
|
+
".ogv": "video/ogg",
|
564
|
+
".ogx": "application/ogg",
|
565
|
+
".opus": "audio/opus",
|
566
|
+
".otf": "font/otf",
|
567
|
+
".png": "image/png",
|
568
|
+
".pdf": "application/pdf",
|
569
|
+
".php": "application/php",
|
570
|
+
".ppt": "application/vnd.ms-powerpoint",
|
571
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
572
|
+
".rar": "application/vnd.rar",
|
573
|
+
".rtf": "application/rtf",
|
574
|
+
".sh": "application/x-sh",
|
575
|
+
".svg": "image/svg+xml",
|
576
|
+
".swf": "application/x-shockwave-flash",
|
577
|
+
".tar": "application/x-tar",
|
578
|
+
".tif": "image/tiff",
|
579
|
+
".tiff": "image/tiff",
|
580
|
+
".ts": "video/mp2t",
|
581
|
+
".ttf": "font/ttf",
|
582
|
+
".txt": "text/plain",
|
583
|
+
".vsd": "application/vnd.visio",
|
584
|
+
".wav": "audio/wav",
|
585
|
+
".weba": "audio/webm",
|
586
|
+
".webm": "video/webm",
|
587
|
+
".webp": "image/webp",
|
588
|
+
".woff": "font/woff",
|
589
|
+
".woff2": "font/woff2",
|
590
|
+
".xhtml": "application/xhtml+xml",
|
591
|
+
".xls": "application/vnd.ms-excel",
|
592
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
593
|
+
".xml": "application/xml",
|
594
|
+
".xul": "application/vnd.mozilla.xul+xml",
|
595
|
+
".zip": "application/zip",
|
596
|
+
".3gp": "video/3gpp",
|
597
|
+
".3g2": "video/3gpp2",
|
598
|
+
".7z": "application/x-7z-compressed"
|
599
|
+
};
|
600
|
+
const MediaTypeAllArr = [
|
601
|
+
'text', 'image', 'audio', 'video', 'font',
|
602
|
+
'application', 'multipart', 'message', 'model'
|
603
|
+
];
|
604
|
+
var Files;
|
605
|
+
(function (Files) {
|
606
|
+
Files.MimeTypesObj = mimeTypes;
|
607
|
+
})(Files || (Files = {}));
|
518
608
|
;
|
519
609
|
({}); // @--end-of-file-for-module=tnp-core lib/core-models.ts
|
520
610
|
|
@@ -554,6 +644,10 @@ class HelpersIsomorphic {
|
|
554
644
|
;
|
555
645
|
({}); // @--end-of-file-for-module=tnp-core lib/helpers-isomorphic.ts
|
556
646
|
|
647
|
+
/* */
|
648
|
+
/* */
|
649
|
+
/* */
|
650
|
+
/* */
|
557
651
|
/* */
|
558
652
|
/* */
|
559
653
|
/* */
|
@@ -615,6 +709,13 @@ class HelpersMessages extends HelpersIsomorphic {
|
|
615
709
|
/* */
|
616
710
|
/* */
|
617
711
|
}
|
712
|
+
renderError(err) {
|
713
|
+
/* */
|
714
|
+
/* */
|
715
|
+
/* */
|
716
|
+
/* */
|
717
|
+
console.error(err);
|
718
|
+
}
|
618
719
|
error(details, noExit = false, noTrace = false) {
|
619
720
|
if (Helpers.isBrowser) {
|
620
721
|
console.error(details);
|
@@ -1051,6 +1152,8 @@ function transformData(details) {
|
|
1051
1152
|
({}); // @--end-of-file-for-module=tnp-core lib/helpers-messages.ts
|
1052
1153
|
|
1053
1154
|
const encoding = 'utf8';
|
1155
|
+
/* */
|
1156
|
+
/* */
|
1054
1157
|
const WEBSQL_PROC_MOCK_PROCESSES_PID = {};
|
1055
1158
|
const WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
|
1056
1159
|
class HelpersCore extends HelpersMessages {
|
@@ -1060,38 +1163,72 @@ class HelpersCore extends HelpersMessages {
|
|
1060
1163
|
}
|
1061
1164
|
return HelpersCore._instanceCore;
|
1062
1165
|
}
|
1166
|
+
/* */
|
1167
|
+
/* */
|
1168
|
+
/* */
|
1169
|
+
/* */
|
1170
|
+
/* */
|
1171
|
+
/* */
|
1172
|
+
/* */
|
1173
|
+
/* */
|
1174
|
+
/* */
|
1175
|
+
/* */
|
1176
|
+
/* */
|
1063
1177
|
constructor() {
|
1064
1178
|
super();
|
1065
1179
|
/* */
|
1066
1180
|
/* */
|
1067
|
-
/* */
|
1068
|
-
/* */
|
1069
|
-
/* */
|
1070
|
-
/* */
|
1071
|
-
/* */
|
1072
|
-
/* */
|
1073
|
-
/* */
|
1074
|
-
/* */
|
1075
|
-
/* */
|
1076
|
-
/* */
|
1077
|
-
/* */
|
1078
|
-
/* */
|
1079
|
-
/* */
|
1080
|
-
/* */
|
1081
|
-
/* */
|
1082
|
-
/* */
|
1083
|
-
/* */
|
1084
|
-
/* */
|
1085
|
-
/* */
|
1086
|
-
/* */
|
1087
1181
|
this.bigMaxBuffer = 2024 * 500;
|
1088
1182
|
/* */
|
1089
1183
|
/* */
|
1090
1184
|
/* */
|
1091
1185
|
}
|
1186
|
+
mediaTypeFromSrc(src) {
|
1187
|
+
const ext = path.extname(src);
|
1188
|
+
const media = mimeTypes[ext];
|
1189
|
+
return _.first(media?.split('/'));
|
1190
|
+
}
|
1191
|
+
/* */
|
1192
|
+
/* */
|
1193
|
+
/* */
|
1194
|
+
/* */
|
1195
|
+
/* */
|
1196
|
+
/* */
|
1197
|
+
/* */
|
1198
|
+
/* */
|
1199
|
+
/* */
|
1200
|
+
/* */
|
1201
|
+
/* */
|
1202
|
+
/* */
|
1203
|
+
/* */
|
1204
|
+
/* */
|
1205
|
+
/* */
|
1206
|
+
/* */
|
1207
|
+
/* */
|
1208
|
+
/* */
|
1209
|
+
/* */
|
1210
|
+
/* */
|
1211
|
+
/* */
|
1212
|
+
/* */
|
1213
|
+
/**
|
1214
|
+
* check if data is nodejs/browser blob
|
1215
|
+
*
|
1216
|
+
* @param maybeBlob
|
1217
|
+
* @returns
|
1218
|
+
*/
|
1092
1219
|
isBlob(maybeBlob) {
|
1093
1220
|
return maybeBlob instanceof Blob; // || toString.call(maybeBlob) === '[object Blob]';
|
1094
1221
|
}
|
1222
|
+
/**
|
1223
|
+
* Check if data is nodejs buffer
|
1224
|
+
*
|
1225
|
+
* @param maybeNodejsBuffer
|
1226
|
+
* @returns
|
1227
|
+
*/
|
1228
|
+
/* */
|
1229
|
+
/* */
|
1230
|
+
/* */
|
1231
|
+
/* */
|
1095
1232
|
removeSlashAtEnd(s) {
|
1096
1233
|
s = s?.endsWith(`/`) ? s.slice(0, s.length - 1) : s;
|
1097
1234
|
return s;
|
@@ -1100,12 +1237,15 @@ class HelpersCore extends HelpersMessages {
|
|
1100
1237
|
s = s?.startsWith(`/`) ? s.slice(1) : s;
|
1101
1238
|
return s;
|
1102
1239
|
}
|
1240
|
+
/**
|
1241
|
+
* stringify to pretty json string
|
1242
|
+
*/
|
1103
1243
|
stringify(inputObject) {
|
1104
1244
|
return JSON.stringify(inputObject, null, 2);
|
1105
1245
|
}
|
1106
1246
|
async runSyncOrAsync(fnOrOptions, ...firstArg) {
|
1107
1247
|
if (_.isUndefined(fnOrOptions)) {
|
1108
|
-
return;
|
1248
|
+
return void 0;
|
1109
1249
|
}
|
1110
1250
|
let promisOrValue;
|
1111
1251
|
const optionsMode = _.isObject(fnOrOptions)
|
@@ -1341,10 +1481,6 @@ class HelpersCore extends HelpersMessages {
|
|
1341
1481
|
/* */
|
1342
1482
|
/* */
|
1343
1483
|
/* */
|
1344
|
-
/* */
|
1345
|
-
/* */
|
1346
|
-
/* */
|
1347
|
-
/* */
|
1348
1484
|
/**
|
1349
1485
|
* symlink may have existed or unexisted destiantion url
|
1350
1486
|
* @param destUrl M
|
@@ -1446,6 +1582,7 @@ class HelpersCore extends HelpersMessages {
|
|
1446
1582
|
/* */
|
1447
1583
|
/* */
|
1448
1584
|
/* */
|
1585
|
+
/* */
|
1449
1586
|
exists(folderOrFilePath) {
|
1450
1587
|
/* */
|
1451
1588
|
/* */
|
@@ -1468,6 +1605,9 @@ class HelpersCore extends HelpersMessages {
|
|
1468
1605
|
/* */
|
1469
1606
|
return (void 0);
|
1470
1607
|
}
|
1608
|
+
/**
|
1609
|
+
* this is HACK for running procesess inside processes
|
1610
|
+
*/
|
1471
1611
|
_fixCommand(command) {
|
1472
1612
|
if ((command.startsWith('tnp ') || command.startsWith('firedev ')) // TODO every cli projects here that uses run and need to kill process easly!
|
1473
1613
|
&&
|
@@ -1532,6 +1672,11 @@ class HelpersCore extends HelpersMessages {
|
|
1532
1672
|
/* */
|
1533
1673
|
/* */
|
1534
1674
|
/* */
|
1675
|
+
/* */
|
1676
|
+
/* */
|
1677
|
+
/* */
|
1678
|
+
/* */
|
1679
|
+
/* */
|
1535
1680
|
};
|
1536
1681
|
}
|
1537
1682
|
wait(second) {
|
@@ -1611,6 +1756,11 @@ class HelpersCore extends HelpersMessages {
|
|
1611
1756
|
/* */
|
1612
1757
|
/* */
|
1613
1758
|
/* */
|
1759
|
+
/* */
|
1760
|
+
/* */
|
1761
|
+
/* */
|
1762
|
+
/* */
|
1763
|
+
/* */
|
1614
1764
|
killProcess(byPid) {
|
1615
1765
|
/* */
|
1616
1766
|
/* */
|
@@ -1671,6 +1821,9 @@ class HelpersCore extends HelpersMessages {
|
|
1671
1821
|
/* */
|
1672
1822
|
/* */
|
1673
1823
|
/* */
|
1824
|
+
/* */
|
1825
|
+
/* */
|
1826
|
+
/* */
|
1674
1827
|
async(detach = false, mockFun) {
|
1675
1828
|
if (mockFun) {
|
1676
1829
|
const subStdoutSub = new Subject();
|
@@ -1749,6 +1902,7 @@ class HelpersCore extends HelpersMessages {
|
|
1749
1902
|
/* */
|
1750
1903
|
/* */
|
1751
1904
|
/* */
|
1905
|
+
/* */
|
1752
1906
|
return (void 0);
|
1753
1907
|
},
|
1754
1908
|
/* */
|
@@ -1843,6 +1997,8 @@ class HelpersCore extends HelpersMessages {
|
|
1843
1997
|
/* */
|
1844
1998
|
/* */
|
1845
1999
|
/* */
|
2000
|
+
/* */
|
2001
|
+
/* */
|
1846
2002
|
};
|
1847
2003
|
}
|
1848
2004
|
/* */
|
@@ -2205,14 +2361,31 @@ class HelpersCore extends HelpersMessages {
|
|
2205
2361
|
/* */
|
2206
2362
|
/* */
|
2207
2363
|
/* */
|
2364
|
+
/* */
|
2365
|
+
/* */
|
2366
|
+
/* */
|
2367
|
+
/* */
|
2368
|
+
/* */
|
2369
|
+
/* */
|
2370
|
+
/* */
|
2371
|
+
/* */
|
2372
|
+
/* */
|
2373
|
+
/* */
|
2374
|
+
/* */
|
2375
|
+
/* */
|
2376
|
+
/* */
|
2377
|
+
/* */
|
2378
|
+
/* */
|
2208
2379
|
/**
|
2209
2380
|
* Quick fix for object values
|
2381
|
+
* @deprecated
|
2210
2382
|
*/
|
2211
2383
|
values(obj) {
|
2212
2384
|
if (_.isObject(obj) && !Array.isArray(obj)) {
|
2213
2385
|
const values = [];
|
2214
2386
|
for (const key in obj) {
|
2215
2387
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
2388
|
+
// @ts-ignore
|
2216
2389
|
values.push(obj[key]);
|
2217
2390
|
}
|
2218
2391
|
}
|
@@ -2281,6 +2454,277 @@ class PROGRESS_DATA {
|
|
2281
2454
|
;
|
2282
2455
|
({}); // @--end-of-file-for-module=tnp-core lib/progress-data.ts
|
2283
2456
|
|
2457
|
+
/* */
|
2458
|
+
/* */
|
2459
|
+
const BLOB_SUPPORTED_IN_SQLJS = false;
|
2460
|
+
var Utils;
|
2461
|
+
(function (Utils) {
|
2462
|
+
let DbBinaryFormatEnum;
|
2463
|
+
(function (DbBinaryFormatEnum) {
|
2464
|
+
DbBinaryFormatEnum["Blob"] = "Blob";
|
2465
|
+
DbBinaryFormatEnum["File"] = "File";
|
2466
|
+
DbBinaryFormatEnum["string"] = "string";
|
2467
|
+
/* */
|
2468
|
+
/* */
|
2469
|
+
})(DbBinaryFormatEnum = Utils.DbBinaryFormatEnum || (Utils.DbBinaryFormatEnum = {}));
|
2470
|
+
/* */
|
2471
|
+
/* */
|
2472
|
+
let binary;
|
2473
|
+
(function (binary) {
|
2474
|
+
/**
|
2475
|
+
* This is for BROWSER ONLY
|
2476
|
+
*
|
2477
|
+
* @param buffer
|
2478
|
+
* @param contentType
|
2479
|
+
* @returns
|
2480
|
+
*/
|
2481
|
+
async function arrayBufferToBlob(buffer, contentType) {
|
2482
|
+
// @ts-ignore
|
2483
|
+
return new Blob([buffer], { type: contentType });
|
2484
|
+
}
|
2485
|
+
binary.arrayBufferToBlob = arrayBufferToBlob;
|
2486
|
+
/**
|
2487
|
+
* This is for BROWSER ONLY
|
2488
|
+
* @param blob
|
2489
|
+
* @returns
|
2490
|
+
*/
|
2491
|
+
async function blobToArrayBuffer(blob) {
|
2492
|
+
return await new Promise((resolve, reject) => {
|
2493
|
+
const reader = new FileReader();
|
2494
|
+
reader.addEventListener('loadend', () => {
|
2495
|
+
resolve(reader.result);
|
2496
|
+
});
|
2497
|
+
reader.addEventListener('error', reject); // @ts-ignore
|
2498
|
+
reader.readAsArrayBuffer(blob);
|
2499
|
+
});
|
2500
|
+
}
|
2501
|
+
binary.blobToArrayBuffer = blobToArrayBuffer;
|
2502
|
+
/**
|
2503
|
+
* it is revers to base64toBlob
|
2504
|
+
* @param blob
|
2505
|
+
* @returns
|
2506
|
+
*/
|
2507
|
+
function blobToBase64(blob) {
|
2508
|
+
return new Promise((resolve, _) => {
|
2509
|
+
const reader = new FileReader();
|
2510
|
+
reader.onloadend = () => resolve(reader.result); // @ts-ignore
|
2511
|
+
reader.readAsDataURL(blob);
|
2512
|
+
});
|
2513
|
+
}
|
2514
|
+
binary.blobToBase64 = blobToBase64;
|
2515
|
+
/**
|
2516
|
+
* it is revers to blobToBase64()
|
2517
|
+
* @param base64Data
|
2518
|
+
* @returns
|
2519
|
+
*/
|
2520
|
+
async function base64toBlob(base64Data, contentTypeOverride) {
|
2521
|
+
let content_type = void 0;
|
2522
|
+
let file_base64 = void 0;
|
2523
|
+
if (!contentTypeOverride) {
|
2524
|
+
const m = /^data:(.+?);base64,(.+)$/.exec(base64Data);
|
2525
|
+
if (!m) {
|
2526
|
+
throw new Error(`[firedev-framework][base64toBlob] Not a base64 blob [${base64Data}]`);
|
2527
|
+
}
|
2528
|
+
var [__, contenttype, filebase64] = m;
|
2529
|
+
content_type = contenttype;
|
2530
|
+
file_base64 = filebase64;
|
2531
|
+
}
|
2532
|
+
content_type = (contentTypeOverride ? contentTypeOverride : content_type || '');
|
2533
|
+
base64Data = contentTypeOverride ? base64Data : file_base64;
|
2534
|
+
const sliceSize = 1024;
|
2535
|
+
const byteCharacters = atob(base64Data);
|
2536
|
+
const bytesLength = byteCharacters.length;
|
2537
|
+
const slicesCount = Math.ceil(bytesLength / sliceSize);
|
2538
|
+
const byteArrays = new Array(slicesCount);
|
2539
|
+
for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
2540
|
+
const begin = sliceIndex * sliceSize;
|
2541
|
+
const end = Math.min(begin + sliceSize, bytesLength);
|
2542
|
+
const bytes = new Array(end - begin);
|
2543
|
+
for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
|
2544
|
+
bytes[i] = byteCharacters[offset].charCodeAt(0);
|
2545
|
+
}
|
2546
|
+
byteArrays[sliceIndex] = new Uint8Array(bytes);
|
2547
|
+
}
|
2548
|
+
return new Blob(byteArrays, { type: content_type });
|
2549
|
+
}
|
2550
|
+
binary.base64toBlob = base64toBlob;
|
2551
|
+
async function base64toDbBinaryFormat(text) {
|
2552
|
+
let result;
|
2553
|
+
result = await (async () => {
|
2554
|
+
if (BLOB_SUPPORTED_IN_SQLJS) {
|
2555
|
+
const blob = await base64toBlob(text);
|
2556
|
+
return blob;
|
2557
|
+
}
|
2558
|
+
return text;
|
2559
|
+
})();
|
2560
|
+
/* */
|
2561
|
+
/* */
|
2562
|
+
/* */
|
2563
|
+
/* */
|
2564
|
+
/* */
|
2565
|
+
return result;
|
2566
|
+
}
|
2567
|
+
binary.base64toDbBinaryFormat = base64toDbBinaryFormat;
|
2568
|
+
async function dbBinaryFormatToBase64(binaryFormat) {
|
2569
|
+
let result;
|
2570
|
+
result = await (async () => {
|
2571
|
+
if (BLOB_SUPPORTED_IN_SQLJS) {
|
2572
|
+
const text = await blobToBase64(binaryFormat);
|
2573
|
+
return text;
|
2574
|
+
}
|
2575
|
+
return binaryFormat;
|
2576
|
+
})();
|
2577
|
+
/* */
|
2578
|
+
/* */
|
2579
|
+
/* */
|
2580
|
+
/* */
|
2581
|
+
/* */
|
2582
|
+
return result;
|
2583
|
+
}
|
2584
|
+
binary.dbBinaryFormatToBase64 = dbBinaryFormatToBase64;
|
2585
|
+
async function textToDbBinaryFormat(text) {
|
2586
|
+
let result;
|
2587
|
+
result = await (async () => {
|
2588
|
+
if (BLOB_SUPPORTED_IN_SQLJS) {
|
2589
|
+
const blob = await textToBlob(text);
|
2590
|
+
return blob;
|
2591
|
+
}
|
2592
|
+
return text;
|
2593
|
+
})();
|
2594
|
+
/* */
|
2595
|
+
/* */
|
2596
|
+
/* */
|
2597
|
+
/* */
|
2598
|
+
/* */
|
2599
|
+
return result;
|
2600
|
+
}
|
2601
|
+
binary.textToDbBinaryFormat = textToDbBinaryFormat;
|
2602
|
+
async function dbBinaryFormatToText(binaryFormat) {
|
2603
|
+
let result;
|
2604
|
+
result = await (async () => {
|
2605
|
+
if (BLOB_SUPPORTED_IN_SQLJS) {
|
2606
|
+
const text = await blobToText(binaryFormat);
|
2607
|
+
return text;
|
2608
|
+
}
|
2609
|
+
return binaryFormat;
|
2610
|
+
})();
|
2611
|
+
/* */
|
2612
|
+
/* */
|
2613
|
+
/* */
|
2614
|
+
/* */
|
2615
|
+
/* */
|
2616
|
+
return result;
|
2617
|
+
}
|
2618
|
+
binary.dbBinaryFormatToText = dbBinaryFormatToText;
|
2619
|
+
/* */
|
2620
|
+
/* */
|
2621
|
+
/* */
|
2622
|
+
/* */
|
2623
|
+
/* */
|
2624
|
+
/* */
|
2625
|
+
/* */
|
2626
|
+
/* */
|
2627
|
+
/* */
|
2628
|
+
/* */
|
2629
|
+
/* */
|
2630
|
+
/* */
|
2631
|
+
async function fileToBlob(file) {
|
2632
|
+
return new Blob([new Uint8Array(await file.arrayBuffer())], { type: file.type });
|
2633
|
+
}
|
2634
|
+
binary.fileToBlob = fileToBlob;
|
2635
|
+
;
|
2636
|
+
async function blobToFile(blob, nameForFile = 'my-file-name') {
|
2637
|
+
if (!nameForFile) {
|
2638
|
+
nameForFile = 'nonamefile' + (new Date()).getTime();
|
2639
|
+
}
|
2640
|
+
;
|
2641
|
+
// @ts-ignore
|
2642
|
+
return new File([blob], nameForFile);
|
2643
|
+
}
|
2644
|
+
binary.blobToFile = blobToFile;
|
2645
|
+
/* */
|
2646
|
+
/* */
|
2647
|
+
/* */
|
2648
|
+
/* */
|
2649
|
+
/* */
|
2650
|
+
/* */
|
2651
|
+
/* */
|
2652
|
+
/* */
|
2653
|
+
/* */
|
2654
|
+
/* */
|
2655
|
+
/* */
|
2656
|
+
/* */
|
2657
|
+
/* */
|
2658
|
+
/* */
|
2659
|
+
/* */
|
2660
|
+
/* */
|
2661
|
+
/* */
|
2662
|
+
/* */
|
2663
|
+
/* */
|
2664
|
+
/* */
|
2665
|
+
/* */
|
2666
|
+
/* */
|
2667
|
+
/* */
|
2668
|
+
async function textToBlob(text, type = 'text/plain') {
|
2669
|
+
const blob = new Blob([text], { type });
|
2670
|
+
return blob;
|
2671
|
+
}
|
2672
|
+
binary.textToBlob = textToBlob;
|
2673
|
+
async function blobToText(blob) {
|
2674
|
+
return await blob.text();
|
2675
|
+
}
|
2676
|
+
binary.blobToText = blobToText;
|
2677
|
+
async function textToFile(text, fileRelativePathOrName) {
|
2678
|
+
const ext = path.extname(fileRelativePathOrName);
|
2679
|
+
const type = mimeTypes[ext];
|
2680
|
+
const blob = new Blob([text], { type });
|
2681
|
+
const file = await blobToFile(blob, fileRelativePathOrName);
|
2682
|
+
return file;
|
2683
|
+
}
|
2684
|
+
binary.textToFile = textToFile;
|
2685
|
+
async function fileToText(file) {
|
2686
|
+
return await file.text();
|
2687
|
+
}
|
2688
|
+
binary.fileToText = fileToText;
|
2689
|
+
async function jsonToBlob(jsonObj) {
|
2690
|
+
const blob = new Blob([JSON.stringify(jsonObj, null, 2)], { type: 'application/json' });
|
2691
|
+
return blob;
|
2692
|
+
}
|
2693
|
+
binary.jsonToBlob = jsonToBlob;
|
2694
|
+
/**
|
2695
|
+
* TODO NOT TESTED
|
2696
|
+
*/
|
2697
|
+
async function blobToJson(blob) {
|
2698
|
+
return JSON.parse(await blob.text());
|
2699
|
+
}
|
2700
|
+
binary.blobToJson = blobToJson;
|
2701
|
+
async function getBlobFrom(url) {
|
2702
|
+
const response = await axios({
|
2703
|
+
url,
|
2704
|
+
method: 'get',
|
2705
|
+
responseType: 'blob'
|
2706
|
+
});
|
2707
|
+
return response.data;
|
2708
|
+
}
|
2709
|
+
binary.getBlobFrom = getBlobFrom;
|
2710
|
+
})(binary = Utils.binary || (Utils.binary = {}));
|
2711
|
+
let css;
|
2712
|
+
(function (css) {
|
2713
|
+
/**
|
2714
|
+
*
|
2715
|
+
* @param pixelsCss pixels ex. 100px
|
2716
|
+
* @returns
|
2717
|
+
*/
|
2718
|
+
function numValue(pixelsCss) {
|
2719
|
+
return parseInt(pixelsCss
|
2720
|
+
.replace('px', ''));
|
2721
|
+
}
|
2722
|
+
css.numValue = numValue;
|
2723
|
+
})(css = Utils.css || (Utils.css = {}));
|
2724
|
+
})(Utils || (Utils = {}));
|
2725
|
+
;
|
2726
|
+
({}); // @--end-of-file-for-module=tnp-core lib/utils.ts
|
2727
|
+
|
2284
2728
|
let Helpers = HelpersCore.InstanceCore;
|
2285
2729
|
;
|
2286
2730
|
({}); // @--end-of-file-for-module=tnp-core lib/index.ts
|
@@ -2289,5 +2733,5 @@ let Helpers = HelpersCore.InstanceCore;
|
|
2289
2733
|
* Generated bundle index. Do not edit.
|
2290
2734
|
*/
|
2291
2735
|
|
2292
|
-
export { CoreConfig, HelpersCore as CoreHelpers, Helpers, PROGRESS_DATA, chalk, crossPlatformPath, frameworkName, frameworkNameBe, path, win32Path };
|
2736
|
+
export { CoreConfig, HelpersCore as CoreHelpers, Files, Helpers, MediaTypeAllArr, PROGRESS_DATA, Utils, chalk, crossPlatformPath, frameworkName, frameworkNameBe, mimeTypes, path, win32Path };
|
2293
2737
|
//# sourceMappingURL=tnp-core.mjs.map
|