mol_plot_all 1.2.1476 → 1.2.1478

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/node.js CHANGED
@@ -390,6 +390,17 @@ var $;
390
390
  $.$mol_dev_format_register = $mol_dev_format_register;
391
391
  $.$mol_dev_format_head = Symbol('$mol_dev_format_head');
392
392
  $.$mol_dev_format_body = Symbol('$mol_dev_format_body');
393
+ function $mol_dev_format_button(label, click) {
394
+ return $mol_dev_format_auto({
395
+ [$.$mol_dev_format_head]() {
396
+ return $mol_dev_format_span({ color: 'cornflowerblue' }, label);
397
+ },
398
+ [$.$mol_dev_format_body]() {
399
+ Promise.resolve().then(click);
400
+ return $mol_dev_format_span({});
401
+ }
402
+ });
403
+ }
393
404
  $mol_dev_format_register({
394
405
  header: (val, config = false) => {
395
406
  if (config)
@@ -407,13 +418,41 @@ var $;
407
418
  if (typeof val === 'function') {
408
419
  return $mol_dev_format_native(val);
409
420
  }
421
+ if (Error.isError(val)) {
422
+ return $mol_dev_format_span({}, $mol_dev_format_native(val), ' ', $mol_dev_format_button('throw', () => $mol_fail_hidden(val)));
423
+ }
424
+ if (val instanceof Promise) {
425
+ return $.$mol_dev_format_shade($mol_dev_format_native(val), ' ', val[Symbol.toStringTag] ?? '');
426
+ }
410
427
  if (Symbol.toStringTag in val) {
411
428
  return $mol_dev_format_native(val);
412
429
  }
413
430
  return null;
414
431
  },
415
- hasBody: val => val[$.$mol_dev_format_body],
416
- body: val => val[$.$mol_dev_format_body](),
432
+ hasBody: (val, config = false) => {
433
+ if (config)
434
+ return false;
435
+ if (!val)
436
+ return false;
437
+ if (val[$.$mol_dev_format_body])
438
+ return true;
439
+ return false;
440
+ },
441
+ body: (val, config = false) => {
442
+ if (config)
443
+ return null;
444
+ if (!val)
445
+ return null;
446
+ if ($.$mol_dev_format_body in val) {
447
+ try {
448
+ return val[$.$mol_dev_format_body]();
449
+ }
450
+ catch (error) {
451
+ return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
452
+ }
453
+ }
454
+ return null;
455
+ },
417
456
  });
418
457
  function $mol_dev_format_native(obj) {
419
458
  if (typeof obj === 'undefined')
@@ -479,6 +518,69 @@ var $;
479
518
  $.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
480
519
  'margin-left': '13px'
481
520
  });
521
+ class Stack extends Array {
522
+ toString() {
523
+ return this.join('\n');
524
+ }
525
+ }
526
+ class Call extends Object {
527
+ type;
528
+ function;
529
+ method;
530
+ eval;
531
+ source;
532
+ offset;
533
+ pos;
534
+ object;
535
+ flags;
536
+ [Symbol.toStringTag];
537
+ constructor(call) {
538
+ super();
539
+ this.type = call.getTypeName() ?? '';
540
+ this.function = call.getFunctionName() ?? '';
541
+ this.method = call.getMethodName() ?? '';
542
+ if (this.method === this.function)
543
+ this.method = '';
544
+ this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
545
+ this.eval = call.getEvalOrigin() ?? '';
546
+ this.source = call.getScriptNameOrSourceURL() ?? '';
547
+ this.object = call.getThis();
548
+ this.offset = call.getPosition();
549
+ const flags = [];
550
+ if (call.isAsync())
551
+ flags.push('async');
552
+ if (call.isConstructor())
553
+ flags.push('constructor');
554
+ if (call.isEval())
555
+ flags.push('eval');
556
+ if (call.isNative())
557
+ flags.push('native');
558
+ if (call.isPromiseAll())
559
+ flags.push('PromiseAll');
560
+ if (call.isToplevel())
561
+ flags.push('top');
562
+ this.flags = flags;
563
+ const type = this.type ? this.type + '.' : '';
564
+ const func = this.function || '<anon>';
565
+ const method = this.method ? ' [' + this.method + '] ' : '';
566
+ this[Symbol.toStringTag] = `${type}${func}${method}`;
567
+ }
568
+ [Symbol.toPrimitive]() {
569
+ return this.toString();
570
+ }
571
+ toString() {
572
+ const object = this.object || '';
573
+ const label = this[Symbol.toStringTag];
574
+ const source = `${this.source}:${this.pos.join(':')} #${this.offset}`;
575
+ return `\tat ${object}${label} (${source})`;
576
+ }
577
+ [$.$mol_dev_format_head]() {
578
+ return $.$mol_dev_format_div({}, $mol_dev_format_native(this), $.$mol_dev_format_shade(' '), ...this.object ? [
579
+ $mol_dev_format_native(this.object),
580
+ ] : [], ...this.method ? [$.$mol_dev_format_shade(' ', ' [', this.method, ']')] : [], $.$mol_dev_format_shade(' ', this.flags.join(', ')));
581
+ }
582
+ }
583
+ Error.prepareStackTrace ??= (error, stack) => new Stack(...stack.map(call => new Call(call)));
482
584
  })($ || ($ = {}));
483
585
 
484
586
  ;
@@ -1026,7 +1128,7 @@ var $;
1026
1128
  if (left instanceof RegExp)
1027
1129
  return left.source === right.source && left.flags === right.flags;
1028
1130
  if (left instanceof Error)
1029
- return left.message === right.message && left.stack === right.stack;
1131
+ return left.message === right.message && $mol_compare_deep(left.stack, right.stack);
1030
1132
  let left_cache = $.$mol_compare_deep_cache.get(left);
1031
1133
  if (left_cache) {
1032
1134
  const right_cache = left_cache.get(right);
@@ -1788,6 +1890,21 @@ var $;
1788
1890
  $.$mol_fail_catch = $mol_fail_catch;
1789
1891
  })($ || ($ = {}));
1790
1892
 
1893
+ ;
1894
+ "use strict";
1895
+ var $;
1896
+ (function ($) {
1897
+ function $mol_try(handler) {
1898
+ try {
1899
+ return handler();
1900
+ }
1901
+ catch (error) {
1902
+ return error;
1903
+ }
1904
+ }
1905
+ $.$mol_try = $mol_try;
1906
+ })($ || ($ = {}));
1907
+
1791
1908
  ;
1792
1909
  "use strict";
1793
1910
  var $;
@@ -1797,7 +1914,7 @@ var $;
1797
1914
  return false;
1798
1915
  if (!$mol_fail_catch(error))
1799
1916
  return false;
1800
- console.error(error);
1917
+ $mol_try(() => { $mol_fail_hidden(error); });
1801
1918
  return true;
1802
1919
  }
1803
1920
  $.$mol_fail_log = $mol_fail_log;
@@ -2101,7 +2218,7 @@ var $;
2101
2218
  get: () => stack_get() + '\n' + [
2102
2219
  this.cause ?? 'no cause',
2103
2220
  ...this.errors.flatMap(e => [
2104
- e.stack,
2221
+ String(e.stack),
2105
2222
  ...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
2106
2223
  ])
2107
2224
  ].map(frame_normalize).join('\n')