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
- return true;
735
- return false;
736
- }
737
- get isNode() {
738
- /* */
739
- /* */
740
- return false;
741
- }
742
- get isElectron() {
743
- // @ts-ignore
744
- if (typeof window !== 'undefined' &&
745
- typeof window.process === 'object' &&
746
- window.process.type === 'renderer') {
747
- return true;
748
- }
749
- // @ts-ignore
750
- if (typeof process !== 'undefined' &&
751
- typeof process.versions === 'object' &&
752
- !!process.versions.electron) {
753
- return true;
754
- }
755
- if (typeof navigator === 'object' &&
756
- typeof navigator.userAgent === 'string' &&
757
- navigator.userAgent.indexOf('Electron') >= 0) {
758
- return true;
759
- }
760
- return false;
761
- }
762
- contain(arr, item) {
763
- return (arr.filter(l => {
764
- if (l instanceof RegExp) {
765
- return l.test(item);
766
- }
767
- if (l === item) {
768
- return true;
769
- }
770
- if (item.match && typeof item.match === 'function' ? item.match(l) : false) {
771
- return true;
772
- }
773
- return false;
774
- }).length > 0);
775
- }
776
- }
777
- ;
778
- ({}); // @--end-of-file-for-module=tnp-core lib/helpers-isomorphic.ts
779
-
780
- /* */
781
- /* */
782
- /* */
783
- const KEY = {
784
- LAST_ERROR: Symbol(),
785
- LAST_INFO: Symbol(),
786
- LAST_WARN: Symbol(),
787
- LAST_LOG: Symbol(),
788
- LAST_SUCCESS: Symbol(),
789
- LAST_TASK_STARTED: Symbol(),
790
- LAST_TASK_DONE: Symbol(),
791
- };
792
- const KEY_COUNT = {
793
- LAST_ERROR: Symbol(),
794
- LAST_INFO: Symbol(),
795
- LAST_WARN: Symbol(),
796
- LAST_LOG: Symbol(),
797
- LAST_SUCCESS: Symbol(),
798
- LAST_TASK_STARTED: Symbol(),
799
- LAST_TASK_DONE: Symbol(),
800
- };
801
- const KEY_IMPORTANTCE = {
802
- LAST_ERROR: Symbol(),
803
- LAST_INFO: Symbol(),
804
- LAST_WARN: Symbol(),
805
- LAST_LOG: Symbol(),
806
- LAST_SUCCESS: Symbol(),
807
- LAST_TASK_STARTED: Symbol(),
808
- LAST_TASK_DONE: Symbol(),
809
- };
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
- const LIMIT = 10;
832
- class HelpersMessages extends HelpersIsomorphic {
833
- msgCacheClear() {
834
- /* */
835
- /* */
836
- /* */
837
- /* */
838
- /* */
839
- }
840
- renderError(err) {
841
- if (this.isBrowser) {
842
- console.error(err);
843
- }
844
- else {
845
- /* */
846
- /* */
847
- /* */
848
- /* */
849
- /* */
850
- /* */
851
- /* */
852
- /* */
853
- /* */
854
- }
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, '');
855
752
  }
856
- error(details, noExit = false, noTrace = false) {
857
- if (Helpers.isBrowser) {
858
- console.error(details);
859
- return;
860
- }
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,26 +796,275 @@ 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
  /* */
908
1042
  /* */
909
1043
  /* */
910
1044
  /* */
911
- }
912
- info(details, repeatable = false) {
913
1045
  /* */
914
1046
  /* */
915
1047
  /* */
916
1048
  /* */
917
1049
  /* */
918
1050
  /* */
919
- if (Helpers.isBrowser) {
920
- console.info(details);
921
- return;
1051
+ /* */
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);
922
1066
  }
1067
+ binary.blobToFile = blobToFile;
923
1068
  /* */
924
1069
  /* */
925
1070
  /* */
@@ -946,6 +1091,80 @@ class HelpersMessages extends HelpersIsomorphic {
946
1091
  /* */
947
1092
  /* */
948
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 = () => {
949
1168
  /* */
950
1169
  /* */
951
1170
  /* */
@@ -954,12 +1173,6 @@ class HelpersMessages extends HelpersIsomorphic {
954
1173
  /* */
955
1174
  /* */
956
1175
  /* */
957
- }
958
- success(details) {
959
- if (Helpers.isBrowser) {
960
- console.info(details);
961
- return;
962
- }
963
1176
  /* */
964
1177
  /* */
965
1178
  /* */
@@ -970,6 +1183,13 @@ class HelpersMessages extends HelpersIsomorphic {
970
1183
  /* */
971
1184
  /* */
972
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
  /* */
@@ -997,18 +1217,6 @@ class HelpersMessages extends HelpersIsomorphic {
997
1217
  /* */
998
1218
  /* */
999
1219
  /* */
1000
- }
1001
- /**
1002
- *
1003
- * @param details
1004
- * @param isLogTask is less important log task
1005
- * @returns
1006
- */
1007
- taskStarted(details, isLogTask = false) {
1008
- if (Helpers.isBrowser) {
1009
- console.info(details);
1010
- return;
1011
- }
1012
1220
  /* */
1013
1221
  /* */
1014
1222
  /* */
@@ -1056,13 +1264,6 @@ class HelpersMessages extends HelpersIsomorphic {
1056
1264
  /* */
1057
1265
  /* */
1058
1266
  /* */
1059
- }
1060
- taskDone(details, isLessImportant = false) {
1061
- if (Helpers.isBrowser) {
1062
- console.info(details);
1063
- return;
1064
- }
1065
- /* */
1066
1267
  /* */
1067
1268
  /* */
1068
1269
  /* */
@@ -1090,6 +1291,10 @@ class HelpersMessages extends HelpersIsomorphic {
1090
1291
  /* */
1091
1292
  /* */
1092
1293
  /* */
1294
+ return (void 0);
1295
+ };
1296
+ UtilsProcess.getBashOrShellName = () => {
1297
+ return 'browser';
1093
1298
  /* */
1094
1299
  /* */
1095
1300
  /* */
@@ -1114,12 +1319,6 @@ class HelpersMessages extends HelpersIsomorphic {
1114
1319
  /* */
1115
1320
  /* */
1116
1321
  /* */
1117
- }
1118
- log(details, debugLevel = 0) {
1119
- if (Helpers.isBrowser) {
1120
- console.log(details);
1121
- return;
1122
- }
1123
1322
  /* */
1124
1323
  /* */
1125
1324
  /* */
@@ -1128,12 +1327,70 @@ class HelpersMessages extends HelpersIsomorphic {
1128
1327
  /* */
1129
1328
  /* */
1130
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 = () => {
1131
1341
  /* */
1132
1342
  /* */
1343
+ return true;
1344
+ };
1345
+ /**
1346
+ * check if script is running in nodejs
1347
+ * (backend script or electron script)
1348
+ */
1349
+ UtilsOs.isRunningInNode = () => {
1133
1350
  /* */
1134
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 = () => {
1135
1360
  /* */
1136
1361
  /* */
1362
+ return true;
1363
+ return false;
1364
+ };
1365
+ /**
1366
+ * check whether the current process is running inside
1367
+ * Electron backend or browser.
1368
+ */
1369
+ UtilsOs.isRunningInElectron = () => {
1370
+ // @ts-ignore
1371
+ if (typeof window !== 'undefined' &&
1372
+ typeof window.process === 'object' &&
1373
+ window.process.type === 'renderer') {
1374
+ return true;
1375
+ }
1376
+ // @ts-ignore
1377
+ if (typeof process !== 'undefined' &&
1378
+ typeof process.versions === 'object' &&
1379
+ !!process.versions.electron) {
1380
+ return true;
1381
+ }
1382
+ if (typeof navigator === 'object' &&
1383
+ typeof navigator.userAgent === 'string' &&
1384
+ navigator.userAgent.indexOf('Electron') >= 0) {
1385
+ return true;
1386
+ }
1387
+ return false;
1388
+ };
1389
+ /**
1390
+ * Check wether the current process is running inside
1391
+ * windows subsystem for linux (WSL).
1392
+ */
1393
+ UtilsOs.isRunningInWsl = () => {
1137
1394
  /* */
1138
1395
  /* */
1139
1396
  /* */
@@ -1151,6 +1408,9 @@ class HelpersMessages extends HelpersIsomorphic {
1151
1408
  /* */
1152
1409
  /* */
1153
1410
  /* */
1411
+ return (void 0);
1412
+ };
1413
+ UtilsOs.isRunningInDocker = () => {
1154
1414
  /* */
1155
1415
  /* */
1156
1416
  /* */
@@ -1158,6 +1418,9 @@ class HelpersMessages extends HelpersIsomorphic {
1158
1418
  /* */
1159
1419
  /* */
1160
1420
  /* */
1421
+ return (void 0);
1422
+ };
1423
+ UtilsOs.isRunningInLinuxGraphicsCapableEnvironment = () => {
1161
1424
  /* */
1162
1425
  /* */
1163
1426
  /* */
@@ -1165,61 +1428,190 @@ class HelpersMessages extends HelpersIsomorphic {
1165
1428
  /* */
1166
1429
  /* */
1167
1430
  /* */
1431
+ return (void 0);
1432
+ };
1433
+ })(UtilsOs || (UtilsOs = {}));
1434
+ var UtilsString;
1435
+ (function (UtilsString) {
1436
+ UtilsString.kebabCaseNoSplitNumbers = (input) => {
1437
+ return (input
1438
+ .replace(/\s+/g, '-')
1439
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
1440
+ .toLowerCase());
1441
+ };
1442
+ })(UtilsString || (UtilsString = {}));
1443
+ ;
1444
+ ({}); // @--end-of-file-for-module=tnp-core lib/utils.ts
1445
+
1446
+ class HelpersIsomorphic {
1447
+ /**
1448
+ * @deprecated
1449
+ * use UtilsOs.isRunningInBrowser() instead
1450
+ */
1451
+ get isBrowser() {
1452
+ return UtilsOs.isRunningInBrowser();
1453
+ }
1454
+ /**
1455
+ * @deprecated
1456
+ * use UtilsOs.isRunningInWebSQL() instead
1457
+ */
1458
+ get isWebSQL() {
1459
+ return UtilsOs.isRunningInWebSQL();
1460
+ }
1461
+ /**
1462
+ * @deprecated
1463
+ * use UtilsOs.isRunningInNode() instead
1464
+ */
1465
+ get isNode() {
1466
+ return UtilsOs.isRunningInNode();
1467
+ }
1468
+ /**
1469
+ * @deprecated
1470
+ * use UtilsOs.isRunningInElectron() instead
1471
+ */
1472
+ get isElectron() {
1473
+ return UtilsOs.isRunningInElectron();
1474
+ }
1475
+ /**
1476
+ * TODO what is the purpose of this function?
1477
+ * @deprecated
1478
+ */
1479
+ contain(arr, item) {
1480
+ return (arr.filter(l => {
1481
+ if (l instanceof RegExp) {
1482
+ return l.test(item);
1483
+ }
1484
+ if (l === item) {
1485
+ return true;
1486
+ }
1487
+ if (item.match && typeof item.match === 'function' ? item.match(l) : false) {
1488
+ return true;
1489
+ }
1490
+ return false;
1491
+ }).length > 0);
1492
+ }
1493
+ }
1494
+ ;
1495
+ ({}); // @--end-of-file-for-module=tnp-core lib/helpers-isomorphic.ts
1496
+
1497
+ /* */
1498
+ /* */
1499
+ /* */
1500
+ const KEY = {
1501
+ LAST_ERROR: Symbol(),
1502
+ LAST_INFO: Symbol(),
1503
+ LAST_WARN: Symbol(),
1504
+ LAST_LOG: Symbol(),
1505
+ LAST_SUCCESS: Symbol(),
1506
+ LAST_TASK_STARTED: Symbol(),
1507
+ LAST_TASK_DONE: Symbol(),
1508
+ };
1509
+ const KEY_COUNT = {
1510
+ LAST_ERROR: Symbol(),
1511
+ LAST_INFO: Symbol(),
1512
+ LAST_WARN: Symbol(),
1513
+ LAST_LOG: Symbol(),
1514
+ LAST_SUCCESS: Symbol(),
1515
+ LAST_TASK_STARTED: Symbol(),
1516
+ LAST_TASK_DONE: Symbol(),
1517
+ };
1518
+ const KEY_IMPORTANTCE = {
1519
+ LAST_ERROR: Symbol(),
1520
+ LAST_INFO: Symbol(),
1521
+ LAST_WARN: Symbol(),
1522
+ LAST_LOG: Symbol(),
1523
+ LAST_SUCCESS: Symbol(),
1524
+ LAST_TASK_STARTED: Symbol(),
1525
+ LAST_TASK_DONE: Symbol(),
1526
+ };
1527
+ /* */
1528
+ /* */
1529
+ /* */
1530
+ /* */
1531
+ /* */
1532
+ /* */
1533
+ /* */
1534
+ /* */
1535
+ /* */
1536
+ /* */
1537
+ /* */
1538
+ /* */
1539
+ /* */
1540
+ /* */
1541
+ /* */
1542
+ /* */
1543
+ /* */
1544
+ /* */
1545
+ /* */
1546
+ /* */
1547
+ /* */
1548
+ const LIMIT = 10;
1549
+ class HelpersMessages extends HelpersIsomorphic {
1550
+ msgCacheClear() {
1168
1551
  /* */
1169
1552
  /* */
1170
1553
  /* */
1171
1554
  /* */
1172
1555
  /* */
1173
1556
  }
1557
+ renderError(err) {
1558
+ if (this.isBrowser) {
1559
+ console.error(err);
1560
+ }
1561
+ else {
1562
+ /* */
1563
+ /* */
1564
+ /* */
1565
+ /* */
1566
+ /* */
1567
+ /* */
1568
+ /* */
1569
+ /* */
1570
+ /* */
1571
+ }
1572
+ }
1174
1573
  /**
1175
- * Logs not visible in normal use of taon-cli
1574
+ * Throw error and exit process
1575
+ * make sure browser or nodejs will not continue
1576
+ * @param details
1176
1577
  */
1177
- logSuccess(details) {
1578
+ throw(details) {
1579
+ if (this.isBrowser) {
1580
+ document.body.innerHTML =
1581
+ '<h1>Application has encountered an error and stopped.</h1>';
1582
+ document.body.style.pointerEvents = 'none';
1583
+ /* */
1584
+ /* */
1585
+ /* */
1586
+ /* */
1587
+ }
1588
+ throw new Error(details);
1589
+ }
1590
+ error(details, noExit = false, noTrace = false) {
1591
+ if (Helpers.isBrowser) {
1592
+ console.error(details);
1593
+ return;
1594
+ }
1178
1595
  /* */
1179
1596
  /* */
1180
1597
  /* */
1181
1598
  /* */
1182
1599
  /* */
1183
- return (void 0);
1184
- }
1185
- /**
1186
- * Logs not visible in normal use of taon-cli
1187
- */
1188
- logInfo(details, repeatable = false) {
1189
1600
  /* */
1190
1601
  /* */
1191
1602
  /* */
1192
1603
  /* */
1193
1604
  /* */
1194
- return (void 0);
1195
- }
1196
- /**
1197
- * Logs not visible in normal use of taon-cli
1198
- */
1199
- logError(details, noExit = false, noTrace = false) {
1200
1605
  /* */
1201
1606
  /* */
1202
1607
  /* */
1203
1608
  /* */
1204
1609
  /* */
1205
- return (void 0);
1206
- }
1207
- /**
1208
- * Logs not visible in normal use of taon-cli
1209
- */
1210
- logWarn(details, trace = false) {
1211
1610
  /* */
1212
1611
  /* */
1213
1612
  /* */
1214
1613
  /* */
1215
1614
  /* */
1216
- return (void 0);
1217
- }
1218
- warn(details, trace = false) {
1219
- if (Helpers.isBrowser) {
1220
- console.warn(details);
1221
- return;
1222
- }
1223
1615
  /* */
1224
1616
  /* */
1225
1617
  /* */
@@ -1250,6 +1642,25 @@ class HelpersMessages extends HelpersIsomorphic {
1250
1642
  /* */
1251
1643
  /* */
1252
1644
  /* */
1645
+ }
1646
+ info(details, repeatable = false) {
1647
+ /* */
1648
+ /* */
1649
+ /* */
1650
+ /* */
1651
+ /* */
1652
+ /* */
1653
+ if (Helpers.isBrowser) {
1654
+ console.info(details);
1655
+ return;
1656
+ }
1657
+ /* */
1658
+ /* */
1659
+ /* */
1660
+ /* */
1661
+ /* */
1662
+ /* */
1663
+ /* */
1253
1664
  /* */
1254
1665
  /* */
1255
1666
  /* */
@@ -1272,60 +1683,26 @@ class HelpersMessages extends HelpersIsomorphic {
1272
1683
  /* */
1273
1684
  /* */
1274
1685
  /* */
1275
- }
1276
- }
1277
- function transformData(details) {
1278
- if (typeof details === 'object') {
1279
- if (Array.isArray(details)) {
1280
- return details.join('\n');
1281
- }
1282
- try {
1283
- const json = JSON.stringify(details);
1284
- details = json;
1285
- }
1286
- catch (error) {
1287
- return details;
1288
- }
1289
- }
1290
- return details;
1291
- }
1292
- ;
1293
- ({}); // @--end-of-file-for-module=tnp-core lib/helpers-messages.ts
1294
-
1295
- const encoding = 'utf8';
1296
- /* */
1297
- /* */
1298
- /* */
1299
- const WEBSQL_PROC_MOCK_PROCESSES_PID = {};
1300
- const WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
1301
- class HelpersCore extends HelpersMessages {
1302
- static get InstanceCore() {
1303
- if (!HelpersCore._instanceCore) {
1304
- HelpersCore._instanceCore = new HelpersCore();
1305
- }
1306
- return HelpersCore._instanceCore;
1307
- }
1308
- /* */
1309
- /* */
1310
- /* */
1311
- /* */
1312
- /* */
1313
- /* */
1314
- /* */
1315
- /* */
1316
- /* */
1317
- /* */
1318
- /* */
1319
- constructor() {
1320
- super();
1321
1686
  /* */
1322
1687
  /* */
1323
- this.bigMaxBuffer = 2024 * 500;
1324
1688
  /* */
1325
1689
  /* */
1326
1690
  /* */
1327
1691
  }
1328
- get isWsl() {
1692
+ success(details) {
1693
+ if (Helpers.isBrowser) {
1694
+ console.info(details);
1695
+ return;
1696
+ }
1697
+ /* */
1698
+ /* */
1699
+ /* */
1700
+ /* */
1701
+ /* */
1702
+ /* */
1703
+ /* */
1704
+ /* */
1705
+ /* */
1329
1706
  /* */
1330
1707
  /* */
1331
1708
  /* */
@@ -1343,9 +1720,6 @@ class HelpersCore extends HelpersMessages {
1343
1720
  /* */
1344
1721
  /* */
1345
1722
  /* */
1346
- return (void 0);
1347
- }
1348
- isRunningInDocker() {
1349
1723
  /* */
1350
1724
  /* */
1351
1725
  /* */
@@ -1353,47 +1727,34 @@ class HelpersCore extends HelpersMessages {
1353
1727
  /* */
1354
1728
  /* */
1355
1729
  /* */
1356
- return (void 0);
1357
- }
1358
- clearConsole() {
1359
- Helpers.msgCacheClear();
1360
- console.log('\x1Bc');
1361
- }
1362
- /**
1363
- * get electron browser ipc renderer
1364
- */
1365
- get ipcRenderer() {
1366
1730
  /* */
1367
1731
  /* */
1368
- if (!this.isElectron) {
1369
- return;
1370
- }
1371
- return window.require('electron')
1372
- .ipcRenderer;
1373
- }
1374
- /**
1375
- * get electron web frame
1376
- */
1377
- get webFrame() {
1378
1732
  /* */
1379
1733
  /* */
1380
- if (!this.isElectron) {
1381
- return;
1382
- }
1383
- return window.require('electron').webFrame;
1384
1734
  }
1385
1735
  /**
1386
- * get electron backend ipc main proces
1736
+ *
1737
+ * @param details
1738
+ * @param isLogTask is less important log task
1739
+ * @returns
1387
1740
  */
1388
- get ipcMain() {
1741
+ taskStarted(details, isLogTask = false) {
1742
+ if (Helpers.isBrowser) {
1743
+ console.info(details);
1744
+ return;
1745
+ }
1746
+ /* */
1747
+ /* */
1748
+ /* */
1749
+ /* */
1750
+ /* */
1751
+ /* */
1752
+ /* */
1389
1753
  /* */
1390
1754
  /* */
1391
1755
  /* */
1392
1756
  /* */
1393
1757
  /* */
1394
- return (void 0);
1395
- }
1396
- getElectronWindow({ allowRunningInsecureContent = true, } = {}) {
1397
1758
  /* */
1398
1759
  /* */
1399
1760
  /* */
@@ -1409,19 +1770,8 @@ class HelpersCore extends HelpersMessages {
1409
1770
  /* */
1410
1771
  /* */
1411
1772
  /* */
1412
- return (void 0);
1413
- }
1414
- mediaTypeFromSrc(src) {
1415
- const ext = path.extname(src);
1416
- const media = CoreModels.mimeTypes[ext];
1417
- return _.first(media?.split('/'));
1418
- }
1419
- sleep(seconds = 1) {
1420
1773
  /* */
1421
1774
  /* */
1422
- return (void 0);
1423
- }
1424
- removeIfExists(absoluteFileOrFolderPath) {
1425
1775
  /* */
1426
1776
  /* */
1427
1777
  /* */
@@ -1440,12 +1790,12 @@ class HelpersCore extends HelpersMessages {
1440
1790
  /* */
1441
1791
  /* */
1442
1792
  /* */
1443
- return (void 0);
1444
- }
1445
- relative(cwd, to) {
1446
- return crossPlatformPath(path.relative(cwd, to));
1447
1793
  }
1448
- removeFileIfExists(absoluteFilePath) {
1794
+ taskDone(details, isLessImportant = false) {
1795
+ if (Helpers.isBrowser) {
1796
+ console.info(details);
1797
+ return;
1798
+ }
1449
1799
  /* */
1450
1800
  /* */
1451
1801
  /* */
@@ -1459,9 +1809,6 @@ class HelpersCore extends HelpersMessages {
1459
1809
  /* */
1460
1810
  /* */
1461
1811
  /* */
1462
- return (void 0);
1463
- }
1464
- removeFolderIfExists(absoluteFolderPath) {
1465
1812
  /* */
1466
1813
  /* */
1467
1814
  /* */
@@ -1476,36 +1823,6 @@ class HelpersCore extends HelpersMessages {
1476
1823
  /* */
1477
1824
  /* */
1478
1825
  /* */
1479
- return (void 0);
1480
- }
1481
- /**
1482
- * leave max 1 empty line
1483
- */
1484
- removeEmptyLineFromString(str) {
1485
- const lines = (str || '').split('\n');
1486
- let previousWasEmpty = false;
1487
- return lines
1488
- .filter(line => {
1489
- if (line.trim() === '') {
1490
- if (previousWasEmpty) {
1491
- return false;
1492
- }
1493
- else {
1494
- previousWasEmpty = true;
1495
- return true;
1496
- }
1497
- }
1498
- else {
1499
- previousWasEmpty = false;
1500
- return true;
1501
- }
1502
- })
1503
- .join('\n');
1504
- }
1505
- /**
1506
- * @deprecated
1507
- */
1508
- tryRemoveDir(dirpath, contentOnly = false, omitWarningNotExisted = false) {
1509
1826
  /* */
1510
1827
  /* */
1511
1828
  /* */
@@ -1531,6 +1848,33 @@ class HelpersCore extends HelpersMessages {
1531
1848
  /* */
1532
1849
  /* */
1533
1850
  /* */
1851
+ }
1852
+ log(details, debugLevel = 0) {
1853
+ if (Helpers.isBrowser) {
1854
+ console.log(details);
1855
+ return;
1856
+ }
1857
+ /* */
1858
+ /* */
1859
+ /* */
1860
+ /* */
1861
+ /* */
1862
+ /* */
1863
+ /* */
1864
+ /* */
1865
+ /* */
1866
+ /* */
1867
+ /* */
1868
+ /* */
1869
+ /* */
1870
+ /* */
1871
+ /* */
1872
+ /* */
1873
+ /* */
1874
+ /* */
1875
+ /* */
1876
+ /* */
1877
+ /* */
1534
1878
  /* */
1535
1879
  /* */
1536
1880
  /* */
@@ -1542,9 +1886,6 @@ class HelpersCore extends HelpersMessages {
1542
1886
  /* */
1543
1887
  /* */
1544
1888
  /* */
1545
- return (void 0);
1546
- }
1547
- remove(fileOrFolderPathOrPatter, exactFolder = false) {
1548
1889
  /* */
1549
1890
  /* */
1550
1891
  /* */
@@ -1555,19 +1896,6 @@ class HelpersCore extends HelpersMessages {
1555
1896
  /* */
1556
1897
  /* */
1557
1898
  /* */
1558
- return (void 0);
1559
- }
1560
- /* */
1561
- /* */
1562
- /* */
1563
- /* */
1564
- /* */
1565
- /* */
1566
- /* */
1567
- /* */
1568
- /* */
1569
- /* */
1570
- get isRunningInGitBash() {
1571
1899
  /* */
1572
1900
  /* */
1573
1901
  /* */
@@ -1576,73 +1904,140 @@ class HelpersCore extends HelpersMessages {
1576
1904
  /* */
1577
1905
  /* */
1578
1906
  /* */
1579
- return (void 0);
1580
1907
  }
1581
1908
  /**
1582
- * Check if the current shell is supported by Taon framework.
1909
+ * Logs not visible in normal use of taon-cli
1583
1910
  */
1584
- get isSupportedTaonTerminal() {
1911
+ logSuccess(details) {
1912
+ /* */
1913
+ /* */
1914
+ /* */
1585
1915
  /* */
1586
1916
  /* */
1587
1917
  return (void 0);
1588
1918
  }
1589
1919
  /**
1590
- * check if function is class
1920
+ * Logs not visible in normal use of taon-cli
1591
1921
  */
1592
- isClass(funcOrClass) {
1593
- let isClass = false;
1594
- if (typeof funcOrClass === 'function') {
1595
- isClass =
1596
- !!funcOrClass.prototype &&
1597
- Object.getOwnPropertyNames(funcOrClass.prototype).filter(f => f !== 'constructor').length > 0;
1598
- }
1599
- return isClass;
1922
+ logInfo(details, repeatable = false) {
1923
+ /* */
1924
+ /* */
1925
+ /* */
1926
+ /* */
1927
+ /* */
1928
+ return (void 0);
1600
1929
  }
1601
1930
  /**
1602
- * check if data is nodejs/browser blob
1603
- *
1604
- * @param maybeBlob
1605
- * @returns
1931
+ * Logs not visible in normal use of taon-cli
1606
1932
  */
1607
- isBlob(maybeBlob) {
1608
- return maybeBlob instanceof Blob; // || toString.call(maybeBlob) === '[object Blob]';
1933
+ logError(details, noExit = false, noTrace = false) {
1934
+ /* */
1935
+ /* */
1936
+ /* */
1937
+ /* */
1938
+ /* */
1939
+ return (void 0);
1609
1940
  }
1610
1941
  /**
1611
- * Check if data is nodejs buffer
1612
- *
1613
- * @param maybeNodejsBuffer
1614
- * @returns
1942
+ * Logs not visible in normal use of taon-cli
1615
1943
  */
1616
- /* */
1617
- /* */
1618
- /* */
1619
- /* */
1620
- removeSlashAtEnd(s) {
1621
- s = s?.endsWith(`/`) ? s.slice(0, s.length - 1) : s;
1622
- return s;
1623
- }
1624
- removeSlashAtBegin(s) {
1625
- s = s?.startsWith(`/`) ? s.slice(1) : s;
1626
- return s;
1944
+ logWarn(details, trace = false) {
1945
+ /* */
1946
+ /* */
1947
+ /* */
1948
+ /* */
1949
+ /* */
1950
+ return (void 0);
1627
1951
  }
1628
- /**
1629
- * stringify to pretty json string
1630
- */
1631
- stringify(inputObject) {
1632
- return JSON.stringify(inputObject, null, 2);
1952
+ warn(details, trace = false) {
1953
+ if (Helpers.isBrowser) {
1954
+ console.warn(details);
1955
+ return;
1956
+ }
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
+ /* */
1633
2009
  }
1634
- async runSyncOrAsync(fnOrOptions) {
1635
- if (_.isUndefined(fnOrOptions)) {
1636
- return void 0;
2010
+ }
2011
+ function transformData(details) {
2012
+ if (typeof details === 'object') {
2013
+ if (Array.isArray(details)) {
2014
+ return details.join('\n');
1637
2015
  }
1638
- let promisOrValue;
1639
- const { functionFn, context, arrayOfParams } = fnOrOptions;
1640
- promisOrValue = functionFn.apply(context, arrayOfParams);
1641
- // // @ts-ignore
1642
- if (promisOrValue instanceof Promise) {
1643
- promisOrValue = Promise.resolve(promisOrValue);
2016
+ try {
2017
+ const json = JSON.stringify(details);
2018
+ details = json;
2019
+ }
2020
+ catch (error) {
2021
+ return details;
1644
2022
  }
1645
- return promisOrValue;
2023
+ }
2024
+ return details;
2025
+ }
2026
+ ;
2027
+ ({}); // @--end-of-file-for-module=tnp-core lib/helpers-messages.ts
2028
+
2029
+ const encoding = 'utf8';
2030
+ /* */
2031
+ /* */
2032
+ /* */
2033
+ const WEBSQL_PROC_MOCK_PROCESSES_PID = {};
2034
+ const WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
2035
+ class HelpersCore extends HelpersMessages {
2036
+ static get InstanceCore() {
2037
+ if (!HelpersCore._instanceCore) {
2038
+ HelpersCore._instanceCore = new HelpersCore();
2039
+ }
2040
+ return HelpersCore._instanceCore;
1646
2041
  }
1647
2042
  /* */
1648
2043
  /* */
@@ -1655,264 +2050,72 @@ class HelpersCore extends HelpersMessages {
1655
2050
  /* */
1656
2051
  /* */
1657
2052
  /* */
1658
- /* */
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
- * symlink may have existed or unexisted destiantion url
1895
- * @param destUrl M
1896
- */
1897
- isSymlinkThatMatchesUrl(possibleSymlink, destUrl, absoluteFileMatch = false) {
1898
- /* */
1899
- /* */
1900
- /* */
1901
- /* */
2053
+ constructor() {
2054
+ super();
1902
2055
  /* */
1903
2056
  /* */
2057
+ this.bigMaxBuffer = 2024 * 500;
1904
2058
  /* */
1905
2059
  /* */
1906
2060
  /* */
2061
+ }
2062
+ /**
2063
+ * @deprecated use UtilsOs.isRunningInsideWsl()
2064
+ */
2065
+ get isWsl() {
2066
+ return UtilsOs.isRunningInWsl();
2067
+ }
2068
+ /**
2069
+ * @deprecated use UtilsOs.isRunningInDocker
2070
+ */
2071
+ isRunningInDocker() {
2072
+ return UtilsOs.isRunningInDocker();
2073
+ }
2074
+ /**
2075
+ * @deprecated use UtilsOs.isRunningInLinuxGraphicEnvironment
2076
+ */
2077
+ isRunningInLinuxGraphicsCapableEnvironment() {
2078
+ return UtilsOs.isRunningInLinuxGraphicsCapableEnvironment();
2079
+ }
2080
+ clearConsole() {
2081
+ Helpers.msgCacheClear();
2082
+ console.log('\x1Bc');
2083
+ }
2084
+ /**
2085
+ * get electron browser ipc renderer
2086
+ */
2087
+ get ipcRenderer() {
1907
2088
  /* */
1908
2089
  /* */
2090
+ if (!this.isElectron) {
2091
+ return;
2092
+ }
2093
+ return window.require('electron')
2094
+ .ipcRenderer;
2095
+ }
2096
+ /**
2097
+ * get electron web frame
2098
+ */
2099
+ get webFrame() {
1909
2100
  /* */
1910
2101
  /* */
2102
+ if (!this.isElectron) {
2103
+ return;
2104
+ }
2105
+ return window.require('electron').webFrame;
2106
+ }
2107
+ /**
2108
+ * get electron backend ipc main proces
2109
+ */
2110
+ get ipcMain() {
1911
2111
  /* */
1912
2112
  /* */
1913
2113
  /* */
1914
2114
  /* */
1915
2115
  /* */
2116
+ return (void 0);
2117
+ }
2118
+ getElectronWindow({ allowRunningInsecureContent = true, } = {}) {
1916
2119
  /* */
1917
2120
  /* */
1918
2121
  /* */
@@ -1930,25 +2133,17 @@ class HelpersCore extends HelpersMessages {
1930
2133
  /* */
1931
2134
  return (void 0);
1932
2135
  }
1933
- isSymlinkFileExitedOrUnexisted(filePath) {
1934
- /* */
1935
- /* */
1936
- /* */
1937
- /* */
1938
- /* */
1939
- /* */
1940
- /* */
1941
- /* */
2136
+ mediaTypeFromSrc(src) {
2137
+ const ext = path.extname(src);
2138
+ const media = CoreModels.mimeTypes[ext];
2139
+ return _.first(media?.split('/'));
2140
+ }
2141
+ sleep(seconds = 1) {
1942
2142
  /* */
1943
2143
  /* */
1944
2144
  return (void 0);
1945
2145
  }
1946
- /**
1947
- * If symbolnk link that target file does not exits
1948
- */
1949
- isUnexistedLink(filePath) {
1950
- /* */
1951
- /* */
2146
+ removeIfExists(absoluteFileOrFolderPath) {
1952
2147
  /* */
1953
2148
  /* */
1954
2149
  /* */
@@ -1970,18 +2165,12 @@ class HelpersCore extends HelpersMessages {
1970
2165
  return (void 0);
1971
2166
  }
1972
2167
  /**
1973
- * @param existedLink check if source of link exists
2168
+ * path.relative that return cross platform path
1974
2169
  */
1975
- isExistedSymlink(filePath) {
1976
- /* */
1977
- /* */
1978
- /* */
1979
- /* */
1980
- /* */
1981
- /* */
1982
- /* */
1983
- /* */
1984
- /* */
2170
+ relative(cwd, to) {
2171
+ return crossPlatformPath(path.relative(cwd, to));
2172
+ }
2173
+ removeFileIfExists(absoluteFilePath) {
1985
2174
  /* */
1986
2175
  /* */
1987
2176
  /* */
@@ -1997,35 +2186,7 @@ class HelpersCore extends HelpersMessages {
1997
2186
  /* */
1998
2187
  return (void 0);
1999
2188
  }
2000
- /* */
2001
- /* */
2002
- /* */
2003
- /* */
2004
- /* */
2005
- /* */
2006
- /* */
2007
- /* */
2008
- /* */
2009
- /* */
2010
- /* */
2011
- /* */
2012
- /* */
2013
- /* */
2014
- /* */
2015
- /* */
2016
- /* */
2017
- /* */
2018
- exists(folderOrFilePath) {
2019
- /* */
2020
- /* */
2021
- /* */
2022
- /* */
2023
- /* */
2024
- /* */
2025
- /* */
2026
- /* */
2027
- /* */
2028
- /* */
2189
+ removeFolderIfExists(absoluteFolderPath) {
2029
2190
  /* */
2030
2191
  /* */
2031
2192
  /* */
@@ -2043,24 +2204,33 @@ class HelpersCore extends HelpersMessages {
2043
2204
  return (void 0);
2044
2205
  }
2045
2206
  /**
2046
- * this is HACK for running procesess inside processes
2207
+ * leave max 1 empty line
2047
2208
  */
2048
- _fixCommand(command) {
2049
- if ((command.startsWith('tnp ') || command.startsWith('taon ')) && // TODO every cli projects here that uses run and need to kill process easly!
2050
- command.search('-spinner=false') === -1 &&
2051
- command.search('-spinner=off') === -1) {
2052
- command = `${command} -spinner=false`;
2053
- }
2054
- if (global.skipCoreCheck &&
2055
- (command.startsWith('tnp ') || command.startsWith('taon '))) {
2056
- command = `${command} --skipCoreCheck`;
2057
- }
2058
- return command;
2209
+ removeEmptyLineFromString(str) {
2210
+ const lines = (str || '').split('\n');
2211
+ let previousWasEmpty = false;
2212
+ return lines
2213
+ .filter(line => {
2214
+ if (line.trim() === '') {
2215
+ if (previousWasEmpty) {
2216
+ return false;
2217
+ }
2218
+ else {
2219
+ previousWasEmpty = true;
2220
+ return true;
2221
+ }
2222
+ }
2223
+ else {
2224
+ previousWasEmpty = false;
2225
+ return true;
2226
+ }
2227
+ })
2228
+ .join('\n');
2059
2229
  }
2060
- command(command) {
2061
- command = Helpers._fixCommand(command);
2062
- return {
2063
- /* */
2230
+ /**
2231
+ * @deprecated
2232
+ */
2233
+ tryRemoveDir(dirpath, contentOnly = false, omitWarningNotExisted = false) {
2064
2234
  /* */
2065
2235
  /* */
2066
2236
  /* */
@@ -2097,6 +2267,9 @@ class HelpersCore extends HelpersMessages {
2097
2267
  /* */
2098
2268
  /* */
2099
2269
  /* */
2270
+ return (void 0);
2271
+ }
2272
+ remove(fileOrFolderPathOrPatter, exactFolder = false) {
2100
2273
  /* */
2101
2274
  /* */
2102
2275
  /* */
@@ -2107,25 +2280,95 @@ class HelpersCore extends HelpersMessages {
2107
2280
  /* */
2108
2281
  /* */
2109
2282
  /* */
2283
+ return (void 0);
2284
+ }
2285
+ /* */
2286
+ /* */
2287
+ /* */
2288
+ /* */
2289
+ /* */
2290
+ /* */
2291
+ /* */
2292
+ /* */
2293
+ /* */
2294
+ /* */
2295
+ get isRunningInGitBash() {
2110
2296
  /* */
2111
2297
  /* */
2112
2298
  /* */
2113
2299
  /* */
2114
2300
  /* */
2115
2301
  /* */
2116
- };
2302
+ /* */
2303
+ /* */
2304
+ return (void 0);
2117
2305
  }
2118
- wait(second) {
2119
- return new Promise((resolve, reject) => {
2120
- setTimeout(() => {
2121
- resolve(void 0);
2122
- }, second * 1000);
2123
- });
2306
+ /**
2307
+ * Check if the current shell is supported by Taon framework.
2308
+ */
2309
+ get isSupportedTaonTerminal() {
2310
+ /* */
2311
+ /* */
2312
+ return (void 0);
2313
+ }
2314
+ /**
2315
+ * check if function is class
2316
+ */
2317
+ isClass(funcOrClass) {
2318
+ let isClass = false;
2319
+ if (typeof funcOrClass === 'function') {
2320
+ isClass =
2321
+ !!funcOrClass.prototype &&
2322
+ Object.getOwnPropertyNames(funcOrClass.prototype).filter(f => f !== 'constructor').length > 0;
2323
+ }
2324
+ return isClass;
2325
+ }
2326
+ /**
2327
+ * check if data is nodejs/browser blob
2328
+ *
2329
+ * @param maybeBlob
2330
+ * @returns
2331
+ */
2332
+ isBlob(maybeBlob) {
2333
+ return maybeBlob instanceof Blob; // || toString.call(maybeBlob) === '[object Blob]';
2124
2334
  }
2335
+ /**
2336
+ * Check if data is nodejs buffer
2337
+ *
2338
+ * @param maybeNodejsBuffer
2339
+ * @returns
2340
+ */
2125
2341
  /* */
2126
2342
  /* */
2127
2343
  /* */
2128
2344
  /* */
2345
+ removeSlashAtEnd(s) {
2346
+ s = s?.endsWith(`/`) ? s.slice(0, s.length - 1) : s;
2347
+ return s;
2348
+ }
2349
+ removeSlashAtBegin(s) {
2350
+ s = s?.startsWith(`/`) ? s.slice(1) : s;
2351
+ return s;
2352
+ }
2353
+ /**
2354
+ * stringify to pretty json string
2355
+ */
2356
+ stringify(inputObject) {
2357
+ return JSON.stringify(inputObject, null, 2);
2358
+ }
2359
+ async runSyncOrAsync(fnOrOptions) {
2360
+ if (_.isUndefined(fnOrOptions)) {
2361
+ return void 0;
2362
+ }
2363
+ let promisOrValue;
2364
+ const { functionFn, context, arrayOfParams } = fnOrOptions;
2365
+ promisOrValue = functionFn.apply(context, arrayOfParams);
2366
+ // // @ts-ignore
2367
+ if (promisOrValue instanceof Promise) {
2368
+ promisOrValue = Promise.resolve(promisOrValue);
2369
+ }
2370
+ return promisOrValue;
2371
+ }
2129
2372
  /* */
2130
2373
  /* */
2131
2374
  /* */
@@ -2200,178 +2443,663 @@ class HelpersCore extends HelpersMessages {
2200
2443
  /* */
2201
2444
  /* */
2202
2445
  /* */
2203
- async killProcessByPort(portOrPortsToKill, options) {
2204
- /* */
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
- return (void 0);
2249
- }
2250
- async killOnPort(portOrPortsToKill, options) {
2251
- return await Helpers.killProcessByPort(portOrPortsToKill, options);
2252
- }
2253
- killProcess(byPid) {
2254
- /* */
2255
- /* */
2256
- /* */
2257
- /* */
2258
- /* */
2259
- if (WEBSQL_PROC_MOCK_PROCESSES_PID[byPid]) {
2260
- const ppid = WEBSQL_PROC_MOCK_PROCESSES_PID[byPid].ppid;
2261
- if (WEBSQL_PROC_MOCK_PROCESSES_PPID[ppid]) {
2262
- const allChilds = WEBSQL_PROC_MOCK_PROCESSES_PPID[ppid]
2263
- .childProcesses;
2264
- WEBSQL_PROC_MOCK_PROCESSES_PPID[ppid].childProcesses = allChilds.filter(p => p !== byPid);
2265
- }
2266
- delete WEBSQL_PROC_MOCK_PROCESSES_PID[byPid];
2267
- }
2268
- if (WEBSQL_PROC_MOCK_PROCESSES_PPID[byPid]) {
2269
- const childs = WEBSQL_PROC_MOCK_PROCESSES_PPID[byPid]
2270
- .childProcesses;
2271
- for (let index = 0; index < childs.length; index++) {
2272
- const childPid = childs[index];
2273
- delete WEBSQL_PROC_MOCK_PROCESSES_PID[childPid];
2274
- }
2275
- delete WEBSQL_PROC_MOCK_PROCESSES_PPID[byPid];
2276
- }
2277
- }
2278
- run(command, options) {
2279
- command = Helpers._fixCommand(command);
2280
- /* */
2281
- /* */
2282
- /* */
2283
- /* */
2284
- /* */
2285
- /* */
2286
- /* */
2287
- /* */
2288
- return {
2289
- /**
2290
- * start command as synchronous nodej proces
2291
- */
2292
- sync() {
2293
- /* */
2294
- /* */
2295
- /* */
2296
- /* */
2297
- /* */
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
- return (void 0);
2325
- },
2326
- /**
2327
- * start command as asynchronous nodej proces
2328
- * @param detach (default: false) - if true process will be detached
2329
- */
2330
- async(detach = false, mockFun) {
2331
- if (mockFun) {
2332
- const subStdoutSub = new Subject();
2333
- const subStderSub = new Subject();
2334
- const exitSub = new Subject();
2335
- const subscribtions = [];
2336
- const procDummy = {
2337
- stdout: {
2338
- on(action, stdoutCallback) {
2339
- if (action == 'data') {
2340
- subscribtions.push(subStdoutSub.subscribe(d => {
2341
- stdoutCallback(d);
2342
- }));
2343
- }
2344
- },
2345
- },
2346
- stderr: {
2347
- on(action, stdoutCallback) {
2348
- if (action == 'data') {
2349
- subscribtions.push(subStderSub.subscribe(d => {
2350
- stdoutCallback(d);
2351
- }));
2352
- }
2353
- },
2354
- },
2355
- on(action, exitFun) {
2356
- if (action == 'exit') {
2357
- subscribtions.push(exitSub.subscribe(d => {
2358
- exitFun(d);
2359
- }));
2360
- }
2361
- }, // @ts-ignore
2362
- ppid: void 0, // @ts-ignore
2363
- pid: void 0,
2364
- };
2365
- procDummy.pid = Math.round(Math.random() * (1000 - 100)) + 100;
2366
- procDummy.ppid = procDummy.pid + 9999;
2367
- WEBSQL_PROC_MOCK_PROCESSES_PID[procDummy.pid] = procDummy;
2368
- if (!WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid]) {
2369
- WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid] = {
2370
- childProcesses: [],
2371
- };
2372
- }
2373
- WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid].childProcesses.push(procDummy.pid);
2374
- const checkIfProcessShouldBeDead = () => {
2446
+ /* */
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
+ * symlink may have existed or unexisted destiantion url
2620
+ * @param destUrl M
2621
+ */
2622
+ isSymlinkThatMatchesUrl(possibleSymlink, destUrl, absoluteFileMatch = false) {
2623
+ /* */
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
+ return (void 0);
2657
+ }
2658
+ isSymlinkFileExitedOrUnexisted(filePath) {
2659
+ /* */
2660
+ /* */
2661
+ /* */
2662
+ /* */
2663
+ /* */
2664
+ /* */
2665
+ /* */
2666
+ /* */
2667
+ /* */
2668
+ /* */
2669
+ return (void 0);
2670
+ }
2671
+ /**
2672
+ * If symbolnk link that target file does not exits
2673
+ */
2674
+ isUnexistedLink(filePath) {
2675
+ /* */
2676
+ /* */
2677
+ /* */
2678
+ /* */
2679
+ /* */
2680
+ /* */
2681
+ /* */
2682
+ /* */
2683
+ /* */
2684
+ /* */
2685
+ /* */
2686
+ /* */
2687
+ /* */
2688
+ /* */
2689
+ /* */
2690
+ /* */
2691
+ /* */
2692
+ /* */
2693
+ /* */
2694
+ /* */
2695
+ return (void 0);
2696
+ }
2697
+ /**
2698
+ * @param existedLink check if source of link exists
2699
+ */
2700
+ isExistedSymlink(filePath) {
2701
+ /* */
2702
+ /* */
2703
+ /* */
2704
+ /* */
2705
+ /* */
2706
+ /* */
2707
+ /* */
2708
+ /* */
2709
+ /* */
2710
+ /* */
2711
+ /* */
2712
+ /* */
2713
+ /* */
2714
+ /* */
2715
+ /* */
2716
+ /* */
2717
+ /* */
2718
+ /* */
2719
+ /* */
2720
+ /* */
2721
+ /* */
2722
+ /* */
2723
+ return (void 0);
2724
+ }
2725
+ /* */
2726
+ /* */
2727
+ /* */
2728
+ /* */
2729
+ /* */
2730
+ /* */
2731
+ /* */
2732
+ /* */
2733
+ /* */
2734
+ /* */
2735
+ /* */
2736
+ /* */
2737
+ /* */
2738
+ /* */
2739
+ /* */
2740
+ /* */
2741
+ /* */
2742
+ /* */
2743
+ exists(folderOrFilePath) {
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
+ return (void 0);
2769
+ }
2770
+ /**
2771
+ * this is HACK for running procesess inside processes
2772
+ */
2773
+ _fixCommand(command) {
2774
+ if ((command.startsWith('tnp ') || command.startsWith('taon ')) && // TODO every cli projects here that uses run and need to kill process easly!
2775
+ command.search('-spinner=false') === -1 &&
2776
+ command.search('-spinner=off') === -1) {
2777
+ command = `${command} -spinner=false`;
2778
+ }
2779
+ if (global.skipCoreCheck &&
2780
+ (command.startsWith('tnp ') || command.startsWith('taon '))) {
2781
+ command = `${command} --skipCoreCheck`;
2782
+ }
2783
+ return command;
2784
+ }
2785
+ command(command) {
2786
+ command = Helpers._fixCommand(command);
2787
+ return {
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
+ /* */
2821
+ /* */
2822
+ /* */
2823
+ /* */
2824
+ /* */
2825
+ /* */
2826
+ /* */
2827
+ /* */
2828
+ /* */
2829
+ /* */
2830
+ /* */
2831
+ /* */
2832
+ /* */
2833
+ /* */
2834
+ /* */
2835
+ /* */
2836
+ /* */
2837
+ /* */
2838
+ /* */
2839
+ /* */
2840
+ /* */
2841
+ };
2842
+ }
2843
+ wait(second) {
2844
+ return new Promise((resolve, reject) => {
2845
+ setTimeout(() => {
2846
+ resolve(void 0);
2847
+ }, second * 1000);
2848
+ });
2849
+ }
2850
+ async timeout(seconds) {
2851
+ return await Helpers.wait(seconds);
2852
+ }
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
+ async killProcessByPort(portOrPortsToKill, options) {
2932
+ /* */
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
+ return (void 0);
2977
+ }
2978
+ async killOnPort(portOrPortsToKill, options) {
2979
+ return await Helpers.killProcessByPort(portOrPortsToKill, options);
2980
+ }
2981
+ killProcess(byPid) {
2982
+ /* */
2983
+ /* */
2984
+ /* */
2985
+ /* */
2986
+ /* */
2987
+ if (WEBSQL_PROC_MOCK_PROCESSES_PID[byPid]) {
2988
+ const ppid = WEBSQL_PROC_MOCK_PROCESSES_PID[byPid].ppid;
2989
+ if (WEBSQL_PROC_MOCK_PROCESSES_PPID[ppid]) {
2990
+ const allChilds = WEBSQL_PROC_MOCK_PROCESSES_PPID[ppid]
2991
+ .childProcesses;
2992
+ WEBSQL_PROC_MOCK_PROCESSES_PPID[ppid].childProcesses = allChilds.filter(p => p !== byPid);
2993
+ }
2994
+ delete WEBSQL_PROC_MOCK_PROCESSES_PID[byPid];
2995
+ }
2996
+ if (WEBSQL_PROC_MOCK_PROCESSES_PPID[byPid]) {
2997
+ const childs = WEBSQL_PROC_MOCK_PROCESSES_PPID[byPid]
2998
+ .childProcesses;
2999
+ for (let index = 0; index < childs.length; index++) {
3000
+ const childPid = childs[index];
3001
+ delete WEBSQL_PROC_MOCK_PROCESSES_PID[childPid];
3002
+ }
3003
+ delete WEBSQL_PROC_MOCK_PROCESSES_PPID[byPid];
3004
+ }
3005
+ }
3006
+ run(command, options) {
3007
+ command = Helpers._fixCommand(command);
3008
+ /* */
3009
+ /* */
3010
+ /* */
3011
+ /* */
3012
+ /* */
3013
+ /* */
3014
+ /* */
3015
+ /* */
3016
+ return {
3017
+ /**
3018
+ * start command as synchronous nodej proces
3019
+ */
3020
+ sync() {
3021
+ /* */
3022
+ /* */
3023
+ /* */
3024
+ /* */
3025
+ /* */
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
+ return (void 0);
3053
+ },
3054
+ /**
3055
+ * start command as asynchronous nodej proces
3056
+ * @param detach (default: false) - if true process will be detached
3057
+ */
3058
+ async(detach = false, mockFun) {
3059
+ if (mockFun) {
3060
+ const subStdoutSub = new Subject();
3061
+ const subStderSub = new Subject();
3062
+ const exitSub = new Subject();
3063
+ const subscribtions = [];
3064
+ const procDummy = {
3065
+ stdout: {
3066
+ on(action, stdoutCallback) {
3067
+ if (action == 'data') {
3068
+ subscribtions.push(subStdoutSub.subscribe(d => {
3069
+ stdoutCallback(d);
3070
+ }));
3071
+ }
3072
+ },
3073
+ },
3074
+ stderr: {
3075
+ on(action, stdoutCallback) {
3076
+ if (action == 'data') {
3077
+ subscribtions.push(subStderSub.subscribe(d => {
3078
+ stdoutCallback(d);
3079
+ }));
3080
+ }
3081
+ },
3082
+ },
3083
+ on(action, exitFun) {
3084
+ if (action == 'exit') {
3085
+ subscribtions.push(exitSub.subscribe(d => {
3086
+ exitFun(d);
3087
+ }));
3088
+ }
3089
+ }, // @ts-ignore
3090
+ ppid: void 0, // @ts-ignore
3091
+ pid: void 0,
3092
+ };
3093
+ procDummy.pid = Math.round(Math.random() * (1000 - 100)) + 100;
3094
+ procDummy.ppid = procDummy.pid + 9999;
3095
+ WEBSQL_PROC_MOCK_PROCESSES_PID[procDummy.pid] = procDummy;
3096
+ if (!WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid]) {
3097
+ WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid] = {
3098
+ childProcesses: [],
3099
+ };
3100
+ }
3101
+ WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid].childProcesses.push(procDummy.pid);
3102
+ const checkIfProcessShouldBeDead = () => {
2375
3103
  return (_.isNil(WEBSQL_PROC_MOCK_PROCESSES_PID[procDummy.pid]) ||
2376
3104
  _.isNil(WEBSQL_PROC_MOCK_PROCESSES_PPID[procDummy.ppid]));
2377
3105
  };
@@ -2651,168 +3379,15 @@ class HelpersCore extends HelpersMessages {
2651
3379
  /* */
2652
3380
  /* */
2653
3381
  /* */
2654
- /* */
2655
- /* */
2656
- /* */
2657
- /* */
2658
- /* */
2659
- /* */
2660
- /* */
2661
- return (void 0);
2662
- }
2663
- /* */
2664
- /* */
2665
- /* */
2666
- /* */
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
- /* */
3382
+ /* */
3383
+ /* */
3384
+ /* */
3385
+ /* */
3386
+ /* */
3387
+ /* */
3388
+ /* */
3389
+ return (void 0);
3390
+ }
2816
3391
  /* */
2817
3392
  /* */
2818
3393
  /* */
@@ -3179,23 +3754,6 @@ class HelpersCore extends HelpersMessages {
3179
3754
  /* */
3180
3755
  /* */
3181
3756
  /* */
3182
- /**
3183
- * Quick fix for object values
3184
- * @deprecated
3185
- */
3186
- values(obj) {
3187
- if (_.isObject(obj) && !Array.isArray(obj)) {
3188
- const values = [];
3189
- for (const key in obj) {
3190
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
3191
- // @ts-ignore
3192
- values.push(obj[key]);
3193
- }
3194
- }
3195
- return values;
3196
- }
3197
- return [];
3198
- }
3199
3757
  /* */
3200
3758
  /* */
3201
3759
  /* */
@@ -3349,6 +3907,23 @@ class HelpersCore extends HelpersMessages {
3349
3907
  /* */
3350
3908
  /* */
3351
3909
  /* */
3910
+ /**
3911
+ * Quick fix for object values
3912
+ * @deprecated
3913
+ */
3914
+ values(obj) {
3915
+ if (_.isObject(obj) && !Array.isArray(obj)) {
3916
+ const values = [];
3917
+ for (const key in obj) {
3918
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
3919
+ // @ts-ignore
3920
+ values.push(obj[key]);
3921
+ }
3922
+ }
3923
+ return values;
3924
+ }
3925
+ return [];
3926
+ }
3352
3927
  /* */
3353
3928
  /* */
3354
3929
  /* */
@@ -3358,14 +3933,6 @@ class HelpersCore extends HelpersMessages {
3358
3933
  /* */
3359
3934
  /* */
3360
3935
  /* */
3361
- replaceLinesInFile(absoluteFilePath, lineReplaceFn) {
3362
- /* */
3363
- /* */
3364
- /* */
3365
- /* */
3366
- /* */
3367
- /* */
3368
- }
3369
3936
  /* */
3370
3937
  /* */
3371
3938
  /* */
@@ -3519,6 +4086,14 @@ class HelpersCore extends HelpersMessages {
3519
4086
  /* */
3520
4087
  /* */
3521
4088
  /* */
4089
+ replaceLinesInFile(absoluteFilePath, lineReplaceFn) {
4090
+ /* */
4091
+ /* */
4092
+ /* */
4093
+ /* */
4094
+ /* */
4095
+ /* */
4096
+ }
3522
4097
  /* */
3523
4098
  /* */
3524
4099
  /* */
@@ -3702,360 +4277,181 @@ class HelpersCore extends HelpersMessages {
3702
4277
  /* */
3703
4278
  /* */
3704
4279
  /* */
3705
- hideNodeWarnings() {
3706
- /* */
3707
- /* */
3708
- /* */
3709
- }
3710
- }
3711
- ;
3712
- ({}); // @--end-of-file-for-module=tnp-core lib/helpers.ts
3713
-
3714
- const CoreConfig = {
3715
- message: {
3716
- globalSystemToolMode: 'globalSystemToolMode',
3717
- },
3718
- };
3719
- ;
3720
- ({}); // @--end-of-file-for-module=tnp-core lib/core-config.ts
3721
-
3722
- class PROGRESS_DATA {
3723
- constructor() {
3724
- this.type = 'event';
3725
- }
3726
- static log(log) {
3727
- /* */
3728
- /* */
3729
- /* */
3730
- /* */
3731
- /* */
3732
- /* */
3733
- /* */
3734
- }
3735
- static resolveFrom(chunk, callbackOnFounded, checkSplit = true) {
3736
- let progress;
3737
- let res = [];
3738
- if (!_.isString(chunk)) {
3739
- return [];
3740
- }
3741
- chunk = chunk.trim();
3742
- if (checkSplit) {
3743
- const split = chunk.split(/\r\n|\n|\r/);
3744
- if (split.length > 1) {
3745
- split.forEach(s => {
3746
- res = res.concat(this.resolveFrom(s, callbackOnFounded, false));
3747
- });
3748
- return res;
3749
- }
3750
- }
3751
- if (/\[\[\[.*\]\]\]/g.test(chunk)) {
3752
- chunk = chunk.replace(/^\[\[\[/g, '').replace(/\]\]\]$/g, '');
3753
- progress = chunk;
3754
- }
3755
- if (!_.isUndefined(progress)) {
3756
- try {
3757
- const p = JSON.parse(progress);
3758
- const single = _.merge(new PROGRESS_DATA(), p);
3759
- res = res.concat([single]);
3760
- if (_.isFunction(callbackOnFounded)) {
3761
- callbackOnFounded(single);
3762
- }
3763
- }
3764
- catch (err) {
3765
- Helpers.error(err, true, true);
3766
- Helpers.error(`ProgresssBarData: fail to parse "${progress}"`, true, true);
3767
- }
3768
- }
3769
- return res;
3770
- }
3771
- }
3772
- ;
3773
- ({}); // @--end-of-file-for-module=tnp-core lib/progress-data.ts
3774
-
3775
- /* */
3776
- /* */
3777
- /* */
3778
- const BLOB_SUPPORTED_IN_SQLJS = false;
3779
- var Utils;
3780
- (function (Utils) {
3781
- Utils.uniqArray = (array, uniqueProperty) => {
3782
- var seen = {};
3783
- return array
3784
- .filter(f => !!f)
3785
- .filter(function (item) {
3786
- return seen.hasOwnProperty(uniqueProperty ? item[uniqueProperty] : item)
3787
- ? false
3788
- : (seen[uniqueProperty ? item[uniqueProperty] : item] = true);
3789
- });
3790
- };
3791
- /**
3792
- * Example:
3793
- * new RegExp(escapeStringForRegEx('a.b.c'),'g') => /a\.b\.c/g
3794
- */
3795
- Utils.escapeStringForRegEx = (stringForRegExp) => {
3796
- return stringForRegExp.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
3797
- };
3798
- function removeChalkSpecialChars(str) {
3799
- const ansiRegex = /\u001b\[[0-9;]*m/g;
3800
- return str.replace(ansiRegex, '');
3801
- }
3802
- Utils.removeChalkSpecialChars = removeChalkSpecialChars;
3803
- Utils.fullDateTime = () => {
3804
- /* */
3805
- /* */
3806
- return (void 0);
3807
- };
3808
- Utils.fullDate = () => {
3809
- /* */
3810
- /* */
3811
- return (void 0);
3812
- };
3813
- let json;
3814
- (function (json) {
3815
- json.getAtrributies = (jsonDeepPath, // lodash path to property in json ex. deep.path.to.prop
3816
- fileContent) => {
3817
- const lines = fileContent.split('\n');
3818
- const pathParts = jsonDeepPath.split('.').reduce((a, b) => {
3819
- if (a.length === 0) {
3820
- return [b];
3821
- }
3822
- const last = a[a.length - 1];
3823
- if ((last.startsWith(`['`) && b.endsWith(`']`)) ||
3824
- (last.startsWith(`["`) && b.endsWith(`"]`))) {
3825
- a[a.length - 1] = [last, b].join('.');
3826
- }
3827
- else {
3828
- a.push(b);
3829
- }
3830
- return a;
3831
- }, []);
3832
- const keyName = pathParts.pop().replace(/^\["(.+)"\]$/, '$1');
3833
- let currentPath = '';
3834
- let attributes = [];
3835
- let collectedComments = [];
3836
- for (const line of lines) {
3837
- const trimmedLine = line.trim();
3838
- if (trimmedLine.startsWith('//')) {
3839
- collectedComments.push(trimmedLine);
3840
- }
3841
- else if (trimmedLine.startsWith('"') || trimmedLine.startsWith("'")) {
3842
- const match = trimmedLine.match(/["']([^"']+)["']\s*:/);
3843
- if (match) {
3844
- const key = match[1];
3845
- currentPath = currentPath
3846
- ? `${currentPath}.${key.includes('.') ? `['${key}']` : key}`
3847
- : key;
3848
- if ((currentPath.endsWith(keyName) &&
3849
- !currentPath.endsWith('/' + keyName)) ||
3850
- currentPath.endsWith(`['${keyName}']`)) {
3851
- attributes = extractAttributesFromComments(collectedComments);
3852
- break;
3853
- }
3854
- collectedComments = [];
3855
- }
3856
- }
3857
- }
3858
- return attributes;
3859
- };
3860
- const extractAttributesFromComments = (comments) => {
3861
- const attributes = [];
3862
- const attrRegex = /@(\w+)(?:\s*=\s*([^\s@]+))?/g;
3863
- for (const comment of comments) {
3864
- let match;
3865
- while ((match = attrRegex.exec(comment)) !== null) {
3866
- const [, name, value] = match;
3867
- const existingAttribute = attributes.find(attr => attr.name === `@${name}`);
3868
- if (existingAttribute) {
3869
- if (value) {
3870
- if (Array.isArray(existingAttribute.value)) {
3871
- existingAttribute.value.push(value);
3872
- }
3873
- else {
3874
- existingAttribute.value = [existingAttribute.value, value];
3875
- }
3876
- }
3877
- }
3878
- else {
3879
- attributes.push({
3880
- name: `@${name}`,
3881
- value: value ? value : true,
3882
- });
3883
- }
3884
- }
3885
- }
3886
- attributes.forEach(attr => {
3887
- if (Array.isArray(attr.value) && attr.value.length === 1) {
3888
- attr.value = attr.value[0];
3889
- }
3890
- });
3891
- return attributes;
3892
- };
3893
- })(json = Utils.json || (Utils.json = {}));
3894
- let DbBinaryFormatEnum;
3895
- (function (DbBinaryFormatEnum) {
3896
- DbBinaryFormatEnum["Blob"] = "Blob";
3897
- DbBinaryFormatEnum["File"] = "File";
3898
- DbBinaryFormatEnum["string"] = "string";
3899
- /* */
3900
- /* */
3901
- })(DbBinaryFormatEnum = Utils.DbBinaryFormatEnum || (Utils.DbBinaryFormatEnum = {}));
3902
4280
  /* */
3903
4281
  /* */
3904
- let binary;
3905
- (function (binary) {
3906
- /**
3907
- * This is for BROWSER ONLY
3908
- *
3909
- * @param buffer
3910
- * @param contentType
3911
- * @returns
3912
- */
3913
- async function arrayBufferToBlob(buffer, contentType) {
3914
- // @ts-ignore
3915
- return new Blob([buffer], { type: contentType });
3916
- }
3917
- binary.arrayBufferToBlob = arrayBufferToBlob;
3918
- /**
3919
- * This is for BROWSER ONLY
3920
- * @param blob
3921
- * @returns
3922
- */
3923
- async function blobToArrayBuffer(blob) {
3924
- return await new Promise((resolve, reject) => {
3925
- const reader = new FileReader();
3926
- reader.addEventListener('loadend', () => {
3927
- resolve(reader.result);
3928
- });
3929
- reader.addEventListener('error', reject); // @ts-ignore
3930
- reader.readAsArrayBuffer(blob);
3931
- });
3932
- }
3933
- binary.blobToArrayBuffer = blobToArrayBuffer;
3934
- /**
3935
- * it is revers to base64toBlob
3936
- * @param blob
3937
- * @returns
3938
- */
3939
- function blobToBase64(blob) {
3940
- return new Promise((resolve, _) => {
3941
- const reader = new FileReader();
3942
- reader.onloadend = () => resolve(reader.result); // @ts-ignore
3943
- reader.readAsDataURL(blob);
3944
- });
3945
- }
3946
- binary.blobToBase64 = blobToBase64;
3947
- /**
3948
- * it is revers to blobToBase64()
3949
- * @param base64Data
3950
- * @returns
3951
- */
3952
- async function base64toBlob(base64Data, contentTypeOverride) {
3953
- let content_type = void 0;
3954
- let file_base64 = void 0;
3955
- if (!contentTypeOverride) {
3956
- const m = /^data:(.+?);base64,(.+)$/.exec(base64Data);
3957
- if (!m) {
3958
- throw new Error(`[taon-framework][base64toBlob] Not a base64 blob [${base64Data}]`);
3959
- }
3960
- var [__, contenttype, filebase64] = m;
3961
- content_type = contenttype;
3962
- file_base64 = filebase64;
3963
- }
3964
- content_type = (contentTypeOverride ? contentTypeOverride : content_type || '');
3965
- base64Data = contentTypeOverride ? base64Data : file_base64;
3966
- const sliceSize = 1024;
3967
- const byteCharacters = atob(base64Data);
3968
- const bytesLength = byteCharacters.length;
3969
- const slicesCount = Math.ceil(bytesLength / sliceSize);
3970
- const byteArrays = new Array(slicesCount);
3971
- for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
3972
- const begin = sliceIndex * sliceSize;
3973
- const end = Math.min(begin + sliceSize, bytesLength);
3974
- const bytes = new Array(end - begin);
3975
- for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
3976
- bytes[i] = byteCharacters[offset].charCodeAt(0);
3977
- }
3978
- byteArrays[sliceIndex] = new Uint8Array(bytes);
3979
- }
3980
- return new Blob(byteArrays, { type: content_type });
3981
- }
3982
- binary.base64toBlob = base64toBlob;
3983
- async function base64toDbBinaryFormat(text) {
3984
- let result;
3985
- result = await (async () => {
3986
- if (BLOB_SUPPORTED_IN_SQLJS) {
3987
- const blob = await base64toBlob(text);
3988
- return blob;
3989
- }
3990
- return text;
3991
- })();
3992
- /* */
3993
- /* */
3994
- /* */
3995
- /* */
3996
- /* */
3997
- return result;
3998
- }
3999
- binary.base64toDbBinaryFormat = base64toDbBinaryFormat;
4000
- async function dbBinaryFormatToBase64(binaryFormat) {
4001
- let result;
4002
- result = await (async () => {
4003
- if (BLOB_SUPPORTED_IN_SQLJS) {
4004
- const text = await blobToBase64(binaryFormat);
4005
- return text;
4006
- }
4007
- return binaryFormat;
4008
- })();
4009
- /* */
4010
- /* */
4011
- /* */
4012
- /* */
4013
- /* */
4014
- return result;
4015
- }
4016
- binary.dbBinaryFormatToBase64 = dbBinaryFormatToBase64;
4017
- async function textToDbBinaryFormat(text) {
4018
- let result;
4019
- result = await (async () => {
4020
- if (BLOB_SUPPORTED_IN_SQLJS) {
4021
- const blob = await textToBlob(text);
4022
- return blob;
4023
- }
4024
- return text;
4025
- })();
4026
- /* */
4027
- /* */
4028
- /* */
4029
- /* */
4030
- /* */
4031
- return result;
4032
- }
4033
- binary.textToDbBinaryFormat = textToDbBinaryFormat;
4034
- async function dbBinaryFormatToText(binaryFormat) {
4035
- let result;
4036
- result = await (async () => {
4037
- if (BLOB_SUPPORTED_IN_SQLJS) {
4038
- const text = await blobToText(binaryFormat);
4039
- return text;
4040
- }
4041
- return binaryFormat;
4042
- })();
4043
- /* */
4044
- /* */
4045
- /* */
4046
- /* */
4047
- /* */
4048
- return result;
4049
- }
4050
- binary.dbBinaryFormatToText = dbBinaryFormatToText;
4051
- /* */
4052
- /* */
4053
- /* */
4054
- /* */
4055
- /* */
4282
+ /* */
4283
+ /* */
4284
+ /* */
4285
+ /* */
4286
+ /* */
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
+ hideNodeWarnings() {
4056
4434
  /* */
4057
4435
  /* */
4058
4436
  /* */
4437
+ }
4438
+ }
4439
+ ;
4440
+ ({}); // @--end-of-file-for-module=tnp-core lib/helpers.ts
4441
+
4442
+ const CoreConfig = {
4443
+ message: {
4444
+ globalSystemToolMode: 'globalSystemToolMode',
4445
+ },
4446
+ };
4447
+ ;
4448
+ ({}); // @--end-of-file-for-module=tnp-core lib/core-config.ts
4449
+
4450
+ class PROGRESS_DATA {
4451
+ constructor() {
4452
+ this.type = 'event';
4453
+ }
4454
+ static log(log) {
4059
4455
  /* */
4060
4456
  /* */
4061
4457
  /* */
@@ -4063,165 +4459,46 @@ var Utils;
4063
4459
  /* */
4064
4460
  /* */
4065
4461
  /* */
4066
- async function fileToBlob(file) {
4067
- return new Blob([new Uint8Array(await file.arrayBuffer())], {
4068
- type: file.type,
4069
- });
4462
+ }
4463
+ static resolveFrom(chunk, callbackOnFounded, checkSplit = true) {
4464
+ let progress;
4465
+ let res = [];
4466
+ if (!_.isString(chunk)) {
4467
+ return [];
4070
4468
  }
4071
- binary.fileToBlob = fileToBlob;
4072
- async function blobToFile(blob, nameForFile = 'my-file-name') {
4073
- if (!nameForFile) {
4074
- nameForFile = 'nonamefile' + new Date().getTime();
4469
+ chunk = chunk.trim();
4470
+ if (checkSplit) {
4471
+ const split = chunk.split(/\r\n|\n|\r/);
4472
+ if (split.length > 1) {
4473
+ split.forEach(s => {
4474
+ res = res.concat(this.resolveFrom(s, callbackOnFounded, false));
4475
+ });
4476
+ return res;
4075
4477
  }
4076
- // @ts-ignore
4077
- return new File([blob], nameForFile);
4078
- }
4079
- binary.blobToFile = blobToFile;
4080
- /* */
4081
- /* */
4082
- /* */
4083
- /* */
4084
- /* */
4085
- /* */
4086
- /* */
4087
- /* */
4088
- /* */
4089
- /* */
4090
- /* */
4091
- /* */
4092
- /* */
4093
- /* */
4094
- /* */
4095
- /* */
4096
- /* */
4097
- /* */
4098
- /* */
4099
- /* */
4100
- /* */
4101
- /* */
4102
- /* */
4103
- /* */
4104
- /* */
4105
- /* */
4106
- async function textToBlob(text, type = 'text/plain') {
4107
- const blob = new Blob([text], { type });
4108
- return blob;
4109
- }
4110
- binary.textToBlob = textToBlob;
4111
- async function blobToText(blob) {
4112
- return await blob.text();
4113
- }
4114
- binary.blobToText = blobToText;
4115
- async function textToFile(text, fileRelativePathOrName) {
4116
- const ext = path.extname(fileRelativePathOrName);
4117
- const type = CoreModels.mimeTypes[ext];
4118
- const blob = new Blob([text], { type });
4119
- const file = await blobToFile(blob, fileRelativePathOrName);
4120
- return file;
4121
- }
4122
- binary.textToFile = textToFile;
4123
- async function fileToText(file) {
4124
- return await file.text();
4125
- }
4126
- binary.fileToText = fileToText;
4127
- async function jsonToBlob(jsonObj) {
4128
- const blob = new Blob([JSON.stringify(jsonObj, null, 2)], {
4129
- type: 'application/json',
4130
- });
4131
- return blob;
4132
4478
  }
4133
- binary.jsonToBlob = jsonToBlob;
4134
- /**
4135
- * TODO NOT TESTED
4136
- */
4137
- async function blobToJson(blob) {
4138
- return JSON.parse(await blob.text());
4139
- }
4140
- binary.blobToJson = blobToJson;
4141
- async function getBlobFrom(url) {
4142
- const response = await axios({
4143
- url,
4144
- method: 'get',
4145
- responseType: 'blob',
4146
- });
4147
- return response.data;
4479
+ if (/\[\[\[.*\]\]\]/g.test(chunk)) {
4480
+ chunk = chunk.replace(/^\[\[\[/g, '').replace(/\]\]\]$/g, '');
4481
+ progress = chunk;
4148
4482
  }
4149
- binary.getBlobFrom = getBlobFrom;
4150
- })(binary = Utils.binary || (Utils.binary = {}));
4151
- let css;
4152
- (function (css) {
4153
- /**
4154
- *
4155
- * @param pixelsCss pixels ex. 100px
4156
- * @returns
4157
- */
4158
- function numValue(pixelsCss) {
4159
- return parseInt(pixelsCss?.toString()?.replace('px', ''));
4483
+ if (!_.isUndefined(progress)) {
4484
+ try {
4485
+ const p = JSON.parse(progress);
4486
+ const single = _.merge(new PROGRESS_DATA(), p);
4487
+ res = res.concat([single]);
4488
+ if (_.isFunction(callbackOnFounded)) {
4489
+ callbackOnFounded(single);
4490
+ }
4491
+ }
4492
+ catch (err) {
4493
+ Helpers.error(err, true, true);
4494
+ Helpers.error(`ProgresssBarData: fail to parse "${progress}"`, true, true);
4495
+ }
4160
4496
  }
4161
- css.numValue = numValue;
4162
- })(css = Utils.css || (Utils.css = {}));
4163
- })(Utils || (Utils = {}));
4164
- var UtilsProcess;
4165
- (function (UtilsProcess) {
4166
- /**
4167
- * TODO IMPLEMENT
4168
- */
4169
- async function startAsync(command, options) {
4170
- }
4171
- UtilsProcess.startAsync = startAsync;
4172
- /**
4173
- * TODO IMPLEMENT
4174
- */
4175
- function startSync(command, options) {
4497
+ return res;
4176
4498
  }
4177
- UtilsProcess.startSync = startSync;
4178
- UtilsProcess.getBashOrShellName = () => {
4179
- /* */
4180
- /* */
4181
- /* */
4182
- /* */
4183
- /* */
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
- return (void 0);
4212
- };
4213
- })(UtilsProcess || (UtilsProcess = {}));
4214
- var UtilsString;
4215
- (function (UtilsString) {
4216
- UtilsString.kebabCaseNoSplitNumbers = (input) => {
4217
- return (input
4218
- .replace(/\s+/g, '-')
4219
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
4220
- .toLowerCase());
4221
- };
4222
- })(UtilsString || (UtilsString = {}));
4499
+ }
4223
4500
  ;
4224
- ({}); // @--end-of-file-for-module=tnp-core lib/utils.ts
4501
+ ({}); // @--end-of-file-for-module=tnp-core lib/progress-data.ts
4225
4502
 
4226
4503
  /* */
4227
4504
  /* */
@@ -4243,6 +4520,10 @@ class CLI {
4243
4520
  ;
4244
4521
  ({}); // @--end-of-file-for-module=tnp-core lib/core-cli.ts
4245
4522
 
4523
+ /**
4524
+ * TODO slowly refactor this.. only actually globally needed are:
4525
+ * pm2, yarn, npm-run, ts-node ???
4526
+ */
4246
4527
  const requiredForDev = {
4247
4528
  npm: [
4248
4529
  /* */
@@ -4277,6 +4558,9 @@ const requiredForDev = {
4277
4558
  /* */
4278
4559
  /* */
4279
4560
  /* */
4561
+ /* */
4562
+ /* */
4563
+ /* */
4280
4564
  ],
4281
4565
  niceTools: [
4282
4566
  /* */
@@ -4313,7 +4597,7 @@ const requiredForDev = {
4313
4597
  ],
4314
4598
  };
4315
4599
  ;
4316
- ({}); // @--end-of-file-for-module=tnp-core lib/required.ts
4600
+ ({}); // @--end-of-file-for-module=tnp-core lib/required-global-npm-packages.ts
4317
4601
 
4318
4602
  let Helpers = HelpersCore.InstanceCore;
4319
4603
  ;
@@ -4323,5 +4607,5 @@ let Helpers = HelpersCore.InstanceCore;
4323
4607
  * Generated bundle index. Do not edit.
4324
4608
  */
4325
4609
 
4326
- export { $, CLI, CoreConfig, HelpersCore as CoreHelpers, CoreModels, Helpers, PROGRESS_DATA, Utils, UtilsProcess, UtilsString, chalk, crossPlatformPath, frameworkName, frameworkNameBe, path, requiredForDev, win32Path };
4610
+ export { $, CLI, CoreConfig, HelpersCore as CoreHelpers, CoreModels, Helpers, PROGRESS_DATA, Utils, UtilsOs, UtilsProcess, UtilsString, chalk, crossPlatformPath, frameworkName, frameworkNameBe, path, requiredForDev, win32Path };
4327
4611
  //# sourceMappingURL=tnp-core.mjs.map