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/web.mjs CHANGED
@@ -375,6 +375,17 @@ var $;
375
375
  $.$mol_dev_format_register = $mol_dev_format_register;
376
376
  $.$mol_dev_format_head = Symbol('$mol_dev_format_head');
377
377
  $.$mol_dev_format_body = Symbol('$mol_dev_format_body');
378
+ function $mol_dev_format_button(label, click) {
379
+ return $mol_dev_format_auto({
380
+ [$.$mol_dev_format_head]() {
381
+ return $mol_dev_format_span({ color: 'cornflowerblue' }, label);
382
+ },
383
+ [$.$mol_dev_format_body]() {
384
+ Promise.resolve().then(click);
385
+ return $mol_dev_format_span({});
386
+ }
387
+ });
388
+ }
378
389
  $mol_dev_format_register({
379
390
  header: (val, config = false) => {
380
391
  if (config)
@@ -392,13 +403,41 @@ var $;
392
403
  if (typeof val === 'function') {
393
404
  return $mol_dev_format_native(val);
394
405
  }
406
+ if (Error.isError(val)) {
407
+ return $mol_dev_format_span({}, $mol_dev_format_native(val), ' ', $mol_dev_format_button('throw', () => $mol_fail_hidden(val)));
408
+ }
409
+ if (val instanceof Promise) {
410
+ return $.$mol_dev_format_shade($mol_dev_format_native(val), ' ', val[Symbol.toStringTag] ?? '');
411
+ }
395
412
  if (Symbol.toStringTag in val) {
396
413
  return $mol_dev_format_native(val);
397
414
  }
398
415
  return null;
399
416
  },
400
- hasBody: val => val[$.$mol_dev_format_body],
401
- body: val => val[$.$mol_dev_format_body](),
417
+ hasBody: (val, config = false) => {
418
+ if (config)
419
+ return false;
420
+ if (!val)
421
+ return false;
422
+ if (val[$.$mol_dev_format_body])
423
+ return true;
424
+ return false;
425
+ },
426
+ body: (val, config = false) => {
427
+ if (config)
428
+ return null;
429
+ if (!val)
430
+ return null;
431
+ if ($.$mol_dev_format_body in val) {
432
+ try {
433
+ return val[$.$mol_dev_format_body]();
434
+ }
435
+ catch (error) {
436
+ return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
437
+ }
438
+ }
439
+ return null;
440
+ },
402
441
  });
403
442
  function $mol_dev_format_native(obj) {
404
443
  if (typeof obj === 'undefined')
@@ -464,6 +503,69 @@ var $;
464
503
  $.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
465
504
  'margin-left': '13px'
466
505
  });
506
+ class Stack extends Array {
507
+ toString() {
508
+ return this.join('\n');
509
+ }
510
+ }
511
+ class Call extends Object {
512
+ type;
513
+ function;
514
+ method;
515
+ eval;
516
+ source;
517
+ offset;
518
+ pos;
519
+ object;
520
+ flags;
521
+ [Symbol.toStringTag];
522
+ constructor(call) {
523
+ super();
524
+ this.type = call.getTypeName() ?? '';
525
+ this.function = call.getFunctionName() ?? '';
526
+ this.method = call.getMethodName() ?? '';
527
+ if (this.method === this.function)
528
+ this.method = '';
529
+ this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
530
+ this.eval = call.getEvalOrigin() ?? '';
531
+ this.source = call.getScriptNameOrSourceURL() ?? '';
532
+ this.object = call.getThis();
533
+ this.offset = call.getPosition();
534
+ const flags = [];
535
+ if (call.isAsync())
536
+ flags.push('async');
537
+ if (call.isConstructor())
538
+ flags.push('constructor');
539
+ if (call.isEval())
540
+ flags.push('eval');
541
+ if (call.isNative())
542
+ flags.push('native');
543
+ if (call.isPromiseAll())
544
+ flags.push('PromiseAll');
545
+ if (call.isToplevel())
546
+ flags.push('top');
547
+ this.flags = flags;
548
+ const type = this.type ? this.type + '.' : '';
549
+ const func = this.function || '<anon>';
550
+ const method = this.method ? ' [' + this.method + '] ' : '';
551
+ this[Symbol.toStringTag] = `${type}${func}${method}`;
552
+ }
553
+ [Symbol.toPrimitive]() {
554
+ return this.toString();
555
+ }
556
+ toString() {
557
+ const object = this.object || '';
558
+ const label = this[Symbol.toStringTag];
559
+ const source = `${this.source}:${this.pos.join(':')} #${this.offset}`;
560
+ return `\tat ${object}${label} (${source})`;
561
+ }
562
+ [$.$mol_dev_format_head]() {
563
+ return $.$mol_dev_format_div({}, $mol_dev_format_native(this), $.$mol_dev_format_shade(' '), ...this.object ? [
564
+ $mol_dev_format_native(this.object),
565
+ ] : [], ...this.method ? [$.$mol_dev_format_shade(' ', ' [', this.method, ']')] : [], $.$mol_dev_format_shade(' ', this.flags.join(', ')));
566
+ }
567
+ }
568
+ Error.prepareStackTrace ??= (error, stack) => new Stack(...stack.map(call => new Call(call)));
467
569
  })($ || ($ = {}));
468
570
 
469
571
  ;
@@ -1017,7 +1119,7 @@ var $;
1017
1119
  if (left instanceof RegExp)
1018
1120
  return left.source === right.source && left.flags === right.flags;
1019
1121
  if (left instanceof Error)
1020
- return left.message === right.message && left.stack === right.stack;
1122
+ return left.message === right.message && $mol_compare_deep(left.stack, right.stack);
1021
1123
  let left_cache = $.$mol_compare_deep_cache.get(left);
1022
1124
  if (left_cache) {
1023
1125
  const right_cache = left_cache.get(right);
@@ -1303,6 +1405,33 @@ var $;
1303
1405
  $.$mol_fail_catch = $mol_fail_catch;
1304
1406
  })($ || ($ = {}));
1305
1407
 
1408
+ ;
1409
+ "use strict";
1410
+ var $;
1411
+ (function ($) {
1412
+ let error;
1413
+ let result;
1414
+ let handler;
1415
+ function $mol_try(handler2) {
1416
+ handler = handler2;
1417
+ error = undefined;
1418
+ result = undefined;
1419
+ window.dispatchEvent(new Event('$mol_try'));
1420
+ const error2 = error;
1421
+ const result2 = result;
1422
+ error = undefined;
1423
+ result = undefined;
1424
+ return error2 || result2;
1425
+ }
1426
+ $.$mol_try = $mol_try;
1427
+ self.addEventListener('$mol_try', (event) => {
1428
+ result = handler();
1429
+ }, true);
1430
+ self.addEventListener('error', (event) => {
1431
+ error = event.error;
1432
+ }, true);
1433
+ })($ || ($ = {}));
1434
+
1306
1435
  ;
1307
1436
  "use strict";
1308
1437
  var $;
@@ -1312,7 +1441,7 @@ var $;
1312
1441
  return false;
1313
1442
  if (!$mol_fail_catch(error))
1314
1443
  return false;
1315
- console.error(error);
1444
+ $mol_try(() => { $mol_fail_hidden(error); });
1316
1445
  return true;
1317
1446
  }
1318
1447
  $.$mol_fail_log = $mol_fail_log;
package/web.test.js CHANGED
@@ -783,7 +783,7 @@ var $;
783
783
  catch (error) {
784
784
  $.$mol_fail = fail;
785
785
  if (typeof ErrorRight === 'string') {
786
- $mol_assert_equal(error.message, ErrorRight);
786
+ $mol_assert_equal(error.message ?? error, ErrorRight);
787
787
  }
788
788
  else {
789
789
  $mol_assert_equal(error instanceof ErrorRight, true);
@@ -807,7 +807,7 @@ var $;
807
807
  continue;
808
808
  if (!$mol_compare_deep(args[i], args[j]))
809
809
  continue;
810
- $mol_fail(new Error(`args[${i}] = args[${j}] = ${print(args[i])}`));
810
+ return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
811
811
  }
812
812
  }
813
813
  }
@@ -818,29 +818,10 @@ var $;
818
818
  continue;
819
819
  if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
820
820
  continue;
821
- return $mol_fail(new Error(`args[0] ≠ args[${i}]\n${print(args[0])}\n---\n${print(args[i])}`));
821
+ return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
822
822
  }
823
823
  }
824
824
  $.$mol_assert_equal = $mol_assert_equal;
825
- const print = (val) => {
826
- if (!val)
827
- return val;
828
- if (typeof val === 'bigint')
829
- return String(val) + 'n';
830
- if (typeof val === 'symbol')
831
- return `Symbol(${val.description})`;
832
- if (typeof val !== 'object')
833
- return val;
834
- if ('outerHTML' in val)
835
- return val.outerHTML;
836
- try {
837
- return JSON.stringify(val, (k, v) => typeof v === 'bigint' ? String(v) : v, '\t');
838
- }
839
- catch (error) {
840
- console.error(error);
841
- return val;
842
- }
843
- };
844
825
  })($ || ($ = {}));
845
826
 
846
827
  ;
@@ -2145,6 +2126,17 @@ var $;
2145
2126
  ;
2146
2127
  "use strict";
2147
2128
 
2129
+ ;
2130
+ "use strict";
2131
+ var $;
2132
+ (function ($) {
2133
+ $mol_test({
2134
+ 'return result without errors'() {
2135
+ $mol_assert_equal($mol_try(() => false), false);
2136
+ },
2137
+ });
2138
+ })($ || ($ = {}));
2139
+
2148
2140
  ;
2149
2141
  "use strict";
2150
2142
  var $;