mol_dump_lib 0.0.1 → 0.0.2

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/web.test.js CHANGED
@@ -1,3 +1,3659 @@
1
1
  "use strict";
2
- function require( path ){ return $node[ path ] }
2
+ function require( path ){ return $node[ path ] };
3
+ "use strict";
4
+ var $;
5
+ (function ($_1) {
6
+ function $mol_test(set) {
7
+ for (let name in set) {
8
+ const code = set[name];
9
+ const test = (typeof code === 'string') ? new Function('', code) : code;
10
+ $_1.$mol_test_all.push(test);
11
+ }
12
+ $mol_test_schedule();
13
+ }
14
+ $_1.$mol_test = $mol_test;
15
+ $_1.$mol_test_mocks = [];
16
+ $_1.$mol_test_all = [];
17
+ async function $mol_test_run() {
18
+ for (var test of $_1.$mol_test_all) {
19
+ let context = Object.create($$);
20
+ for (let mock of $_1.$mol_test_mocks)
21
+ await mock(context);
22
+ const res = test(context);
23
+ if ($mol_promise_like(res)) {
24
+ await new Promise((done, fail) => {
25
+ res.then(done, fail);
26
+ setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
27
+ });
28
+ }
29
+ }
30
+ $$.$mol_log3_done({
31
+ place: '$mol_test',
32
+ message: 'All tests passed',
33
+ count: $_1.$mol_test_all.length,
34
+ });
35
+ }
36
+ $_1.$mol_test_run = $mol_test_run;
37
+ let scheduled = false;
38
+ function $mol_test_schedule() {
39
+ if (scheduled)
40
+ return;
41
+ scheduled = true;
42
+ setTimeout(async () => {
43
+ scheduled = false;
44
+ await $mol_test_run();
45
+ $$.$mol_test_complete();
46
+ }, 1000);
47
+ }
48
+ $_1.$mol_test_schedule = $mol_test_schedule;
49
+ $_1.$mol_test_mocks.push(context => {
50
+ let seed = 0;
51
+ context.Math = Object.create(Math);
52
+ context.Math.random = () => Math.sin(seed++);
53
+ const forbidden = ['XMLHttpRequest', 'fetch'];
54
+ for (let api of forbidden) {
55
+ context[api] = new Proxy(function () { }, {
56
+ get() {
57
+ $mol_fail_hidden(new Error(`${api} is forbidden in tests`));
58
+ },
59
+ apply() {
60
+ $mol_fail_hidden(new Error(`${api} is forbidden in tests`));
61
+ },
62
+ });
63
+ }
64
+ });
65
+ $mol_test({
66
+ 'mocked Math.random'($) {
67
+ console.assert($.Math.random() === 0);
68
+ console.assert($.Math.random() === Math.sin(1));
69
+ },
70
+ 'forbidden XMLHttpRequest'($) {
71
+ try {
72
+ console.assert(void new $.XMLHttpRequest);
73
+ }
74
+ catch (error) {
75
+ console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
76
+ }
77
+ },
78
+ 'forbidden fetch'($) {
79
+ try {
80
+ console.assert(void $.fetch(''));
81
+ }
82
+ catch (error) {
83
+ console.assert(error.message === 'fetch is forbidden in tests');
84
+ }
85
+ },
86
+ });
87
+ })($ || ($ = {}));
88
+ //mol/test/test.test.ts
89
+ ;
90
+ "use strict";
91
+ var $;
92
+ (function ($) {
93
+ function $mol_test_complete() {
94
+ }
95
+ $.$mol_test_complete = $mol_test_complete;
96
+ })($ || ($ = {}));
97
+ //mol/test/test.web.test.ts
98
+ ;
99
+ "use strict";
100
+ //mol/type/assert/assert.ts
101
+ ;
102
+ "use strict";
103
+ //mol/type/assert/assert.test.ts
104
+ ;
105
+ "use strict";
106
+ //mol/type/partial/deep/deep.ts
107
+ ;
108
+ "use strict";
109
+ //mol/type/partial/deep/deep.test.ts
110
+ ;
111
+ "use strict";
112
+ var $;
113
+ (function ($) {
114
+ $.$mol_jsx_prefix = '';
115
+ $.$mol_jsx_crumbs = '';
116
+ $.$mol_jsx_booked = null;
117
+ $.$mol_jsx_document = {
118
+ getElementById: () => null,
119
+ createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
120
+ createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
121
+ };
122
+ $.$mol_jsx_frag = '';
123
+ function $mol_jsx(Elem, props, ...childNodes) {
124
+ const id = props && props.id || '';
125
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
126
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
127
+ if (Elem && $.$mol_jsx_booked) {
128
+ if ($.$mol_jsx_booked.has(id)) {
129
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
130
+ }
131
+ else {
132
+ $.$mol_jsx_booked.add(id);
133
+ }
134
+ }
135
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
136
+ if ($.$mol_jsx_prefix) {
137
+ const prefix_ext = $.$mol_jsx_prefix;
138
+ const booked_ext = $.$mol_jsx_booked;
139
+ const crumbs_ext = $.$mol_jsx_crumbs;
140
+ for (const field in props) {
141
+ const func = props[field];
142
+ if (typeof func !== 'function')
143
+ continue;
144
+ const wrapper = function (...args) {
145
+ const prefix = $.$mol_jsx_prefix;
146
+ const booked = $.$mol_jsx_booked;
147
+ const crumbs = $.$mol_jsx_crumbs;
148
+ try {
149
+ $.$mol_jsx_prefix = prefix_ext;
150
+ $.$mol_jsx_booked = booked_ext;
151
+ $.$mol_jsx_crumbs = crumbs_ext;
152
+ return func.call(this, ...args);
153
+ }
154
+ finally {
155
+ $.$mol_jsx_prefix = prefix;
156
+ $.$mol_jsx_booked = booked;
157
+ $.$mol_jsx_crumbs = crumbs;
158
+ }
159
+ };
160
+ $mol_func_name_from(wrapper, func);
161
+ props[field] = wrapper;
162
+ }
163
+ }
164
+ if (typeof Elem !== 'string') {
165
+ if ('prototype' in Elem) {
166
+ const view = node && node[String(Elem)] || new Elem;
167
+ Object.assign(view, props);
168
+ view[Symbol.toStringTag] = guid;
169
+ view.childNodes = childNodes;
170
+ if (!view.ownerDocument)
171
+ view.ownerDocument = $.$mol_jsx_document;
172
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
173
+ node = view.valueOf();
174
+ node[String(Elem)] = view;
175
+ return node;
176
+ }
177
+ else {
178
+ const prefix = $.$mol_jsx_prefix;
179
+ const booked = $.$mol_jsx_booked;
180
+ const crumbs = $.$mol_jsx_crumbs;
181
+ try {
182
+ $.$mol_jsx_prefix = guid;
183
+ $.$mol_jsx_booked = new Set;
184
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
185
+ return Elem(props, ...childNodes);
186
+ }
187
+ finally {
188
+ $.$mol_jsx_prefix = prefix;
189
+ $.$mol_jsx_booked = booked;
190
+ $.$mol_jsx_crumbs = crumbs;
191
+ }
192
+ }
193
+ }
194
+ if (!node) {
195
+ node = Elem
196
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
197
+ : $.$mol_jsx_document.createDocumentFragment();
198
+ }
199
+ $mol_dom_render_children(node, [].concat(...childNodes));
200
+ if (!Elem)
201
+ return node;
202
+ if (guid)
203
+ node.id = guid;
204
+ for (const key in props) {
205
+ if (key === 'id')
206
+ continue;
207
+ if (typeof props[key] === 'string') {
208
+ if (typeof node[key] === 'string')
209
+ node[key] = props[key];
210
+ node.setAttribute(key, props[key]);
211
+ }
212
+ else if (props[key] &&
213
+ typeof props[key] === 'object' &&
214
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
215
+ if (typeof node[key] === 'object') {
216
+ Object.assign(node[key], props[key]);
217
+ continue;
218
+ }
219
+ }
220
+ else {
221
+ node[key] = props[key];
222
+ }
223
+ }
224
+ if ($.$mol_jsx_crumbs)
225
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
226
+ return node;
227
+ }
228
+ $.$mol_jsx = $mol_jsx;
229
+ })($ || ($ = {}));
230
+ //mol/jsx/jsx.ts
231
+ ;
232
+ "use strict";
233
+ var $;
234
+ (function ($) {
235
+ $mol_test({
236
+ 'Make empty div'() {
237
+ $mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
238
+ },
239
+ 'Define native field'() {
240
+ const dom = $mol_jsx("input", { value: '123' });
241
+ $mol_assert_equal(dom.outerHTML, '<input value="123">');
242
+ $mol_assert_equal(dom.value, '123');
243
+ },
244
+ 'Define classes'() {
245
+ const dom = $mol_jsx("div", { class: 'foo bar' });
246
+ $mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
247
+ },
248
+ 'Define styles'() {
249
+ const dom = $mol_jsx("div", { style: { color: 'red' } });
250
+ $mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
251
+ },
252
+ 'Define dataset'() {
253
+ const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
254
+ $mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
255
+ },
256
+ 'Define attributes'() {
257
+ const dom = $mol_jsx("div", { lang: "ru", hidden: true });
258
+ $mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
259
+ },
260
+ 'Define child nodes'() {
261
+ const dom = $mol_jsx("div", null,
262
+ "hello",
263
+ $mol_jsx("strong", null, "world"),
264
+ "!");
265
+ $mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
266
+ },
267
+ 'Function as component'() {
268
+ const Button = (props, target) => {
269
+ return $mol_jsx("button", { title: props.hint }, target());
270
+ };
271
+ const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
272
+ $mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
273
+ },
274
+ 'Nested guid generation'() {
275
+ const Foo = () => {
276
+ return $mol_jsx("div", null,
277
+ $mol_jsx(Bar, { id: "bar" },
278
+ $mol_jsx("img", { id: "icon" })));
279
+ };
280
+ const Bar = (props, icon) => {
281
+ return $mol_jsx("span", null,
282
+ icon,
283
+ $mol_jsx("i", { id: "label" }));
284
+ };
285
+ const dom = $mol_jsx(Foo, { id: "foo" });
286
+ $mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
287
+ },
288
+ 'Fail on non unique ids'() {
289
+ const App = () => {
290
+ return $mol_jsx("div", null,
291
+ $mol_jsx("span", { id: "bar" }),
292
+ $mol_jsx("span", { id: "bar" }));
293
+ };
294
+ $mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
295
+ },
296
+ 'Owner based guid generationn'() {
297
+ const Foo = () => {
298
+ return $mol_jsx("div", null,
299
+ $mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
300
+ };
301
+ const Bar = (props) => {
302
+ return $mol_jsx("span", null, props.icon());
303
+ };
304
+ const dom = $mol_jsx(Foo, { id: "app" });
305
+ $mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
306
+ },
307
+ 'Fail on same ids from different caller'() {
308
+ const Foo = () => {
309
+ return $mol_jsx("div", null,
310
+ $mol_jsx("img", { id: "icon" }),
311
+ $mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
312
+ };
313
+ const Bar = (props) => {
314
+ return $mol_jsx("span", null, props.icon());
315
+ };
316
+ $mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
317
+ },
318
+ });
319
+ })($ || ($ = {}));
320
+ //mol/jsx/jsx.test.tsx
321
+ ;
322
+ "use strict";
323
+ var $;
324
+ (function ($) {
325
+ $mol_test({
326
+ 'nulls & undefineds'() {
327
+ $mol_assert_ok($mol_compare_deep(null, null));
328
+ $mol_assert_ok($mol_compare_deep(undefined, undefined));
329
+ $mol_assert_not($mol_compare_deep(undefined, null));
330
+ $mol_assert_not($mol_compare_deep({}, null));
331
+ },
332
+ 'number'() {
333
+ $mol_assert_ok($mol_compare_deep(1, 1));
334
+ $mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
335
+ $mol_assert_not($mol_compare_deep(1, 2));
336
+ $mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
337
+ $mol_assert_not($mol_compare_deep(Object(1), Object(2)));
338
+ },
339
+ 'POJO'() {
340
+ $mol_assert_ok($mol_compare_deep({}, {}));
341
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
342
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
343
+ $mol_assert_not($mol_compare_deep({}, { a: undefined }));
344
+ $mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
345
+ $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
346
+ $mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
347
+ },
348
+ 'Array'() {
349
+ $mol_assert_ok($mol_compare_deep([], []));
350
+ $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
351
+ $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
352
+ $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
353
+ },
354
+ 'Non POJO are different'() {
355
+ class Thing extends Object {
356
+ }
357
+ $mol_assert_not($mol_compare_deep(new Thing, new Thing));
358
+ $mol_assert_not($mol_compare_deep(() => 1, () => 1));
359
+ $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
360
+ },
361
+ 'POJO with symbols'() {
362
+ const sym = Symbol();
363
+ $mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
364
+ $mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
365
+ },
366
+ 'same POJOs with cyclic reference'() {
367
+ const a = { foo: {} };
368
+ a['self'] = a;
369
+ const b = { foo: {} };
370
+ b['self'] = b;
371
+ $mol_assert_ok($mol_compare_deep(a, b));
372
+ },
373
+ 'Date'() {
374
+ $mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
375
+ $mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
376
+ },
377
+ 'RegExp'() {
378
+ $mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
379
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
380
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
381
+ },
382
+ 'Error'() {
383
+ $mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
384
+ const fail = (message) => new Error(message);
385
+ $mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
386
+ $mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
387
+ },
388
+ 'Map'() {
389
+ $mol_assert_ok($mol_compare_deep(new Map, new Map));
390
+ $mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
391
+ $mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
392
+ $mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
393
+ $mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
394
+ },
395
+ 'Set'() {
396
+ $mol_assert_ok($mol_compare_deep(new Set, new Set));
397
+ $mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
398
+ $mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
399
+ },
400
+ 'Uint8Array'() {
401
+ $mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
402
+ $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
403
+ $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
404
+ },
405
+ 'Serializale'() {
406
+ class User {
407
+ name;
408
+ rand;
409
+ constructor(name, rand = Math.random()) {
410
+ this.name = name;
411
+ this.rand = rand;
412
+ }
413
+ [Symbol.toPrimitive](mode) {
414
+ return this.name;
415
+ }
416
+ }
417
+ $mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
418
+ $mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
419
+ },
420
+ 'Iterable'() {
421
+ $mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
422
+ $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
423
+ $mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
424
+ },
425
+ });
426
+ })($ || ($ = {}));
427
+ //mol/compare/deep/deep.test.tsx
428
+ ;
429
+ "use strict";
430
+ var $;
431
+ (function ($) {
432
+ function $mol_dom_serialize(node) {
433
+ const serializer = new $mol_dom_context.XMLSerializer;
434
+ return serializer.serializeToString(node);
435
+ }
436
+ $.$mol_dom_serialize = $mol_dom_serialize;
437
+ })($ || ($ = {}));
438
+ //mol/dom/serialize/serialize.ts
439
+ ;
440
+ "use strict";
441
+ var $;
442
+ (function ($) {
443
+ function $mol_assert_ok(value) {
444
+ if (value)
445
+ return;
446
+ $mol_fail(new Error(`${value} ≠ true`));
447
+ }
448
+ $.$mol_assert_ok = $mol_assert_ok;
449
+ function $mol_assert_not(value) {
450
+ if (!value)
451
+ return;
452
+ $mol_fail(new Error(`${value} ≠ false`));
453
+ }
454
+ $.$mol_assert_not = $mol_assert_not;
455
+ function $mol_assert_fail(handler, ErrorRight) {
456
+ const fail = $.$mol_fail;
457
+ try {
458
+ $.$mol_fail = $.$mol_fail_hidden;
459
+ handler();
460
+ }
461
+ catch (error) {
462
+ if (!ErrorRight)
463
+ return error;
464
+ $.$mol_fail = fail;
465
+ if (typeof ErrorRight === 'string') {
466
+ $mol_assert_equal(error.message, ErrorRight);
467
+ }
468
+ else {
469
+ $mol_assert_ok(error instanceof ErrorRight);
470
+ }
471
+ return error;
472
+ }
473
+ finally {
474
+ $.$mol_fail = fail;
475
+ }
476
+ $mol_fail(new Error('Not failed'));
477
+ }
478
+ $.$mol_assert_fail = $mol_assert_fail;
479
+ function $mol_assert_equal(...args) {
480
+ for (let i = 0; i < args.length; ++i) {
481
+ for (let j = 0; j < args.length; ++j) {
482
+ if (i === j)
483
+ continue;
484
+ if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
485
+ continue;
486
+ if (args[i] !== args[j])
487
+ $mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
488
+ }
489
+ }
490
+ }
491
+ $.$mol_assert_equal = $mol_assert_equal;
492
+ function $mol_assert_unique(...args) {
493
+ for (let i = 0; i < args.length; ++i) {
494
+ for (let j = 0; j < args.length; ++j) {
495
+ if (i === j)
496
+ continue;
497
+ if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
498
+ $mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
499
+ }
500
+ }
501
+ }
502
+ }
503
+ $.$mol_assert_unique = $mol_assert_unique;
504
+ function $mol_assert_like(head, ...tail) {
505
+ for (let [index, value] of Object.entries(tail)) {
506
+ if (!$mol_compare_deep(value, head)) {
507
+ const print = (val) => {
508
+ if (!val)
509
+ return val;
510
+ if (typeof val !== 'object')
511
+ return val;
512
+ if ('outerHTML' in val)
513
+ return val.outerHTML;
514
+ try {
515
+ return JSON.stringify(val);
516
+ }
517
+ catch (error) {
518
+ console.error(error);
519
+ return val;
520
+ }
521
+ };
522
+ return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
523
+ }
524
+ }
525
+ }
526
+ $.$mol_assert_like = $mol_assert_like;
527
+ function $mol_assert_dom(left, right) {
528
+ $mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
529
+ }
530
+ $.$mol_assert_dom = $mol_assert_dom;
531
+ })($ || ($ = {}));
532
+ //mol/assert/assert.ts
533
+ ;
534
+ "use strict";
535
+ var $;
536
+ (function ($) {
537
+ $mol_test({
538
+ 'must be false'() {
539
+ $mol_assert_not(0);
540
+ },
541
+ 'must be true'() {
542
+ $mol_assert_ok(1);
543
+ },
544
+ 'two must be equal'() {
545
+ $mol_assert_equal(2, 2);
546
+ },
547
+ 'three must be equal'() {
548
+ $mol_assert_equal(2, 2, 2);
549
+ },
550
+ 'two must be unique'() {
551
+ $mol_assert_unique([3], [3]);
552
+ },
553
+ 'three must be unique'() {
554
+ $mol_assert_unique([3], [3], [3]);
555
+ },
556
+ 'two must be alike'() {
557
+ $mol_assert_like([3], [3]);
558
+ },
559
+ 'three must be alike'() {
560
+ $mol_assert_like([3], [3], [3]);
561
+ },
562
+ });
563
+ })($ || ($ = {}));
564
+ //mol/assert/assert.test.ts
565
+ ;
566
+ "use strict";
567
+ var $;
568
+ (function ($) {
569
+ function $mol_log3_area_lazy(event) {
570
+ const self = this;
571
+ const stack = self.$mol_log3_stack;
572
+ const deep = stack.length;
573
+ let logged = false;
574
+ stack.push(() => {
575
+ logged = true;
576
+ self.$mol_log3_area.call(self, event);
577
+ });
578
+ return () => {
579
+ if (logged)
580
+ self.console.groupEnd();
581
+ if (stack.length > deep)
582
+ stack.length = deep;
583
+ };
584
+ }
585
+ $.$mol_log3_area_lazy = $mol_log3_area_lazy;
586
+ $.$mol_log3_stack = [];
587
+ })($ || ($ = {}));
588
+ //mol/log3/log3.ts
589
+ ;
590
+ "use strict";
591
+ //mol/type/equals/equals.test.ts
592
+ ;
593
+ "use strict";
594
+ //mol/type/keys/extract/extract.test.ts
595
+ ;
596
+ "use strict";
597
+ var $;
598
+ (function ($) {
599
+ function $mol_log3_web_make(level, color) {
600
+ return function $mol_log3_logger(event) {
601
+ const pending = this.$mol_log3_stack.pop();
602
+ if (pending)
603
+ pending();
604
+ let tpl = '%c';
605
+ const chunks = Object.values(event);
606
+ for (let i = 0; i < chunks.length; ++i) {
607
+ tpl += (typeof chunks[i] === 'string') ? ' ⦙ %s' : ' ⦙ %o';
608
+ }
609
+ const style = `color:${color};font-weight:bolder`;
610
+ this.console[level](tpl, style, ...chunks);
611
+ const self = this;
612
+ return () => self.console.groupEnd();
613
+ };
614
+ }
615
+ $.$mol_log3_web_make = $mol_log3_web_make;
616
+ $.$mol_log3_come = $mol_log3_web_make('info', 'royalblue');
617
+ $.$mol_log3_done = $mol_log3_web_make('info', 'forestgreen');
618
+ $.$mol_log3_fail = $mol_log3_web_make('error', 'orangered');
619
+ $.$mol_log3_warn = $mol_log3_web_make('warn', 'goldenrod');
620
+ $.$mol_log3_rise = $mol_log3_web_make('log', 'magenta');
621
+ $.$mol_log3_area = $mol_log3_web_make('group', 'cyan');
622
+ })($ || ($ = {}));
623
+ //mol/log3/log3.web.ts
624
+ ;
625
+ "use strict";
626
+ var $;
627
+ (function ($_1) {
628
+ $mol_test_mocks.push($ => {
629
+ $.$mol_log3_come = () => { };
630
+ $.$mol_log3_done = () => { };
631
+ $.$mol_log3_fail = () => { };
632
+ $.$mol_log3_warn = () => { };
633
+ $.$mol_log3_rise = () => { };
634
+ $.$mol_log3_area = () => () => { };
635
+ });
636
+ })($ || ($ = {}));
637
+ //mol/log3/log3.test.ts
638
+ ;
639
+ "use strict";
640
+ var $;
641
+ (function ($_1) {
642
+ $mol_test({
643
+ 'FQN of anon function'($) {
644
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
645
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
646
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
647
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
648
+ },
649
+ });
650
+ })($ || ($ = {}));
651
+ //mol/func/name/name.test.ts
652
+ ;
653
+ "use strict";
654
+ var $;
655
+ (function ($) {
656
+ $mol_test({
657
+ 'get'() {
658
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
659
+ $mol_assert_equal(proxy.foo, 777);
660
+ },
661
+ 'has'() {
662
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
663
+ $mol_assert_equal('foo' in proxy, true);
664
+ },
665
+ 'set'() {
666
+ const target = { foo: 777 };
667
+ const proxy = $mol_delegate({}, () => target);
668
+ proxy.foo = 123;
669
+ $mol_assert_equal(target.foo, 123);
670
+ },
671
+ 'getOwnPropertyDescriptor'() {
672
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
673
+ $mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
674
+ value: 777,
675
+ writable: true,
676
+ enumerable: true,
677
+ configurable: true,
678
+ });
679
+ },
680
+ 'ownKeys'() {
681
+ const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
682
+ $mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
683
+ },
684
+ 'getPrototypeOf'() {
685
+ class Foo {
686
+ }
687
+ const proxy = $mol_delegate({}, () => new Foo);
688
+ $mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
689
+ },
690
+ 'setPrototypeOf'() {
691
+ class Foo {
692
+ }
693
+ const target = {};
694
+ const proxy = $mol_delegate({}, () => target);
695
+ Object.setPrototypeOf(proxy, Foo.prototype);
696
+ $mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
697
+ },
698
+ 'instanceof'() {
699
+ class Foo {
700
+ }
701
+ const proxy = $mol_delegate({}, () => new Foo);
702
+ $mol_assert_ok(proxy instanceof Foo);
703
+ $mol_assert_ok(proxy instanceof $mol_delegate);
704
+ },
705
+ 'autobind'() {
706
+ class Foo {
707
+ }
708
+ const proxy = $mol_delegate({}, () => new Foo);
709
+ $mol_assert_ok(proxy instanceof Foo);
710
+ $mol_assert_ok(proxy instanceof $mol_delegate);
711
+ },
712
+ });
713
+ })($ || ($ = {}));
714
+ //mol/delegate/delegate.test.ts
715
+ ;
716
+ "use strict";
717
+ //mol/type/writable/writable.test.ts
718
+ ;
719
+ "use strict";
720
+ var $;
721
+ (function ($) {
722
+ $mol_test({
723
+ 'init with overload'() {
724
+ class X extends $mol_object {
725
+ foo() {
726
+ return 1;
727
+ }
728
+ }
729
+ var x = X.make({
730
+ foo: () => 2,
731
+ });
732
+ $mol_assert_equal(x.foo(), 2);
733
+ },
734
+ });
735
+ })($ || ($ = {}));
736
+ //mol/object/object.test.ts
737
+ ;
738
+ "use strict";
739
+ var $;
740
+ (function ($_1) {
741
+ $mol_test({
742
+ 'Collect deps'() {
743
+ const pub1 = new $mol_wire_pub;
744
+ const pub2 = new $mol_wire_pub;
745
+ const sub = new $mol_wire_pub_sub;
746
+ const bu1 = sub.track_on();
747
+ try {
748
+ pub1.promote();
749
+ pub2.promote();
750
+ pub2.promote();
751
+ }
752
+ finally {
753
+ sub.track_cut();
754
+ sub.track_off(bu1);
755
+ }
756
+ pub1.emit();
757
+ pub2.emit();
758
+ $mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
759
+ const bu2 = sub.track_on();
760
+ try {
761
+ pub1.promote();
762
+ pub1.promote();
763
+ pub2.promote();
764
+ }
765
+ finally {
766
+ sub.track_cut();
767
+ sub.track_off(bu2);
768
+ }
769
+ pub1.emit();
770
+ pub2.emit();
771
+ $mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
772
+ },
773
+ 'cyclic detection'($) {
774
+ const sub1 = new $mol_wire_pub_sub;
775
+ const sub2 = new $mol_wire_pub_sub;
776
+ const bu1 = sub1.track_on();
777
+ try {
778
+ const bu2 = sub2.track_on();
779
+ try {
780
+ $mol_assert_fail(() => sub1.promote(), 'Circular subscription');
781
+ }
782
+ finally {
783
+ sub2.track_cut();
784
+ sub2.track_off(bu2);
785
+ }
786
+ }
787
+ finally {
788
+ sub1.track_cut();
789
+ sub1.track_off(bu1);
790
+ }
791
+ },
792
+ });
793
+ })($ || ($ = {}));
794
+ //mol/wire/pub/sub/sub.test.ts
795
+ ;
796
+ "use strict";
797
+ var $;
798
+ (function ($) {
799
+ $.$mol_after_mock_queue = [];
800
+ function $mol_after_mock_warp() {
801
+ const queue = $.$mol_after_mock_queue.splice(0);
802
+ for (const task of queue)
803
+ task();
804
+ }
805
+ $.$mol_after_mock_warp = $mol_after_mock_warp;
806
+ class $mol_after_mock_commmon extends $mol_object2 {
807
+ task;
808
+ promise = Promise.resolve();
809
+ cancelled = false;
810
+ id;
811
+ constructor(task) {
812
+ super();
813
+ this.task = task;
814
+ $.$mol_after_mock_queue.push(task);
815
+ }
816
+ destructor() {
817
+ const index = $.$mol_after_mock_queue.indexOf(this.task);
818
+ if (index >= 0)
819
+ $.$mol_after_mock_queue.splice(index, 1);
820
+ }
821
+ }
822
+ $.$mol_after_mock_commmon = $mol_after_mock_commmon;
823
+ class $mol_after_mock_timeout extends $mol_after_mock_commmon {
824
+ delay;
825
+ constructor(delay, task) {
826
+ super(task);
827
+ this.delay = delay;
828
+ }
829
+ }
830
+ $.$mol_after_mock_timeout = $mol_after_mock_timeout;
831
+ })($ || ($ = {}));
832
+ //mol/after/mock/mock.test.ts
833
+ ;
834
+ "use strict";
835
+ var $;
836
+ (function ($_1) {
837
+ $mol_test_mocks.push($ => {
838
+ $.$mol_after_frame = $mol_after_mock_commmon;
839
+ });
840
+ })($ || ($ = {}));
841
+ //mol/after/frame/frame.test.ts
842
+ ;
843
+ "use strict";
844
+ var $;
845
+ (function ($) {
846
+ $mol_test({
847
+ 'Sync execution'() {
848
+ class Sync extends $mol_object2 {
849
+ static calc(a, b) {
850
+ return a + b;
851
+ }
852
+ }
853
+ __decorate([
854
+ $mol_wire_method
855
+ ], Sync, "calc", null);
856
+ $mol_assert_equal(Sync.calc(1, 2), 3);
857
+ },
858
+ async 'async <=> sync'() {
859
+ class SyncAsync extends $mol_object2 {
860
+ static async val(a) {
861
+ return a;
862
+ }
863
+ static sum(a, b) {
864
+ const syn = $mol_wire_sync(this);
865
+ return syn.val(a) + syn.val(b);
866
+ }
867
+ static async calc(a, b) {
868
+ return 5 + await $mol_wire_async(this).sum(a, b);
869
+ }
870
+ }
871
+ $mol_assert_equal(await SyncAsync.calc(1, 2), 8);
872
+ },
873
+ async 'Idempotence control'() {
874
+ class Idempotence extends $mol_object2 {
875
+ static logs_idemp = 0;
876
+ static logs_unidemp = 0;
877
+ static log_idemp() {
878
+ this.logs_idemp += 1;
879
+ }
880
+ static log_unidemp() {
881
+ this.logs_unidemp += 1;
882
+ }
883
+ static async val(a) {
884
+ return a;
885
+ }
886
+ static sum(a, b) {
887
+ this.log_idemp();
888
+ this.log_unidemp();
889
+ const syn = $mol_wire_sync(this);
890
+ return syn.val(a) + syn.val(b);
891
+ }
892
+ static async calc(a, b) {
893
+ return 5 + await $mol_wire_async(this).sum(a, b);
894
+ }
895
+ }
896
+ __decorate([
897
+ $mol_wire_method
898
+ ], Idempotence, "log_idemp", null);
899
+ $mol_assert_equal(await Idempotence.calc(1, 2), 8);
900
+ $mol_assert_equal(Idempotence.logs_idemp, 1);
901
+ $mol_assert_equal(Idempotence.logs_unidemp, 3);
902
+ },
903
+ async 'Error handling'() {
904
+ class Handle extends $mol_object2 {
905
+ static async sum(a, b) {
906
+ $mol_fail(new Error('test error ' + (a + b)));
907
+ }
908
+ static check() {
909
+ try {
910
+ return $mol_wire_sync(Handle).sum(1, 2);
911
+ }
912
+ catch (error) {
913
+ if ($mol_promise_like(error))
914
+ $mol_fail_hidden(error);
915
+ $mol_assert_equal(error.message, 'test error 3');
916
+ }
917
+ }
918
+ }
919
+ await $mol_wire_async(Handle).check();
920
+ },
921
+ });
922
+ })($ || ($ = {}));
923
+ //mol/wire/fiber/fiber.test.ts
924
+ ;
925
+ "use strict";
926
+ //mol/type/tail/tail.test.ts
927
+ ;
928
+ "use strict";
929
+ var $;
930
+ (function ($) {
931
+ function $mol_promise() {
932
+ let done;
933
+ let fail;
934
+ const promise = new Promise((d, f) => {
935
+ done = d;
936
+ fail = f;
937
+ });
938
+ return Object.assign(promise, {
939
+ done,
940
+ fail,
941
+ });
942
+ }
943
+ $.$mol_promise = $mol_promise;
944
+ })($ || ($ = {}));
945
+ //mol/promise/promise/promise.ts
946
+ ;
947
+ "use strict";
948
+ var $;
949
+ (function ($_1) {
950
+ $mol_test_mocks.push($ => {
951
+ $.$mol_after_timeout = $mol_after_mock_timeout;
952
+ });
953
+ })($ || ($ = {}));
954
+ //mol/after/timeout/timeout.test.ts
955
+ ;
956
+ "use strict";
957
+ var $;
958
+ (function ($) {
959
+ function $mol_wait_timeout_async(timeout) {
960
+ const promise = $mol_promise();
961
+ const task = new this.$mol_after_timeout(timeout, () => promise.done());
962
+ return Object.assign(promise, {
963
+ destructor: () => task.destructor()
964
+ });
965
+ }
966
+ $.$mol_wait_timeout_async = $mol_wait_timeout_async;
967
+ function $mol_wait_timeout(timeout) {
968
+ return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
969
+ }
970
+ $.$mol_wait_timeout = $mol_wait_timeout;
971
+ })($ || ($ = {}));
972
+ //mol/wait/timeout/timeout.ts
973
+ ;
974
+ "use strict";
975
+ var $;
976
+ (function ($_1) {
977
+ $mol_test({
978
+ async 'Latest method calls wins'($) {
979
+ class NameLogger extends $mol_object2 {
980
+ static $ = $;
981
+ static first = [];
982
+ static last = [];
983
+ static send(next) {
984
+ $mol_wire_sync(this.first).push(next);
985
+ this.$.$mol_wait_timeout(0);
986
+ this.last.push(next);
987
+ }
988
+ }
989
+ const name = $mol_wire_async(NameLogger).send;
990
+ name('john');
991
+ const promise = name('jin');
992
+ $.$mol_after_mock_warp();
993
+ await promise;
994
+ $mol_assert_like(NameLogger.first, ['john', 'jin']);
995
+ $mol_assert_like(NameLogger.last, ['jin']);
996
+ },
997
+ async 'Latest function calls wins'($) {
998
+ const first = [];
999
+ const last = [];
1000
+ function send_name(next) {
1001
+ $mol_wire_sync(first).push(next);
1002
+ $.$mol_wait_timeout(0);
1003
+ last.push(next);
1004
+ }
1005
+ const name = $mol_wire_async(send_name);
1006
+ name('john');
1007
+ const promise = name('jin');
1008
+ $.$mol_after_mock_warp();
1009
+ await promise;
1010
+ $mol_assert_like(first, ['john', 'jin']);
1011
+ $mol_assert_like(last, ['jin']);
1012
+ },
1013
+ });
1014
+ })($ || ($ = {}));
1015
+ //mol/wire/async/async.test.ts
1016
+ ;
1017
+ "use strict";
1018
+ var $;
1019
+ (function ($_1) {
1020
+ $mol_test({
1021
+ 'Cached channel'($) {
1022
+ class App extends $mol_object2 {
1023
+ static $ = $;
1024
+ static value(next = 1) {
1025
+ return next + 1;
1026
+ }
1027
+ }
1028
+ __decorate([
1029
+ $mol_wire_solo
1030
+ ], App, "value", null);
1031
+ $mol_assert_equal(App.value(), 2);
1032
+ App.value(2);
1033
+ $mol_assert_equal(App.value(), 3);
1034
+ },
1035
+ 'Read Pushed'($) {
1036
+ class App extends $mol_object2 {
1037
+ static $ = $;
1038
+ static value(next = 0) {
1039
+ return next;
1040
+ }
1041
+ }
1042
+ __decorate([
1043
+ $mol_wire_solo
1044
+ ], App, "value", null);
1045
+ $mol_assert_equal(App.value(1), 1);
1046
+ $mol_assert_equal(App.value(), 1);
1047
+ },
1048
+ 'Mem overrides mem'($) {
1049
+ class Base extends $mol_object2 {
1050
+ static $ = $;
1051
+ static value(next = 1) {
1052
+ return next + 1;
1053
+ }
1054
+ }
1055
+ __decorate([
1056
+ $mol_wire_solo
1057
+ ], Base, "value", null);
1058
+ class Middle extends Base {
1059
+ static value(next) {
1060
+ return super.value(next) + 1;
1061
+ }
1062
+ }
1063
+ __decorate([
1064
+ $mol_wire_solo
1065
+ ], Middle, "value", null);
1066
+ class App extends Middle {
1067
+ static value(next) {
1068
+ return super.value(next) * 3;
1069
+ }
1070
+ }
1071
+ __decorate([
1072
+ $mol_wire_solo
1073
+ ], App, "value", null);
1074
+ $mol_assert_equal(App.value(), 9);
1075
+ $mol_assert_equal(App.value(5), 21);
1076
+ $mol_assert_equal(App.value(), 21);
1077
+ },
1078
+ 'Auto recalculation of cached values'($) {
1079
+ class App extends $mol_object2 {
1080
+ static $ = $;
1081
+ static xxx(next) {
1082
+ return next || 1;
1083
+ }
1084
+ static yyy() {
1085
+ return this.xxx() + 1;
1086
+ }
1087
+ static zzz() {
1088
+ return this.yyy() + 1;
1089
+ }
1090
+ }
1091
+ __decorate([
1092
+ $mol_wire_solo
1093
+ ], App, "xxx", null);
1094
+ __decorate([
1095
+ $mol_wire_solo
1096
+ ], App, "yyy", null);
1097
+ __decorate([
1098
+ $mol_wire_solo
1099
+ ], App, "zzz", null);
1100
+ $mol_assert_equal(App.yyy(), 2);
1101
+ $mol_assert_equal(App.zzz(), 3);
1102
+ App.xxx(5);
1103
+ $mol_assert_equal(App.zzz(), 7);
1104
+ },
1105
+ 'Skip recalculation when actually no dependency changes'($) {
1106
+ const log = [];
1107
+ class App extends $mol_object2 {
1108
+ static $ = $;
1109
+ static xxx(next) {
1110
+ log.push('xxx');
1111
+ return next || 1;
1112
+ }
1113
+ static yyy() {
1114
+ log.push('yyy');
1115
+ return [Math.sign(this.xxx())];
1116
+ }
1117
+ static zzz() {
1118
+ log.push('zzz');
1119
+ return this.yyy()[0] + 1;
1120
+ }
1121
+ }
1122
+ __decorate([
1123
+ $mol_wire_solo
1124
+ ], App, "xxx", null);
1125
+ __decorate([
1126
+ $mol_wire_solo
1127
+ ], App, "yyy", null);
1128
+ __decorate([
1129
+ $mol_wire_solo
1130
+ ], App, "zzz", null);
1131
+ App.zzz();
1132
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx']);
1133
+ App.xxx(5);
1134
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx']);
1135
+ App.zzz();
1136
+ $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
1137
+ },
1138
+ 'Flow: Auto'($) {
1139
+ class App extends $mol_object2 {
1140
+ static get $() { return $; }
1141
+ static source(next = 1) { return next; }
1142
+ static condition(next = true) { return next; }
1143
+ static counter = 0;
1144
+ static result() {
1145
+ const res = this.condition() ? this.source() : 0;
1146
+ return res + this.counter++;
1147
+ }
1148
+ }
1149
+ __decorate([
1150
+ $mol_wire_solo
1151
+ ], App, "source", null);
1152
+ __decorate([
1153
+ $mol_wire_solo
1154
+ ], App, "condition", null);
1155
+ __decorate([
1156
+ $mol_wire_solo
1157
+ ], App, "result", null);
1158
+ $mol_assert_equal(App.result(), 1);
1159
+ $mol_assert_equal(App.counter, 1);
1160
+ App.source(10);
1161
+ $mol_assert_equal(App.result(), 11);
1162
+ $mol_assert_equal(App.counter, 2);
1163
+ App.condition(false);
1164
+ $mol_assert_equal(App.result(), 2);
1165
+ $mol_assert_equal(App.counter, 3);
1166
+ $mol_wire_fiber.sync();
1167
+ $mol_assert_equal(App.source(), 1);
1168
+ App.source(20);
1169
+ $mol_assert_equal(App.result(), 2);
1170
+ $mol_assert_equal(App.counter, 3);
1171
+ App.condition(true);
1172
+ $mol_assert_equal(App.result(), 23);
1173
+ $mol_assert_equal(App.counter, 4);
1174
+ },
1175
+ 'Dupes: Equality'($) {
1176
+ let counter = 0;
1177
+ class App extends $mol_object2 {
1178
+ static $ = $;
1179
+ static foo(next) {
1180
+ return next ?? { numbs: [1] };
1181
+ }
1182
+ static bar() {
1183
+ return { ...this.foo(), count: ++counter };
1184
+ }
1185
+ }
1186
+ __decorate([
1187
+ $mol_wire_solo
1188
+ ], App, "foo", null);
1189
+ __decorate([
1190
+ $mol_wire_solo
1191
+ ], App, "bar", null);
1192
+ $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1193
+ App.foo({ numbs: [1] });
1194
+ $mol_assert_like(App.bar(), { numbs: [1], count: 1 });
1195
+ App.foo({ numbs: [2] });
1196
+ $mol_assert_like(App.bar(), { numbs: [2], count: 2 });
1197
+ },
1198
+ 'Cycle: Fail'($) {
1199
+ class App extends $mol_object2 {
1200
+ static $ = $;
1201
+ static foo() {
1202
+ return this.bar() + 1;
1203
+ }
1204
+ static bar() {
1205
+ return this.foo() + 1;
1206
+ }
1207
+ static test() {
1208
+ $mol_assert_fail(() => App.foo(), 'Circular subscription');
1209
+ }
1210
+ }
1211
+ __decorate([
1212
+ $mol_wire_solo
1213
+ ], App, "foo", null);
1214
+ __decorate([
1215
+ $mol_wire_solo
1216
+ ], App, "bar", null);
1217
+ __decorate([
1218
+ $mol_wire_method
1219
+ ], App, "test", null);
1220
+ App.test();
1221
+ },
1222
+ 'Different order of pull and push'($) {
1223
+ class App extends $mol_object2 {
1224
+ static $ = $;
1225
+ static store(next = 0) {
1226
+ return next;
1227
+ }
1228
+ static fast(next) {
1229
+ return this.store(next);
1230
+ }
1231
+ static slow(next) {
1232
+ if (next !== undefined)
1233
+ this.slow();
1234
+ return this.store(next);
1235
+ }
1236
+ }
1237
+ __decorate([
1238
+ $mol_wire_solo
1239
+ ], App, "store", null);
1240
+ __decorate([
1241
+ $mol_wire_solo
1242
+ ], App, "fast", null);
1243
+ __decorate([
1244
+ $mol_wire_solo
1245
+ ], App, "slow", null);
1246
+ App.fast();
1247
+ $mol_assert_equal(App.slow(666), 666);
1248
+ $mol_assert_equal(App.fast(), App.slow(), 666);
1249
+ App.store(777);
1250
+ $mol_assert_equal(App.fast(), App.slow(), 777);
1251
+ },
1252
+ 'Actions inside invariant'($) {
1253
+ class App extends $mol_object2 {
1254
+ static $ = $;
1255
+ static count(next = 0) {
1256
+ return next;
1257
+ }
1258
+ static count2() {
1259
+ return this.count();
1260
+ }
1261
+ static res() {
1262
+ const count = this.count2();
1263
+ if (!count)
1264
+ this.count(count + 1);
1265
+ return count + 1;
1266
+ }
1267
+ }
1268
+ __decorate([
1269
+ $mol_wire_solo
1270
+ ], App, "count", null);
1271
+ __decorate([
1272
+ $mol_wire_solo
1273
+ ], App, "count2", null);
1274
+ __decorate([
1275
+ $mol_wire_solo
1276
+ ], App, "res", null);
1277
+ $mol_assert_like(App.res(), 1);
1278
+ App.count(5);
1279
+ $mol_assert_like(App.res(), 6);
1280
+ },
1281
+ async 'Toggle with async'($) {
1282
+ class App extends $mol_object2 {
1283
+ static $ = $;
1284
+ static checked(next = false) {
1285
+ $$.$mol_wait_timeout(0);
1286
+ return next;
1287
+ }
1288
+ static toggle() {
1289
+ const prev = this.checked();
1290
+ $mol_assert_unique(this.checked(!prev), prev);
1291
+ }
1292
+ static res() {
1293
+ return this.checked();
1294
+ }
1295
+ static test() {
1296
+ $mol_assert_equal(App.res(), false);
1297
+ App.toggle();
1298
+ $mol_assert_equal(App.res(), true);
1299
+ }
1300
+ }
1301
+ __decorate([
1302
+ $mol_wire_solo
1303
+ ], App, "checked", null);
1304
+ __decorate([
1305
+ $mol_wire_method
1306
+ ], App, "toggle", null);
1307
+ __decorate([
1308
+ $mol_wire_solo
1309
+ ], App, "res", null);
1310
+ __decorate([
1311
+ $mol_wire_method
1312
+ ], App, "test", null);
1313
+ await $mol_wire_async(App).test();
1314
+ },
1315
+ 'Restore after error'($) {
1316
+ class App extends $mol_object2 {
1317
+ static get $() { return $; }
1318
+ static condition(next = false) { return next; }
1319
+ static broken() {
1320
+ if (this.condition()) {
1321
+ $mol_fail(new Error('test error'));
1322
+ }
1323
+ return 1;
1324
+ }
1325
+ static result() {
1326
+ return this.broken();
1327
+ }
1328
+ }
1329
+ __decorate([
1330
+ $mol_wire_solo
1331
+ ], App, "condition", null);
1332
+ __decorate([
1333
+ $mol_wire_solo
1334
+ ], App, "broken", null);
1335
+ __decorate([
1336
+ $mol_wire_solo
1337
+ ], App, "result", null);
1338
+ $mol_assert_equal(App.result(), 1);
1339
+ App.condition(true);
1340
+ $mol_assert_fail(() => App.result());
1341
+ App.condition(false);
1342
+ $mol_assert_equal(App.result(), 1);
1343
+ },
1344
+ async 'Wait for data'($) {
1345
+ class App extends $mol_object2 {
1346
+ static $ = $;
1347
+ static async source() {
1348
+ return 'Jin';
1349
+ }
1350
+ static middle() {
1351
+ return $mol_wire_sync(this).source();
1352
+ }
1353
+ static target() {
1354
+ return this.middle();
1355
+ }
1356
+ static test() {
1357
+ $mol_assert_equal(App.target(), 'Jin');
1358
+ }
1359
+ }
1360
+ __decorate([
1361
+ $mol_wire_solo
1362
+ ], App, "middle", null);
1363
+ __decorate([
1364
+ $mol_wire_solo
1365
+ ], App, "target", null);
1366
+ __decorate([
1367
+ $mol_wire_method
1368
+ ], App, "test", null);
1369
+ await $mol_wire_async(App).test();
1370
+ },
1371
+ 'Auto destroy on long alone'($) {
1372
+ let destroyed = false;
1373
+ class App extends $mol_object2 {
1374
+ static $ = $;
1375
+ static showing(next = true) {
1376
+ return next;
1377
+ }
1378
+ static details() {
1379
+ return {
1380
+ destructor() {
1381
+ destroyed = true;
1382
+ }
1383
+ };
1384
+ }
1385
+ static render() {
1386
+ return this.showing() ? this.details() : null;
1387
+ }
1388
+ }
1389
+ __decorate([
1390
+ $mol_wire_solo
1391
+ ], App, "showing", null);
1392
+ __decorate([
1393
+ $mol_wire_solo
1394
+ ], App, "details", null);
1395
+ __decorate([
1396
+ $mol_wire_solo
1397
+ ], App, "render", null);
1398
+ const details = App.render();
1399
+ $mol_assert_ok(details);
1400
+ App.showing(false);
1401
+ $mol_assert_not(App.render());
1402
+ App.showing(true);
1403
+ $mol_assert_equal(App.render(), details);
1404
+ $mol_wire_fiber.sync();
1405
+ $mol_assert_not(destroyed);
1406
+ App.showing(false);
1407
+ $mol_wire_fiber.sync();
1408
+ $mol_assert_ok(destroyed);
1409
+ App.showing(true);
1410
+ $mol_assert_unique(App.render(), details);
1411
+ },
1412
+ async 'Hold pubs while wait async task'($) {
1413
+ class App extends $mol_object2 {
1414
+ static $ = $;
1415
+ static counter = 0;
1416
+ static resets(next) {
1417
+ return ($mol_wire_probe(() => this.resets()) ?? -1) + 1;
1418
+ }
1419
+ static async wait() { }
1420
+ static value() {
1421
+ return ++this.counter;
1422
+ }
1423
+ static result() {
1424
+ if (this.resets())
1425
+ $mol_wire_sync(this).wait();
1426
+ return this.value();
1427
+ }
1428
+ static test() {
1429
+ }
1430
+ }
1431
+ __decorate([
1432
+ $mol_wire_solo
1433
+ ], App, "resets", null);
1434
+ __decorate([
1435
+ $mol_wire_solo
1436
+ ], App, "value", null);
1437
+ __decorate([
1438
+ $mol_wire_solo
1439
+ ], App, "result", null);
1440
+ __decorate([
1441
+ $mol_wire_method
1442
+ ], App, "test", null);
1443
+ $mol_assert_equal(App.result(), 1);
1444
+ App.resets(null);
1445
+ $mol_wire_fiber.sync();
1446
+ $mol_assert_equal(await $mol_wire_async(App).result(), 1);
1447
+ },
1448
+ 'Owned value has js-path name'() {
1449
+ class App extends $mol_object2 {
1450
+ static title() {
1451
+ return new $mol_object2;
1452
+ }
1453
+ }
1454
+ __decorate([
1455
+ $mol_wire_solo
1456
+ ], App, "title", null);
1457
+ $mol_assert_equal(`${App.title()}`, 'App.title()');
1458
+ },
1459
+ 'Unsubscribe from temp pubs on complete'($) {
1460
+ class Random extends $mol_object2 {
1461
+ static $ = $;
1462
+ static seed() {
1463
+ return Math.random();
1464
+ }
1465
+ static resets(next) {
1466
+ return Math.random();
1467
+ }
1468
+ static value() {
1469
+ this.resets();
1470
+ return this.seed();
1471
+ }
1472
+ }
1473
+ __decorate([
1474
+ $mol_wire_method
1475
+ ], Random, "seed", null);
1476
+ __decorate([
1477
+ $mol_wire_solo
1478
+ ], Random, "resets", null);
1479
+ __decorate([
1480
+ $mol_wire_solo
1481
+ ], Random, "value", null);
1482
+ const first = Random.value();
1483
+ Random.resets(null);
1484
+ $mol_assert_unique(Random.value(), first);
1485
+ },
1486
+ });
1487
+ })($ || ($ = {}));
1488
+ //mol/wire/solo/solo.test.ts
1489
+ ;
1490
+ "use strict";
1491
+ var $;
1492
+ (function ($_1) {
1493
+ $mol_test({
1494
+ 'Memoize by single simple key'($) {
1495
+ class Team extends $mol_object2 {
1496
+ static $ = $;
1497
+ static user_name(user, next) {
1498
+ return next ?? user;
1499
+ }
1500
+ static user_names() {
1501
+ return [
1502
+ this.user_name('jin'),
1503
+ this.user_name('john'),
1504
+ ];
1505
+ }
1506
+ }
1507
+ __decorate([
1508
+ $mol_wire_plex
1509
+ ], Team, "user_name", null);
1510
+ __decorate([
1511
+ $mol_wire_solo
1512
+ ], Team, "user_names", null);
1513
+ $mol_assert_like(Team.user_names(), ['jin', 'john']);
1514
+ Team.user_name('jin', 'JIN');
1515
+ $mol_assert_like(Team.user_names(), ['JIN', 'john']);
1516
+ },
1517
+ 'Memoize by single complex key'($) {
1518
+ class Map extends $mol_object2 {
1519
+ static $ = $;
1520
+ static tile(pos) {
1521
+ return new String(`/tile=${pos}`);
1522
+ }
1523
+ static test() {
1524
+ $mol_assert_like(this.tile([0, 1]), new String('/tile=0,1'));
1525
+ $mol_assert_equal(this.tile([0, 1]), this.tile([0, 1]));
1526
+ }
1527
+ }
1528
+ __decorate([
1529
+ $mol_wire_plex
1530
+ ], Map, "tile", null);
1531
+ __decorate([
1532
+ $mol_wire_method
1533
+ ], Map, "test", null);
1534
+ Map.test();
1535
+ },
1536
+ 'Owned value has js-path name'() {
1537
+ class App extends $mol_object2 {
1538
+ static like(friend) {
1539
+ return new $mol_object2;
1540
+ }
1541
+ static relation([friend, props]) {
1542
+ return new $mol_object2;
1543
+ }
1544
+ }
1545
+ __decorate([
1546
+ $mol_wire_plex
1547
+ ], App, "like", null);
1548
+ __decorate([
1549
+ $mol_wire_plex
1550
+ ], App, "relation", null);
1551
+ $mol_assert_equal(`${App.like(123)}`, 'App.like(123)');
1552
+ $mol_assert_equal(`${App.relation([123, [456]])}`, 'App.relation([123,[456]])');
1553
+ },
1554
+ 'Deep deps'($) {
1555
+ class Fib extends $mol_object2 {
1556
+ static $ = $;
1557
+ static sums = 0;
1558
+ static value(index, next) {
1559
+ if (next)
1560
+ return next;
1561
+ if (index < 2)
1562
+ return 1;
1563
+ ++this.sums;
1564
+ return this.value(index - 1) + this.value(index - 2);
1565
+ }
1566
+ }
1567
+ __decorate([
1568
+ $mol_wire_plex
1569
+ ], Fib, "value", null);
1570
+ $mol_assert_equal(Fib.value(4), 5);
1571
+ $mol_assert_equal(Fib.sums, 3);
1572
+ Fib.value(1, 2);
1573
+ $mol_assert_equal(Fib.value(4), 8);
1574
+ $mol_assert_equal(Fib.sums, 6);
1575
+ },
1576
+ });
1577
+ })($ || ($ = {}));
1578
+ //mol/wire/plex/plex.test.ts
1579
+ ;
1580
+ "use strict";
1581
+ var $;
1582
+ (function ($) {
1583
+ $mol_test({
1584
+ 'Previous value'() {
1585
+ class Cache extends $mol_object2 {
1586
+ static store(next) {
1587
+ if (!next)
1588
+ return {};
1589
+ return {
1590
+ ...$mol_wire_probe(() => this.store()) ?? {},
1591
+ ...next,
1592
+ };
1593
+ }
1594
+ }
1595
+ __decorate([
1596
+ $mol_wire_solo
1597
+ ], Cache, "store", null);
1598
+ $mol_assert_like(Cache.store(), {});
1599
+ $mol_assert_like(Cache.store({ foo: 666 }), { foo: 666 });
1600
+ $mol_assert_like(Cache.store({ bar: 777 }), { foo: 666, bar: 777 });
1601
+ },
1602
+ });
1603
+ })($ || ($ = {}));
1604
+ //mol/wire/probe/probe.test.ts
1605
+ ;
1606
+ "use strict";
1607
+ var $;
1608
+ (function ($_1) {
1609
+ $mol_test_mocks.push($ => {
1610
+ $.$mol_after_tick = $mol_after_mock_commmon;
1611
+ });
1612
+ })($ || ($ = {}));
1613
+ //mol/after/tick/tick.test.ts
1614
+ ;
1615
+ "use strict";
1616
+ var $;
1617
+ (function ($) {
1618
+ $mol_test({
1619
+ 'all cases of using maybe'() {
1620
+ $mol_assert_equal($mol_maybe(0)[0], 0);
1621
+ $mol_assert_equal($mol_maybe(false)[0], false);
1622
+ $mol_assert_equal($mol_maybe(null)[0], void 0);
1623
+ $mol_assert_equal($mol_maybe(void 0)[0], void 0);
1624
+ $mol_assert_equal($mol_maybe(void 0).map(v => v.toString())[0], void 0);
1625
+ $mol_assert_equal($mol_maybe(0).map(v => v.toString())[0], '0');
1626
+ },
1627
+ });
1628
+ })($ || ($ = {}));
1629
+ //mol/maybe/maybe.test.ts
1630
+ ;
1631
+ "use strict";
1632
+ var $;
1633
+ (function ($) {
1634
+ $mol_test({
1635
+ 'run callback'() {
1636
+ class Plus1 extends $mol_wrapper {
1637
+ static wrap(task) {
1638
+ return function (...args) {
1639
+ return task.call(this, ...args) + 1;
1640
+ };
1641
+ }
1642
+ }
1643
+ $mol_assert_equal(Plus1.run(() => 2), 3);
1644
+ },
1645
+ 'wrap function'() {
1646
+ class Plus1 extends $mol_wrapper {
1647
+ static wrap(task) {
1648
+ return function (...args) {
1649
+ return task.call(this, ...args) + 1;
1650
+ };
1651
+ }
1652
+ }
1653
+ const obj = {
1654
+ level: 2,
1655
+ pow: Plus1.func(function (a) {
1656
+ return a ** this.level;
1657
+ })
1658
+ };
1659
+ $mol_assert_equal(obj.pow(2), 5);
1660
+ },
1661
+ 'decorate field getter'() {
1662
+ class Plus1 extends $mol_wrapper {
1663
+ static last = 0;
1664
+ static wrap(task) {
1665
+ return function (...args) {
1666
+ return Plus1.last = (task.call(this, ...args) || 0) + 1;
1667
+ };
1668
+ }
1669
+ }
1670
+ class Foo {
1671
+ static get two() {
1672
+ return 1;
1673
+ }
1674
+ static set two(next) { }
1675
+ }
1676
+ __decorate([
1677
+ Plus1.field
1678
+ ], Foo, "two", null);
1679
+ $mol_assert_equal(Foo.two, 2);
1680
+ Foo.two = 3;
1681
+ $mol_assert_equal(Plus1.last, 2);
1682
+ $mol_assert_equal(Foo.two, 2);
1683
+ },
1684
+ 'decorate instance method'() {
1685
+ class Plus1 extends $mol_wrapper {
1686
+ static wrap(task) {
1687
+ return function (...args) {
1688
+ return task.call(this, ...args) + 1;
1689
+ };
1690
+ }
1691
+ }
1692
+ class Foo1 {
1693
+ level = 2;
1694
+ pow(a) {
1695
+ return a ** this.level;
1696
+ }
1697
+ }
1698
+ __decorate([
1699
+ Plus1.method
1700
+ ], Foo1.prototype, "pow", null);
1701
+ const Foo2 = Foo1;
1702
+ const foo = new Foo2;
1703
+ $mol_assert_equal(foo.pow(2), 5);
1704
+ },
1705
+ 'decorate static method'() {
1706
+ class Plus1 extends $mol_wrapper {
1707
+ static wrap(task) {
1708
+ return function (...args) {
1709
+ return task.call(this, ...args) + 1;
1710
+ };
1711
+ }
1712
+ }
1713
+ class Foo {
1714
+ static level = 2;
1715
+ static pow(a) {
1716
+ return a ** this.level;
1717
+ }
1718
+ }
1719
+ __decorate([
1720
+ Plus1.method
1721
+ ], Foo, "pow", null);
1722
+ $mol_assert_equal(Foo.pow(2), 5);
1723
+ },
1724
+ 'decorate class'() {
1725
+ class BarInc extends $mol_wrapper {
1726
+ static wrap(task) {
1727
+ return function (...args) {
1728
+ const foo = task.call(this, ...args);
1729
+ foo.bar++;
1730
+ return foo;
1731
+ };
1732
+ }
1733
+ }
1734
+ let Foo = class Foo {
1735
+ bar;
1736
+ constructor(bar) {
1737
+ this.bar = bar;
1738
+ }
1739
+ };
1740
+ Foo = __decorate([
1741
+ BarInc.class
1742
+ ], Foo);
1743
+ $mol_assert_equal(new Foo(2).bar, 3);
1744
+ },
1745
+ });
1746
+ })($ || ($ = {}));
1747
+ //mol/wrapper/wrapper.test.ts
1748
+ ;
1749
+ "use strict";
1750
+ var $;
1751
+ (function ($) {
1752
+ $mol_test({
1753
+ 'memoize field'() {
1754
+ class Foo {
1755
+ static one = 1;
1756
+ static get two() {
1757
+ return ++this.one;
1758
+ }
1759
+ static set two(next) { }
1760
+ }
1761
+ __decorate([
1762
+ $mol_memo.field
1763
+ ], Foo, "two", null);
1764
+ $mol_assert_equal(Foo.two, 2);
1765
+ $mol_assert_equal(Foo.two, 2);
1766
+ Foo.two = 3;
1767
+ $mol_assert_equal(Foo.two, 3);
1768
+ $mol_assert_equal(Foo.two, 3);
1769
+ },
1770
+ });
1771
+ })($ || ($ = {}));
1772
+ //mol/memo/memo.test.ts
1773
+ ;
1774
+ "use strict";
1775
+ var $;
1776
+ (function ($) {
1777
+ $mol_test({
1778
+ 'Primitives'() {
1779
+ $mol_assert_equal($mol_key(null), 'null');
1780
+ $mol_assert_equal($mol_key(false), 'false');
1781
+ $mol_assert_equal($mol_key(true), 'true');
1782
+ $mol_assert_equal($mol_key(0), '0');
1783
+ $mol_assert_equal($mol_key(''), '""');
1784
+ },
1785
+ 'Array & POJO'() {
1786
+ $mol_assert_equal($mol_key([null]), '[null]');
1787
+ $mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
1788
+ $mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
1789
+ },
1790
+ 'Function'() {
1791
+ const func = () => { };
1792
+ $mol_assert_equal($mol_key(func), $mol_key(func));
1793
+ $mol_assert_unique($mol_key(func), $mol_key(() => { }));
1794
+ },
1795
+ 'Objects'() {
1796
+ class User {
1797
+ }
1798
+ const jin = new User();
1799
+ $mol_assert_equal($mol_key(jin), $mol_key(jin));
1800
+ $mol_assert_unique($mol_key(jin), $mol_key(new User()));
1801
+ },
1802
+ 'Elements'() {
1803
+ const foo = $mol_jsx("div", null, "bar");
1804
+ $mol_assert_equal($mol_key(foo), $mol_key(foo));
1805
+ $mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
1806
+ },
1807
+ 'Custom JSON representation'() {
1808
+ class User {
1809
+ name;
1810
+ age;
1811
+ constructor(name, age) {
1812
+ this.name = name;
1813
+ this.age = age;
1814
+ }
1815
+ toJSON() { return { name: this.name }; }
1816
+ }
1817
+ $mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
1818
+ },
1819
+ 'Special native classes'() {
1820
+ $mol_assert_equal($mol_key(new Date('xyz')), 'null');
1821
+ $mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
1822
+ $mol_assert_equal($mol_key(/./), '"/./"');
1823
+ $mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
1824
+ },
1825
+ });
1826
+ })($ || ($ = {}));
1827
+ //mol/key/key.test.tsx
1828
+ ;
1829
+ "use strict";
1830
+ //mol/type/foot/foot.test.ts
1831
+ ;
1832
+ "use strict";
1833
+ var $;
1834
+ (function ($) {
1835
+ class $mol_wire_log extends $mol_object2 {
1836
+ static watch(task) {
1837
+ return task;
1838
+ }
1839
+ static track(fiber) {
1840
+ const prev = $mol_wire_probe(() => this.track(fiber));
1841
+ let next;
1842
+ try {
1843
+ next = fiber.sync();
1844
+ }
1845
+ finally {
1846
+ for (const pub of fiber.pub_list) {
1847
+ if (pub instanceof $mol_wire_fiber) {
1848
+ this.track(pub);
1849
+ }
1850
+ }
1851
+ }
1852
+ if (fiber.host === this)
1853
+ return next;
1854
+ if ($mol_compare_deep(prev, next)) {
1855
+ this.$.$mol_log3_rise({
1856
+ message: '💧 Same',
1857
+ place: fiber,
1858
+ });
1859
+ }
1860
+ else if (prev !== undefined) {
1861
+ this.$.$mol_log3_rise({
1862
+ message: '🔥 Next',
1863
+ place: fiber,
1864
+ prev,
1865
+ });
1866
+ }
1867
+ return next;
1868
+ }
1869
+ static active() {
1870
+ try {
1871
+ this.watch()?.();
1872
+ }
1873
+ catch (error) {
1874
+ $mol_fail_log(error);
1875
+ }
1876
+ finally {
1877
+ for (const pub of $mol_wire_auto().pub_list) {
1878
+ if (pub instanceof $mol_wire_fiber) {
1879
+ this.track(pub);
1880
+ }
1881
+ }
1882
+ }
1883
+ }
1884
+ }
1885
+ __decorate([
1886
+ $mol_mem
1887
+ ], $mol_wire_log, "watch", null);
1888
+ __decorate([
1889
+ $mol_mem_key
1890
+ ], $mol_wire_log, "track", null);
1891
+ __decorate([
1892
+ $mol_mem
1893
+ ], $mol_wire_log, "active", null);
1894
+ $.$mol_wire_log = $mol_wire_log;
1895
+ })($ || ($ = {}));
1896
+ //mol/wire/log/log.ts
1897
+ ;
1898
+ "use strict";
1899
+ var $;
1900
+ (function ($) {
1901
+ $mol_wire_log.active();
1902
+ })($ || ($ = {}));
1903
+ //mol/wire/atom/atom.test.ts
1904
+ ;
1905
+ "use strict";
1906
+ var $;
1907
+ (function ($) {
1908
+ $mol_test({
1909
+ 'const returns stored value'() {
1910
+ const foo = { bar: $mol_const(Math.random()) };
1911
+ $mol_assert_equal(foo.bar(), foo.bar());
1912
+ $mol_assert_equal(foo.bar(), foo.bar['()']);
1913
+ },
1914
+ });
1915
+ })($ || ($ = {}));
1916
+ //mol/const/const.test.ts
1917
+ ;
1918
+ "use strict";
1919
+ var $;
1920
+ (function ($_1) {
1921
+ $mol_test({
1922
+ 'id auto generation'($) {
1923
+ class $mol_view_test_item extends $mol_view {
1924
+ }
1925
+ class $mol_view_test_block extends $mol_view {
1926
+ static $ = $;
1927
+ element(id) {
1928
+ return new $mol_view_test_item();
1929
+ }
1930
+ }
1931
+ __decorate([
1932
+ $mol_mem_key
1933
+ ], $mol_view_test_block.prototype, "element", null);
1934
+ var x = $mol_view_test_block.Root(0);
1935
+ $mol_assert_equal(x.dom_node().id, '$mol_view_test_block.Root(0)');
1936
+ $mol_assert_equal(x.element(0).dom_node().id, '$mol_view_test_block.Root(0).element(0)');
1937
+ },
1938
+ 'caching ref to dom node'($) {
1939
+ var x = new class extends $mol_view {
1940
+ };
1941
+ x.$ = $;
1942
+ $mol_assert_equal(x.dom_node(), x.dom_node());
1943
+ },
1944
+ 'content render'($) {
1945
+ class $mol_view_test extends $mol_view {
1946
+ sub() {
1947
+ return ['lol', 5];
1948
+ }
1949
+ }
1950
+ var x = new $mol_view_test();
1951
+ x.$ = $;
1952
+ var node = x.dom_tree();
1953
+ $mol_assert_equal(node.innerHTML, 'lol5');
1954
+ },
1955
+ 'bem attributes generation'($) {
1956
+ class $mol_view_test_item extends $mol_view {
1957
+ }
1958
+ class $mol_view_test_block extends $mol_view {
1959
+ Element(id) {
1960
+ return new $mol_view_test_item();
1961
+ }
1962
+ }
1963
+ __decorate([
1964
+ $mol_mem_key
1965
+ ], $mol_view_test_block.prototype, "Element", null);
1966
+ var x = new $mol_view_test_block();
1967
+ x.$ = $;
1968
+ $mol_assert_equal(x.dom_node().getAttribute('mol_view_test_block'), '');
1969
+ $mol_assert_equal(x.dom_node().getAttribute('mol_view'), '');
1970
+ $mol_assert_equal(x.Element(0).dom_node().getAttribute('mol_view_test_block_element'), '');
1971
+ $mol_assert_equal(x.Element(0).dom_node().getAttribute('mol_view_test_item'), '');
1972
+ $mol_assert_equal(x.Element(0).dom_node().getAttribute('mol_view'), '');
1973
+ },
1974
+ 'render custom attributes'($) {
1975
+ class $mol_view_test extends $mol_view {
1976
+ attr() {
1977
+ return {
1978
+ 'href': '#haha',
1979
+ 'required': true,
1980
+ 'hidden': false,
1981
+ };
1982
+ }
1983
+ }
1984
+ var x = new $mol_view_test();
1985
+ x.$ = $;
1986
+ var node = x.dom_tree();
1987
+ $mol_assert_equal(node.getAttribute('href'), '#haha');
1988
+ $mol_assert_equal(node.getAttribute('required'), 'true');
1989
+ $mol_assert_equal(node.getAttribute('hidden'), null);
1990
+ },
1991
+ 'render custom fields'($) {
1992
+ class $mol_view_test extends $mol_view {
1993
+ field() {
1994
+ return {
1995
+ 'hidden': true
1996
+ };
1997
+ }
1998
+ }
1999
+ var x = new $mol_view_test();
2000
+ x.$ = $;
2001
+ var node = x.dom_tree();
2002
+ $mol_assert_equal(node.hidden, true);
2003
+ },
2004
+ 'attach event handlers'($) {
2005
+ var clicked = false;
2006
+ class $mol_view_test extends $mol_view {
2007
+ event() {
2008
+ return {
2009
+ 'click': (next) => this.event_click(next)
2010
+ };
2011
+ }
2012
+ event_click(next) {
2013
+ clicked = true;
2014
+ }
2015
+ }
2016
+ var x = new $mol_view_test();
2017
+ x.$ = $;
2018
+ var node = x.dom_node();
2019
+ node.click();
2020
+ $mol_assert_ok(clicked);
2021
+ },
2022
+ });
2023
+ })($ || ($ = {}));
2024
+ //mol/view/view/view.test.ts
2025
+ ;
2026
+ "use strict";
2027
+ var $;
2028
+ (function ($) {
2029
+ class $mol_view_tree_test_simple extends $mol_view {
2030
+ some() {
2031
+ return 1;
2032
+ }
2033
+ bool() {
2034
+ return true;
2035
+ }
2036
+ str() {
2037
+ return "test";
2038
+ }
2039
+ arr() {
2040
+ return [];
2041
+ }
2042
+ arr_string() {
2043
+ return [];
2044
+ }
2045
+ }
2046
+ $.$mol_view_tree_test_simple = $mol_view_tree_test_simple;
2047
+ })($ || ($ = {}));
2048
+ //mol/view/tree/test/-view.tree/simple.test.view.tree.ts
2049
+ ;
2050
+ "use strict";
2051
+ var $;
2052
+ (function ($) {
2053
+ class $mol_view_tree_test_binding extends $mol_view {
2054
+ value(next) {
2055
+ return this.task_title_new(next);
2056
+ }
2057
+ enabled() {
2058
+ return this.head_complete_enabled();
2059
+ }
2060
+ task_title_new(next) {
2061
+ if (next !== undefined)
2062
+ return next;
2063
+ return "123";
2064
+ }
2065
+ head_complete_enabled() {
2066
+ return false;
2067
+ }
2068
+ }
2069
+ __decorate([
2070
+ $mol_mem
2071
+ ], $mol_view_tree_test_binding.prototype, "task_title_new", null);
2072
+ $.$mol_view_tree_test_binding = $mol_view_tree_test_binding;
2073
+ })($ || ($ = {}));
2074
+ //mol/view/tree/test/-view.tree/binding.test.view.tree.ts
2075
+ ;
2076
+ "use strict";
2077
+ var $;
2078
+ (function ($) {
2079
+ class $mol_view_tree_test_attributes_super extends $mol_view {
2080
+ some() {
2081
+ return {
2082
+ a: 0,
2083
+ b: 2
2084
+ };
2085
+ }
2086
+ }
2087
+ $.$mol_view_tree_test_attributes_super = $mol_view_tree_test_attributes_super;
2088
+ class $mol_view_tree_test_attributes extends $mol_view_tree_test_attributes_super {
2089
+ some() {
2090
+ return {
2091
+ ...super.some(),
2092
+ a: 1
2093
+ };
2094
+ }
2095
+ }
2096
+ $.$mol_view_tree_test_attributes = $mol_view_tree_test_attributes;
2097
+ })($ || ($ = {}));
2098
+ //mol/view/tree/test/-view.tree/attributes.test.view.tree.ts
2099
+ ;
2100
+ "use strict";
2101
+ var $;
2102
+ (function ($) {
2103
+ class $mol_view_tree_test_attributes_subcomponent extends $mol_view {
2104
+ Page(id) {
2105
+ const obj = new this.$.$mol_view_tree_test_attributes_subcomponent_page();
2106
+ obj.Sub = () => this.page(id);
2107
+ return obj;
2108
+ }
2109
+ page(id) {
2110
+ return null;
2111
+ }
2112
+ }
2113
+ __decorate([
2114
+ $mol_mem_key
2115
+ ], $mol_view_tree_test_attributes_subcomponent.prototype, "Page", null);
2116
+ $.$mol_view_tree_test_attributes_subcomponent = $mol_view_tree_test_attributes_subcomponent;
2117
+ class $mol_view_tree_test_attributes_subcomponent_page extends $mol_view {
2118
+ Sub() {
2119
+ return null;
2120
+ }
2121
+ }
2122
+ $.$mol_view_tree_test_attributes_subcomponent_page = $mol_view_tree_test_attributes_subcomponent_page;
2123
+ })($ || ($ = {}));
2124
+ //mol/view/tree/test/-view.tree/subcomponent.test.view.tree.ts
2125
+ ;
2126
+ "use strict";
2127
+ var $;
2128
+ (function ($) {
2129
+ class $mol_view_tree_test_binding_right extends $mol_view {
2130
+ outer_width(v) {
2131
+ return this.Test().width(v);
2132
+ }
2133
+ Test() {
2134
+ const obj = new this.$.$mol_view_tree_test_binding_right_test();
2135
+ return obj;
2136
+ }
2137
+ }
2138
+ __decorate([
2139
+ $mol_mem
2140
+ ], $mol_view_tree_test_binding_right.prototype, "Test", null);
2141
+ $.$mol_view_tree_test_binding_right = $mol_view_tree_test_binding_right;
2142
+ class $mol_view_tree_test_binding_right_test extends $mol_view {
2143
+ width(next) {
2144
+ if (next !== undefined)
2145
+ return next;
2146
+ return 0;
2147
+ }
2148
+ }
2149
+ __decorate([
2150
+ $mol_mem
2151
+ ], $mol_view_tree_test_binding_right_test.prototype, "width", null);
2152
+ $.$mol_view_tree_test_binding_right_test = $mol_view_tree_test_binding_right_test;
2153
+ })($ || ($ = {}));
2154
+ //mol/view/tree/test/-view.tree/binding_right.test.view.tree.ts
2155
+ ;
2156
+ "use strict";
2157
+ var $;
2158
+ (function ($_1) {
2159
+ var $$;
2160
+ (function ($$) {
2161
+ $mol_test({
2162
+ 'simple props'($) {
2163
+ const app = $mol_view_tree_test_simple.make({ $ });
2164
+ $mol_assert_equal(app.some(), 1);
2165
+ $mol_assert_equal(app.bool(), true);
2166
+ $mol_assert_equal(app.str(), 'test');
2167
+ $mol_assert_ok(Array.isArray(app.arr()));
2168
+ $mol_assert_ok(Array.isArray(app.arr_string()));
2169
+ },
2170
+ 'default value'($) {
2171
+ const app = $mol_view_tree_test_binding.make({ $ });
2172
+ $mol_assert_equal(app.value(), '123');
2173
+ },
2174
+ 'both binding'($) {
2175
+ const app = $mol_view_tree_test_binding.make({ $ });
2176
+ $mol_assert_ok(app.value() !== '1');
2177
+ app.value('1');
2178
+ $mol_assert_equal(app.value(), '1');
2179
+ },
2180
+ 'left binding'($) {
2181
+ const app = $mol_view_tree_test_binding.make({ $ });
2182
+ $mol_assert_not(app.head_complete_enabled());
2183
+ $mol_assert_not(app.enabled());
2184
+ },
2185
+ 'sub component'($) {
2186
+ const app = $mol_view_tree_test_binding_right.make({ $ });
2187
+ $mol_assert_ok(app.Test() instanceof $mol_view_tree_test_binding_right_test);
2188
+ },
2189
+ 'right binding - change owner property'($) {
2190
+ const app = $mol_view_tree_test_binding_right.make({ $ });
2191
+ const val = 123;
2192
+ $mol_assert_ok(app.outer_width() !== val);
2193
+ $mol_assert_ok(app.Test().width() !== val);
2194
+ app.outer_width(val);
2195
+ $mol_assert_equal(app.outer_width(), val);
2196
+ $mol_assert_equal(app.Test().width(), val);
2197
+ },
2198
+ 'right binding - change part property'($) {
2199
+ const app = $mol_view_tree_test_binding_right.make({ $ });
2200
+ const val = 123;
2201
+ $mol_assert_ok(app.outer_width() !== val);
2202
+ $mol_assert_ok(app.Test().width() !== val);
2203
+ app.Test().width(val);
2204
+ $mol_assert_equal(app.Test().width(), val);
2205
+ $mol_assert_equal(app.outer_width(), val);
2206
+ },
2207
+ 'attributes merging'($) {
2208
+ const app = $mol_view_tree_test_attributes.make({ $ });
2209
+ $mol_assert_like(app.some(), { a: 1, b: 2 });
2210
+ },
2211
+ 'subcomponent indexed'($) {
2212
+ const app = $mol_view_tree_test_attributes_subcomponent.make({ $ });
2213
+ const val = 123;
2214
+ app.page = (index) => index;
2215
+ $mol_assert_equal(app.Page(val).Sub(), val);
2216
+ },
2217
+ });
2218
+ })($$ = $_1.$$ || ($_1.$$ = {}));
2219
+ })($ || ($ = {}));
2220
+ //mol/view/tree/test/tree.test.ts
2221
+ ;
2222
+ "use strict";
2223
+ var $;
2224
+ (function ($) {
2225
+ $.$mol_tree_convert = Symbol('$mol_tree_convert');
2226
+ class $mol_tree extends $mol_object2 {
2227
+ type;
2228
+ data;
2229
+ sub;
2230
+ baseUri;
2231
+ row;
2232
+ col;
2233
+ length;
2234
+ constructor(config = {}) {
2235
+ super();
2236
+ this.type = config.type || '';
2237
+ if (config.value !== undefined) {
2238
+ var sub = $mol_tree.values(config.value);
2239
+ if (config.type || sub.length > 1) {
2240
+ this.sub = [...sub, ...(config.sub || [])];
2241
+ this.data = config.data || '';
2242
+ }
2243
+ else {
2244
+ this.data = sub[0].data;
2245
+ this.sub = config.sub || [];
2246
+ }
2247
+ }
2248
+ else {
2249
+ this.data = config.data || '';
2250
+ this.sub = config.sub || [];
2251
+ }
2252
+ this.baseUri = config.baseUri || '';
2253
+ this.row = config.row || 0;
2254
+ this.col = config.col || 0;
2255
+ this.length = config.length || 0;
2256
+ }
2257
+ static values(str, baseUri) {
2258
+ return str.split('\n').map((data, index) => new $mol_tree({
2259
+ data: data,
2260
+ baseUri: baseUri,
2261
+ row: index + 1,
2262
+ length: data.length,
2263
+ }));
2264
+ }
2265
+ clone(config = {}) {
2266
+ return new $mol_tree({
2267
+ type: ('type' in config) ? config.type : this.type,
2268
+ data: ('data' in config) ? config.data : this.data,
2269
+ sub: ('sub' in config) ? config.sub : this.sub,
2270
+ baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
2271
+ row: ('row' in config) ? config.row : this.row,
2272
+ col: ('col' in config) ? config.col : this.col,
2273
+ length: ('length' in config) ? config.length : this.length,
2274
+ value: config.value
2275
+ });
2276
+ }
2277
+ make(config) {
2278
+ return new $mol_tree({
2279
+ baseUri: this.baseUri,
2280
+ row: this.row,
2281
+ col: this.col,
2282
+ length: this.length,
2283
+ ...config,
2284
+ });
2285
+ }
2286
+ make_data(value, sub) {
2287
+ return this.make({ value, sub });
2288
+ }
2289
+ make_struct(type, sub) {
2290
+ return this.make({ type, sub });
2291
+ }
2292
+ static fromString(str, baseUri) {
2293
+ var root = new $mol_tree({ baseUri: baseUri });
2294
+ var stack = [root];
2295
+ var row = 0;
2296
+ var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
2297
+ var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
2298
+ lines.forEach(line => {
2299
+ ++row;
2300
+ var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
2301
+ if (!chunks || chunks[4])
2302
+ return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
2303
+ var indent = chunks[1];
2304
+ var path = chunks[2];
2305
+ var data = chunks[3];
2306
+ var deep = indent.length;
2307
+ var types = path ? path.replace(/ $/, '').split(/ +/) : [];
2308
+ if (stack.length <= deep)
2309
+ return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
2310
+ stack.length = deep + 1;
2311
+ var parent = stack[deep];
2312
+ let col = deep;
2313
+ types.forEach(type => {
2314
+ if (!type)
2315
+ return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
2316
+ var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
2317
+ const parent_sub = parent.sub;
2318
+ parent_sub.push(next);
2319
+ parent = next;
2320
+ col += type.length + 1;
2321
+ });
2322
+ if (data) {
2323
+ var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
2324
+ const parent_sub = parent.sub;
2325
+ parent_sub.push(next);
2326
+ parent = next;
2327
+ }
2328
+ stack.push(parent);
2329
+ });
2330
+ return root;
2331
+ }
2332
+ static fromJSON(json, baseUri = '') {
2333
+ switch (true) {
2334
+ case typeof json === 'boolean':
2335
+ case typeof json === 'number':
2336
+ case json === null:
2337
+ return new $mol_tree({
2338
+ type: String(json),
2339
+ baseUri: baseUri
2340
+ });
2341
+ case typeof json === 'string':
2342
+ return new $mol_tree({
2343
+ value: json,
2344
+ baseUri: baseUri
2345
+ });
2346
+ case Array.isArray(json):
2347
+ return new $mol_tree({
2348
+ type: "/",
2349
+ sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
2350
+ });
2351
+ case json instanceof Date:
2352
+ return new $mol_tree({
2353
+ value: json.toISOString(),
2354
+ baseUri: baseUri
2355
+ });
2356
+ default:
2357
+ if (typeof json[$.$mol_tree_convert] === 'function') {
2358
+ return json[$.$mol_tree_convert]();
2359
+ }
2360
+ if (typeof json.toJSON === 'function') {
2361
+ return $mol_tree.fromJSON(json.toJSON());
2362
+ }
2363
+ if (json instanceof Error) {
2364
+ const { name, message, stack } = json;
2365
+ json = { ...json, name, message, stack };
2366
+ }
2367
+ var sub = [];
2368
+ for (var key in json) {
2369
+ if (json[key] === undefined)
2370
+ continue;
2371
+ const subsub = $mol_tree.fromJSON(json[key], baseUri);
2372
+ if (/^[^\n\t\\ ]+$/.test(key)) {
2373
+ var child = new $mol_tree({
2374
+ type: key,
2375
+ baseUri: baseUri,
2376
+ sub: [subsub],
2377
+ });
2378
+ }
2379
+ else {
2380
+ var child = new $mol_tree({
2381
+ value: key,
2382
+ baseUri: baseUri,
2383
+ sub: [subsub],
2384
+ });
2385
+ }
2386
+ sub.push(child);
2387
+ }
2388
+ return new $mol_tree({
2389
+ type: "*",
2390
+ sub: sub,
2391
+ baseUri: baseUri
2392
+ });
2393
+ }
2394
+ }
2395
+ get uri() {
2396
+ return this.baseUri + '#' + this.row + ':' + this.col;
2397
+ }
2398
+ toString(prefix = '') {
2399
+ var output = '';
2400
+ if (this.type.length) {
2401
+ if (!prefix.length) {
2402
+ prefix = "\t";
2403
+ }
2404
+ output += this.type;
2405
+ if (this.sub.length == 1) {
2406
+ return output + ' ' + this.sub[0].toString(prefix);
2407
+ }
2408
+ output += "\n";
2409
+ }
2410
+ else if (this.data.length || prefix.length) {
2411
+ output += "\\" + this.data + "\n";
2412
+ }
2413
+ for (var child of this.sub) {
2414
+ output += prefix;
2415
+ output += child.toString(prefix + "\t");
2416
+ }
2417
+ return output;
2418
+ }
2419
+ toJSON() {
2420
+ if (!this.type)
2421
+ return this.value;
2422
+ if (this.type === 'true')
2423
+ return true;
2424
+ if (this.type === 'false')
2425
+ return false;
2426
+ if (this.type === 'null')
2427
+ return null;
2428
+ if (this.type === '*') {
2429
+ var obj = {};
2430
+ for (var child of this.sub) {
2431
+ if (child.type === '-')
2432
+ continue;
2433
+ var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
2434
+ var val = child.sub[child.sub.length - 1].toJSON();
2435
+ if (val !== undefined)
2436
+ obj[key] = val;
2437
+ }
2438
+ return obj;
2439
+ }
2440
+ if (this.type === '/') {
2441
+ var res = [];
2442
+ this.sub.forEach(child => {
2443
+ if (child.type === '-')
2444
+ return;
2445
+ var val = child.toJSON();
2446
+ if (val !== undefined)
2447
+ res.push(val);
2448
+ });
2449
+ return res;
2450
+ }
2451
+ if (this.type === 'time') {
2452
+ return new Date(this.value);
2453
+ }
2454
+ const numb = Number(this.type);
2455
+ if (!Number.isNaN(numb) || this.type === 'NaN')
2456
+ return numb;
2457
+ throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
2458
+ }
2459
+ get value() {
2460
+ var values = [];
2461
+ for (var child of this.sub) {
2462
+ if (child.type)
2463
+ continue;
2464
+ values.push(child.value);
2465
+ }
2466
+ return this.data + values.join("\n");
2467
+ }
2468
+ insert(value, ...path) {
2469
+ if (path.length === 0)
2470
+ return value;
2471
+ const type = path[0];
2472
+ if (typeof type === 'string') {
2473
+ let replaced = false;
2474
+ const sub = this.sub.map((item, index) => {
2475
+ if (item.type !== type)
2476
+ return item;
2477
+ replaced = true;
2478
+ return item.insert(value, ...path.slice(1));
2479
+ });
2480
+ if (!replaced)
2481
+ sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
2482
+ return this.clone({ sub });
2483
+ }
2484
+ else if (typeof type === 'number') {
2485
+ const sub = this.sub.slice();
2486
+ sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
2487
+ return this.clone({ sub });
2488
+ }
2489
+ else {
2490
+ return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
2491
+ }
2492
+ }
2493
+ select(...path) {
2494
+ var next = [this];
2495
+ for (var type of path) {
2496
+ if (!next.length)
2497
+ break;
2498
+ var prev = next;
2499
+ next = [];
2500
+ for (var item of prev) {
2501
+ switch (typeof (type)) {
2502
+ case 'string':
2503
+ for (var child of item.sub) {
2504
+ if (!type || (child.type == type)) {
2505
+ next.push(child);
2506
+ }
2507
+ }
2508
+ break;
2509
+ case 'number':
2510
+ if (type < item.sub.length)
2511
+ next.push(item.sub[type]);
2512
+ break;
2513
+ default: next.push(...item.sub);
2514
+ }
2515
+ }
2516
+ }
2517
+ return new $mol_tree({ sub: next });
2518
+ }
2519
+ filter(path, value) {
2520
+ var sub = this.sub.filter(function (item) {
2521
+ var found = item.select(...path);
2522
+ if (value == null) {
2523
+ return Boolean(found.sub.length);
2524
+ }
2525
+ else {
2526
+ return found.sub.some(child => child.value == value);
2527
+ }
2528
+ });
2529
+ return new $mol_tree({ sub: sub });
2530
+ }
2531
+ transform(visit, stack = []) {
2532
+ const sub_stack = [this, ...stack];
2533
+ return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
2534
+ }
2535
+ hack(context) {
2536
+ const sub = [].concat(...this.sub.map(child => {
2537
+ const handle = context[child.type] || context[''];
2538
+ if (!handle)
2539
+ $mol_fail(child.error('Handler not defined'));
2540
+ return handle(child, context);
2541
+ }));
2542
+ return this.clone({ sub });
2543
+ }
2544
+ error(message) {
2545
+ return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
2546
+ }
2547
+ }
2548
+ $.$mol_tree = $mol_tree;
2549
+ })($ || ($ = {}));
2550
+ //mol/tree/tree.ts
2551
+ ;
2552
+ "use strict";
2553
+ var $;
2554
+ (function ($_1) {
2555
+ $mol_test({
2556
+ 'tree parsing'() {
2557
+ $mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
2558
+ $mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
2559
+ $mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
2560
+ $mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
2561
+ $mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
2562
+ $mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
2563
+ $mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
2564
+ $mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
2565
+ },
2566
+ 'inserting'() {
2567
+ $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
2568
+ $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
2569
+ $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
2570
+ $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
2571
+ $mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
2572
+ $mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
2573
+ },
2574
+ 'fromJSON'() {
2575
+ $mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
2576
+ $mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
2577
+ $mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
2578
+ $mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
2579
+ $mol_assert_equal($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');
2580
+ },
2581
+ 'toJSON'() {
2582
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
2583
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
2584
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
2585
+ $mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
2586
+ $mol_assert_equal(JSON.stringify($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"}');
2587
+ },
2588
+ 'hack'() {
2589
+ const res = $mol_tree.fromString(`foo bar xxx`).hack({
2590
+ '': (tree, context) => [tree.hack(context)],
2591
+ 'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
2592
+ });
2593
+ $mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
2594
+ },
2595
+ 'errors handling'($) {
2596
+ const errors = [];
2597
+ class Tree extends $mol_tree {
2598
+ static $ = $.$mol_ambient({
2599
+ $mol_fail: error => errors.push(error.message)
2600
+ });
2601
+ }
2602
+ Tree.fromString(`
2603
+ \t \tfoo
2604
+ bar \\data
2605
+ `, 'test');
2606
+ $mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
2607
+ },
2608
+ });
2609
+ })($ || ($ = {}));
2610
+ //mol/tree/tree.test.ts
2611
+ ;
2612
+ "use strict";
2613
+ var $;
2614
+ (function ($) {
2615
+ $mol_test({
2616
+ 'local get set delete'() {
2617
+ var key = '$mol_state_local_test:' + Math.random();
2618
+ $mol_assert_equal($mol_state_local.value(key), null);
2619
+ $mol_state_local.value(key, 123);
2620
+ $mol_assert_equal($mol_state_local.value(key), 123);
2621
+ $mol_state_local.value(key, null);
2622
+ $mol_assert_equal($mol_state_local.value(key), null);
2623
+ },
2624
+ });
2625
+ })($ || ($ = {}));
2626
+ //mol/state/local/local.test.ts
2627
+ ;
2628
+ "use strict";
2629
+ var $;
2630
+ (function ($) {
2631
+ $mol_test_mocks.push(context => {
2632
+ class $mol_state_local_mock extends $mol_state_local {
2633
+ static state = {};
2634
+ static value(key, next = this.state[key]) {
2635
+ return this.state[key] = (next || null);
2636
+ }
2637
+ }
2638
+ __decorate([
2639
+ $mol_mem_key
2640
+ ], $mol_state_local_mock, "value", null);
2641
+ context.$mol_state_local = $mol_state_local_mock;
2642
+ });
2643
+ })($ || ($ = {}));
2644
+ //mol/state/local/local.mock.test.ts
2645
+ ;
2646
+ "use strict";
2647
+ var $;
2648
+ (function ($) {
2649
+ $mol_test({
2650
+ 'decode utf8 string'() {
2651
+ const str = 'Hello, ΧΨΩЫ';
2652
+ const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
2653
+ $mol_assert_equal($mol_charset_decode(encoded), str);
2654
+ $mol_assert_equal($mol_charset_decode(encoded, 'utf8'), str);
2655
+ },
2656
+ 'decode empty string'() {
2657
+ const encoded = new Uint8Array([]);
2658
+ $mol_assert_equal($mol_charset_decode(encoded), '');
2659
+ },
2660
+ });
2661
+ })($ || ($ = {}));
2662
+ //mol/charset/decode/decode.test.ts
2663
+ ;
2664
+ "use strict";
2665
+ var $;
2666
+ (function ($) {
2667
+ $mol_test({
2668
+ 'encode utf8 string'() {
2669
+ const str = 'Hello, ΧΨΩЫ';
2670
+ const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
2671
+ $mol_assert_like($mol_charset_encode(str), encoded);
2672
+ },
2673
+ });
2674
+ })($ || ($ = {}));
2675
+ //mol/charset/encode/encode.test.ts
2676
+ ;
2677
+ "use strict";
2678
+ var $;
2679
+ (function ($_1) {
2680
+ $mol_test_mocks.push($ => {
2681
+ class $mol_locale_mock extends $mol_locale {
2682
+ lang(next = 'en') { return next; }
2683
+ static source(lang) {
2684
+ return {};
2685
+ }
2686
+ }
2687
+ __decorate([
2688
+ $mol_mem
2689
+ ], $mol_locale_mock.prototype, "lang", null);
2690
+ __decorate([
2691
+ $mol_mem_key
2692
+ ], $mol_locale_mock, "source", null);
2693
+ $.$mol_locale = $mol_locale_mock;
2694
+ });
2695
+ })($ || ($ = {}));
2696
+ //mol/locale/locale.test.ts
2697
+ ;
2698
+ "use strict";
2699
+ var $;
2700
+ (function ($) {
2701
+ function $mol_view_tree_trim_remarks(def) {
2702
+ return def.transform(([node], sub) => (node.type === '-') ? null : node.clone({ sub: sub() }));
2703
+ }
2704
+ $.$mol_view_tree_trim_remarks = $mol_view_tree_trim_remarks;
2705
+ function $mol_view_tree_classes(defs) {
2706
+ return $mol_view_tree_trim_remarks(defs);
2707
+ }
2708
+ $.$mol_view_tree_classes = $mol_view_tree_classes;
2709
+ function $mol_view_tree_class_name(val) {
2710
+ return val.type;
2711
+ }
2712
+ $.$mol_view_tree_class_name = $mol_view_tree_class_name;
2713
+ function $mol_view_tree_super_name(val) {
2714
+ if (val.sub.length != 1)
2715
+ throw val.error('Wrong sub count');
2716
+ return val.sub[0].type;
2717
+ }
2718
+ $.$mol_view_tree_super_name = $mol_view_tree_super_name;
2719
+ function $mol_view_tree_class_props(def) {
2720
+ const props = {};
2721
+ const catch_prop = (prop, type = '') => {
2722
+ let def = prop;
2723
+ if (type === '=>') {
2724
+ if (prop.sub[0])
2725
+ throw prop.error('Right binding can not have default value');
2726
+ }
2727
+ else {
2728
+ if (prop.sub.length === 0)
2729
+ return;
2730
+ if (prop.sub[0].type === '-')
2731
+ return;
2732
+ props[prop.type] = props[prop.type];
2733
+ def = prop.clone({
2734
+ sub: [prop.sub[0].transform(([node, ...stack], sub) => {
2735
+ if (['<=', '<=>', '=>'].indexOf(node.type) === -1)
2736
+ return node.clone({ sub: sub() });
2737
+ catch_prop(node.sub[0], node.type);
2738
+ return node.clone({
2739
+ sub: [node.sub[0].clone({
2740
+ sub: []
2741
+ })]
2742
+ });
2743
+ })]
2744
+ });
2745
+ }
2746
+ if (props[prop.type]) {
2747
+ if (props[prop.type].toString() !== def.toString()) {
2748
+ throw def.error('Property already defined with another default value' + props[prop.type].error('').message + '\n---');
2749
+ }
2750
+ }
2751
+ else {
2752
+ props[prop.type] = def;
2753
+ }
2754
+ };
2755
+ def.sub[0].sub.map(sub => catch_prop(sub));
2756
+ return def.clone({
2757
+ type: '',
2758
+ sub: Object.keys(props).map(name => props[name]),
2759
+ });
2760
+ }
2761
+ $.$mol_view_tree_class_props = $mol_view_tree_class_props;
2762
+ function $mol_view_tree_prop_name(prop) {
2763
+ return (prop.type.match(/^\w+/) || [])[0] || '';
2764
+ }
2765
+ $.$mol_view_tree_prop_name = $mol_view_tree_prop_name;
2766
+ function $mol_view_tree_prop_key(prop) {
2767
+ return (prop.type.match(/!(\w+)$/) || [])[1] || '';
2768
+ }
2769
+ $.$mol_view_tree_prop_key = $mol_view_tree_prop_key;
2770
+ function $mol_view_tree_prop_next(prop) {
2771
+ return (prop.type.match(/\?(\w+)$/) || [])[1] || '';
2772
+ }
2773
+ $.$mol_view_tree_prop_next = $mol_view_tree_prop_next;
2774
+ function $mol_view_tree_prop_value(prop) {
2775
+ if (prop.sub.length != 1)
2776
+ throw prop.error(`Wrong sub count (${prop.sub.length})`);
2777
+ return prop.sub[0];
2778
+ }
2779
+ $.$mol_view_tree_prop_value = $mol_view_tree_prop_value;
2780
+ function $mol_view_tree_value_type(val) {
2781
+ switch (val.type) {
2782
+ case 'true': return 'bool';
2783
+ case 'false': return 'bool';
2784
+ case 'null': return 'null';
2785
+ case '*': return 'dict';
2786
+ case '@': return 'locale';
2787
+ case '': return 'string';
2788
+ case '<=': return 'get';
2789
+ case '<=>': return 'bind';
2790
+ case '=>': return 'put';
2791
+ }
2792
+ switch (val.type[0]) {
2793
+ case '/': return 'list';
2794
+ case '$': return 'object';
2795
+ }
2796
+ if (Number(val.type).toString() == val.type)
2797
+ return 'number';
2798
+ throw val.error('Wrong value');
2799
+ }
2800
+ $.$mol_view_tree_value_type = $mol_view_tree_value_type;
2801
+ function $mol_view_tree_compile(tree) {
2802
+ const splittedUri = tree.uri.split(/[#\\\/]/);
2803
+ splittedUri.pop();
2804
+ const fileName = splittedUri.pop();
2805
+ const SourceNode = (row, col, fileName, text) => text;
2806
+ var content = [];
2807
+ var locales = {};
2808
+ for (let def of $mol_view_tree_classes(tree).sub) {
2809
+ if (!/^\$\w+$/.test(def.type))
2810
+ throw def.error('Wrong component name');
2811
+ const parent = def.sub[0];
2812
+ const members = {};
2813
+ for (let param of $mol_view_tree_class_props(def).sub) {
2814
+ try {
2815
+ var needSet = false;
2816
+ var needCache = false;
2817
+ if (param.type === '<=>') {
2818
+ param = param.sub[0];
2819
+ }
2820
+ if (param.type === '<=') {
2821
+ param = param.sub[0];
2822
+ }
2823
+ var propName = /(.*?)(?:\!(\w+))?(?:\?(\w+))?$/.exec(param.type);
2824
+ if (propName[3]) {
2825
+ needSet = true;
2826
+ needCache = true;
2827
+ }
2828
+ const getValue = (value, definition) => {
2829
+ try {
2830
+ switch (true) {
2831
+ case (value.type === ''):
2832
+ return [JSON.stringify(value.value)];
2833
+ case (value.type === '@'):
2834
+ const key = `${def.type}_${param.type.replace(/[?!].*/, '')}`;
2835
+ locales[key] = value.value;
2836
+ return [`this.$.$mol_locale.text( ${JSON.stringify(key)} )`];
2837
+ case (value.type === '-'):
2838
+ return null;
2839
+ case (value.type[0] === '/'):
2840
+ const item_type = value.type.substring(1);
2841
+ var items = [];
2842
+ value.sub.forEach(item => {
2843
+ if (item.type === '-')
2844
+ return;
2845
+ if (item.type === '^') {
2846
+ items.push(`...super.${param.type}()`);
2847
+ return;
2848
+ }
2849
+ var val = getValue(item);
2850
+ if (val)
2851
+ items.push(val.join(""));
2852
+ });
2853
+ return [`[`, items.join(' , '), `]`, (item_type ? ` as ( ${item_type} )[]` : ` as any[]`)];
2854
+ case (value.type[0] === '$'):
2855
+ if (!definition)
2856
+ throw value.error('Objects should be bound');
2857
+ needCache = true;
2858
+ const overs = [];
2859
+ value.sub.forEach(over => {
2860
+ if (/^[-\/]?$/.test(over.type))
2861
+ return '';
2862
+ var overName = /(.*?)(?:\!(\w+))?(?:\?(\w+))?$/.exec(over.type);
2863
+ var ns = needSet;
2864
+ if (over.sub[0].type === '=>') {
2865
+ if (over.sub[0].sub.length === 1) {
2866
+ const [, own_name, own_key, own_next] = /(.*?)(?:\!(\w+))?(?:\?(\w+))?$/.exec(over.sub[0].sub[0].type);
2867
+ let own_args = [];
2868
+ if (own_key)
2869
+ own_args.push(` ${own_key} : any `);
2870
+ if (own_next)
2871
+ own_args.push(` ${own_next}? : any `);
2872
+ let [, their_name, ...their_args] = /(.*?)(?:\!(\w+))?(?:\?(\w+))?$/.exec(over.type);
2873
+ their_args = their_args.filter(Boolean);
2874
+ members[own_name] = [`\t${own_name}(${own_args.join(',')}) {\n\t\treturn this.${propName[1]}(${propName[2] || ''}).${their_name}( ${their_args.join(' , ')} )\n\t}\n\n`];
2875
+ return;
2876
+ }
2877
+ }
2878
+ var v = getValue(over.sub[0]);
2879
+ let args = [];
2880
+ if (overName[2])
2881
+ args.push(` ${overName[2]} : any `);
2882
+ if (overName[3])
2883
+ args.push(` ${overName[3]}? : any `);
2884
+ overs.push(...['\t\t\tobj.', SourceNode(over.row, over.col, fileName, overName[1]), ' = (', args.join(','), ') => ', ...(v || []), '\n']);
2885
+ needSet = ns;
2886
+ });
2887
+ const object_args = value.select('/', '').sub.map(arg => getValue(arg)).join(' , ');
2888
+ return ['(( obj )=>{\n', ...overs, '\t\t\treturn obj\n\t\t})( new this.$.', SourceNode(value.row, value.col, fileName, value.type), '( ', object_args, ' ) )'];
2889
+ case (value.type === '*'):
2890
+ const opts = [];
2891
+ for (const opt of value.sub) {
2892
+ if (opt.type === '-')
2893
+ continue;
2894
+ if (opt.type === '^') {
2895
+ opts.push(`\t\t\t...super.${param.type}() ,\n`);
2896
+ continue;
2897
+ }
2898
+ const key = /(.*?)(?:\?(\w+))?$/.exec(opt.type);
2899
+ const ns = needSet;
2900
+ const v = getValue(opt.sub[0]);
2901
+ const arg = key[2] ? ` ( ${key[2]}? : any )=> ` : '';
2902
+ opts.push(...[
2903
+ '\t\t\t"',
2904
+ SourceNode(opt.row, opt.col, fileName, key[1] + '" : '),
2905
+ arg,
2906
+ ' ',
2907
+ ...(v || []),
2908
+ ' ,\n'
2909
+ ]);
2910
+ needSet = ns;
2911
+ }
2912
+ return ['({\n', opts.join(''), '\t\t})'];
2913
+ case (value.type === '<=>'):
2914
+ if (value.sub.length === 1) {
2915
+ var type = /(.*?)(?:\!(\w+))?(?:\?(\w+))$/.exec(value.sub[0].type);
2916
+ return ['this.' + type[1] + '(' + (type[2] ? type[2] + ' ,' : '') + ' ' + type[3] + ' )'];
2917
+ }
2918
+ break;
2919
+ case (value.type === '<='):
2920
+ if (value.sub.length === 1) {
2921
+ var type = /(.*?)(?:\!(\w+))?(?:\?(\w+))?$/.exec(value.sub[0].type);
2922
+ return ['this.' + type[1] + '(' + (type[2] ? type[2] : '') + ')'];
2923
+ }
2924
+ break;
2925
+ }
2926
+ switch (value.type) {
2927
+ case 'true':
2928
+ case 'false':
2929
+ return [value.type];
2930
+ case 'null':
2931
+ return ['null as any'];
2932
+ }
2933
+ if (Number(value.type).toString() == value.type)
2934
+ return [value.type];
2935
+ throw value.error('Wrong value');
2936
+ }
2937
+ catch (err) {
2938
+ throw err;
2939
+ }
2940
+ };
2941
+ if (param.sub.length > 1)
2942
+ throw new Error('Too more sub');
2943
+ param.sub.forEach(child => {
2944
+ var val = getValue(child, true);
2945
+ if (!val)
2946
+ return;
2947
+ var args = [];
2948
+ if (propName[2])
2949
+ args.push(` ${propName[2]} : any `);
2950
+ if (propName[3])
2951
+ args.push(` ${propName[3]}? : any , force? : $${''}mol_mem_force `);
2952
+ if (needSet)
2953
+ val = [
2954
+ `( ${propName[3]} !== void 0 ) ? ${propName[3]} : `,
2955
+ ...val
2956
+ ];
2957
+ val = ['return ', ...val];
2958
+ let decl = ['\t', SourceNode(param.row, param.col, fileName, propName[1]), '(', args.join(','), ') {\n\t\t', ...val, '\n\t}\n\n'];
2959
+ if (needCache) {
2960
+ if (propName[2])
2961
+ decl = ['\t@ $', 'mol_mem_key\n', ...decl];
2962
+ else
2963
+ decl = ['\t@ $', 'mol_mem\n', ...decl];
2964
+ }
2965
+ decl = ['\t/**\n\t * ```\n', param.toString().trim().replace(/^/mg, '\t * '), '\n\t * ```\n\t **/\n', ...decl];
2966
+ members[propName[1]] = decl;
2967
+ });
2968
+ }
2969
+ catch (err) {
2970
+ throw err;
2971
+ }
2972
+ }
2973
+ var body = Object.keys(members).reduce(function (acc, name) {
2974
+ const items = members[name] ? members[name] : ['\t', name, '() { return null as any }\n\t}\n'];
2975
+ return [...acc, ...items];
2976
+ }, []);
2977
+ var classes = ['namespace $ { export class ', SourceNode(def.row, def.col, fileName, def.type), ' extends ', SourceNode(parent.row, parent.col, fileName, parent.type), ' {\n\n', ...body, '} }\n'];
2978
+ content = [...content, ...classes];
2979
+ }
2980
+ return { script: content.join(''), locales };
2981
+ }
2982
+ $.$mol_view_tree_compile = $mol_view_tree_compile;
2983
+ })($ || ($ = {}));
2984
+ //mol/view/tree/tree.ts
2985
+ ;
2986
+ "use strict";
2987
+ //mol/type/merge/merge.test.ts
2988
+ ;
2989
+ "use strict";
2990
+ //mol/type/intersect/intersect.test.ts
2991
+ ;
2992
+ "use strict";
2993
+ var $;
2994
+ (function ($) {
2995
+ $mol_test({
2996
+ 'escape'() {
2997
+ const specials = $mol_regexp.from('.*+?^${}()|[]\\');
2998
+ $mol_assert_equal(specials.source, '\\.\\*\\+\\?\\^\\$\\{\\}\\(\\)\\|\\[\\]\\\\');
2999
+ },
3000
+ 'char code'() {
3001
+ const space = $mol_regexp.from(32);
3002
+ $mol_assert_like(' '.match(space), [' ']);
3003
+ },
3004
+ 'repeat fixed'() {
3005
+ const { repeat, decimal_only: digit } = $mol_regexp;
3006
+ const year = repeat(digit, 4, 4);
3007
+ $mol_assert_like('#2020#'.match(year), ['2020']);
3008
+ },
3009
+ 'greedy repeat'() {
3010
+ const { repeat, repeat_greedy, latin_only: letter } = $mol_regexp;
3011
+ $mol_assert_like('abc'.match(repeat(letter, 1, 2)), ['a', 'b', 'c']);
3012
+ $mol_assert_like('abc'.match(repeat_greedy(letter, 1, 2)), ['ab', 'c']);
3013
+ },
3014
+ 'repeat range'() {
3015
+ const { repeat_greedy, decimal_only: digit } = $mol_regexp;
3016
+ const year = repeat_greedy(digit, 2, 4);
3017
+ $mol_assert_like('#2#'.match(year), null);
3018
+ $mol_assert_like('#20#'.match(year), ['20']);
3019
+ $mol_assert_like('#2020#'.match(year), ['2020']);
3020
+ $mol_assert_like('#20201#'.match(year), ['2020']);
3021
+ },
3022
+ 'repeat from'() {
3023
+ const { repeat_greedy, latin_only: letter } = $mol_regexp;
3024
+ const name = repeat_greedy(letter, 2);
3025
+ $mol_assert_like('##'.match(name), null);
3026
+ $mol_assert_like('#a#'.match(name), null);
3027
+ $mol_assert_like('#ab#'.match(name), ['ab']);
3028
+ $mol_assert_like('#abc#'.match(name), ['abc']);
3029
+ },
3030
+ 'from string'() {
3031
+ const regexp = $mol_regexp.from('[\\d]');
3032
+ $mol_assert_equal(regexp.source, '\\[\\\\d\\]');
3033
+ $mol_assert_equal(regexp.flags, 'gsu');
3034
+ },
3035
+ 'from regexp'() {
3036
+ const regexp = $mol_regexp.from(/[\d]/i);
3037
+ $mol_assert_equal(regexp.source, '[\\d]');
3038
+ $mol_assert_equal(regexp.flags, 'i');
3039
+ },
3040
+ 'split'() {
3041
+ const regexp = $mol_regexp.from(';');
3042
+ $mol_assert_like('aaa;bbb;ccc'.split(regexp), ['aaa', ';', 'bbb', ';', 'ccc']);
3043
+ $mol_assert_like('aaa;;ccc'.split(regexp), ['aaa', ';', '', ';', 'ccc']);
3044
+ $mol_assert_like('aaa'.split(regexp), ['aaa']);
3045
+ $mol_assert_like(''.split(regexp), ['']);
3046
+ },
3047
+ 'test for matching'() {
3048
+ const regexp = $mol_regexp.from('foo');
3049
+ $mol_assert_like(regexp.test(''), false);
3050
+ $mol_assert_like(regexp.test('fo'), false);
3051
+ $mol_assert_like(regexp.test('foo'), true);
3052
+ $mol_assert_like(regexp.test('foobar'), true);
3053
+ $mol_assert_like(regexp.test('barfoo'), true);
3054
+ },
3055
+ 'case ignoring'() {
3056
+ const xxx = $mol_regexp.from('x', { ignoreCase: true });
3057
+ $mol_assert_like(xxx.flags, 'gisu');
3058
+ $mol_assert_like(xxx.exec('xx')[0], 'x');
3059
+ $mol_assert_like(xxx.exec('XX')[0], 'X');
3060
+ },
3061
+ 'multiline mode'() {
3062
+ const { end, from } = $mol_regexp;
3063
+ const xxx = from(['x', end], { multiline: true });
3064
+ $mol_assert_like(xxx.exec('x\ny')[0], 'x');
3065
+ $mol_assert_like(xxx.flags, 'gmsu');
3066
+ },
3067
+ 'flags override'() {
3068
+ const triplet = $mol_regexp.from($mol_regexp.from(/.../, { ignoreCase: true }), { multiline: true });
3069
+ $mol_assert_like(triplet.toString(), '/.../gmsu');
3070
+ },
3071
+ 'sequence'() {
3072
+ const { begin, end, decimal_only: digit, repeat, from } = $mol_regexp;
3073
+ const year = repeat(digit, 4, 4);
3074
+ const dash = '-';
3075
+ const month = repeat(digit, 2, 2);
3076
+ const day = repeat(digit, 2, 2);
3077
+ const date = from([begin, year, dash, month, dash, day, end]);
3078
+ $mol_assert_like(date.exec('2020-01-02')[0], '2020-01-02');
3079
+ },
3080
+ 'optional'() {
3081
+ const name = $mol_regexp.from(['A', ['4']]);
3082
+ $mol_assert_equal('AB'.match(name)[0], 'A');
3083
+ $mol_assert_equal('A4'.match(name)[0], 'A4');
3084
+ },
3085
+ 'anon variants'() {
3086
+ const name = $mol_regexp.from(['A', $mol_regexp.vary(['4', '5'])]);
3087
+ $mol_assert_equal('AB'.match(name), null);
3088
+ $mol_assert_equal('A4'.match(name)[0], 'A4');
3089
+ $mol_assert_equal('A5'.match(name)[0], 'A5');
3090
+ },
3091
+ 'only groups'() {
3092
+ const regexp = $mol_regexp.from({ dog: '@' });
3093
+ $mol_assert_like([...'#'.matchAll(regexp)][0].groups, undefined);
3094
+ $mol_assert_like([...'@'.matchAll(regexp)][0].groups, { dog: '@' });
3095
+ },
3096
+ 'catch skipped'() {
3097
+ const regexp = $mol_regexp.from(/(@)(\d?)/g);
3098
+ $mol_assert_like([...'[[@]]'.matchAll(regexp)].map(f => [...f]), [
3099
+ ['[['],
3100
+ ['@', '@', ''],
3101
+ [']]'],
3102
+ ]);
3103
+ },
3104
+ 'enum variants'() {
3105
+ let Sex;
3106
+ (function (Sex) {
3107
+ Sex["male"] = "male";
3108
+ Sex["female"] = "female";
3109
+ })(Sex || (Sex = {}));
3110
+ const sexism = $mol_regexp.from(Sex);
3111
+ $mol_assert_like([...''.matchAll(sexism)].length, 0);
3112
+ $mol_assert_like([...'trans'.matchAll(sexism)][0].groups, undefined);
3113
+ $mol_assert_like([...'male'.matchAll(sexism)][0].groups, { male: 'male', female: '' });
3114
+ $mol_assert_like([...'female'.matchAll(sexism)][0].groups, { male: '', female: 'female' });
3115
+ },
3116
+ 'recursive only groups'() {
3117
+ let Sex;
3118
+ (function (Sex) {
3119
+ Sex["male"] = "male";
3120
+ Sex["female"] = "female";
3121
+ })(Sex || (Sex = {}));
3122
+ const sexism = $mol_regexp.from({ Sex });
3123
+ $mol_assert_like([...''.matchAll(sexism)].length, 0);
3124
+ $mol_assert_like([...'male'.matchAll(sexism)][0].groups, { Sex: 'male', male: 'male', female: '' });
3125
+ $mol_assert_like([...'female'.matchAll(sexism)][0].groups, { Sex: 'female', male: '', female: 'female' });
3126
+ },
3127
+ 'sequence with groups'() {
3128
+ const { begin, end, decimal_only: digit, repeat, from } = $mol_regexp;
3129
+ const year = repeat(digit, 4, 4);
3130
+ const dash = '-';
3131
+ const month = repeat(digit, 2, 2);
3132
+ const day = repeat(digit, 2, 2);
3133
+ const regexp = from([begin, { year }, dash, { month }, dash, { day }, end]);
3134
+ const found = [...'2020-01-02'.matchAll(regexp)];
3135
+ $mol_assert_like(found[0].groups, {
3136
+ year: '2020',
3137
+ month: '01',
3138
+ day: '02',
3139
+ });
3140
+ },
3141
+ 'sequence with groups of mixed type'() {
3142
+ const prefix = '/';
3143
+ const postfix = '/';
3144
+ const regexp = $mol_regexp.from([{ prefix }, /(\w+)/, { postfix }, /([gumi]*)/]);
3145
+ $mol_assert_like([...'/foo/mi'.matchAll(regexp)], [
3146
+ Object.assign(["/foo/mi", "/", "foo", "/", "mi"], {
3147
+ groups: {
3148
+ prefix: '/',
3149
+ postfix: '/',
3150
+ },
3151
+ index: 0,
3152
+ input: "/",
3153
+ }),
3154
+ ]);
3155
+ },
3156
+ 'recursive sequence with groups'() {
3157
+ const { begin, end, decimal_only: digit, repeat, from } = $mol_regexp;
3158
+ const year = repeat(digit, 4, 4);
3159
+ const dash = '-';
3160
+ const month = repeat(digit, 2, 2);
3161
+ const day = repeat(digit, 2, 2);
3162
+ const regexp = from([
3163
+ begin, { date: [{ year }, dash, { month }] }, dash, { day }, end
3164
+ ]);
3165
+ const found = [...'2020-01-02'.matchAll(regexp)];
3166
+ $mol_assert_like(found[0].groups, {
3167
+ date: '2020-01',
3168
+ year: '2020',
3169
+ month: '01',
3170
+ day: '02',
3171
+ });
3172
+ },
3173
+ 'parse multiple'() {
3174
+ const { decimal_only: digit, from } = $mol_regexp;
3175
+ const regexp = from({ digit });
3176
+ $mol_assert_like([...'123'.matchAll(regexp)].map(f => f.groups), [
3177
+ { digit: '1' },
3178
+ { digit: '2' },
3179
+ { digit: '3' },
3180
+ ]);
3181
+ },
3182
+ 'named variants'() {
3183
+ const { begin, or, end, from } = $mol_regexp;
3184
+ const sexism = from([
3185
+ begin, 'sex = ', { sex: ['male', or, 'female'] }, end
3186
+ ]);
3187
+ $mol_assert_like([...'sex = male'.matchAll(sexism)][0].groups, { sex: 'male' });
3188
+ $mol_assert_like([...'sex = female'.matchAll(sexism)][0].groups, { sex: 'female' });
3189
+ $mol_assert_like([...'sex = malefemale'.matchAll(sexism)][0].groups, undefined);
3190
+ },
3191
+ 'force after'() {
3192
+ const { latin_only: letter, force_after, from } = $mol_regexp;
3193
+ const regexp = from([letter, force_after('.')]);
3194
+ $mol_assert_like('x.'.match(regexp), ['x']);
3195
+ $mol_assert_like('x,'.match(regexp), null);
3196
+ },
3197
+ 'forbid after'() {
3198
+ const { latin_only: letter, forbid_after, from } = $mol_regexp;
3199
+ const regexp = from([letter, forbid_after('.')]);
3200
+ $mol_assert_like('x.'.match(regexp), null);
3201
+ $mol_assert_like('x,'.match(regexp), ['x']);
3202
+ },
3203
+ 'char except'() {
3204
+ const { char_except, latin_only, tab } = $mol_regexp;
3205
+ const name = char_except(latin_only, tab);
3206
+ $mol_assert_like('a'.match(name), null);
3207
+ $mol_assert_like('\t'.match(name), null);
3208
+ $mol_assert_like('('.match(name), ['(']);
3209
+ },
3210
+ 'unicode only'() {
3211
+ const { unicode_only, from } = $mol_regexp;
3212
+ const name = from([
3213
+ unicode_only('Script', 'Cyrillic'),
3214
+ unicode_only('Hex_Digit'),
3215
+ ]);
3216
+ $mol_assert_like('FF'.match(name), null);
3217
+ $mol_assert_like('ФG'.match(name), null);
3218
+ $mol_assert_like('ФF'.match(name), ['ФF']);
3219
+ },
3220
+ 'generate by optional with inner group'() {
3221
+ const { begin, end, from } = $mol_regexp;
3222
+ const animals = from([begin, '#', ['^', { dog: '@' }], end]);
3223
+ $mol_assert_equal(animals.generate({}), '#');
3224
+ $mol_assert_equal(animals.generate({ dog: false }), '#');
3225
+ $mol_assert_equal(animals.generate({ dog: true }), '#^@');
3226
+ $mol_assert_fail(() => animals.generate({ dog: '$' }), 'Wrong param: dog=$');
3227
+ },
3228
+ 'generate by optional with inner group with variants'() {
3229
+ const { begin, end, from } = $mol_regexp;
3230
+ const animals = from([begin, '#', ['^', { animal: { dog: '@', fox: '&' } }], end]);
3231
+ $mol_assert_equal(animals.generate({}), '#');
3232
+ $mol_assert_equal(animals.generate({ dog: true }), '#^@');
3233
+ $mol_assert_equal(animals.generate({ fox: true }), '#^&');
3234
+ $mol_assert_fail(() => animals.generate({ dog: '$' }), 'Wrong param: dog=$');
3235
+ },
3236
+ 'complex example'() {
3237
+ const { begin, end, char_only, char_range, latin_only, slash_back, repeat_greedy, from, } = $mol_regexp;
3238
+ const atom_char = char_only(latin_only, "!#$%&'*+/=?^`{|}~-");
3239
+ const atom = repeat_greedy(atom_char, 1);
3240
+ const dot_atom = from([atom, repeat_greedy(['.', atom])]);
3241
+ const name_letter = char_only(char_range(0x01, 0x08), 0x0b, 0x0c, char_range(0x0e, 0x1f), 0x21, char_range(0x23, 0x5b), char_range(0x5d, 0x7f));
3242
+ const quoted_pair = from([
3243
+ slash_back,
3244
+ char_only(char_range(0x01, 0x09), 0x0b, 0x0c, char_range(0x0e, 0x7f))
3245
+ ]);
3246
+ const name = repeat_greedy({ name_letter, quoted_pair });
3247
+ const quoted_name = from(['"', { name }, '"']);
3248
+ const local_part = from({ dot_atom, quoted_name });
3249
+ const domain = dot_atom;
3250
+ const mail = from([begin, local_part, '@', { domain }, end]);
3251
+ $mol_assert_equal('foo..bar@example.org'.match(mail), null);
3252
+ $mol_assert_equal('foo..bar"@example.org'.match(mail), null);
3253
+ $mol_assert_like([...'foo.bar@example.org'.matchAll(mail)][0].groups, {
3254
+ dot_atom: "foo.bar",
3255
+ quoted_name: "",
3256
+ name: "",
3257
+ name_letter: "",
3258
+ quoted_pair: "",
3259
+ domain: "example.org",
3260
+ });
3261
+ $mol_assert_like([...'"foo..bar"@example.org'.matchAll(mail)][0].groups, {
3262
+ dot_atom: "",
3263
+ quoted_name: '"foo..bar"',
3264
+ name: "foo..bar",
3265
+ name_letter: "r",
3266
+ quoted_pair: "",
3267
+ domain: "example.org",
3268
+ });
3269
+ $mol_assert_equal(mail.generate({ dot_atom: 'foo.bar', domain: 'example.org' }), 'foo.bar@example.org');
3270
+ $mol_assert_equal(mail.generate({ name: 'foo..bar', domain: 'example.org' }), '"foo..bar"@example.org');
3271
+ $mol_assert_fail(() => mail.generate({ dot_atom: 'foo..bar', domain: 'example.org' }), 'Wrong param: dot_atom=foo..bar');
3272
+ },
3273
+ });
3274
+ })($ || ($ = {}));
3275
+ //mol/regexp/regexp.test.ts
3276
+ ;
3277
+ "use strict";
3278
+ var $;
3279
+ (function ($) {
3280
+ var $$;
3281
+ (function ($$) {
3282
+ $mol_test({
3283
+ 'Empty needle'() {
3284
+ const app = new $mol_dimmer;
3285
+ app.needle = () => ' ';
3286
+ app.haystack = () => 'foo bar';
3287
+ $mol_assert_like(app.strings(), ['foo bar']);
3288
+ },
3289
+ 'Empty haystack'() {
3290
+ const app = new $mol_dimmer;
3291
+ app.needle = () => 'foo bar';
3292
+ app.haystack = () => '';
3293
+ $mol_assert_like(app.strings(), ['']);
3294
+ },
3295
+ 'Not found'() {
3296
+ const app = new $mol_dimmer;
3297
+ app.needle = () => 'foo';
3298
+ app.haystack = () => ' bar ';
3299
+ $mol_assert_like(app.strings(), [' bar ']);
3300
+ },
3301
+ 'One found'() {
3302
+ const app = new $mol_dimmer;
3303
+ app.needle = () => 'foo';
3304
+ app.haystack = () => ' barfoo ';
3305
+ $mol_assert_like(app.strings(), [' bar', 'foo', ' ']);
3306
+ },
3307
+ 'Multiple found'() {
3308
+ const app = new $mol_dimmer;
3309
+ app.needle = () => 'foo';
3310
+ app.haystack = () => ' foobarfoo foo';
3311
+ $mol_assert_like(app.strings(), [' ', 'foo', 'bar', 'foo', ' ', 'foo']);
3312
+ },
3313
+ 'Fuzzy search'() {
3314
+ const app = new $mol_dimmer;
3315
+ app.needle = () => 'foo bar';
3316
+ app.haystack = () => ' barfoo ';
3317
+ $mol_assert_like(app.strings(), [' ', 'bar', '', 'foo', ' ']);
3318
+ },
3319
+ });
3320
+ })($$ = $.$$ || ($.$$ = {}));
3321
+ })($ || ($ = {}));
3322
+ //mol/dimmer/dimmer.test.ts
3323
+ ;
3324
+ "use strict";
3325
+ var $;
3326
+ (function ($) {
3327
+ class $mol_style_sheet_test1 extends $mol_view {
3328
+ Item() { return new $mol_view; }
3329
+ }
3330
+ $.$mol_style_sheet_test1 = $mol_style_sheet_test1;
3331
+ class $mol_style_sheet_test2 extends $mol_view {
3332
+ List() { return new $mol_style_sheet_test1; }
3333
+ }
3334
+ $.$mol_style_sheet_test2 = $mol_style_sheet_test2;
3335
+ $mol_test({
3336
+ 'component block styles'() {
3337
+ class $mol_style_sheet_test extends $mol_view {
3338
+ }
3339
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3340
+ display: 'block',
3341
+ zIndex: 1,
3342
+ });
3343
+ $mol_assert_equal(sheet, '[mol_style_sheet_test] {\n\tdisplay: block;\n\tz-index: 1;\n}\n');
3344
+ },
3345
+ 'various units'() {
3346
+ class $mol_style_sheet_test extends $mol_view {
3347
+ }
3348
+ const { px, per } = $mol_style_unit;
3349
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3350
+ width: per(50),
3351
+ height: px(50),
3352
+ });
3353
+ $mol_assert_equal(sheet, '[mol_style_sheet_test] {\n\twidth: 50%;\n\theight: 50px;\n}\n');
3354
+ },
3355
+ 'various functions'() {
3356
+ class $mol_style_sheet_test extends $mol_view {
3357
+ }
3358
+ const { calc } = $mol_style_func;
3359
+ const { px, per } = $mol_style_unit;
3360
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3361
+ width: calc(`${per(100)} - ${px(1)}`),
3362
+ });
3363
+ $mol_assert_equal(sheet, '[mol_style_sheet_test] {\n\twidth: calc(100% - 1px);\n}\n');
3364
+ },
3365
+ 'property groups'() {
3366
+ class $mol_style_sheet_test extends $mol_view {
3367
+ }
3368
+ const { px } = $mol_style_unit;
3369
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3370
+ flex: {
3371
+ grow: 5
3372
+ }
3373
+ });
3374
+ $mol_assert_equal(sheet, '[mol_style_sheet_test] {\n\tflex-grow: 5;\n}\n');
3375
+ },
3376
+ 'custom properties'() {
3377
+ class $mol_style_sheet_test extends $mol_view {
3378
+ }
3379
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3380
+ '--isVariable': 'yes',
3381
+ });
3382
+ $mol_assert_equal(sheet, '[mol_style_sheet_test] {\n\t--is-variable: yes;\n}\n');
3383
+ },
3384
+ 'custom property groups'() {
3385
+ class $mol_style_sheet_test extends $mol_view {
3386
+ }
3387
+ const { px } = $mol_style_unit;
3388
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3389
+ '--variable': {
3390
+ test: px(5)
3391
+ }
3392
+ });
3393
+ $mol_assert_equal(sheet, '[mol_style_sheet_test] {\n\t--variable-test: 5px;\n}\n');
3394
+ },
3395
+ 'property shorthand'() {
3396
+ class $mol_style_sheet_test extends $mol_view {
3397
+ }
3398
+ const { px } = $mol_style_unit;
3399
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3400
+ padding: [px(5), 'auto']
3401
+ });
3402
+ $mol_assert_equal(sheet, '[mol_style_sheet_test] {\n\tpadding: 5px auto;\n}\n');
3403
+ },
3404
+ 'sequenced values'() {
3405
+ class $mol_style_sheet_test extends $mol_view {
3406
+ }
3407
+ const { url } = $mol_style_func;
3408
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3409
+ background: {
3410
+ image: [[url('foo')], [url('bar')]],
3411
+ },
3412
+ });
3413
+ $mol_assert_equal(sheet, '[mol_style_sheet_test] {\n\tbackground-image: url("foo"),url("bar");\n}\n');
3414
+ },
3415
+ 'sequenced structs'() {
3416
+ class $mol_style_sheet_test extends $mol_view {
3417
+ }
3418
+ const { rem } = $mol_style_unit;
3419
+ const { hsla } = $mol_style_func;
3420
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3421
+ box: {
3422
+ shadow: [
3423
+ {
3424
+ inset: true,
3425
+ x: 0,
3426
+ y: 0,
3427
+ blur: rem(.5),
3428
+ spread: 0,
3429
+ color: 'red',
3430
+ },
3431
+ {
3432
+ inset: false,
3433
+ x: 0,
3434
+ y: 0,
3435
+ blur: rem(.5),
3436
+ spread: 0,
3437
+ color: 'blue',
3438
+ },
3439
+ ],
3440
+ },
3441
+ });
3442
+ $mol_assert_equal(sheet, '[mol_style_sheet_test] {\n\tbox-shadow: inset 0 0 0.5rem 0 red,0 0 0.5rem 0 blue;\n}\n');
3443
+ },
3444
+ 'component block styles with pseudo class'() {
3445
+ class $mol_style_sheet_test extends $mol_view {
3446
+ }
3447
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3448
+ ':focus': {
3449
+ color: 'red',
3450
+ display: 'block',
3451
+ },
3452
+ });
3453
+ $mol_assert_equal(sheet, '[mol_style_sheet_test]:focus {\n\tcolor: red;\n\tdisplay: block;\n}\n');
3454
+ },
3455
+ 'component block styles with pseudo element'() {
3456
+ class $mol_style_sheet_test extends $mol_view {
3457
+ }
3458
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3459
+ '::first-line': {
3460
+ color: 'red',
3461
+ display: 'block',
3462
+ },
3463
+ });
3464
+ $mol_assert_equal(sheet, '[mol_style_sheet_test]::first-line {\n\tcolor: red;\n\tdisplay: block;\n}\n');
3465
+ },
3466
+ 'component block styles with media query'() {
3467
+ class $mol_style_sheet_test extends $mol_view {
3468
+ }
3469
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3470
+ '@media': {
3471
+ 'print': {
3472
+ color: 'red',
3473
+ display: 'block',
3474
+ },
3475
+ },
3476
+ });
3477
+ $mol_assert_equal(sheet, '@media print {\n[mol_style_sheet_test] {\n\tcolor: red;\n\tdisplay: block;\n}\n}\n');
3478
+ },
3479
+ 'component block styles with attribute value'() {
3480
+ class $mol_style_sheet_test extends $mol_view {
3481
+ attr() {
3482
+ return {
3483
+ mol_theme: '$mol_theme_dark'
3484
+ };
3485
+ }
3486
+ }
3487
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3488
+ '@': {
3489
+ mol_theme: {
3490
+ '$mol_theme_dark': {
3491
+ color: 'red',
3492
+ display: 'block',
3493
+ },
3494
+ },
3495
+ },
3496
+ });
3497
+ $mol_assert_equal(sheet, '[mol_style_sheet_test]:where([mol_theme="$mol_theme_dark"]) {\n\tcolor: red;\n\tdisplay: block;\n}\n');
3498
+ },
3499
+ 'component element styles'() {
3500
+ class $mol_style_sheet_test extends $mol_view {
3501
+ Item() { return new $mol_view; }
3502
+ }
3503
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3504
+ Item: {
3505
+ color: 'red',
3506
+ display: 'block',
3507
+ },
3508
+ });
3509
+ $mol_assert_equal(sheet, '[mol_style_sheet_test_item] {\n\tcolor: red;\n\tdisplay: block;\n}\n');
3510
+ },
3511
+ 'component element of element styles'() {
3512
+ const sheet = $mol_style_sheet($mol_style_sheet_test2, {
3513
+ List: {
3514
+ Item: {
3515
+ color: 'red',
3516
+ display: 'block',
3517
+ },
3518
+ },
3519
+ });
3520
+ $mol_assert_equal(sheet, '[mol_style_sheet_test2_list_item] {\n\tcolor: red;\n\tdisplay: block;\n}\n');
3521
+ },
3522
+ 'component element styles with block attribute value'() {
3523
+ class $mol_style_sheet_test extends $mol_view {
3524
+ Item() { return new $mol_view; }
3525
+ attr() {
3526
+ return {
3527
+ mol_theme: '$mol_theme_dark'
3528
+ };
3529
+ }
3530
+ }
3531
+ const sheet = $mol_style_sheet($mol_style_sheet_test, {
3532
+ '@': {
3533
+ mol_theme: {
3534
+ '$mol_theme_dark': {
3535
+ Item: {
3536
+ color: 'red',
3537
+ },
3538
+ },
3539
+ },
3540
+ },
3541
+ });
3542
+ $mol_assert_equal(sheet, '[mol_style_sheet_test]:where([mol_theme="$mol_theme_dark"]) :where([mol_style_sheet_test_item]) {\n\tcolor: red;\n}\n');
3543
+ },
3544
+ 'inner component styles by class'() {
3545
+ const sheet = $mol_style_sheet($mol_style_sheet_test2, {
3546
+ $mol_style_sheet_test1: {
3547
+ color: 'red',
3548
+ display: 'block',
3549
+ },
3550
+ });
3551
+ $mol_assert_equal(sheet, '[mol_style_sheet_test2] :where([mol_style_sheet_test1]) {\n\tcolor: red;\n\tdisplay: block;\n}\n');
3552
+ },
3553
+ 'child component styles by class'() {
3554
+ const sheet = $mol_style_sheet($mol_style_sheet_test2, {
3555
+ '>': {
3556
+ $mol_style_sheet_test1: {
3557
+ color: 'red',
3558
+ display: 'block',
3559
+ },
3560
+ },
3561
+ });
3562
+ $mol_assert_equal(sheet, '[mol_style_sheet_test2] > :where([mol_style_sheet_test1]) {\n\tcolor: red;\n\tdisplay: block;\n}\n');
3563
+ },
3564
+ });
3565
+ })($ || ($ = {}));
3566
+ //mol/style/sheet/sheet.test.ts
3567
+ ;
3568
+ "use strict";
3569
+ var $;
3570
+ (function ($) {
3571
+ $mol_test({
3572
+ '$mol_syntax2_md_flow'() {
3573
+ const check = (input, right) => {
3574
+ const tokens = [];
3575
+ $mol_syntax2_md_flow.tokenize(input, (...token) => tokens.push(token));
3576
+ $mol_assert_like(tokens, right);
3577
+ };
3578
+ check('Hello,\nWorld..\r\n\r\n\nof Love!', [
3579
+ ['block', 'Hello,\n', ['Hello,', '\n'], 0],
3580
+ ['block', 'World..\r\n\r\n\n', ['World..', '\r\n\r\n\n'], 7],
3581
+ ['block', 'of Love!', ['of Love!', ''], 19],
3582
+ ]);
3583
+ check('# Header1\n\nHello!\n\n## Header2', [
3584
+ ['header', '# Header1\n\n', ['#', ' ', 'Header1', '\n\n'], 0],
3585
+ ['block', 'Hello!\n\n', ['Hello!', '\n\n'], 11],
3586
+ ['header', '## Header2', ['##', ' ', 'Header2', ''], 19],
3587
+ ]);
3588
+ check('```\nstart()\n```\n\n```jam.js\nrestart()\n```\n\nHello!\n\n```\nstop()\n```', [
3589
+ ['code', '```\nstart()\n```\n\n', ['```', '', 'start()\n', '```', '\n\n'], 0],
3590
+ ['code', '```jam.js\nrestart()\n```\n\n', ['```', 'jam.js', 'restart()\n', '```', '\n\n'], 17],
3591
+ ['block', 'Hello!\n\n', ['Hello!', '\n\n'], 42],
3592
+ ['code', '```\nstop()\n```', ['```', '', 'stop()\n', '```', ''], 50],
3593
+ ]);
3594
+ check('| header1 | header2\n|----|----\n| Cell11 | Cell12\n| Cell21 | Cell22\n\n| Cell11 | Cell12\n| Cell21 | Cell22\n', [
3595
+ ['table', '| header1 | header2\n|----|----\n| Cell11 | Cell12\n| Cell21 | Cell22\n\n', ['| header1 | header2\n|----|----\n| Cell11 | Cell12\n| Cell21 | Cell22\n', '\n'], 0],
3596
+ ['table', '| Cell11 | Cell12\n| Cell21 | Cell22\n', ['| Cell11 | Cell12\n| Cell21 | Cell22\n', ''], 68],
3597
+ ]);
3598
+ },
3599
+ });
3600
+ })($ || ($ = {}));
3601
+ //mol/syntax2/md/md.test.ts
3602
+ ;
3603
+ "use strict";
3604
+ var $;
3605
+ (function ($_1) {
3606
+ var $$;
3607
+ (function ($$) {
3608
+ $mol_test({
3609
+ 'handle clicks by default'($) {
3610
+ let clicked = false;
3611
+ const clicker = $mol_button.make({
3612
+ $,
3613
+ click: (event) => { clicked = true; },
3614
+ });
3615
+ const element = clicker.dom_tree();
3616
+ const event = $mol_dom_context.document.createEvent('mouseevent');
3617
+ event.initEvent('click', true, true);
3618
+ element.dispatchEvent(event);
3619
+ $mol_assert_ok(clicked);
3620
+ },
3621
+ 'no handle clicks if disabled'($) {
3622
+ let clicked = false;
3623
+ const clicker = $mol_button.make({
3624
+ $,
3625
+ click: (event) => { clicked = true; },
3626
+ enabled: () => false,
3627
+ });
3628
+ const element = clicker.dom_tree();
3629
+ const event = $mol_dom_context.document.createEvent('mouseevent');
3630
+ event.initEvent('click', true, true);
3631
+ element.dispatchEvent(event);
3632
+ $mol_assert_not(clicked);
3633
+ },
3634
+ 'Store error'($) {
3635
+ const clicker = $mol_button.make({
3636
+ $,
3637
+ click: (event) => $.$mol_fail(new Error('Test error')),
3638
+ });
3639
+ const event = $mol_dom_context.document.createEvent('mouseevent');
3640
+ $mol_assert_fail(() => clicker.event_activate(event), 'Test error');
3641
+ $mol_assert_equal(clicker.status()[0].message, 'Test error');
3642
+ },
3643
+ });
3644
+ })($$ = $_1.$$ || ($_1.$$ = {}));
3645
+ })($ || ($ = {}));
3646
+ //mol/button/button.test.ts
3647
+ ;
3648
+ "use strict";
3649
+ var $;
3650
+ (function ($) {
3651
+ $mol_test({
3652
+ 'return result without errors'() {
3653
+ $mol_assert_equal($mol_try(() => false), false);
3654
+ },
3655
+ });
3656
+ })($ || ($ = {}));
3657
+ //mol/try/try.test.ts
3658
+
3
3659
  //# sourceMappingURL=web.test.js.map