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
|
|
@@ -553,6 +643,10 @@ class HelpersIsomorphic {
|
|
553
643
|
;
|
554
644
|
({}); // @--end-of-file-for-module=tnp-core lib/helpers-isomorphic.ts
|
555
645
|
|
646
|
+
/* */
|
647
|
+
/* */
|
648
|
+
/* */
|
649
|
+
/* */
|
556
650
|
/* */
|
557
651
|
/* */
|
558
652
|
/* */
|
@@ -614,6 +708,13 @@ class HelpersMessages extends HelpersIsomorphic {
|
|
614
708
|
/* */
|
615
709
|
/* */
|
616
710
|
}
|
711
|
+
renderError(err) {
|
712
|
+
/* */
|
713
|
+
/* */
|
714
|
+
/* */
|
715
|
+
/* */
|
716
|
+
console.error(err);
|
717
|
+
}
|
617
718
|
error(details, noExit = false, noTrace = false) {
|
618
719
|
if (Helpers.isBrowser) {
|
619
720
|
console.error(details);
|
@@ -1050,6 +1151,8 @@ function transformData(details) {
|
|
1050
1151
|
({}); // @--end-of-file-for-module=tnp-core lib/helpers-messages.ts
|
1051
1152
|
|
1052
1153
|
const encoding = 'utf8';
|
1154
|
+
/* */
|
1155
|
+
/* */
|
1053
1156
|
const WEBSQL_PROC_MOCK_PROCESSES_PID = {};
|
1054
1157
|
const WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
|
1055
1158
|
class HelpersCore extends HelpersMessages {
|
@@ -1059,38 +1162,72 @@ class HelpersCore extends HelpersMessages {
|
|
1059
1162
|
}
|
1060
1163
|
return HelpersCore._instanceCore;
|
1061
1164
|
}
|
1165
|
+
/* */
|
1166
|
+
/* */
|
1167
|
+
/* */
|
1168
|
+
/* */
|
1169
|
+
/* */
|
1170
|
+
/* */
|
1171
|
+
/* */
|
1172
|
+
/* */
|
1173
|
+
/* */
|
1174
|
+
/* */
|
1175
|
+
/* */
|
1062
1176
|
constructor() {
|
1063
1177
|
super();
|
1064
1178
|
/* */
|
1065
1179
|
/* */
|
1066
|
-
/* */
|
1067
|
-
/* */
|
1068
|
-
/* */
|
1069
|
-
/* */
|
1070
|
-
/* */
|
1071
|
-
/* */
|
1072
|
-
/* */
|
1073
|
-
/* */
|
1074
|
-
/* */
|
1075
|
-
/* */
|
1076
|
-
/* */
|
1077
|
-
/* */
|
1078
|
-
/* */
|
1079
|
-
/* */
|
1080
|
-
/* */
|
1081
|
-
/* */
|
1082
|
-
/* */
|
1083
|
-
/* */
|
1084
|
-
/* */
|
1085
|
-
/* */
|
1086
1180
|
this.bigMaxBuffer = 2024 * 500;
|
1087
1181
|
/* */
|
1088
1182
|
/* */
|
1089
1183
|
/* */
|
1090
1184
|
}
|
1185
|
+
mediaTypeFromSrc(src) {
|
1186
|
+
const ext = path.extname(src);
|
1187
|
+
const media = mimeTypes[ext];
|
1188
|
+
return _.first(media?.split('/'));
|
1189
|
+
}
|
1190
|
+
/* */
|
1191
|
+
/* */
|
1192
|
+
/* */
|
1193
|
+
/* */
|
1194
|
+
/* */
|
1195
|
+
/* */
|
1196
|
+
/* */
|
1197
|
+
/* */
|
1198
|
+
/* */
|
1199
|
+
/* */
|
1200
|
+
/* */
|
1201
|
+
/* */
|
1202
|
+
/* */
|
1203
|
+
/* */
|
1204
|
+
/* */
|
1205
|
+
/* */
|
1206
|
+
/* */
|
1207
|
+
/* */
|
1208
|
+
/* */
|
1209
|
+
/* */
|
1210
|
+
/* */
|
1211
|
+
/* */
|
1212
|
+
/**
|
1213
|
+
* check if data is nodejs/browser blob
|
1214
|
+
*
|
1215
|
+
* @param maybeBlob
|
1216
|
+
* @returns
|
1217
|
+
*/
|
1091
1218
|
isBlob(maybeBlob) {
|
1092
1219
|
return maybeBlob instanceof Blob; // || toString.call(maybeBlob) === '[object Blob]';
|
1093
1220
|
}
|
1221
|
+
/**
|
1222
|
+
* Check if data is nodejs buffer
|
1223
|
+
*
|
1224
|
+
* @param maybeNodejsBuffer
|
1225
|
+
* @returns
|
1226
|
+
*/
|
1227
|
+
/* */
|
1228
|
+
/* */
|
1229
|
+
/* */
|
1230
|
+
/* */
|
1094
1231
|
removeSlashAtEnd(s) {
|
1095
1232
|
s = s?.endsWith(`/`) ? s.slice(0, s.length - 1) : s;
|
1096
1233
|
return s;
|
@@ -1099,12 +1236,15 @@ class HelpersCore extends HelpersMessages {
|
|
1099
1236
|
s = s?.startsWith(`/`) ? s.slice(1) : s;
|
1100
1237
|
return s;
|
1101
1238
|
}
|
1239
|
+
/**
|
1240
|
+
* stringify to pretty json string
|
1241
|
+
*/
|
1102
1242
|
stringify(inputObject) {
|
1103
1243
|
return JSON.stringify(inputObject, null, 2);
|
1104
1244
|
}
|
1105
1245
|
async runSyncOrAsync(fnOrOptions, ...firstArg) {
|
1106
1246
|
if (_.isUndefined(fnOrOptions)) {
|
1107
|
-
return;
|
1247
|
+
return void 0;
|
1108
1248
|
}
|
1109
1249
|
let promisOrValue;
|
1110
1250
|
const optionsMode = _.isObject(fnOrOptions)
|
@@ -1340,10 +1480,6 @@ class HelpersCore extends HelpersMessages {
|
|
1340
1480
|
/* */
|
1341
1481
|
/* */
|
1342
1482
|
/* */
|
1343
|
-
/* */
|
1344
|
-
/* */
|
1345
|
-
/* */
|
1346
|
-
/* */
|
1347
1483
|
/**
|
1348
1484
|
* symlink may have existed or unexisted destiantion url
|
1349
1485
|
* @param destUrl M
|
@@ -1445,6 +1581,7 @@ class HelpersCore extends HelpersMessages {
|
|
1445
1581
|
/* */
|
1446
1582
|
/* */
|
1447
1583
|
/* */
|
1584
|
+
/* */
|
1448
1585
|
exists(folderOrFilePath) {
|
1449
1586
|
/* */
|
1450
1587
|
/* */
|
@@ -1467,6 +1604,9 @@ class HelpersCore extends HelpersMessages {
|
|
1467
1604
|
/* */
|
1468
1605
|
return (void 0);
|
1469
1606
|
}
|
1607
|
+
/**
|
1608
|
+
* this is HACK for running procesess inside processes
|
1609
|
+
*/
|
1470
1610
|
_fixCommand(command) {
|
1471
1611
|
if ((command.startsWith('tnp ') || command.startsWith('firedev ')) // TODO every cli projects here that uses run and need to kill process easly!
|
1472
1612
|
&&
|
@@ -1531,6 +1671,11 @@ class HelpersCore extends HelpersMessages {
|
|
1531
1671
|
/* */
|
1532
1672
|
/* */
|
1533
1673
|
/* */
|
1674
|
+
/* */
|
1675
|
+
/* */
|
1676
|
+
/* */
|
1677
|
+
/* */
|
1678
|
+
/* */
|
1534
1679
|
};
|
1535
1680
|
}
|
1536
1681
|
wait(second) {
|
@@ -1610,6 +1755,11 @@ class HelpersCore extends HelpersMessages {
|
|
1610
1755
|
/* */
|
1611
1756
|
/* */
|
1612
1757
|
/* */
|
1758
|
+
/* */
|
1759
|
+
/* */
|
1760
|
+
/* */
|
1761
|
+
/* */
|
1762
|
+
/* */
|
1613
1763
|
killProcess(byPid) {
|
1614
1764
|
/* */
|
1615
1765
|
/* */
|
@@ -1668,6 +1818,9 @@ class HelpersCore extends HelpersMessages {
|
|
1668
1818
|
/* */
|
1669
1819
|
/* */
|
1670
1820
|
/* */
|
1821
|
+
/* */
|
1822
|
+
/* */
|
1823
|
+
/* */
|
1671
1824
|
async(detach = false, mockFun) {
|
1672
1825
|
if (mockFun) {
|
1673
1826
|
const subStdoutSub = new Subject();
|
@@ -1746,6 +1899,7 @@ class HelpersCore extends HelpersMessages {
|
|
1746
1899
|
/* */
|
1747
1900
|
/* */
|
1748
1901
|
/* */
|
1902
|
+
/* */
|
1749
1903
|
return (void 0);
|
1750
1904
|
},
|
1751
1905
|
/* */
|
@@ -1840,6 +1994,8 @@ class HelpersCore extends HelpersMessages {
|
|
1840
1994
|
/* */
|
1841
1995
|
/* */
|
1842
1996
|
/* */
|
1997
|
+
/* */
|
1998
|
+
/* */
|
1843
1999
|
};
|
1844
2000
|
}
|
1845
2001
|
/* */
|
@@ -2202,14 +2358,31 @@ class HelpersCore extends HelpersMessages {
|
|
2202
2358
|
/* */
|
2203
2359
|
/* */
|
2204
2360
|
/* */
|
2361
|
+
/* */
|
2362
|
+
/* */
|
2363
|
+
/* */
|
2364
|
+
/* */
|
2365
|
+
/* */
|
2366
|
+
/* */
|
2367
|
+
/* */
|
2368
|
+
/* */
|
2369
|
+
/* */
|
2370
|
+
/* */
|
2371
|
+
/* */
|
2372
|
+
/* */
|
2373
|
+
/* */
|
2374
|
+
/* */
|
2375
|
+
/* */
|
2205
2376
|
/**
|
2206
2377
|
* Quick fix for object values
|
2378
|
+
* @deprecated
|
2207
2379
|
*/
|
2208
2380
|
values(obj) {
|
2209
2381
|
if (_.isObject(obj) && !Array.isArray(obj)) {
|
2210
2382
|
const values = [];
|
2211
2383
|
for (const key in obj) {
|
2212
2384
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
2385
|
+
// @ts-ignore
|
2213
2386
|
values.push(obj[key]);
|
2214
2387
|
}
|
2215
2388
|
}
|
@@ -2278,6 +2451,277 @@ class PROGRESS_DATA {
|
|
2278
2451
|
;
|
2279
2452
|
({}); // @--end-of-file-for-module=tnp-core lib/progress-data.ts
|
2280
2453
|
|
2454
|
+
/* */
|
2455
|
+
/* */
|
2456
|
+
const BLOB_SUPPORTED_IN_SQLJS = false;
|
2457
|
+
var Utils;
|
2458
|
+
(function (Utils) {
|
2459
|
+
let DbBinaryFormatEnum;
|
2460
|
+
(function (DbBinaryFormatEnum) {
|
2461
|
+
DbBinaryFormatEnum["Blob"] = "Blob";
|
2462
|
+
DbBinaryFormatEnum["File"] = "File";
|
2463
|
+
DbBinaryFormatEnum["string"] = "string";
|
2464
|
+
/* */
|
2465
|
+
/* */
|
2466
|
+
})(DbBinaryFormatEnum = Utils.DbBinaryFormatEnum || (Utils.DbBinaryFormatEnum = {}));
|
2467
|
+
/* */
|
2468
|
+
/* */
|
2469
|
+
let binary;
|
2470
|
+
(function (binary) {
|
2471
|
+
/**
|
2472
|
+
* This is for BROWSER ONLY
|
2473
|
+
*
|
2474
|
+
* @param buffer
|
2475
|
+
* @param contentType
|
2476
|
+
* @returns
|
2477
|
+
*/
|
2478
|
+
async function arrayBufferToBlob(buffer, contentType) {
|
2479
|
+
// @ts-ignore
|
2480
|
+
return new Blob([buffer], { type: contentType });
|
2481
|
+
}
|
2482
|
+
binary.arrayBufferToBlob = arrayBufferToBlob;
|
2483
|
+
/**
|
2484
|
+
* This is for BROWSER ONLY
|
2485
|
+
* @param blob
|
2486
|
+
* @returns
|
2487
|
+
*/
|
2488
|
+
async function blobToArrayBuffer(blob) {
|
2489
|
+
return await new Promise((resolve, reject) => {
|
2490
|
+
const reader = new FileReader();
|
2491
|
+
reader.addEventListener('loadend', () => {
|
2492
|
+
resolve(reader.result);
|
2493
|
+
});
|
2494
|
+
reader.addEventListener('error', reject); // @ts-ignore
|
2495
|
+
reader.readAsArrayBuffer(blob);
|
2496
|
+
});
|
2497
|
+
}
|
2498
|
+
binary.blobToArrayBuffer = blobToArrayBuffer;
|
2499
|
+
/**
|
2500
|
+
* it is revers to base64toBlob
|
2501
|
+
* @param blob
|
2502
|
+
* @returns
|
2503
|
+
*/
|
2504
|
+
function blobToBase64(blob) {
|
2505
|
+
return new Promise((resolve, _) => {
|
2506
|
+
const reader = new FileReader();
|
2507
|
+
reader.onloadend = () => resolve(reader.result); // @ts-ignore
|
2508
|
+
reader.readAsDataURL(blob);
|
2509
|
+
});
|
2510
|
+
}
|
2511
|
+
binary.blobToBase64 = blobToBase64;
|
2512
|
+
/**
|
2513
|
+
* it is revers to blobToBase64()
|
2514
|
+
* @param base64Data
|
2515
|
+
* @returns
|
2516
|
+
*/
|
2517
|
+
async function base64toBlob(base64Data, contentTypeOverride) {
|
2518
|
+
let content_type = void 0;
|
2519
|
+
let file_base64 = void 0;
|
2520
|
+
if (!contentTypeOverride) {
|
2521
|
+
const m = /^data:(.+?);base64,(.+)$/.exec(base64Data);
|
2522
|
+
if (!m) {
|
2523
|
+
throw new Error(`[firedev-framework][base64toBlob] Not a base64 blob [${base64Data}]`);
|
2524
|
+
}
|
2525
|
+
var [__, contenttype, filebase64] = m;
|
2526
|
+
content_type = contenttype;
|
2527
|
+
file_base64 = filebase64;
|
2528
|
+
}
|
2529
|
+
content_type = (contentTypeOverride ? contentTypeOverride : content_type || '');
|
2530
|
+
base64Data = contentTypeOverride ? base64Data : file_base64;
|
2531
|
+
const sliceSize = 1024;
|
2532
|
+
const byteCharacters = atob(base64Data);
|
2533
|
+
const bytesLength = byteCharacters.length;
|
2534
|
+
const slicesCount = Math.ceil(bytesLength / sliceSize);
|
2535
|
+
const byteArrays = new Array(slicesCount);
|
2536
|
+
for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
2537
|
+
const begin = sliceIndex * sliceSize;
|
2538
|
+
const end = Math.min(begin + sliceSize, bytesLength);
|
2539
|
+
const bytes = new Array(end - begin);
|
2540
|
+
for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
|
2541
|
+
bytes[i] = byteCharacters[offset].charCodeAt(0);
|
2542
|
+
}
|
2543
|
+
byteArrays[sliceIndex] = new Uint8Array(bytes);
|
2544
|
+
}
|
2545
|
+
return new Blob(byteArrays, { type: content_type });
|
2546
|
+
}
|
2547
|
+
binary.base64toBlob = base64toBlob;
|
2548
|
+
async function base64toDbBinaryFormat(text) {
|
2549
|
+
let result;
|
2550
|
+
result = await (async () => {
|
2551
|
+
if (BLOB_SUPPORTED_IN_SQLJS) {
|
2552
|
+
const blob = await base64toBlob(text);
|
2553
|
+
return blob;
|
2554
|
+
}
|
2555
|
+
return text;
|
2556
|
+
})();
|
2557
|
+
/* */
|
2558
|
+
/* */
|
2559
|
+
/* */
|
2560
|
+
/* */
|
2561
|
+
/* */
|
2562
|
+
return result;
|
2563
|
+
}
|
2564
|
+
binary.base64toDbBinaryFormat = base64toDbBinaryFormat;
|
2565
|
+
async function dbBinaryFormatToBase64(binaryFormat) {
|
2566
|
+
let result;
|
2567
|
+
result = await (async () => {
|
2568
|
+
if (BLOB_SUPPORTED_IN_SQLJS) {
|
2569
|
+
const text = await blobToBase64(binaryFormat);
|
2570
|
+
return text;
|
2571
|
+
}
|
2572
|
+
return binaryFormat;
|
2573
|
+
})();
|
2574
|
+
/* */
|
2575
|
+
/* */
|
2576
|
+
/* */
|
2577
|
+
/* */
|
2578
|
+
/* */
|
2579
|
+
return result;
|
2580
|
+
}
|
2581
|
+
binary.dbBinaryFormatToBase64 = dbBinaryFormatToBase64;
|
2582
|
+
async function textToDbBinaryFormat(text) {
|
2583
|
+
let result;
|
2584
|
+
result = await (async () => {
|
2585
|
+
if (BLOB_SUPPORTED_IN_SQLJS) {
|
2586
|
+
const blob = await textToBlob(text);
|
2587
|
+
return blob;
|
2588
|
+
}
|
2589
|
+
return text;
|
2590
|
+
})();
|
2591
|
+
/* */
|
2592
|
+
/* */
|
2593
|
+
/* */
|
2594
|
+
/* */
|
2595
|
+
/* */
|
2596
|
+
return result;
|
2597
|
+
}
|
2598
|
+
binary.textToDbBinaryFormat = textToDbBinaryFormat;
|
2599
|
+
async function dbBinaryFormatToText(binaryFormat) {
|
2600
|
+
let result;
|
2601
|
+
result = await (async () => {
|
2602
|
+
if (BLOB_SUPPORTED_IN_SQLJS) {
|
2603
|
+
const text = await blobToText(binaryFormat);
|
2604
|
+
return text;
|
2605
|
+
}
|
2606
|
+
return binaryFormat;
|
2607
|
+
})();
|
2608
|
+
/* */
|
2609
|
+
/* */
|
2610
|
+
/* */
|
2611
|
+
/* */
|
2612
|
+
/* */
|
2613
|
+
return result;
|
2614
|
+
}
|
2615
|
+
binary.dbBinaryFormatToText = dbBinaryFormatToText;
|
2616
|
+
/* */
|
2617
|
+
/* */
|
2618
|
+
/* */
|
2619
|
+
/* */
|
2620
|
+
/* */
|
2621
|
+
/* */
|
2622
|
+
/* */
|
2623
|
+
/* */
|
2624
|
+
/* */
|
2625
|
+
/* */
|
2626
|
+
/* */
|
2627
|
+
/* */
|
2628
|
+
async function fileToBlob(file) {
|
2629
|
+
return new Blob([new Uint8Array(await file.arrayBuffer())], { type: file.type });
|
2630
|
+
}
|
2631
|
+
binary.fileToBlob = fileToBlob;
|
2632
|
+
;
|
2633
|
+
async function blobToFile(blob, nameForFile = 'my-file-name') {
|
2634
|
+
if (!nameForFile) {
|
2635
|
+
nameForFile = 'nonamefile' + (new Date()).getTime();
|
2636
|
+
}
|
2637
|
+
;
|
2638
|
+
// @ts-ignore
|
2639
|
+
return new File([blob], nameForFile);
|
2640
|
+
}
|
2641
|
+
binary.blobToFile = blobToFile;
|
2642
|
+
/* */
|
2643
|
+
/* */
|
2644
|
+
/* */
|
2645
|
+
/* */
|
2646
|
+
/* */
|
2647
|
+
/* */
|
2648
|
+
/* */
|
2649
|
+
/* */
|
2650
|
+
/* */
|
2651
|
+
/* */
|
2652
|
+
/* */
|
2653
|
+
/* */
|
2654
|
+
/* */
|
2655
|
+
/* */
|
2656
|
+
/* */
|
2657
|
+
/* */
|
2658
|
+
/* */
|
2659
|
+
/* */
|
2660
|
+
/* */
|
2661
|
+
/* */
|
2662
|
+
/* */
|
2663
|
+
/* */
|
2664
|
+
/* */
|
2665
|
+
async function textToBlob(text, type = 'text/plain') {
|
2666
|
+
const blob = new Blob([text], { type });
|
2667
|
+
return blob;
|
2668
|
+
}
|
2669
|
+
binary.textToBlob = textToBlob;
|
2670
|
+
async function blobToText(blob) {
|
2671
|
+
return await blob.text();
|
2672
|
+
}
|
2673
|
+
binary.blobToText = blobToText;
|
2674
|
+
async function textToFile(text, fileRelativePathOrName) {
|
2675
|
+
const ext = path.extname(fileRelativePathOrName);
|
2676
|
+
const type = mimeTypes[ext];
|
2677
|
+
const blob = new Blob([text], { type });
|
2678
|
+
const file = await blobToFile(blob, fileRelativePathOrName);
|
2679
|
+
return file;
|
2680
|
+
}
|
2681
|
+
binary.textToFile = textToFile;
|
2682
|
+
async function fileToText(file) {
|
2683
|
+
return await file.text();
|
2684
|
+
}
|
2685
|
+
binary.fileToText = fileToText;
|
2686
|
+
async function jsonToBlob(jsonObj) {
|
2687
|
+
const blob = new Blob([JSON.stringify(jsonObj, null, 2)], { type: 'application/json' });
|
2688
|
+
return blob;
|
2689
|
+
}
|
2690
|
+
binary.jsonToBlob = jsonToBlob;
|
2691
|
+
/**
|
2692
|
+
* TODO NOT TESTED
|
2693
|
+
*/
|
2694
|
+
async function blobToJson(blob) {
|
2695
|
+
return JSON.parse(await blob.text());
|
2696
|
+
}
|
2697
|
+
binary.blobToJson = blobToJson;
|
2698
|
+
async function getBlobFrom(url) {
|
2699
|
+
const response = await axios({
|
2700
|
+
url,
|
2701
|
+
method: 'get',
|
2702
|
+
responseType: 'blob'
|
2703
|
+
});
|
2704
|
+
return response.data;
|
2705
|
+
}
|
2706
|
+
binary.getBlobFrom = getBlobFrom;
|
2707
|
+
})(binary = Utils.binary || (Utils.binary = {}));
|
2708
|
+
let css;
|
2709
|
+
(function (css) {
|
2710
|
+
/**
|
2711
|
+
*
|
2712
|
+
* @param pixelsCss pixels ex. 100px
|
2713
|
+
* @returns
|
2714
|
+
*/
|
2715
|
+
function numValue(pixelsCss) {
|
2716
|
+
return parseInt(pixelsCss
|
2717
|
+
.replace('px', ''));
|
2718
|
+
}
|
2719
|
+
css.numValue = numValue;
|
2720
|
+
})(css = Utils.css || (Utils.css = {}));
|
2721
|
+
})(Utils || (Utils = {}));
|
2722
|
+
;
|
2723
|
+
({}); // @--end-of-file-for-module=tnp-core lib/utils.ts
|
2724
|
+
|
2281
2725
|
let Helpers = HelpersCore.InstanceCore;
|
2282
2726
|
;
|
2283
2727
|
({}); // @--end-of-file-for-module=tnp-core lib/index.ts
|
@@ -2286,5 +2730,5 @@ let Helpers = HelpersCore.InstanceCore;
|
|
2286
2730
|
* Generated bundle index. Do not edit.
|
2287
2731
|
*/
|
2288
2732
|
|
2289
|
-
export { CoreConfig, HelpersCore as CoreHelpers, Helpers, PROGRESS_DATA, chalk, crossPlatformPath, frameworkName, frameworkNameBe, path, win32Path };
|
2733
|
+
export { CoreConfig, HelpersCore as CoreHelpers, Files, Helpers, MediaTypeAllArr, PROGRESS_DATA, Utils, chalk, crossPlatformPath, frameworkName, frameworkNameBe, mimeTypes, path, win32Path };
|
2290
2734
|
//# sourceMappingURL=tnp-core.mjs.map
|