mol_crypto_lib 0.0.357 → 0.0.360
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 +118 -14
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +118 -14
- package/web.test.js.map +1 -1
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: "
|
|
637
|
-
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="
|
|
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: "
|
|
643
|
-
$mol_jsx("img", { id: "
|
|
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,
|
|
646
|
+
return $mol_jsx("span", null,
|
|
647
|
+
icon,
|
|
648
|
+
$mol_jsx("i", { id: "label" }));
|
|
647
649
|
};
|
|
648
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
649
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
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: "
|
|
655
|
-
$mol_jsx("span", { id: "
|
|
656
|
+
$mol_jsx("span", { id: "bar" }),
|
|
657
|
+
$mol_jsx("span", { id: "bar" }));
|
|
656
658
|
};
|
|
657
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "
|
|
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.replace(/\/.*/i, '')}`) : $.$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(
|
|
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
|
}
|
|
@@ -717,7 +775,11 @@ var $;
|
|
|
717
775
|
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
718
776
|
if (!Elem)
|
|
719
777
|
return node;
|
|
778
|
+
if (guid)
|
|
779
|
+
node.id = guid;
|
|
720
780
|
for (const key in props) {
|
|
781
|
+
if (key === 'id')
|
|
782
|
+
continue;
|
|
721
783
|
if (typeof props[key] === 'string') {
|
|
722
784
|
;
|
|
723
785
|
node.setAttribute(key, props[key]);
|
|
@@ -734,8 +796,8 @@ var $;
|
|
|
734
796
|
node[key] = props[key];
|
|
735
797
|
}
|
|
736
798
|
}
|
|
737
|
-
if (
|
|
738
|
-
node.
|
|
799
|
+
if ($.$mol_jsx_crumbs)
|
|
800
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
739
801
|
return node;
|
|
740
802
|
}
|
|
741
803
|
$.$mol_jsx = $mol_jsx;
|
|
@@ -1707,6 +1769,48 @@ var $;
|
|
|
1707
1769
|
;
|
|
1708
1770
|
"use strict";
|
|
1709
1771
|
var $;
|
|
1772
|
+
(function ($_1) {
|
|
1773
|
+
$mol_test({
|
|
1774
|
+
'FQN of anon function'($) {
|
|
1775
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1776
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1777
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1778
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1779
|
+
},
|
|
1780
|
+
});
|
|
1781
|
+
})($ || ($ = {}));
|
|
1782
|
+
//mol/func/name/name.test.ts
|
|
1783
|
+
;
|
|
1784
|
+
"use strict";
|
|
1785
|
+
var $;
|
|
1786
|
+
(function ($) {
|
|
1787
|
+
function $mol_func_name(func) {
|
|
1788
|
+
let name = func.name;
|
|
1789
|
+
if (name?.length > 1)
|
|
1790
|
+
return name;
|
|
1791
|
+
for (let key in this) {
|
|
1792
|
+
try {
|
|
1793
|
+
if (this[key] !== func)
|
|
1794
|
+
continue;
|
|
1795
|
+
name = key;
|
|
1796
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
1797
|
+
break;
|
|
1798
|
+
}
|
|
1799
|
+
catch { }
|
|
1800
|
+
}
|
|
1801
|
+
return name;
|
|
1802
|
+
}
|
|
1803
|
+
$.$mol_func_name = $mol_func_name;
|
|
1804
|
+
function $mol_func_name_from(target, source) {
|
|
1805
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
1806
|
+
return target;
|
|
1807
|
+
}
|
|
1808
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
1809
|
+
})($ || ($ = {}));
|
|
1810
|
+
//mol/func/name/name.ts
|
|
1811
|
+
;
|
|
1812
|
+
"use strict";
|
|
1813
|
+
var $;
|
|
1710
1814
|
(function ($) {
|
|
1711
1815
|
$mol_test({
|
|
1712
1816
|
async 'sizes'() {
|