tnp-core 18.0.39 → 18.0.40

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.
Files changed (72) hide show
  1. package/assets/shared/shared_folder_info.txt +1 -1
  2. package/browser/esm2022/lib/helpers-isomorphic.mjs +26 -30
  3. package/browser/esm2022/lib/helpers-messages.mjs +18 -1
  4. package/browser/esm2022/lib/helpers.mjs +22 -28
  5. package/browser/esm2022/lib/index.mjs +2 -2
  6. package/browser/esm2022/lib/required-global-npm-packages.mjs +79 -0
  7. package/browser/esm2022/lib/utils.mjs +273 -2
  8. package/browser/fesm2022/tnp-core.mjs +1860 -1576
  9. package/browser/fesm2022/tnp-core.mjs.map +1 -1
  10. package/browser/lib/helpers-isomorphic.d.ts +20 -0
  11. package/browser/lib/helpers-messages.d.ts +6 -0
  12. package/browser/lib/helpers.d.ts +16 -2
  13. package/browser/lib/index.d.ts +1 -1
  14. package/{websql/lib/required.d.ts → browser/lib/required-global-npm-packages.d.ts} +4 -0
  15. package/browser/lib/utils.d.ts +52 -8
  16. package/cli.backend.js +2 -2
  17. package/client/esm2022/lib/helpers-isomorphic.mjs +26 -30
  18. package/client/esm2022/lib/helpers-messages.mjs +18 -1
  19. package/client/esm2022/lib/helpers.mjs +22 -28
  20. package/client/esm2022/lib/index.mjs +2 -2
  21. package/client/esm2022/lib/required-global-npm-packages.mjs +79 -0
  22. package/client/esm2022/lib/utils.mjs +273 -2
  23. package/client/fesm2022/tnp-core.mjs +1860 -1576
  24. package/client/fesm2022/tnp-core.mjs.map +1 -1
  25. package/client/lib/helpers-isomorphic.d.ts +20 -0
  26. package/client/lib/helpers-messages.d.ts +6 -0
  27. package/client/lib/helpers.d.ts +16 -2
  28. package/client/lib/index.d.ts +1 -1
  29. package/{browser/lib/required.d.ts → client/lib/required-global-npm-packages.d.ts} +4 -0
  30. package/client/lib/utils.d.ts +52 -8
  31. package/lib/core-cli.js +3 -3
  32. package/lib/core-cli.js.map +1 -1
  33. package/lib/helpers-isomorphic.d.ts +20 -0
  34. package/lib/helpers-isomorphic.js +25 -35
  35. package/lib/helpers-isomorphic.js.map +1 -1
  36. package/lib/helpers-messages.d.ts +6 -0
  37. package/lib/helpers-messages.js +19 -0
  38. package/lib/helpers-messages.js.map +1 -1
  39. package/lib/helpers.d.ts +14 -0
  40. package/lib/helpers.js +33 -28
  41. package/lib/helpers.js.map +1 -1
  42. package/lib/index.d.ts +1 -1
  43. package/lib/index.js +1 -1
  44. package/lib/index.js.map +1 -1
  45. package/lib/node-chalk-mock.js +2 -2
  46. package/lib/node-path-mock.js +2 -2
  47. package/lib/{required.d.ts → required-global-npm-packages.d.ts} +6 -2
  48. package/lib/{required.js → required-global-npm-packages.js} +8 -1
  49. package/lib/required-global-npm-packages.js.map +1 -0
  50. package/lib/utils.d.ts +52 -8
  51. package/lib/utils.js +329 -4
  52. package/lib/utils.js.map +1 -1
  53. package/package.json +3 -3
  54. package/tmp-environment.json +36 -31
  55. package/websql/esm2022/lib/helpers-isomorphic.mjs +26 -29
  56. package/websql/esm2022/lib/helpers-messages.mjs +18 -1
  57. package/websql/esm2022/lib/helpers.mjs +22 -28
  58. package/websql/esm2022/lib/index.mjs +2 -2
  59. package/websql/esm2022/lib/required-global-npm-packages.mjs +79 -0
  60. package/websql/esm2022/lib/utils.mjs +272 -2
  61. package/websql/fesm2022/tnp-core.mjs +1861 -1577
  62. package/websql/fesm2022/tnp-core.mjs.map +1 -1
  63. package/websql/lib/helpers-isomorphic.d.ts +20 -0
  64. package/websql/lib/helpers-messages.d.ts +6 -0
  65. package/websql/lib/helpers.d.ts +16 -2
  66. package/websql/lib/index.d.ts +1 -1
  67. package/{client/lib/required.d.ts → websql/lib/required-global-npm-packages.d.ts} +4 -0
  68. package/websql/lib/utils.d.ts +52 -8
  69. package/browser/esm2022/lib/required.mjs +0 -72
  70. package/client/esm2022/lib/required.mjs +0 -72
  71. package/lib/required.js.map +0 -1
  72. package/websql/esm2022/lib/required.mjs +0 -72
@@ -9,8 +9,8 @@ import * as dateformat from 'dateformat';
9
9
  export { dateformat };
10
10
  import * as json5 from 'json5';
11
11
  export { json5 };
12
- import { Subject } from 'rxjs';
13
12
  import axios from 'axios';
13
+ import { Subject } from 'rxjs';
14
14
 
15
15
  let isBrowser = false;
16
16
  isBrowser = true;
@@ -722,151 +722,47 @@ var CoreModels;
722
722
  ;
723
723
  ({}); // @--end-of-file-for-module=tnp-core lib/core-models.ts
724
724
 
725
- class HelpersIsomorphic {
726
- get isBrowser() {
727
- /* */
728
- /* */
729
- return true;
730
- }
731
- get isWebSQL() {
732
- /* */
733
- /* */
734
- /* */
735
- /* */
736
- return false;
737
- }
738
- get isNode() {
739
- /* */
740
- /* */
741
- return false;
742
- }
743
- get isElectron() {
744
- // @ts-ignore
745
- if (typeof window !== 'undefined' &&
746
- typeof window.process === 'object' &&
747
- window.process.type === 'renderer') {
748
- return true;
749
- }
750
- // @ts-ignore
751
- if (typeof process !== 'undefined' &&
752
- typeof process.versions === 'object' &&
753
- !!process.versions.electron) {
754
- return true;
755
- }
756
- if (typeof navigator === 'object' &&
757
- typeof navigator.userAgent === 'string' &&
758
- navigator.userAgent.indexOf('Electron') >= 0) {
759
- return true;
760
- }
761
- return false;
762
- }
763
- contain(arr, item) {
764
- return (arr.filter(l => {
765
- if (l instanceof RegExp) {
766
- return l.test(item);
767
- }
768
- if (l === item) {
769
- return true;
770
- }
771
- if (item.match && typeof item.match === 'function' ? item.match(l) : false) {
772
- return true;
773
- }
774
- return false;
775
- }).length > 0);
776
- }
777
- }
778
- ;
779
- ({}); // @--end-of-file-for-module=tnp-core lib/helpers-isomorphic.ts
780
-
781
- /* */
782
- /* */
783
- /* */
784
- const KEY = {
785
- LAST_ERROR: Symbol(),
786
- LAST_INFO: Symbol(),
787
- LAST_WARN: Symbol(),
788
- LAST_LOG: Symbol(),
789
- LAST_SUCCESS: Symbol(),
790
- LAST_TASK_STARTED: Symbol(),
791
- LAST_TASK_DONE: Symbol(),
792
- };
793
- const KEY_COUNT = {
794
- LAST_ERROR: Symbol(),
795
- LAST_INFO: Symbol(),
796
- LAST_WARN: Symbol(),
797
- LAST_LOG: Symbol(),
798
- LAST_SUCCESS: Symbol(),
799
- LAST_TASK_STARTED: Symbol(),
800
- LAST_TASK_DONE: Symbol(),
801
- };
802
- const KEY_IMPORTANTCE = {
803
- LAST_ERROR: Symbol(),
804
- LAST_INFO: Symbol(),
805
- LAST_WARN: Symbol(),
806
- LAST_LOG: Symbol(),
807
- LAST_SUCCESS: Symbol(),
808
- LAST_TASK_STARTED: Symbol(),
809
- LAST_TASK_DONE: Symbol(),
810
- };
811
- /* */
812
- /* */
813
- /* */
814
- /* */
815
- /* */
816
- /* */
817
- /* */
818
- /* */
819
725
  /* */
820
726
  /* */
821
727
  /* */
822
728
  /* */
823
- /* */
824
- /* */
825
- /* */
826
- /* */
827
- /* */
828
- /* */
829
- /* */
830
- /* */
831
- /* */
832
- const LIMIT = 10;
833
- class HelpersMessages extends HelpersIsomorphic {
834
- msgCacheClear() {
835
- /* */
836
- /* */
837
- /* */
838
- /* */
839
- /* */
840
- }
841
- renderError(err) {
842
- if (this.isBrowser) {
843
- console.error(err);
844
- }
845
- else {
846
- /* */
847
- /* */
848
- /* */
849
- /* */
850
- /* */
851
- /* */
852
- /* */
853
- /* */
854
- /* */
855
- }
729
+ const BLOB_SUPPORTED_IN_SQLJS = false;
730
+ var Utils;
731
+ (function (Utils) {
732
+ Utils.uniqArray = (array, uniqueProperty) => {
733
+ var seen = {};
734
+ return array
735
+ .filter(f => !!f)
736
+ .filter(function (item) {
737
+ return seen.hasOwnProperty(uniqueProperty ? item[uniqueProperty] : item)
738
+ ? false
739
+ : (seen[uniqueProperty ? item[uniqueProperty] : item] = true);
740
+ });
741
+ };
742
+ /**
743
+ * Example:
744
+ * new RegExp(escapeStringForRegEx('a.b.c'),'g') => /a\.b\.c/g
745
+ */
746
+ Utils.escapeStringForRegEx = (stringForRegExp) => {
747
+ return stringForRegExp.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
748
+ };
749
+ function removeChalkSpecialChars(str) {
750
+ const ansiRegex = /\u001b\[[0-9;]*m/g;
751
+ return str.replace(ansiRegex, '');
856
752
  }
857
- error(details, noExit = false, noTrace = false) {
858
- if (Helpers.isBrowser) {
859
- console.error(details);
860
- return;
861
- }
862
- /* */
863
- /* */
864
- /* */
865
- /* */
753
+ Utils.removeChalkSpecialChars = removeChalkSpecialChars;
754
+ Utils.fullDateTime = () => {
866
755
  /* */
867
756
  /* */
757
+ return (void 0);
758
+ };
759
+ Utils.fullDate = () => {
868
760
  /* */
869
761
  /* */
762
+ return (void 0);
763
+ };
764
+ const takenPorts = [];
765
+ Utils.getFreePort = async (options) => {
870
766
  /* */
871
767
  /* */
872
768
  /* */
@@ -900,8 +796,246 @@ class HelpersMessages extends HelpersIsomorphic {
900
796
  /* */
901
797
  /* */
902
798
  /* */
799
+ return (void 0);
800
+ };
801
+ let json;
802
+ (function (json) {
803
+ json.getAtrributies = (jsonDeepPath, // lodash path to property in json ex. deep.path.to.prop
804
+ fileContent) => {
805
+ const lines = fileContent.split('\n');
806
+ const pathParts = jsonDeepPath.split('.').reduce((a, b) => {
807
+ if (a.length === 0) {
808
+ return [b];
809
+ }
810
+ const last = a[a.length - 1];
811
+ if ((last.startsWith(`['`) && b.endsWith(`']`)) ||
812
+ (last.startsWith(`["`) && b.endsWith(`"]`))) {
813
+ a[a.length - 1] = [last, b].join('.');
814
+ }
815
+ else {
816
+ a.push(b);
817
+ }
818
+ return a;
819
+ }, []);
820
+ const keyName = pathParts.pop().replace(/^\["(.+)"\]$/, '$1');
821
+ let currentPath = '';
822
+ let attributes = [];
823
+ let collectedComments = [];
824
+ for (const line of lines) {
825
+ const trimmedLine = line.trim();
826
+ if (trimmedLine.startsWith('//')) {
827
+ collectedComments.push(trimmedLine);
828
+ }
829
+ else if (trimmedLine.startsWith('"') || trimmedLine.startsWith("'")) {
830
+ const match = trimmedLine.match(/["']([^"']+)["']\s*:/);
831
+ if (match) {
832
+ const key = match[1];
833
+ currentPath = currentPath
834
+ ? `${currentPath}.${key.includes('.') ? `['${key}']` : key}`
835
+ : key;
836
+ if ((currentPath.endsWith(keyName) &&
837
+ !currentPath.endsWith('/' + keyName)) ||
838
+ currentPath.endsWith(`['${keyName}']`)) {
839
+ attributes = extractAttributesFromComments(collectedComments);
840
+ break;
841
+ }
842
+ collectedComments = [];
843
+ }
844
+ }
845
+ }
846
+ return attributes;
847
+ };
848
+ const extractAttributesFromComments = (comments) => {
849
+ const attributes = [];
850
+ const attrRegex = /@(\w+)(?:\s*=\s*([^\s@]+))?/g;
851
+ for (const comment of comments) {
852
+ let match;
853
+ while ((match = attrRegex.exec(comment)) !== null) {
854
+ const [, name, value] = match;
855
+ const existingAttribute = attributes.find(attr => attr.name === `@${name}`);
856
+ if (existingAttribute) {
857
+ if (value) {
858
+ if (Array.isArray(existingAttribute.value)) {
859
+ existingAttribute.value.push(value);
860
+ }
861
+ else {
862
+ existingAttribute.value = [existingAttribute.value, value];
863
+ }
864
+ }
865
+ }
866
+ else {
867
+ attributes.push({
868
+ name: `@${name}`,
869
+ value: value ? value : true,
870
+ });
871
+ }
872
+ }
873
+ }
874
+ attributes.forEach(attr => {
875
+ if (Array.isArray(attr.value) && attr.value.length === 1) {
876
+ attr.value = attr.value[0];
877
+ }
878
+ });
879
+ return attributes;
880
+ };
881
+ })(json = Utils.json || (Utils.json = {}));
882
+ let DbBinaryFormatEnum;
883
+ (function (DbBinaryFormatEnum) {
884
+ DbBinaryFormatEnum["Blob"] = "Blob";
885
+ DbBinaryFormatEnum["File"] = "File";
886
+ DbBinaryFormatEnum["string"] = "string";
903
887
  /* */
904
888
  /* */
889
+ })(DbBinaryFormatEnum = Utils.DbBinaryFormatEnum || (Utils.DbBinaryFormatEnum = {}));
890
+ /* */
891
+ /* */
892
+ let binary;
893
+ (function (binary) {
894
+ /**
895
+ * This is for BROWSER ONLY
896
+ *
897
+ * @param buffer
898
+ * @param contentType
899
+ * @returns
900
+ */
901
+ async function arrayBufferToBlob(buffer, contentType) {
902
+ // @ts-ignore
903
+ return new Blob([buffer], { type: contentType });
904
+ }
905
+ binary.arrayBufferToBlob = arrayBufferToBlob;
906
+ /**
907
+ * This is for BROWSER ONLY
908
+ * @param blob
909
+ * @returns
910
+ */
911
+ async function blobToArrayBuffer(blob) {
912
+ return await new Promise((resolve, reject) => {
913
+ const reader = new FileReader();
914
+ reader.addEventListener('loadend', () => {
915
+ resolve(reader.result);
916
+ });
917
+ reader.addEventListener('error', reject); // @ts-ignore
918
+ reader.readAsArrayBuffer(blob);
919
+ });
920
+ }
921
+ binary.blobToArrayBuffer = blobToArrayBuffer;
922
+ /**
923
+ * it is revers to base64toBlob
924
+ * @param blob
925
+ * @returns
926
+ */
927
+ function blobToBase64(blob) {
928
+ return new Promise((resolve, _) => {
929
+ const reader = new FileReader();
930
+ reader.onloadend = () => resolve(reader.result); // @ts-ignore
931
+ reader.readAsDataURL(blob);
932
+ });
933
+ }
934
+ binary.blobToBase64 = blobToBase64;
935
+ /**
936
+ * it is revers to blobToBase64()
937
+ * @param base64Data
938
+ * @returns
939
+ */
940
+ async function base64toBlob(base64Data, contentTypeOverride) {
941
+ let content_type = void 0;
942
+ let file_base64 = void 0;
943
+ if (!contentTypeOverride) {
944
+ const m = /^data:(.+?);base64,(.+)$/.exec(base64Data);
945
+ if (!m) {
946
+ throw new Error(`[taon-framework][base64toBlob] Not a base64 blob [${base64Data}]`);
947
+ }
948
+ var [__, contenttype, filebase64] = m;
949
+ content_type = contenttype;
950
+ file_base64 = filebase64;
951
+ }
952
+ content_type = (contentTypeOverride ? contentTypeOverride : content_type || '');
953
+ base64Data = contentTypeOverride ? base64Data : file_base64;
954
+ const sliceSize = 1024;
955
+ const byteCharacters = atob(base64Data);
956
+ const bytesLength = byteCharacters.length;
957
+ const slicesCount = Math.ceil(bytesLength / sliceSize);
958
+ const byteArrays = new Array(slicesCount);
959
+ for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
960
+ const begin = sliceIndex * sliceSize;
961
+ const end = Math.min(begin + sliceSize, bytesLength);
962
+ const bytes = new Array(end - begin);
963
+ for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
964
+ bytes[i] = byteCharacters[offset].charCodeAt(0);
965
+ }
966
+ byteArrays[sliceIndex] = new Uint8Array(bytes);
967
+ }
968
+ return new Blob(byteArrays, { type: content_type });
969
+ }
970
+ binary.base64toBlob = base64toBlob;
971
+ async function base64toDbBinaryFormat(text) {
972
+ let result;
973
+ result = await (async () => {
974
+ if (BLOB_SUPPORTED_IN_SQLJS) {
975
+ const blob = await base64toBlob(text);
976
+ return blob;
977
+ }
978
+ return text;
979
+ })();
980
+ /* */
981
+ /* */
982
+ /* */
983
+ /* */
984
+ /* */
985
+ return result;
986
+ }
987
+ binary.base64toDbBinaryFormat = base64toDbBinaryFormat;
988
+ async function dbBinaryFormatToBase64(binaryFormat) {
989
+ let result;
990
+ result = await (async () => {
991
+ if (BLOB_SUPPORTED_IN_SQLJS) {
992
+ const text = await blobToBase64(binaryFormat);
993
+ return text;
994
+ }
995
+ return binaryFormat;
996
+ })();
997
+ /* */
998
+ /* */
999
+ /* */
1000
+ /* */
1001
+ /* */
1002
+ return result;
1003
+ }
1004
+ binary.dbBinaryFormatToBase64 = dbBinaryFormatToBase64;
1005
+ async function textToDbBinaryFormat(text) {
1006
+ let result;
1007
+ result = await (async () => {
1008
+ if (BLOB_SUPPORTED_IN_SQLJS) {
1009
+ const blob = await textToBlob(text);
1010
+ return blob;
1011
+ }
1012
+ return text;
1013
+ })();
1014
+ /* */
1015
+ /* */
1016
+ /* */
1017
+ /* */
1018
+ /* */
1019
+ return result;
1020
+ }
1021
+ binary.textToDbBinaryFormat = textToDbBinaryFormat;
1022
+ async function dbBinaryFormatToText(binaryFormat) {
1023
+ let result;
1024
+ result = await (async () => {
1025
+ if (BLOB_SUPPORTED_IN_SQLJS) {
1026
+ const text = await blobToText(binaryFormat);
1027
+ return text;
1028
+ }
1029
+ return binaryFormat;
1030
+ })();
1031
+ /* */
1032
+ /* */
1033
+ /* */
1034
+ /* */
1035
+ /* */
1036
+ return result;
1037
+ }
1038
+ binary.dbBinaryFormatToText = dbBinaryFormatToText;
905
1039
  /* */
906
1040
  /* */
907
1041
  /* */
@@ -909,18 +1043,28 @@ class HelpersMessages extends HelpersIsomorphic {
909
1043
  /* */
910
1044
  /* */
911
1045
  /* */
912
- }
913
- info(details, repeatable = false) {
914
1046
  /* */
915
1047
  /* */
916
1048
  /* */
917
1049
  /* */
918
1050
  /* */
919
1051
  /* */
920
- if (Helpers.isBrowser) {
921
- console.info(details);
922
- return;
1052
+ /* */
1053
+ /* */
1054
+ async function fileToBlob(file) {
1055
+ return new Blob([new Uint8Array(await file.arrayBuffer())], {
1056
+ type: file.type,
1057
+ });
1058
+ }
1059
+ binary.fileToBlob = fileToBlob;
1060
+ async function blobToFile(blob, nameForFile = 'my-file-name') {
1061
+ if (!nameForFile) {
1062
+ nameForFile = 'nonamefile' + new Date().getTime();
1063
+ }
1064
+ // @ts-ignore
1065
+ return new File([blob], nameForFile);
923
1066
  }
1067
+ binary.blobToFile = blobToFile;
924
1068
  /* */
925
1069
  /* */
926
1070
  /* */
@@ -947,6 +1091,80 @@ class HelpersMessages extends HelpersIsomorphic {
947
1091
  /* */
948
1092
  /* */
949
1093
  /* */
1094
+ async function textToBlob(text, type = 'text/plain') {
1095
+ const blob = new Blob([text], { type });
1096
+ return blob;
1097
+ }
1098
+ binary.textToBlob = textToBlob;
1099
+ async function blobToText(blob) {
1100
+ return await blob.text();
1101
+ }
1102
+ binary.blobToText = blobToText;
1103
+ async function textToFile(text, fileRelativePathOrName) {
1104
+ const ext = path.extname(fileRelativePathOrName);
1105
+ const type = CoreModels.mimeTypes[ext];
1106
+ const blob = new Blob([text], { type });
1107
+ const file = await blobToFile(blob, fileRelativePathOrName);
1108
+ return file;
1109
+ }
1110
+ binary.textToFile = textToFile;
1111
+ async function fileToText(file) {
1112
+ return await file.text();
1113
+ }
1114
+ binary.fileToText = fileToText;
1115
+ async function jsonToBlob(jsonObj) {
1116
+ const blob = new Blob([JSON.stringify(jsonObj, null, 2)], {
1117
+ type: 'application/json',
1118
+ });
1119
+ return blob;
1120
+ }
1121
+ binary.jsonToBlob = jsonToBlob;
1122
+ /**
1123
+ * TODO NOT TESTED
1124
+ */
1125
+ async function blobToJson(blob) {
1126
+ return JSON.parse(await blob.text());
1127
+ }
1128
+ binary.blobToJson = blobToJson;
1129
+ async function getBlobFrom(url) {
1130
+ const response = await axios({
1131
+ url,
1132
+ method: 'get',
1133
+ responseType: 'blob',
1134
+ });
1135
+ return response.data;
1136
+ }
1137
+ binary.getBlobFrom = getBlobFrom;
1138
+ })(binary = Utils.binary || (Utils.binary = {}));
1139
+ let css;
1140
+ (function (css) {
1141
+ /**
1142
+ *
1143
+ * @param pixelsCss pixels ex. 100px
1144
+ * @returns
1145
+ */
1146
+ function numValue(pixelsCss) {
1147
+ return parseInt(pixelsCss?.toString()?.replace('px', ''));
1148
+ }
1149
+ css.numValue = numValue;
1150
+ })(css = Utils.css || (Utils.css = {}));
1151
+ })(Utils || (Utils = {}));
1152
+ var UtilsProcess;
1153
+ (function (UtilsProcess) {
1154
+ /**
1155
+ * TODO IMPLEMENT
1156
+ * start async node process
1157
+ */
1158
+ async function startAsync(command, options) {
1159
+ }
1160
+ UtilsProcess.startAsync = startAsync;
1161
+ /**
1162
+ * TODO IMPLEMENT
1163
+ */
1164
+ function startSync(command, options) {
1165
+ }
1166
+ UtilsProcess.startSync = startSync;
1167
+ UtilsProcess.getGitBashPath = () => {
950
1168
  /* */
951
1169
  /* */
952
1170
  /* */
@@ -955,12 +1173,6 @@ class HelpersMessages extends HelpersIsomorphic {
955
1173
  /* */
956
1174
  /* */
957
1175
  /* */
958
- }
959
- success(details) {
960
- if (Helpers.isBrowser) {
961
- console.info(details);
962
- return;
963
- }
964
1176
  /* */
965
1177
  /* */
966
1178
  /* */
@@ -970,6 +1182,14 @@ class HelpersMessages extends HelpersIsomorphic {
970
1182
  /* */
971
1183
  /* */
972
1184
  /* */
1185
+ /* */
1186
+ return (void 0);
1187
+ };
1188
+ /**
1189
+ * TODO IMPLEMENT
1190
+ * start async node process
1191
+ */
1192
+ UtilsProcess.startInNewTerminalWindow = (command, options) => {
973
1193
  /* */
974
1194
  /* */
975
1195
  /* */
@@ -998,18 +1218,6 @@ class HelpersMessages extends HelpersIsomorphic {
998
1218
  /* */
999
1219
  /* */
1000
1220
  /* */
1001
- }
1002
- /**
1003
- *
1004
- * @param details
1005
- * @param isLogTask is less important log task
1006
- * @returns
1007
- */
1008
- taskStarted(details, isLogTask = false) {
1009
- if (Helpers.isBrowser) {
1010
- console.info(details);
1011
- return;
1012
- }
1013
1221
  /* */
1014
1222
  /* */
1015
1223
  /* */
@@ -1057,12 +1265,6 @@ class HelpersMessages extends HelpersIsomorphic {
1057
1265
  /* */
1058
1266
  /* */
1059
1267
  /* */
1060
- }
1061
- taskDone(details, isLessImportant = false) {
1062
- if (Helpers.isBrowser) {
1063
- console.info(details);
1064
- return;
1065
- }
1066
1268
  /* */
1067
1269
  /* */
1068
1270
  /* */
@@ -1089,6 +1291,10 @@ class HelpersMessages extends HelpersIsomorphic {
1089
1291
  /* */
1090
1292
  /* */
1091
1293
  /* */
1294
+ return (void 0);
1295
+ };
1296
+ UtilsProcess.getBashOrShellName = () => {
1297
+ return 'browser';
1092
1298
  /* */
1093
1299
  /* */
1094
1300
  /* */
@@ -1115,26 +1321,77 @@ class HelpersMessages extends HelpersIsomorphic {
1115
1321
  /* */
1116
1322
  /* */
1117
1323
  /* */
1118
- }
1119
- log(details, debugLevel = 0) {
1120
- if (Helpers.isBrowser) {
1121
- console.log(details);
1122
- return;
1123
- }
1124
1324
  /* */
1125
1325
  /* */
1126
1326
  /* */
1127
1327
  /* */
1128
1328
  /* */
1129
1329
  /* */
1330
+ return (void 0);
1331
+ };
1332
+ })(UtilsProcess || (UtilsProcess = {}));
1333
+ var UtilsOs;
1334
+ (function (UtilsOs) {
1335
+ /**
1336
+ * check if script is running in client browser
1337
+ * (websql model -> is also considered as browser
1338
+ * because it is running in browser)
1339
+ */
1340
+ UtilsOs.isRunningInBrowser = () => {
1130
1341
  /* */
1131
1342
  /* */
1343
+ return true;
1344
+ };
1345
+ /**
1346
+ * check if script is running in nodejs
1347
+ * (backend script or electron script)
1348
+ */
1349
+ UtilsOs.isRunningInNode = () => {
1132
1350
  /* */
1133
1351
  /* */
1352
+ return false;
1353
+ };
1354
+ /**
1355
+ * check if script is running special
1356
+ * browser mode that has sql.js backend
1357
+ * and executes sql queries in browser
1358
+ */
1359
+ UtilsOs.isRunningInWebSQL = () => {
1134
1360
  /* */
1135
1361
  /* */
1136
1362
  /* */
1137
1363
  /* */
1364
+ return false;
1365
+ };
1366
+ /**
1367
+ * check whether the current process is running inside
1368
+ * Electron backend or browser.
1369
+ */
1370
+ UtilsOs.isRunningInElectron = () => {
1371
+ // @ts-ignore
1372
+ if (typeof window !== 'undefined' &&
1373
+ typeof window.process === 'object' &&
1374
+ window.process.type === 'renderer') {
1375
+ return true;
1376
+ }
1377
+ // @ts-ignore
1378
+ if (typeof process !== 'undefined' &&
1379
+ typeof process.versions === 'object' &&
1380
+ !!process.versions.electron) {
1381
+ return true;
1382
+ }
1383
+ if (typeof navigator === 'object' &&
1384
+ typeof navigator.userAgent === 'string' &&
1385
+ navigator.userAgent.indexOf('Electron') >= 0) {
1386
+ return true;
1387
+ }
1388
+ return false;
1389
+ };
1390
+ /**
1391
+ * Check wether the current process is running inside
1392
+ * windows subsystem for linux (WSL).
1393
+ */
1394
+ UtilsOs.isRunningInWsl = () => {
1138
1395
  /* */
1139
1396
  /* */
1140
1397
  /* */
@@ -1152,6 +1409,9 @@ class HelpersMessages extends HelpersIsomorphic {
1152
1409
  /* */
1153
1410
  /* */
1154
1411
  /* */
1412
+ return (void 0);
1413
+ };
1414
+ UtilsOs.isRunningInDocker = () => {
1155
1415
  /* */
1156
1416
  /* */
1157
1417
  /* */
@@ -1159,6 +1419,9 @@ class HelpersMessages extends HelpersIsomorphic {
1159
1419
  /* */
1160
1420
  /* */
1161
1421
  /* */
1422
+ return (void 0);
1423
+ };
1424
+ UtilsOs.isRunningInLinuxGraphicsCapableEnvironment = () => {
1162
1425
  /* */
1163
1426
  /* */
1164
1427
  /* */
@@ -1166,61 +1429,190 @@ class HelpersMessages extends HelpersIsomorphic {
1166
1429
  /* */
1167
1430
  /* */
1168
1431
  /* */
1432
+ return (void 0);
1433
+ };
1434
+ })(UtilsOs || (UtilsOs = {}));
1435
+ var UtilsString;
1436
+ (function (UtilsString) {
1437
+ UtilsString.kebabCaseNoSplitNumbers = (input) => {
1438
+ return (input
1439
+ .replace(/\s+/g, '-')
1440
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
1441
+ .toLowerCase());
1442
+ };
1443
+ })(UtilsString || (UtilsString = {}));
1444
+ ;
1445
+ ({}); // @--end-of-file-for-module=tnp-core lib/utils.ts
1446
+
1447
+ class HelpersIsomorphic {
1448
+ /**
1449
+ * @deprecated
1450
+ * use UtilsOs.isRunningInBrowser() instead
1451
+ */
1452
+ get isBrowser() {
1453
+ return UtilsOs.isRunningInBrowser();
1454
+ }
1455
+ /**
1456
+ * @deprecated
1457
+ * use UtilsOs.isRunningInWebSQL() instead
1458
+ */
1459
+ get isWebSQL() {
1460
+ return UtilsOs.isRunningInWebSQL();
1461
+ }
1462
+ /**
1463
+ * @deprecated
1464
+ * use UtilsOs.isRunningInNode() instead
1465
+ */
1466
+ get isNode() {
1467
+ return UtilsOs.isRunningInNode();
1468
+ }
1469
+ /**
1470
+ * @deprecated
1471
+ * use UtilsOs.isRunningInElectron() instead
1472
+ */
1473
+ get isElectron() {
1474
+ return UtilsOs.isRunningInElectron();
1475
+ }
1476
+ /**
1477
+ * TODO what is the purpose of this function?
1478
+ * @deprecated
1479
+ */
1480
+ contain(arr, item) {
1481
+ return (arr.filter(l => {
1482
+ if (l instanceof RegExp) {
1483
+ return l.test(item);
1484
+ }
1485
+ if (l === item) {
1486
+ return true;
1487
+ }
1488
+ if (item.match && typeof item.match === 'function' ? item.match(l) : false) {
1489
+ return true;
1490
+ }
1491
+ return false;
1492
+ }).length > 0);
1493
+ }
1494
+ }
1495
+ ;
1496
+ ({}); // @--end-of-file-for-module=tnp-core lib/helpers-isomorphic.ts
1497
+
1498
+ /* */
1499
+ /* */
1500
+ /* */
1501
+ const KEY = {
1502
+ LAST_ERROR: Symbol(),
1503
+ LAST_INFO: Symbol(),
1504
+ LAST_WARN: Symbol(),
1505
+ LAST_LOG: Symbol(),
1506
+ LAST_SUCCESS: Symbol(),
1507
+ LAST_TASK_STARTED: Symbol(),
1508
+ LAST_TASK_DONE: Symbol(),
1509
+ };
1510
+ const KEY_COUNT = {
1511
+ LAST_ERROR: Symbol(),
1512
+ LAST_INFO: Symbol(),
1513
+ LAST_WARN: Symbol(),
1514
+ LAST_LOG: Symbol(),
1515
+ LAST_SUCCESS: Symbol(),
1516
+ LAST_TASK_STARTED: Symbol(),
1517
+ LAST_TASK_DONE: Symbol(),
1518
+ };
1519
+ const KEY_IMPORTANTCE = {
1520
+ LAST_ERROR: Symbol(),
1521
+ LAST_INFO: Symbol(),
1522
+ LAST_WARN: Symbol(),
1523
+ LAST_LOG: Symbol(),
1524
+ LAST_SUCCESS: Symbol(),
1525
+ LAST_TASK_STARTED: Symbol(),
1526
+ LAST_TASK_DONE: Symbol(),
1527
+ };
1528
+ /* */
1529
+ /* */
1530
+ /* */
1531
+ /* */
1532
+ /* */
1533
+ /* */
1534
+ /* */
1535
+ /* */
1536
+ /* */
1537
+ /* */
1538
+ /* */
1539
+ /* */
1540
+ /* */
1541
+ /* */
1542
+ /* */
1543
+ /* */
1544
+ /* */
1545
+ /* */
1546
+ /* */
1547
+ /* */
1548
+ /* */
1549
+ const LIMIT = 10;
1550
+ class HelpersMessages extends HelpersIsomorphic {
1551
+ msgCacheClear() {
1169
1552
  /* */
1170
1553
  /* */
1171
1554
  /* */
1172
1555
  /* */
1173
1556
  /* */
1174
1557
  }
1558
+ renderError(err) {
1559
+ if (this.isBrowser) {
1560
+ console.error(err);
1561
+ }
1562
+ else {
1563
+ /* */
1564
+ /* */
1565
+ /* */
1566
+ /* */
1567
+ /* */
1568
+ /* */
1569
+ /* */
1570
+ /* */
1571
+ /* */
1572
+ }
1573
+ }
1175
1574
  /**
1176
- * Logs not visible in normal use of taon-cli
1575
+ * Throw error and exit process
1576
+ * make sure browser or nodejs will not continue
1577
+ * @param details
1177
1578
  */
1178
- logSuccess(details) {
1579
+ throw(details) {
1580
+ if (this.isBrowser) {
1581
+ document.body.innerHTML =
1582
+ '<h1>Application has encountered an error and stopped.</h1>';
1583
+ document.body.style.pointerEvents = 'none';
1584
+ /* */
1585
+ /* */
1586
+ /* */
1587
+ /* */
1588
+ }
1589
+ throw new Error(details);
1590
+ }
1591
+ error(details, noExit = false, noTrace = false) {
1592
+ if (Helpers.isBrowser) {
1593
+ console.error(details);
1594
+ return;
1595
+ }
1179
1596
  /* */
1180
1597
  /* */
1181
1598
  /* */
1182
1599
  /* */
1183
1600
  /* */
1184
- return (void 0);
1185
- }
1186
- /**
1187
- * Logs not visible in normal use of taon-cli
1188
- */
1189
- logInfo(details, repeatable = false) {
1190
1601
  /* */
1191
1602
  /* */
1192
1603
  /* */
1193
1604
  /* */
1194
1605
  /* */
1195
- return (void 0);
1196
- }
1197
- /**
1198
- * Logs not visible in normal use of taon-cli
1199
- */
1200
- logError(details, noExit = false, noTrace = false) {
1201
1606
  /* */
1202
1607
  /* */
1203
1608
  /* */
1204
1609
  /* */
1205
1610
  /* */
1206
- return (void 0);
1207
- }
1208
- /**
1209
- * Logs not visible in normal use of taon-cli
1210
- */
1211
- logWarn(details, trace = false) {
1212
1611
  /* */
1213
1612
  /* */
1214
1613
  /* */
1215
1614
  /* */
1216
1615
  /* */
1217
- return (void 0);
1218
- }
1219
- warn(details, trace = false) {
1220
- if (Helpers.isBrowser) {
1221
- console.warn(details);
1222
- return;
1223
- }
1224
1616
  /* */
1225
1617
  /* */
1226
1618
  /* */
@@ -1251,6 +1643,25 @@ class HelpersMessages extends HelpersIsomorphic {
1251
1643
  /* */
1252
1644
  /* */
1253
1645
  /* */
1646
+ }
1647
+ info(details, repeatable = false) {
1648
+ /* */
1649
+ /* */
1650
+ /* */
1651
+ /* */
1652
+ /* */
1653
+ /* */
1654
+ if (Helpers.isBrowser) {
1655
+ console.info(details);
1656
+ return;
1657
+ }
1658
+ /* */
1659
+ /* */
1660
+ /* */
1661
+ /* */
1662
+ /* */
1663
+ /* */
1664
+ /* */
1254
1665
  /* */
1255
1666
  /* */
1256
1667
  /* */
@@ -1273,60 +1684,26 @@ class HelpersMessages extends HelpersIsomorphic {
1273
1684
  /* */
1274
1685
  /* */
1275
1686
  /* */
1276
- }
1277
- }
1278
- function transformData(details) {
1279
- if (typeof details === 'object') {
1280
- if (Array.isArray(details)) {
1281
- return details.join('\n');
1282
- }
1283
- try {
1284
- const json = JSON.stringify(details);
1285
- details = json;
1286
- }
1287
- catch (error) {
1288
- return details;
1289
- }
1290
- }
1291
- return details;
1292
- }
1293
- ;
1294
- ({}); // @--end-of-file-for-module=tnp-core lib/helpers-messages.ts
1295
-
1296
- const encoding = 'utf8';
1297
- /* */
1298
- /* */
1299
- /* */
1300
- const WEBSQL_PROC_MOCK_PROCESSES_PID = {};
1301
- const WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
1302
- class HelpersCore extends HelpersMessages {
1303
- static get InstanceCore() {
1304
- if (!HelpersCore._instanceCore) {
1305
- HelpersCore._instanceCore = new HelpersCore();
1306
- }
1307
- return HelpersCore._instanceCore;
1308
- }
1309
- /* */
1310
- /* */
1311
- /* */
1312
- /* */
1313
- /* */
1314
- /* */
1315
- /* */
1316
- /* */
1317
- /* */
1318
- /* */
1319
- /* */
1320
- constructor() {
1321
- super();
1322
1687
  /* */
1323
1688
  /* */
1324
- this.bigMaxBuffer = 2024 * 500;
1325
1689
  /* */
1326
1690
  /* */
1327
1691
  /* */
1328
1692
  }
1329
- get isWsl() {
1693
+ success(details) {
1694
+ if (Helpers.isBrowser) {
1695
+ console.info(details);
1696
+ return;
1697
+ }
1698
+ /* */
1699
+ /* */
1700
+ /* */
1701
+ /* */
1702
+ /* */
1703
+ /* */
1704
+ /* */
1705
+ /* */
1706
+ /* */
1330
1707
  /* */
1331
1708
  /* */
1332
1709
  /* */
@@ -1344,9 +1721,6 @@ class HelpersCore extends HelpersMessages {
1344
1721
  /* */
1345
1722
  /* */
1346
1723
  /* */
1347
- return (void 0);
1348
- }
1349
- isRunningInDocker() {
1350
1724
  /* */
1351
1725
  /* */
1352
1726
  /* */
@@ -1354,47 +1728,34 @@ class HelpersCore extends HelpersMessages {
1354
1728
  /* */
1355
1729
  /* */
1356
1730
  /* */
1357
- return (void 0);
1358
- }
1359
- clearConsole() {
1360
- Helpers.msgCacheClear();
1361
- console.log('\x1Bc');
1362
- }
1363
- /**
1364
- * get electron browser ipc renderer
1365
- */
1366
- get ipcRenderer() {
1367
1731
  /* */
1368
1732
  /* */
1369
- if (!this.isElectron) {
1370
- return;
1371
- }
1372
- return window.require('electron')
1373
- .ipcRenderer;
1374
- }
1375
- /**
1376
- * get electron web frame
1377
- */
1378
- get webFrame() {
1379
1733
  /* */
1380
1734
  /* */
1381
- if (!this.isElectron) {
1382
- return;
1383
- }
1384
- return window.require('electron').webFrame;
1385
1735
  }
1386
1736
  /**
1387
- * get electron backend ipc main proces
1737
+ *
1738
+ * @param details
1739
+ * @param isLogTask is less important log task
1740
+ * @returns
1388
1741
  */
1389
- get ipcMain() {
1742
+ taskStarted(details, isLogTask = false) {
1743
+ if (Helpers.isBrowser) {
1744
+ console.info(details);
1745
+ return;
1746
+ }
1747
+ /* */
1748
+ /* */
1749
+ /* */
1750
+ /* */
1751
+ /* */
1752
+ /* */
1753
+ /* */
1390
1754
  /* */
1391
1755
  /* */
1392
1756
  /* */
1393
1757
  /* */
1394
1758
  /* */
1395
- return (void 0);
1396
- }
1397
- getElectronWindow({ allowRunningInsecureContent = true, } = {}) {
1398
1759
  /* */
1399
1760
  /* */
1400
1761
  /* */
@@ -1410,19 +1771,8 @@ class HelpersCore extends HelpersMessages {
1410
1771
  /* */
1411
1772
  /* */
1412
1773
  /* */
1413
- return (void 0);
1414
- }
1415
- mediaTypeFromSrc(src) {
1416
- const ext = path.extname(src);
1417
- const media = CoreModels.mimeTypes[ext];
1418
- return _.first(media?.split('/'));
1419
- }
1420
- sleep(seconds = 1) {
1421
1774
  /* */
1422
1775
  /* */
1423
- return (void 0);
1424
- }
1425
- removeIfExists(absoluteFileOrFolderPath) {
1426
1776
  /* */
1427
1777
  /* */
1428
1778
  /* */
@@ -1441,12 +1791,12 @@ class HelpersCore extends HelpersMessages {
1441
1791
  /* */
1442
1792
  /* */
1443
1793
  /* */
1444
- return (void 0);
1445
- }
1446
- relative(cwd, to) {
1447
- return crossPlatformPath(path.relative(cwd, to));
1448
1794
  }
1449
- removeFileIfExists(absoluteFilePath) {
1795
+ taskDone(details, isLessImportant = false) {
1796
+ if (Helpers.isBrowser) {
1797
+ console.info(details);
1798
+ return;
1799
+ }
1450
1800
  /* */
1451
1801
  /* */
1452
1802
  /* */
@@ -1460,9 +1810,6 @@ class HelpersCore extends HelpersMessages {
1460
1810
  /* */
1461
1811
  /* */
1462
1812
  /* */
1463
- return (void 0);
1464
- }
1465
- removeFolderIfExists(absoluteFolderPath) {
1466
1813
  /* */
1467
1814
  /* */
1468
1815
  /* */
@@ -1477,36 +1824,6 @@ class HelpersCore extends HelpersMessages {
1477
1824
  /* */
1478
1825
  /* */
1479
1826
  /* */
1480
- return (void 0);
1481
- }
1482
- /**
1483
- * leave max 1 empty line
1484
- */
1485
- removeEmptyLineFromString(str) {
1486
- const lines = (str || '').split('\n');
1487
- let previousWasEmpty = false;
1488
- return lines
1489
- .filter(line => {
1490
- if (line.trim() === '') {
1491
- if (previousWasEmpty) {
1492
- return false;
1493
- }
1494
- else {
1495
- previousWasEmpty = true;
1496
- return true;
1497
- }
1498
- }
1499
- else {
1500
- previousWasEmpty = false;
1501
- return true;
1502
- }
1503
- })
1504
- .join('\n');
1505
- }
1506
- /**
1507
- * @deprecated
1508
- */
1509
- tryRemoveDir(dirpath, contentOnly = false, omitWarningNotExisted = false) {
1510
1827
  /* */
1511
1828
  /* */
1512
1829
  /* */
@@ -1532,6 +1849,33 @@ class HelpersCore extends HelpersMessages {
1532
1849
  /* */
1533
1850
  /* */
1534
1851
  /* */
1852
+ }
1853
+ log(details, debugLevel = 0) {
1854
+ if (Helpers.isBrowser) {
1855
+ console.log(details);
1856
+ return;
1857
+ }
1858
+ /* */
1859
+ /* */
1860
+ /* */
1861
+ /* */
1862
+ /* */
1863
+ /* */
1864
+ /* */
1865
+ /* */
1866
+ /* */
1867
+ /* */
1868
+ /* */
1869
+ /* */
1870
+ /* */
1871
+ /* */
1872
+ /* */
1873
+ /* */
1874
+ /* */
1875
+ /* */
1876
+ /* */
1877
+ /* */
1878
+ /* */
1535
1879
  /* */
1536
1880
  /* */
1537
1881
  /* */
@@ -1543,9 +1887,6 @@ class HelpersCore extends HelpersMessages {
1543
1887
  /* */
1544
1888
  /* */
1545
1889
  /* */
1546
- return (void 0);
1547
- }
1548
- remove(fileOrFolderPathOrPatter, exactFolder = false) {
1549
1890
  /* */
1550
1891
  /* */
1551
1892
  /* */
@@ -1556,19 +1897,6 @@ class HelpersCore extends HelpersMessages {
1556
1897
  /* */
1557
1898
  /* */
1558
1899
  /* */
1559
- return (void 0);
1560
- }
1561
- /* */
1562
- /* */
1563
- /* */
1564
- /* */
1565
- /* */
1566
- /* */
1567
- /* */
1568
- /* */
1569
- /* */
1570
- /* */
1571
- get isRunningInGitBash() {
1572
1900
  /* */
1573
1901
  /* */
1574
1902
  /* */
@@ -1577,73 +1905,140 @@ class HelpersCore extends HelpersMessages {
1577
1905
  /* */
1578
1906
  /* */
1579
1907
  /* */
1580
- return (void 0);
1581
1908
  }
1582
1909
  /**
1583
- * Check if the current shell is supported by Taon framework.
1910
+ * Logs not visible in normal use of taon-cli
1584
1911
  */
1585
- get isSupportedTaonTerminal() {
1912
+ logSuccess(details) {
1913
+ /* */
1914
+ /* */
1915
+ /* */
1586
1916
  /* */
1587
1917
  /* */
1588
1918
  return (void 0);
1589
1919
  }
1590
1920
  /**
1591
- * check if function is class
1921
+ * Logs not visible in normal use of taon-cli
1592
1922
  */
1593
- isClass(funcOrClass) {
1594
- let isClass = false;
1595
- if (typeof funcOrClass === 'function') {
1596
- isClass =
1597
- !!funcOrClass.prototype &&
1598
- Object.getOwnPropertyNames(funcOrClass.prototype).filter(f => f !== 'constructor').length > 0;
1599
- }
1600
- return isClass;
1923
+ logInfo(details, repeatable = false) {
1924
+ /* */
1925
+ /* */
1926
+ /* */
1927
+ /* */
1928
+ /* */
1929
+ return (void 0);
1601
1930
  }
1602
1931
  /**
1603
- * check if data is nodejs/browser blob
1604
- *
1605
- * @param maybeBlob
1606
- * @returns
1932
+ * Logs not visible in normal use of taon-cli
1607
1933
  */
1608
- isBlob(maybeBlob) {
1609
- return maybeBlob instanceof Blob; // || toString.call(maybeBlob) === '[object Blob]';
1934
+ logError(details, noExit = false, noTrace = false) {
1935
+ /* */
1936
+ /* */
1937
+ /* */
1938
+ /* */
1939
+ /* */
1940
+ return (void 0);
1610
1941
  }
1611
1942
  /**
1612
- * Check if data is nodejs buffer
1613
- *
1614
- * @param maybeNodejsBuffer
1615
- * @returns
1943
+ * Logs not visible in normal use of taon-cli
1616
1944
  */
1617
- /* */
1618
- /* */
1619
- /* */
1620
- /* */
1621
- removeSlashAtEnd(s) {
1622
- s = s?.endsWith(`/`) ? s.slice(0, s.length - 1) : s;
1623
- return s;
1624
- }
1625
- removeSlashAtBegin(s) {
1626
- s = s?.startsWith(`/`) ? s.slice(1) : s;
1627
- return s;
1945
+ logWarn(details, trace = false) {
1946
+ /* */
1947
+ /* */
1948
+ /* */
1949
+ /* */
1950
+ /* */
1951
+ return (void 0);
1628
1952
  }
1629
- /**
1630
- * stringify to pretty json string
1631
- */
1632
- stringify(inputObject) {
1633
- return JSON.stringify(inputObject, null, 2);
1953
+ warn(details, trace = false) {
1954
+ if (Helpers.isBrowser) {
1955
+ console.warn(details);
1956
+ return;
1957
+ }
1958
+ /* */
1959
+ /* */
1960
+ /* */
1961
+ /* */
1962
+ /* */
1963
+ /* */
1964
+ /* */
1965
+ /* */
1966
+ /* */
1967
+ /* */
1968
+ /* */
1969
+ /* */
1970
+ /* */
1971
+ /* */
1972
+ /* */
1973
+ /* */
1974
+ /* */
1975
+ /* */
1976
+ /* */
1977
+ /* */
1978
+ /* */
1979
+ /* */
1980
+ /* */
1981
+ /* */
1982
+ /* */
1983
+ /* */
1984
+ /* */
1985
+ /* */
1986
+ /* */
1987
+ /* */
1988
+ /* */
1989
+ /* */
1990
+ /* */
1991
+ /* */
1992
+ /* */
1993
+ /* */
1994
+ /* */
1995
+ /* */
1996
+ /* */
1997
+ /* */
1998
+ /* */
1999
+ /* */
2000
+ /* */
2001
+ /* */
2002
+ /* */
2003
+ /* */
2004
+ /* */
2005
+ /* */
2006
+ /* */
2007
+ /* */
2008
+ /* */
2009
+ /* */
1634
2010
  }
1635
- async runSyncOrAsync(fnOrOptions) {
1636
- if (_.isUndefined(fnOrOptions)) {
1637
- return void 0;
2011
+ }
2012
+ function transformData(details) {
2013
+ if (typeof details === 'object') {
2014
+ if (Array.isArray(details)) {
2015
+ return details.join('\n');
1638
2016
  }
1639
- let promisOrValue;
1640
- const { functionFn, context, arrayOfParams } = fnOrOptions;
1641
- promisOrValue = functionFn.apply(context, arrayOfParams);
1642
- // // @ts-ignore
1643
- if (promisOrValue instanceof Promise) {
1644
- promisOrValue = Promise.resolve(promisOrValue);
2017
+ try {
2018
+ const json = JSON.stringify(details);
2019
+ details = json;
2020
+ }
2021
+ catch (error) {
2022
+ return details;
1645
2023
  }
1646
- return promisOrValue;
2024
+ }
2025
+ return details;
2026
+ }
2027
+ ;
2028
+ ({}); // @--end-of-file-for-module=tnp-core lib/helpers-messages.ts
2029
+
2030
+ const encoding = 'utf8';
2031
+ /* */
2032
+ /* */
2033
+ /* */
2034
+ const WEBSQL_PROC_MOCK_PROCESSES_PID = {};
2035
+ const WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
2036
+ class HelpersCore extends HelpersMessages {
2037
+ static get InstanceCore() {
2038
+ if (!HelpersCore._instanceCore) {
2039
+ HelpersCore._instanceCore = new HelpersCore();
2040
+ }
2041
+ return HelpersCore._instanceCore;
1647
2042
  }
1648
2043
  /* */
1649
2044
  /* */
@@ -1656,264 +2051,72 @@ class HelpersCore extends HelpersMessages {
1656
2051
  /* */
1657
2052
  /* */
1658
2053
  /* */
1659
- /* */
1660
- /* */
1661
- /* */
1662
- /* */
1663
- /* */
1664
- /* */
1665
- /* */
1666
- /* */
1667
- /* */
1668
- /* */
1669
- /* */
1670
- /* */
1671
- /* */
1672
- /* */
1673
- /* */
1674
- /* */
1675
- /* */
1676
- /* */
1677
- /* */
1678
- /* */
1679
- /* */
1680
- /* */
1681
- /* */
1682
- /* */
1683
- /* */
1684
- /* */
1685
- /* */
1686
- /* */
1687
- /* */
1688
- /* */
1689
- /* */
1690
- /* */
1691
- /* */
1692
- /* */
1693
- /* */
1694
- /* */
1695
- /* */
1696
- /* */
1697
- /* */
1698
- /* */
1699
- /* */
1700
- /* */
1701
- /* */
1702
- /* */
1703
- /* */
1704
- /* */
1705
- /* */
1706
- /* */
1707
- /* */
1708
- /* */
1709
- /* */
1710
- /* */
1711
- /* */
1712
- /* */
1713
- /* */
1714
- /* */
1715
- /* */
1716
- /* */
1717
- /* */
1718
- /* */
1719
- /* */
1720
- /* */
1721
- /* */
1722
- /* */
1723
- /* */
1724
- /* */
1725
- /* */
1726
- /* */
1727
- /* */
1728
- /* */
1729
- /* */
1730
- /* */
1731
- /* */
1732
- /* */
1733
- /* */
1734
- /* */
1735
- /* */
1736
- /* */
1737
- /* */
1738
- /* */
1739
- /* */
1740
- /* */
1741
- /* */
1742
- /* */
1743
- /* */
1744
- /* */
1745
- /* */
1746
- /* */
1747
- /* */
1748
- /* */
1749
- /* */
1750
- /* */
1751
- /* */
1752
- /* */
1753
- /* */
1754
- /* */
1755
- /* */
1756
- /* */
1757
- /* */
1758
- /* */
1759
- /* */
1760
- /* */
1761
- /* */
1762
- /* */
1763
- /* */
1764
- /* */
1765
- /* */
1766
- /* */
1767
- /* */
1768
- /* */
1769
- /* */
1770
- /* */
1771
- /* */
1772
- /* */
1773
- /* */
1774
- /* */
1775
- /* */
1776
- /* */
1777
- /* */
1778
- /* */
1779
- /* */
1780
- /* */
1781
- /* */
1782
- /* */
1783
- /* */
1784
- /* */
1785
- /* */
1786
- /* */
1787
- /* */
1788
- /* */
1789
- /* */
1790
- /* */
1791
- /* */
1792
- /* */
1793
- /* */
1794
- /* */
1795
- /* */
1796
- /* */
1797
- /* */
1798
- /* */
1799
- /* */
1800
- /* */
1801
- /* */
1802
- /* */
1803
- /* */
1804
- /* */
1805
- /* */
1806
- /* */
1807
- /* */
1808
- /* */
1809
- /* */
1810
- /* */
1811
- /* */
1812
- /* */
1813
- /* */
1814
- /* */
1815
- /* */
1816
- /* */
1817
- /* */
1818
- /* */
1819
- /* */
1820
- /* */
1821
- /* */
1822
- /* */
1823
- /* */
1824
- /* */
1825
- /* */
1826
- /* */
1827
- /* */
1828
- /* */
1829
- /* */
1830
- /* */
1831
- /* */
1832
- /* */
1833
- /* */
1834
- /* */
1835
- /* */
1836
- /* */
1837
- /* */
1838
- /* */
1839
- /* */
1840
- /* */
1841
- /* */
1842
- /* */
1843
- /* */
1844
- /* */
1845
- /* */
1846
- /* */
1847
- /* */
1848
- /* */
1849
- /* */
1850
- /* */
1851
- /* */
1852
- /* */
1853
- /* */
1854
- /* */
1855
- /* */
1856
- /* */
1857
- /* */
1858
- /* */
1859
- /* */
1860
- /* */
1861
- /* */
1862
- /* */
1863
- /* */
1864
- /* */
1865
- /* */
1866
- /* */
1867
- /* */
1868
- /* */
1869
- /* */
1870
- /* */
1871
- /* */
1872
- /* */
1873
- /* */
1874
- /* */
1875
- /* */
1876
- /* */
1877
- /* */
1878
- /* */
1879
- /* */
1880
- /* */
1881
- /* */
1882
- /* */
1883
- /* */
1884
- /* */
1885
- /* */
1886
- /* */
1887
- /* */
1888
- /* */
1889
- /* */
1890
- /* */
1891
- /* */
1892
- /* */
1893
- /* */
1894
- /**
1895
- * symlink may have existed or unexisted destiantion url
1896
- * @param destUrl M
1897
- */
1898
- isSymlinkThatMatchesUrl(possibleSymlink, destUrl, absoluteFileMatch = false) {
1899
- /* */
1900
- /* */
1901
- /* */
1902
- /* */
2054
+ constructor() {
2055
+ super();
1903
2056
  /* */
1904
2057
  /* */
2058
+ this.bigMaxBuffer = 2024 * 500;
1905
2059
  /* */
1906
2060
  /* */
1907
2061
  /* */
2062
+ }
2063
+ /**
2064
+ * @deprecated use UtilsOs.isRunningInsideWsl()
2065
+ */
2066
+ get isWsl() {
2067
+ return UtilsOs.isRunningInWsl();
2068
+ }
2069
+ /**
2070
+ * @deprecated use UtilsOs.isRunningInDocker
2071
+ */
2072
+ isRunningInDocker() {
2073
+ return UtilsOs.isRunningInDocker();
2074
+ }
2075
+ /**
2076
+ * @deprecated use UtilsOs.isRunningInLinuxGraphicEnvironment
2077
+ */
2078
+ isRunningInLinuxGraphicsCapableEnvironment() {
2079
+ return UtilsOs.isRunningInLinuxGraphicsCapableEnvironment();
2080
+ }
2081
+ clearConsole() {
2082
+ Helpers.msgCacheClear();
2083
+ console.log('\x1Bc');
2084
+ }
2085
+ /**
2086
+ * get electron browser ipc renderer
2087
+ */
2088
+ get ipcRenderer() {
1908
2089
  /* */
1909
2090
  /* */
2091
+ if (!this.isElectron) {
2092
+ return;
2093
+ }
2094
+ return window.require('electron')
2095
+ .ipcRenderer;
2096
+ }
2097
+ /**
2098
+ * get electron web frame
2099
+ */
2100
+ get webFrame() {
1910
2101
  /* */
1911
2102
  /* */
2103
+ if (!this.isElectron) {
2104
+ return;
2105
+ }
2106
+ return window.require('electron').webFrame;
2107
+ }
2108
+ /**
2109
+ * get electron backend ipc main proces
2110
+ */
2111
+ get ipcMain() {
1912
2112
  /* */
1913
2113
  /* */
1914
2114
  /* */
1915
2115
  /* */
1916
2116
  /* */
2117
+ return (void 0);
2118
+ }
2119
+ getElectronWindow({ allowRunningInsecureContent = true, } = {}) {
1917
2120
  /* */
1918
2121
  /* */
1919
2122
  /* */
@@ -1931,25 +2134,17 @@ class HelpersCore extends HelpersMessages {
1931
2134
  /* */
1932
2135
  return (void 0);
1933
2136
  }
1934
- isSymlinkFileExitedOrUnexisted(filePath) {
1935
- /* */
1936
- /* */
1937
- /* */
1938
- /* */
1939
- /* */
1940
- /* */
1941
- /* */
1942
- /* */
2137
+ mediaTypeFromSrc(src) {
2138
+ const ext = path.extname(src);
2139
+ const media = CoreModels.mimeTypes[ext];
2140
+ return _.first(media?.split('/'));
2141
+ }
2142
+ sleep(seconds = 1) {
1943
2143
  /* */
1944
2144
  /* */
1945
2145
  return (void 0);
1946
2146
  }
1947
- /**
1948
- * If symbolnk link that target file does not exits
1949
- */
1950
- isUnexistedLink(filePath) {
1951
- /* */
1952
- /* */
2147
+ removeIfExists(absoluteFileOrFolderPath) {
1953
2148
  /* */
1954
2149
  /* */
1955
2150
  /* */
@@ -1971,18 +2166,12 @@ class HelpersCore extends HelpersMessages {
1971
2166
  return (void 0);
1972
2167
  }
1973
2168
  /**
1974
- * @param existedLink check if source of link exists
2169
+ * path.relative that return cross platform path
1975
2170
  */
1976
- isExistedSymlink(filePath) {
1977
- /* */
1978
- /* */
1979
- /* */
1980
- /* */
1981
- /* */
1982
- /* */
1983
- /* */
1984
- /* */
1985
- /* */
2171
+ relative(cwd, to) {
2172
+ return crossPlatformPath(path.relative(cwd, to));
2173
+ }
2174
+ removeFileIfExists(absoluteFilePath) {
1986
2175
  /* */
1987
2176
  /* */
1988
2177
  /* */
@@ -1998,35 +2187,7 @@ class HelpersCore extends HelpersMessages {
1998
2187
  /* */
1999
2188
  return (void 0);
2000
2189
  }
2001
- /* */
2002
- /* */
2003
- /* */
2004
- /* */
2005
- /* */
2006
- /* */
2007
- /* */
2008
- /* */
2009
- /* */
2010
- /* */
2011
- /* */
2012
- /* */
2013
- /* */
2014
- /* */
2015
- /* */
2016
- /* */
2017
- /* */
2018
- /* */
2019
- exists(folderOrFilePath) {
2020
- /* */
2021
- /* */
2022
- /* */
2023
- /* */
2024
- /* */
2025
- /* */
2026
- /* */
2027
- /* */
2028
- /* */
2029
- /* */
2190
+ removeFolderIfExists(absoluteFolderPath) {
2030
2191
  /* */
2031
2192
  /* */
2032
2193
  /* */
@@ -2044,26 +2205,33 @@ class HelpersCore extends HelpersMessages {
2044
2205
  return (void 0);
2045
2206
  }
2046
2207
  /**
2047
- * this is HACK for running procesess inside processes
2208
+ * leave max 1 empty line
2048
2209
  */
2049
- _fixCommand(command) {
2050
- if ((command.startsWith('tnp ') || command.startsWith('taon ')) && // TODO every cli projects here that uses run and need to kill process easly!
2051
- command.search('-spinner=false') === -1 &&
2052
- command.search('-spinner=off') === -1) {
2053
- command = `${command} -spinner=false`;
2054
- }
2055
- if (global.skipCoreCheck &&
2056
- (command.startsWith('tnp ') || command.startsWith('taon '))) {
2057
- command = `${command} --skipCoreCheck`;
2058
- }
2059
- return command;
2210
+ removeEmptyLineFromString(str) {
2211
+ const lines = (str || '').split('\n');
2212
+ let previousWasEmpty = false;
2213
+ return lines
2214
+ .filter(line => {
2215
+ if (line.trim() === '') {
2216
+ if (previousWasEmpty) {
2217
+ return false;
2218
+ }
2219
+ else {
2220
+ previousWasEmpty = true;
2221
+ return true;
2222
+ }
2223
+ }
2224
+ else {
2225
+ previousWasEmpty = false;
2226
+ return true;
2227
+ }
2228
+ })
2229
+ .join('\n');
2060
2230
  }
2061
- command(command) {
2062
- command = Helpers._fixCommand(command);
2063
- return {
2064
- /* */
2065
- /* */
2066
- /* */
2231
+ /**
2232
+ * @deprecated
2233
+ */
2234
+ tryRemoveDir(dirpath, contentOnly = false, omitWarningNotExisted = false) {
2067
2235
  /* */
2068
2236
  /* */
2069
2237
  /* */
@@ -2100,6 +2268,9 @@ class HelpersCore extends HelpersMessages {
2100
2268
  /* */
2101
2269
  /* */
2102
2270
  /* */
2271
+ return (void 0);
2272
+ }
2273
+ remove(fileOrFolderPathOrPatter, exactFolder = false) {
2103
2274
  /* */
2104
2275
  /* */
2105
2276
  /* */
@@ -2110,23 +2281,95 @@ class HelpersCore extends HelpersMessages {
2110
2281
  /* */
2111
2282
  /* */
2112
2283
  /* */
2284
+ return (void 0);
2285
+ }
2286
+ /* */
2287
+ /* */
2288
+ /* */
2289
+ /* */
2290
+ /* */
2291
+ /* */
2292
+ /* */
2293
+ /* */
2294
+ /* */
2295
+ /* */
2296
+ get isRunningInGitBash() {
2113
2297
  /* */
2114
2298
  /* */
2115
2299
  /* */
2116
2300
  /* */
2117
- };
2301
+ /* */
2302
+ /* */
2303
+ /* */
2304
+ /* */
2305
+ return (void 0);
2118
2306
  }
2119
- wait(second) {
2120
- return new Promise((resolve, reject) => {
2121
- setTimeout(() => {
2122
- resolve(void 0);
2123
- }, second * 1000);
2124
- });
2307
+ /**
2308
+ * Check if the current shell is supported by Taon framework.
2309
+ */
2310
+ get isSupportedTaonTerminal() {
2311
+ /* */
2312
+ /* */
2313
+ return (void 0);
2125
2314
  }
2315
+ /**
2316
+ * check if function is class
2317
+ */
2318
+ isClass(funcOrClass) {
2319
+ let isClass = false;
2320
+ if (typeof funcOrClass === 'function') {
2321
+ isClass =
2322
+ !!funcOrClass.prototype &&
2323
+ Object.getOwnPropertyNames(funcOrClass.prototype).filter(f => f !== 'constructor').length > 0;
2324
+ }
2325
+ return isClass;
2326
+ }
2327
+ /**
2328
+ * check if data is nodejs/browser blob
2329
+ *
2330
+ * @param maybeBlob
2331
+ * @returns
2332
+ */
2333
+ isBlob(maybeBlob) {
2334
+ return maybeBlob instanceof Blob; // || toString.call(maybeBlob) === '[object Blob]';
2335
+ }
2336
+ /**
2337
+ * Check if data is nodejs buffer
2338
+ *
2339
+ * @param maybeNodejsBuffer
2340
+ * @returns
2341
+ */
2126
2342
  /* */
2127
2343
  /* */
2128
2344
  /* */
2129
2345
  /* */
2346
+ removeSlashAtEnd(s) {
2347
+ s = s?.endsWith(`/`) ? s.slice(0, s.length - 1) : s;
2348
+ return s;
2349
+ }
2350
+ removeSlashAtBegin(s) {
2351
+ s = s?.startsWith(`/`) ? s.slice(1) : s;
2352
+ return s;
2353
+ }
2354
+ /**
2355
+ * stringify to pretty json string
2356
+ */
2357
+ stringify(inputObject) {
2358
+ return JSON.stringify(inputObject, null, 2);
2359
+ }
2360
+ async runSyncOrAsync(fnOrOptions) {
2361
+ if (_.isUndefined(fnOrOptions)) {
2362
+ return void 0;
2363
+ }
2364
+ let promisOrValue;
2365
+ const { functionFn, context, arrayOfParams } = fnOrOptions;
2366
+ promisOrValue = functionFn.apply(context, arrayOfParams);
2367
+ // // @ts-ignore
2368
+ if (promisOrValue instanceof Promise) {
2369
+ promisOrValue = Promise.resolve(promisOrValue);
2370
+ }
2371
+ return promisOrValue;
2372
+ }
2130
2373
  /* */
2131
2374
  /* */
2132
2375
  /* */
@@ -2201,176 +2444,661 @@ class HelpersCore extends HelpersMessages {
2201
2444
  /* */
2202
2445
  /* */
2203
2446
  /* */
2204
- async killProcessByPort(portOrPortsToKill, options) {
2205
- /* */
2206
- /* */
2207
- /* */
2208
- /* */
2209
- /* */
2210
- /* */
2211
- /* */
2212
- /* */
2213
- /* */
2214
- /* */
2215
- /* */
2216
- /* */
2217
- /* */
2218
- /* */
2219
- /* */
2220
- /* */
2221
- /* */
2222
- /* */
2223
- /* */
2224
- /* */
2225
- /* */
2226
- /* */
2227
- /* */
2228
- /* */
2229
- /* */
2230
- /* */
2231
- /* */
2232
- /* */
2233
- /* */
2234
- /* */
2235
- /* */
2236
- /* */
2237
- /* */
2238
- /* */
2239
- /* */
2240
- /* */
2241
- /* */
2242
- /* */
2243
- /* */
2244
- /* */
2245
- /* */
2246
- /* */
2247
- /* */
2248
- /* */
2249
- return (void 0);
2250
- }
2251
- async killOnPort(portOrPortsToKill, options) {
2252
- return await Helpers.killProcessByPort(portOrPortsToKill, options);
2253
- }
2254
- killProcess(byPid) {
2255
- /* */
2256
- /* */
2257
- /* */
2258
- /* */
2259
- /* */
2260
- /* */
2261
- /* */
2262
- /* */
2263
- /* */
2264
- /* */
2265
- /* */
2266
- /* */
2267
- /* */
2268
- /* */
2269
- /* */
2270
- /* */
2271
- /* */
2272
- /* */
2273
- /* */
2274
- /* */
2275
- /* */
2276
- /* */
2277
- /* */
2278
- /* */
2279
- /* */
2280
- /* */
2281
- /* */
2282
- }
2283
- run(command, options) {
2284
- command = Helpers._fixCommand(command);
2285
- /* */
2286
- /* */
2287
- /* */
2288
- /* */
2289
- /* */
2290
- /* */
2291
- /* */
2292
- /* */
2293
- return {
2294
- /**
2295
- * start command as synchronous nodej proces
2296
- */
2297
- sync() {
2298
- /* */
2299
- /* */
2300
- /* */
2301
- /* */
2302
- /* */
2303
- /* */
2304
- /* */
2305
- /* */
2306
- /* */
2307
- /* */
2308
- /* */
2309
- /* */
2310
- /* */
2311
- /* */
2312
- /* */
2313
- /* */
2314
- /* */
2315
- /* */
2316
- /* */
2317
- /* */
2318
- /* */
2319
- /* */
2320
- /* */
2321
- /* */
2322
- /* */
2323
- /* */
2324
- /* */
2325
- /* */
2326
- /* */
2327
- /* */
2328
- /* */
2329
- return (void 0);
2330
- },
2331
- /**
2332
- * start command as asynchronous nodej proces
2333
- * @param detach (default: false) - if true process will be detached
2334
- */
2335
- async(detach = false, mockFun) {
2336
- if (mockFun) {
2337
- const subStdoutSub = new Subject();
2338
- const subStderSub = new Subject();
2339
- const exitSub = new Subject();
2340
- const subscribtions = [];
2341
- const procDummy = {
2342
- stdout: {
2343
- on(action, stdoutCallback) {
2344
- if (action == 'data') {
2345
- subscribtions.push(subStdoutSub.subscribe(d => {
2346
- stdoutCallback(d);
2347
- }));
2348
- }
2349
- },
2350
- },
2351
- stderr: {
2352
- on(action, stdoutCallback) {
2353
- if (action == 'data') {
2354
- subscribtions.push(subStderSub.subscribe(d => {
2355
- stdoutCallback(d);
2356
- }));
2357
- }
2358
- },
2359
- },
2360
- on(action, exitFun) {
2361
- if (action == 'exit') {
2362
- subscribtions.push(exitSub.subscribe(d => {
2363
- exitFun(d);
2364
- }));
2365
- }
2366
- }, // @ts-ignore
2367
- ppid: void 0, // @ts-ignore
2368
- pid: void 0,
2369
- };
2370
- procDummy.pid = Math.round(Math.random() * (1000 - 100)) + 100;
2371
- procDummy.ppid = procDummy.pid + 9999;
2372
- WEBSQL_PROC_MOCK_PROCESSES_PID[procDummy.pid] = procDummy;
2373
- if (!WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid]) {
2447
+ /* */
2448
+ /* */
2449
+ /* */
2450
+ /* */
2451
+ /* */
2452
+ /* */
2453
+ /* */
2454
+ /* */
2455
+ /* */
2456
+ /* */
2457
+ /* */
2458
+ /* */
2459
+ /* */
2460
+ /* */
2461
+ /* */
2462
+ /* */
2463
+ /* */
2464
+ /* */
2465
+ /* */
2466
+ /* */
2467
+ /* */
2468
+ /* */
2469
+ /* */
2470
+ /* */
2471
+ /* */
2472
+ /* */
2473
+ /* */
2474
+ /* */
2475
+ /* */
2476
+ /* */
2477
+ /* */
2478
+ /* */
2479
+ /* */
2480
+ /* */
2481
+ /* */
2482
+ /* */
2483
+ /* */
2484
+ /* */
2485
+ /* */
2486
+ /* */
2487
+ /* */
2488
+ /* */
2489
+ /* */
2490
+ /* */
2491
+ /* */
2492
+ /* */
2493
+ /* */
2494
+ /* */
2495
+ /* */
2496
+ /* */
2497
+ /* */
2498
+ /* */
2499
+ /* */
2500
+ /* */
2501
+ /* */
2502
+ /* */
2503
+ /* */
2504
+ /* */
2505
+ /* */
2506
+ /* */
2507
+ /* */
2508
+ /* */
2509
+ /* */
2510
+ /* */
2511
+ /* */
2512
+ /* */
2513
+ /* */
2514
+ /* */
2515
+ /* */
2516
+ /* */
2517
+ /* */
2518
+ /* */
2519
+ /* */
2520
+ /* */
2521
+ /* */
2522
+ /* */
2523
+ /* */
2524
+ /* */
2525
+ /* */
2526
+ /* */
2527
+ /* */
2528
+ /* */
2529
+ /* */
2530
+ /* */
2531
+ /* */
2532
+ /* */
2533
+ /* */
2534
+ /* */
2535
+ /* */
2536
+ /* */
2537
+ /* */
2538
+ /* */
2539
+ /* */
2540
+ /* */
2541
+ /* */
2542
+ /* */
2543
+ /* */
2544
+ /* */
2545
+ /* */
2546
+ /* */
2547
+ /* */
2548
+ /* */
2549
+ /* */
2550
+ /* */
2551
+ /* */
2552
+ /* */
2553
+ /* */
2554
+ /* */
2555
+ /* */
2556
+ /* */
2557
+ /* */
2558
+ /* */
2559
+ /* */
2560
+ /* */
2561
+ /* */
2562
+ /* */
2563
+ /* */
2564
+ /* */
2565
+ /* */
2566
+ /* */
2567
+ /* */
2568
+ /* */
2569
+ /* */
2570
+ /* */
2571
+ /* */
2572
+ /* */
2573
+ /* */
2574
+ /* */
2575
+ /* */
2576
+ /* */
2577
+ /* */
2578
+ /* */
2579
+ /* */
2580
+ /* */
2581
+ /* */
2582
+ /* */
2583
+ /* */
2584
+ /* */
2585
+ /* */
2586
+ /* */
2587
+ /* */
2588
+ /* */
2589
+ /* */
2590
+ /* */
2591
+ /* */
2592
+ /* */
2593
+ /* */
2594
+ /* */
2595
+ /* */
2596
+ /* */
2597
+ /* */
2598
+ /* */
2599
+ /* */
2600
+ /* */
2601
+ /* */
2602
+ /* */
2603
+ /* */
2604
+ /* */
2605
+ /* */
2606
+ /* */
2607
+ /* */
2608
+ /* */
2609
+ /* */
2610
+ /* */
2611
+ /* */
2612
+ /* */
2613
+ /* */
2614
+ /* */
2615
+ /* */
2616
+ /* */
2617
+ /* */
2618
+ /* */
2619
+ /**
2620
+ * symlink may have existed or unexisted destiantion url
2621
+ * @param destUrl M
2622
+ */
2623
+ isSymlinkThatMatchesUrl(possibleSymlink, destUrl, absoluteFileMatch = false) {
2624
+ /* */
2625
+ /* */
2626
+ /* */
2627
+ /* */
2628
+ /* */
2629
+ /* */
2630
+ /* */
2631
+ /* */
2632
+ /* */
2633
+ /* */
2634
+ /* */
2635
+ /* */
2636
+ /* */
2637
+ /* */
2638
+ /* */
2639
+ /* */
2640
+ /* */
2641
+ /* */
2642
+ /* */
2643
+ /* */
2644
+ /* */
2645
+ /* */
2646
+ /* */
2647
+ /* */
2648
+ /* */
2649
+ /* */
2650
+ /* */
2651
+ /* */
2652
+ /* */
2653
+ /* */
2654
+ /* */
2655
+ /* */
2656
+ /* */
2657
+ return (void 0);
2658
+ }
2659
+ isSymlinkFileExitedOrUnexisted(filePath) {
2660
+ /* */
2661
+ /* */
2662
+ /* */
2663
+ /* */
2664
+ /* */
2665
+ /* */
2666
+ /* */
2667
+ /* */
2668
+ /* */
2669
+ /* */
2670
+ return (void 0);
2671
+ }
2672
+ /**
2673
+ * If symbolnk link that target file does not exits
2674
+ */
2675
+ isUnexistedLink(filePath) {
2676
+ /* */
2677
+ /* */
2678
+ /* */
2679
+ /* */
2680
+ /* */
2681
+ /* */
2682
+ /* */
2683
+ /* */
2684
+ /* */
2685
+ /* */
2686
+ /* */
2687
+ /* */
2688
+ /* */
2689
+ /* */
2690
+ /* */
2691
+ /* */
2692
+ /* */
2693
+ /* */
2694
+ /* */
2695
+ /* */
2696
+ return (void 0);
2697
+ }
2698
+ /**
2699
+ * @param existedLink check if source of link exists
2700
+ */
2701
+ isExistedSymlink(filePath) {
2702
+ /* */
2703
+ /* */
2704
+ /* */
2705
+ /* */
2706
+ /* */
2707
+ /* */
2708
+ /* */
2709
+ /* */
2710
+ /* */
2711
+ /* */
2712
+ /* */
2713
+ /* */
2714
+ /* */
2715
+ /* */
2716
+ /* */
2717
+ /* */
2718
+ /* */
2719
+ /* */
2720
+ /* */
2721
+ /* */
2722
+ /* */
2723
+ /* */
2724
+ return (void 0);
2725
+ }
2726
+ /* */
2727
+ /* */
2728
+ /* */
2729
+ /* */
2730
+ /* */
2731
+ /* */
2732
+ /* */
2733
+ /* */
2734
+ /* */
2735
+ /* */
2736
+ /* */
2737
+ /* */
2738
+ /* */
2739
+ /* */
2740
+ /* */
2741
+ /* */
2742
+ /* */
2743
+ /* */
2744
+ exists(folderOrFilePath) {
2745
+ /* */
2746
+ /* */
2747
+ /* */
2748
+ /* */
2749
+ /* */
2750
+ /* */
2751
+ /* */
2752
+ /* */
2753
+ /* */
2754
+ /* */
2755
+ /* */
2756
+ /* */
2757
+ /* */
2758
+ /* */
2759
+ /* */
2760
+ /* */
2761
+ /* */
2762
+ /* */
2763
+ /* */
2764
+ /* */
2765
+ /* */
2766
+ /* */
2767
+ /* */
2768
+ /* */
2769
+ return (void 0);
2770
+ }
2771
+ /**
2772
+ * this is HACK for running procesess inside processes
2773
+ */
2774
+ _fixCommand(command) {
2775
+ if ((command.startsWith('tnp ') || command.startsWith('taon ')) && // TODO every cli projects here that uses run and need to kill process easly!
2776
+ command.search('-spinner=false') === -1 &&
2777
+ command.search('-spinner=off') === -1) {
2778
+ command = `${command} -spinner=false`;
2779
+ }
2780
+ if (global.skipCoreCheck &&
2781
+ (command.startsWith('tnp ') || command.startsWith('taon '))) {
2782
+ command = `${command} --skipCoreCheck`;
2783
+ }
2784
+ return command;
2785
+ }
2786
+ command(command) {
2787
+ command = Helpers._fixCommand(command);
2788
+ return {
2789
+ /* */
2790
+ /* */
2791
+ /* */
2792
+ /* */
2793
+ /* */
2794
+ /* */
2795
+ /* */
2796
+ /* */
2797
+ /* */
2798
+ /* */
2799
+ /* */
2800
+ /* */
2801
+ /* */
2802
+ /* */
2803
+ /* */
2804
+ /* */
2805
+ /* */
2806
+ /* */
2807
+ /* */
2808
+ /* */
2809
+ /* */
2810
+ /* */
2811
+ /* */
2812
+ /* */
2813
+ /* */
2814
+ /* */
2815
+ /* */
2816
+ /* */
2817
+ /* */
2818
+ /* */
2819
+ /* */
2820
+ /* */
2821
+ /* */
2822
+ /* */
2823
+ /* */
2824
+ /* */
2825
+ /* */
2826
+ /* */
2827
+ /* */
2828
+ /* */
2829
+ /* */
2830
+ /* */
2831
+ /* */
2832
+ /* */
2833
+ /* */
2834
+ /* */
2835
+ /* */
2836
+ /* */
2837
+ /* */
2838
+ /* */
2839
+ /* */
2840
+ /* */
2841
+ /* */
2842
+ };
2843
+ }
2844
+ wait(second) {
2845
+ return new Promise((resolve, reject) => {
2846
+ setTimeout(() => {
2847
+ resolve(void 0);
2848
+ }, second * 1000);
2849
+ });
2850
+ }
2851
+ async timeout(seconds) {
2852
+ return await Helpers.wait(seconds);
2853
+ }
2854
+ /* */
2855
+ /* */
2856
+ /* */
2857
+ /* */
2858
+ /* */
2859
+ /* */
2860
+ /* */
2861
+ /* */
2862
+ /* */
2863
+ /* */
2864
+ /* */
2865
+ /* */
2866
+ /* */
2867
+ /* */
2868
+ /* */
2869
+ /* */
2870
+ /* */
2871
+ /* */
2872
+ /* */
2873
+ /* */
2874
+ /* */
2875
+ /* */
2876
+ /* */
2877
+ /* */
2878
+ /* */
2879
+ /* */
2880
+ /* */
2881
+ /* */
2882
+ /* */
2883
+ /* */
2884
+ /* */
2885
+ /* */
2886
+ /* */
2887
+ /* */
2888
+ /* */
2889
+ /* */
2890
+ /* */
2891
+ /* */
2892
+ /* */
2893
+ /* */
2894
+ /* */
2895
+ /* */
2896
+ /* */
2897
+ /* */
2898
+ /* */
2899
+ /* */
2900
+ /* */
2901
+ /* */
2902
+ /* */
2903
+ /* */
2904
+ /* */
2905
+ /* */
2906
+ /* */
2907
+ /* */
2908
+ /* */
2909
+ /* */
2910
+ /* */
2911
+ /* */
2912
+ /* */
2913
+ /* */
2914
+ /* */
2915
+ /* */
2916
+ /* */
2917
+ /* */
2918
+ /* */
2919
+ /* */
2920
+ /* */
2921
+ /* */
2922
+ /* */
2923
+ /* */
2924
+ /* */
2925
+ /* */
2926
+ /* */
2927
+ /* */
2928
+ /* */
2929
+ /* */
2930
+ /* */
2931
+ /* */
2932
+ async killProcessByPort(portOrPortsToKill, options) {
2933
+ /* */
2934
+ /* */
2935
+ /* */
2936
+ /* */
2937
+ /* */
2938
+ /* */
2939
+ /* */
2940
+ /* */
2941
+ /* */
2942
+ /* */
2943
+ /* */
2944
+ /* */
2945
+ /* */
2946
+ /* */
2947
+ /* */
2948
+ /* */
2949
+ /* */
2950
+ /* */
2951
+ /* */
2952
+ /* */
2953
+ /* */
2954
+ /* */
2955
+ /* */
2956
+ /* */
2957
+ /* */
2958
+ /* */
2959
+ /* */
2960
+ /* */
2961
+ /* */
2962
+ /* */
2963
+ /* */
2964
+ /* */
2965
+ /* */
2966
+ /* */
2967
+ /* */
2968
+ /* */
2969
+ /* */
2970
+ /* */
2971
+ /* */
2972
+ /* */
2973
+ /* */
2974
+ /* */
2975
+ /* */
2976
+ /* */
2977
+ return (void 0);
2978
+ }
2979
+ async killOnPort(portOrPortsToKill, options) {
2980
+ return await Helpers.killProcessByPort(portOrPortsToKill, options);
2981
+ }
2982
+ killProcess(byPid) {
2983
+ /* */
2984
+ /* */
2985
+ /* */
2986
+ /* */
2987
+ /* */
2988
+ /* */
2989
+ /* */
2990
+ /* */
2991
+ /* */
2992
+ /* */
2993
+ /* */
2994
+ /* */
2995
+ /* */
2996
+ /* */
2997
+ /* */
2998
+ /* */
2999
+ /* */
3000
+ /* */
3001
+ /* */
3002
+ /* */
3003
+ /* */
3004
+ /* */
3005
+ /* */
3006
+ /* */
3007
+ /* */
3008
+ /* */
3009
+ /* */
3010
+ }
3011
+ run(command, options) {
3012
+ command = Helpers._fixCommand(command);
3013
+ /* */
3014
+ /* */
3015
+ /* */
3016
+ /* */
3017
+ /* */
3018
+ /* */
3019
+ /* */
3020
+ /* */
3021
+ return {
3022
+ /**
3023
+ * start command as synchronous nodej proces
3024
+ */
3025
+ sync() {
3026
+ /* */
3027
+ /* */
3028
+ /* */
3029
+ /* */
3030
+ /* */
3031
+ /* */
3032
+ /* */
3033
+ /* */
3034
+ /* */
3035
+ /* */
3036
+ /* */
3037
+ /* */
3038
+ /* */
3039
+ /* */
3040
+ /* */
3041
+ /* */
3042
+ /* */
3043
+ /* */
3044
+ /* */
3045
+ /* */
3046
+ /* */
3047
+ /* */
3048
+ /* */
3049
+ /* */
3050
+ /* */
3051
+ /* */
3052
+ /* */
3053
+ /* */
3054
+ /* */
3055
+ /* */
3056
+ /* */
3057
+ return (void 0);
3058
+ },
3059
+ /**
3060
+ * start command as asynchronous nodej proces
3061
+ * @param detach (default: false) - if true process will be detached
3062
+ */
3063
+ async(detach = false, mockFun) {
3064
+ if (mockFun) {
3065
+ const subStdoutSub = new Subject();
3066
+ const subStderSub = new Subject();
3067
+ const exitSub = new Subject();
3068
+ const subscribtions = [];
3069
+ const procDummy = {
3070
+ stdout: {
3071
+ on(action, stdoutCallback) {
3072
+ if (action == 'data') {
3073
+ subscribtions.push(subStdoutSub.subscribe(d => {
3074
+ stdoutCallback(d);
3075
+ }));
3076
+ }
3077
+ },
3078
+ },
3079
+ stderr: {
3080
+ on(action, stdoutCallback) {
3081
+ if (action == 'data') {
3082
+ subscribtions.push(subStderSub.subscribe(d => {
3083
+ stdoutCallback(d);
3084
+ }));
3085
+ }
3086
+ },
3087
+ },
3088
+ on(action, exitFun) {
3089
+ if (action == 'exit') {
3090
+ subscribtions.push(exitSub.subscribe(d => {
3091
+ exitFun(d);
3092
+ }));
3093
+ }
3094
+ }, // @ts-ignore
3095
+ ppid: void 0, // @ts-ignore
3096
+ pid: void 0,
3097
+ };
3098
+ procDummy.pid = Math.round(Math.random() * (1000 - 100)) + 100;
3099
+ procDummy.ppid = procDummy.pid + 9999;
3100
+ WEBSQL_PROC_MOCK_PROCESSES_PID[procDummy.pid] = procDummy;
3101
+ if (!WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid]) {
2374
3102
  WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid] = {
2375
3103
  childProcesses: [],
2376
3104
  };
@@ -2656,168 +3384,15 @@ class HelpersCore extends HelpersMessages {
2656
3384
  /* */
2657
3385
  /* */
2658
3386
  /* */
2659
- /* */
2660
- /* */
2661
- /* */
2662
- /* */
2663
- /* */
2664
- /* */
2665
- /* */
2666
- return (void 0);
2667
- }
2668
- /* */
2669
- /* */
2670
- /* */
2671
- /* */
2672
- /* */
2673
- /* */
2674
- /* */
2675
- /* */
2676
- /* */
2677
- /* */
2678
- /* */
2679
- /* */
2680
- /* */
2681
- /* */
2682
- /* */
2683
- /* */
2684
- /* */
2685
- /* */
2686
- /* */
2687
- /* */
2688
- /* */
2689
- /* */
2690
- /* */
2691
- /* */
2692
- /* */
2693
- /* */
2694
- /* */
2695
- /* */
2696
- /* */
2697
- /* */
2698
- /* */
2699
- /* */
2700
- /* */
2701
- /* */
2702
- /* */
2703
- /* */
2704
- /* */
2705
- /* */
2706
- /* */
2707
- /* */
2708
- /* */
2709
- /* */
2710
- /* */
2711
- /* */
2712
- /* */
2713
- /* */
2714
- /* */
2715
- /* */
2716
- /* */
2717
- /* */
2718
- /* */
2719
- /* */
2720
- /* */
2721
- /* */
2722
- /* */
2723
- /* */
2724
- /* */
2725
- /* */
2726
- /* */
2727
- /* */
2728
- /* */
2729
- /* */
2730
- /* */
2731
- /* */
2732
- /* */
2733
- /* */
2734
- /* */
2735
- /* */
2736
- /* */
2737
- /* */
2738
- /* */
2739
- /* */
2740
- /* */
2741
- /* */
2742
- /* */
2743
- /* */
2744
- /* */
2745
- /* */
2746
- /* */
2747
- /* */
2748
- /* */
2749
- /* */
2750
- /* */
2751
- /* */
2752
- /* */
2753
- /* */
2754
- /* */
2755
- /* */
2756
- /* */
2757
- /* */
2758
- /* */
2759
- /* */
2760
- /* */
2761
- /* */
2762
- /* */
2763
- /* */
2764
- /* */
2765
- /* */
2766
- /* */
2767
- /* */
2768
- /* */
2769
- /* */
2770
- /* */
2771
- /* */
2772
- /* */
2773
- /* */
2774
- /* */
2775
- /* */
2776
- /* */
2777
- /* */
2778
- /* */
2779
- /* */
2780
- /* */
2781
- /* */
2782
- /* */
2783
- /* */
2784
- /* */
2785
- /* */
2786
- /* */
2787
- /* */
2788
- /* */
2789
- /* */
2790
- /* */
2791
- /* */
2792
- /* */
2793
- /* */
2794
- /* */
2795
- /* */
2796
- /* */
2797
- /* */
2798
- /* */
2799
- /* */
2800
- /* */
2801
- /* */
2802
- /* */
2803
- /* */
2804
- /* */
2805
- /* */
2806
- /* */
2807
- /* */
2808
- /* */
2809
- /* */
2810
- /* */
2811
- /* */
2812
- /* */
2813
- /* */
2814
- /* */
2815
- /* */
2816
- /* */
2817
- /* */
2818
- /* */
2819
- /* */
2820
- /* */
3387
+ /* */
3388
+ /* */
3389
+ /* */
3390
+ /* */
3391
+ /* */
3392
+ /* */
3393
+ /* */
3394
+ return (void 0);
3395
+ }
2821
3396
  /* */
2822
3397
  /* */
2823
3398
  /* */
@@ -3184,23 +3759,6 @@ class HelpersCore extends HelpersMessages {
3184
3759
  /* */
3185
3760
  /* */
3186
3761
  /* */
3187
- /**
3188
- * Quick fix for object values
3189
- * @deprecated
3190
- */
3191
- values(obj) {
3192
- if (_.isObject(obj) && !Array.isArray(obj)) {
3193
- const values = [];
3194
- for (const key in obj) {
3195
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
3196
- // @ts-ignore
3197
- values.push(obj[key]);
3198
- }
3199
- }
3200
- return values;
3201
- }
3202
- return [];
3203
- }
3204
3762
  /* */
3205
3763
  /* */
3206
3764
  /* */
@@ -3354,6 +3912,23 @@ class HelpersCore extends HelpersMessages {
3354
3912
  /* */
3355
3913
  /* */
3356
3914
  /* */
3915
+ /**
3916
+ * Quick fix for object values
3917
+ * @deprecated
3918
+ */
3919
+ values(obj) {
3920
+ if (_.isObject(obj) && !Array.isArray(obj)) {
3921
+ const values = [];
3922
+ for (const key in obj) {
3923
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
3924
+ // @ts-ignore
3925
+ values.push(obj[key]);
3926
+ }
3927
+ }
3928
+ return values;
3929
+ }
3930
+ return [];
3931
+ }
3357
3932
  /* */
3358
3933
  /* */
3359
3934
  /* */
@@ -3363,14 +3938,6 @@ class HelpersCore extends HelpersMessages {
3363
3938
  /* */
3364
3939
  /* */
3365
3940
  /* */
3366
- replaceLinesInFile(absoluteFilePath, lineReplaceFn) {
3367
- /* */
3368
- /* */
3369
- /* */
3370
- /* */
3371
- /* */
3372
- /* */
3373
- }
3374
3941
  /* */
3375
3942
  /* */
3376
3943
  /* */
@@ -3524,6 +4091,14 @@ class HelpersCore extends HelpersMessages {
3524
4091
  /* */
3525
4092
  /* */
3526
4093
  /* */
4094
+ replaceLinesInFile(absoluteFilePath, lineReplaceFn) {
4095
+ /* */
4096
+ /* */
4097
+ /* */
4098
+ /* */
4099
+ /* */
4100
+ /* */
4101
+ }
3527
4102
  /* */
3528
4103
  /* */
3529
4104
  /* */
@@ -3707,360 +4282,181 @@ class HelpersCore extends HelpersMessages {
3707
4282
  /* */
3708
4283
  /* */
3709
4284
  /* */
3710
- hideNodeWarnings() {
3711
- /* */
3712
- /* */
3713
- /* */
3714
- }
3715
- }
3716
- ;
3717
- ({}); // @--end-of-file-for-module=tnp-core lib/helpers.ts
3718
-
3719
- const CoreConfig = {
3720
- message: {
3721
- globalSystemToolMode: 'globalSystemToolMode',
3722
- },
3723
- };
3724
- ;
3725
- ({}); // @--end-of-file-for-module=tnp-core lib/core-config.ts
3726
-
3727
- class PROGRESS_DATA {
3728
- constructor() {
3729
- this.type = 'event';
3730
- }
3731
- static log(log) {
3732
- /* */
3733
- /* */
3734
- /* */
3735
- /* */
3736
- /* */
3737
- /* */
3738
- /* */
3739
- }
3740
- static resolveFrom(chunk, callbackOnFounded, checkSplit = true) {
3741
- let progress;
3742
- let res = [];
3743
- if (!_.isString(chunk)) {
3744
- return [];
3745
- }
3746
- chunk = chunk.trim();
3747
- if (checkSplit) {
3748
- const split = chunk.split(/\r\n|\n|\r/);
3749
- if (split.length > 1) {
3750
- split.forEach(s => {
3751
- res = res.concat(this.resolveFrom(s, callbackOnFounded, false));
3752
- });
3753
- return res;
3754
- }
3755
- }
3756
- if (/\[\[\[.*\]\]\]/g.test(chunk)) {
3757
- chunk = chunk.replace(/^\[\[\[/g, '').replace(/\]\]\]$/g, '');
3758
- progress = chunk;
3759
- }
3760
- if (!_.isUndefined(progress)) {
3761
- try {
3762
- const p = JSON.parse(progress);
3763
- const single = _.merge(new PROGRESS_DATA(), p);
3764
- res = res.concat([single]);
3765
- if (_.isFunction(callbackOnFounded)) {
3766
- callbackOnFounded(single);
3767
- }
3768
- }
3769
- catch (err) {
3770
- Helpers.error(err, true, true);
3771
- Helpers.error(`ProgresssBarData: fail to parse "${progress}"`, true, true);
3772
- }
3773
- }
3774
- return res;
3775
- }
3776
- }
3777
- ;
3778
- ({}); // @--end-of-file-for-module=tnp-core lib/progress-data.ts
3779
-
3780
- /* */
3781
- /* */
3782
- /* */
3783
- const BLOB_SUPPORTED_IN_SQLJS = false;
3784
- var Utils;
3785
- (function (Utils) {
3786
- Utils.uniqArray = (array, uniqueProperty) => {
3787
- var seen = {};
3788
- return array
3789
- .filter(f => !!f)
3790
- .filter(function (item) {
3791
- return seen.hasOwnProperty(uniqueProperty ? item[uniqueProperty] : item)
3792
- ? false
3793
- : (seen[uniqueProperty ? item[uniqueProperty] : item] = true);
3794
- });
3795
- };
3796
- /**
3797
- * Example:
3798
- * new RegExp(escapeStringForRegEx('a.b.c'),'g') => /a\.b\.c/g
3799
- */
3800
- Utils.escapeStringForRegEx = (stringForRegExp) => {
3801
- return stringForRegExp.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
3802
- };
3803
- function removeChalkSpecialChars(str) {
3804
- const ansiRegex = /\u001b\[[0-9;]*m/g;
3805
- return str.replace(ansiRegex, '');
3806
- }
3807
- Utils.removeChalkSpecialChars = removeChalkSpecialChars;
3808
- Utils.fullDateTime = () => {
3809
- /* */
3810
- /* */
3811
- return (void 0);
3812
- };
3813
- Utils.fullDate = () => {
3814
- /* */
3815
- /* */
3816
- return (void 0);
3817
- };
3818
- let json;
3819
- (function (json) {
3820
- json.getAtrributies = (jsonDeepPath, // lodash path to property in json ex. deep.path.to.prop
3821
- fileContent) => {
3822
- const lines = fileContent.split('\n');
3823
- const pathParts = jsonDeepPath.split('.').reduce((a, b) => {
3824
- if (a.length === 0) {
3825
- return [b];
3826
- }
3827
- const last = a[a.length - 1];
3828
- if ((last.startsWith(`['`) && b.endsWith(`']`)) ||
3829
- (last.startsWith(`["`) && b.endsWith(`"]`))) {
3830
- a[a.length - 1] = [last, b].join('.');
3831
- }
3832
- else {
3833
- a.push(b);
3834
- }
3835
- return a;
3836
- }, []);
3837
- const keyName = pathParts.pop().replace(/^\["(.+)"\]$/, '$1');
3838
- let currentPath = '';
3839
- let attributes = [];
3840
- let collectedComments = [];
3841
- for (const line of lines) {
3842
- const trimmedLine = line.trim();
3843
- if (trimmedLine.startsWith('//')) {
3844
- collectedComments.push(trimmedLine);
3845
- }
3846
- else if (trimmedLine.startsWith('"') || trimmedLine.startsWith("'")) {
3847
- const match = trimmedLine.match(/["']([^"']+)["']\s*:/);
3848
- if (match) {
3849
- const key = match[1];
3850
- currentPath = currentPath
3851
- ? `${currentPath}.${key.includes('.') ? `['${key}']` : key}`
3852
- : key;
3853
- if ((currentPath.endsWith(keyName) &&
3854
- !currentPath.endsWith('/' + keyName)) ||
3855
- currentPath.endsWith(`['${keyName}']`)) {
3856
- attributes = extractAttributesFromComments(collectedComments);
3857
- break;
3858
- }
3859
- collectedComments = [];
3860
- }
3861
- }
3862
- }
3863
- return attributes;
3864
- };
3865
- const extractAttributesFromComments = (comments) => {
3866
- const attributes = [];
3867
- const attrRegex = /@(\w+)(?:\s*=\s*([^\s@]+))?/g;
3868
- for (const comment of comments) {
3869
- let match;
3870
- while ((match = attrRegex.exec(comment)) !== null) {
3871
- const [, name, value] = match;
3872
- const existingAttribute = attributes.find(attr => attr.name === `@${name}`);
3873
- if (existingAttribute) {
3874
- if (value) {
3875
- if (Array.isArray(existingAttribute.value)) {
3876
- existingAttribute.value.push(value);
3877
- }
3878
- else {
3879
- existingAttribute.value = [existingAttribute.value, value];
3880
- }
3881
- }
3882
- }
3883
- else {
3884
- attributes.push({
3885
- name: `@${name}`,
3886
- value: value ? value : true,
3887
- });
3888
- }
3889
- }
3890
- }
3891
- attributes.forEach(attr => {
3892
- if (Array.isArray(attr.value) && attr.value.length === 1) {
3893
- attr.value = attr.value[0];
3894
- }
3895
- });
3896
- return attributes;
3897
- };
3898
- })(json = Utils.json || (Utils.json = {}));
3899
- let DbBinaryFormatEnum;
3900
- (function (DbBinaryFormatEnum) {
3901
- DbBinaryFormatEnum["Blob"] = "Blob";
3902
- DbBinaryFormatEnum["File"] = "File";
3903
- DbBinaryFormatEnum["string"] = "string";
3904
- /* */
3905
- /* */
3906
- })(DbBinaryFormatEnum = Utils.DbBinaryFormatEnum || (Utils.DbBinaryFormatEnum = {}));
3907
4285
  /* */
3908
4286
  /* */
3909
- let binary;
3910
- (function (binary) {
3911
- /**
3912
- * This is for BROWSER ONLY
3913
- *
3914
- * @param buffer
3915
- * @param contentType
3916
- * @returns
3917
- */
3918
- async function arrayBufferToBlob(buffer, contentType) {
3919
- // @ts-ignore
3920
- return new Blob([buffer], { type: contentType });
3921
- }
3922
- binary.arrayBufferToBlob = arrayBufferToBlob;
3923
- /**
3924
- * This is for BROWSER ONLY
3925
- * @param blob
3926
- * @returns
3927
- */
3928
- async function blobToArrayBuffer(blob) {
3929
- return await new Promise((resolve, reject) => {
3930
- const reader = new FileReader();
3931
- reader.addEventListener('loadend', () => {
3932
- resolve(reader.result);
3933
- });
3934
- reader.addEventListener('error', reject); // @ts-ignore
3935
- reader.readAsArrayBuffer(blob);
3936
- });
3937
- }
3938
- binary.blobToArrayBuffer = blobToArrayBuffer;
3939
- /**
3940
- * it is revers to base64toBlob
3941
- * @param blob
3942
- * @returns
3943
- */
3944
- function blobToBase64(blob) {
3945
- return new Promise((resolve, _) => {
3946
- const reader = new FileReader();
3947
- reader.onloadend = () => resolve(reader.result); // @ts-ignore
3948
- reader.readAsDataURL(blob);
3949
- });
3950
- }
3951
- binary.blobToBase64 = blobToBase64;
3952
- /**
3953
- * it is revers to blobToBase64()
3954
- * @param base64Data
3955
- * @returns
3956
- */
3957
- async function base64toBlob(base64Data, contentTypeOverride) {
3958
- let content_type = void 0;
3959
- let file_base64 = void 0;
3960
- if (!contentTypeOverride) {
3961
- const m = /^data:(.+?);base64,(.+)$/.exec(base64Data);
3962
- if (!m) {
3963
- throw new Error(`[taon-framework][base64toBlob] Not a base64 blob [${base64Data}]`);
3964
- }
3965
- var [__, contenttype, filebase64] = m;
3966
- content_type = contenttype;
3967
- file_base64 = filebase64;
3968
- }
3969
- content_type = (contentTypeOverride ? contentTypeOverride : content_type || '');
3970
- base64Data = contentTypeOverride ? base64Data : file_base64;
3971
- const sliceSize = 1024;
3972
- const byteCharacters = atob(base64Data);
3973
- const bytesLength = byteCharacters.length;
3974
- const slicesCount = Math.ceil(bytesLength / sliceSize);
3975
- const byteArrays = new Array(slicesCount);
3976
- for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
3977
- const begin = sliceIndex * sliceSize;
3978
- const end = Math.min(begin + sliceSize, bytesLength);
3979
- const bytes = new Array(end - begin);
3980
- for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
3981
- bytes[i] = byteCharacters[offset].charCodeAt(0);
3982
- }
3983
- byteArrays[sliceIndex] = new Uint8Array(bytes);
3984
- }
3985
- return new Blob(byteArrays, { type: content_type });
3986
- }
3987
- binary.base64toBlob = base64toBlob;
3988
- async function base64toDbBinaryFormat(text) {
3989
- let result;
3990
- result = await (async () => {
3991
- if (BLOB_SUPPORTED_IN_SQLJS) {
3992
- const blob = await base64toBlob(text);
3993
- return blob;
3994
- }
3995
- return text;
3996
- })();
3997
- /* */
3998
- /* */
3999
- /* */
4000
- /* */
4001
- /* */
4002
- return result;
4003
- }
4004
- binary.base64toDbBinaryFormat = base64toDbBinaryFormat;
4005
- async function dbBinaryFormatToBase64(binaryFormat) {
4006
- let result;
4007
- result = await (async () => {
4008
- if (BLOB_SUPPORTED_IN_SQLJS) {
4009
- const text = await blobToBase64(binaryFormat);
4010
- return text;
4011
- }
4012
- return binaryFormat;
4013
- })();
4014
- /* */
4015
- /* */
4016
- /* */
4017
- /* */
4018
- /* */
4019
- return result;
4020
- }
4021
- binary.dbBinaryFormatToBase64 = dbBinaryFormatToBase64;
4022
- async function textToDbBinaryFormat(text) {
4023
- let result;
4024
- result = await (async () => {
4025
- if (BLOB_SUPPORTED_IN_SQLJS) {
4026
- const blob = await textToBlob(text);
4027
- return blob;
4028
- }
4029
- return text;
4030
- })();
4031
- /* */
4032
- /* */
4033
- /* */
4034
- /* */
4035
- /* */
4036
- return result;
4037
- }
4038
- binary.textToDbBinaryFormat = textToDbBinaryFormat;
4039
- async function dbBinaryFormatToText(binaryFormat) {
4040
- let result;
4041
- result = await (async () => {
4042
- if (BLOB_SUPPORTED_IN_SQLJS) {
4043
- const text = await blobToText(binaryFormat);
4044
- return text;
4045
- }
4046
- return binaryFormat;
4047
- })();
4048
- /* */
4049
- /* */
4050
- /* */
4051
- /* */
4052
- /* */
4053
- return result;
4054
- }
4055
- binary.dbBinaryFormatToText = dbBinaryFormatToText;
4056
- /* */
4057
- /* */
4058
- /* */
4059
- /* */
4060
- /* */
4287
+ /* */
4288
+ /* */
4289
+ /* */
4290
+ /* */
4291
+ /* */
4292
+ /* */
4293
+ /* */
4294
+ /* */
4295
+ /* */
4296
+ /* */
4297
+ /* */
4298
+ /* */
4299
+ /* */
4300
+ /* */
4301
+ /* */
4302
+ /* */
4303
+ /* */
4304
+ /* */
4305
+ /* */
4306
+ /* */
4307
+ /* */
4308
+ /* */
4309
+ /* */
4310
+ /* */
4311
+ /* */
4312
+ /* */
4313
+ /* */
4314
+ /* */
4315
+ /* */
4316
+ /* */
4317
+ /* */
4318
+ /* */
4319
+ /* */
4320
+ /* */
4321
+ /* */
4322
+ /* */
4323
+ /* */
4324
+ /* */
4325
+ /* */
4326
+ /* */
4327
+ /* */
4328
+ /* */
4329
+ /* */
4330
+ /* */
4331
+ /* */
4332
+ /* */
4333
+ /* */
4334
+ /* */
4335
+ /* */
4336
+ /* */
4337
+ /* */
4338
+ /* */
4339
+ /* */
4340
+ /* */
4341
+ /* */
4342
+ /* */
4343
+ /* */
4344
+ /* */
4345
+ /* */
4346
+ /* */
4347
+ /* */
4348
+ /* */
4349
+ /* */
4350
+ /* */
4351
+ /* */
4352
+ /* */
4353
+ /* */
4354
+ /* */
4355
+ /* */
4356
+ /* */
4357
+ /* */
4358
+ /* */
4359
+ /* */
4360
+ /* */
4361
+ /* */
4362
+ /* */
4363
+ /* */
4364
+ /* */
4365
+ /* */
4366
+ /* */
4367
+ /* */
4368
+ /* */
4369
+ /* */
4370
+ /* */
4371
+ /* */
4372
+ /* */
4373
+ /* */
4374
+ /* */
4375
+ /* */
4376
+ /* */
4377
+ /* */
4378
+ /* */
4379
+ /* */
4380
+ /* */
4381
+ /* */
4382
+ /* */
4383
+ /* */
4384
+ /* */
4385
+ /* */
4386
+ /* */
4387
+ /* */
4388
+ /* */
4389
+ /* */
4390
+ /* */
4391
+ /* */
4392
+ /* */
4393
+ /* */
4394
+ /* */
4395
+ /* */
4396
+ /* */
4397
+ /* */
4398
+ /* */
4399
+ /* */
4400
+ /* */
4401
+ /* */
4402
+ /* */
4403
+ /* */
4404
+ /* */
4405
+ /* */
4406
+ /* */
4407
+ /* */
4408
+ /* */
4409
+ /* */
4410
+ /* */
4411
+ /* */
4412
+ /* */
4413
+ /* */
4414
+ /* */
4415
+ /* */
4416
+ /* */
4417
+ /* */
4418
+ /* */
4419
+ /* */
4420
+ /* */
4421
+ /* */
4422
+ /* */
4423
+ /* */
4424
+ /* */
4425
+ /* */
4426
+ /* */
4427
+ /* */
4428
+ /* */
4429
+ /* */
4430
+ /* */
4431
+ /* */
4432
+ /* */
4433
+ /* */
4434
+ /* */
4435
+ /* */
4436
+ /* */
4437
+ /* */
4438
+ hideNodeWarnings() {
4061
4439
  /* */
4062
4440
  /* */
4063
4441
  /* */
4442
+ }
4443
+ }
4444
+ ;
4445
+ ({}); // @--end-of-file-for-module=tnp-core lib/helpers.ts
4446
+
4447
+ const CoreConfig = {
4448
+ message: {
4449
+ globalSystemToolMode: 'globalSystemToolMode',
4450
+ },
4451
+ };
4452
+ ;
4453
+ ({}); // @--end-of-file-for-module=tnp-core lib/core-config.ts
4454
+
4455
+ class PROGRESS_DATA {
4456
+ constructor() {
4457
+ this.type = 'event';
4458
+ }
4459
+ static log(log) {
4064
4460
  /* */
4065
4461
  /* */
4066
4462
  /* */
@@ -4068,165 +4464,46 @@ var Utils;
4068
4464
  /* */
4069
4465
  /* */
4070
4466
  /* */
4071
- async function fileToBlob(file) {
4072
- return new Blob([new Uint8Array(await file.arrayBuffer())], {
4073
- type: file.type,
4074
- });
4467
+ }
4468
+ static resolveFrom(chunk, callbackOnFounded, checkSplit = true) {
4469
+ let progress;
4470
+ let res = [];
4471
+ if (!_.isString(chunk)) {
4472
+ return [];
4075
4473
  }
4076
- binary.fileToBlob = fileToBlob;
4077
- async function blobToFile(blob, nameForFile = 'my-file-name') {
4078
- if (!nameForFile) {
4079
- nameForFile = 'nonamefile' + new Date().getTime();
4474
+ chunk = chunk.trim();
4475
+ if (checkSplit) {
4476
+ const split = chunk.split(/\r\n|\n|\r/);
4477
+ if (split.length > 1) {
4478
+ split.forEach(s => {
4479
+ res = res.concat(this.resolveFrom(s, callbackOnFounded, false));
4480
+ });
4481
+ return res;
4080
4482
  }
4081
- // @ts-ignore
4082
- return new File([blob], nameForFile);
4083
- }
4084
- binary.blobToFile = blobToFile;
4085
- /* */
4086
- /* */
4087
- /* */
4088
- /* */
4089
- /* */
4090
- /* */
4091
- /* */
4092
- /* */
4093
- /* */
4094
- /* */
4095
- /* */
4096
- /* */
4097
- /* */
4098
- /* */
4099
- /* */
4100
- /* */
4101
- /* */
4102
- /* */
4103
- /* */
4104
- /* */
4105
- /* */
4106
- /* */
4107
- /* */
4108
- /* */
4109
- /* */
4110
- /* */
4111
- async function textToBlob(text, type = 'text/plain') {
4112
- const blob = new Blob([text], { type });
4113
- return blob;
4114
- }
4115
- binary.textToBlob = textToBlob;
4116
- async function blobToText(blob) {
4117
- return await blob.text();
4118
- }
4119
- binary.blobToText = blobToText;
4120
- async function textToFile(text, fileRelativePathOrName) {
4121
- const ext = path.extname(fileRelativePathOrName);
4122
- const type = CoreModels.mimeTypes[ext];
4123
- const blob = new Blob([text], { type });
4124
- const file = await blobToFile(blob, fileRelativePathOrName);
4125
- return file;
4126
- }
4127
- binary.textToFile = textToFile;
4128
- async function fileToText(file) {
4129
- return await file.text();
4130
- }
4131
- binary.fileToText = fileToText;
4132
- async function jsonToBlob(jsonObj) {
4133
- const blob = new Blob([JSON.stringify(jsonObj, null, 2)], {
4134
- type: 'application/json',
4135
- });
4136
- return blob;
4137
4483
  }
4138
- binary.jsonToBlob = jsonToBlob;
4139
- /**
4140
- * TODO NOT TESTED
4141
- */
4142
- async function blobToJson(blob) {
4143
- return JSON.parse(await blob.text());
4144
- }
4145
- binary.blobToJson = blobToJson;
4146
- async function getBlobFrom(url) {
4147
- const response = await axios({
4148
- url,
4149
- method: 'get',
4150
- responseType: 'blob',
4151
- });
4152
- return response.data;
4484
+ if (/\[\[\[.*\]\]\]/g.test(chunk)) {
4485
+ chunk = chunk.replace(/^\[\[\[/g, '').replace(/\]\]\]$/g, '');
4486
+ progress = chunk;
4153
4487
  }
4154
- binary.getBlobFrom = getBlobFrom;
4155
- })(binary = Utils.binary || (Utils.binary = {}));
4156
- let css;
4157
- (function (css) {
4158
- /**
4159
- *
4160
- * @param pixelsCss pixels ex. 100px
4161
- * @returns
4162
- */
4163
- function numValue(pixelsCss) {
4164
- return parseInt(pixelsCss?.toString()?.replace('px', ''));
4488
+ if (!_.isUndefined(progress)) {
4489
+ try {
4490
+ const p = JSON.parse(progress);
4491
+ const single = _.merge(new PROGRESS_DATA(), p);
4492
+ res = res.concat([single]);
4493
+ if (_.isFunction(callbackOnFounded)) {
4494
+ callbackOnFounded(single);
4495
+ }
4496
+ }
4497
+ catch (err) {
4498
+ Helpers.error(err, true, true);
4499
+ Helpers.error(`ProgresssBarData: fail to parse "${progress}"`, true, true);
4500
+ }
4165
4501
  }
4166
- css.numValue = numValue;
4167
- })(css = Utils.css || (Utils.css = {}));
4168
- })(Utils || (Utils = {}));
4169
- var UtilsProcess;
4170
- (function (UtilsProcess) {
4171
- /**
4172
- * TODO IMPLEMENT
4173
- */
4174
- async function startAsync(command, options) {
4175
- }
4176
- UtilsProcess.startAsync = startAsync;
4177
- /**
4178
- * TODO IMPLEMENT
4179
- */
4180
- function startSync(command, options) {
4502
+ return res;
4181
4503
  }
4182
- UtilsProcess.startSync = startSync;
4183
- UtilsProcess.getBashOrShellName = () => {
4184
- /* */
4185
- /* */
4186
- /* */
4187
- /* */
4188
- /* */
4189
- /* */
4190
- /* */
4191
- /* */
4192
- /* */
4193
- /* */
4194
- /* */
4195
- /* */
4196
- /* */
4197
- /* */
4198
- /* */
4199
- /* */
4200
- /* */
4201
- /* */
4202
- /* */
4203
- /* */
4204
- /* */
4205
- /* */
4206
- /* */
4207
- /* */
4208
- /* */
4209
- /* */
4210
- /* */
4211
- /* */
4212
- /* */
4213
- /* */
4214
- /* */
4215
- /* */
4216
- return (void 0);
4217
- };
4218
- })(UtilsProcess || (UtilsProcess = {}));
4219
- var UtilsString;
4220
- (function (UtilsString) {
4221
- UtilsString.kebabCaseNoSplitNumbers = (input) => {
4222
- return (input
4223
- .replace(/\s+/g, '-')
4224
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
4225
- .toLowerCase());
4226
- };
4227
- })(UtilsString || (UtilsString = {}));
4504
+ }
4228
4505
  ;
4229
- ({}); // @--end-of-file-for-module=tnp-core lib/utils.ts
4506
+ ({}); // @--end-of-file-for-module=tnp-core lib/progress-data.ts
4230
4507
 
4231
4508
  /* */
4232
4509
  /* */
@@ -4248,6 +4525,10 @@ class CLI {
4248
4525
  ;
4249
4526
  ({}); // @--end-of-file-for-module=tnp-core lib/core-cli.ts
4250
4527
 
4528
+ /**
4529
+ * TODO slowly refactor this.. only actually globally needed are:
4530
+ * pm2, yarn, npm-run, ts-node ???
4531
+ */
4251
4532
  const requiredForDev = {
4252
4533
  npm: [
4253
4534
  /* */
@@ -4282,6 +4563,9 @@ const requiredForDev = {
4282
4563
  /* */
4283
4564
  /* */
4284
4565
  /* */
4566
+ /* */
4567
+ /* */
4568
+ /* */
4285
4569
  ],
4286
4570
  niceTools: [
4287
4571
  /* */
@@ -4318,7 +4602,7 @@ const requiredForDev = {
4318
4602
  ],
4319
4603
  };
4320
4604
  ;
4321
- ({}); // @--end-of-file-for-module=tnp-core lib/required.ts
4605
+ ({}); // @--end-of-file-for-module=tnp-core lib/required-global-npm-packages.ts
4322
4606
 
4323
4607
  let Helpers = HelpersCore.InstanceCore;
4324
4608
  ;
@@ -4328,5 +4612,5 @@ let Helpers = HelpersCore.InstanceCore;
4328
4612
  * Generated bundle index. Do not edit.
4329
4613
  */
4330
4614
 
4331
- export { $, CLI, CoreConfig, HelpersCore as CoreHelpers, CoreModels, Helpers, PROGRESS_DATA, Utils, UtilsProcess, UtilsString, chalk, crossPlatformPath, frameworkName, frameworkNameBe, path, requiredForDev, win32Path };
4615
+ export { $, CLI, CoreConfig, HelpersCore as CoreHelpers, CoreModels, Helpers, PROGRESS_DATA, Utils, UtilsOs, UtilsProcess, UtilsString, chalk, crossPlatformPath, frameworkName, frameworkNameBe, path, requiredForDev, win32Path };
4332
4616
  //# sourceMappingURL=tnp-core.mjs.map