mol_db 0.0.45

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 ADDED
@@ -0,0 +1,1962 @@
1
+ "use strict";
2
+ "use strict"
3
+
4
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ };
10
+
11
+ var globalThis = globalThis || ( typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this )
12
+ var $ = ( typeof module === 'object' ) ? Object.setPrototypeOf( module['export'+'s'] , globalThis ) : globalThis
13
+ $.$$ = $
14
+
15
+ ;
16
+ "use strict";
17
+ Error.stackTraceLimit = 50;
18
+ var $;
19
+ (function ($) {
20
+ })($ || ($ = {}));
21
+ module.exports = $;
22
+ //mam.js.map
23
+ ;
24
+ "use strict";
25
+ var $;
26
+ (function ($) {
27
+ function $mol_db_response(request) {
28
+ return new Promise((done, fail) => {
29
+ request.onerror = () => fail(new Error(request.error.message));
30
+ request.onsuccess = () => done(request.result);
31
+ });
32
+ }
33
+ $.$mol_db_response = $mol_db_response;
34
+ })($ || ($ = {}));
35
+ //response.js.map
36
+ ;
37
+ "use strict";
38
+ var $;
39
+ (function ($) {
40
+ class $mol_db_store {
41
+ native;
42
+ constructor(native) {
43
+ this.native = native;
44
+ }
45
+ get name() {
46
+ return this.native.name;
47
+ }
48
+ get path() {
49
+ return this.native.keyPath;
50
+ }
51
+ get incremental() {
52
+ return this.native.autoIncrement;
53
+ }
54
+ get indexes() {
55
+ return new Proxy({}, {
56
+ ownKeys: () => [...this.native.indexNames],
57
+ has: (_, name) => this.native.indexNames.contains(name),
58
+ get: (_, name) => new $.$mol_db_index(this.native.index(name))
59
+ });
60
+ }
61
+ index_make(name, path = [], unique = false, multiEntry = false) {
62
+ return this.native.createIndex(name, path, { multiEntry, unique });
63
+ }
64
+ index_drop(name) {
65
+ this.native.deleteIndex(name);
66
+ return this;
67
+ }
68
+ get transaction() {
69
+ return new $.$mol_db_transaction(this.native.transaction);
70
+ }
71
+ get db() {
72
+ return this.transaction.db;
73
+ }
74
+ clear() {
75
+ return $.$mol_db_response(this.native.clear());
76
+ }
77
+ count(keys) {
78
+ return $.$mol_db_response(this.native.count(keys));
79
+ }
80
+ put(doc, key) {
81
+ return $.$mol_db_response(this.native.put(doc, key));
82
+ }
83
+ get(key) {
84
+ return $.$mol_db_response(this.native.get(key));
85
+ }
86
+ select(key, count) {
87
+ return $.$mol_db_response(this.native.getAll(key, count));
88
+ }
89
+ drop(keys) {
90
+ return $.$mol_db_response(this.native.delete(keys));
91
+ }
92
+ }
93
+ $.$mol_db_store = $mol_db_store;
94
+ })($ || ($ = {}));
95
+ //store.js.map
96
+ ;
97
+ "use strict";
98
+ //store_schema.js.map
99
+ ;
100
+ "use strict";
101
+ var $;
102
+ (function ($) {
103
+ async function $mol_db(name, ...migrations) {
104
+ const request = this.indexedDB.open(name, migrations.length ? migrations.length + 1 : undefined);
105
+ request.onupgradeneeded = event => {
106
+ migrations.splice(0, event.oldVersion - 1);
107
+ const transaction = new $.$mol_db_transaction(request.transaction);
108
+ for (const migrate of migrations)
109
+ migrate(transaction);
110
+ };
111
+ const db = await $.$mol_db_response(request);
112
+ return new $.$mol_db_database(db);
113
+ }
114
+ $.$mol_db = $mol_db;
115
+ })($ || ($ = {}));
116
+ //db.js.map
117
+ ;
118
+ "use strict";
119
+ //db_schema.js.map
120
+ ;
121
+ "use strict";
122
+ var $;
123
+ (function ($) {
124
+ class $mol_db_database {
125
+ native;
126
+ constructor(native) {
127
+ this.native = native;
128
+ }
129
+ get name() {
130
+ return this.native.name;
131
+ }
132
+ get version() {
133
+ return this.native.version;
134
+ }
135
+ get stores() {
136
+ return [...this.native.objectStoreNames];
137
+ }
138
+ read(...names) {
139
+ return new $.$mol_db_transaction(this.native.transaction(names, 'readonly')).stores;
140
+ }
141
+ change(...names) {
142
+ return new $.$mol_db_transaction(this.native.transaction(names, 'readwrite'));
143
+ }
144
+ kill() {
145
+ this.native.close();
146
+ const request = indexedDB.deleteDatabase(this.name);
147
+ request.onblocked = console.error;
148
+ return $.$mol_db_response(request).then(() => { });
149
+ }
150
+ destructor() {
151
+ this.native.close();
152
+ }
153
+ }
154
+ $.$mol_db_database = $mol_db_database;
155
+ })($ || ($ = {}));
156
+ //database.js.map
157
+ ;
158
+ "use strict";
159
+ var $;
160
+ (function ($) {
161
+ class $mol_db_transaction {
162
+ native;
163
+ constructor(native) {
164
+ this.native = native;
165
+ }
166
+ get stores() {
167
+ return new Proxy({}, {
168
+ ownKeys: () => [...this.native.objectStoreNames],
169
+ has: (_, name) => this.native.objectStoreNames.contains(name),
170
+ get: (_, name) => new $.$mol_db_store(this.native.objectStore(name)),
171
+ });
172
+ }
173
+ store_make(name) {
174
+ return this.native.db.createObjectStore(name, { autoIncrement: true });
175
+ }
176
+ store_drop(name) {
177
+ this.native.db.deleteObjectStore(name);
178
+ return this;
179
+ }
180
+ abort() {
181
+ this.native.abort();
182
+ }
183
+ commit() {
184
+ this.native.commit();
185
+ return new Promise((done, fail) => {
186
+ this.native.onerror = () => fail(new Error(this.native.error.message));
187
+ this.native.oncomplete = () => done();
188
+ });
189
+ }
190
+ get db() {
191
+ return new $.$mol_db_database(this.native.db);
192
+ }
193
+ }
194
+ $.$mol_db_transaction = $mol_db_transaction;
195
+ })($ || ($ = {}));
196
+ //transaction.js.map
197
+ ;
198
+ "use strict";
199
+ var $;
200
+ (function ($) {
201
+ class $mol_db_index {
202
+ native;
203
+ constructor(native) {
204
+ this.native = native;
205
+ }
206
+ get name() {
207
+ return this.native.name;
208
+ }
209
+ get paths() {
210
+ return this.native.keyPath;
211
+ }
212
+ get unique() {
213
+ return this.native.unique;
214
+ }
215
+ get multiple() {
216
+ return this.native.multiEntry;
217
+ }
218
+ get store() {
219
+ return new $.$mol_db_store(this.native.objectStore);
220
+ }
221
+ get transaction() {
222
+ return this.store.transaction;
223
+ }
224
+ get db() {
225
+ return this.store.db;
226
+ }
227
+ count(keys) {
228
+ return $.$mol_db_response(this.native.count(keys));
229
+ }
230
+ get(key) {
231
+ return $.$mol_db_response(this.native.get(key));
232
+ }
233
+ select(key, count) {
234
+ return $.$mol_db_response(this.native.getAll(key, count));
235
+ }
236
+ }
237
+ $.$mol_db_index = $mol_db_index;
238
+ })($ || ($ = {}));
239
+ //index.js.map
240
+ ;
241
+ "use strict";
242
+ //index_schema.js.map
243
+ ;
244
+ "use strict";
245
+ var $;
246
+ (function ($) {
247
+ function $mol_fail(error) {
248
+ throw error;
249
+ }
250
+ $.$mol_fail = $mol_fail;
251
+ })($ || ($ = {}));
252
+ //fail.js.map
253
+ ;
254
+ "use strict";
255
+ var $;
256
+ (function ($) {
257
+ function $mol_fail_hidden(error) {
258
+ throw error;
259
+ }
260
+ $.$mol_fail_hidden = $mol_fail_hidden;
261
+ })($ || ($ = {}));
262
+ //hidden.js.map
263
+ ;
264
+ "use strict";
265
+ var $;
266
+ (function ($) {
267
+ function $mol_test_complete() {
268
+ process.exit(0);
269
+ }
270
+ $.$mol_test_complete = $mol_test_complete;
271
+ })($ || ($ = {}));
272
+ //test.node.test.js.map
273
+ ;
274
+ "use strict";
275
+ var $;
276
+ (function ($_1) {
277
+ function $mol_test(set) {
278
+ for (let name in set) {
279
+ const code = set[name];
280
+ const test = (typeof code === 'string') ? new Function('', code) : code;
281
+ $_1.$mol_test_all.push(test);
282
+ }
283
+ $mol_test_schedule();
284
+ }
285
+ $_1.$mol_test = $mol_test;
286
+ $_1.$mol_test_mocks = [];
287
+ $_1.$mol_test_all = [];
288
+ async function $mol_test_run() {
289
+ for (var test of $_1.$mol_test_all) {
290
+ let context = Object.create($_1.$$);
291
+ for (let mock of $_1.$mol_test_mocks)
292
+ await mock(context);
293
+ await test(context);
294
+ }
295
+ $_1.$$.$mol_log3_done({
296
+ place: '$mol_test',
297
+ message: 'All tests passed',
298
+ count: $_1.$mol_test_all.length,
299
+ });
300
+ }
301
+ $_1.$mol_test_run = $mol_test_run;
302
+ let scheduled = false;
303
+ function $mol_test_schedule() {
304
+ if (scheduled)
305
+ return;
306
+ scheduled = true;
307
+ setTimeout(async () => {
308
+ scheduled = false;
309
+ try {
310
+ await $mol_test_run();
311
+ }
312
+ finally {
313
+ $_1.$$.$mol_test_complete();
314
+ }
315
+ }, 0);
316
+ }
317
+ $_1.$mol_test_schedule = $mol_test_schedule;
318
+ $_1.$mol_test_mocks.push(context => {
319
+ let seed = 0;
320
+ context.Math = Object.create(Math);
321
+ context.Math.random = () => Math.sin(seed++);
322
+ const forbidden = ['XMLHttpRequest', 'fetch'];
323
+ for (let api of forbidden) {
324
+ context[api] = new Proxy(function () { }, {
325
+ get() {
326
+ $_1.$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
327
+ },
328
+ apply() {
329
+ $_1.$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
330
+ },
331
+ });
332
+ }
333
+ });
334
+ $mol_test({
335
+ 'mocked Math.random'($) {
336
+ console.assert($.Math.random() === 0);
337
+ console.assert($.Math.random() === Math.sin(1));
338
+ },
339
+ 'forbidden XMLHttpRequest'($) {
340
+ try {
341
+ console.assert(void new $.XMLHttpRequest);
342
+ }
343
+ catch (error) {
344
+ console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
345
+ }
346
+ },
347
+ 'forbidden fetch'($) {
348
+ try {
349
+ console.assert(void $.fetch(''));
350
+ }
351
+ catch (error) {
352
+ console.assert(error.message === 'fetch is forbidden in tests');
353
+ }
354
+ },
355
+ });
356
+ })($ || ($ = {}));
357
+ //test.test.js.map
358
+ ;
359
+ "use strict";
360
+ var $;
361
+ (function ($) {
362
+ })($ || ($ = {}));
363
+ //context.js.map
364
+ ;
365
+ "use strict";
366
+ //node.js.map
367
+ ;
368
+ "use strict";
369
+ var $node = new Proxy({ require }, {
370
+ get(target, name, wrapper) {
371
+ if (target[name])
372
+ return target[name];
373
+ const mod = target.require('module');
374
+ if (mod.builtinModules.indexOf(name) >= 0)
375
+ return target.require(name);
376
+ const path = target.require('path');
377
+ const fs = target.require('fs');
378
+ let dir = path.resolve('.');
379
+ const suffix = `./node_modules/${name}`;
380
+ const $$ = $;
381
+ while (!fs.existsSync(path.join(dir, suffix))) {
382
+ const parent = path.resolve(dir, '..');
383
+ if (parent === dir) {
384
+ $$.$mol_exec('.', 'npm', 'install', name);
385
+ try {
386
+ $$.$mol_exec('.', 'npm', 'install', '@types/' + name);
387
+ }
388
+ catch { }
389
+ break;
390
+ }
391
+ else {
392
+ dir = parent;
393
+ }
394
+ }
395
+ return target.require(name);
396
+ },
397
+ set(target, name, value) {
398
+ target[name] = value;
399
+ return true;
400
+ },
401
+ });
402
+ require = (req => Object.assign(function require(name) {
403
+ return $node[name];
404
+ }, req))(require);
405
+ //node.node.js.map
406
+ ;
407
+ "use strict";
408
+ var $;
409
+ (function ($) {
410
+ $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
411
+ })($ || ($ = {}));
412
+ //context.node.js.map
413
+ ;
414
+ "use strict";
415
+ var $;
416
+ (function ($) {
417
+ function $mol_dom_render_children(el, childNodes) {
418
+ const node_set = new Set(childNodes);
419
+ let nextNode = el.firstChild;
420
+ for (let view of childNodes) {
421
+ if (view == null)
422
+ continue;
423
+ if (view instanceof $.$mol_dom_context.Node) {
424
+ while (true) {
425
+ if (!nextNode) {
426
+ el.appendChild(view);
427
+ break;
428
+ }
429
+ if (nextNode == view) {
430
+ nextNode = nextNode.nextSibling;
431
+ break;
432
+ }
433
+ else {
434
+ if (node_set.has(nextNode)) {
435
+ el.insertBefore(view, nextNode);
436
+ break;
437
+ }
438
+ else {
439
+ const nn = nextNode.nextSibling;
440
+ el.removeChild(nextNode);
441
+ nextNode = nn;
442
+ }
443
+ }
444
+ }
445
+ }
446
+ else {
447
+ if (nextNode && nextNode.nodeName === '#text') {
448
+ const str = String(view);
449
+ if (nextNode.nodeValue !== str)
450
+ nextNode.nodeValue = str;
451
+ nextNode = nextNode.nextSibling;
452
+ }
453
+ else {
454
+ const textNode = $.$mol_dom_context.document.createTextNode(String(view));
455
+ el.insertBefore(textNode, nextNode);
456
+ }
457
+ }
458
+ }
459
+ while (nextNode) {
460
+ const currNode = nextNode;
461
+ nextNode = currNode.nextSibling;
462
+ el.removeChild(currNode);
463
+ }
464
+ }
465
+ $.$mol_dom_render_children = $mol_dom_render_children;
466
+ })($ || ($ = {}));
467
+ //children.js.map
468
+ ;
469
+ "use strict";
470
+ //error.js.map
471
+ ;
472
+ "use strict";
473
+ //assert.test.js.map
474
+ ;
475
+ "use strict";
476
+ //assert.js.map
477
+ ;
478
+ "use strict";
479
+ //deep.test.js.map
480
+ ;
481
+ "use strict";
482
+ //deep.js.map
483
+ ;
484
+ "use strict";
485
+ var $;
486
+ (function ($) {
487
+ $.$mol_test({
488
+ 'Make empty div'() {
489
+ $.$mol_assert_equal(($.$mol_jsx("div", null)).outerHTML, '<div></div>');
490
+ },
491
+ 'Define native field'() {
492
+ const dom = $.$mol_jsx("input", { value: '123' });
493
+ $.$mol_assert_equal(dom.outerHTML, '<input value="123">');
494
+ $.$mol_assert_equal(dom.value, '123');
495
+ },
496
+ 'Define classes'() {
497
+ const dom = $.$mol_jsx("div", { class: 'foo bar' });
498
+ $.$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
499
+ },
500
+ 'Define styles'() {
501
+ const dom = $.$mol_jsx("div", { style: { color: 'red' } });
502
+ $.$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
503
+ },
504
+ 'Define dataset'() {
505
+ const dom = $.$mol_jsx("div", { dataset: { foo: 'bar' } });
506
+ $.$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
507
+ },
508
+ 'Define attributes'() {
509
+ const dom = $.$mol_jsx("div", { lang: "ru", hidden: true });
510
+ $.$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
511
+ },
512
+ 'Define child nodes'() {
513
+ const dom = $.$mol_jsx("div", null,
514
+ "hello",
515
+ $.$mol_jsx("strong", null, "world"),
516
+ "!");
517
+ $.$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
518
+ },
519
+ 'Function as component'() {
520
+ const Button = ({ hint }, target) => {
521
+ return $.$mol_jsx("button", { title: hint }, target());
522
+ };
523
+ const dom = $.$mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
524
+ $.$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
525
+ },
526
+ 'Nested guid generation'() {
527
+ const Foo = () => {
528
+ return $.$mol_jsx("div", null,
529
+ $.$mol_jsx(Bar, { id: "/bar" },
530
+ $.$mol_jsx("img", { id: "/icon" })));
531
+ };
532
+ const Bar = (props, icon) => {
533
+ return $.$mol_jsx("span", null, icon);
534
+ };
535
+ const dom = $.$mol_jsx(Foo, { id: "/foo" });
536
+ $.$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
537
+ },
538
+ 'Fail on non unique ids'() {
539
+ const App = () => {
540
+ return $.$mol_jsx("div", null,
541
+ $.$mol_jsx("span", { id: "/bar" }),
542
+ $.$mol_jsx("span", { id: "/bar" }));
543
+ };
544
+ $.$mol_assert_fail(() => $.$mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
545
+ },
546
+ });
547
+ })($ || ($ = {}));
548
+ //jsx.test.js.map
549
+ ;
550
+ "use strict";
551
+ var $;
552
+ (function ($) {
553
+ $.$mol_jsx_prefix = '';
554
+ $.$mol_jsx_booked = null;
555
+ $.$mol_jsx_document = {
556
+ getElementById: () => null,
557
+ createElementNS: (space, name) => $.$mol_dom_context.document.createElementNS(space, name),
558
+ createDocumentFragment: () => $.$mol_dom_context.document.createDocumentFragment(),
559
+ };
560
+ $.$mol_jsx_frag = '';
561
+ function $mol_jsx(Elem, props, ...childNodes) {
562
+ const id = props && props.id || '';
563
+ if (Elem && $.$mol_jsx_booked) {
564
+ if ($.$mol_jsx_booked.has(id)) {
565
+ $.$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
566
+ }
567
+ else {
568
+ $.$mol_jsx_booked.add(id);
569
+ }
570
+ }
571
+ const guid = $.$mol_jsx_prefix + id;
572
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
573
+ if (typeof Elem !== 'string') {
574
+ if ('prototype' in Elem) {
575
+ const view = node && node[Elem] || new Elem;
576
+ Object.assign(view, props);
577
+ view[Symbol.toStringTag] = guid;
578
+ view.childNodes = childNodes;
579
+ if (!view.ownerDocument)
580
+ view.ownerDocument = $.$mol_jsx_document;
581
+ node = view.valueOf();
582
+ node[Elem] = view;
583
+ return node;
584
+ }
585
+ else {
586
+ const prefix = $.$mol_jsx_prefix;
587
+ const booked = $.$mol_jsx_booked;
588
+ try {
589
+ $.$mol_jsx_prefix = guid;
590
+ $.$mol_jsx_booked = new Set;
591
+ return Elem(props, ...childNodes);
592
+ }
593
+ finally {
594
+ $.$mol_jsx_prefix = prefix;
595
+ $.$mol_jsx_booked = booked;
596
+ }
597
+ }
598
+ }
599
+ if (!node) {
600
+ node = Elem
601
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
602
+ : $.$mol_jsx_document.createDocumentFragment();
603
+ }
604
+ $.$mol_dom_render_children(node, [].concat(...childNodes));
605
+ if (!Elem)
606
+ return node;
607
+ for (const key in props) {
608
+ if (typeof props[key] === 'string') {
609
+ ;
610
+ node.setAttribute(key, props[key]);
611
+ }
612
+ else if (props[key] &&
613
+ typeof props[key] === 'object' &&
614
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
615
+ if (typeof node[key] === 'object') {
616
+ Object.assign(node[key], props[key]);
617
+ continue;
618
+ }
619
+ }
620
+ else {
621
+ node[key] = props[key];
622
+ }
623
+ }
624
+ if (guid)
625
+ node.id = guid;
626
+ return node;
627
+ }
628
+ $.$mol_jsx = $mol_jsx;
629
+ })($ || ($ = {}));
630
+ //jsx.js.map
631
+ ;
632
+ "use strict";
633
+ var $;
634
+ (function ($) {
635
+ $.$mol_test({
636
+ 'nulls & undefineds'() {
637
+ $.$mol_assert_ok($.$mol_compare_deep(null, null));
638
+ $.$mol_assert_ok($.$mol_compare_deep(undefined, undefined));
639
+ $.$mol_assert_not($.$mol_compare_deep(undefined, null));
640
+ $.$mol_assert_not($.$mol_compare_deep({}, null));
641
+ },
642
+ 'number'() {
643
+ $.$mol_assert_ok($.$mol_compare_deep(1, 1));
644
+ $.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
645
+ $.$mol_assert_not($.$mol_compare_deep(1, 2));
646
+ },
647
+ 'Number'() {
648
+ $.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
649
+ $.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
650
+ $.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
651
+ },
652
+ 'empty POJOs'() {
653
+ $.$mol_assert_ok($.$mol_compare_deep({}, {}));
654
+ },
655
+ 'different POJOs'() {
656
+ $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
657
+ },
658
+ 'different POJOs with same keys but different values'() {
659
+ $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
660
+ },
661
+ 'different POJOs with different keys but same values'() {
662
+ $.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
663
+ },
664
+ 'Array'() {
665
+ $.$mol_assert_ok($.$mol_compare_deep([], []));
666
+ $.$mol_assert_ok($.$mol_compare_deep([1, [2]], [1, [2]]));
667
+ $.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
668
+ $.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
669
+ },
670
+ 'same POJO trees'() {
671
+ $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
672
+ },
673
+ 'different classes with same values'() {
674
+ class Obj {
675
+ foo = 1;
676
+ }
677
+ const a = new Obj;
678
+ const b = new class extends Obj {
679
+ };
680
+ $.$mol_assert_not($.$mol_compare_deep(a, b));
681
+ },
682
+ 'same POJOs with cyclic reference'() {
683
+ const a = { foo: {} };
684
+ a['self'] = a;
685
+ const b = { foo: {} };
686
+ b['self'] = b;
687
+ $.$mol_assert_ok($.$mol_compare_deep(a, b));
688
+ },
689
+ 'empty Element'() {
690
+ $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
691
+ $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
692
+ },
693
+ 'Element with attributes'() {
694
+ $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
695
+ $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
696
+ $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
697
+ },
698
+ 'Element with styles'() {
699
+ $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
700
+ $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
701
+ $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
702
+ },
703
+ 'Element with content'() {
704
+ $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
705
+ "foo",
706
+ $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
707
+ "foo",
708
+ $.$mol_jsx("br", null))));
709
+ $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
710
+ "foo",
711
+ $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
712
+ "bar",
713
+ $.$mol_jsx("br", null))));
714
+ $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
715
+ "foo",
716
+ $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
717
+ "foo",
718
+ $.$mol_jsx("hr", null))));
719
+ },
720
+ 'Element with handlers'() {
721
+ $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
722
+ $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
723
+ },
724
+ 'Date'() {
725
+ $.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
726
+ $.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
727
+ },
728
+ 'RegExp'() {
729
+ $.$mol_assert_ok($.$mol_compare_deep(/\x22/mig, /\x22/mig));
730
+ $.$mol_assert_not($.$mol_compare_deep(/\x22/mig, /\x21/mig));
731
+ $.$mol_assert_not($.$mol_compare_deep(/\x22/mig, /\x22/mg));
732
+ },
733
+ 'Map'() {
734
+ $.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
735
+ $.$mol_assert_ok($.$mol_compare_deep(new Map([[[1], [2]]]), new Map([[[1], [2]]])));
736
+ $.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
737
+ },
738
+ 'Set'() {
739
+ $.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
740
+ $.$mol_assert_ok($.$mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
741
+ $.$mol_assert_not($.$mol_compare_deep(new Set([1]), new Set([2])));
742
+ },
743
+ 'Uint8Array'() {
744
+ $.$mol_assert_ok($.$mol_compare_deep(new Uint8Array, new Uint8Array));
745
+ $.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
746
+ $.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
747
+ },
748
+ });
749
+ })($ || ($ = {}));
750
+ //deep.test.js.map
751
+ ;
752
+ "use strict";
753
+ var $;
754
+ (function ($) {
755
+ const a_stack = [];
756
+ const b_stack = [];
757
+ let cache = null;
758
+ function $mol_compare_deep(a, b) {
759
+ if (Object.is(a, b))
760
+ return true;
761
+ const a_type = typeof a;
762
+ const b_type = typeof b;
763
+ if (a_type !== b_type)
764
+ return false;
765
+ if (a_type === 'function')
766
+ return a['toString']() === b['toString']();
767
+ if (a_type !== 'object')
768
+ return false;
769
+ if (!a || !b)
770
+ return false;
771
+ if (a instanceof Error)
772
+ return false;
773
+ if (a['constructor'] !== b['constructor'])
774
+ return false;
775
+ if (a instanceof RegExp)
776
+ return a.toString() === b['toString']();
777
+ const ref = a_stack.indexOf(a);
778
+ if (ref >= 0) {
779
+ return Object.is(b_stack[ref], b);
780
+ }
781
+ if (!cache)
782
+ cache = new WeakMap;
783
+ let a_cache = cache.get(a);
784
+ if (a_cache) {
785
+ const b_cache = a_cache.get(b);
786
+ if (typeof b_cache === 'boolean')
787
+ return b_cache;
788
+ }
789
+ else {
790
+ a_cache = new WeakMap();
791
+ cache.set(a, a_cache);
792
+ }
793
+ a_stack.push(a);
794
+ b_stack.push(b);
795
+ let result;
796
+ try {
797
+ if (Symbol.iterator in a) {
798
+ const a_iter = a[Symbol.iterator]();
799
+ const b_iter = b[Symbol.iterator]();
800
+ while (true) {
801
+ const a_next = a_iter.next();
802
+ const b_next = b_iter.next();
803
+ if (a_next.done !== b_next.done)
804
+ return result = false;
805
+ if (a_next.done)
806
+ break;
807
+ if (!$mol_compare_deep(a_next.value, b_next.value))
808
+ return result = false;
809
+ }
810
+ return result = true;
811
+ }
812
+ let count = 0;
813
+ for (let key in a) {
814
+ try {
815
+ if (!$mol_compare_deep(a[key], b[key]))
816
+ return result = false;
817
+ }
818
+ catch (error) {
819
+ $.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
820
+ }
821
+ ++count;
822
+ }
823
+ for (let key in b) {
824
+ --count;
825
+ if (count < 0)
826
+ return result = false;
827
+ }
828
+ if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
829
+ if (!Object.is(a['valueOf'](), b['valueOf']()))
830
+ return result = false;
831
+ }
832
+ return result = true;
833
+ }
834
+ finally {
835
+ a_stack.pop();
836
+ b_stack.pop();
837
+ if (a_stack.length === 0) {
838
+ cache = null;
839
+ }
840
+ else {
841
+ a_cache.set(b, result);
842
+ }
843
+ }
844
+ }
845
+ $.$mol_compare_deep = $mol_compare_deep;
846
+ })($ || ($ = {}));
847
+ //deep.js.map
848
+ ;
849
+ "use strict";
850
+ var $;
851
+ (function ($) {
852
+ $.$mol_test({
853
+ 'must be false'() {
854
+ $.$mol_assert_not(0);
855
+ },
856
+ 'must be true'() {
857
+ $.$mol_assert_ok(1);
858
+ },
859
+ 'two must be equal'() {
860
+ $.$mol_assert_equal(2, 2);
861
+ },
862
+ 'three must be equal'() {
863
+ $.$mol_assert_equal(2, 2, 2);
864
+ },
865
+ 'two must be unique'() {
866
+ $.$mol_assert_unique([3], [3]);
867
+ },
868
+ 'three must be unique'() {
869
+ $.$mol_assert_unique([3], [3], [3]);
870
+ },
871
+ 'two must be alike'() {
872
+ $.$mol_assert_like([3], [3]);
873
+ },
874
+ 'three must be alike'() {
875
+ $.$mol_assert_like([3], [3], [3]);
876
+ },
877
+ });
878
+ })($ || ($ = {}));
879
+ //assert.test.js.map
880
+ ;
881
+ "use strict";
882
+ var $;
883
+ (function ($) {
884
+ function $mol_assert_ok(value) {
885
+ if (value)
886
+ return;
887
+ $.$mol_fail(new Error(`${value} ≠ true`));
888
+ }
889
+ $.$mol_assert_ok = $mol_assert_ok;
890
+ function $mol_assert_not(value) {
891
+ if (!value)
892
+ return;
893
+ $.$mol_fail(new Error(`${value} ≠ false`));
894
+ }
895
+ $.$mol_assert_not = $mol_assert_not;
896
+ function $mol_assert_fail(handler, ErrorRight) {
897
+ const fail = $.$mol_fail;
898
+ try {
899
+ $.$mol_fail = $.$mol_fail_hidden;
900
+ handler();
901
+ }
902
+ catch (error) {
903
+ if (!ErrorRight)
904
+ return error;
905
+ $.$mol_fail = fail;
906
+ if (typeof ErrorRight === 'string') {
907
+ $mol_assert_equal(error.message, ErrorRight);
908
+ }
909
+ else {
910
+ $mol_assert_ok(error instanceof ErrorRight);
911
+ }
912
+ return error;
913
+ }
914
+ finally {
915
+ $.$mol_fail = fail;
916
+ }
917
+ $.$mol_fail(new Error('Not failed'));
918
+ }
919
+ $.$mol_assert_fail = $mol_assert_fail;
920
+ function $mol_assert_equal(...args) {
921
+ for (let i = 0; i < args.length; ++i) {
922
+ for (let j = 0; j < args.length; ++j) {
923
+ if (i === j)
924
+ continue;
925
+ if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
926
+ continue;
927
+ if (args[i] !== args[j])
928
+ $.$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
929
+ }
930
+ }
931
+ }
932
+ $.$mol_assert_equal = $mol_assert_equal;
933
+ function $mol_assert_unique(...args) {
934
+ for (let i = 0; i < args.length; ++i) {
935
+ for (let j = 0; j < args.length; ++j) {
936
+ if (i === j)
937
+ continue;
938
+ if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
939
+ $.$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
940
+ }
941
+ }
942
+ }
943
+ }
944
+ $.$mol_assert_unique = $mol_assert_unique;
945
+ function $mol_assert_like(head, ...tail) {
946
+ for (let [index, value] of Object.entries(tail)) {
947
+ if (!$.$mol_compare_deep(value, head)) {
948
+ const print = (val) => {
949
+ if (!val)
950
+ return val;
951
+ if (typeof val !== 'object')
952
+ return val;
953
+ if ('outerHTML' in val)
954
+ return val.outerHTML;
955
+ try {
956
+ return JSON.stringify(val);
957
+ }
958
+ catch (error) {
959
+ console.error(error);
960
+ return val;
961
+ }
962
+ };
963
+ return $.$mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
964
+ }
965
+ }
966
+ }
967
+ $.$mol_assert_like = $mol_assert_like;
968
+ })($ || ($ = {}));
969
+ //assert.js.map
970
+ ;
971
+ "use strict";
972
+ var $;
973
+ (function ($) {
974
+ $.$mol_test({
975
+ async 'put, get, drop, count records and clear store'() {
976
+ const db = await $.$$.$mol_db('$mol_db_test', mig => mig.store_make('letters'));
977
+ const trans = db.change('letters');
978
+ try {
979
+ const { letters } = trans.stores;
980
+ $.$mol_assert_like(await letters.get(1), undefined);
981
+ $.$mol_assert_like(await letters.get(2), undefined);
982
+ $.$mol_assert_like(await letters.count(), 0);
983
+ await letters.put('a');
984
+ await letters.put('b', 1);
985
+ await letters.put('c', 2);
986
+ $.$mol_assert_like(await letters.get(1), 'b');
987
+ $.$mol_assert_like(await letters.get(2), 'c');
988
+ $.$mol_assert_like(await letters.count(), 2);
989
+ await letters.drop(1);
990
+ $.$mol_assert_like(await letters.get(1), undefined);
991
+ $.$mol_assert_like(await letters.count(), 1);
992
+ await letters.clear();
993
+ $.$mol_assert_like(await letters.count(), 0);
994
+ }
995
+ finally {
996
+ trans.abort();
997
+ db.kill();
998
+ }
999
+ },
1000
+ async 'select by query'() {
1001
+ const db = await $.$$.$mol_db('$mol_db_test', mig => mig.store_make('letters'));
1002
+ const trans = db.change('letters');
1003
+ try {
1004
+ const { letters } = trans.stores;
1005
+ await letters.put('a');
1006
+ await letters.put('b');
1007
+ await letters.put('c');
1008
+ await letters.put('d');
1009
+ $.$mol_assert_like(await letters.select(), ['a', 'b', 'c', 'd']);
1010
+ $.$mol_assert_like(await letters.select(null, 2), ['a', 'b']);
1011
+ $.$mol_assert_like(await letters.select(IDBKeyRange.bound(2, 3)), ['b', 'c']);
1012
+ }
1013
+ finally {
1014
+ trans.abort();
1015
+ db.kill();
1016
+ }
1017
+ },
1018
+ });
1019
+ })($ || ($ = {}));
1020
+ //store.test.js.map
1021
+ ;
1022
+ "use strict";
1023
+ var $;
1024
+ (function ($) {
1025
+ $.$mol_test({
1026
+ async 'take and drop db'() {
1027
+ const db = await $.$$.$mol_db('$mol_db_test');
1028
+ await db.kill();
1029
+ },
1030
+ async 'make and drop store in separate migrations'() {
1031
+ try {
1032
+ const db1 = await $.$$.$mol_db('$mol_db_test', mig => mig.store_make('temp'));
1033
+ db1.destructor();
1034
+ $.$mol_assert_like(db1.stores, ['temp']);
1035
+ $.$mol_assert_like(db1.version, 2);
1036
+ const db2 = await $.$$.$mol_db('$mol_db_test', mig => mig.store_make('temp'), mig => mig.store_drop('temp'));
1037
+ db2.destructor();
1038
+ $.$mol_assert_like(db2.stores, []);
1039
+ $.$mol_assert_like(db2.version, 3);
1040
+ }
1041
+ finally {
1042
+ const db0 = await $.$$.$mol_db('$mol_db_test');
1043
+ await db0.kill();
1044
+ }
1045
+ },
1046
+ });
1047
+ })($ || ($ = {}));
1048
+ //db.test.js.map
1049
+ ;
1050
+ "use strict";
1051
+ var $;
1052
+ (function ($) {
1053
+ function $mol_log3_area_lazy(event) {
1054
+ const self = this;
1055
+ const stack = self.$mol_log3_stack;
1056
+ const deep = stack.length;
1057
+ let logged = false;
1058
+ stack.push(() => {
1059
+ logged = true;
1060
+ self.$mol_log3_area.call(self, event);
1061
+ });
1062
+ return () => {
1063
+ if (logged)
1064
+ self.console.groupEnd();
1065
+ if (stack.length > deep)
1066
+ stack.length = deep;
1067
+ };
1068
+ }
1069
+ $.$mol_log3_area_lazy = $mol_log3_area_lazy;
1070
+ $.$mol_log3_stack = [];
1071
+ })($ || ($ = {}));
1072
+ //log3.js.map
1073
+ ;
1074
+ "use strict";
1075
+ var $;
1076
+ (function ($) {
1077
+ function $mol_log3_node_make(level, output, type, color) {
1078
+ return function $mol_log3_logger(event) {
1079
+ if (!event.time)
1080
+ event = { time: new Date().toISOString(), ...event };
1081
+ const tree = this.$mol_tree.fromJSON(event).clone({ type });
1082
+ let str = tree.toString();
1083
+ if (process[output].isTTY) {
1084
+ str = $node.colorette[color + 'Bright'](str);
1085
+ }
1086
+ ;
1087
+ this.console[level](str);
1088
+ const self = this;
1089
+ return () => self.console.groupEnd();
1090
+ };
1091
+ }
1092
+ $.$mol_log3_node_make = $mol_log3_node_make;
1093
+ $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
1094
+ $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
1095
+ $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
1096
+ $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
1097
+ $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
1098
+ $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
1099
+ })($ || ($ = {}));
1100
+ //log3.node.js.map
1101
+ ;
1102
+ "use strict";
1103
+ var $;
1104
+ (function ($_1) {
1105
+ $_1.$mol_test_mocks.push($ => {
1106
+ $.$mol_log3_come = () => { };
1107
+ $.$mol_log3_done = () => { };
1108
+ $.$mol_log3_fail = () => { };
1109
+ $.$mol_log3_warn = () => { };
1110
+ $.$mol_log3_rise = () => { };
1111
+ $.$mol_log3_area = () => () => { };
1112
+ });
1113
+ })($ || ($ = {}));
1114
+ //log3.test.js.map
1115
+ ;
1116
+ "use strict";
1117
+ var $;
1118
+ (function ($) {
1119
+ function $mol_env() {
1120
+ return {};
1121
+ }
1122
+ $.$mol_env = $mol_env;
1123
+ })($ || ($ = {}));
1124
+ //env.js.map
1125
+ ;
1126
+ "use strict";
1127
+ var $;
1128
+ (function ($) {
1129
+ $.$mol_env = function $mol_env() {
1130
+ return this.process.env;
1131
+ };
1132
+ })($ || ($ = {}));
1133
+ //env.node.js.map
1134
+ ;
1135
+ "use strict";
1136
+ var $;
1137
+ (function ($) {
1138
+ function $mol_exec(dir, command, ...args) {
1139
+ let [app, ...args0] = command.split(' ');
1140
+ args = [...args0, ...args];
1141
+ this.$mol_log3_come({
1142
+ place: '$mol_exec',
1143
+ dir: $node.path.relative('', dir),
1144
+ message: 'Run',
1145
+ command: `${app} ${args.join(' ')}`,
1146
+ });
1147
+ var res = $node['child_process'].spawnSync(app, args, {
1148
+ cwd: $node.path.resolve(dir),
1149
+ shell: true,
1150
+ env: this.$mol_env(),
1151
+ });
1152
+ if (res.status || res.error)
1153
+ return $.$mol_fail(res.error || new Error(res.stderr.toString()));
1154
+ if (!res.stdout)
1155
+ res.stdout = Buffer.from([]);
1156
+ return res;
1157
+ }
1158
+ $.$mol_exec = $mol_exec;
1159
+ })($ || ($ = {}));
1160
+ //exec.node.js.map
1161
+ ;
1162
+ "use strict";
1163
+ var $;
1164
+ (function ($) {
1165
+ $.$mol_ambient_ref = Symbol('$mol_ambient_ref');
1166
+ function $mol_ambient(overrides) {
1167
+ return Object.setPrototypeOf(overrides, this || $);
1168
+ }
1169
+ $.$mol_ambient = $mol_ambient;
1170
+ })($ || ($ = {}));
1171
+ //ambient.js.map
1172
+ ;
1173
+ "use strict";
1174
+ var $;
1175
+ (function ($) {
1176
+ $.$mol_test({
1177
+ 'get'() {
1178
+ const proxy = $.$mol_delegate({}, () => ({ foo: 777 }));
1179
+ $.$mol_assert_equal(proxy.foo, 777);
1180
+ },
1181
+ 'has'() {
1182
+ const proxy = $.$mol_delegate({}, () => ({ foo: 777 }));
1183
+ $.$mol_assert_equal('foo' in proxy, true);
1184
+ },
1185
+ 'set'() {
1186
+ const target = { foo: 777 };
1187
+ const proxy = $.$mol_delegate({}, () => target);
1188
+ proxy.foo = 123;
1189
+ $.$mol_assert_equal(target.foo, 123);
1190
+ },
1191
+ 'getOwnPropertyDescriptor'() {
1192
+ const proxy = $.$mol_delegate({}, () => ({ foo: 777 }));
1193
+ $.$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
1194
+ value: 777,
1195
+ writable: true,
1196
+ enumerable: true,
1197
+ configurable: true,
1198
+ });
1199
+ },
1200
+ 'ownKeys'() {
1201
+ const proxy = $.$mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
1202
+ $.$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
1203
+ },
1204
+ 'getPrototypeOf'() {
1205
+ class Foo {
1206
+ }
1207
+ const proxy = $.$mol_delegate({}, () => new Foo);
1208
+ $.$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
1209
+ },
1210
+ 'setPrototypeOf'() {
1211
+ class Foo {
1212
+ }
1213
+ const target = {};
1214
+ const proxy = $.$mol_delegate({}, () => target);
1215
+ Object.setPrototypeOf(proxy, Foo.prototype);
1216
+ $.$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
1217
+ },
1218
+ 'instanceof'() {
1219
+ class Foo {
1220
+ }
1221
+ const proxy = $.$mol_delegate({}, () => new Foo);
1222
+ $.$mol_assert_ok(proxy instanceof Foo);
1223
+ $.$mol_assert_ok(proxy instanceof $.$mol_delegate);
1224
+ },
1225
+ 'autobind'() {
1226
+ class Foo {
1227
+ }
1228
+ const proxy = $.$mol_delegate({}, () => new Foo);
1229
+ $.$mol_assert_ok(proxy instanceof Foo);
1230
+ $.$mol_assert_ok(proxy instanceof $.$mol_delegate);
1231
+ },
1232
+ });
1233
+ })($ || ($ = {}));
1234
+ //delegate.test.js.map
1235
+ ;
1236
+ "use strict";
1237
+ var $;
1238
+ (function ($) {
1239
+ const instances = new WeakSet();
1240
+ function $mol_delegate(proto, target) {
1241
+ const proxy = new Proxy(proto, {
1242
+ get: (_, field) => {
1243
+ const obj = target();
1244
+ let val = Reflect.get(obj, field);
1245
+ if (typeof val === 'function') {
1246
+ val = val.bind(obj);
1247
+ }
1248
+ return val;
1249
+ },
1250
+ has: (_, field) => Reflect.has(target(), field),
1251
+ set: (_, field, value) => Reflect.set(target(), field, value),
1252
+ getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
1253
+ ownKeys: () => Reflect.ownKeys(target()),
1254
+ getPrototypeOf: () => Reflect.getPrototypeOf(target()),
1255
+ setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
1256
+ isExtensible: () => Reflect.isExtensible(target()),
1257
+ preventExtensions: () => Reflect.preventExtensions(target()),
1258
+ apply: (_, self, args) => Reflect.apply(target(), self, args),
1259
+ construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
1260
+ defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
1261
+ deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
1262
+ });
1263
+ instances.add(proxy);
1264
+ return proxy;
1265
+ }
1266
+ $.$mol_delegate = $mol_delegate;
1267
+ Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
1268
+ value: (obj) => instances.has(obj),
1269
+ });
1270
+ })($ || ($ = {}));
1271
+ //delegate.js.map
1272
+ ;
1273
+ "use strict";
1274
+ var $;
1275
+ (function ($) {
1276
+ $.$mol_owning_map = new WeakMap();
1277
+ function $mol_owning_allow(having) {
1278
+ try {
1279
+ if (!having)
1280
+ return false;
1281
+ if (typeof having !== 'object')
1282
+ return false;
1283
+ if (having instanceof $.$mol_delegate)
1284
+ return false;
1285
+ if (typeof having['destructor'] !== 'function')
1286
+ return false;
1287
+ return true;
1288
+ }
1289
+ catch {
1290
+ return false;
1291
+ }
1292
+ }
1293
+ $.$mol_owning_allow = $mol_owning_allow;
1294
+ function $mol_owning_get(having, Owner) {
1295
+ if (!$mol_owning_allow(having))
1296
+ return null;
1297
+ while (true) {
1298
+ const owner = $.$mol_owning_map.get(having);
1299
+ if (!owner)
1300
+ return owner;
1301
+ if (!Owner)
1302
+ return owner;
1303
+ if (owner instanceof Owner)
1304
+ return owner;
1305
+ having = owner;
1306
+ }
1307
+ }
1308
+ $.$mol_owning_get = $mol_owning_get;
1309
+ function $mol_owning_check(owner, having) {
1310
+ if (!$mol_owning_allow(having))
1311
+ return false;
1312
+ if ($.$mol_owning_map.get(having) !== owner)
1313
+ return false;
1314
+ return true;
1315
+ }
1316
+ $.$mol_owning_check = $mol_owning_check;
1317
+ function $mol_owning_catch(owner, having) {
1318
+ if (!$mol_owning_allow(having))
1319
+ return false;
1320
+ if ($.$mol_owning_map.get(having))
1321
+ return false;
1322
+ $.$mol_owning_map.set(having, owner);
1323
+ return true;
1324
+ }
1325
+ $.$mol_owning_catch = $mol_owning_catch;
1326
+ })($ || ($ = {}));
1327
+ //owning.js.map
1328
+ ;
1329
+ "use strict";
1330
+ //writable.test.js.map
1331
+ ;
1332
+ "use strict";
1333
+ //writable.js.map
1334
+ ;
1335
+ "use strict";
1336
+ var $;
1337
+ (function ($) {
1338
+ class $mol_object2 {
1339
+ static $ = $;
1340
+ [$.$mol_ambient_ref] = null;
1341
+ get $() {
1342
+ if (this[$.$mol_ambient_ref])
1343
+ return this[$.$mol_ambient_ref];
1344
+ const owner = $.$mol_owning_get(this);
1345
+ return this[$.$mol_ambient_ref] = owner?.$ || $mol_object2.$;
1346
+ }
1347
+ set $(next) {
1348
+ if (this[$.$mol_ambient_ref])
1349
+ $.$mol_fail_hidden(new Error('Context already defined'));
1350
+ this[$.$mol_ambient_ref] = next;
1351
+ }
1352
+ static create(init) {
1353
+ const obj = new this;
1354
+ if (init)
1355
+ init(obj);
1356
+ return obj;
1357
+ }
1358
+ static [Symbol.toPrimitive]() {
1359
+ return this.toString();
1360
+ }
1361
+ static toString() {
1362
+ if (Symbol.toStringTag in this)
1363
+ return this[Symbol.toStringTag];
1364
+ return this.name;
1365
+ }
1366
+ destructor() { }
1367
+ [Symbol.toPrimitive](hint) {
1368
+ return hint === 'number' ? this.valueOf() : this.toString();
1369
+ }
1370
+ toString() {
1371
+ return this[Symbol.toStringTag] || this.constructor.name + '()';
1372
+ }
1373
+ toJSON() {
1374
+ return this.toString();
1375
+ }
1376
+ }
1377
+ $.$mol_object2 = $mol_object2;
1378
+ })($ || ($ = {}));
1379
+ //object2.js.map
1380
+ ;
1381
+ "use strict";
1382
+ var $;
1383
+ (function ($) {
1384
+ function $mol_deprecated(message) {
1385
+ return (host, field, descr) => {
1386
+ const value = descr.value;
1387
+ let warned = false;
1388
+ descr.value = function $mol_deprecated_wrapper(...args) {
1389
+ if (!warned) {
1390
+ $.$$.$mol_log3_warn({
1391
+ place: `${host.constructor.name}::${field}`,
1392
+ message: `Deprecated`,
1393
+ hint: message,
1394
+ });
1395
+ warned = true;
1396
+ }
1397
+ return value.call(this, ...args);
1398
+ };
1399
+ };
1400
+ }
1401
+ $.$mol_deprecated = $mol_deprecated;
1402
+ })($ || ($ = {}));
1403
+ //deprecated.js.map
1404
+ ;
1405
+ "use strict";
1406
+ var $;
1407
+ (function ($_1) {
1408
+ $_1.$mol_test({
1409
+ 'tree parsing'() {
1410
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString("foo\nbar\n").sub.length, 2);
1411
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
1412
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString("foo\n\n\n").sub.length, 1);
1413
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
1414
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
1415
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
1416
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
1417
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
1418
+ },
1419
+ 'inserting'() {
1420
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString('a b c d').insert(new $_1.$mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
1421
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString('a b').insert(new $_1.$mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
1422
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString('a b c d').insert(new $_1.$mol_tree, 0, 0, 0).toString(), 'a b \\\n');
1423
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString('a b').insert(new $_1.$mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
1424
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString('a b c d').insert(new $_1.$mol_tree, null, null, null).toString(), 'a b \\\n');
1425
+ $_1.$mol_assert_equal($_1.$mol_tree.fromString('a b').insert(new $_1.$mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
1426
+ },
1427
+ 'fromJSON'() {
1428
+ $_1.$mol_assert_equal($_1.$mol_tree.fromJSON([]).toString(), '/\n');
1429
+ $_1.$mol_assert_equal($_1.$mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
1430
+ $_1.$mol_assert_equal($_1.$mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
1431
+ $_1.$mol_assert_equal($_1.$mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
1432
+ $_1.$mol_assert_equal($_1.$mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
1433
+ },
1434
+ 'toJSON'() {
1435
+ $_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('/\n').sub[0]), '[]');
1436
+ $_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
1437
+ $_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
1438
+ $_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
1439
+ $_1.$mol_assert_equal(JSON.stringify($_1.$mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
1440
+ },
1441
+ 'hack'() {
1442
+ const res = $_1.$mol_tree.fromString(`foo bar xxx`).hack({
1443
+ '': (tree, context) => [tree.hack(context)],
1444
+ 'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
1445
+ });
1446
+ $_1.$mol_assert_equal(res.toString(), new $_1.$mol_tree({ type: 'foo 777 xxx' }).toString());
1447
+ },
1448
+ 'errors handling'($) {
1449
+ const errors = [];
1450
+ class Tree extends $_1.$mol_tree {
1451
+ static $ = $.$mol_ambient({
1452
+ $mol_fail: error => errors.push(error.message)
1453
+ });
1454
+ }
1455
+ Tree.fromString(`
1456
+ \t \tfoo
1457
+ bar \\data
1458
+ `, 'test');
1459
+ $_1.$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
1460
+ },
1461
+ });
1462
+ })($ || ($ = {}));
1463
+ //tree.test.js.map
1464
+ ;
1465
+ "use strict";
1466
+ var $;
1467
+ (function ($) {
1468
+ $.$mol_tree_convert = Symbol('$mol_tree_convert');
1469
+ class $mol_tree extends $.$mol_object2 {
1470
+ type;
1471
+ data;
1472
+ sub;
1473
+ baseUri;
1474
+ row;
1475
+ col;
1476
+ length;
1477
+ constructor(config = {}) {
1478
+ super();
1479
+ this.type = config.type || '';
1480
+ if (config.value !== undefined) {
1481
+ var sub = $mol_tree.values(config.value);
1482
+ if (config.type || sub.length > 1) {
1483
+ this.sub = [...sub, ...(config.sub || [])];
1484
+ this.data = config.data || '';
1485
+ }
1486
+ else {
1487
+ this.data = sub[0].data;
1488
+ this.sub = config.sub || [];
1489
+ }
1490
+ }
1491
+ else {
1492
+ this.data = config.data || '';
1493
+ this.sub = config.sub || [];
1494
+ }
1495
+ this.baseUri = config.baseUri || '';
1496
+ this.row = config.row || 0;
1497
+ this.col = config.col || 0;
1498
+ this.length = config.length || 0;
1499
+ }
1500
+ static values(str, baseUri) {
1501
+ return str.split('\n').map((data, index) => new $mol_tree({
1502
+ data: data,
1503
+ baseUri: baseUri,
1504
+ row: index + 1,
1505
+ length: data.length,
1506
+ }));
1507
+ }
1508
+ clone(config = {}) {
1509
+ return new $mol_tree({
1510
+ type: ('type' in config) ? config.type : this.type,
1511
+ data: ('data' in config) ? config.data : this.data,
1512
+ sub: ('sub' in config) ? config.sub : this.sub,
1513
+ baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
1514
+ row: ('row' in config) ? config.row : this.row,
1515
+ col: ('col' in config) ? config.col : this.col,
1516
+ length: ('length' in config) ? config.length : this.length,
1517
+ value: config.value
1518
+ });
1519
+ }
1520
+ make(config) {
1521
+ return new $mol_tree({
1522
+ baseUri: this.baseUri,
1523
+ row: this.row,
1524
+ col: this.col,
1525
+ length: this.length,
1526
+ ...config,
1527
+ });
1528
+ }
1529
+ make_data(value, sub) {
1530
+ return this.make({ value, sub });
1531
+ }
1532
+ make_struct(type, sub) {
1533
+ return this.make({ type, sub });
1534
+ }
1535
+ static fromString(str, baseUri) {
1536
+ var root = new $mol_tree({ baseUri: baseUri });
1537
+ var stack = [root];
1538
+ var row = 0;
1539
+ var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
1540
+ var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
1541
+ lines.forEach(line => {
1542
+ ++row;
1543
+ var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
1544
+ if (!chunks || chunks[4])
1545
+ return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
1546
+ var indent = chunks[1];
1547
+ var path = chunks[2];
1548
+ var data = chunks[3];
1549
+ var deep = indent.length;
1550
+ var types = path ? path.replace(/ $/, '').split(/ +/) : [];
1551
+ if (stack.length <= deep)
1552
+ return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
1553
+ stack.length = deep + 1;
1554
+ var parent = stack[deep];
1555
+ let col = deep;
1556
+ types.forEach(type => {
1557
+ if (!type)
1558
+ return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
1559
+ var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
1560
+ const parent_sub = parent.sub;
1561
+ parent_sub.push(next);
1562
+ parent = next;
1563
+ col += type.length + 1;
1564
+ });
1565
+ if (data) {
1566
+ var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
1567
+ const parent_sub = parent.sub;
1568
+ parent_sub.push(next);
1569
+ parent = next;
1570
+ }
1571
+ stack.push(parent);
1572
+ });
1573
+ return root;
1574
+ }
1575
+ static fromJSON(json, baseUri = '') {
1576
+ switch (true) {
1577
+ case typeof json === 'boolean':
1578
+ case typeof json === 'number':
1579
+ case json === null:
1580
+ return new $mol_tree({
1581
+ type: String(json),
1582
+ baseUri: baseUri
1583
+ });
1584
+ case typeof json === 'string':
1585
+ return new $mol_tree({
1586
+ value: json,
1587
+ baseUri: baseUri
1588
+ });
1589
+ case Array.isArray(json):
1590
+ return new $mol_tree({
1591
+ type: "/",
1592
+ sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
1593
+ });
1594
+ case json instanceof Date:
1595
+ return new $mol_tree({
1596
+ value: json.toISOString(),
1597
+ baseUri: baseUri
1598
+ });
1599
+ default:
1600
+ if (typeof json[$.$mol_tree_convert] === 'function') {
1601
+ return json[$.$mol_tree_convert]();
1602
+ }
1603
+ if (typeof json.toJSON === 'function') {
1604
+ return $mol_tree.fromJSON(json.toJSON());
1605
+ }
1606
+ if (json instanceof Error) {
1607
+ const { name, message, stack } = json;
1608
+ json = { ...json, name, message, stack };
1609
+ }
1610
+ var sub = [];
1611
+ for (var key in json) {
1612
+ if (json[key] === undefined)
1613
+ continue;
1614
+ const subsub = $mol_tree.fromJSON(json[key], baseUri);
1615
+ if (/^[^\n\t\\ ]+$/.test(key)) {
1616
+ var child = new $mol_tree({
1617
+ type: key,
1618
+ baseUri: baseUri,
1619
+ sub: [subsub],
1620
+ });
1621
+ }
1622
+ else {
1623
+ var child = new $mol_tree({
1624
+ value: key,
1625
+ baseUri: baseUri,
1626
+ sub: [subsub],
1627
+ });
1628
+ }
1629
+ sub.push(child);
1630
+ }
1631
+ return new $mol_tree({
1632
+ type: "*",
1633
+ sub: sub,
1634
+ baseUri: baseUri
1635
+ });
1636
+ }
1637
+ }
1638
+ get uri() {
1639
+ return this.baseUri + '#' + this.row + ':' + this.col;
1640
+ }
1641
+ toString(prefix = '') {
1642
+ var output = '';
1643
+ if (this.type.length) {
1644
+ if (!prefix.length) {
1645
+ prefix = "\t";
1646
+ }
1647
+ output += this.type;
1648
+ if (this.sub.length == 1) {
1649
+ return output + ' ' + this.sub[0].toString(prefix);
1650
+ }
1651
+ output += "\n";
1652
+ }
1653
+ else if (this.data.length || prefix.length) {
1654
+ output += "\\" + this.data + "\n";
1655
+ }
1656
+ for (var child of this.sub) {
1657
+ output += prefix;
1658
+ output += child.toString(prefix + "\t");
1659
+ }
1660
+ return output;
1661
+ }
1662
+ toJSON() {
1663
+ if (!this.type)
1664
+ return this.value;
1665
+ if (this.type === 'true')
1666
+ return true;
1667
+ if (this.type === 'false')
1668
+ return false;
1669
+ if (this.type === 'null')
1670
+ return null;
1671
+ if (this.type === '*') {
1672
+ var obj = {};
1673
+ for (var child of this.sub) {
1674
+ if (child.type === '-')
1675
+ continue;
1676
+ var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
1677
+ var val = child.sub[child.sub.length - 1].toJSON();
1678
+ if (val !== undefined)
1679
+ obj[key] = val;
1680
+ }
1681
+ return obj;
1682
+ }
1683
+ if (this.type === '/') {
1684
+ var res = [];
1685
+ this.sub.forEach(child => {
1686
+ if (child.type === '-')
1687
+ return;
1688
+ var val = child.toJSON();
1689
+ if (val !== undefined)
1690
+ res.push(val);
1691
+ });
1692
+ return res;
1693
+ }
1694
+ if (this.type === 'time') {
1695
+ return new Date(this.value);
1696
+ }
1697
+ const numb = Number(this.type);
1698
+ if (!Number.isNaN(numb) || this.type === 'NaN')
1699
+ return numb;
1700
+ throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
1701
+ }
1702
+ get value() {
1703
+ var values = [];
1704
+ for (var child of this.sub) {
1705
+ if (child.type)
1706
+ continue;
1707
+ values.push(child.value);
1708
+ }
1709
+ return this.data + values.join("\n");
1710
+ }
1711
+ insert(value, ...path) {
1712
+ if (path.length === 0)
1713
+ return value;
1714
+ const type = path[0];
1715
+ if (typeof type === 'string') {
1716
+ let replaced = false;
1717
+ const sub = this.sub.map((item, index) => {
1718
+ if (item.type !== type)
1719
+ return item;
1720
+ replaced = true;
1721
+ return item.insert(value, ...path.slice(1));
1722
+ });
1723
+ if (!replaced)
1724
+ sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
1725
+ return this.clone({ sub });
1726
+ }
1727
+ else if (typeof type === 'number') {
1728
+ const sub = this.sub.slice();
1729
+ sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
1730
+ return this.clone({ sub });
1731
+ }
1732
+ else {
1733
+ return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
1734
+ }
1735
+ }
1736
+ select(...path) {
1737
+ var next = [this];
1738
+ for (var type of path) {
1739
+ if (!next.length)
1740
+ break;
1741
+ var prev = next;
1742
+ next = [];
1743
+ for (var item of prev) {
1744
+ switch (typeof (type)) {
1745
+ case 'string':
1746
+ for (var child of item.sub) {
1747
+ if (!type || (child.type == type)) {
1748
+ next.push(child);
1749
+ }
1750
+ }
1751
+ break;
1752
+ case 'number':
1753
+ if (type < item.sub.length)
1754
+ next.push(item.sub[type]);
1755
+ break;
1756
+ default: next.push(...item.sub);
1757
+ }
1758
+ }
1759
+ }
1760
+ return new $mol_tree({ sub: next });
1761
+ }
1762
+ filter(path, value) {
1763
+ var sub = this.sub.filter(function (item) {
1764
+ var found = item.select(...path);
1765
+ if (value == null) {
1766
+ return Boolean(found.sub.length);
1767
+ }
1768
+ else {
1769
+ return found.sub.some(child => child.value == value);
1770
+ }
1771
+ });
1772
+ return new $mol_tree({ sub: sub });
1773
+ }
1774
+ transform(visit, stack = []) {
1775
+ const sub_stack = [this, ...stack];
1776
+ return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
1777
+ }
1778
+ hack(context) {
1779
+ const sub = [].concat(...this.sub.map(child => {
1780
+ const handle = context[child.type] || context[''];
1781
+ if (!handle)
1782
+ $.$mol_fail(child.error('Handler not defined'));
1783
+ return handle(child, context);
1784
+ }));
1785
+ return this.clone({ sub });
1786
+ }
1787
+ error(message) {
1788
+ return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
1789
+ }
1790
+ }
1791
+ __decorate([
1792
+ $.$mol_deprecated('Use $mol_tree:hack')
1793
+ ], $mol_tree.prototype, "transform", null);
1794
+ $.$mol_tree = $mol_tree;
1795
+ })($ || ($ = {}));
1796
+ //tree.js.map
1797
+ ;
1798
+ "use strict";
1799
+ //equals.test.js.map
1800
+ ;
1801
+ "use strict";
1802
+ //equals.js.map
1803
+ ;
1804
+ "use strict";
1805
+ var $;
1806
+ (function ($) {
1807
+ $.$mol_test({
1808
+ 'equal paths'() {
1809
+ const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
1810
+ $.$mol_assert_like(diff, {
1811
+ prefix: [1, 2, 3, 4],
1812
+ suffix: [[], [], []],
1813
+ });
1814
+ },
1815
+ 'different suffix'() {
1816
+ const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
1817
+ $.$mol_assert_like(diff, {
1818
+ prefix: [1, 2],
1819
+ suffix: [[3, 4], [3, 5], [5, 4]],
1820
+ });
1821
+ },
1822
+ 'one contains other'() {
1823
+ const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
1824
+ $.$mol_assert_like(diff, {
1825
+ prefix: [1, 2],
1826
+ suffix: [[3, 4], [], [3]],
1827
+ });
1828
+ },
1829
+ 'fully different'() {
1830
+ const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
1831
+ $.$mol_assert_like(diff, {
1832
+ prefix: [],
1833
+ suffix: [[1, 2], [3, 4], [5, 6]],
1834
+ });
1835
+ },
1836
+ });
1837
+ })($ || ($ = {}));
1838
+ //path.test.js.map
1839
+ ;
1840
+ "use strict";
1841
+ var $;
1842
+ (function ($) {
1843
+ function $mol_diff_path(...paths) {
1844
+ const limit = Math.min(...paths.map(path => path.length));
1845
+ lookup: for (var i = 0; i < limit; ++i) {
1846
+ const first = paths[0][i];
1847
+ for (let j = 1; j < paths.length; ++j) {
1848
+ if (paths[j][i] !== first)
1849
+ break lookup;
1850
+ }
1851
+ }
1852
+ return {
1853
+ prefix: paths[0].slice(0, i),
1854
+ suffix: paths.map(path => path.slice(i)),
1855
+ };
1856
+ }
1857
+ $.$mol_diff_path = $mol_diff_path;
1858
+ })($ || ($ = {}));
1859
+ //path.js.map
1860
+ ;
1861
+ "use strict";
1862
+ var $;
1863
+ (function ($) {
1864
+ class $mol_error_mix extends Error {
1865
+ errors;
1866
+ constructor(message, ...errors) {
1867
+ super(message);
1868
+ this.errors = errors;
1869
+ if (errors.length) {
1870
+ const stacks = [...errors.map(error => error.stack), this.stack];
1871
+ const diff = $.$mol_diff_path(...stacks.map(stack => {
1872
+ if (!stack)
1873
+ return [];
1874
+ return stack.split('\n').reverse();
1875
+ }));
1876
+ const head = diff.prefix.reverse().join('\n');
1877
+ const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
1878
+ this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
1879
+ this.message += errors.map(error => '\n' + error.message).join('');
1880
+ }
1881
+ }
1882
+ toJSON() {
1883
+ return this.message;
1884
+ }
1885
+ }
1886
+ $.$mol_error_mix = $mol_error_mix;
1887
+ })($ || ($ = {}));
1888
+ //mix.js.map
1889
+ ;
1890
+ "use strict";
1891
+ var $;
1892
+ (function ($) {
1893
+ $.$mol_test({
1894
+ async 'unique index'() {
1895
+ const db = await $.$$.$mol_db('$mol_db_test', mig => mig.store_make('users'), mig => mig.stores.users.index_make('names', ['name'], !!'unique'));
1896
+ const trans = db.change('users');
1897
+ try {
1898
+ const { users } = trans.stores;
1899
+ await users.put({ name: 'Jin' }, 'jin');
1900
+ await users.put({ name: 'John' }, 'john');
1901
+ await users.put({ name: 'Bin' }, 'bin');
1902
+ const { names } = users.indexes;
1903
+ $.$mol_assert_like(await names.get(['Jin']), { name: 'Jin' });
1904
+ $.$mol_assert_like(await names.get(['John']), { name: 'John' });
1905
+ $.$mol_assert_like(await names.count(), 3);
1906
+ $.$mol_assert_like(await names.select(IDBKeyRange.bound(['J'], ['J\uFFFF'])), [{ name: 'Jin' }, { name: 'John' }]);
1907
+ try {
1908
+ await users.put({ name: 'Jin' }, 'jin2');
1909
+ $.$mol_fail(new Error('Exception expected'));
1910
+ }
1911
+ catch (error) {
1912
+ $.$mol_assert_equal(error.message, `Unable to add key to index 'names': at least one key does not satisfy the uniqueness requirements.`);
1913
+ }
1914
+ }
1915
+ finally {
1916
+ trans.abort();
1917
+ db.kill();
1918
+ }
1919
+ },
1920
+ async 'multi path index'() {
1921
+ const db = await $.$$.$mol_db('$mol_db_test', mig => mig.store_make('users'), mig => mig.stores.users.index_make('names', ['first', 'last']));
1922
+ const trans = db.change('users');
1923
+ try {
1924
+ const { users } = trans.stores;
1925
+ await users.put({ first: 'Jin', last: 'Johnson' }, 'jin');
1926
+ await users.put({ first: 'John', last: 'Jinson' }, 'john');
1927
+ await users.put({ first: 'Bond', last: 'James' }, '007');
1928
+ const { names } = users.indexes;
1929
+ $.$mol_assert_like(await names.get(['Jin', 'Johnson']), { first: 'Jin', last: 'Johnson' });
1930
+ $.$mol_assert_like(await names.get(['John', 'Jinson']), { first: 'John', last: 'Jinson' });
1931
+ $.$mol_assert_like(await names.count(), 3);
1932
+ $.$mol_assert_like(await names.select(IDBKeyRange.bound(['Jin', 'Johnson'], ['John', 'Jinson'])), [{ first: 'Jin', last: 'Johnson' }, { first: 'John', last: 'Jinson' }]);
1933
+ }
1934
+ finally {
1935
+ trans.abort();
1936
+ db.kill();
1937
+ }
1938
+ },
1939
+ async 'multiple indexes'() {
1940
+ const db = await $.$$.$mol_db('$mol_db_test', mig => mig.store_make('users'), mig => mig.stores.users.index_make('names', ['name'], !!'unique'), mig => mig.stores.users.index_make('ages', ['age']));
1941
+ const trans = db.change('users');
1942
+ try {
1943
+ const { users } = trans.stores;
1944
+ await users.put({ name: 'Jin', age: 18 }, 'jin');
1945
+ await users.put({ name: 'John', age: 18 }, 'john');
1946
+ const { names, ages } = users.indexes;
1947
+ $.$mol_assert_like(await names.select(['Jin']), [{ name: 'Jin', age: 18 }]);
1948
+ $.$mol_assert_like(await names.select(['John']), [{ name: 'John', age: 18 }]);
1949
+ $.$mol_assert_like(await names.count(), 2);
1950
+ $.$mol_assert_like(await ages.select([18]), [{ name: 'Jin', age: 18 }, { name: 'John', age: 18 }]);
1951
+ $.$mol_assert_like(await ages.count(), 2);
1952
+ }
1953
+ finally {
1954
+ trans.abort();
1955
+ db.kill();
1956
+ }
1957
+ },
1958
+ });
1959
+ })($ || ($ = {}));
1960
+ //index.test.js.map
1961
+
1962
+ //# sourceMappingURL=node.test.js.map