mol_db 0.0.1730 → 0.0.1732
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.d.ts +219 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +228 -9
- package/node.js.map +1 -1
- package/node.mjs +228 -9
- package/node.test.js +289 -9
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +43 -0
- package/web.d.ts.map +1 -1
- package/web.js +43 -0
- package/web.js.map +1 -1
- package/web.mjs +43 -0
- package/web.test.js +67 -1
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -32,7 +32,7 @@ var $;
|
|
|
32
32
|
"use strict";
|
|
33
33
|
var $;
|
|
34
34
|
(function ($) {
|
|
35
|
-
const mod = require('module');
|
|
35
|
+
const mod = require /****/('module');
|
|
36
36
|
const internals = mod.builtinModules;
|
|
37
37
|
function $node_internal_check(name) {
|
|
38
38
|
if (name.startsWith('node:'))
|
|
@@ -72,7 +72,7 @@ var $;
|
|
|
72
72
|
var $;
|
|
73
73
|
(function ($) {
|
|
74
74
|
function $mol_fail_hidden(error) {
|
|
75
|
-
throw error;
|
|
75
|
+
throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
|
|
76
76
|
}
|
|
77
77
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
78
78
|
})($ || ($ = {}));
|
|
@@ -130,8 +130,8 @@ var $;
|
|
|
130
130
|
"use strict";
|
|
131
131
|
var $;
|
|
132
132
|
(function ($) {
|
|
133
|
-
const path = require('path');
|
|
134
|
-
const mod = require('module');
|
|
133
|
+
const path = require /****/('path');
|
|
134
|
+
const mod = require /****/('module');
|
|
135
135
|
const localRequire = mod.createRequire(path.join(process.cwd(), 'package.json'));
|
|
136
136
|
function $node_autoinstall(name) {
|
|
137
137
|
try {
|
|
@@ -238,6 +238,7 @@ var $;
|
|
|
238
238
|
])
|
|
239
239
|
].map(frame_normalize).join('\n')
|
|
240
240
|
});
|
|
241
|
+
// в nodejs, что б не дублировалось cause в консоли
|
|
241
242
|
Object.defineProperty(this, 'cause', {
|
|
242
243
|
get: () => cause
|
|
243
244
|
});
|
|
@@ -271,6 +272,11 @@ var $;
|
|
|
271
272
|
var $;
|
|
272
273
|
(function ($) {
|
|
273
274
|
const instances = new WeakSet();
|
|
275
|
+
/**
|
|
276
|
+
* Proxy that delegates all to lazy returned target.
|
|
277
|
+
*
|
|
278
|
+
* $mol_delegate( Array.prototype , ()=> fetch_array() )
|
|
279
|
+
*/
|
|
274
280
|
function $mol_delegate(proto, target) {
|
|
275
281
|
const proxy = new Proxy(proto, {
|
|
276
282
|
get: (_, field) => {
|
|
@@ -414,6 +420,9 @@ var $;
|
|
|
414
420
|
[Symbol.dispose]() {
|
|
415
421
|
this.destructor();
|
|
416
422
|
}
|
|
423
|
+
//[ Symbol.toPrimitive ]( hint: string ) {
|
|
424
|
+
// return hint === 'number' ? this.valueOf() : this.toString()
|
|
425
|
+
//}
|
|
417
426
|
toString() {
|
|
418
427
|
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
|
419
428
|
}
|
|
@@ -464,6 +473,7 @@ var $;
|
|
|
464
473
|
"use strict";
|
|
465
474
|
var $;
|
|
466
475
|
(function ($) {
|
|
476
|
+
/** Generates unique identifier. */
|
|
467
477
|
function $mol_guid(length = 8, exists = () => false) {
|
|
468
478
|
for (;;) {
|
|
469
479
|
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
@@ -479,11 +489,16 @@ var $;
|
|
|
479
489
|
"use strict";
|
|
480
490
|
var $;
|
|
481
491
|
(function ($) {
|
|
492
|
+
/** Special status statuses. */
|
|
482
493
|
let $mol_wire_cursor;
|
|
483
494
|
(function ($mol_wire_cursor) {
|
|
495
|
+
/** Update required. */
|
|
484
496
|
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
497
|
+
/** Some of (transitive) pub update required. */
|
|
485
498
|
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
499
|
+
/** Actual state but may be dropped. */
|
|
486
500
|
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
501
|
+
/** State will never be changed. */
|
|
487
502
|
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
488
503
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
489
504
|
})($ || ($ = {}));
|
|
@@ -492,6 +507,9 @@ var $;
|
|
|
492
507
|
"use strict";
|
|
493
508
|
var $;
|
|
494
509
|
(function ($) {
|
|
510
|
+
/**
|
|
511
|
+
* Collects subscribers in compact array. 28B
|
|
512
|
+
*/
|
|
495
513
|
class $mol_wire_pub extends Object {
|
|
496
514
|
constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
|
|
497
515
|
super();
|
|
@@ -499,10 +517,17 @@ var $;
|
|
|
499
517
|
}
|
|
500
518
|
[Symbol.toStringTag];
|
|
501
519
|
data = [];
|
|
520
|
+
// Derived objects should be Arrays.
|
|
502
521
|
static get [Symbol.species]() {
|
|
503
522
|
return Array;
|
|
504
523
|
}
|
|
505
|
-
|
|
524
|
+
/**
|
|
525
|
+
* Index of first subscriber.
|
|
526
|
+
*/
|
|
527
|
+
sub_from = 0; // 4B
|
|
528
|
+
/**
|
|
529
|
+
* All current subscribers.
|
|
530
|
+
*/
|
|
506
531
|
get sub_list() {
|
|
507
532
|
const res = [];
|
|
508
533
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
@@ -510,14 +535,23 @@ var $;
|
|
|
510
535
|
}
|
|
511
536
|
return res;
|
|
512
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Has any subscribers or not.
|
|
540
|
+
*/
|
|
513
541
|
get sub_empty() {
|
|
514
542
|
return this.sub_from === this.data.length;
|
|
515
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
|
|
546
|
+
*/
|
|
516
547
|
sub_on(sub, pub_pos) {
|
|
517
548
|
const pos = this.data.length;
|
|
518
549
|
this.data.push(sub, pub_pos);
|
|
519
550
|
return pos;
|
|
520
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
|
|
554
|
+
*/
|
|
521
555
|
sub_off(sub_pos) {
|
|
522
556
|
if (!(sub_pos < this.data.length)) {
|
|
523
557
|
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
@@ -530,21 +564,39 @@ var $;
|
|
|
530
564
|
if (end === this.sub_from)
|
|
531
565
|
this.reap();
|
|
532
566
|
}
|
|
567
|
+
/**
|
|
568
|
+
* Called when last sub was unsubscribed.
|
|
569
|
+
**/
|
|
533
570
|
reap() { }
|
|
571
|
+
/**
|
|
572
|
+
* Autowire this publisher with current subscriber.
|
|
573
|
+
**/
|
|
534
574
|
promote() {
|
|
535
575
|
$mol_wire_auto()?.track_next(this);
|
|
536
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* Enforce actualization. Should not throw errors.
|
|
579
|
+
*/
|
|
537
580
|
fresh() { }
|
|
581
|
+
/**
|
|
582
|
+
* Allow to put data to caches in the subtree.
|
|
583
|
+
*/
|
|
538
584
|
complete() { }
|
|
539
585
|
get incompleted() {
|
|
540
586
|
return false;
|
|
541
587
|
}
|
|
588
|
+
/**
|
|
589
|
+
* Notify subscribers about self changes.
|
|
590
|
+
*/
|
|
542
591
|
emit(quant = $mol_wire_cursor.stale) {
|
|
543
592
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
544
593
|
;
|
|
545
594
|
this.data[i].absorb(quant, this.data[i + 1]);
|
|
546
595
|
}
|
|
547
596
|
}
|
|
597
|
+
/**
|
|
598
|
+
* Moves peer from one position to another. Doesn't clear data at old position!
|
|
599
|
+
*/
|
|
548
600
|
peer_move(from_pos, to_pos) {
|
|
549
601
|
const peer = this.data[from_pos];
|
|
550
602
|
const self_pos = this.data[from_pos + 1];
|
|
@@ -552,6 +604,9 @@ var $;
|
|
|
552
604
|
this.data[to_pos + 1] = self_pos;
|
|
553
605
|
peer.peer_repos(self_pos, to_pos);
|
|
554
606
|
}
|
|
607
|
+
/**
|
|
608
|
+
* Updates self position in the peer.
|
|
609
|
+
*/
|
|
555
610
|
peer_repos(peer_pos, self_pos) {
|
|
556
611
|
this.data[peer_pos + 1] = self_pos;
|
|
557
612
|
}
|
|
@@ -567,10 +622,16 @@ var $;
|
|
|
567
622
|
var $;
|
|
568
623
|
(function ($) {
|
|
569
624
|
$.$mol_wire_auto_sub = null;
|
|
625
|
+
/**
|
|
626
|
+
* When fulfilled, all publishers are promoted to this subscriber on access to its.
|
|
627
|
+
*/
|
|
570
628
|
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
571
629
|
return $.$mol_wire_auto_sub = next;
|
|
572
630
|
}
|
|
573
631
|
$.$mol_wire_auto = $mol_wire_auto;
|
|
632
|
+
/**
|
|
633
|
+
* Affection queue. Used to prevent accidental stack overflow on emit.
|
|
634
|
+
*/
|
|
574
635
|
$.$mol_wire_affected = [];
|
|
575
636
|
})($ || ($ = {}));
|
|
576
637
|
|
|
@@ -578,6 +639,7 @@ var $;
|
|
|
578
639
|
"use strict";
|
|
579
640
|
var $;
|
|
580
641
|
(function ($) {
|
|
642
|
+
// https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
|
|
581
643
|
$['devtoolsFormatters'] ||= [];
|
|
582
644
|
function $mol_dev_format_register(config) {
|
|
583
645
|
$['devtoolsFormatters'].push(config);
|
|
@@ -629,6 +691,7 @@ var $;
|
|
|
629
691
|
return false;
|
|
630
692
|
if (!val)
|
|
631
693
|
return false;
|
|
694
|
+
// if( Error.isError( val ) ) true
|
|
632
695
|
if (val[$.$mol_dev_format_body])
|
|
633
696
|
return true;
|
|
634
697
|
return false;
|
|
@@ -646,12 +709,16 @@ var $;
|
|
|
646
709
|
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
647
710
|
}
|
|
648
711
|
}
|
|
712
|
+
// if( Error.isError( val ) ) {
|
|
713
|
+
// return $mol_dev_format_native( val )
|
|
714
|
+
// }
|
|
649
715
|
return null;
|
|
650
716
|
},
|
|
651
717
|
});
|
|
652
718
|
function $mol_dev_format_native(obj) {
|
|
653
719
|
if (typeof obj === 'undefined')
|
|
654
720
|
return $.$mol_dev_format_shade('undefined');
|
|
721
|
+
// if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
|
|
655
722
|
return [
|
|
656
723
|
'object',
|
|
657
724
|
{
|
|
@@ -709,6 +776,9 @@ var $;
|
|
|
709
776
|
'margin-left': '13px'
|
|
710
777
|
});
|
|
711
778
|
class Stack extends Array {
|
|
779
|
+
// [ Symbol.toPrimitive ]() {
|
|
780
|
+
// return this.toString()
|
|
781
|
+
// }
|
|
712
782
|
toString() {
|
|
713
783
|
return this.join('\n');
|
|
714
784
|
}
|
|
@@ -731,6 +801,7 @@ var $;
|
|
|
731
801
|
this.method = call.getMethodName() ?? '';
|
|
732
802
|
if (this.method === this.function)
|
|
733
803
|
this.method = '';
|
|
804
|
+
// const func = c.getFunction()
|
|
734
805
|
this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
|
|
735
806
|
this.eval = call.getEvalOrigin() ?? '';
|
|
736
807
|
this.source = call.getScriptNameOrSourceURL() ?? '';
|
|
@@ -777,9 +848,16 @@ var $;
|
|
|
777
848
|
"use strict";
|
|
778
849
|
var $;
|
|
779
850
|
(function ($) {
|
|
851
|
+
/**
|
|
852
|
+
* Publisher that can auto collect other publishers. 32B
|
|
853
|
+
*
|
|
854
|
+
* P1 P2 P3 P4 S1 S2 S3
|
|
855
|
+
* ^ ^
|
|
856
|
+
* pubs_from subs_from
|
|
857
|
+
*/
|
|
780
858
|
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
781
|
-
pub_from = 0;
|
|
782
|
-
cursor = $mol_wire_cursor.stale;
|
|
859
|
+
pub_from = 0; // 4B
|
|
860
|
+
cursor = $mol_wire_cursor.stale; // 4B
|
|
783
861
|
get temp() {
|
|
784
862
|
return false;
|
|
785
863
|
}
|
|
@@ -897,10 +975,27 @@ var $;
|
|
|
897
975
|
return;
|
|
898
976
|
this.cursor = quant;
|
|
899
977
|
this.emit($mol_wire_cursor.doubt);
|
|
978
|
+
// if( pos >= 0 && pos < this.sub_from - 2 ) {
|
|
979
|
+
// const pub = this.data[ pos ] as $mol_wire_pub
|
|
980
|
+
// if( pub instanceof $mol_wire_task ) return
|
|
981
|
+
// for(
|
|
982
|
+
// let cursor = this.pub_from;
|
|
983
|
+
// cursor < this.sub_from;
|
|
984
|
+
// cursor += 2
|
|
985
|
+
// ) {
|
|
986
|
+
// const pub = this.data[ cursor ] as $mol_wire_pub
|
|
987
|
+
// if( pub instanceof $mol_wire_task ) {
|
|
988
|
+
// pub.destructor()
|
|
989
|
+
// }
|
|
990
|
+
// }
|
|
991
|
+
// }
|
|
900
992
|
}
|
|
901
993
|
[$mol_dev_format_head]() {
|
|
902
994
|
return $mol_dev_format_native(this);
|
|
903
995
|
}
|
|
996
|
+
/**
|
|
997
|
+
* Is subscribed to any publisher or not.
|
|
998
|
+
*/
|
|
904
999
|
get pub_empty() {
|
|
905
1000
|
return this.sub_from === this.pub_from;
|
|
906
1001
|
}
|
|
@@ -941,6 +1036,13 @@ var $;
|
|
|
941
1036
|
var $;
|
|
942
1037
|
(function ($) {
|
|
943
1038
|
const wrappers = new WeakMap();
|
|
1039
|
+
/**
|
|
1040
|
+
* Suspendable task with support both sync/async api.
|
|
1041
|
+
*
|
|
1042
|
+
* A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
|
|
1043
|
+
* ^ ^ ^
|
|
1044
|
+
* args_from pubs_from subs_from
|
|
1045
|
+
**/
|
|
944
1046
|
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
945
1047
|
task;
|
|
946
1048
|
host;
|
|
@@ -961,6 +1063,7 @@ var $;
|
|
|
961
1063
|
});
|
|
962
1064
|
}
|
|
963
1065
|
static sync() {
|
|
1066
|
+
// Sync whole fiber graph
|
|
964
1067
|
while (this.planning.size) {
|
|
965
1068
|
for (const fiber of this.planning) {
|
|
966
1069
|
this.planning.delete(fiber);
|
|
@@ -971,6 +1074,7 @@ var $;
|
|
|
971
1074
|
fiber.fresh();
|
|
972
1075
|
}
|
|
973
1076
|
}
|
|
1077
|
+
// Collect garbage
|
|
974
1078
|
while (this.reaping.size) {
|
|
975
1079
|
const fibers = this.reaping;
|
|
976
1080
|
this.reaping = new Set;
|
|
@@ -1122,6 +1226,10 @@ var $;
|
|
|
1122
1226
|
this.cursor = $mol_wire_cursor.stale;
|
|
1123
1227
|
this.fresh();
|
|
1124
1228
|
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
|
|
1231
|
+
* Should be called inside SuspenseAPI consumer (ie fiber).
|
|
1232
|
+
*/
|
|
1125
1233
|
sync() {
|
|
1126
1234
|
if (!$mol_wire_fiber.warm) {
|
|
1127
1235
|
return this.result();
|
|
@@ -1136,6 +1244,10 @@ var $;
|
|
|
1136
1244
|
}
|
|
1137
1245
|
return this.cache;
|
|
1138
1246
|
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Asynchronous execution.
|
|
1249
|
+
* It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
|
|
1250
|
+
*/
|
|
1139
1251
|
async async_raw() {
|
|
1140
1252
|
while (true) {
|
|
1141
1253
|
this.fresh();
|
|
@@ -1148,6 +1260,7 @@ var $;
|
|
|
1148
1260
|
if (!$mol_promise_like(this.cache))
|
|
1149
1261
|
return this.cache;
|
|
1150
1262
|
if (this.cursor === $mol_wire_cursor.final) {
|
|
1263
|
+
// never ends on destructed fiber
|
|
1151
1264
|
await new Promise(() => { });
|
|
1152
1265
|
}
|
|
1153
1266
|
}
|
|
@@ -1195,6 +1308,10 @@ var $;
|
|
|
1195
1308
|
var $;
|
|
1196
1309
|
(function ($) {
|
|
1197
1310
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
1311
|
+
/**
|
|
1312
|
+
* Deeply compares two values. Returns true if equal.
|
|
1313
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
1314
|
+
*/
|
|
1198
1315
|
function $mol_compare_deep(left, right) {
|
|
1199
1316
|
if (Object.is(left, right))
|
|
1200
1317
|
return true;
|
|
@@ -1334,6 +1451,7 @@ var $;
|
|
|
1334
1451
|
"use strict";
|
|
1335
1452
|
var $;
|
|
1336
1453
|
(function ($) {
|
|
1454
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
1337
1455
|
function $mol_log3_area_lazy(event) {
|
|
1338
1456
|
const self = this.$;
|
|
1339
1457
|
const stack = self.$mol_log3_stack;
|
|
@@ -1358,6 +1476,7 @@ var $;
|
|
|
1358
1476
|
"use strict";
|
|
1359
1477
|
var $;
|
|
1360
1478
|
(function ($) {
|
|
1479
|
+
/** Position in any resource. */
|
|
1361
1480
|
class $mol_span extends $mol_object2 {
|
|
1362
1481
|
uri;
|
|
1363
1482
|
source;
|
|
@@ -1373,13 +1492,17 @@ var $;
|
|
|
1373
1492
|
this.length = length;
|
|
1374
1493
|
this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
|
|
1375
1494
|
}
|
|
1495
|
+
/** Span for begin of unknown resource */
|
|
1376
1496
|
static unknown = $mol_span.begin('?');
|
|
1497
|
+
/** Makes new span for begin of resource. */
|
|
1377
1498
|
static begin(uri, source = '') {
|
|
1378
1499
|
return new $mol_span(uri, source, 1, 1, 0);
|
|
1379
1500
|
}
|
|
1501
|
+
/** Makes new span for end of resource. */
|
|
1380
1502
|
static end(uri, source) {
|
|
1381
1503
|
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1382
1504
|
}
|
|
1505
|
+
/** Makes new span for entire resource. */
|
|
1383
1506
|
static entire(uri, source) {
|
|
1384
1507
|
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1385
1508
|
}
|
|
@@ -1394,15 +1517,19 @@ var $;
|
|
|
1394
1517
|
length: this.length
|
|
1395
1518
|
};
|
|
1396
1519
|
}
|
|
1520
|
+
/** Makes new error for this span. */
|
|
1397
1521
|
error(message, Class = Error) {
|
|
1398
1522
|
return new Class(`${message} (${this})`);
|
|
1399
1523
|
}
|
|
1524
|
+
/** Makes new span for same uri. */
|
|
1400
1525
|
span(row, col, length) {
|
|
1401
1526
|
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1402
1527
|
}
|
|
1528
|
+
/** Makes new span after end of this. */
|
|
1403
1529
|
after(length = 0) {
|
|
1404
1530
|
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1405
1531
|
}
|
|
1532
|
+
/** Makes new span between begin and end. */
|
|
1406
1533
|
slice(begin, end = -1) {
|
|
1407
1534
|
let len = this.length;
|
|
1408
1535
|
if (begin < 0)
|
|
@@ -1425,6 +1552,7 @@ var $;
|
|
|
1425
1552
|
"use strict";
|
|
1426
1553
|
var $;
|
|
1427
1554
|
(function ($) {
|
|
1555
|
+
/** Serializes tree to string in tree format. */
|
|
1428
1556
|
function $mol_tree2_to_string(tree) {
|
|
1429
1557
|
let output = [];
|
|
1430
1558
|
function dump(tree, prefix = '') {
|
|
@@ -1468,12 +1596,25 @@ var $;
|
|
|
1468
1596
|
"use strict";
|
|
1469
1597
|
var $;
|
|
1470
1598
|
(function ($) {
|
|
1599
|
+
/**
|
|
1600
|
+
* Abstract Syntax Tree with human readable serialization.
|
|
1601
|
+
* Avoid direct instantiation. Use static factories instead.
|
|
1602
|
+
* @see https://github.com/nin-jin/tree.d
|
|
1603
|
+
*/
|
|
1471
1604
|
class $mol_tree2 extends Object {
|
|
1472
1605
|
type;
|
|
1473
1606
|
value;
|
|
1474
1607
|
kids;
|
|
1475
1608
|
span;
|
|
1476
|
-
constructor(
|
|
1609
|
+
constructor(
|
|
1610
|
+
/** Type of structural node, `value` should be empty */
|
|
1611
|
+
type,
|
|
1612
|
+
/** Content of data node, `type` should be empty */
|
|
1613
|
+
value,
|
|
1614
|
+
/** Child nodes */
|
|
1615
|
+
kids,
|
|
1616
|
+
/** Position in most far source resource */
|
|
1617
|
+
span) {
|
|
1477
1618
|
super();
|
|
1478
1619
|
this.type = type;
|
|
1479
1620
|
this.value = value;
|
|
@@ -1481,12 +1622,15 @@ var $;
|
|
|
1481
1622
|
this.span = span;
|
|
1482
1623
|
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1483
1624
|
}
|
|
1625
|
+
/** Makes collection node. */
|
|
1484
1626
|
static list(kids, span = $mol_span.unknown) {
|
|
1485
1627
|
return new $mol_tree2('', '', kids, span);
|
|
1486
1628
|
}
|
|
1629
|
+
/** Makes new derived collection node. */
|
|
1487
1630
|
list(kids) {
|
|
1488
1631
|
return $mol_tree2.list(kids, this.span);
|
|
1489
1632
|
}
|
|
1633
|
+
/** Makes data node for any string. */
|
|
1490
1634
|
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1491
1635
|
const chunks = value.split('\n');
|
|
1492
1636
|
if (chunks.length > 1) {
|
|
@@ -1500,21 +1644,26 @@ var $;
|
|
|
1500
1644
|
}
|
|
1501
1645
|
return new $mol_tree2('', value, kids, span);
|
|
1502
1646
|
}
|
|
1647
|
+
/** Makes new derived data node. */
|
|
1503
1648
|
data(value, kids = []) {
|
|
1504
1649
|
return $mol_tree2.data(value, kids, this.span);
|
|
1505
1650
|
}
|
|
1651
|
+
/** Makes struct node. */
|
|
1506
1652
|
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1507
1653
|
if (/[ \n\t\\]/.test(type)) {
|
|
1508
1654
|
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1509
1655
|
}
|
|
1510
1656
|
return new $mol_tree2(type, '', kids, span);
|
|
1511
1657
|
}
|
|
1658
|
+
/** Makes new derived structural node. */
|
|
1512
1659
|
struct(type, kids = []) {
|
|
1513
1660
|
return $mol_tree2.struct(type, kids, this.span);
|
|
1514
1661
|
}
|
|
1662
|
+
/** Makes new derived node with different kids id defined. */
|
|
1515
1663
|
clone(kids, span = this.span) {
|
|
1516
1664
|
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1517
1665
|
}
|
|
1666
|
+
/** Returns multiline text content. */
|
|
1518
1667
|
text() {
|
|
1519
1668
|
var values = [];
|
|
1520
1669
|
for (var kid of this.kids) {
|
|
@@ -1524,15 +1673,20 @@ var $;
|
|
|
1524
1673
|
}
|
|
1525
1674
|
return this.value + values.join('\n');
|
|
1526
1675
|
}
|
|
1676
|
+
/** Parses tree format. */
|
|
1677
|
+
/** @deprecated Use $mol_tree2_from_string */
|
|
1527
1678
|
static fromString(str, uri = 'unknown') {
|
|
1528
1679
|
return $$.$mol_tree2_from_string(str, uri);
|
|
1529
1680
|
}
|
|
1681
|
+
/** Serializes to tree format. */
|
|
1530
1682
|
toString() {
|
|
1531
1683
|
return $$.$mol_tree2_to_string(this);
|
|
1532
1684
|
}
|
|
1685
|
+
/** Makes new tree with node overrided by path. */
|
|
1533
1686
|
insert(value, ...path) {
|
|
1534
1687
|
return this.update($mol_maybe(value), ...path)[0];
|
|
1535
1688
|
}
|
|
1689
|
+
/** Makes new tree with node overrided by path. */
|
|
1536
1690
|
update(value, ...path) {
|
|
1537
1691
|
if (path.length === 0)
|
|
1538
1692
|
return value;
|
|
@@ -1565,6 +1719,7 @@ var $;
|
|
|
1565
1719
|
return [this.clone(kids)];
|
|
1566
1720
|
}
|
|
1567
1721
|
}
|
|
1722
|
+
/** Query nodes by path. */
|
|
1568
1723
|
select(...path) {
|
|
1569
1724
|
let next = [this];
|
|
1570
1725
|
for (const type of path) {
|
|
@@ -1591,6 +1746,7 @@ var $;
|
|
|
1591
1746
|
}
|
|
1592
1747
|
return this.list(next);
|
|
1593
1748
|
}
|
|
1749
|
+
/** Filter kids by path or value. */
|
|
1594
1750
|
filter(path, value) {
|
|
1595
1751
|
const sub = this.kids.filter(item => {
|
|
1596
1752
|
var found = item.select(...path);
|
|
@@ -1618,9 +1774,11 @@ var $;
|
|
|
1618
1774
|
$mol_fail_hidden(error);
|
|
1619
1775
|
}
|
|
1620
1776
|
}
|
|
1777
|
+
/** Transform tree through context with transformers */
|
|
1621
1778
|
hack(belt, context = {}) {
|
|
1622
1779
|
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
1623
1780
|
}
|
|
1781
|
+
/** Makes Error with node coordinates. */
|
|
1624
1782
|
error(message, Class = Error) {
|
|
1625
1783
|
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
1626
1784
|
}
|
|
@@ -1638,6 +1796,7 @@ var $;
|
|
|
1638
1796
|
"use strict";
|
|
1639
1797
|
var $;
|
|
1640
1798
|
(function ($) {
|
|
1799
|
+
/** Syntax error with cordinates and source line snippet. */
|
|
1641
1800
|
class $mol_error_syntax extends SyntaxError {
|
|
1642
1801
|
reason;
|
|
1643
1802
|
line;
|
|
@@ -1656,6 +1815,7 @@ var $;
|
|
|
1656
1815
|
"use strict";
|
|
1657
1816
|
var $;
|
|
1658
1817
|
(function ($) {
|
|
1818
|
+
/** Parses tree format from string. */
|
|
1659
1819
|
function $mol_tree2_from_string(str, uri = '?') {
|
|
1660
1820
|
const span = $mol_span.entire(uri, str);
|
|
1661
1821
|
var root = $mol_tree2.list([], span);
|
|
@@ -1665,6 +1825,7 @@ var $;
|
|
|
1665
1825
|
var indent = 0;
|
|
1666
1826
|
var line_start = pos;
|
|
1667
1827
|
row++;
|
|
1828
|
+
// read indent
|
|
1668
1829
|
while (str.length > pos && str[pos] == '\t') {
|
|
1669
1830
|
indent++;
|
|
1670
1831
|
pos++;
|
|
@@ -1673,8 +1834,10 @@ var $;
|
|
|
1673
1834
|
min_indent = indent;
|
|
1674
1835
|
}
|
|
1675
1836
|
indent -= min_indent;
|
|
1837
|
+
// invalid tab size
|
|
1676
1838
|
if (indent < 0 || indent >= stack.length) {
|
|
1677
1839
|
const sp = span.span(row, 1, pos - line_start);
|
|
1840
|
+
// skip error line
|
|
1678
1841
|
while (str.length > pos && str[pos] != '\n') {
|
|
1679
1842
|
pos++;
|
|
1680
1843
|
}
|
|
@@ -1689,7 +1852,9 @@ var $;
|
|
|
1689
1852
|
}
|
|
1690
1853
|
stack.length = indent + 1;
|
|
1691
1854
|
var parent = stack[indent];
|
|
1855
|
+
// parse types
|
|
1692
1856
|
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1857
|
+
// type can not contain space and tab
|
|
1693
1858
|
var error_start = pos;
|
|
1694
1859
|
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1695
1860
|
pos++;
|
|
@@ -1701,6 +1866,7 @@ var $;
|
|
|
1701
1866
|
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1702
1867
|
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1703
1868
|
}
|
|
1869
|
+
// read type
|
|
1704
1870
|
var type_start = pos;
|
|
1705
1871
|
while (str.length > pos &&
|
|
1706
1872
|
str[pos] != '\\' &&
|
|
@@ -1715,10 +1881,12 @@ var $;
|
|
|
1715
1881
|
parent_kids.push(next);
|
|
1716
1882
|
parent = next;
|
|
1717
1883
|
}
|
|
1884
|
+
// read one space if exists
|
|
1718
1885
|
if (str.length > pos && str[pos] == ' ') {
|
|
1719
1886
|
pos++;
|
|
1720
1887
|
}
|
|
1721
1888
|
}
|
|
1889
|
+
// read data
|
|
1722
1890
|
if (str.length > pos && str[pos] == '\\') {
|
|
1723
1891
|
var data_start = pos;
|
|
1724
1892
|
while (str.length > pos && str[pos] != '\n') {
|
|
@@ -1729,6 +1897,7 @@ var $;
|
|
|
1729
1897
|
parent_kids.push(next);
|
|
1730
1898
|
parent = next;
|
|
1731
1899
|
}
|
|
1900
|
+
// now must be end of text
|
|
1732
1901
|
if (str.length === pos && stack.length > 0) {
|
|
1733
1902
|
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1734
1903
|
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
@@ -1821,6 +1990,7 @@ var $;
|
|
|
1821
1990
|
"use strict";
|
|
1822
1991
|
var $;
|
|
1823
1992
|
(function ($) {
|
|
1993
|
+
/** Module for working with terminal. Text coloring when output in terminal */
|
|
1824
1994
|
class $mol_term_color {
|
|
1825
1995
|
static reset = this.ansi(0, 0);
|
|
1826
1996
|
static bold = this.ansi(1, 22);
|
|
@@ -1892,6 +2062,7 @@ var $;
|
|
|
1892
2062
|
"use strict";
|
|
1893
2063
|
var $;
|
|
1894
2064
|
(function ($) {
|
|
2065
|
+
/** One-shot fiber */
|
|
1895
2066
|
class $mol_wire_task extends $mol_wire_fiber {
|
|
1896
2067
|
static getter(task) {
|
|
1897
2068
|
return function $mol_wire_task_get(host, args) {
|
|
@@ -1917,6 +2088,7 @@ var $;
|
|
|
1917
2088
|
}
|
|
1918
2089
|
const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
|
|
1919
2090
|
const next = new $mol_wire_task(key, task, host, args);
|
|
2091
|
+
// Disabled because non-idempotency is required for try-catch
|
|
1920
2092
|
if (existen?.temp) {
|
|
1921
2093
|
$$.$mol_log3_warn({
|
|
1922
2094
|
place: '$mol_wire_task',
|
|
@@ -1949,7 +2121,7 @@ var $;
|
|
|
1949
2121
|
try {
|
|
1950
2122
|
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
1951
2123
|
}
|
|
1952
|
-
catch {
|
|
2124
|
+
catch { // Promises throw in strict mode
|
|
1953
2125
|
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
1954
2126
|
}
|
|
1955
2127
|
}
|
|
@@ -2002,6 +2174,10 @@ var $;
|
|
|
2002
2174
|
props[field] = get_val;
|
|
2003
2175
|
return get_val;
|
|
2004
2176
|
}
|
|
2177
|
+
/**
|
|
2178
|
+
* Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
|
|
2179
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
2180
|
+
*/
|
|
2005
2181
|
function $mol_wire_sync(obj) {
|
|
2006
2182
|
return new Proxy(obj, {
|
|
2007
2183
|
get(obj, field) {
|
|
@@ -2163,6 +2339,7 @@ var $;
|
|
|
2163
2339
|
"use strict";
|
|
2164
2340
|
var $;
|
|
2165
2341
|
(function ($) {
|
|
2342
|
+
/** Converts IDBResult to Promise */
|
|
2166
2343
|
function $mol_db_response(request) {
|
|
2167
2344
|
return new Promise((done, fail) => {
|
|
2168
2345
|
request.onerror = () => fail(new Error(request.error.message));
|
|
@@ -2176,6 +2353,14 @@ var $;
|
|
|
2176
2353
|
"use strict";
|
|
2177
2354
|
var $;
|
|
2178
2355
|
(function ($) {
|
|
2356
|
+
/**
|
|
2357
|
+
* Creates new or returns existen database with automatic schema migration.
|
|
2358
|
+
* Schema version is based on migrations count.
|
|
2359
|
+
* Migrations code mustn't be changed after deploy.
|
|
2360
|
+
* Only adding migrations at the end is allowed.
|
|
2361
|
+
* Only new migrations will be applyed to existen DB.
|
|
2362
|
+
* Schema changes allowed only through migratios.
|
|
2363
|
+
*/
|
|
2179
2364
|
async function $mol_db(name, ...migrations) {
|
|
2180
2365
|
const request = this.$mol_dom_context.indexedDB.open(name, migrations.length ? migrations.length + 1 : undefined);
|
|
2181
2366
|
request.onupgradeneeded = event => {
|
|
@@ -2194,6 +2379,7 @@ var $;
|
|
|
2194
2379
|
"use strict";
|
|
2195
2380
|
var $;
|
|
2196
2381
|
(function ($) {
|
|
2382
|
+
/** IndexedDB ObjectStore wrapper. */
|
|
2197
2383
|
class $mol_db_store {
|
|
2198
2384
|
native;
|
|
2199
2385
|
constructor(native) {
|
|
@@ -2208,6 +2394,7 @@ var $;
|
|
|
2208
2394
|
get incremental() {
|
|
2209
2395
|
return this.native.autoIncrement;
|
|
2210
2396
|
}
|
|
2397
|
+
/** Returns dictionary of all existen Indexes. */
|
|
2211
2398
|
get indexes() {
|
|
2212
2399
|
return new Proxy({}, {
|
|
2213
2400
|
ownKeys: () => [...this.native.indexNames],
|
|
@@ -2215,9 +2402,11 @@ var $;
|
|
|
2215
2402
|
get: (_, name) => new $mol_db_index(this.native.index(name))
|
|
2216
2403
|
});
|
|
2217
2404
|
}
|
|
2405
|
+
/** Creates new Index */
|
|
2218
2406
|
index_make(name, path = [], unique = false, multiEntry = false) {
|
|
2219
2407
|
return this.native.createIndex(name, path, { multiEntry, unique });
|
|
2220
2408
|
}
|
|
2409
|
+
/** Drops existen Index */
|
|
2221
2410
|
index_drop(name) {
|
|
2222
2411
|
this.native.deleteIndex(name);
|
|
2223
2412
|
return this;
|
|
@@ -2228,21 +2417,27 @@ var $;
|
|
|
2228
2417
|
get db() {
|
|
2229
2418
|
return this.transaction.db;
|
|
2230
2419
|
}
|
|
2420
|
+
/** Deletes all stored Documents */
|
|
2231
2421
|
clear() {
|
|
2232
2422
|
return $mol_db_response(this.native.clear());
|
|
2233
2423
|
}
|
|
2424
|
+
/** Counts Documents by primary key(s) */
|
|
2234
2425
|
count(keys) {
|
|
2235
2426
|
return $mol_db_response(this.native.count(keys));
|
|
2236
2427
|
}
|
|
2428
|
+
/** Stores single Document by primary key. */
|
|
2237
2429
|
put(doc, key) {
|
|
2238
2430
|
return $mol_db_response(this.native.put(doc, key));
|
|
2239
2431
|
}
|
|
2432
|
+
/** Returns Document by primary key. */
|
|
2240
2433
|
get(key) {
|
|
2241
2434
|
return $mol_db_response(this.native.get(key));
|
|
2242
2435
|
}
|
|
2436
|
+
/** Selects Documents by primary keys. */
|
|
2243
2437
|
select(key, count) {
|
|
2244
2438
|
return $mol_db_response(this.native.getAll(key, count));
|
|
2245
2439
|
}
|
|
2440
|
+
/** Deletes Documents by primary key(s). */
|
|
2246
2441
|
drop(keys) {
|
|
2247
2442
|
return $mol_db_response(this.native.delete(keys));
|
|
2248
2443
|
}
|
|
@@ -2264,6 +2459,7 @@ var $;
|
|
|
2264
2459
|
"use strict";
|
|
2265
2460
|
var $;
|
|
2266
2461
|
(function ($) {
|
|
2462
|
+
/** IndexedDB Index wrapper. */
|
|
2267
2463
|
class $mol_db_index {
|
|
2268
2464
|
native;
|
|
2269
2465
|
constructor(native) {
|
|
@@ -2290,12 +2486,15 @@ var $;
|
|
|
2290
2486
|
get db() {
|
|
2291
2487
|
return this.store.db;
|
|
2292
2488
|
}
|
|
2489
|
+
/** Counts Documents by key(s) */
|
|
2293
2490
|
count(keys) {
|
|
2294
2491
|
return $mol_db_response(this.native.count(keys));
|
|
2295
2492
|
}
|
|
2493
|
+
/** Returns Document by primary key. */
|
|
2296
2494
|
get(key) {
|
|
2297
2495
|
return $mol_db_response(this.native.get(key));
|
|
2298
2496
|
}
|
|
2497
|
+
/** Selects Documents by primary keys. */
|
|
2299
2498
|
select(key, count) {
|
|
2300
2499
|
return $mol_db_response(this.native.getAll(key, count));
|
|
2301
2500
|
}
|
|
@@ -2331,32 +2530,46 @@ var $;
|
|
|
2331
2530
|
"use strict";
|
|
2332
2531
|
var $;
|
|
2333
2532
|
(function ($) {
|
|
2533
|
+
/** IndexedDB instance wrapper. */
|
|
2334
2534
|
class $mol_db_database {
|
|
2335
2535
|
native;
|
|
2336
2536
|
constructor(native) {
|
|
2337
2537
|
this.native = native;
|
|
2338
2538
|
}
|
|
2539
|
+
/** Returns database name. */
|
|
2339
2540
|
get name() {
|
|
2340
2541
|
return this.native.name;
|
|
2341
2542
|
}
|
|
2543
|
+
/** Returns database schema version. */
|
|
2342
2544
|
get version() {
|
|
2343
2545
|
return this.native.version;
|
|
2344
2546
|
}
|
|
2547
|
+
/** Returns all stores names. */
|
|
2345
2548
|
get stores() {
|
|
2346
2549
|
return [...this.native.objectStoreNames];
|
|
2347
2550
|
}
|
|
2551
|
+
/** Create read-only transaction. */
|
|
2348
2552
|
read(...names) {
|
|
2349
2553
|
return new $mol_db_transaction(this.native.transaction(names, 'readonly', { durability: 'relaxed' })).stores;
|
|
2350
2554
|
}
|
|
2555
|
+
/** Create read/write transaction. */
|
|
2351
2556
|
change(...names) {
|
|
2352
2557
|
return new $mol_db_transaction(this.native.transaction(names, 'readwrite', { durability: 'relaxed' }));
|
|
2353
2558
|
}
|
|
2559
|
+
/**
|
|
2560
|
+
* Deletes database.
|
|
2561
|
+
* DB can be deleted only after end of all transactions.
|
|
2562
|
+
*/
|
|
2354
2563
|
kill() {
|
|
2355
2564
|
this.native.close();
|
|
2356
2565
|
const request = $mol_dom_context.indexedDB.deleteDatabase(this.name);
|
|
2357
2566
|
request.onblocked = console.warn;
|
|
2358
2567
|
return $mol_db_response(request);
|
|
2359
2568
|
}
|
|
2569
|
+
/**
|
|
2570
|
+
* Closes DB connection.
|
|
2571
|
+
* Connection really be closed only after end of all transactions.
|
|
2572
|
+
*/
|
|
2360
2573
|
destructor() {
|
|
2361
2574
|
this.native.close();
|
|
2362
2575
|
}
|
|
@@ -2368,11 +2581,13 @@ var $;
|
|
|
2368
2581
|
"use strict";
|
|
2369
2582
|
var $;
|
|
2370
2583
|
(function ($) {
|
|
2584
|
+
/** IndexedDB Transaction wrapper. */
|
|
2371
2585
|
class $mol_db_transaction {
|
|
2372
2586
|
native;
|
|
2373
2587
|
constructor(native) {
|
|
2374
2588
|
this.native = native;
|
|
2375
2589
|
}
|
|
2590
|
+
/** Returns dictionary of all existen Stores. */
|
|
2376
2591
|
get stores() {
|
|
2377
2592
|
return new Proxy({}, {
|
|
2378
2593
|
ownKeys: () => [...this.native.objectStoreNames],
|
|
@@ -2382,18 +2597,22 @@ var $;
|
|
|
2382
2597
|
: undefined,
|
|
2383
2598
|
});
|
|
2384
2599
|
}
|
|
2600
|
+
/** Creates new Store */
|
|
2385
2601
|
store_make(name) {
|
|
2386
2602
|
return this.native.db.createObjectStore(name, { autoIncrement: true });
|
|
2387
2603
|
}
|
|
2604
|
+
/** Drops existen Store */
|
|
2388
2605
|
store_drop(name) {
|
|
2389
2606
|
this.native.db.deleteObjectStore(name);
|
|
2390
2607
|
return this;
|
|
2391
2608
|
}
|
|
2609
|
+
/** Instant abort transaction. Any errors aborts transactions automatically. */
|
|
2392
2610
|
abort() {
|
|
2393
2611
|
if (this.native.error)
|
|
2394
2612
|
return;
|
|
2395
2613
|
this.native.abort();
|
|
2396
2614
|
}
|
|
2615
|
+
/** Instant commits transaction. Without errors commit proceed automatically later. */
|
|
2397
2616
|
commit() {
|
|
2398
2617
|
this.native.commit?.();
|
|
2399
2618
|
return new Promise((done, fail) => {
|
|
@@ -2509,18 +2728,34 @@ var $;
|
|
|
2509
2728
|
"use strict";
|
|
2510
2729
|
var $;
|
|
2511
2730
|
(function ($) {
|
|
2731
|
+
/**
|
|
2732
|
+
* Argument must be Truthy
|
|
2733
|
+
* @deprecated use $mol_assert_equal instead
|
|
2734
|
+
*/
|
|
2512
2735
|
function $mol_assert_ok(value) {
|
|
2513
2736
|
if (value)
|
|
2514
2737
|
return;
|
|
2515
2738
|
$mol_fail(new Error(`${value} ≠ true`));
|
|
2516
2739
|
}
|
|
2517
2740
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
2741
|
+
/**
|
|
2742
|
+
* Argument must be Falsy
|
|
2743
|
+
* @deprecated use $mol_assert_equal instead
|
|
2744
|
+
*/
|
|
2518
2745
|
function $mol_assert_not(value) {
|
|
2519
2746
|
if (!value)
|
|
2520
2747
|
return;
|
|
2521
2748
|
$mol_fail(new Error(`${value} ≠ false`));
|
|
2522
2749
|
}
|
|
2523
2750
|
$.$mol_assert_not = $mol_assert_not;
|
|
2751
|
+
/**
|
|
2752
|
+
* Handler must throw an error.
|
|
2753
|
+
* @example
|
|
2754
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } ) // Passes because throws error
|
|
2755
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , 'Parse error' ) // Passes because throws right message
|
|
2756
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , Error ) // Passes because throws right class
|
|
2757
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
2758
|
+
*/
|
|
2524
2759
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
2525
2760
|
const fail = $.$mol_fail;
|
|
2526
2761
|
try {
|
|
@@ -2543,10 +2778,18 @@ var $;
|
|
|
2543
2778
|
$mol_fail(new Error('Not failed', { cause: { expect: ErrorRight } }));
|
|
2544
2779
|
}
|
|
2545
2780
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
2781
|
+
/** @deprecated Use $mol_assert_equal */
|
|
2546
2782
|
function $mol_assert_like(...args) {
|
|
2547
2783
|
$mol_assert_equal(...args);
|
|
2548
2784
|
}
|
|
2549
2785
|
$.$mol_assert_like = $mol_assert_like;
|
|
2786
|
+
/**
|
|
2787
|
+
* All arguments must not be structural equal to each other.
|
|
2788
|
+
* @example
|
|
2789
|
+
* $mol_assert_unique( 1 , 2 , 3 ) // Passes
|
|
2790
|
+
* $mol_assert_unique( 1 , 1 , 2 ) // Fails because 1 === 1
|
|
2791
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
2792
|
+
*/
|
|
2550
2793
|
function $mol_assert_unique(...args) {
|
|
2551
2794
|
for (let i = 0; i < args.length; ++i) {
|
|
2552
2795
|
for (let j = 0; j < args.length; ++j) {
|
|
@@ -2559,6 +2802,13 @@ var $;
|
|
|
2559
2802
|
}
|
|
2560
2803
|
}
|
|
2561
2804
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
2805
|
+
/**
|
|
2806
|
+
* All arguments must be structural equal each other.
|
|
2807
|
+
* @example
|
|
2808
|
+
* $mol_assert_like( [1] , [1] , [1] ) // Passes
|
|
2809
|
+
* $mol_assert_like( [1] , [1] , [2] ) // Fails because 1 !== 2
|
|
2810
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
2811
|
+
*/
|
|
2562
2812
|
function $mol_assert_equal(...args) {
|
|
2563
2813
|
for (let i = 1; i < args.length; ++i) {
|
|
2564
2814
|
if ($mol_compare_deep(args[0], args[i]))
|
|
@@ -2615,6 +2865,12 @@ var $;
|
|
|
2615
2865
|
'return result without errors'() {
|
|
2616
2866
|
$mol_assert_equal($mol_try(() => false), false);
|
|
2617
2867
|
},
|
|
2868
|
+
//'return error if thrown'() {
|
|
2869
|
+
//
|
|
2870
|
+
// const error = new Error( '$mol_try test error' )
|
|
2871
|
+
// $mol_assert_equal( $mol_try( ()=> { throw error } ) , error )
|
|
2872
|
+
//
|
|
2873
|
+
//} ,
|
|
2618
2874
|
});
|
|
2619
2875
|
})($ || ($ = {}));
|
|
2620
2876
|
|
|
@@ -3123,6 +3379,7 @@ var $;
|
|
|
3123
3379
|
"use strict";
|
|
3124
3380
|
var $;
|
|
3125
3381
|
(function ($) {
|
|
3382
|
+
/// @todo right orderinng
|
|
3126
3383
|
$.$mol_after_mock_queue = [];
|
|
3127
3384
|
function $mol_after_mock_warp() {
|
|
3128
3385
|
const queue = $.$mol_after_mock_queue.splice(0);
|
|
@@ -3252,6 +3509,7 @@ var $;
|
|
|
3252
3509
|
"use strict";
|
|
3253
3510
|
var $;
|
|
3254
3511
|
(function ($) {
|
|
3512
|
+
/** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
|
|
3255
3513
|
function $mol_wire_async(obj) {
|
|
3256
3514
|
let fiber;
|
|
3257
3515
|
const temp = $mol_wire_task.getter(obj);
|
|
@@ -3335,6 +3593,9 @@ var $;
|
|
|
3335
3593
|
"use strict";
|
|
3336
3594
|
var $;
|
|
3337
3595
|
(function ($) {
|
|
3596
|
+
/**
|
|
3597
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber.
|
|
3598
|
+
*/
|
|
3338
3599
|
function $mol_wire_method(host, field, descr) {
|
|
3339
3600
|
if (!descr)
|
|
3340
3601
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -3745,6 +4006,12 @@ var $;
|
|
|
3745
4006
|
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
3746
4007
|
};
|
|
3747
4008
|
$.$mol_jsx_frag = '';
|
|
4009
|
+
/**
|
|
4010
|
+
* JSX adapter that makes DOM tree.
|
|
4011
|
+
* Generates global unique ids for every DOM-element by components tree with ids.
|
|
4012
|
+
* Ensures all local ids are unique.
|
|
4013
|
+
* Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
|
|
4014
|
+
*/
|
|
3748
4015
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
3749
4016
|
const id = props && props.id || '';
|
|
3750
4017
|
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
@@ -3855,6 +4122,8 @@ var $;
|
|
|
3855
4122
|
|
|
3856
4123
|
;
|
|
3857
4124
|
"use strict";
|
|
4125
|
+
/** @jsx $mol_jsx */
|
|
4126
|
+
/** @jsxFrag $mol_jsx_frag */
|
|
3858
4127
|
var $;
|
|
3859
4128
|
(function ($) {
|
|
3860
4129
|
$mol_test({
|
|
@@ -3960,6 +4229,7 @@ var $;
|
|
|
3960
4229
|
"use strict";
|
|
3961
4230
|
var $;
|
|
3962
4231
|
(function ($) {
|
|
4232
|
+
/** Lazy computed lists with native Array interface. $mol_range2_array is mutable but all derived ranges are immutable. */
|
|
3963
4233
|
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
3964
4234
|
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
3965
4235
|
if (typeof item !== 'function') {
|
|
@@ -4008,6 +4278,7 @@ var $;
|
|
|
4008
4278
|
}
|
|
4009
4279
|
$.$mol_range2 = $mol_range2;
|
|
4010
4280
|
class $mol_range2_array extends Array {
|
|
4281
|
+
// Lazy
|
|
4011
4282
|
concat(...tail) {
|
|
4012
4283
|
if (tail.length === 0)
|
|
4013
4284
|
return this;
|
|
@@ -4019,6 +4290,7 @@ var $;
|
|
|
4019
4290
|
}
|
|
4020
4291
|
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
4021
4292
|
}
|
|
4293
|
+
// Lazy
|
|
4022
4294
|
filter(check, context) {
|
|
4023
4295
|
const filtered = [];
|
|
4024
4296
|
let cursor = -1;
|
|
@@ -4031,13 +4303,16 @@ var $;
|
|
|
4031
4303
|
return filtered[index];
|
|
4032
4304
|
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
4033
4305
|
}
|
|
4306
|
+
// Diligent
|
|
4034
4307
|
forEach(proceed, context) {
|
|
4035
4308
|
for (let [key, value] of this.entries())
|
|
4036
4309
|
proceed.call(context, value, key, this);
|
|
4037
4310
|
}
|
|
4311
|
+
// Lazy
|
|
4038
4312
|
map(proceed, context) {
|
|
4039
4313
|
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
4040
4314
|
}
|
|
4315
|
+
// Diligent
|
|
4041
4316
|
reduce(merge, result) {
|
|
4042
4317
|
let index = 0;
|
|
4043
4318
|
if (arguments.length === 1) {
|
|
@@ -4048,12 +4323,15 @@ var $;
|
|
|
4048
4323
|
}
|
|
4049
4324
|
return result;
|
|
4050
4325
|
}
|
|
4326
|
+
// Lazy
|
|
4051
4327
|
toReversed() {
|
|
4052
4328
|
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
4053
4329
|
}
|
|
4330
|
+
// Lazy
|
|
4054
4331
|
slice(from = 0, to = this.length) {
|
|
4055
4332
|
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
4056
4333
|
}
|
|
4334
|
+
// Lazy
|
|
4057
4335
|
some(check, context) {
|
|
4058
4336
|
for (let index = 0; index < this.length; ++index) {
|
|
4059
4337
|
if (check.call(context, this[index], index, this))
|
|
@@ -4246,6 +4524,7 @@ var $;
|
|
|
4246
4524
|
|
|
4247
4525
|
;
|
|
4248
4526
|
"use strict";
|
|
4527
|
+
/** @jsx $mol_jsx */
|
|
4249
4528
|
var $;
|
|
4250
4529
|
(function ($) {
|
|
4251
4530
|
$mol_test({
|
|
@@ -4307,6 +4586,7 @@ var $;
|
|
|
4307
4586
|
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
4308
4587
|
obj1.obj3 = obj3;
|
|
4309
4588
|
obj1_copy.obj3 = obj3_copy;
|
|
4589
|
+
// warmup cache
|
|
4310
4590
|
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
4311
4591
|
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
4312
4592
|
$mol_assert_not($mol_compare_deep(obj3, {}));
|