tnp-core 16.5.1 → 16.5.7

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 (35) hide show
  1. package/assets/shared/shared_folder_info.txt +1 -1
  2. package/browser/esm2022/lib/core-models.mjs +2 -1
  3. package/browser/esm2022/lib/helpers-messages.mjs +33 -1
  4. package/browser/esm2022/lib/helpers.mjs +17 -2
  5. package/browser/esm2022/lib/node-chalk-mock.mjs +3 -1
  6. package/browser/esm2022/lib/node-path-mock.mjs +57 -1
  7. package/browser/esm2022/lib/progress-data.mjs +2 -1
  8. package/browser/esm2022/lib/utils.mjs +14 -2
  9. package/browser/fesm2022/tnp-core.mjs +121 -2
  10. package/browser/fesm2022/tnp-core.mjs.map +1 -1
  11. package/cli.backend.js +3 -3
  12. package/client/esm2022/lib/core-models.mjs +2 -1
  13. package/client/esm2022/lib/helpers-messages.mjs +33 -1
  14. package/client/esm2022/lib/helpers.mjs +17 -2
  15. package/client/esm2022/lib/node-chalk-mock.mjs +3 -1
  16. package/client/esm2022/lib/node-path-mock.mjs +57 -1
  17. package/client/esm2022/lib/progress-data.mjs +2 -1
  18. package/client/esm2022/lib/utils.mjs +14 -2
  19. package/client/fesm2022/tnp-core.mjs +121 -2
  20. package/client/fesm2022/tnp-core.mjs.map +1 -1
  21. package/client/package.json +32 -32
  22. package/lib/node-chalk-mock.js +3 -3
  23. package/lib/node-path-mock.js +3 -3
  24. package/package.json +2 -2
  25. package/src.d.ts +6 -0
  26. package/tmp-environment.json +36 -37
  27. package/websql/esm2022/lib/core-models.mjs +2 -1
  28. package/websql/esm2022/lib/helpers-messages.mjs +33 -1
  29. package/websql/esm2022/lib/helpers.mjs +17 -2
  30. package/websql/esm2022/lib/node-chalk-mock.mjs +3 -1
  31. package/websql/esm2022/lib/node-path-mock.mjs +57 -1
  32. package/websql/esm2022/lib/progress-data.mjs +2 -1
  33. package/websql/esm2022/lib/utils.mjs +14 -2
  34. package/websql/fesm2022/tnp-core.mjs +121 -2
  35. package/websql/fesm2022/tnp-core.mjs.map +1 -1
@@ -26,6 +26,7 @@ function assertPath(path) {
26
26
  throw new TypeError('[firedev-core] Path must be a string. Received ' + JSON.stringify(path));
27
27
  }
28
28
  }
29
+ /* \/\/ Resolves \. and \.\. elements in a path with directory names */
29
30
  function normalizeStringPosix(path, allowAboveRoot) {
30
31
  var res = '';
31
32
  var lastSegmentLength = 0;
@@ -41,6 +42,7 @@ function normalizeStringPosix(path, allowAboveRoot) {
41
42
  code = 47 /*/*/;
42
43
  if (code === 47 /*/*/) {
43
44
  if (lastSlash === i - 1 || dots === 1) {
45
+ /* \/\/ NOOP */
44
46
  }
45
47
  else if (lastSlash !== i - 1 && dots === 2) {
46
48
  if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
@@ -107,6 +109,7 @@ function _format(sep, pathObject) {
107
109
  return dir + sep + base;
108
110
  }
109
111
  const path$1 = {
112
+ /* \/\/ path\.resolve\(\[from \.\.\.\], to\) */
110
113
  resolve: function resolve(pathToResovle) {
111
114
  return pathToResovle;
112
115
  },
@@ -116,6 +119,7 @@ const path$1 = {
116
119
  return '.';
117
120
  var isAbsolute = pathArg.charCodeAt(0) === 47 /*/*/;
118
121
  var trailingSeparator = pathArg.charCodeAt(pathArg.length - 1) === 47 /*/*/;
122
+ /* \/\/ Normalize the path */
119
123
  pathArg = normalizeStringPosix(pathArg, !isAbsolute);
120
124
  if (pathArg.length === 0 && !isAbsolute)
121
125
  pathArg = '.';
@@ -156,6 +160,7 @@ const path$1 = {
156
160
  to = path$1.resolve(to);
157
161
  if (from === to)
158
162
  return '';
163
+ /* \/\/ Trim any leading backslashes */
159
164
  var fromStart = 1;
160
165
  for (; fromStart < from.length; ++fromStart) {
161
166
  if (from.charCodeAt(fromStart) !== 47 /*/*/)
@@ -163,6 +168,7 @@ const path$1 = {
163
168
  }
164
169
  var fromEnd = from.length;
165
170
  var fromLen = fromEnd - fromStart;
171
+ /* \/\/ Trim any leading backslashes */
166
172
  var toStart = 1;
167
173
  for (; toStart < to.length; ++toStart) {
168
174
  if (to.charCodeAt(toStart) !== 47 /*/*/)
@@ -170,6 +176,7 @@ const path$1 = {
170
176
  }
171
177
  var toEnd = to.length;
172
178
  var toLen = toEnd - toStart;
179
+ /* \/\/ Compare paths to find the longest common path from root */
173
180
  var length = fromLen < toLen ? fromLen : toLen;
174
181
  var lastCommonSep = -1;
175
182
  var i = 0;
@@ -177,17 +184,25 @@ const path$1 = {
177
184
  if (i === length) {
178
185
  if (toLen > length) {
179
186
  if (to.charCodeAt(toStart + i) === 47 /*/*/) {
187
+ /* \/\/ We get here if `from` is the exact base path for `to`\. */
188
+ /* \/\/ For example: from='\/foo\/bar'; to='\/foo\/bar\/baz' */
180
189
  return to.slice(toStart + i + 1);
181
190
  }
182
191
  else if (i === 0) {
192
+ /* \/\/ We get here if `from` is the root */
193
+ /* \/\/ For example: from='\/'; to='\/foo' */
183
194
  return to.slice(toStart + i);
184
195
  }
185
196
  }
186
197
  else if (fromLen > length) {
187
198
  if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
199
+ /* \/\/ We get here if `to` is the exact base path for `from`\. */
200
+ /* \/\/ For example: from='\/foo\/bar\/baz'; to='\/foo\/bar' */
188
201
  lastCommonSep = i;
189
202
  }
190
203
  else if (i === 0) {
204
+ /* \/\/ We get here if `to` is the root\. */
205
+ /* \/\/ For example: from='\/foo'; to='\/' */
191
206
  lastCommonSep = 0;
192
207
  }
193
208
  }
@@ -201,6 +216,8 @@ const path$1 = {
201
216
  lastCommonSep = i;
202
217
  }
203
218
  var out = '';
219
+ /* \/\/ Generate the relative path based on the path difference between `to` */
220
+ /* \/\/ and `from` */
204
221
  for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
205
222
  if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
206
223
  if (out.length === 0)
@@ -209,6 +226,8 @@ const path$1 = {
209
226
  out += '/..';
210
227
  }
211
228
  }
229
+ /* \/\/ Lastly, append the rest of the destination \(`to`\) path that comes after */
230
+ /* \/\/ the common path parts */
212
231
  if (out.length > 0)
213
232
  return out + to.slice(toStart + lastCommonSep);
214
233
  else {
@@ -238,6 +257,7 @@ const path$1 = {
238
257
  }
239
258
  }
240
259
  else {
260
+ /* \/\/ We saw the first non\-path separator */
241
261
  matchedSlash = false;
242
262
  }
243
263
  }
@@ -263,6 +283,8 @@ const path$1 = {
263
283
  for (i = pathArg.length - 1; i >= 0; --i) {
264
284
  var code = pathArg.charCodeAt(i);
265
285
  if (code === 47 /*/*/) {
286
+ /* \/\/ If we reached a path separator that was not part of a set of path */
287
+ /* \/\/ separators at the end of the string, stop now */
266
288
  if (!matchedSlash) {
267
289
  start = i + 1;
268
290
  break;
@@ -270,16 +292,23 @@ const path$1 = {
270
292
  }
271
293
  else {
272
294
  if (firstNonSlashEnd === -1) {
295
+ /* \/\/ We saw the first non\-path separator, remember this index in case */
296
+ /* \/\/ we need it if the extension ends up not matching */
273
297
  matchedSlash = false;
274
298
  firstNonSlashEnd = i + 1;
275
299
  }
276
300
  if (extIdx >= 0) {
301
+ /* \/\/ Try to match the explicit extension */
277
302
  if (code === ext.charCodeAt(extIdx)) {
278
303
  if (--extIdx === -1) {
304
+ /* \/\/ We matched the extension, so mark this as the end of our path */
305
+ /* \/\/ component */
279
306
  end = i;
280
307
  }
281
308
  }
282
309
  else {
310
+ /* \/\/ Extension does not match, so our result is the entire path */
311
+ /* \/\/ component */
283
312
  extIdx = -1;
284
313
  end = firstNonSlashEnd;
285
314
  }
@@ -295,12 +324,16 @@ const path$1 = {
295
324
  else {
296
325
  for (i = pathArg.length - 1; i >= 0; --i) {
297
326
  if (pathArg.charCodeAt(i) === 47 /*/*/) {
327
+ /* \/\/ If we reached a path separator that was not part of a set of path */
328
+ /* \/\/ separators at the end of the string, stop now */
298
329
  if (!matchedSlash) {
299
330
  start = i + 1;
300
331
  break;
301
332
  }
302
333
  }
303
334
  else if (end === -1) {
335
+ /* \/\/ We saw the first non\-path separator, mark this as the end of our */
336
+ /* \/\/ path component */
304
337
  matchedSlash = false;
305
338
  end = i + 1;
306
339
  }
@@ -316,10 +349,14 @@ const path$1 = {
316
349
  var startPart = 0;
317
350
  var end = -1;
318
351
  var matchedSlash = true;
352
+ /* \/\/ Track the state of characters \(if any\) we see before our first dot and */
353
+ /* \/\/ after any path separator we find */
319
354
  var preDotState = 0;
320
355
  for (var i = pathArg.length - 1; i >= 0; --i) {
321
356
  var code = pathArg.charCodeAt(i);
322
357
  if (code === 47 /*/*/) {
358
+ /* \/\/ If we reached a path separator that was not part of a set of path */
359
+ /* \/\/ separators at the end of the string, stop now */
323
360
  if (!matchedSlash) {
324
361
  startPart = i + 1;
325
362
  break;
@@ -327,21 +364,28 @@ const path$1 = {
327
364
  continue;
328
365
  }
329
366
  if (end === -1) {
367
+ /* \/\/ We saw the first non\-path separator, mark this as the end of our */
368
+ /* \/\/ extension */
330
369
  matchedSlash = false;
331
370
  end = i + 1;
332
371
  }
333
372
  if (code === 46 /*.*/) {
373
+ /* \/\/ If this is our first dot, mark it as the start of our extension */
334
374
  if (startDot === -1)
335
375
  startDot = i;
336
376
  else if (preDotState !== 1)
337
377
  preDotState = 1;
338
378
  }
339
379
  else if (startDot !== -1) {
380
+ /* \/\/ We saw a non\-dot and non\-path separator before our dot, so we should */
381
+ /* \/\/ have a good chance at having a non\-empty extension */
340
382
  preDotState = -1;
341
383
  }
342
384
  }
343
385
  if (startDot === -1 || end === -1 ||
386
+ /* \/\/ We saw a non\-dot character immediately before the dot */
344
387
  preDotState === 0 ||
388
+ /* \/\/ The \(right\-most\) trimmed path component is exactly '\.\.' */
345
389
  preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
346
390
  return '';
347
391
  }
@@ -373,10 +417,15 @@ const path$1 = {
373
417
  var end = -1;
374
418
  var matchedSlash = true;
375
419
  var i = pathArg.length - 1;
420
+ /* \/\/ Track the state of characters \(if any\) we see before our first dot and */
421
+ /* \/\/ after any path separator we find */
376
422
  var preDotState = 0;
423
+ /* \/\/ Get non\-dir info */
377
424
  for (; i >= start; --i) {
378
425
  code = pathArg.charCodeAt(i);
379
426
  if (code === 47 /*/*/) {
427
+ /* \/\/ If we reached a path separator that was not part of a set of path */
428
+ /* \/\/ separators at the end of the string, stop now */
380
429
  if (!matchedSlash) {
381
430
  startPart = i + 1;
382
431
  break;
@@ -384,21 +433,28 @@ const path$1 = {
384
433
  continue;
385
434
  }
386
435
  if (end === -1) {
436
+ /* \/\/ We saw the first non\-path separator, mark this as the end of our */
437
+ /* \/\/ extension */
387
438
  matchedSlash = false;
388
439
  end = i + 1;
389
440
  }
390
441
  if (code === 46 /*.*/) {
442
+ /* \/\/ If this is our first dot, mark it as the start of our extension */
391
443
  if (startDot === -1)
392
444
  startDot = i;
393
445
  else if (preDotState !== 1)
394
446
  preDotState = 1;
395
447
  }
396
448
  else if (startDot !== -1) {
449
+ /* \/\/ We saw a non\-dot and non\-path separator before our dot, so we should */
450
+ /* \/\/ have a good chance at having a non\-empty extension */
397
451
  preDotState = -1;
398
452
  }
399
453
  }
400
454
  if (startDot === -1 || end === -1 ||
455
+ /* \/\/ We saw a non\-dot character immediately before the dot */
401
456
  preDotState === 0 ||
457
+ /* \/\/ The \(right\-most\) trimmed path component is exactly '\.\.' */
402
458
  preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
403
459
  if (end !== -1) {
404
460
  if (startPart === 0 && isAbsolute)
@@ -436,6 +492,8 @@ const path$1 = {
436
492
  ;
437
493
  ({}); // @--end-of-file-for-module=tnp-core lib/node-path-mock.ts
438
494
 
495
+ /* \/\/ TODO finish this MOCK @LAST */
496
+ /* \/\/ const c:Chalk = void 0; */
439
497
  const allObj = {
440
498
  black(a) {
441
499
  console.log(a);
@@ -521,6 +579,7 @@ const crossPlatformPath = (pathStringOrPathParts) => {
521
579
  };
522
580
  ({}); // @--end-of-file-for-module=tnp-core lib/core-imports.ts
523
581
 
582
+ /* \/\/ https:\/\/developer\.mozilla\.org\/en\-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/MIME_types\/Common_types */
524
583
  const mimeTypes = {
525
584
  ".aac": "audio/aac",
526
585
  ".abw": "application/x-abiword",
@@ -653,6 +712,9 @@ class HelpersIsomorphic {
653
712
  /* */
654
713
  /* */
655
714
  /* */
715
+ /* \/\/ import \{ config \} from 'tnp\-config'; */
716
+ /* \/\/ import \{ PROGRESS_DATA \} from 'tnp\-models'; */
717
+ /* \/\/ TODO handle global\.testMode \? */
656
718
  const KEY = {
657
719
  LAST_ERROR: Symbol(),
658
720
  LAST_INFO: Symbol(),
@@ -703,6 +765,34 @@ const KEY_IMPORTANTCE = {
703
765
  /* */
704
766
  /* */
705
767
  const LIMIT = 10;
768
+ /* \/\/ export class Log \{ */
769
+ /* \/\/ private static _instance: Log; */
770
+ /* \/\/ public Instance\(\) \{ */
771
+ /* \/\/ if \(!Log\._instance\) \{ */
772
+ /* \/\/ Log\._instance = new Log\(\); */
773
+ /* \/\/ \} */
774
+ /* \/\/ return Log\._instance; */
775
+ /* \/\/ \} */
776
+ /* \/\/ create\(name: string, level\?: Level\) \{ */
777
+ /* \/\/ if \(level === void 0\) \{ */
778
+ /* \/\/ level = Level\.DATA; */
779
+ /* \/\/ \} */
780
+ /* \/\/ return \{ */
781
+ /* \/\/ d\(details: string, debugLevel\?: number\) \{ */
782
+ /* \/\/ return Helpers\.log\(`\[\$\{name\}\] \$\{details\}`, debugLevel\) */
783
+ /* \/\/ \}, */
784
+ /* \/\/ i\(details: string\) \{ */
785
+ /* \/\/ return Helpers\.info\(`\[\$\{name\}\] \$\{details\}`\) */
786
+ /* \/\/ \}, */
787
+ /* \/\/ w\(details: string, noExit = false, noTrace = false\) \{ */
788
+ /* \/\/ return Helpers\.error\(`\[\$\{name\}\] \$\{details\}`, noExit, noTrace\); */
789
+ /* \/\/ \}, */
790
+ /* \/\/ er\(details: string, \) \{ */
791
+ /* \/\/ return Helpers\.info\(`\[\$\{name\}\] \$\{details\}`\) */
792
+ /* \/\/ \}, */
793
+ /* \/\/ \} */
794
+ /* \/\/ \} */
795
+ /* \/\/ \} */
706
796
  class HelpersMessages extends HelpersIsomorphic {
707
797
  msgCacheClear() {
708
798
  /* */
@@ -716,6 +806,7 @@ class HelpersMessages extends HelpersIsomorphic {
716
806
  /* */
717
807
  /* */
718
808
  /* */
809
+ /* \/\/ TODO for FE */
719
810
  console.error(err);
720
811
  }
721
812
  error(details, noExit = false, noTrace = false) {
@@ -1219,6 +1310,7 @@ class HelpersCore extends HelpersMessages {
1219
1310
  * @returns
1220
1311
  */
1221
1312
  isBlob(maybeBlob) {
1313
+ /* \/\/ TODO is this needed hmmmm */
1222
1314
  return maybeBlob instanceof Blob; // || toString.call(maybeBlob) === '[object Blob]';
1223
1315
  }
1224
1316
  /**
@@ -1243,6 +1335,13 @@ class HelpersCore extends HelpersMessages {
1243
1335
  * stringify to pretty json string
1244
1336
  */
1245
1337
  stringify(inputObject) {
1338
+ /* \/\/ if \(_\.isString\(inputObject\)\) \{ */
1339
+ /* \/\/ return inputObject; */
1340
+ /* \/\/ \} */
1341
+ /* \/\/ if \(_\.isObject\(inputObject\)\) \{ */
1342
+ /* \/\/ config\.log\(inputObject\) */
1343
+ /* \/\/ Helpers\.error\(`\[tnp\-helpers\] trying to stringify not a object`, false, true\); */
1344
+ /* \/\/ \} */
1246
1345
  return JSON.stringify(inputObject, null, 2);
1247
1346
  }
1248
1347
  async runSyncOrAsync(fnOrOptions, ...firstArg) {
@@ -1262,9 +1361,12 @@ class HelpersCore extends HelpersMessages {
1262
1361
  // @ts-ignore
1263
1362
  promisOrValue = _.isArray(fnOrOptions) ? fnOrOptions[1][fnOrOptions[0]](...firstArg) : fnOrOptions(...firstArg);
1264
1363
  }
1364
+ /* \/\/ let wasPromise = false; */
1265
1365
  if (promisOrValue instanceof Promise) {
1366
+ /* \/\/ wasPromise = true; */
1266
1367
  promisOrValue = Promise.resolve(promisOrValue);
1267
1368
  }
1369
+ /* \/\/ console\.log\('was promis ', wasPromise\) */
1268
1370
  return promisOrValue;
1269
1371
  }
1270
1372
  /* */
@@ -1590,7 +1692,9 @@ class HelpersCore extends HelpersMessages {
1590
1692
  /* */
1591
1693
  /* */
1592
1694
  /* */
1593
- exists(folderOrFilePath) {
1695
+ exists(folderOrFilePath
1696
+ /* \/\/ , allowUnexistedLinks = false */
1697
+ ) {
1594
1698
  /* */
1595
1699
  /* */
1596
1700
  /* */
@@ -1627,6 +1731,7 @@ class HelpersCore extends HelpersMessages {
1627
1731
  return command;
1628
1732
  }
1629
1733
  command(command) {
1734
+ /* \/\/ console\.log\(\{ command \}\) */
1630
1735
  command = Helpers._fixCommand(command);
1631
1736
  return {
1632
1737
  /* */
@@ -1795,6 +1900,7 @@ class HelpersCore extends HelpersMessages {
1795
1900
  }
1796
1901
  run(command, options) {
1797
1902
  command = Helpers._fixCommand(command);
1903
+ /* \/\/ console\.log\(\{ command \}\) */
1798
1904
  /* */
1799
1905
  /* */
1800
1906
  /* */
@@ -2431,6 +2537,7 @@ class PROGRESS_DATA {
2431
2537
  if (checkSplit) {
2432
2538
  const split = chunk.split(/\r\n|\n|\r/);
2433
2539
  if (split.length > 1) {
2540
+ /* \/\/ console\.log\('split founded', split\) */
2434
2541
  split.forEach(s => {
2435
2542
  res = res.concat(this.resolveFrom(s, callbackOnFounded, false));
2436
2543
  });
@@ -2532,6 +2639,7 @@ var Utils;
2532
2639
  if (!m) {
2533
2640
  throw new Error(`[firedev-framework][base64toBlob] Not a base64 blob [${base64Data}]`);
2534
2641
  }
2642
+ /* \/\/ tslint:disable\-next\-line:prefer\-const */
2535
2643
  var [__, contenttype, filebase64] = m;
2536
2644
  content_type = contenttype;
2537
2645
  file_base64 = filebase64;
@@ -2547,6 +2655,7 @@ var Utils;
2547
2655
  const begin = sliceIndex * sliceSize;
2548
2656
  const end = Math.min(begin + sliceSize, bytesLength);
2549
2657
  const bytes = new Array(end - begin);
2658
+ /* \/\/ tslint:disable\-next\-line:one\-variable\-per\-declaration */
2550
2659
  for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
2551
2660
  bytes[i] = byteCharacters[offset].charCodeAt(0);
2552
2661
  }
@@ -2682,10 +2791,16 @@ var Utils;
2682
2791
  }
2683
2792
  binary.blobToText = blobToText;
2684
2793
  async function textToFile(text, fileRelativePathOrName) {
2794
+ /* \/\/ console\.log\(\{ path \}\) */
2685
2795
  const ext = path.extname(fileRelativePathOrName);
2686
2796
  const type = mimeTypes[ext];
2687
2797
  const blob = new Blob([text], { type });
2688
2798
  const file = await blobToFile(blob, fileRelativePathOrName);
2799
+ /* \/\/ console\.log\(\{ */
2800
+ /* \/\/ ext, */
2801
+ /* \/\/ blob, file */
2802
+ /* \/\/ \}\); */
2803
+ /* \/\/ debugger */
2689
2804
  return file;
2690
2805
  }
2691
2806
  binary.textToFile = textToFile;
@@ -2723,8 +2838,12 @@ var Utils;
2723
2838
  * @returns
2724
2839
  */
2725
2840
  function numValue(pixelsCss) {
2841
+ /* \/\/ tslint:disable\-next\-line:radix */
2726
2842
  return parseInt(pixelsCss
2727
- .replace('px', ''));
2843
+ .replace('px', '')
2844
+ /* \/\/ \.replace\('pt', ''\) TOOD handle other types */
2845
+ /* \/\/ \.replace\('1rem', ''\) \/\/ to */
2846
+ );
2728
2847
  }
2729
2848
  css.numValue = numValue;
2730
2849
  })(css = Utils.css || (Utils.css = {}));