mol_key 0.0.51 → 0.0.54
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.deps.json +1 -1
- package/node.test.js +251 -251
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.test.js +134 -134
- package/web.test.js.map +1 -1
package/node.deps.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"files":["LICENSE","README.md","lang.lang.tree","mam.jam.js","mam.ts","package.json","sandbox.config.json","tsconfig.json","tsfmt.json","yarn.lock","mol/CNAME","mol/CODE_OF_CONDUCT.md","mol/CONTRIBUTING.md","mol/LICENSE","mol/index.html","mol/mol.meta.tree","mol/readme.md","mol/guid/guid.ts","mol/key/README.md","mol/key/key.ts"],"mods":{},"deps_in":{"mol":{"mol/key":-9007199254740991,"mol/guid":-9007199254740991},"":{"mol":-9007199254740991},"mol/guid":{"mol/key":-3}},"deps_out":{"mol/key":{"mol":-9007199254740991,"mol/guid":-3},"mol":{"":-9007199254740991},"mol/guid":{"mol":-9007199254740991}},"sloc":{"LICENSE":113,"md":
|
|
1
|
+
{"files":["LICENSE","README.md","lang.lang.tree","mam.jam.js","mam.ts","package.json","sandbox.config.json","tsconfig.json","tsfmt.json","yarn.lock","mol/CNAME","mol/CODE_OF_CONDUCT.md","mol/CONTRIBUTING.md","mol/LICENSE","mol/index.html","mol/mol.meta.tree","mol/readme.md","mol/guid/guid.ts","mol/key/README.md","mol/key/key.ts"],"mods":{},"deps_in":{"mol":{"mol/key":-9007199254740991,"mol/guid":-9007199254740991},"":{"mol":-9007199254740991},"mol/guid":{"mol/key":-3}},"deps_out":{"mol/key":{"mol":-9007199254740991,"mol/guid":-3},"mol":{"":-9007199254740991},"mol/guid":{"mol":-9007199254740991}},"sloc":{"LICENSE":113,"md":514,"tree":31,"js":10,"ts":46,"json":87,"lock":939,"CNAME":1,"html":1},"deps":{"mol/key":{"..":-9007199254740991,"/mol/key/store":-1,"/mol/key":-1,"/mol/key/store/get":-3,"/mol/guid":-3,"/mol/key/store/set":-3},"mol":{"..":-9007199254740991},"":{},"mol/guid":{"..":-9007199254740991,"/mol/guid":-1}}}
|
package/node.test.js
CHANGED
|
@@ -451,213 +451,16 @@ var $;
|
|
|
451
451
|
//mol/type/assert/assert.ts
|
|
452
452
|
;
|
|
453
453
|
"use strict";
|
|
454
|
-
//mol/type/
|
|
455
|
-
;
|
|
456
|
-
"use strict";
|
|
457
|
-
//mol/type/partial/deep/deep.ts
|
|
454
|
+
//mol/type/equals/equals.test.ts
|
|
458
455
|
;
|
|
459
456
|
"use strict";
|
|
460
|
-
|
|
461
|
-
(function ($) {
|
|
462
|
-
$mol_test({
|
|
463
|
-
'Make empty div'() {
|
|
464
|
-
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
465
|
-
},
|
|
466
|
-
'Define native field'() {
|
|
467
|
-
const dom = $mol_jsx("input", { value: '123' });
|
|
468
|
-
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
469
|
-
$mol_assert_equal(dom.value, '123');
|
|
470
|
-
},
|
|
471
|
-
'Define classes'() {
|
|
472
|
-
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
473
|
-
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
474
|
-
},
|
|
475
|
-
'Define styles'() {
|
|
476
|
-
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
477
|
-
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
478
|
-
},
|
|
479
|
-
'Define dataset'() {
|
|
480
|
-
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
481
|
-
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
482
|
-
},
|
|
483
|
-
'Define attributes'() {
|
|
484
|
-
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
485
|
-
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
486
|
-
},
|
|
487
|
-
'Define child nodes'() {
|
|
488
|
-
const dom = $mol_jsx("div", null,
|
|
489
|
-
"hello",
|
|
490
|
-
$mol_jsx("strong", null, "world"),
|
|
491
|
-
"!");
|
|
492
|
-
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
493
|
-
},
|
|
494
|
-
'Function as component'() {
|
|
495
|
-
const Button = ({ hint }, target) => {
|
|
496
|
-
return $mol_jsx("button", { title: hint }, target());
|
|
497
|
-
};
|
|
498
|
-
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
499
|
-
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
500
|
-
},
|
|
501
|
-
'Nested guid generation'() {
|
|
502
|
-
const Foo = () => {
|
|
503
|
-
return $mol_jsx("div", null,
|
|
504
|
-
$mol_jsx(Bar, { id: "/bar" },
|
|
505
|
-
$mol_jsx("img", { id: "/icon" })));
|
|
506
|
-
};
|
|
507
|
-
const Bar = (props, icon) => {
|
|
508
|
-
return $mol_jsx("span", null, icon);
|
|
509
|
-
};
|
|
510
|
-
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
511
|
-
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
512
|
-
},
|
|
513
|
-
'Fail on non unique ids'() {
|
|
514
|
-
const App = () => {
|
|
515
|
-
return $mol_jsx("div", null,
|
|
516
|
-
$mol_jsx("span", { id: "/bar" }),
|
|
517
|
-
$mol_jsx("span", { id: "/bar" }));
|
|
518
|
-
};
|
|
519
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
520
|
-
},
|
|
521
|
-
});
|
|
522
|
-
})($ || ($ = {}));
|
|
523
|
-
//mol/jsx/jsx.test.tsx
|
|
457
|
+
//mol/type/equals/equals.ts
|
|
524
458
|
;
|
|
525
459
|
"use strict";
|
|
526
|
-
|
|
527
|
-
(function ($) {
|
|
528
|
-
$.$mol_jsx_prefix = '';
|
|
529
|
-
$.$mol_jsx_booked = null;
|
|
530
|
-
$.$mol_jsx_document = {
|
|
531
|
-
getElementById: () => null,
|
|
532
|
-
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
533
|
-
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
534
|
-
};
|
|
535
|
-
$.$mol_jsx_frag = '';
|
|
536
|
-
function $mol_jsx(Elem, props, ...childNodes) {
|
|
537
|
-
const id = props && props.id || '';
|
|
538
|
-
if (Elem && $.$mol_jsx_booked) {
|
|
539
|
-
if ($.$mol_jsx_booked.has(id)) {
|
|
540
|
-
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
541
|
-
}
|
|
542
|
-
else {
|
|
543
|
-
$.$mol_jsx_booked.add(id);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
const guid = $.$mol_jsx_prefix + id;
|
|
547
|
-
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
548
|
-
if (typeof Elem !== 'string') {
|
|
549
|
-
if ('prototype' in Elem) {
|
|
550
|
-
const view = node && node[Elem] || new Elem;
|
|
551
|
-
Object.assign(view, props);
|
|
552
|
-
view[Symbol.toStringTag] = guid;
|
|
553
|
-
view.childNodes = childNodes;
|
|
554
|
-
if (!view.ownerDocument)
|
|
555
|
-
view.ownerDocument = $.$mol_jsx_document;
|
|
556
|
-
node = view.valueOf();
|
|
557
|
-
node[Elem] = view;
|
|
558
|
-
return node;
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
|
-
const prefix = $.$mol_jsx_prefix;
|
|
562
|
-
const booked = $.$mol_jsx_booked;
|
|
563
|
-
try {
|
|
564
|
-
$.$mol_jsx_prefix = guid;
|
|
565
|
-
$.$mol_jsx_booked = new Set;
|
|
566
|
-
return Elem(props, ...childNodes);
|
|
567
|
-
}
|
|
568
|
-
finally {
|
|
569
|
-
$.$mol_jsx_prefix = prefix;
|
|
570
|
-
$.$mol_jsx_booked = booked;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
if (!node) {
|
|
575
|
-
node = Elem
|
|
576
|
-
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
577
|
-
: $.$mol_jsx_document.createDocumentFragment();
|
|
578
|
-
}
|
|
579
|
-
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
580
|
-
if (!Elem)
|
|
581
|
-
return node;
|
|
582
|
-
for (const key in props) {
|
|
583
|
-
if (typeof props[key] === 'string') {
|
|
584
|
-
;
|
|
585
|
-
node.setAttribute(key, props[key]);
|
|
586
|
-
}
|
|
587
|
-
else if (props[key] &&
|
|
588
|
-
typeof props[key] === 'object' &&
|
|
589
|
-
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
590
|
-
if (typeof node[key] === 'object') {
|
|
591
|
-
Object.assign(node[key], props[key]);
|
|
592
|
-
continue;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
else {
|
|
596
|
-
node[key] = props[key];
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
if (guid)
|
|
600
|
-
node.id = guid;
|
|
601
|
-
return node;
|
|
602
|
-
}
|
|
603
|
-
$.$mol_jsx = $mol_jsx;
|
|
604
|
-
})($ || ($ = {}));
|
|
605
|
-
//mol/jsx/jsx.ts
|
|
460
|
+
//mol/type/partial/deep/deep.test.ts
|
|
606
461
|
;
|
|
607
462
|
"use strict";
|
|
608
|
-
|
|
609
|
-
(function ($) {
|
|
610
|
-
$mol_test({
|
|
611
|
-
'Primitives'() {
|
|
612
|
-
$mol_assert_equal($mol_key(null), 'null');
|
|
613
|
-
$mol_assert_equal($mol_key(false), 'false');
|
|
614
|
-
$mol_assert_equal($mol_key(true), 'true');
|
|
615
|
-
$mol_assert_equal($mol_key(0), '0');
|
|
616
|
-
$mol_assert_equal($mol_key(''), '""');
|
|
617
|
-
},
|
|
618
|
-
'Array & POJO'() {
|
|
619
|
-
$mol_assert_equal($mol_key([null]), '[null]');
|
|
620
|
-
$mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
|
|
621
|
-
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
622
|
-
},
|
|
623
|
-
'Function'() {
|
|
624
|
-
const func = () => { };
|
|
625
|
-
$mol_assert_equal($mol_key(func), $mol_key(func));
|
|
626
|
-
$mol_assert_unique($mol_key(func), $mol_key(() => { }));
|
|
627
|
-
},
|
|
628
|
-
'Objects'() {
|
|
629
|
-
class User {
|
|
630
|
-
}
|
|
631
|
-
const jin = new User();
|
|
632
|
-
$mol_assert_equal($mol_key(jin), $mol_key(jin));
|
|
633
|
-
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
634
|
-
},
|
|
635
|
-
'Elements'() {
|
|
636
|
-
const foo = $mol_jsx("div", null, "bar");
|
|
637
|
-
$mol_assert_equal($mol_key(foo), $mol_key(foo));
|
|
638
|
-
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
639
|
-
},
|
|
640
|
-
'Custom JSON representation'() {
|
|
641
|
-
class User {
|
|
642
|
-
name;
|
|
643
|
-
age;
|
|
644
|
-
constructor(name, age) {
|
|
645
|
-
this.name = name;
|
|
646
|
-
this.age = age;
|
|
647
|
-
}
|
|
648
|
-
toJSON() { return { name: this.name }; }
|
|
649
|
-
}
|
|
650
|
-
$mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
651
|
-
},
|
|
652
|
-
'Special native classes'() {
|
|
653
|
-
$mol_assert_equal($mol_key(new Date('xyz')), 'null');
|
|
654
|
-
$mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
655
|
-
$mol_assert_equal($mol_key(/./), '"/./"');
|
|
656
|
-
$mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
657
|
-
},
|
|
658
|
-
});
|
|
659
|
-
})($ || ($ = {}));
|
|
660
|
-
//mol/key/key.test.tsx
|
|
463
|
+
//mol/type/partial/deep/deep.ts
|
|
661
464
|
;
|
|
662
465
|
"use strict";
|
|
663
466
|
var $;
|
|
@@ -727,52 +530,6 @@ var $;
|
|
|
727
530
|
;
|
|
728
531
|
"use strict";
|
|
729
532
|
var $;
|
|
730
|
-
(function ($) {
|
|
731
|
-
function $mol_env() {
|
|
732
|
-
return {};
|
|
733
|
-
}
|
|
734
|
-
$.$mol_env = $mol_env;
|
|
735
|
-
})($ || ($ = {}));
|
|
736
|
-
//mol/env/env.ts
|
|
737
|
-
;
|
|
738
|
-
"use strict";
|
|
739
|
-
var $;
|
|
740
|
-
(function ($) {
|
|
741
|
-
$.$mol_env = function $mol_env() {
|
|
742
|
-
return this.process.env;
|
|
743
|
-
};
|
|
744
|
-
})($ || ($ = {}));
|
|
745
|
-
//mol/env/env.node.ts
|
|
746
|
-
;
|
|
747
|
-
"use strict";
|
|
748
|
-
var $;
|
|
749
|
-
(function ($) {
|
|
750
|
-
function $mol_exec(dir, command, ...args) {
|
|
751
|
-
let [app, ...args0] = command.split(' ');
|
|
752
|
-
args = [...args0, ...args];
|
|
753
|
-
this.$mol_log3_come({
|
|
754
|
-
place: '$mol_exec',
|
|
755
|
-
dir: $node.path.relative('', dir),
|
|
756
|
-
message: 'Run',
|
|
757
|
-
command: `${app} ${args.join(' ')}`,
|
|
758
|
-
});
|
|
759
|
-
var res = $node['child_process'].spawnSync(app, args, {
|
|
760
|
-
cwd: $node.path.resolve(dir),
|
|
761
|
-
shell: true,
|
|
762
|
-
env: this.$mol_env(),
|
|
763
|
-
});
|
|
764
|
-
if (res.status || res.error)
|
|
765
|
-
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
766
|
-
if (!res.stdout)
|
|
767
|
-
res.stdout = Buffer.from([]);
|
|
768
|
-
return res;
|
|
769
|
-
}
|
|
770
|
-
$.$mol_exec = $mol_exec;
|
|
771
|
-
})($ || ($ = {}));
|
|
772
|
-
//mol/exec/exec.node.ts
|
|
773
|
-
;
|
|
774
|
-
"use strict";
|
|
775
|
-
var $;
|
|
776
533
|
(function ($) {
|
|
777
534
|
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
778
535
|
function $mol_ambient(overrides) {
|
|
@@ -1406,6 +1163,200 @@ var $;
|
|
|
1406
1163
|
;
|
|
1407
1164
|
"use strict";
|
|
1408
1165
|
var $;
|
|
1166
|
+
(function ($) {
|
|
1167
|
+
function $mol_env() {
|
|
1168
|
+
return {};
|
|
1169
|
+
}
|
|
1170
|
+
$.$mol_env = $mol_env;
|
|
1171
|
+
})($ || ($ = {}));
|
|
1172
|
+
//mol/env/env.ts
|
|
1173
|
+
;
|
|
1174
|
+
"use strict";
|
|
1175
|
+
var $;
|
|
1176
|
+
(function ($) {
|
|
1177
|
+
$.$mol_env = function $mol_env() {
|
|
1178
|
+
return this.process.env;
|
|
1179
|
+
};
|
|
1180
|
+
})($ || ($ = {}));
|
|
1181
|
+
//mol/env/env.node.ts
|
|
1182
|
+
;
|
|
1183
|
+
"use strict";
|
|
1184
|
+
var $;
|
|
1185
|
+
(function ($) {
|
|
1186
|
+
function $mol_exec(dir, command, ...args) {
|
|
1187
|
+
let [app, ...args0] = command.split(' ');
|
|
1188
|
+
args = [...args0, ...args];
|
|
1189
|
+
this.$mol_log3_come({
|
|
1190
|
+
place: '$mol_exec',
|
|
1191
|
+
dir: $node.path.relative('', dir),
|
|
1192
|
+
message: 'Run',
|
|
1193
|
+
command: `${app} ${args.join(' ')}`,
|
|
1194
|
+
});
|
|
1195
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
|
1196
|
+
cwd: $node.path.resolve(dir),
|
|
1197
|
+
shell: true,
|
|
1198
|
+
env: this.$mol_env(),
|
|
1199
|
+
});
|
|
1200
|
+
if (res.status || res.error)
|
|
1201
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
1202
|
+
if (!res.stdout)
|
|
1203
|
+
res.stdout = Buffer.from([]);
|
|
1204
|
+
return res;
|
|
1205
|
+
}
|
|
1206
|
+
$.$mol_exec = $mol_exec;
|
|
1207
|
+
})($ || ($ = {}));
|
|
1208
|
+
//mol/exec/exec.node.ts
|
|
1209
|
+
;
|
|
1210
|
+
"use strict";
|
|
1211
|
+
var $;
|
|
1212
|
+
(function ($) {
|
|
1213
|
+
$mol_test({
|
|
1214
|
+
'Make empty div'() {
|
|
1215
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
1216
|
+
},
|
|
1217
|
+
'Define native field'() {
|
|
1218
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
1219
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
1220
|
+
$mol_assert_equal(dom.value, '123');
|
|
1221
|
+
},
|
|
1222
|
+
'Define classes'() {
|
|
1223
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
1224
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
1225
|
+
},
|
|
1226
|
+
'Define styles'() {
|
|
1227
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
1228
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
1229
|
+
},
|
|
1230
|
+
'Define dataset'() {
|
|
1231
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
1232
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
1233
|
+
},
|
|
1234
|
+
'Define attributes'() {
|
|
1235
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
1236
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
1237
|
+
},
|
|
1238
|
+
'Define child nodes'() {
|
|
1239
|
+
const dom = $mol_jsx("div", null,
|
|
1240
|
+
"hello",
|
|
1241
|
+
$mol_jsx("strong", null, "world"),
|
|
1242
|
+
"!");
|
|
1243
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
1244
|
+
},
|
|
1245
|
+
'Function as component'() {
|
|
1246
|
+
const Button = ({ hint }, target) => {
|
|
1247
|
+
return $mol_jsx("button", { title: hint }, target());
|
|
1248
|
+
};
|
|
1249
|
+
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
1250
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
1251
|
+
},
|
|
1252
|
+
'Nested guid generation'() {
|
|
1253
|
+
const Foo = () => {
|
|
1254
|
+
return $mol_jsx("div", null,
|
|
1255
|
+
$mol_jsx(Bar, { id: "/bar" },
|
|
1256
|
+
$mol_jsx("img", { id: "/icon" })));
|
|
1257
|
+
};
|
|
1258
|
+
const Bar = (props, icon) => {
|
|
1259
|
+
return $mol_jsx("span", null, icon);
|
|
1260
|
+
};
|
|
1261
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
1262
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
1263
|
+
},
|
|
1264
|
+
'Fail on non unique ids'() {
|
|
1265
|
+
const App = () => {
|
|
1266
|
+
return $mol_jsx("div", null,
|
|
1267
|
+
$mol_jsx("span", { id: "/bar" }),
|
|
1268
|
+
$mol_jsx("span", { id: "/bar" }));
|
|
1269
|
+
};
|
|
1270
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
1271
|
+
},
|
|
1272
|
+
});
|
|
1273
|
+
})($ || ($ = {}));
|
|
1274
|
+
//mol/jsx/jsx.test.tsx
|
|
1275
|
+
;
|
|
1276
|
+
"use strict";
|
|
1277
|
+
var $;
|
|
1278
|
+
(function ($) {
|
|
1279
|
+
$.$mol_jsx_prefix = '';
|
|
1280
|
+
$.$mol_jsx_booked = null;
|
|
1281
|
+
$.$mol_jsx_document = {
|
|
1282
|
+
getElementById: () => null,
|
|
1283
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
1284
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
1285
|
+
};
|
|
1286
|
+
$.$mol_jsx_frag = '';
|
|
1287
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
|
1288
|
+
const id = props && props.id || '';
|
|
1289
|
+
if (Elem && $.$mol_jsx_booked) {
|
|
1290
|
+
if ($.$mol_jsx_booked.has(id)) {
|
|
1291
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
1292
|
+
}
|
|
1293
|
+
else {
|
|
1294
|
+
$.$mol_jsx_booked.add(id);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
const guid = $.$mol_jsx_prefix + id;
|
|
1298
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
1299
|
+
if (typeof Elem !== 'string') {
|
|
1300
|
+
if ('prototype' in Elem) {
|
|
1301
|
+
const view = node && node[Elem] || new Elem;
|
|
1302
|
+
Object.assign(view, props);
|
|
1303
|
+
view[Symbol.toStringTag] = guid;
|
|
1304
|
+
view.childNodes = childNodes;
|
|
1305
|
+
if (!view.ownerDocument)
|
|
1306
|
+
view.ownerDocument = $.$mol_jsx_document;
|
|
1307
|
+
node = view.valueOf();
|
|
1308
|
+
node[Elem] = view;
|
|
1309
|
+
return node;
|
|
1310
|
+
}
|
|
1311
|
+
else {
|
|
1312
|
+
const prefix = $.$mol_jsx_prefix;
|
|
1313
|
+
const booked = $.$mol_jsx_booked;
|
|
1314
|
+
try {
|
|
1315
|
+
$.$mol_jsx_prefix = guid;
|
|
1316
|
+
$.$mol_jsx_booked = new Set;
|
|
1317
|
+
return Elem(props, ...childNodes);
|
|
1318
|
+
}
|
|
1319
|
+
finally {
|
|
1320
|
+
$.$mol_jsx_prefix = prefix;
|
|
1321
|
+
$.$mol_jsx_booked = booked;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
if (!node) {
|
|
1326
|
+
node = Elem
|
|
1327
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
1328
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
|
1329
|
+
}
|
|
1330
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
1331
|
+
if (!Elem)
|
|
1332
|
+
return node;
|
|
1333
|
+
for (const key in props) {
|
|
1334
|
+
if (typeof props[key] === 'string') {
|
|
1335
|
+
;
|
|
1336
|
+
node.setAttribute(key, props[key]);
|
|
1337
|
+
}
|
|
1338
|
+
else if (props[key] &&
|
|
1339
|
+
typeof props[key] === 'object' &&
|
|
1340
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
1341
|
+
if (typeof node[key] === 'object') {
|
|
1342
|
+
Object.assign(node[key], props[key]);
|
|
1343
|
+
continue;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
node[key] = props[key];
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
if (guid)
|
|
1351
|
+
node.id = guid;
|
|
1352
|
+
return node;
|
|
1353
|
+
}
|
|
1354
|
+
$.$mol_jsx = $mol_jsx;
|
|
1355
|
+
})($ || ($ = {}));
|
|
1356
|
+
//mol/jsx/jsx.ts
|
|
1357
|
+
;
|
|
1358
|
+
"use strict";
|
|
1359
|
+
var $;
|
|
1409
1360
|
(function ($) {
|
|
1410
1361
|
$mol_test({
|
|
1411
1362
|
'nulls & undefineds'() {
|
|
@@ -1625,9 +1576,58 @@ var $;
|
|
|
1625
1576
|
//mol/compare/deep/deep.ts
|
|
1626
1577
|
;
|
|
1627
1578
|
"use strict";
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1579
|
+
var $;
|
|
1580
|
+
(function ($) {
|
|
1581
|
+
$mol_test({
|
|
1582
|
+
'Primitives'() {
|
|
1583
|
+
$mol_assert_equal($mol_key(null), 'null');
|
|
1584
|
+
$mol_assert_equal($mol_key(false), 'false');
|
|
1585
|
+
$mol_assert_equal($mol_key(true), 'true');
|
|
1586
|
+
$mol_assert_equal($mol_key(0), '0');
|
|
1587
|
+
$mol_assert_equal($mol_key(''), '""');
|
|
1588
|
+
},
|
|
1589
|
+
'Array & POJO'() {
|
|
1590
|
+
$mol_assert_equal($mol_key([null]), '[null]');
|
|
1591
|
+
$mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
|
|
1592
|
+
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
1593
|
+
},
|
|
1594
|
+
'Function'() {
|
|
1595
|
+
const func = () => { };
|
|
1596
|
+
$mol_assert_equal($mol_key(func), $mol_key(func));
|
|
1597
|
+
$mol_assert_unique($mol_key(func), $mol_key(() => { }));
|
|
1598
|
+
},
|
|
1599
|
+
'Objects'() {
|
|
1600
|
+
class User {
|
|
1601
|
+
}
|
|
1602
|
+
const jin = new User();
|
|
1603
|
+
$mol_assert_equal($mol_key(jin), $mol_key(jin));
|
|
1604
|
+
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
1605
|
+
},
|
|
1606
|
+
'Elements'() {
|
|
1607
|
+
const foo = $mol_jsx("div", null, "bar");
|
|
1608
|
+
$mol_assert_equal($mol_key(foo), $mol_key(foo));
|
|
1609
|
+
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
1610
|
+
},
|
|
1611
|
+
'Custom JSON representation'() {
|
|
1612
|
+
class User {
|
|
1613
|
+
name;
|
|
1614
|
+
age;
|
|
1615
|
+
constructor(name, age) {
|
|
1616
|
+
this.name = name;
|
|
1617
|
+
this.age = age;
|
|
1618
|
+
}
|
|
1619
|
+
toJSON() { return { name: this.name }; }
|
|
1620
|
+
}
|
|
1621
|
+
$mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
1622
|
+
},
|
|
1623
|
+
'Special native classes'() {
|
|
1624
|
+
$mol_assert_equal($mol_key(new Date('xyz')), 'null');
|
|
1625
|
+
$mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
1626
|
+
$mol_assert_equal($mol_key(/./), '"/./"');
|
|
1627
|
+
$mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
1628
|
+
},
|
|
1629
|
+
});
|
|
1630
|
+
})($ || ($ = {}));
|
|
1631
|
+
//mol/key/key.test.tsx
|
|
1632
1632
|
|
|
1633
1633
|
//# sourceMappingURL=node.test.js.map
|