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",
@@ -652,6 +711,9 @@ class HelpersIsomorphic {
652
711
  /* */
653
712
  /* */
654
713
  /* */
714
+ /* \/\/ import \{ config \} from 'tnp\-config'; */
715
+ /* \/\/ import \{ PROGRESS_DATA \} from 'tnp\-models'; */
716
+ /* \/\/ TODO handle global\.testMode \? */
655
717
  const KEY = {
656
718
  LAST_ERROR: Symbol(),
657
719
  LAST_INFO: Symbol(),
@@ -702,6 +764,34 @@ const KEY_IMPORTANTCE = {
702
764
  /* */
703
765
  /* */
704
766
  const LIMIT = 10;
767
+ /* \/\/ export class Log \{ */
768
+ /* \/\/ private static _instance: Log; */
769
+ /* \/\/ public Instance\(\) \{ */
770
+ /* \/\/ if \(!Log\._instance\) \{ */
771
+ /* \/\/ Log\._instance = new Log\(\); */
772
+ /* \/\/ \} */
773
+ /* \/\/ return Log\._instance; */
774
+ /* \/\/ \} */
775
+ /* \/\/ create\(name: string, level\?: Level\) \{ */
776
+ /* \/\/ if \(level === void 0\) \{ */
777
+ /* \/\/ level = Level\.DATA; */
778
+ /* \/\/ \} */
779
+ /* \/\/ return \{ */
780
+ /* \/\/ d\(details: string, debugLevel\?: number\) \{ */
781
+ /* \/\/ return Helpers\.log\(`\[\$\{name\}\] \$\{details\}`, debugLevel\) */
782
+ /* \/\/ \}, */
783
+ /* \/\/ i\(details: string\) \{ */
784
+ /* \/\/ return Helpers\.info\(`\[\$\{name\}\] \$\{details\}`\) */
785
+ /* \/\/ \}, */
786
+ /* \/\/ w\(details: string, noExit = false, noTrace = false\) \{ */
787
+ /* \/\/ return Helpers\.error\(`\[\$\{name\}\] \$\{details\}`, noExit, noTrace\); */
788
+ /* \/\/ \}, */
789
+ /* \/\/ er\(details: string, \) \{ */
790
+ /* \/\/ return Helpers\.info\(`\[\$\{name\}\] \$\{details\}`\) */
791
+ /* \/\/ \}, */
792
+ /* \/\/ \} */
793
+ /* \/\/ \} */
794
+ /* \/\/ \} */
705
795
  class HelpersMessages extends HelpersIsomorphic {
706
796
  msgCacheClear() {
707
797
  /* */
@@ -715,6 +805,7 @@ class HelpersMessages extends HelpersIsomorphic {
715
805
  /* */
716
806
  /* */
717
807
  /* */
808
+ /* \/\/ TODO for FE */
718
809
  console.error(err);
719
810
  }
720
811
  error(details, noExit = false, noTrace = false) {
@@ -1218,6 +1309,7 @@ class HelpersCore extends HelpersMessages {
1218
1309
  * @returns
1219
1310
  */
1220
1311
  isBlob(maybeBlob) {
1312
+ /* \/\/ TODO is this needed hmmmm */
1221
1313
  return maybeBlob instanceof Blob; // || toString.call(maybeBlob) === '[object Blob]';
1222
1314
  }
1223
1315
  /**
@@ -1242,6 +1334,13 @@ class HelpersCore extends HelpersMessages {
1242
1334
  * stringify to pretty json string
1243
1335
  */
1244
1336
  stringify(inputObject) {
1337
+ /* \/\/ if \(_\.isString\(inputObject\)\) \{ */
1338
+ /* \/\/ return inputObject; */
1339
+ /* \/\/ \} */
1340
+ /* \/\/ if \(_\.isObject\(inputObject\)\) \{ */
1341
+ /* \/\/ config\.log\(inputObject\) */
1342
+ /* \/\/ Helpers\.error\(`\[tnp\-helpers\] trying to stringify not a object`, false, true\); */
1343
+ /* \/\/ \} */
1245
1344
  return JSON.stringify(inputObject, null, 2);
1246
1345
  }
1247
1346
  async runSyncOrAsync(fnOrOptions, ...firstArg) {
@@ -1261,9 +1360,12 @@ class HelpersCore extends HelpersMessages {
1261
1360
  // @ts-ignore
1262
1361
  promisOrValue = _.isArray(fnOrOptions) ? fnOrOptions[1][fnOrOptions[0]](...firstArg) : fnOrOptions(...firstArg);
1263
1362
  }
1363
+ /* \/\/ let wasPromise = false; */
1264
1364
  if (promisOrValue instanceof Promise) {
1365
+ /* \/\/ wasPromise = true; */
1265
1366
  promisOrValue = Promise.resolve(promisOrValue);
1266
1367
  }
1368
+ /* \/\/ console\.log\('was promis ', wasPromise\) */
1267
1369
  return promisOrValue;
1268
1370
  }
1269
1371
  /* */
@@ -1589,7 +1691,9 @@ class HelpersCore extends HelpersMessages {
1589
1691
  /* */
1590
1692
  /* */
1591
1693
  /* */
1592
- exists(folderOrFilePath) {
1694
+ exists(folderOrFilePath
1695
+ /* \/\/ , allowUnexistedLinks = false */
1696
+ ) {
1593
1697
  /* */
1594
1698
  /* */
1595
1699
  /* */
@@ -1626,6 +1730,7 @@ class HelpersCore extends HelpersMessages {
1626
1730
  return command;
1627
1731
  }
1628
1732
  command(command) {
1733
+ /* \/\/ console\.log\(\{ command \}\) */
1629
1734
  command = Helpers._fixCommand(command);
1630
1735
  return {
1631
1736
  /* */
@@ -1792,6 +1897,7 @@ class HelpersCore extends HelpersMessages {
1792
1897
  }
1793
1898
  run(command, options) {
1794
1899
  command = Helpers._fixCommand(command);
1900
+ /* \/\/ console\.log\(\{ command \}\) */
1795
1901
  /* */
1796
1902
  /* */
1797
1903
  /* */
@@ -2428,6 +2534,7 @@ class PROGRESS_DATA {
2428
2534
  if (checkSplit) {
2429
2535
  const split = chunk.split(/\r\n|\n|\r/);
2430
2536
  if (split.length > 1) {
2537
+ /* \/\/ console\.log\('split founded', split\) */
2431
2538
  split.forEach(s => {
2432
2539
  res = res.concat(this.resolveFrom(s, callbackOnFounded, false));
2433
2540
  });
@@ -2529,6 +2636,7 @@ var Utils;
2529
2636
  if (!m) {
2530
2637
  throw new Error(`[firedev-framework][base64toBlob] Not a base64 blob [${base64Data}]`);
2531
2638
  }
2639
+ /* \/\/ tslint:disable\-next\-line:prefer\-const */
2532
2640
  var [__, contenttype, filebase64] = m;
2533
2641
  content_type = contenttype;
2534
2642
  file_base64 = filebase64;
@@ -2544,6 +2652,7 @@ var Utils;
2544
2652
  const begin = sliceIndex * sliceSize;
2545
2653
  const end = Math.min(begin + sliceSize, bytesLength);
2546
2654
  const bytes = new Array(end - begin);
2655
+ /* \/\/ tslint:disable\-next\-line:one\-variable\-per\-declaration */
2547
2656
  for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
2548
2657
  bytes[i] = byteCharacters[offset].charCodeAt(0);
2549
2658
  }
@@ -2679,10 +2788,16 @@ var Utils;
2679
2788
  }
2680
2789
  binary.blobToText = blobToText;
2681
2790
  async function textToFile(text, fileRelativePathOrName) {
2791
+ /* \/\/ console\.log\(\{ path \}\) */
2682
2792
  const ext = path.extname(fileRelativePathOrName);
2683
2793
  const type = mimeTypes[ext];
2684
2794
  const blob = new Blob([text], { type });
2685
2795
  const file = await blobToFile(blob, fileRelativePathOrName);
2796
+ /* \/\/ console\.log\(\{ */
2797
+ /* \/\/ ext, */
2798
+ /* \/\/ blob, file */
2799
+ /* \/\/ \}\); */
2800
+ /* \/\/ debugger */
2686
2801
  return file;
2687
2802
  }
2688
2803
  binary.textToFile = textToFile;
@@ -2720,8 +2835,12 @@ var Utils;
2720
2835
  * @returns
2721
2836
  */
2722
2837
  function numValue(pixelsCss) {
2838
+ /* \/\/ tslint:disable\-next\-line:radix */
2723
2839
  return parseInt(pixelsCss
2724
- .replace('px', ''));
2840
+ .replace('px', '')
2841
+ /* \/\/ \.replace\('pt', ''\) TOOD handle other types */
2842
+ /* \/\/ \.replace\('1rem', ''\) \/\/ to */
2843
+ );
2725
2844
  }
2726
2845
  css.numValue = numValue;
2727
2846
  })(css = Utils.css || (Utils.css = {}));