tnp-core 19.0.54 → 19.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -20
- package/browser/README.md +24 -24
- package/browser/fesm2022/tnp-core.mjs +183 -102
- package/browser/fesm2022/tnp-core.mjs.map +1 -1
- package/browser/lib/core-models.d.ts +3 -0
- package/browser/lib/framework-name.d.ts +3 -2
- package/browser/lib/utils.d.ts +35 -23
- package/browser/package.json +1 -1
- package/cli.backend.js +2 -2
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/core-models.d.ts +3 -0
- package/lib/core-models.js +1 -1
- package/lib/core-models.js.map +1 -1
- package/lib/framework-name.d.ts +3 -2
- package/lib/framework-name.js +6 -4
- package/lib/framework-name.js.map +1 -1
- package/lib/helpers-messages.js.map +1 -1
- package/lib/node-chalk-mock.js +2 -2
- package/lib/node-path-mock.js +2 -2
- package/lib/utils.d.ts +36 -24
- package/lib/utils.js +198 -127
- package/lib/utils.js.map +1 -1
- package/package.json +3 -2
- package/tmp-environment.json +6 -5
- package/websql/README.md +24 -24
- package/websql/fesm2022/tnp-core.mjs +183 -102
- package/websql/fesm2022/tnp-core.mjs.map +1 -1
- package/websql/lib/core-models.d.ts +3 -0
- package/websql/lib/framework-name.d.ts +3 -2
- package/websql/lib/utils.d.ts +35 -23
- package/websql/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# taon-core ( tnp-core )
|
|
2
|
-
|
|
3
|
-
- Part of [taon.dev](https://github.com/darekf77/taon)
|
|
4
|
-
- JavasScript/Typescript most essential helpers
|
|
5
|
-
- Basic taon releated helpers
|
|
6
|
-
- Purpose:
|
|
7
|
-
+ lightweight most essential helpers library
|
|
8
|
-
+ crossplatform helpers for NodeJs/Browser
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
- in taon isomorphic libs/apps or any NodeJS apps/libs:
|
|
13
|
-
```ts
|
|
14
|
-
import { Helpers } from 'tnp-core';
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
- in any frontend browser apps (except taon libs/apps)
|
|
18
|
-
```ts
|
|
19
|
-
import { Helpers } from 'tnp-core/browser';
|
|
20
|
-
```
|
|
1
|
+
# taon-core ( tnp-core )
|
|
2
|
+
|
|
3
|
+
- Part of [taon.dev](https://github.com/darekf77/taon)
|
|
4
|
+
- JavasScript/Typescript most essential helpers
|
|
5
|
+
- Basic taon releated helpers
|
|
6
|
+
- Purpose:
|
|
7
|
+
+ lightweight most essential helpers library
|
|
8
|
+
+ crossplatform helpers for NodeJs/Browser
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
- in taon isomorphic libs/apps or any NodeJS apps/libs:
|
|
13
|
+
```ts
|
|
14
|
+
import { Helpers } from 'tnp-core';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- in any frontend browser apps (except taon libs/apps)
|
|
18
|
+
```ts
|
|
19
|
+
import { Helpers } from 'tnp-core/browser';
|
|
20
|
+
```
|
package/browser/README.md
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# MyLib
|
|
2
|
-
|
|
3
|
-
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0.
|
|
4
|
-
|
|
5
|
-
## Code scaffolding
|
|
6
|
-
|
|
7
|
-
Run `ng generate component component-name --project my-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project my-lib`.
|
|
8
|
-
> Note: Don't forget to add `--project my-lib` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
-
|
|
10
|
-
## Build
|
|
11
|
-
|
|
12
|
-
Run `ng build my-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
-
|
|
14
|
-
## Publishing
|
|
15
|
-
|
|
16
|
-
After building your library with `ng build my-lib`, go to the dist folder `cd dist/my-lib` and run `npm publish`.
|
|
17
|
-
|
|
18
|
-
## Running unit tests
|
|
19
|
-
|
|
20
|
-
Run `ng test my-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
-
|
|
22
|
-
## Further help
|
|
23
|
-
|
|
24
|
-
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
|
1
|
+
# MyLib
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project my-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project my-lib`.
|
|
8
|
+
> Note: Don't forget to add `--project my-lib` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
Run `ng build my-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
## Publishing
|
|
15
|
+
|
|
16
|
+
After building your library with `ng build my-lib`, go to the dist folder `cd dist/my-lib` and run `npm publish`.
|
|
17
|
+
|
|
18
|
+
## Running unit tests
|
|
19
|
+
|
|
20
|
+
Run `ng test my-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
+
|
|
22
|
+
## Further help
|
|
23
|
+
|
|
24
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
|
@@ -18,10 +18,10 @@ let isBrowser = false;
|
|
|
18
18
|
isBrowser = true;
|
|
19
19
|
//#endregion
|
|
20
20
|
const frameworkNameBeTmp = '';
|
|
21
|
+
let frameworkNameBe = frameworkNameBeTmp;
|
|
21
22
|
/* */
|
|
22
23
|
/* */
|
|
23
24
|
/* */
|
|
24
|
-
const frameworkNameBe = frameworkNameBeTmp;
|
|
25
25
|
const frameworkName = isBrowser ? 'taon' : frameworkNameBe;
|
|
26
26
|
|
|
27
27
|
// TODO finish this MOCK @LAST
|
|
@@ -950,7 +950,7 @@ var CoreModels;
|
|
|
950
950
|
'model',
|
|
951
951
|
];
|
|
952
952
|
CoreModels.MimeTypesObj = CoreModels.mimeTypes;
|
|
953
|
-
|
|
953
|
+
CoreModels.tagForTaskName = '@updateValueWithPortNumForTaskName';
|
|
954
954
|
})(CoreModels || (CoreModels = {}));
|
|
955
955
|
|
|
956
956
|
//#region imports
|
|
@@ -1125,105 +1125,6 @@ var Utils;
|
|
|
1125
1125
|
})
|
|
1126
1126
|
.replace(/\s+/g, '');
|
|
1127
1127
|
};
|
|
1128
|
-
let json;
|
|
1129
|
-
(function (json) {
|
|
1130
|
-
json.getAtrributies = (jsonDeepPath, // lodash path to property in json ex. deep.path.to.prop
|
|
1131
|
-
fileContent) => {
|
|
1132
|
-
const lines = fileContent.split('\n');
|
|
1133
|
-
// split path to parts but keep part if is for example 'sql.js
|
|
1134
|
-
const pathParts = jsonDeepPath.split('.').reduce((a, b) => {
|
|
1135
|
-
if (a.length === 0) {
|
|
1136
|
-
return [b];
|
|
1137
|
-
}
|
|
1138
|
-
const last = a[a.length - 1];
|
|
1139
|
-
if ((last.startsWith(`['`) && b.endsWith(`']`)) ||
|
|
1140
|
-
(last.startsWith(`["`) && b.endsWith(`"]`))) {
|
|
1141
|
-
a[a.length - 1] = [last, b].join('.');
|
|
1142
|
-
}
|
|
1143
|
-
else {
|
|
1144
|
-
a.push(b);
|
|
1145
|
-
}
|
|
1146
|
-
return a;
|
|
1147
|
-
}, []);
|
|
1148
|
-
// console.log({ pathParts });
|
|
1149
|
-
// const pathParts = jsonDeepPath.split('.');
|
|
1150
|
-
const keyName = pathParts.pop().replace(/^\["(.+)"\]$/, '$1');
|
|
1151
|
-
let currentPath = '';
|
|
1152
|
-
let attributes = [];
|
|
1153
|
-
let collectedComments = [];
|
|
1154
|
-
for (const line of lines) {
|
|
1155
|
-
const trimmedLine = line.trim();
|
|
1156
|
-
if (trimmedLine.startsWith('//')) {
|
|
1157
|
-
// Collect comments
|
|
1158
|
-
collectedComments.push(trimmedLine);
|
|
1159
|
-
// trimmedLine.startsWith('//pizda') &&
|
|
1160
|
-
// console.log('pushlin line', { trimmedLine });
|
|
1161
|
-
}
|
|
1162
|
-
else if (trimmedLine.startsWith('"') || trimmedLine.startsWith("'")) {
|
|
1163
|
-
// Extract the key from the line
|
|
1164
|
-
const match = trimmedLine.match(/["']([^"']+)["']\s*:/);
|
|
1165
|
-
// console.log({ match0: match && match[0], match1: match && match[1] });
|
|
1166
|
-
if (match) {
|
|
1167
|
-
const key = match[1];
|
|
1168
|
-
currentPath = currentPath
|
|
1169
|
-
? `${currentPath}.${key.includes('.') ? `['${key}']` : key}`
|
|
1170
|
-
: key;
|
|
1171
|
-
// console.log({ key });
|
|
1172
|
-
// Check if the current path matches the jsonDeepPath
|
|
1173
|
-
if ((currentPath.endsWith(keyName) &&
|
|
1174
|
-
!currentPath.endsWith('/' + keyName)) ||
|
|
1175
|
-
currentPath.endsWith(`['${keyName}']`)) {
|
|
1176
|
-
// console.log('extract attributes', {
|
|
1177
|
-
// keyName,
|
|
1178
|
-
// collectedCommentsLength: collectedComments.length,
|
|
1179
|
-
// });
|
|
1180
|
-
// Process the collected comments to extract attributes
|
|
1181
|
-
attributes = extractAttributesFromComments(collectedComments);
|
|
1182
|
-
break;
|
|
1183
|
-
}
|
|
1184
|
-
// Reset collected comments as they only relate to the next key
|
|
1185
|
-
collectedComments = [];
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
return attributes;
|
|
1190
|
-
};
|
|
1191
|
-
const extractAttributesFromComments = (comments) => {
|
|
1192
|
-
const attributes = [];
|
|
1193
|
-
const attrRegex = /@(\w+)(?:\s*=\s*([^\s@]+))?/g;
|
|
1194
|
-
// console.log({ comments });
|
|
1195
|
-
for (const comment of comments) {
|
|
1196
|
-
let match;
|
|
1197
|
-
while ((match = attrRegex.exec(comment)) !== null) {
|
|
1198
|
-
const [, name, value] = match;
|
|
1199
|
-
const existingAttribute = attributes.find(attr => attr.name === `@${name}`);
|
|
1200
|
-
if (existingAttribute) {
|
|
1201
|
-
if (value) {
|
|
1202
|
-
if (Array.isArray(existingAttribute.value)) {
|
|
1203
|
-
existingAttribute.value.push(value);
|
|
1204
|
-
}
|
|
1205
|
-
else {
|
|
1206
|
-
existingAttribute.value = [existingAttribute.value, value];
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
else {
|
|
1211
|
-
attributes.push({
|
|
1212
|
-
name: `@${name}`,
|
|
1213
|
-
value: value ? value : true,
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
// Normalize single values not to be arrays
|
|
1219
|
-
attributes.forEach(attr => {
|
|
1220
|
-
if (Array.isArray(attr.value) && attr.value.length === 1) {
|
|
1221
|
-
attr.value = attr.value[0];
|
|
1222
|
-
}
|
|
1223
|
-
});
|
|
1224
|
-
return attributes;
|
|
1225
|
-
};
|
|
1226
|
-
})(json = Utils.json || (Utils.json = {}));
|
|
1227
1128
|
//#endregion
|
|
1228
1129
|
//#region binary
|
|
1229
1130
|
//#region db binary format type
|
|
@@ -3457,11 +3358,150 @@ var UtilsTerminal;
|
|
|
3457
3358
|
return (void 0);
|
|
3458
3359
|
};
|
|
3459
3360
|
//#endregion
|
|
3361
|
+
//#region draw big text
|
|
3362
|
+
UtilsTerminal.drawBigText = async (text, options) => {
|
|
3363
|
+
/* */
|
|
3364
|
+
/* */
|
|
3365
|
+
/* */
|
|
3366
|
+
/* */
|
|
3367
|
+
/* */
|
|
3368
|
+
/* */
|
|
3369
|
+
/* */
|
|
3370
|
+
/* */
|
|
3371
|
+
/* */
|
|
3372
|
+
/* */
|
|
3373
|
+
/* */
|
|
3374
|
+
/* */
|
|
3375
|
+
/* */
|
|
3376
|
+
/* */
|
|
3377
|
+
/* */
|
|
3378
|
+
/* */
|
|
3379
|
+
/* */
|
|
3380
|
+
/* */
|
|
3381
|
+
/* */
|
|
3382
|
+
return (void 0);
|
|
3383
|
+
};
|
|
3384
|
+
//#endregion
|
|
3460
3385
|
})(UtilsTerminal || (UtilsTerminal = {}));
|
|
3461
3386
|
//#endregion
|
|
3462
3387
|
//#region utils json
|
|
3463
3388
|
var UtilsJson;
|
|
3464
3389
|
(function (UtilsJson) {
|
|
3390
|
+
//#region get attributes from jsonc or json5 file
|
|
3391
|
+
/**
|
|
3392
|
+
* Get attributes from jsonc or json5 file
|
|
3393
|
+
* @param jsonDeepPath lodash path to property in json ex. deep.path.to.prop
|
|
3394
|
+
* @param fileContent jsonc or json5 - json with comments
|
|
3395
|
+
* @returns array of attributes
|
|
3396
|
+
*/
|
|
3397
|
+
UtilsJson.getAtrributiesFromJsonWithComments = (jsonDeepPath, // lodash path to property in json ex. deep.path.to.prop
|
|
3398
|
+
fileContent) => {
|
|
3399
|
+
const lines = fileContent.split('\n');
|
|
3400
|
+
// split path to parts but keep part if is for example 'sql.js
|
|
3401
|
+
const pathParts = jsonDeepPath.split('.').reduce((a, b) => {
|
|
3402
|
+
if (a.length === 0) {
|
|
3403
|
+
return [b];
|
|
3404
|
+
}
|
|
3405
|
+
const last = a[a.length - 1];
|
|
3406
|
+
if ((last.startsWith(`['`) && b.endsWith(`']`)) ||
|
|
3407
|
+
(last.startsWith(`["`) && b.endsWith(`"]`))) {
|
|
3408
|
+
a[a.length - 1] = [last, b].join('.');
|
|
3409
|
+
}
|
|
3410
|
+
else {
|
|
3411
|
+
a.push(b);
|
|
3412
|
+
}
|
|
3413
|
+
return a;
|
|
3414
|
+
}, []);
|
|
3415
|
+
// console.log({ pathParts });
|
|
3416
|
+
// const pathParts = jsonDeepPath.split('.');
|
|
3417
|
+
const keyName = pathParts.pop().replace(/^\["(.+)"\]$/, '$1');
|
|
3418
|
+
let currentPath = '';
|
|
3419
|
+
let attributes = [];
|
|
3420
|
+
let collectedComments = [];
|
|
3421
|
+
for (const line of lines) {
|
|
3422
|
+
const trimmedLine = line.trim();
|
|
3423
|
+
if (trimmedLine.startsWith('//')) {
|
|
3424
|
+
// Collect comments
|
|
3425
|
+
collectedComments.push(trimmedLine);
|
|
3426
|
+
// trimmedLine.startsWith('//pizda') &&
|
|
3427
|
+
// console.log('pushlin line', { trimmedLine });
|
|
3428
|
+
}
|
|
3429
|
+
else if (trimmedLine.startsWith('"') || trimmedLine.startsWith("'")) {
|
|
3430
|
+
// Extract the key from the line
|
|
3431
|
+
const match = trimmedLine.match(/["']([^"']+)["']\s*:/);
|
|
3432
|
+
// console.log({ match0: match && match[0], match1: match && match[1] });
|
|
3433
|
+
if (match) {
|
|
3434
|
+
const key = match[1];
|
|
3435
|
+
currentPath = currentPath
|
|
3436
|
+
? `${currentPath}.${key.includes('.') ? `['${key}']` : key}`
|
|
3437
|
+
: key;
|
|
3438
|
+
// console.log({ key });
|
|
3439
|
+
// Check if the current path matches the jsonDeepPath
|
|
3440
|
+
if ((currentPath.endsWith(keyName) &&
|
|
3441
|
+
!currentPath.endsWith('/' + keyName)) ||
|
|
3442
|
+
currentPath.endsWith(`['${keyName}']`)) {
|
|
3443
|
+
// console.log('extract attributes', {
|
|
3444
|
+
// keyName,
|
|
3445
|
+
// collectedCommentsLength: collectedComments.length,
|
|
3446
|
+
// });
|
|
3447
|
+
// Process the collected comments to extract attributes
|
|
3448
|
+
attributes = extractAttributesFromComments(collectedComments);
|
|
3449
|
+
break;
|
|
3450
|
+
}
|
|
3451
|
+
// Reset collected comments as they only relate to the next key
|
|
3452
|
+
collectedComments = [];
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
return attributes;
|
|
3457
|
+
};
|
|
3458
|
+
//#endregion
|
|
3459
|
+
//#region get attributes from comment
|
|
3460
|
+
UtilsJson.getAttributiesFromComment = (comment, attributes = []) => {
|
|
3461
|
+
// Match @name=value OR @name
|
|
3462
|
+
// Values can be "..." or '...' or unquoted token without @
|
|
3463
|
+
const attrRegex = /@(\w+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s@]+)))?/g;
|
|
3464
|
+
let match;
|
|
3465
|
+
while ((match = attrRegex.exec(comment)) !== null) {
|
|
3466
|
+
const [, name, doubleQuoted, singleQuoted, unquoted] = match;
|
|
3467
|
+
const value = doubleQuoted ?? singleQuoted ?? unquoted;
|
|
3468
|
+
const existingAttribute = attributes.find(attr => attr.name === `@${name}`);
|
|
3469
|
+
if (existingAttribute) {
|
|
3470
|
+
if (value !== undefined) {
|
|
3471
|
+
if (Array.isArray(existingAttribute.value)) {
|
|
3472
|
+
existingAttribute.value.push(value);
|
|
3473
|
+
}
|
|
3474
|
+
else {
|
|
3475
|
+
existingAttribute.value = [existingAttribute.value, value];
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
else {
|
|
3480
|
+
attributes.push({
|
|
3481
|
+
name: `@${name}`,
|
|
3482
|
+
value: value !== undefined ? value : true,
|
|
3483
|
+
});
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
// Normalize single values not to be arrays
|
|
3487
|
+
attributes.forEach(attr => {
|
|
3488
|
+
if (Array.isArray(attr.value) && attr.value.length === 1) {
|
|
3489
|
+
attr.value = attr.value[0];
|
|
3490
|
+
}
|
|
3491
|
+
});
|
|
3492
|
+
return attributes;
|
|
3493
|
+
};
|
|
3494
|
+
//#endregion
|
|
3495
|
+
//#region extract attributes from comments
|
|
3496
|
+
const extractAttributesFromComments = (comments) => {
|
|
3497
|
+
const attributes = [];
|
|
3498
|
+
// console.log({ comments });
|
|
3499
|
+
for (const comment of comments) {
|
|
3500
|
+
UtilsJson.getAttributiesFromComment(comment, attributes);
|
|
3501
|
+
}
|
|
3502
|
+
return attributes;
|
|
3503
|
+
};
|
|
3504
|
+
//#endregion
|
|
3465
3505
|
//#region read json
|
|
3466
3506
|
/**
|
|
3467
3507
|
* read json from absolute path
|
|
@@ -3692,7 +3732,48 @@ var UtilsNetwork;
|
|
|
3692
3732
|
// Utility to escape domain for RegExp
|
|
3693
3733
|
const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
3694
3734
|
//#region utils network / simulate domain in etc hosts
|
|
3695
|
-
UtilsNetwork.simulateDomain = async (
|
|
3735
|
+
UtilsNetwork.simulateDomain = async (domainOrDomains, options) => {
|
|
3736
|
+
/* */
|
|
3737
|
+
/* */
|
|
3738
|
+
/* */
|
|
3739
|
+
/* */
|
|
3740
|
+
/* */
|
|
3741
|
+
/* */
|
|
3742
|
+
/* */
|
|
3743
|
+
/* */
|
|
3744
|
+
/* */
|
|
3745
|
+
/* */
|
|
3746
|
+
/* */
|
|
3747
|
+
/* */
|
|
3748
|
+
/* */
|
|
3749
|
+
/* */
|
|
3750
|
+
/* */
|
|
3751
|
+
/* */
|
|
3752
|
+
/* */
|
|
3753
|
+
/* */
|
|
3754
|
+
/* */
|
|
3755
|
+
/* */
|
|
3756
|
+
/* */
|
|
3757
|
+
/* */
|
|
3758
|
+
/* */
|
|
3759
|
+
/* */
|
|
3760
|
+
/* */
|
|
3761
|
+
/* */
|
|
3762
|
+
/* */
|
|
3763
|
+
/* */
|
|
3764
|
+
/* */
|
|
3765
|
+
/* */
|
|
3766
|
+
/* */
|
|
3767
|
+
/* */
|
|
3768
|
+
/* */
|
|
3769
|
+
/* */
|
|
3770
|
+
/* */
|
|
3771
|
+
/* */
|
|
3772
|
+
/* */
|
|
3773
|
+
/* */
|
|
3774
|
+
/* */
|
|
3775
|
+
/* */
|
|
3776
|
+
/* */
|
|
3696
3777
|
/* */
|
|
3697
3778
|
/* */
|
|
3698
3779
|
/* */
|