mol_crypto_lib 0.0.358 → 0.0.359

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.test.js CHANGED
@@ -633,28 +633,52 @@ var $;
633
633
  const Button = (props, target) => {
634
634
  return $mol_jsx("button", { title: props.hint }, target());
635
635
  };
636
- const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
637
- $mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
636
+ const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
637
+ $mol_assert_equal(dom.outerHTML, '<button title="click me" id="foo" class="Button">hey!</button>');
638
638
  },
639
639
  'Nested guid generation'() {
640
640
  const Foo = () => {
641
641
  return $mol_jsx("div", null,
642
- $mol_jsx(Bar, { id: "/bar" },
643
- $mol_jsx("img", { id: "/icon" })));
642
+ $mol_jsx(Bar, { id: "bar" },
643
+ $mol_jsx("img", { id: "icon" })));
644
644
  };
645
645
  const Bar = (props, icon) => {
646
- return $mol_jsx("span", null, icon);
646
+ return $mol_jsx("span", null,
647
+ icon,
648
+ $mol_jsx("i", { id: "label" }));
647
649
  };
648
- const dom = $mol_jsx(Foo, { id: "/foo" });
649
- $mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
650
+ const dom = $mol_jsx(Foo, { id: "foo" });
651
+ $mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
650
652
  },
651
653
  'Fail on non unique ids'() {
652
654
  const App = () => {
653
655
  return $mol_jsx("div", null,
654
- $mol_jsx("span", { id: "/bar" }),
655
- $mol_jsx("span", { id: "/bar" }));
656
+ $mol_jsx("span", { id: "bar" }),
657
+ $mol_jsx("span", { id: "bar" }));
656
658
  };
657
- $mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
659
+ $mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
660
+ },
661
+ 'Owner based guid generationn'() {
662
+ const Foo = () => {
663
+ return $mol_jsx("div", null,
664
+ $mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
665
+ };
666
+ const Bar = (props) => {
667
+ return $mol_jsx("span", null, props.icon());
668
+ };
669
+ const dom = $mol_jsx(Foo, { id: "app" });
670
+ $mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
671
+ },
672
+ 'Fail on same ids from different caller'() {
673
+ const Foo = () => {
674
+ return $mol_jsx("div", null,
675
+ $mol_jsx("img", { id: "icon" }),
676
+ $mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
677
+ };
678
+ const Bar = (props) => {
679
+ return $mol_jsx("span", null, props.icon());
680
+ };
681
+ $mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
658
682
  },
659
683
  });
660
684
  })($ || ($ = {}));
@@ -664,6 +688,7 @@ var $;
664
688
  var $;
665
689
  (function ($) {
666
690
  $.$mol_jsx_prefix = '';
691
+ $.$mol_jsx_crumbs = '';
667
692
  $.$mol_jsx_booked = null;
668
693
  $.$mol_jsx_document = {
669
694
  getElementById: () => null,
@@ -673,16 +698,45 @@ var $;
673
698
  $.$mol_jsx_frag = '';
674
699
  function $mol_jsx(Elem, props, ...childNodes) {
675
700
  const id = props && props.id || '';
701
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
702
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id}`) : $.$mol_jsx_crumbs;
676
703
  if (Elem && $.$mol_jsx_booked) {
677
704
  if ($.$mol_jsx_booked.has(id)) {
678
- $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
705
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
679
706
  }
680
707
  else {
681
708
  $.$mol_jsx_booked.add(id);
682
709
  }
683
710
  }
684
- const guid = $.$mol_jsx_prefix + id;
685
711
  let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
712
+ if ($.$mol_jsx_prefix) {
713
+ const prefix_ext = $.$mol_jsx_prefix;
714
+ const booked_ext = $.$mol_jsx_booked;
715
+ const crumbs_ext = $.$mol_jsx_crumbs;
716
+ for (const field in props) {
717
+ const func = props[field];
718
+ if (typeof func !== 'function')
719
+ continue;
720
+ const wrapper = function (...args) {
721
+ const prefix = $.$mol_jsx_prefix;
722
+ const booked = $.$mol_jsx_booked;
723
+ const crumbs = $.$mol_jsx_crumbs;
724
+ try {
725
+ $.$mol_jsx_prefix = prefix_ext;
726
+ $.$mol_jsx_booked = booked_ext;
727
+ $.$mol_jsx_crumbs = crumbs_ext;
728
+ return func.call(this, ...args);
729
+ }
730
+ finally {
731
+ $.$mol_jsx_prefix = prefix;
732
+ $.$mol_jsx_booked = booked;
733
+ $.$mol_jsx_crumbs = crumbs;
734
+ }
735
+ };
736
+ $mol_func_name_from(wrapper, func);
737
+ props[field] = wrapper;
738
+ }
739
+ }
686
740
  if (typeof Elem !== 'string') {
687
741
  if ('prototype' in Elem) {
688
742
  const view = node && node[Elem] || new Elem;
@@ -691,6 +745,7 @@ var $;
691
745
  view.childNodes = childNodes;
692
746
  if (!view.ownerDocument)
693
747
  view.ownerDocument = $.$mol_jsx_document;
748
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
694
749
  node = view.valueOf();
695
750
  node[Elem] = view;
696
751
  return node;
@@ -698,14 +753,17 @@ var $;
698
753
  else {
699
754
  const prefix = $.$mol_jsx_prefix;
700
755
  const booked = $.$mol_jsx_booked;
756
+ const crumbs = $.$mol_jsx_crumbs;
701
757
  try {
702
758
  $.$mol_jsx_prefix = guid;
703
759
  $.$mol_jsx_booked = new Set;
760
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
704
761
  return Elem(props, ...childNodes);
705
762
  }
706
763
  finally {
707
764
  $.$mol_jsx_prefix = prefix;
708
765
  $.$mol_jsx_booked = booked;
766
+ $.$mol_jsx_crumbs = crumbs;
709
767
  }
710
768
  }
711
769
  }
@@ -736,6 +794,8 @@ var $;
736
794
  }
737
795
  if (guid)
738
796
  node.id = guid;
797
+ if ($.$mol_jsx_crumbs)
798
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
739
799
  return node;
740
800
  }
741
801
  $.$mol_jsx = $mol_jsx;
@@ -1707,6 +1767,48 @@ var $;
1707
1767
  ;
1708
1768
  "use strict";
1709
1769
  var $;
1770
+ (function ($_1) {
1771
+ $mol_test({
1772
+ 'FQN of anon function'($) {
1773
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
1774
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
1775
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
1776
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
1777
+ },
1778
+ });
1779
+ })($ || ($ = {}));
1780
+ //mol/func/name/name.test.ts
1781
+ ;
1782
+ "use strict";
1783
+ var $;
1784
+ (function ($) {
1785
+ function $mol_func_name(func) {
1786
+ let name = func.name;
1787
+ if (name?.length > 1)
1788
+ return name;
1789
+ for (let key in this) {
1790
+ try {
1791
+ if (this[key] !== func)
1792
+ continue;
1793
+ name = key;
1794
+ Object.defineProperty(func, 'name', { value: name });
1795
+ break;
1796
+ }
1797
+ catch { }
1798
+ }
1799
+ return name;
1800
+ }
1801
+ $.$mol_func_name = $mol_func_name;
1802
+ function $mol_func_name_from(target, source) {
1803
+ Object.defineProperty(target, 'name', { value: source.name });
1804
+ return target;
1805
+ }
1806
+ $.$mol_func_name_from = $mol_func_name_from;
1807
+ })($ || ($ = {}));
1808
+ //mol/func/name/name.ts
1809
+ ;
1810
+ "use strict";
1811
+ var $;
1710
1812
  (function ($) {
1711
1813
  $mol_test({
1712
1814
  async 'sizes'() {