mol_tree2 0.0.5 → 1.0.8

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,3187 +1,1617 @@
1
1
  "use strict";
2
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($_1.$$);
20
- for (let mock of $_1.$mol_test_mocks)
21
- await mock(context);
22
- await test(context);
23
- }
24
- $_1.$mol_ambient({}).$mol_log3_done({
25
- place: '$mol_test',
26
- message: 'Completed',
27
- count: $_1.$mol_test_all.length,
28
- });
29
- }
30
- $_1.$mol_test_run = $mol_test_run;
31
- let scheduled = false;
32
- function $mol_test_schedule() {
33
- if (scheduled)
34
- return;
35
- scheduled = true;
36
- setTimeout(() => {
37
- scheduled = false;
38
- $mol_test_run();
39
- }, 0);
40
- }
41
- $_1.$mol_test_schedule = $mol_test_schedule;
42
- $_1.$mol_test_mocks.push(context => {
43
- let seed = 0;
44
- context.Math = Object.create(Math);
45
- context.Math.random = () => Math.sin(seed++);
46
- const forbidden = ['XMLHttpRequest', 'fetch'];
47
- for (let api of forbidden) {
48
- context[api] = new Proxy(function () { }, {
49
- get() {
50
- $_1.$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
51
- },
52
- apply() {
53
- $_1.$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
54
- },
55
- });
56
- }
57
- });
58
- $mol_test({
59
- 'mocked Math.random'($) {
60
- console.assert($.Math.random() === 0);
61
- console.assert($.Math.random() === Math.sin(1));
62
- },
63
- 'forbidden XMLHttpRequest'($) {
64
- try {
65
- console.assert(void new $.XMLHttpRequest);
66
- }
67
- catch (error) {
68
- console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
69
- }
70
- },
71
- 'forbidden fetch'($) {
72
- try {
73
- console.assert(void $.fetch(''));
74
- }
75
- catch (error) {
76
- console.assert(error.message === 'fetch is forbidden in tests');
77
- }
78
- },
79
- });
80
- })($ || ($ = {}));
81
- //test.test.js.map
82
- ;
83
- "use strict";
84
- var $;
85
- (function ($) {
86
- })($ || ($ = {}));
87
- //context.js.map
88
- ;
89
- "use strict";
90
- var $;
91
- (function ($) {
92
- $.$mol_dom_context = self;
93
- })($ || ($ = {}));
94
- //context.web.js.map
95
- ;
96
- "use strict";
97
- var $;
98
- (function ($) {
99
- function $mol_dom_render_children(el, childNodes) {
100
- const node_set = new Set(childNodes);
101
- let nextNode = el.firstChild;
102
- for (let view of childNodes) {
103
- if (view == null)
104
- continue;
105
- if (view instanceof $.$mol_dom_context.Node) {
106
- while (true) {
107
- if (!nextNode) {
108
- el.appendChild(view);
109
- break;
110
- }
111
- if (nextNode == view) {
112
- nextNode = nextNode.nextSibling;
113
- break;
114
- }
115
- else {
116
- if (node_set.has(nextNode)) {
117
- el.insertBefore(view, nextNode);
118
- break;
119
- }
120
- else {
121
- const nn = nextNode.nextSibling;
122
- el.removeChild(nextNode);
123
- nextNode = nn;
124
- }
125
- }
126
- }
127
- }
128
- else {
129
- if (nextNode && nextNode.nodeName === '#text') {
130
- const str = String(view);
131
- if (nextNode.nodeValue !== str)
132
- nextNode.nodeValue = str;
133
- nextNode = nextNode.nextSibling;
134
- }
135
- else {
136
- const textNode = $.$mol_dom_context.document.createTextNode(String(view));
137
- el.insertBefore(textNode, nextNode);
138
- }
139
- }
140
- }
141
- while (nextNode) {
142
- const currNode = nextNode;
143
- nextNode = currNode.nextSibling;
144
- el.removeChild(currNode);
145
- }
146
- }
147
- $.$mol_dom_render_children = $mol_dom_render_children;
148
- })($ || ($ = {}));
149
- //children.js.map
150
- ;
151
- "use strict";
152
- //assert.test.js.map
153
- ;
154
- "use strict";
155
- //assert.js.map
156
- ;
157
- "use strict";
158
- //deep.test.js.map
159
- ;
160
- "use strict";
161
- //deep.js.map
162
- ;
163
- "use strict";
164
- var $;
165
- (function ($) {
166
- $.$mol_test({
167
- 'Make empty div'() {
168
- $.$mol_assert_equal(($.$mol_jsx("div", null)).outerHTML, '<div></div>');
169
- },
170
- 'Define native field'() {
171
- const dom = $.$mol_jsx("input", { value: '123' });
172
- $.$mol_assert_equal(dom.outerHTML, '<input value="123">');
173
- $.$mol_assert_equal(dom.value, '123');
174
- },
175
- 'Define classes'() {
176
- const dom = $.$mol_jsx("div", { class: 'foo bar' });
177
- $.$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
178
- },
179
- 'Define styles'() {
180
- const dom = $.$mol_jsx("div", { style: { color: 'red' } });
181
- $.$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
182
- },
183
- 'Define dataset'() {
184
- const dom = $.$mol_jsx("div", { dataset: { foo: 'bar' } });
185
- $.$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
186
- },
187
- 'Define attributes'() {
188
- const dom = $.$mol_jsx("div", { lang: "ru", hidden: true });
189
- $.$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
190
- },
191
- 'Define child nodes'() {
192
- const dom = $.$mol_jsx("div", null,
193
- "hello",
194
- $.$mol_jsx("strong", null, "world"),
195
- "!");
196
- $.$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
197
- },
198
- 'Function as component'() {
199
- const Button = ({ hint }, target) => {
200
- return $.$mol_jsx("button", { title: hint }, target());
201
- };
202
- const dom = $.$mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
203
- $.$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
204
- },
205
- 'Nested guid generation'() {
206
- const Foo = () => {
207
- return $.$mol_jsx("div", null,
208
- $.$mol_jsx(Bar, { id: "/bar" },
209
- $.$mol_jsx("img", { id: "/icon" })));
210
- };
211
- const Bar = (props, icon) => {
212
- return $.$mol_jsx("span", null, icon);
213
- };
214
- const dom = $.$mol_jsx(Foo, { id: "/foo" });
215
- $.$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
216
- },
217
- 'Fail on non unique ids'() {
218
- const App = () => {
219
- return $.$mol_jsx("div", null,
220
- $.$mol_jsx("span", { id: "/bar" }),
221
- $.$mol_jsx("span", { id: "/bar" }));
222
- };
223
- $.$mol_assert_fail(() => $.$mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
224
- },
225
- });
226
- })($ || ($ = {}));
227
- //jsx.test.js.map
228
- ;
229
- "use strict";
230
- var $;
231
- (function ($) {
232
- $.$mol_jsx_prefix = '';
233
- $.$mol_jsx_booked = null;
234
- $.$mol_jsx_document = {
235
- getElementById: () => null,
236
- createElement: (name) => $.$mol_dom_context.document.createElement(name)
237
- };
238
- function $mol_jsx(Elem, props, ...childNodes) {
239
- const id = props && props.id || '';
240
- if ($.$mol_jsx_booked) {
241
- if ($.$mol_jsx_booked.has(id)) {
242
- $.$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
243
- }
244
- else {
245
- $.$mol_jsx_booked.add(id);
246
- }
247
- }
248
- const guid = $.$mol_jsx_prefix + id;
249
- let node = guid && $.$mol_jsx_document.getElementById(guid);
250
- if (typeof Elem !== 'string') {
251
- if ('prototype' in Elem) {
252
- const view = node && node[Elem] || new Elem;
253
- Object.assign(view, props);
254
- view[Symbol.toStringTag] = guid;
255
- view.childNodes = childNodes;
256
- if (!view.ownerDocument)
257
- view.ownerDocument = $.$mol_jsx_document;
258
- node = view.valueOf();
259
- node[Elem] = view;
260
- return node;
261
- }
262
- else {
263
- const prefix = $.$mol_jsx_prefix;
264
- const booked = $.$mol_jsx_booked;
265
- try {
266
- $.$mol_jsx_prefix = guid;
267
- $.$mol_jsx_booked = new Set;
268
- return Elem(props, ...childNodes);
269
- }
270
- finally {
271
- $.$mol_jsx_prefix = prefix;
272
- $.$mol_jsx_booked = booked;
273
- }
274
- }
275
- }
276
- if (!node)
277
- node = $.$mol_jsx_document.createElement(Elem);
278
- $.$mol_dom_render_children(node, [].concat(...childNodes));
279
- for (const key in props) {
280
- if (typeof props[key] === 'string') {
281
- node.setAttribute(key, props[key]);
282
- }
283
- else if (props[key] &&
284
- typeof props[key] === 'object' &&
285
- Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
286
- if (typeof node[key] === 'object') {
287
- Object.assign(node[key], props[key]);
288
- continue;
289
- }
290
- }
291
- node[key] = props[key];
292
- }
293
- if (guid)
294
- node.id = guid;
295
- return node;
296
- }
297
- $.$mol_jsx = $mol_jsx;
298
- })($ || ($ = {}));
299
- //jsx.js.map
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 (res instanceof Promise) {
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
+ }, 0);
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
300
89
  ;
301
- "use strict";
302
- var $;
303
- (function ($) {
304
- $.$mol_test({
305
- 'nulls & undefineds'() {
306
- $.$mol_assert_ok($.$mol_compare_deep(null, null));
307
- $.$mol_assert_ok($.$mol_compare_deep(undefined, undefined));
308
- $.$mol_assert_not($.$mol_compare_deep(undefined, null));
309
- $.$mol_assert_not($.$mol_compare_deep({}, null));
310
- },
311
- 'number'() {
312
- $.$mol_assert_ok($.$mol_compare_deep(1, 1));
313
- $.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
314
- $.$mol_assert_not($.$mol_compare_deep(1, 2));
315
- },
316
- 'Number'() {
317
- $.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
318
- $.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
319
- $.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
320
- },
321
- 'empty POJOs'() {
322
- $.$mol_assert_ok($.$mol_compare_deep({}, {}));
323
- },
324
- 'different POJOs'() {
325
- $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
326
- },
327
- 'different POJOs with same keys but different values'() {
328
- $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
329
- },
330
- 'different POJOs with different keys but same values'() {
331
- $.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
332
- },
333
- 'Array'() {
334
- $.$mol_assert_ok($.$mol_compare_deep([], []));
335
- $.$mol_assert_ok($.$mol_compare_deep([1, [2]], [1, [2]]));
336
- $.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
337
- $.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
338
- },
339
- 'same POJO trees'() {
340
- $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
341
- },
342
- 'different classes with same values'() {
343
- class Obj {
344
- constructor() {
345
- this.foo = 1;
346
- }
347
- }
348
- const a = new Obj;
349
- const b = new class extends Obj {
350
- };
351
- $.$mol_assert_not($.$mol_compare_deep(a, b));
352
- },
353
- 'same POJOs with cyclic reference'() {
354
- const a = { foo: {} };
355
- a['self'] = a;
356
- const b = { foo: {} };
357
- b['self'] = b;
358
- $.$mol_assert_ok($.$mol_compare_deep(a, b));
359
- },
360
- 'empty Element'() {
361
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
362
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
363
- },
364
- 'Element with attributes'() {
365
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
366
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
367
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
368
- },
369
- 'Element with styles'() {
370
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
371
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
372
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
373
- },
374
- 'Element with content'() {
375
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
376
- "foo",
377
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
378
- "foo",
379
- $.$mol_jsx("br", null))));
380
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
381
- "foo",
382
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
383
- "bar",
384
- $.$mol_jsx("br", null))));
385
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
386
- "foo",
387
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
388
- "foo",
389
- $.$mol_jsx("hr", null))));
390
- },
391
- 'Element with handlers'() {
392
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
393
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
394
- },
395
- 'Date'() {
396
- $.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
397
- $.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
398
- },
399
- 'RegExp'() {
400
- $.$mol_assert_ok($.$mol_compare_deep(/\x22/mig, /\x22/mig));
401
- $.$mol_assert_not($.$mol_compare_deep(/\x22/mig, /\x21/mig));
402
- $.$mol_assert_not($.$mol_compare_deep(/\x22/mig, /\x22/mg));
403
- },
404
- 'Map'() {
405
- $.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
406
- $.$mol_assert_ok($.$mol_compare_deep(new Map([[[1], [2]]]), new Map([[[1], [2]]])));
407
- $.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
408
- },
409
- 'Set'() {
410
- $.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
411
- $.$mol_assert_ok($.$mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
412
- $.$mol_assert_not($.$mol_compare_deep(new Set([1]), new Set([2])));
413
- },
414
- 'Uint8Array'() {
415
- $.$mol_assert_ok($.$mol_compare_deep(new Uint8Array, new Uint8Array));
416
- $.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
417
- $.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
418
- },
419
- });
420
- })($ || ($ = {}));
421
- //deep.test.js.map
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
422
98
  ;
423
- "use strict";
424
- var $;
425
- (function ($) {
426
- const a_stack = [];
427
- const b_stack = [];
428
- let cache = null;
429
- function $mol_compare_deep(a, b) {
430
- if (Object.is(a, b))
431
- return true;
432
- const a_type = typeof a;
433
- const b_type = typeof b;
434
- if (a_type !== b_type)
435
- return false;
436
- if (a_type === 'function')
437
- return a['toString']() === b['toString']();
438
- if (a_type !== 'object')
439
- return false;
440
- if (!a || !b)
441
- return false;
442
- if (a instanceof Error)
443
- return false;
444
- if (a['constructor'] !== b['constructor'])
445
- return false;
446
- if (a instanceof RegExp)
447
- return a.toString() === b['toString']();
448
- const ref = a_stack.indexOf(a);
449
- if (ref >= 0) {
450
- return Object.is(b_stack[ref], b);
451
- }
452
- if (!cache)
453
- cache = new WeakMap;
454
- let a_cache = cache.get(a);
455
- if (a_cache) {
456
- const b_cache = a_cache.get(b);
457
- if (typeof b_cache === 'boolean')
458
- return b_cache;
459
- }
460
- else {
461
- a_cache = new WeakMap();
462
- cache.set(a, a_cache);
463
- }
464
- a_stack.push(a);
465
- b_stack.push(b);
466
- let result;
467
- try {
468
- if (Symbol.iterator in a) {
469
- const a_iter = a[Symbol.iterator]();
470
- const b_iter = b[Symbol.iterator]();
471
- while (true) {
472
- const a_next = a_iter.next();
473
- const b_next = b_iter.next();
474
- if (a_next.done !== b_next.done)
475
- return result = false;
476
- if (a_next.done)
477
- break;
478
- if (!$mol_compare_deep(a_next.value, b_next.value))
479
- return result = false;
480
- }
481
- return result = true;
482
- }
483
- let count = 0;
484
- for (let key in a) {
485
- try {
486
- if (!$mol_compare_deep(a[key], b[key]))
487
- return result = false;
488
- }
489
- catch (error) {
490
- $.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
491
- }
492
- ++count;
493
- }
494
- for (let key in b) {
495
- --count;
496
- if (count < 0)
497
- return result = false;
498
- }
499
- if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
500
- if (!Object.is(a['valueOf'](), b['valueOf']()))
501
- return result = false;
502
- }
503
- return result = true;
504
- }
505
- finally {
506
- a_stack.pop();
507
- b_stack.pop();
508
- if (a_stack.length === 0) {
509
- cache = null;
510
- }
511
- else {
512
- a_cache.set(b, result);
513
- }
514
- }
515
- }
516
- $.$mol_compare_deep = $mol_compare_deep;
517
- })($ || ($ = {}));
518
- //deep.js.map
99
+ "use strict";
100
+ var $;
101
+ (function ($) {
102
+ })($ || ($ = {}));
103
+ //mol/dom/context/context.ts
519
104
  ;
520
- "use strict";
521
- var $;
522
- (function ($) {
523
- $.$mol_test({
524
- 'must be false'() {
525
- $.$mol_assert_not(0);
526
- },
527
- 'must be true'() {
528
- $.$mol_assert_ok(1);
529
- },
530
- 'two must be equal'() {
531
- $.$mol_assert_equal(2, 2);
532
- },
533
- 'three must be equal'() {
534
- $.$mol_assert_equal(2, 2, 2);
535
- },
536
- 'two must be unique'() {
537
- $.$mol_assert_unique([3], [3]);
538
- },
539
- 'three must be unique'() {
540
- $.$mol_assert_unique([3], [3], [3]);
541
- },
542
- 'two must be alike'() {
543
- $.$mol_assert_like([3], [3]);
544
- },
545
- 'three must be alike'() {
546
- $.$mol_assert_like([3], [3], [3]);
547
- },
548
- });
549
- })($ || ($ = {}));
550
- //assert.test.js.map
105
+ "use strict";
106
+ var $;
107
+ (function ($) {
108
+ $.$mol_dom_context = self;
109
+ })($ || ($ = {}));
110
+ //mol/dom/context/context.web.ts
551
111
  ;
552
- "use strict";
553
- var $;
554
- (function ($) {
555
- function $mol_assert_ok(value) {
556
- if (value)
557
- return;
558
- $.$mol_fail(new Error(`${value} true`));
559
- }
560
- $.$mol_assert_ok = $mol_assert_ok;
561
- function $mol_assert_not(value) {
562
- if (!value)
563
- return;
564
- $.$mol_fail(new Error(`${value} ≠ false`));
565
- }
566
- $.$mol_assert_not = $mol_assert_not;
567
- function $mol_assert_fail(handler, ErrorRight) {
568
- const fail = $.$mol_fail;
569
- try {
570
- $.$mol_fail = $.$mol_fail_hidden;
571
- handler();
572
- }
573
- catch (error) {
574
- if (!ErrorRight)
575
- return error;
576
- $.$mol_fail = fail;
577
- if (typeof ErrorRight === 'string') {
578
- $mol_assert_equal(error.message, ErrorRight);
579
- }
580
- else {
581
- $mol_assert_ok(error instanceof ErrorRight);
582
- }
583
- return error;
584
- }
585
- finally {
586
- $.$mol_fail = fail;
587
- }
588
- $.$mol_fail(new Error('Not failed'));
589
- }
590
- $.$mol_assert_fail = $mol_assert_fail;
591
- function $mol_assert_equal(...args) {
592
- for (let i = 0; i < args.length; ++i) {
593
- for (let j = 0; j < args.length; ++j) {
594
- if (i === j)
595
- continue;
596
- if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
597
- continue;
598
- if (args[i] !== args[j])
599
- $.$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
600
- }
601
- }
602
- }
603
- $.$mol_assert_equal = $mol_assert_equal;
604
- function $mol_assert_unique(...args) {
605
- for (let i = 0; i < args.length; ++i) {
606
- for (let j = 0; j < args.length; ++j) {
607
- if (i === j)
608
- continue;
609
- if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
610
- $.$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
611
- }
612
- }
613
- }
614
- }
615
- $.$mol_assert_unique = $mol_assert_unique;
616
- function $mol_assert_like(head, ...tail) {
617
- for (let [index, value] of Object.entries(tail)) {
618
- if (!$.$mol_compare_deep(value, head)) {
619
- const print = (val) => {
620
- if (!val)
621
- return val;
622
- if (typeof val !== 'object')
623
- return val;
624
- if ('outerHTML' in val)
625
- return val.outerHTML;
626
- try {
627
- return JSON.stringify(val);
628
- }
629
- catch (error) {
630
- console.error(error);
631
- return val;
632
- }
633
- };
634
- return $.$mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
635
- }
636
- }
637
- }
638
- $.$mol_assert_like = $mol_assert_like;
639
- })($ || ($ = {}));
640
- //assert.js.map
112
+ "use strict";
113
+ var $;
114
+ (function ($) {
115
+ function $mol_dom_render_children(el, childNodes) {
116
+ const node_set = new Set(childNodes);
117
+ let nextNode = el.firstChild;
118
+ for (let view of childNodes) {
119
+ if (view == null)
120
+ continue;
121
+ if (view instanceof $mol_dom_context.Node) {
122
+ while (true) {
123
+ if (!nextNode) {
124
+ el.appendChild(view);
125
+ break;
126
+ }
127
+ if (nextNode == view) {
128
+ nextNode = nextNode.nextSibling;
129
+ break;
130
+ }
131
+ else {
132
+ if (node_set.has(nextNode)) {
133
+ el.insertBefore(view, nextNode);
134
+ break;
135
+ }
136
+ else {
137
+ const nn = nextNode.nextSibling;
138
+ el.removeChild(nextNode);
139
+ nextNode = nn;
140
+ }
141
+ }
142
+ }
143
+ }
144
+ else {
145
+ if (nextNode && nextNode.nodeName === '#text') {
146
+ const str = String(view);
147
+ if (nextNode.nodeValue !== str)
148
+ nextNode.nodeValue = str;
149
+ nextNode = nextNode.nextSibling;
150
+ }
151
+ else {
152
+ const textNode = $mol_dom_context.document.createTextNode(String(view));
153
+ el.insertBefore(textNode, nextNode);
154
+ }
155
+ }
156
+ }
157
+ while (nextNode) {
158
+ const currNode = nextNode;
159
+ nextNode = currNode.nextSibling;
160
+ el.removeChild(currNode);
161
+ }
162
+ }
163
+ $.$mol_dom_render_children = $mol_dom_render_children;
164
+ })($ || ($ = {}));
165
+ //mol/dom/render/children/children.ts
641
166
  ;
642
- "use strict";
643
- var $;
644
- (function ($) {
645
- $.$mol_test({
646
- 'get'() {
647
- const proxy = $.$mol_delegate({}, () => ({ foo: 777 }));
648
- $.$mol_assert_equal(proxy.foo, 777);
649
- },
650
- 'has'() {
651
- const proxy = $.$mol_delegate({}, () => ({ foo: 777 }));
652
- $.$mol_assert_equal('foo' in proxy, true);
653
- },
654
- 'set'() {
655
- const target = { foo: 777 };
656
- const proxy = $.$mol_delegate({}, () => target);
657
- proxy.foo = 123;
658
- $.$mol_assert_equal(target.foo, 123);
659
- },
660
- 'getOwnPropertyDescriptor'() {
661
- const proxy = $.$mol_delegate({}, () => ({ foo: 777 }));
662
- $.$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
663
- value: 777,
664
- writable: true,
665
- enumerable: true,
666
- configurable: true,
667
- });
668
- },
669
- 'ownKeys'() {
670
- const proxy = $.$mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
671
- $.$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
672
- },
673
- 'getPrototypeOf'() {
674
- class Foo {
675
- }
676
- const proxy = $.$mol_delegate({}, () => new Foo);
677
- $.$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
678
- },
679
- 'setPrototypeOf'() {
680
- class Foo {
681
- }
682
- const target = {};
683
- const proxy = $.$mol_delegate({}, () => target);
684
- Object.setPrototypeOf(proxy, Foo.prototype);
685
- $.$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
686
- },
687
- 'instanceof'() {
688
- class Foo {
689
- }
690
- const proxy = $.$mol_delegate({}, () => new Foo);
691
- $.$mol_assert_ok(proxy instanceof Foo);
692
- $.$mol_assert_ok(proxy instanceof $.$mol_delegate);
693
- },
694
- 'autobind'() {
695
- class Foo {
696
- }
697
- const proxy = $.$mol_delegate({}, () => new Foo);
698
- $.$mol_assert_ok(proxy instanceof Foo);
699
- $.$mol_assert_ok(proxy instanceof $.$mol_delegate);
700
- },
701
- });
702
- })($ || ($ = {}));
703
- //delegate.test.js.map
167
+ "use strict";
168
+ //mol/type/error/error.ts
704
169
  ;
705
- "use strict";
706
- //writable.test.js.map
170
+ "use strict";
171
+ //mol/type/assert/assert.test.ts
707
172
  ;
708
- "use strict";
709
- var $;
710
- (function ($_1) {
711
- $_1.$mol_test({
712
- 'span for same uri'($) {
713
- const span = new $_1.$mol_span('test.ts', '', 1, 3, 4);
714
- const child = span.span(4, 5, 8);
715
- $_1.$mol_assert_equal(child.uri, 'test.ts');
716
- $_1.$mol_assert_equal(child.row, 4);
717
- $_1.$mol_assert_equal(child.col, 5);
718
- $_1.$mol_assert_equal(child.length, 8);
719
- },
720
- 'span after of given position'($) {
721
- const span = new $_1.$mol_span('test.ts', '', 1, 3, 4);
722
- const child = span.after(11);
723
- $_1.$mol_assert_equal(child.uri, 'test.ts');
724
- $_1.$mol_assert_equal(child.row, 1);
725
- $_1.$mol_assert_equal(child.col, 7);
726
- $_1.$mol_assert_equal(child.length, 11);
727
- },
728
- 'slice span - regular'($) {
729
- const span = new $_1.$mol_span('test.ts', '', 1, 3, 5);
730
- const child = span.slice(1, 4);
731
- $_1.$mol_assert_equal(child.row, 1);
732
- $_1.$mol_assert_equal(child.col, 4);
733
- $_1.$mol_assert_equal(child.length, 3);
734
- const child2 = span.slice(2, 2);
735
- $_1.$mol_assert_equal(child2.col, 5);
736
- $_1.$mol_assert_equal(child2.length, 0);
737
- },
738
- 'slice span - negative'($) {
739
- const span = new $_1.$mol_span('test.ts', '', 1, 3, 5);
740
- const child = span.slice(-3, -1);
741
- $_1.$mol_assert_equal(child.row, 1);
742
- $_1.$mol_assert_equal(child.col, 5);
743
- $_1.$mol_assert_equal(child.length, 2);
744
- },
745
- 'slice span - out of range'($) {
746
- const span = new $_1.$mol_span('test.ts', '', 1, 3, 5);
747
- $_1.$mol_assert_fail(() => span.slice(-1, 3));
748
- $_1.$mol_assert_fail(() => span.slice(1, 6));
749
- $_1.$mol_assert_fail(() => span.slice(1, 10));
750
- },
751
- 'error handling'($) {
752
- const span = new $_1.$mol_span('test.ts', '', 1, 3, 4);
753
- const error = span.error('Some error\n');
754
- $_1.$mol_assert_equal(error.message, 'Some error\ntest.ts#1:3/4');
755
- }
756
- });
757
- })($ || ($ = {}));
758
- //span.test.js.map
173
+ "use strict";
174
+ //mol/type/assert/assert.ts
759
175
  ;
760
- "use strict";
761
- var $;
762
- (function ($_1) {
763
- $_1.$mol_test_mocks.push($ => {
764
- $.$mol_log3_come = () => { };
765
- $.$mol_log3_done = () => { };
766
- $.$mol_log3_fail = () => { };
767
- $.$mol_log3_warn = () => { };
768
- $.$mol_log3_rise = () => { };
769
- $.$mol_log3_area = () => () => { };
770
- });
771
- })($ || ($ = {}));
772
- //log3.test.js.map
176
+ "use strict";
177
+ //mol/type/equals/equals.test.ts
773
178
  ;
774
- "use strict";
775
- var $;
776
- (function ($_1) {
777
- $_1.$mol_test({
778
- 'inserting'($) {
779
- $_1.$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
780
- .insert($_1.$mol_tree2.struct('x'), 'a', 'b', 'c')
781
- .toString(), 'a b x\n');
782
- $_1.$mol_assert_equal($.$mol_tree2_from_string('a b\n')
783
- .insert($_1.$mol_tree2.struct('x'), 'a', 'b', 'c', 'd')
784
- .toString(), 'a b c x\n');
785
- $_1.$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
786
- .insert($_1.$mol_tree2.struct('x'), 0, 0, 0)
787
- .toString(), 'a b x\n');
788
- $_1.$mol_assert_equal($.$mol_tree2_from_string('a b\n')
789
- .insert($_1.$mol_tree2.struct('x'), 0, 0, 0, 0)
790
- .toString(), 'a b \\\n\tx\n');
791
- $_1.$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
792
- .insert($_1.$mol_tree2.struct('x'), null, null, null)
793
- .toString(), 'a b x\n');
794
- $_1.$mol_assert_equal($.$mol_tree2_from_string('a b\n')
795
- .insert($_1.$mol_tree2.struct('x'), null, null, null, null)
796
- .toString(), 'a b \\\n\tx\n');
797
- },
798
- 'hack'($) {
799
- const res = $.$mol_tree2_from_string(`foo bar xxx\n`)
800
- .hack({
801
- 'bar': (input, belt) => [input.struct('777', input.hack(belt))],
802
- });
803
- $_1.$mol_assert_equal(res.toString(), 'foo 777 xxx\n');
804
- },
805
- });
806
- })($ || ($ = {}));
807
- //tree2.test.js.map
179
+ "use strict";
180
+ //mol/type/equals/equals.ts
808
181
  ;
809
- "use strict";
810
- var $;
811
- (function ($) {
812
- function $mol_dom_parse(text, type = 'application/xhtml+xml') {
813
- const parser = new $.$mol_dom_context.DOMParser();
814
- const doc = parser.parseFromString(text, type);
815
- const error = doc.getElementsByTagName('parsererror');
816
- if (error.length)
817
- throw new Error(error[0].textContent);
818
- return doc;
819
- }
820
- $.$mol_dom_parse = $mol_dom_parse;
821
- })($ || ($ = {}));
822
- //parse.js.map
182
+ "use strict";
183
+ //mol/type/partial/deep/deep.test.ts
823
184
  ;
824
- "use strict";
825
- var $;
826
- (function ($) {
827
- $.$mol_test({
828
- 'Attach to document'() {
829
- const doc = $.$mol_dom_parse('<html><body id="/foo"></body></html>');
830
- $.$mol_jsx_attach(doc, () => $.$mol_jsx("body", { id: "/foo" }, "bar"));
831
- $.$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">bar</body></html>');
832
- },
833
- });
834
- })($ || ($ = {}));
835
- //attach.test.js.map
185
+ "use strict";
186
+ //mol/type/partial/deep/deep.ts
836
187
  ;
837
- "use strict";
838
- var $;
839
- (function ($) {
840
- function $mol_jsx_attach(next, action) {
841
- const prev = $.$mol_jsx_document;
842
- try {
843
- $.$mol_jsx_document = next;
844
- return action();
845
- }
846
- finally {
847
- $.$mol_jsx_document = prev;
848
- }
849
- }
850
- $.$mol_jsx_attach = $mol_jsx_attach;
851
- })($ || ($ = {}));
852
- //attach.js.map
188
+ "use strict";
189
+ var $;
190
+ (function ($) {
191
+ $mol_test({
192
+ 'Make empty div'() {
193
+ $mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
194
+ },
195
+ 'Define native field'() {
196
+ const dom = $mol_jsx("input", { value: '123' });
197
+ $mol_assert_equal(dom.outerHTML, '<input value="123">');
198
+ $mol_assert_equal(dom.value, '123');
199
+ },
200
+ 'Define classes'() {
201
+ const dom = $mol_jsx("div", { class: 'foo bar' });
202
+ $mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
203
+ },
204
+ 'Define styles'() {
205
+ const dom = $mol_jsx("div", { style: { color: 'red' } });
206
+ $mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
207
+ },
208
+ 'Define dataset'() {
209
+ const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
210
+ $mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
211
+ },
212
+ 'Define attributes'() {
213
+ const dom = $mol_jsx("div", { lang: "ru", hidden: true });
214
+ $mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
215
+ },
216
+ 'Define child nodes'() {
217
+ const dom = $mol_jsx("div", null,
218
+ "hello",
219
+ $mol_jsx("strong", null, "world"),
220
+ "!");
221
+ $mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
222
+ },
223
+ 'Function as component'() {
224
+ const Button = (props, target) => {
225
+ return $mol_jsx("button", { title: props.hint }, target());
226
+ };
227
+ const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
228
+ $mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
229
+ },
230
+ 'Nested guid generation'() {
231
+ const Foo = () => {
232
+ return $mol_jsx("div", null,
233
+ $mol_jsx(Bar, { id: "bar" },
234
+ $mol_jsx("img", { id: "icon" })));
235
+ };
236
+ const Bar = (props, icon) => {
237
+ return $mol_jsx("span", null,
238
+ icon,
239
+ $mol_jsx("i", { id: "label" }));
240
+ };
241
+ const dom = $mol_jsx(Foo, { id: "foo" });
242
+ $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>');
243
+ },
244
+ 'Fail on non unique ids'() {
245
+ const App = () => {
246
+ return $mol_jsx("div", null,
247
+ $mol_jsx("span", { id: "bar" }),
248
+ $mol_jsx("span", { id: "bar" }));
249
+ };
250
+ $mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
251
+ },
252
+ 'Owner based guid generationn'() {
253
+ const Foo = () => {
254
+ return $mol_jsx("div", null,
255
+ $mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
256
+ };
257
+ const Bar = (props) => {
258
+ return $mol_jsx("span", null, props.icon());
259
+ };
260
+ const dom = $mol_jsx(Foo, { id: "app" });
261
+ $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>');
262
+ },
263
+ 'Fail on same ids from different caller'() {
264
+ const Foo = () => {
265
+ return $mol_jsx("div", null,
266
+ $mol_jsx("img", { id: "icon" }),
267
+ $mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
268
+ };
269
+ const Bar = (props) => {
270
+ return $mol_jsx("span", null, props.icon());
271
+ };
272
+ $mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
273
+ },
274
+ });
275
+ })($ || ($ = {}));
276
+ //mol/jsx/jsx.test.tsx
853
277
  ;
854
- "use strict";
855
- var $;
856
- (function ($) {
857
- $.$mol_test({
858
- 'init with overload'() {
859
- class X extends $.$mol_object {
860
- foo() {
861
- return 1;
862
- }
863
- }
864
- var x = X.make({
865
- foo: () => 2,
866
- });
867
- $.$mol_assert_equal(x.foo(), 2);
868
- },
869
- });
870
- })($ || ($ = {}));
871
- //object.test.js.map
278
+ "use strict";
279
+ var $;
280
+ (function ($) {
281
+ $.$mol_jsx_prefix = '';
282
+ $.$mol_jsx_crumbs = '';
283
+ $.$mol_jsx_booked = null;
284
+ $.$mol_jsx_document = {
285
+ getElementById: () => null,
286
+ createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
287
+ createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
288
+ };
289
+ $.$mol_jsx_frag = '';
290
+ function $mol_jsx(Elem, props, ...childNodes) {
291
+ const id = props && props.id || '';
292
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
293
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
294
+ if (Elem && $.$mol_jsx_booked) {
295
+ if ($.$mol_jsx_booked.has(id)) {
296
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
297
+ }
298
+ else {
299
+ $.$mol_jsx_booked.add(id);
300
+ }
301
+ }
302
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
303
+ if ($.$mol_jsx_prefix) {
304
+ const prefix_ext = $.$mol_jsx_prefix;
305
+ const booked_ext = $.$mol_jsx_booked;
306
+ const crumbs_ext = $.$mol_jsx_crumbs;
307
+ for (const field in props) {
308
+ const func = props[field];
309
+ if (typeof func !== 'function')
310
+ continue;
311
+ const wrapper = function (...args) {
312
+ const prefix = $.$mol_jsx_prefix;
313
+ const booked = $.$mol_jsx_booked;
314
+ const crumbs = $.$mol_jsx_crumbs;
315
+ try {
316
+ $.$mol_jsx_prefix = prefix_ext;
317
+ $.$mol_jsx_booked = booked_ext;
318
+ $.$mol_jsx_crumbs = crumbs_ext;
319
+ return func.call(this, ...args);
320
+ }
321
+ finally {
322
+ $.$mol_jsx_prefix = prefix;
323
+ $.$mol_jsx_booked = booked;
324
+ $.$mol_jsx_crumbs = crumbs;
325
+ }
326
+ };
327
+ $mol_func_name_from(wrapper, func);
328
+ props[field] = wrapper;
329
+ }
330
+ }
331
+ if (typeof Elem !== 'string') {
332
+ if ('prototype' in Elem) {
333
+ const view = node && node[Elem] || new Elem;
334
+ Object.assign(view, props);
335
+ view[Symbol.toStringTag] = guid;
336
+ view.childNodes = childNodes;
337
+ if (!view.ownerDocument)
338
+ view.ownerDocument = $.$mol_jsx_document;
339
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
340
+ node = view.valueOf();
341
+ node[Elem] = view;
342
+ return node;
343
+ }
344
+ else {
345
+ const prefix = $.$mol_jsx_prefix;
346
+ const booked = $.$mol_jsx_booked;
347
+ const crumbs = $.$mol_jsx_crumbs;
348
+ try {
349
+ $.$mol_jsx_prefix = guid;
350
+ $.$mol_jsx_booked = new Set;
351
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
352
+ return Elem(props, ...childNodes);
353
+ }
354
+ finally {
355
+ $.$mol_jsx_prefix = prefix;
356
+ $.$mol_jsx_booked = booked;
357
+ $.$mol_jsx_crumbs = crumbs;
358
+ }
359
+ }
360
+ }
361
+ if (!node) {
362
+ node = Elem
363
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
364
+ : $.$mol_jsx_document.createDocumentFragment();
365
+ }
366
+ $mol_dom_render_children(node, [].concat(...childNodes));
367
+ if (!Elem)
368
+ return node;
369
+ if (guid)
370
+ node.id = guid;
371
+ for (const key in props) {
372
+ if (key === 'id')
373
+ continue;
374
+ if (typeof props[key] === 'string') {
375
+ ;
376
+ node.setAttribute(key, props[key]);
377
+ }
378
+ else if (props[key] &&
379
+ typeof props[key] === 'object' &&
380
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
381
+ if (typeof node[key] === 'object') {
382
+ Object.assign(node[key], props[key]);
383
+ continue;
384
+ }
385
+ }
386
+ else {
387
+ node[key] = props[key];
388
+ }
389
+ }
390
+ if ($.$mol_jsx_crumbs)
391
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
392
+ return node;
393
+ }
394
+ $.$mol_jsx = $mol_jsx;
395
+ })($ || ($ = {}));
396
+ //mol/jsx/jsx.ts
872
397
  ;
873
- "use strict";
874
- var $;
875
- (function ($_1) {
876
- let $$;
877
- (function ($$) {
878
- let $;
879
- })($$ = $_1.$$ || ($_1.$$ = {}));
880
- $_1.$mol_object_field = Symbol('$mol_object_field');
881
- class $mol_object extends $_1.$mol_object2 {
882
- static make(config) {
883
- return super.create(obj => {
884
- for (let key in config)
885
- obj[key] = config[key];
886
- });
887
- }
888
- }
889
- $_1.$mol_object = $mol_object;
890
- })($ || ($ = {}));
891
- //object.js.map
398
+ "use strict";
399
+ var $;
400
+ (function ($) {
401
+ $mol_test({
402
+ 'nulls & undefineds'() {
403
+ $mol_assert_ok($mol_compare_deep(null, null));
404
+ $mol_assert_ok($mol_compare_deep(undefined, undefined));
405
+ $mol_assert_not($mol_compare_deep(undefined, null));
406
+ $mol_assert_not($mol_compare_deep({}, null));
407
+ },
408
+ 'number'() {
409
+ $mol_assert_ok($mol_compare_deep(1, 1));
410
+ $mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
411
+ $mol_assert_not($mol_compare_deep(1, 2));
412
+ $mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
413
+ $mol_assert_not($mol_compare_deep(Object(1), Object(2)));
414
+ },
415
+ 'POJO'() {
416
+ $mol_assert_ok($mol_compare_deep({}, {}));
417
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
418
+ $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
419
+ $mol_assert_not($mol_compare_deep({}, { a: undefined }));
420
+ $mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
421
+ $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
422
+ },
423
+ 'Array'() {
424
+ $mol_assert_ok($mol_compare_deep([], []));
425
+ $mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
426
+ $mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
427
+ $mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
428
+ },
429
+ 'Non POJO are different'() {
430
+ class Thing extends Object {
431
+ }
432
+ $mol_assert_not($mol_compare_deep(new Thing, new Thing));
433
+ $mol_assert_not($mol_compare_deep(() => 1, () => 1));
434
+ $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
435
+ },
436
+ 'same POJOs with cyclic reference'() {
437
+ const a = { foo: {} };
438
+ a['self'] = a;
439
+ const b = { foo: {} };
440
+ b['self'] = b;
441
+ $mol_assert_ok($mol_compare_deep(a, b));
442
+ },
443
+ 'Date'() {
444
+ $mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
445
+ $mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
446
+ },
447
+ 'RegExp'() {
448
+ $mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
449
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
450
+ $mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
451
+ },
452
+ 'Error'() {
453
+ $mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
454
+ const fail = (message) => new Error(message);
455
+ $mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
456
+ $mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
457
+ },
458
+ 'Map'() {
459
+ $mol_assert_ok($mol_compare_deep(new Map, new Map));
460
+ $mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
461
+ $mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
462
+ $mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
463
+ },
464
+ 'Set'() {
465
+ $mol_assert_ok($mol_compare_deep(new Set, new Set));
466
+ $mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
467
+ $mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
468
+ },
469
+ 'Uint8Array'() {
470
+ $mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
471
+ $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
472
+ $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
473
+ },
474
+ 'Custom comparator'() {
475
+ class User {
476
+ name;
477
+ rand;
478
+ constructor(name, rand = Math.random()) {
479
+ this.name = name;
480
+ this.rand = rand;
481
+ }
482
+ [Symbol.toPrimitive](mode) {
483
+ return this.name;
484
+ }
485
+ }
486
+ $mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
487
+ $mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
488
+ },
489
+ });
490
+ })($ || ($ = {}));
491
+ //mol/compare/deep/deep.test.tsx
892
492
  ;
893
- "use strict";
894
- var $;
895
- (function ($) {
896
- $.$mol_test({
897
- 'run callback'() {
898
- class Plus1 extends $.$mol_wrapper {
899
- static wrap(task) {
900
- return function (...args) {
901
- return task.call(this, ...args) + 1;
902
- };
903
- }
904
- }
905
- $.$mol_assert_equal(Plus1.run(() => 2), 3);
906
- },
907
- 'wrap function'() {
908
- class Plus1 extends $.$mol_wrapper {
909
- static wrap(task) {
910
- return function (...args) {
911
- return task.call(this, ...args) + 1;
912
- };
913
- }
914
- }
915
- const obj = {
916
- level: 2,
917
- pow: Plus1.func(function (a) {
918
- return a ** this.level;
919
- })
920
- };
921
- $.$mol_assert_equal(obj.pow(2), 5);
922
- },
923
- 'decorate field getter'() {
924
- class Plus1 extends $.$mol_wrapper {
925
- static wrap(task) {
926
- return function (...args) {
927
- return Plus1.last = (task.call(this, ...args) || 0) + 1;
928
- };
929
- }
930
- }
931
- Plus1.last = 0;
932
- class Foo {
933
- static get two() {
934
- return 1;
935
- }
936
- static set two(next) { }
937
- }
938
- __decorate([
939
- Plus1.field
940
- ], Foo, "two", null);
941
- $.$mol_assert_equal(Foo.two, 2);
942
- Foo.two = 3;
943
- $.$mol_assert_equal(Plus1.last, 2);
944
- $.$mol_assert_equal(Foo.two, 2);
945
- },
946
- 'decorate instance method'() {
947
- class Plus1 extends $.$mol_wrapper {
948
- static wrap(task) {
949
- return function (...args) {
950
- return task.call(this, ...args) + 1;
951
- };
952
- }
953
- }
954
- class Foo1 {
955
- constructor() {
956
- this.level = 2;
957
- }
958
- pow(a) {
959
- return a ** this.level;
960
- }
961
- }
962
- __decorate([
963
- Plus1.method
964
- ], Foo1.prototype, "pow", null);
965
- const Foo2 = Foo1;
966
- const foo = new Foo2;
967
- $.$mol_assert_equal(foo.pow(2), 5);
968
- },
969
- 'decorate static method'() {
970
- class Plus1 extends $.$mol_wrapper {
971
- static wrap(task) {
972
- return function (...args) {
973
- return task.call(this, ...args) + 1;
974
- };
975
- }
976
- }
977
- class Foo {
978
- static pow(a) {
979
- return a ** this.level;
980
- }
981
- }
982
- Foo.level = 2;
983
- __decorate([
984
- Plus1.method
985
- ], Foo, "pow", null);
986
- $.$mol_assert_equal(Foo.pow(2), 5);
987
- },
988
- 'decorate class'() {
989
- class BarInc extends $.$mol_wrapper {
990
- static wrap(task) {
991
- return function (...args) {
992
- const foo = task.call(this, ...args);
993
- foo.bar++;
994
- return foo;
995
- };
996
- }
997
- }
998
- let Foo = class Foo {
999
- constructor(bar) {
1000
- this.bar = bar;
1001
- }
1002
- };
1003
- Foo = __decorate([
1004
- BarInc.class
1005
- ], Foo);
1006
- $.$mol_assert_equal(new Foo(2).bar, 3);
1007
- },
1008
- });
1009
- })($ || ($ = {}));
1010
- //wrapper.test.js.map
493
+ "use strict";
494
+ var $;
495
+ (function ($) {
496
+ $.$mol_compare_deep_cache = new WeakMap();
497
+ function $mol_compare_deep(left, right) {
498
+ if (Object.is(left, right))
499
+ return true;
500
+ if (left === null)
501
+ return false;
502
+ if (right === null)
503
+ return false;
504
+ if (typeof left !== 'object')
505
+ return false;
506
+ if (typeof right !== 'object')
507
+ return false;
508
+ const left_proto = Reflect.getPrototypeOf(left);
509
+ const right_proto = Reflect.getPrototypeOf(right);
510
+ if (left_proto !== right_proto)
511
+ return false;
512
+ if (left instanceof Boolean)
513
+ return Object.is(left.valueOf(), right['valueOf']());
514
+ if (left instanceof Number)
515
+ return Object.is(left.valueOf(), right['valueOf']());
516
+ if (left instanceof String)
517
+ return Object.is(left.valueOf(), right['valueOf']());
518
+ if (left instanceof Date)
519
+ return Object.is(left.valueOf(), right['valueOf']());
520
+ if (left instanceof RegExp)
521
+ return left.source === right['source'] && left.flags === right['flags'];
522
+ if (left instanceof Error)
523
+ return left.stack === right['stack'];
524
+ let left_cache = $.$mol_compare_deep_cache.get(left);
525
+ if (left_cache) {
526
+ const right_cache = left_cache.get(right);
527
+ if (typeof right_cache === 'boolean')
528
+ return right_cache;
529
+ }
530
+ else {
531
+ left_cache = new WeakMap([[right, true]]);
532
+ $.$mol_compare_deep_cache.set(left, left_cache);
533
+ }
534
+ let result;
535
+ try {
536
+ if (left_proto && !Reflect.getPrototypeOf(left_proto))
537
+ result = compare_pojo(left, right);
538
+ else if (Array.isArray(left))
539
+ result = compare_array(left, right);
540
+ else if (left instanceof Set)
541
+ result = compare_set(left, right);
542
+ else if (left instanceof Map)
543
+ result = compare_map(left, right);
544
+ else if (ArrayBuffer.isView(left))
545
+ result = compare_buffer(left, right);
546
+ else if (Symbol.toPrimitive in left)
547
+ result = compare_primitive(left, right);
548
+ else
549
+ result = false;
550
+ }
551
+ finally {
552
+ left_cache.set(right, result);
553
+ }
554
+ return result;
555
+ }
556
+ $.$mol_compare_deep = $mol_compare_deep;
557
+ function compare_array(left, right) {
558
+ const len = left.length;
559
+ if (len !== right.length)
560
+ return false;
561
+ for (let i = 0; i < len; ++i) {
562
+ if (!$mol_compare_deep(left[i], right[i]))
563
+ return false;
564
+ }
565
+ return true;
566
+ }
567
+ function compare_buffer(left, right) {
568
+ const len = left.byteLength;
569
+ if (len !== right.byteLength)
570
+ return false;
571
+ for (let i = 0; i < len; ++i) {
572
+ if (left[i] !== right[i])
573
+ return false;
574
+ }
575
+ return true;
576
+ }
577
+ function compare_iterator(left, right, compare) {
578
+ while (true) {
579
+ const left_next = left.next();
580
+ const right_next = right.next();
581
+ if (left_next.done !== right_next.done)
582
+ return false;
583
+ if (left_next.done)
584
+ break;
585
+ if (!compare(left_next.value, right_next.value))
586
+ return false;
587
+ }
588
+ return true;
589
+ }
590
+ function compare_set(left, right) {
591
+ if (left.size !== right.size)
592
+ return false;
593
+ return compare_iterator(left.values(), right.values(), $mol_compare_deep);
594
+ }
595
+ function compare_map(left, right) {
596
+ if (left.size !== right.size)
597
+ return false;
598
+ return compare_iterator(left.keys(), right.keys(), Object.is)
599
+ && compare_iterator(left.values(), right.values(), $mol_compare_deep);
600
+ }
601
+ function compare_pojo(left, right) {
602
+ const left_keys = Object.getOwnPropertyNames(left);
603
+ const right_keys = Object.getOwnPropertyNames(right);
604
+ if (left_keys.length !== right_keys.length)
605
+ return false;
606
+ for (let key of left_keys) {
607
+ if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
608
+ return false;
609
+ }
610
+ return true;
611
+ }
612
+ function compare_primitive(left, right) {
613
+ return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
614
+ }
615
+ })($ || ($ = {}));
616
+ //mol/compare/deep/deep.ts
1011
617
  ;
1012
- "use strict";
1013
- var $;
1014
- (function ($) {
1015
- class $mol_wrapper extends $.$mol_object2 {
1016
- static run(task) {
1017
- return this.func(task)();
1018
- }
1019
- static func(func) {
1020
- return this.wrap(func);
1021
- }
1022
- static get class() {
1023
- return (Class) => {
1024
- const construct = (target, args) => new Class(...args);
1025
- const handler = {
1026
- construct: this.func(construct)
1027
- };
1028
- handler[Symbol.toStringTag] = Class.name + '#';
1029
- return new Proxy(Class, handler);
1030
- };
1031
- }
1032
- static get method() {
1033
- return (obj, name, descr) => {
1034
- descr.value = this.func(descr.value);
1035
- return descr;
1036
- };
1037
- }
1038
- static get field() {
1039
- return (obj, name, descr) => {
1040
- descr.get = descr.set = this.func(descr.get);
1041
- return descr;
1042
- };
1043
- }
1044
- }
1045
- $.$mol_wrapper = $mol_wrapper;
1046
- })($ || ($ = {}));
1047
- //wrapper.js.map
618
+ "use strict";
619
+ var $;
620
+ (function ($) {
621
+ function $mol_dom_serialize(node) {
622
+ const serializer = new $mol_dom_context.XMLSerializer;
623
+ return serializer.serializeToString(node);
624
+ }
625
+ $.$mol_dom_serialize = $mol_dom_serialize;
626
+ })($ || ($ = {}));
627
+ //mol/dom/serialize/serialize.ts
1048
628
  ;
1049
- "use strict";
1050
- var $;
1051
- (function ($) {
1052
- $.$mol_after_mock_queue = [];
1053
- function $mol_after_mock_warp() {
1054
- const queue = $.$mol_after_mock_queue.splice(0);
1055
- for (const task of queue)
1056
- task();
1057
- }
1058
- $.$mol_after_mock_warp = $mol_after_mock_warp;
1059
- class $mol_after_mock_commmon extends $.$mol_object2 {
1060
- constructor(task) {
1061
- super();
1062
- this.task = task;
1063
- this.promise = Promise.resolve();
1064
- this.cancelled = false;
1065
- $.$mol_after_mock_queue.push(task);
1066
- }
1067
- destructor() {
1068
- const index = $.$mol_after_mock_queue.indexOf(this.task);
1069
- if (index >= 0)
1070
- $.$mol_after_mock_queue.splice(index, 1);
1071
- }
1072
- }
1073
- $.$mol_after_mock_commmon = $mol_after_mock_commmon;
1074
- class $mol_after_mock_timeout extends $mol_after_mock_commmon {
1075
- constructor(delay, task) {
1076
- super(task);
1077
- this.delay = delay;
1078
- }
1079
- }
1080
- $.$mol_after_mock_timeout = $mol_after_mock_timeout;
1081
- })($ || ($ = {}));
1082
- //mock.test.js.map
629
+ "use strict";
630
+ var $;
631
+ (function ($) {
632
+ $mol_test({
633
+ 'must be false'() {
634
+ $mol_assert_not(0);
635
+ },
636
+ 'must be true'() {
637
+ $mol_assert_ok(1);
638
+ },
639
+ 'two must be equal'() {
640
+ $mol_assert_equal(2, 2);
641
+ },
642
+ 'three must be equal'() {
643
+ $mol_assert_equal(2, 2, 2);
644
+ },
645
+ 'two must be unique'() {
646
+ $mol_assert_unique([3], [3]);
647
+ },
648
+ 'three must be unique'() {
649
+ $mol_assert_unique([3], [3], [3]);
650
+ },
651
+ 'two must be alike'() {
652
+ $mol_assert_like([3], [3]);
653
+ },
654
+ 'three must be alike'() {
655
+ $mol_assert_like([3], [3], [3]);
656
+ },
657
+ });
658
+ })($ || ($ = {}));
659
+ //mol/assert/assert.test.ts
1083
660
  ;
1084
- "use strict";
1085
- var $;
1086
- (function ($_1) {
1087
- $_1.$mol_test_mocks.push($ => {
1088
- $.$mol_after_frame = $_1.$mol_after_mock_commmon;
1089
- });
1090
- })($ || ($ = {}));
1091
- //frame.test.js.map
661
+ "use strict";
662
+ var $;
663
+ (function ($) {
664
+ function $mol_assert_ok(value) {
665
+ if (value)
666
+ return;
667
+ $mol_fail(new Error(`${value} true`));
668
+ }
669
+ $.$mol_assert_ok = $mol_assert_ok;
670
+ function $mol_assert_not(value) {
671
+ if (!value)
672
+ return;
673
+ $mol_fail(new Error(`${value} ≠ false`));
674
+ }
675
+ $.$mol_assert_not = $mol_assert_not;
676
+ function $mol_assert_fail(handler, ErrorRight) {
677
+ const fail = $.$mol_fail;
678
+ try {
679
+ $.$mol_fail = $.$mol_fail_hidden;
680
+ handler();
681
+ }
682
+ catch (error) {
683
+ if (!ErrorRight)
684
+ return error;
685
+ $.$mol_fail = fail;
686
+ if (typeof ErrorRight === 'string') {
687
+ $mol_assert_equal(error.message, ErrorRight);
688
+ }
689
+ else {
690
+ $mol_assert_ok(error instanceof ErrorRight);
691
+ }
692
+ return error;
693
+ }
694
+ finally {
695
+ $.$mol_fail = fail;
696
+ }
697
+ $mol_fail(new Error('Not failed'));
698
+ }
699
+ $.$mol_assert_fail = $mol_assert_fail;
700
+ function $mol_assert_equal(...args) {
701
+ for (let i = 0; i < args.length; ++i) {
702
+ for (let j = 0; j < args.length; ++j) {
703
+ if (i === j)
704
+ continue;
705
+ if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
706
+ continue;
707
+ if (args[i] !== args[j])
708
+ $mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
709
+ }
710
+ }
711
+ }
712
+ $.$mol_assert_equal = $mol_assert_equal;
713
+ function $mol_assert_unique(...args) {
714
+ for (let i = 0; i < args.length; ++i) {
715
+ for (let j = 0; j < args.length; ++j) {
716
+ if (i === j)
717
+ continue;
718
+ if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
719
+ $mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
720
+ }
721
+ }
722
+ }
723
+ }
724
+ $.$mol_assert_unique = $mol_assert_unique;
725
+ function $mol_assert_like(head, ...tail) {
726
+ for (let [index, value] of Object.entries(tail)) {
727
+ if (!$mol_compare_deep(value, head)) {
728
+ const print = (val) => {
729
+ if (!val)
730
+ return val;
731
+ if (typeof val !== 'object')
732
+ return val;
733
+ if ('outerHTML' in val)
734
+ return val.outerHTML;
735
+ try {
736
+ return JSON.stringify(val);
737
+ }
738
+ catch (error) {
739
+ console.error(error);
740
+ return val;
741
+ }
742
+ };
743
+ return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
744
+ }
745
+ }
746
+ }
747
+ $.$mol_assert_like = $mol_assert_like;
748
+ function $mol_assert_dom(left, right) {
749
+ $mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
750
+ }
751
+ $.$mol_assert_dom = $mol_assert_dom;
752
+ })($ || ($ = {}));
753
+ //mol/assert/assert.ts
1092
754
  ;
1093
- "use strict";
1094
- var $;
1095
- (function ($) {
1096
- class $mol_after_frame extends $.$mol_object2 {
1097
- constructor(task) {
1098
- super();
1099
- this.task = task;
1100
- this.cancelled = false;
1101
- this.promise = $mol_after_frame.promise.then(() => {
1102
- if (this.cancelled)
1103
- return;
1104
- task();
1105
- });
1106
- }
1107
- static get promise() {
1108
- if (this._promise)
1109
- return this._promise;
1110
- return this._promise = new Promise(done => requestAnimationFrame(() => {
1111
- this._promise = null;
1112
- done();
1113
- }));
1114
- }
1115
- destructor() {
1116
- this.cancelled = true;
1117
- }
1118
- }
1119
- $mol_after_frame._promise = null;
1120
- $.$mol_after_frame = $mol_after_frame;
1121
- })($ || ($ = {}));
1122
- //frame.web.js.map
755
+ "use strict";
756
+ var $;
757
+ (function ($) {
758
+ $mol_test({
759
+ 'get'() {
760
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
761
+ $mol_assert_equal(proxy.foo, 777);
762
+ },
763
+ 'has'() {
764
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
765
+ $mol_assert_equal('foo' in proxy, true);
766
+ },
767
+ 'set'() {
768
+ const target = { foo: 777 };
769
+ const proxy = $mol_delegate({}, () => target);
770
+ proxy.foo = 123;
771
+ $mol_assert_equal(target.foo, 123);
772
+ },
773
+ 'getOwnPropertyDescriptor'() {
774
+ const proxy = $mol_delegate({}, () => ({ foo: 777 }));
775
+ $mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
776
+ value: 777,
777
+ writable: true,
778
+ enumerable: true,
779
+ configurable: true,
780
+ });
781
+ },
782
+ 'ownKeys'() {
783
+ const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
784
+ $mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
785
+ },
786
+ 'getPrototypeOf'() {
787
+ class Foo {
788
+ }
789
+ const proxy = $mol_delegate({}, () => new Foo);
790
+ $mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
791
+ },
792
+ 'setPrototypeOf'() {
793
+ class Foo {
794
+ }
795
+ const target = {};
796
+ const proxy = $mol_delegate({}, () => target);
797
+ Object.setPrototypeOf(proxy, Foo.prototype);
798
+ $mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
799
+ },
800
+ 'instanceof'() {
801
+ class Foo {
802
+ }
803
+ const proxy = $mol_delegate({}, () => new Foo);
804
+ $mol_assert_ok(proxy instanceof Foo);
805
+ $mol_assert_ok(proxy instanceof $mol_delegate);
806
+ },
807
+ 'autobind'() {
808
+ class Foo {
809
+ }
810
+ const proxy = $mol_delegate({}, () => new Foo);
811
+ $mol_assert_ok(proxy instanceof Foo);
812
+ $mol_assert_ok(proxy instanceof $mol_delegate);
813
+ },
814
+ });
815
+ })($ || ($ = {}));
816
+ //mol/delegate/delegate.test.ts
1123
817
  ;
1124
- "use strict";
1125
- var $;
1126
- (function ($) {
1127
- $.$mol_test({
1128
- 'objects by reference'() {
1129
- $.$mol_assert_equal($.$mol_compare_any({}, {}), false);
1130
- },
1131
- 'primitives by value'() {
1132
- $.$mol_assert_equal($.$mol_compare_any('a', 'a'), true);
1133
- },
1134
- 'NaN by value'() {
1135
- $.$mol_assert_equal($.$mol_compare_any(Number.NaN, Number.NaN), true);
1136
- },
1137
- 'NaN not equal zero'() {
1138
- $.$mol_assert_equal($.$mol_compare_any(Number.NaN, 0), false);
1139
- },
1140
- });
1141
- })($ || ($ = {}));
1142
- //any.test.js.map
818
+ "use strict";
819
+ //mol/type/writable/writable.test.ts
1143
820
  ;
1144
- "use strict";
1145
- var $;
1146
- (function ($) {
1147
- function $mol_compare_any(a, b) {
1148
- if (a === b)
1149
- return true;
1150
- if (!Number.isNaN(a))
1151
- return false;
1152
- if (!Number.isNaN(b))
1153
- return false;
1154
- return true;
1155
- }
1156
- $.$mol_compare_any = $mol_compare_any;
1157
- })($ || ($ = {}));
1158
- //any.js.map
821
+ "use strict";
822
+ var $;
823
+ (function ($_1) {
824
+ $mol_test({
825
+ 'span for same uri'($) {
826
+ const span = new $mol_span('test.ts', '', 1, 3, 4);
827
+ const child = span.span(4, 5, 8);
828
+ $mol_assert_equal(child.uri, 'test.ts');
829
+ $mol_assert_equal(child.row, 4);
830
+ $mol_assert_equal(child.col, 5);
831
+ $mol_assert_equal(child.length, 8);
832
+ },
833
+ 'span after of given position'($) {
834
+ const span = new $mol_span('test.ts', '', 1, 3, 4);
835
+ const child = span.after(11);
836
+ $mol_assert_equal(child.uri, 'test.ts');
837
+ $mol_assert_equal(child.row, 1);
838
+ $mol_assert_equal(child.col, 7);
839
+ $mol_assert_equal(child.length, 11);
840
+ },
841
+ 'slice span - regular'($) {
842
+ const span = new $mol_span('test.ts', '', 1, 3, 5);
843
+ const child = span.slice(1, 4);
844
+ $mol_assert_equal(child.row, 1);
845
+ $mol_assert_equal(child.col, 4);
846
+ $mol_assert_equal(child.length, 3);
847
+ const child2 = span.slice(2, 2);
848
+ $mol_assert_equal(child2.col, 5);
849
+ $mol_assert_equal(child2.length, 0);
850
+ },
851
+ 'slice span - negative'($) {
852
+ const span = new $mol_span('test.ts', '', 1, 3, 5);
853
+ const child = span.slice(-3, -1);
854
+ $mol_assert_equal(child.row, 1);
855
+ $mol_assert_equal(child.col, 5);
856
+ $mol_assert_equal(child.length, 2);
857
+ },
858
+ 'slice span - out of range'($) {
859
+ const span = new $mol_span('test.ts', '', 1, 3, 5);
860
+ $mol_assert_fail(() => span.slice(-1, 3));
861
+ $mol_assert_fail(() => span.slice(1, 6));
862
+ $mol_assert_fail(() => span.slice(1, 10));
863
+ },
864
+ 'error handling'($) {
865
+ const span = new $mol_span('test.ts', '', 1, 3, 4);
866
+ const error = span.error('Some error\n');
867
+ $mol_assert_equal(error.message, 'Some error\ntest.ts#1:3/4');
868
+ }
869
+ });
870
+ })($ || ($ = {}));
871
+ //mol/span/span.test.ts
1159
872
  ;
1160
- "use strict";
1161
- var $;
1162
- (function ($) {
1163
- $.$mol_test({
1164
- 'return source when same object'() {
1165
- const target = {};
1166
- $.$mol_assert_equal($.$mol_conform(target, target), target);
1167
- },
1168
- 'return target when some is not object'() {
1169
- const obj = { a: 1 };
1170
- $.$mol_assert_equal($.$mol_conform(true, obj), true);
1171
- $.$mol_assert_equal($.$mol_conform(obj, true), obj);
1172
- },
1173
- 'return target when some is null'() {
1174
- const obj = { a: 1 };
1175
- $.$mol_assert_equal($.$mol_conform(null, obj), null);
1176
- $.$mol_assert_equal($.$mol_conform(obj, null), obj);
1177
- },
1178
- 'return target when some is undefined'() {
1179
- const obj = { a: 1 };
1180
- $.$mol_assert_equal($.$mol_conform(undefined, obj), undefined);
1181
- $.$mol_assert_equal($.$mol_conform(obj, undefined), obj);
1182
- },
1183
- 'return target when different keys count'() {
1184
- const target = [1, 2, 3];
1185
- const source = [1, 2, 3, undefined];
1186
- const result = $.$mol_conform(target, source);
1187
- $.$mol_assert_equal(result, target);
1188
- $.$mol_assert_equal(result.join(','), '1,2,3');
1189
- },
1190
- 'return source when array values are strong equal'() {
1191
- const source = [1, 2, 3];
1192
- $.$mol_assert_equal($.$mol_conform([1, 2, 3], source), source);
1193
- },
1194
- 'return source when object values are strong equal'() {
1195
- const source = { a: 1, b: 2 };
1196
- $.$mol_assert_equal($.$mol_conform({ a: 1, b: 2 }, source), source);
1197
- },
1198
- 'return target when some values are not equal'() {
1199
- const target = [1, 2, 3];
1200
- const source = [1, 2, 5];
1201
- const result = $.$mol_conform(target, source);
1202
- $.$mol_assert_equal(result, target);
1203
- $.$mol_assert_equal(result.join(','), '1,2,3');
1204
- },
1205
- 'return source when values are deep equal'() {
1206
- const source = { foo: { bar: 1 } };
1207
- $.$mol_assert_equal($.$mol_conform({ foo: { bar: 1 } }, source), source);
1208
- },
1209
- 'return target with equal values from source and not equal from target'() {
1210
- const source = { foo: { xxx: 1 }, bar: { xxx: 2 } };
1211
- const target = { foo: { xxx: 1 }, bar: { xxx: 3 } };
1212
- const result = $.$mol_conform(target, source);
1213
- $.$mol_assert_equal(result, target);
1214
- $.$mol_assert_equal(result.foo, source.foo);
1215
- $.$mol_assert_equal(result.bar, target.bar);
1216
- },
1217
- 'return target when equal but with different class'() {
1218
- const target = { '0': 1 };
1219
- $.$mol_assert_equal($.$mol_conform(target, [1]), target);
1220
- },
1221
- 'return target when conformer for class is not defined'() {
1222
- const Obj = class {
1223
- };
1224
- const source = new Obj;
1225
- const target = new Obj;
1226
- const result = $.$mol_conform(target, source);
1227
- $.$mol_assert_equal(result, target);
1228
- },
1229
- 'return target when has cyclic reference'() {
1230
- const source = { foo: {} };
1231
- source['self'] = source;
1232
- const target = { foo: {} };
1233
- target['self'] = target;
1234
- const result = $.$mol_conform(target, source);
1235
- $.$mol_assert_equal(result, target);
1236
- $.$mol_assert_equal(result['self'], target);
1237
- $.$mol_assert_equal(result.foo, source.foo);
1238
- },
1239
- 'return source when equal dates'() {
1240
- const source = new Date(12345);
1241
- const target = new Date(12345);
1242
- const result = $.$mol_conform(target, source);
1243
- $.$mol_assert_equal(result, source);
1244
- },
1245
- 'return source when equal regular expressions'() {
1246
- const source = /\x22/mig;
1247
- const target = /\x22/mig;
1248
- const result = $.$mol_conform(target, source);
1249
- $.$mol_assert_equal(result, source);
1250
- },
1251
- 'return cached value if already conformed'() {
1252
- const source = { foo: { xxx: 1 }, bar: { xxx: 3 } };
1253
- const target = { foo: { xxx: 2 }, bar: { xxx: 3 } };
1254
- const result = $.$mol_conform(target, source);
1255
- target.foo.xxx = 1;
1256
- $.$mol_assert_equal($.$mol_conform(target.foo, source.foo), target.foo);
1257
- },
1258
- 'skip readlony fields'() {
1259
- const source = { foo: {}, bar: {} };
1260
- const target = { foo: {}, bar: {} };
1261
- Object.defineProperty(target, 'bar', { value: {}, writable: false });
1262
- const result = $.$mol_conform(target, source);
1263
- $.$mol_assert_equal(result, target);
1264
- $.$mol_assert_equal(result.foo, source.foo);
1265
- $.$mol_assert_equal(result.bar, target.bar);
1266
- },
1267
- 'object with NaN'() {
1268
- const source = { foo: Number.NaN };
1269
- const target = { foo: Number.NaN };
1270
- const result = $.$mol_conform(target, source);
1271
- $.$mol_assert_equal(result, source);
1272
- },
1273
- 'array with NaN'() {
1274
- const source = [Number.NaN];
1275
- const target = [Number.NaN];
1276
- const result = $.$mol_conform(target, source);
1277
- $.$mol_assert_equal(result, source);
1278
- },
1279
- });
1280
- })($ || ($ = {}));
1281
- //conform.test.js.map
873
+ "use strict";
874
+ var $;
875
+ (function ($_1) {
876
+ $mol_test({
877
+ 'tree parsing'($) {
878
+ $mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
879
+ $mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
880
+ $mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
881
+ $mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
882
+ $mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
883
+ $mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
884
+ $mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
885
+ $mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
886
+ },
887
+ 'Too many tabs'($) {
888
+ const tree = `
889
+ foo
890
+ bar
891
+ `;
892
+ $mol_assert_fail(() => {
893
+ $.$mol_tree2_from_string(tree, 'test');
894
+ }, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
895
+ },
896
+ 'Too few tabs'($) {
897
+ const tree = `
898
+ foo
899
+ bar
900
+ `;
901
+ $mol_assert_fail(() => {
902
+ $.$mol_tree2_from_string(tree, 'test');
903
+ }, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
904
+ },
905
+ 'Wrong nodes separator'($) {
906
+ const tree = `foo bar\n`;
907
+ $mol_assert_fail(() => {
908
+ $.$mol_tree2_from_string(tree, 'test');
909
+ }, 'Wrong nodes separator\ntest#1:4/2\n !!\nfoo bar');
910
+ },
911
+ 'Undexpected EOF, LF required'($) {
912
+ const tree = ` foo`;
913
+ $mol_assert_fail(() => {
914
+ $.$mol_tree2_from_string(tree, 'test');
915
+ }, 'Undexpected EOF, LF required\ntest#1:5/1\n !\n foo');
916
+ },
917
+ 'Errors skip and collect'($) {
918
+ const tree = `foo bar`;
919
+ const errors = [];
920
+ const $$ = $.$mol_ambient({
921
+ $mol_fail: (error) => {
922
+ errors.push(error.message);
923
+ return null;
924
+ }
925
+ });
926
+ const res = $$.$mol_tree2_from_string(tree, 'test');
927
+ $mol_assert_like(errors, [
928
+ 'Wrong nodes separator\ntest#1:4/2\n !!\nfoo bar',
929
+ 'Undexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
930
+ ]);
931
+ $mol_assert_equal(res.toString(), 'foo bar\n');
932
+ },
933
+ });
934
+ })($ || ($ = {}));
935
+ //mol/tree2/from/string/string.test.ts
1282
936
  ;
1283
- "use strict";
1284
- var $;
1285
- (function ($) {
1286
- const cache = new WeakMap();
1287
- $.$mol_conform_stack = [];
1288
- function $mol_conform(target, source) {
1289
- if ($.$mol_compare_any(target, source))
1290
- return source;
1291
- if (!target || typeof target !== 'object')
1292
- return target;
1293
- if (!source || typeof source !== 'object')
1294
- return target;
1295
- if (target instanceof Error)
1296
- return target;
1297
- if (source instanceof Error)
1298
- return target;
1299
- if (target['constructor'] !== source['constructor'])
1300
- return target;
1301
- if (cache.get(target))
1302
- return target;
1303
- cache.set(target, true);
1304
- const conform = $.$mol_conform_handlers.get(target['constructor']);
1305
- if (!conform)
1306
- return target;
1307
- if ($.$mol_conform_stack.indexOf(target) !== -1)
1308
- return target;
1309
- $.$mol_conform_stack.push(target);
1310
- try {
1311
- return conform(target, source);
1312
- }
1313
- finally {
1314
- $.$mol_conform_stack.pop();
1315
- }
1316
- }
1317
- $.$mol_conform = $mol_conform;
1318
- $.$mol_conform_handlers = new WeakMap();
1319
- function $mol_conform_handler(cl, handler) {
1320
- $.$mol_conform_handlers.set(cl, handler);
1321
- }
1322
- $.$mol_conform_handler = $mol_conform_handler;
1323
- function $mol_conform_array(target, source) {
1324
- if (source.length !== target.length)
1325
- return target;
1326
- for (let i = 0; i < target.length; ++i) {
1327
- if (!$.$mol_compare_any(source[i], target[i]))
1328
- return target;
1329
- }
1330
- return source;
1331
- }
1332
- $.$mol_conform_array = $mol_conform_array;
1333
- $mol_conform_handler(Array, $mol_conform_array);
1334
- $mol_conform_handler(Uint8Array, $mol_conform_array);
1335
- $mol_conform_handler(Uint16Array, $mol_conform_array);
1336
- $mol_conform_handler(Uint32Array, $mol_conform_array);
1337
- $mol_conform_handler(({})['constructor'], (target, source) => {
1338
- let count = 0;
1339
- let equal = true;
1340
- for (let key in target) {
1341
- const conformed = $mol_conform(target[key], source[key]);
1342
- if (conformed !== target[key]) {
1343
- try {
1344
- target[key] = conformed;
1345
- }
1346
- catch (error) { }
1347
- if (!$.$mol_compare_any(conformed, target[key]))
1348
- equal = false;
1349
- }
1350
- if (!$.$mol_compare_any(conformed, source[key]))
1351
- equal = false;
1352
- ++count;
1353
- }
1354
- for (let key in source)
1355
- if (--count < 0)
1356
- break;
1357
- return (equal && count === 0) ? source : target;
1358
- });
1359
- $mol_conform_handler(Date, (target, source) => {
1360
- if (target.getTime() === source.getTime())
1361
- return source;
1362
- return target;
1363
- });
1364
- $mol_conform_handler(RegExp, (target, source) => {
1365
- if (target.toString() === source.toString())
1366
- return source;
1367
- return target;
1368
- });
1369
- })($ || ($ = {}));
1370
- //conform.js.map
937
+ "use strict";
938
+ var $;
939
+ (function ($) {
940
+ function $mol_log3_area_lazy(event) {
941
+ const self = this;
942
+ const stack = self.$mol_log3_stack;
943
+ const deep = stack.length;
944
+ let logged = false;
945
+ stack.push(() => {
946
+ logged = true;
947
+ self.$mol_log3_area.call(self, event);
948
+ });
949
+ return () => {
950
+ if (logged)
951
+ self.console.groupEnd();
952
+ if (stack.length > deep)
953
+ stack.length = deep;
954
+ };
955
+ }
956
+ $.$mol_log3_area_lazy = $mol_log3_area_lazy;
957
+ $.$mol_log3_stack = [];
958
+ })($ || ($ = {}));
959
+ //mol/log3/log3.ts
1371
960
  ;
1372
- "use strict";
1373
- var $;
1374
- (function ($) {
1375
- $.$mol_test({
1376
- 'trim array'() {
1377
- const array = [undefined, null, 0, false, null, undefined, undefined];
1378
- const correct = [undefined, null, 0, false, null];
1379
- $.$mol_array_trim(array);
1380
- $.$mol_assert_like(array, correct);
1381
- }
1382
- });
1383
- })($ || ($ = {}));
1384
- //trim.test.js.map
961
+ "use strict";
962
+ //mol/type/keys/extract/extract.test.ts
1385
963
  ;
1386
- "use strict";
1387
- var $;
1388
- (function ($) {
1389
- function $mol_array_trim(array) {
1390
- let last = array.length;
1391
- while (last > 0) {
1392
- --last;
1393
- const value = array[last];
1394
- if (value === undefined)
1395
- array.pop();
1396
- else
1397
- break;
1398
- }
1399
- return array;
1400
- }
1401
- $.$mol_array_trim = $mol_array_trim;
1402
- })($ || ($ = {}));
1403
- //trim.js.map
964
+ "use strict";
965
+ //mol/type/keys/extract/extract.ts
1404
966
  ;
1405
- "use strict";
1406
- var $;
1407
- (function ($) {
1408
- $['devtoolsFormatters'] = $['devtoolsFormatters'] || [];
1409
- function $mol_dev_format_register(config) {
1410
- $['devtoolsFormatters'].push(config);
1411
- }
1412
- $.$mol_dev_format_register = $mol_dev_format_register;
1413
- $.$mol_dev_format_head = Symbol('$mol_dev_format_head');
1414
- $.$mol_dev_format_body = Symbol('$mol_dev_format_body');
1415
- $mol_dev_format_register({
1416
- header: (val, config = false) => {
1417
- if (config)
1418
- return null;
1419
- if (!val)
1420
- return null;
1421
- if ($.$mol_dev_format_head in val) {
1422
- return val[$.$mol_dev_format_head]();
1423
- }
1424
- return null;
1425
- },
1426
- hasBody: val => val[$.$mol_dev_format_body],
1427
- body: val => val[$.$mol_dev_format_body](),
1428
- });
1429
- function $mol_dev_format_native(obj) {
1430
- if (typeof obj === 'undefined')
1431
- return $.$mol_dev_format_shade('undefined');
1432
- if (typeof obj !== 'object')
1433
- return obj;
1434
- return [
1435
- 'object',
1436
- {
1437
- object: obj,
1438
- config: true,
1439
- },
1440
- ];
1441
- }
1442
- $.$mol_dev_format_native = $mol_dev_format_native;
1443
- function $mol_dev_format_auto(obj) {
1444
- if (obj == null)
1445
- return $.$mol_dev_format_shade(String(obj));
1446
- if (typeof obj === 'object' && $.$mol_dev_format_head in obj) {
1447
- return obj[$.$mol_dev_format_head]();
1448
- }
1449
- return [
1450
- 'object',
1451
- {
1452
- object: obj,
1453
- config: false,
1454
- },
1455
- ];
1456
- }
1457
- $.$mol_dev_format_auto = $mol_dev_format_auto;
1458
- function $mol_dev_format_element(element, style, ...content) {
1459
- const styles = [];
1460
- for (let key in style)
1461
- styles.push(`${key} : ${style[key]}`);
1462
- return [
1463
- element,
1464
- {
1465
- style: styles.join(' ; '),
1466
- },
1467
- ...content,
1468
- ];
1469
- }
1470
- $.$mol_dev_format_element = $mol_dev_format_element;
1471
- function $mol_dev_format_span(style, ...content) {
1472
- return $mol_dev_format_element('span', Object.assign({ 'vertical-align': '8%' }, style), ...content);
1473
- }
1474
- $.$mol_dev_format_span = $mol_dev_format_span;
1475
- $.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
1476
- $.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
1477
- $.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
1478
- $.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
1479
- $.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
1480
- $.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
1481
- $.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
1482
- 'color': 'magenta',
1483
- });
1484
- $.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
1485
- 'font-weight': 'bold',
1486
- });
1487
- $.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
1488
- 'color': 'green',
1489
- });
1490
- $.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
1491
- 'color': 'gray',
1492
- });
1493
- $.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
1494
- 'margin-left': '13px'
1495
- });
1496
- })($ || ($ = {}));
1497
- //format.js.map
967
+ "use strict";
968
+ var $;
969
+ (function ($_1) {
970
+ $mol_test_mocks.push($ => {
971
+ $.$mol_log3_come = () => { };
972
+ $.$mol_log3_done = () => { };
973
+ $.$mol_log3_fail = () => { };
974
+ $.$mol_log3_warn = () => { };
975
+ $.$mol_log3_rise = () => { };
976
+ $.$mol_log3_area = () => () => { };
977
+ });
978
+ })($ || ($ = {}));
979
+ //mol/log3/log3.test.ts
1498
980
  ;
1499
- "use strict";
1500
- var $;
1501
- (function ($_1) {
1502
- $_1.$mol_test_mocks.push(async ($) => {
1503
- await $_1.$mol_fiber_warp();
1504
- $_1.$mol_fiber.deadline = Date.now() + 100;
1505
- });
1506
- $_1.$mol_test({
1507
- 'sync to async': async ($) => {
1508
- const sum = $_1.$mol_fiber_async((a, b) => a + b);
1509
- const res = await sum(1, 2);
1510
- $_1.$mol_assert_equal(res, 3);
1511
- },
1512
- });
1513
- })($ || ($ = {}));
1514
- //fiber.test.js.map
981
+ "use strict";
982
+ var $;
983
+ (function ($) {
984
+ function $mol_log3_web_make(level, color) {
985
+ return function $mol_log3_logger(event) {
986
+ const pending = this.$mol_log3_stack.pop();
987
+ if (pending)
988
+ pending();
989
+ let tpl = '%c';
990
+ const chunks = Object.values(event);
991
+ for (let i = 0; i < chunks.length; ++i) {
992
+ tpl += (typeof chunks[i] === 'string') ? ' ⦙ %s' : ' ⦙ %o';
993
+ }
994
+ const style = `color:${color};font-weight:bolder`;
995
+ this.console[level](tpl, style, ...chunks);
996
+ const self = this;
997
+ return () => self.console.groupEnd();
998
+ };
999
+ }
1000
+ $.$mol_log3_web_make = $mol_log3_web_make;
1001
+ $.$mol_log3_come = $mol_log3_web_make('info', 'royalblue');
1002
+ $.$mol_log3_done = $mol_log3_web_make('info', 'forestgreen');
1003
+ $.$mol_log3_fail = $mol_log3_web_make('error', 'orangered');
1004
+ $.$mol_log3_warn = $mol_log3_web_make('warn', 'goldenrod');
1005
+ $.$mol_log3_rise = $mol_log3_web_make('log', 'magenta');
1006
+ $.$mol_log3_area = $mol_log3_web_make('group', 'cyan');
1007
+ })($ || ($ = {}));
1008
+ //mol/log3/log3.web.ts
1515
1009
  ;
1516
- "use strict";
1517
- var $;
1518
- (function ($) {
1519
- function $mol_fiber_defer(calculate) {
1520
- const fiber = new $mol_fiber;
1521
- fiber.calculate = calculate;
1522
- fiber[Symbol.toStringTag] = calculate.name;
1523
- fiber.schedule();
1524
- return fiber;
1525
- }
1526
- $.$mol_fiber_defer = $mol_fiber_defer;
1527
- function $mol_fiber_func(calculate) {
1528
- $.$mol_ambient({}).$mol_log3_warn({
1529
- place: '$mol_fiber_func',
1530
- message: 'Deprecated',
1531
- hint: 'Use $mol_fiber.func instead',
1532
- });
1533
- return $mol_fiber.func(calculate);
1534
- }
1535
- $.$mol_fiber_func = $mol_fiber_func;
1536
- function $mol_fiber_root(calculate) {
1537
- const wrapper = function (...args) {
1538
- const fiber = new $mol_fiber();
1539
- fiber.calculate = calculate.bind(this, ...args);
1540
- fiber[Symbol.toStringTag] = wrapper[Symbol.toStringTag];
1541
- return fiber.wake();
1542
- };
1543
- wrapper[Symbol.toStringTag] = calculate.name;
1544
- return wrapper;
1545
- }
1546
- $.$mol_fiber_root = $mol_fiber_root;
1547
- function $mol_fiber_method(obj, name, descr) {
1548
- $.$mol_ambient({}).$mol_log3_warn({
1549
- place: '$mol_fiber_method',
1550
- message: 'Deprecated',
1551
- hint: 'Use $mol_fiber.method instead',
1552
- });
1553
- return $mol_fiber.method(obj, name, descr);
1554
- }
1555
- $.$mol_fiber_method = $mol_fiber_method;
1556
- function $mol_fiber_async(task) {
1557
- return (...args) => new Promise($mol_fiber_root((done, fail) => {
1558
- try {
1559
- done(task(...args));
1560
- }
1561
- catch (error) {
1562
- if ('then' in error)
1563
- return $.$mol_fail_hidden(error);
1564
- fail(error);
1565
- }
1566
- }));
1567
- }
1568
- $.$mol_fiber_async = $mol_fiber_async;
1569
- function $mol_fiber_sync(request) {
1570
- return function $mol_fiber_sync_wrapper(...args) {
1571
- const slave = $mol_fiber.current;
1572
- let master = slave && slave.master;
1573
- if (!master || master.constructor !== $mol_fiber) {
1574
- master = new $mol_fiber;
1575
- master.cursor = -3;
1576
- master.error = request.call(this, ...args).then((next) => master.push(next), (error) => master.fail(error));
1577
- const prefix = slave ? `${slave}/${slave.cursor / 2}:` : '/';
1578
- master[Symbol.toStringTag] = prefix + (request.name || $mol_fiber_sync.name);
1579
- }
1580
- return master.get();
1581
- };
1582
- }
1583
- $.$mol_fiber_sync = $mol_fiber_sync;
1584
- async function $mol_fiber_warp() {
1585
- const deadline = $mol_fiber.deadline;
1586
- try {
1587
- $mol_fiber.deadline = Number.POSITIVE_INFINITY;
1588
- while ($mol_fiber.queue.length)
1589
- await $mol_fiber.tick();
1590
- return Promise.resolve();
1591
- }
1592
- finally {
1593
- $mol_fiber.deadline = deadline;
1594
- }
1595
- }
1596
- $.$mol_fiber_warp = $mol_fiber_warp;
1597
- function $mol_fiber_fence(func) {
1598
- const prev = $mol_fiber.current;
1599
- try {
1600
- $mol_fiber.current = null;
1601
- return func();
1602
- }
1603
- finally {
1604
- $mol_fiber.current = prev;
1605
- }
1606
- }
1607
- $.$mol_fiber_fence = $mol_fiber_fence;
1608
- function $mol_fiber_unlimit(task) {
1609
- const deadline = $mol_fiber.deadline;
1610
- try {
1611
- $mol_fiber.deadline = Number.POSITIVE_INFINITY;
1612
- return task();
1613
- }
1614
- finally {
1615
- $mol_fiber.deadline = deadline;
1616
- }
1617
- }
1618
- $.$mol_fiber_unlimit = $mol_fiber_unlimit;
1619
- class $mol_fiber_solid extends $.$mol_wrapper {
1620
- static func(task) {
1621
- function wrapped(...args) {
1622
- const deadline = $mol_fiber.deadline;
1623
- try {
1624
- $mol_fiber.deadline = Number.POSITIVE_INFINITY;
1625
- return task.call(this, ...args);
1626
- }
1627
- catch (error) {
1628
- if ('then' in error)
1629
- $.$mol_fail(new Error('Solid fiber can not be suspended.'));
1630
- return $.$mol_fail_hidden(error);
1631
- }
1632
- finally {
1633
- $mol_fiber.deadline = deadline;
1634
- }
1635
- }
1636
- return $mol_fiber.func(wrapped);
1637
- }
1638
- }
1639
- $.$mol_fiber_solid = $mol_fiber_solid;
1640
- class $mol_fiber extends $.$mol_wrapper {
1641
- constructor() {
1642
- super(...arguments);
1643
- this.cursor = 0;
1644
- this.masters = [];
1645
- this._value = undefined;
1646
- this._error = null;
1647
- }
1648
- static wrap(task) {
1649
- return function $mol_fiber_wrapper(...args) {
1650
- const slave = $mol_fiber.current;
1651
- let master = slave && slave.master;
1652
- if (!master || master.constructor !== $mol_fiber) {
1653
- master = new $mol_fiber;
1654
- master.calculate = task.bind(this, ...args);
1655
- const prefix = slave ? `${slave}/${slave.cursor / 2}:` : '/';
1656
- master[Symbol.toStringTag] = `${prefix}${task.name}`;
1657
- }
1658
- return master.get();
1659
- };
1660
- }
1661
- static async tick() {
1662
- while ($mol_fiber.queue.length > 0) {
1663
- const now = Date.now();
1664
- if (now >= $mol_fiber.deadline) {
1665
- $mol_fiber.schedule();
1666
- $mol_fiber.liveline = now;
1667
- return;
1668
- }
1669
- const task = $mol_fiber.queue.shift();
1670
- await task();
1671
- }
1672
- }
1673
- static schedule() {
1674
- if (!$mol_fiber.scheduled) {
1675
- $mol_fiber.scheduled = new $.$mol_after_frame(async () => {
1676
- const now = Date.now();
1677
- let quant = $mol_fiber.quant;
1678
- if ($mol_fiber.liveline) {
1679
- quant = Math.max(quant, Math.floor((now - $mol_fiber.liveline) / 2));
1680
- $mol_fiber.liveline = 0;
1681
- }
1682
- $mol_fiber.deadline = now + quant;
1683
- $mol_fiber.scheduled = null;
1684
- await $mol_fiber.tick();
1685
- });
1686
- }
1687
- const promise = new this.$.Promise(done => this.queue.push(() => (done(null), promise)));
1688
- return promise;
1689
- }
1690
- get value() { return this._value; }
1691
- set value(next) {
1692
- this._value = next;
1693
- }
1694
- get error() { return this._error; }
1695
- set error(next) {
1696
- this._error = next;
1697
- }
1698
- schedule() {
1699
- $mol_fiber.schedule().then(() => this.wake());
1700
- }
1701
- wake() {
1702
- const unscoupe = this.$.$mol_log3_area_lazy({
1703
- place: this,
1704
- message: 'Wake'
1705
- });
1706
- try {
1707
- if (this.cursor > -2)
1708
- return this.get();
1709
- }
1710
- catch (error) {
1711
- if ('then' in error)
1712
- return;
1713
- $.$mol_fail_hidden(error);
1714
- }
1715
- finally {
1716
- unscoupe();
1717
- }
1718
- }
1719
- push(value) {
1720
- value = this.$.$mol_conform(value, this.value);
1721
- if (this.error !== null || !Object.is(this.value, value)) {
1722
- if ($mol_fiber.logs)
1723
- this.$.$mol_log3_done({
1724
- place: this,
1725
- message: 'Changed',
1726
- next: value,
1727
- value: this.value,
1728
- error: this.error,
1729
- });
1730
- this.obsolete_slaves();
1731
- this.forget();
1732
- }
1733
- else {
1734
- if ($mol_fiber.logs)
1735
- this.$.$mol_log3_done({
1736
- place: this,
1737
- message: 'Same value',
1738
- value,
1739
- });
1740
- }
1741
- this.error = null;
1742
- this.value = value;
1743
- this.complete();
1744
- return value;
1745
- }
1746
- fail(error) {
1747
- this.complete();
1748
- if ($mol_fiber.logs)
1749
- this.$.$mol_log3_fail({
1750
- place: this,
1751
- message: error.message,
1752
- });
1753
- this.error = error;
1754
- this.obsolete_slaves();
1755
- return error;
1756
- }
1757
- wait(promise) {
1758
- this.error = promise;
1759
- if ($mol_fiber.logs)
1760
- this.$.$mol_log3_warn({
1761
- place: this,
1762
- message: `Wait`,
1763
- hint: `Don't panic, it's normal`,
1764
- promise,
1765
- });
1766
- this.cursor = 0;
1767
- return promise;
1768
- }
1769
- complete() {
1770
- if (this.cursor <= -2)
1771
- return;
1772
- for (let index = 0; index < this.masters.length; index += 2) {
1773
- this.complete_master(index);
1774
- }
1775
- this.cursor = -2;
1776
- }
1777
- complete_master(master_index) {
1778
- this.disobey(master_index);
1779
- }
1780
- pull() {
1781
- if ($mol_fiber.logs)
1782
- this.$.$mol_log3_come({
1783
- place: this,
1784
- message: 'Pull',
1785
- });
1786
- this.push(this.calculate());
1787
- }
1788
- update() {
1789
- const slave = $mol_fiber.current;
1790
- try {
1791
- $mol_fiber.current = this;
1792
- this.pull();
1793
- }
1794
- catch (error) {
1795
- if (Object(error) !== error)
1796
- error = new Error(error);
1797
- if ('then' in error) {
1798
- if (!slave) {
1799
- const listener = () => this.wake();
1800
- error = error.then(listener, listener);
1801
- }
1802
- this.wait(error);
1803
- }
1804
- else {
1805
- this.fail(error);
1806
- }
1807
- }
1808
- finally {
1809
- $mol_fiber.current = slave;
1810
- }
1811
- }
1812
- get() {
1813
- if (this.cursor > 0) {
1814
- this.$.$mol_fail(new Error(`Cyclic dependency at ${this}`));
1815
- }
1816
- const slave = $mol_fiber.current;
1817
- if (slave)
1818
- slave.master = this;
1819
- if (this.cursor > -2)
1820
- this.update();
1821
- if (this.error !== null)
1822
- return this.$.$mol_fail_hidden(this.error);
1823
- return this.value;
1824
- }
1825
- limit() {
1826
- if (!$mol_fiber.deadline)
1827
- return;
1828
- if (!$mol_fiber.current)
1829
- return;
1830
- if (Date.now() < $mol_fiber.deadline)
1831
- return;
1832
- this.$.$mol_fail_hidden($mol_fiber.schedule());
1833
- }
1834
- get master() {
1835
- return (this.cursor < this.masters.length ? this.masters[this.cursor] : undefined);
1836
- }
1837
- set master(next) {
1838
- if (this.cursor === -1)
1839
- return;
1840
- const cursor = this.cursor;
1841
- const prev = this.master;
1842
- if (prev !== next) {
1843
- if (prev)
1844
- this.rescue(prev, cursor);
1845
- this.masters[cursor] = next;
1846
- this.masters[cursor + 1] = this.obey(next, cursor);
1847
- }
1848
- this.cursor = cursor + 2;
1849
- }
1850
- rescue(master, master_index) { }
1851
- obey(master, master_index) { return -1; }
1852
- lead(slave, master_index) { return -1; }
1853
- dislead(slave_index) {
1854
- this.destructor();
1855
- }
1856
- disobey(master_index) {
1857
- const master = this.masters[master_index];
1858
- if (!master)
1859
- return;
1860
- master.dislead(this.masters[master_index + 1]);
1861
- this.masters[master_index] = undefined;
1862
- this.masters[master_index + 1] = undefined;
1863
- this.$.$mol_array_trim(this.masters);
1864
- }
1865
- obsolete_slaves() { }
1866
- obsolete(master_index) { }
1867
- forget() {
1868
- this.value = undefined;
1869
- }
1870
- abort() {
1871
- this.forget();
1872
- return true;
1873
- }
1874
- destructor() {
1875
- if (!this.abort())
1876
- return;
1877
- if ($mol_fiber.logs)
1878
- this.$.$mol_log3_done({
1879
- place: this,
1880
- message: 'Destructed',
1881
- });
1882
- this.complete();
1883
- }
1884
- [$.$mol_dev_format_head]() {
1885
- return $.$mol_dev_format_native(this);
1886
- }
1887
- }
1888
- $mol_fiber.logs = false;
1889
- $mol_fiber.quant = 16;
1890
- $mol_fiber.deadline = 0;
1891
- $mol_fiber.liveline = 0;
1892
- $mol_fiber.current = null;
1893
- $mol_fiber.scheduled = null;
1894
- $mol_fiber.queue = [];
1895
- $.$mol_fiber = $mol_fiber;
1896
- })($ || ($ = {}));
1897
- //fiber.js.map
1010
+ "use strict";
1011
+ var $;
1012
+ (function ($_1) {
1013
+ $mol_test({
1014
+ 'FQN of anon function'($) {
1015
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
1016
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
1017
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
1018
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
1019
+ },
1020
+ });
1021
+ })($ || ($ = {}));
1022
+ //mol/func/name/name.test.ts
1898
1023
  ;
1899
- "use strict";
1900
- var $;
1901
- (function ($) {
1902
- class $mol_defer extends $.$mol_object {
1903
- constructor(run) {
1904
- super();
1905
- this.run = run;
1906
- $mol_defer.add(this);
1907
- }
1908
- destructor() {
1909
- $mol_defer.drop(this);
1910
- }
1911
- static schedule() {
1912
- if (this.timer)
1913
- return;
1914
- this.timer = this.scheduleNative(() => {
1915
- this.timer = null;
1916
- this.run();
1917
- });
1918
- }
1919
- static unschedule() {
1920
- if (!this.timer)
1921
- return;
1922
- cancelAnimationFrame(this.timer);
1923
- this.timer = null;
1924
- }
1925
- static add(defer) {
1926
- this.all.push(defer);
1927
- this.schedule();
1928
- }
1929
- static drop(defer) {
1930
- var index = this.all.indexOf(defer);
1931
- if (index >= 0)
1932
- this.all.splice(index, 1);
1933
- }
1934
- static run() {
1935
- if (this.all.length === 0)
1936
- return;
1937
- this.schedule();
1938
- for (var defer; defer = this.all.shift();)
1939
- defer.run();
1940
- }
1941
- }
1942
- $mol_defer.all = [];
1943
- $mol_defer.timer = null;
1944
- $mol_defer.scheduleNative = (typeof requestAnimationFrame == 'function')
1945
- ? handler => requestAnimationFrame(handler)
1946
- : handler => setTimeout(handler, 16);
1947
- $.$mol_defer = $mol_defer;
1948
- })($ || ($ = {}));
1949
- //defer.js.map
1024
+ "use strict";
1025
+ var $;
1026
+ (function ($) {
1027
+ function $mol_func_name(func) {
1028
+ let name = func.name;
1029
+ if (name?.length > 1)
1030
+ return name;
1031
+ for (let key in this) {
1032
+ try {
1033
+ if (this[key] !== func)
1034
+ continue;
1035
+ name = key;
1036
+ Object.defineProperty(func, 'name', { value: name });
1037
+ break;
1038
+ }
1039
+ catch { }
1040
+ }
1041
+ return name;
1042
+ }
1043
+ $.$mol_func_name = $mol_func_name;
1044
+ function $mol_func_name_from(target, source) {
1045
+ Object.defineProperty(target, 'name', { value: source.name });
1046
+ return target;
1047
+ }
1048
+ $.$mol_func_name_from = $mol_func_name_from;
1049
+ })($ || ($ = {}));
1050
+ //mol/func/name/name.ts
1950
1051
  ;
1951
- "use strict";
1952
- var $;
1953
- (function ($_1) {
1954
- $_1.$mol_test({
1955
- 'Value has js-path name'() {
1956
- class App extends $_1.$mol_object2 {
1957
- static get title() { return new $_1.$mol_object2; }
1958
- }
1959
- __decorate([
1960
- $_1.$mol_atom2_field
1961
- ], App, "title", null);
1962
- $_1.$mol_assert_equal(`${App.title}`, 'App.title');
1963
- },
1964
- 'Simple property'() {
1965
- class App extends $_1.$mol_object2 {
1966
- }
1967
- App.value = 1;
1968
- __decorate([
1969
- $_1.$mol_atom2_field
1970
- ], App, "value", void 0);
1971
- $_1.$mol_assert_equal(App.value, 1);
1972
- App.value = 2;
1973
- $_1.$mol_assert_equal(App.value, 2);
1974
- },
1975
- 'Instant actualization'($) {
1976
- class Source extends $_1.$mol_object2 {
1977
- constructor() {
1978
- super(...arguments);
1979
- this.value = 1;
1980
- }
1981
- get $() { return $; }
1982
- destructor() { }
1983
- }
1984
- __decorate([
1985
- $_1.$mol_atom2_field
1986
- ], Source.prototype, "value", void 0);
1987
- class App extends $_1.$mol_object2 {
1988
- static get $() { return $; }
1989
- static get source() { return Source.create(); }
1990
- static get value() { return this.source.value + 1; }
1991
- }
1992
- __decorate([
1993
- $_1.$mol_atom2_field
1994
- ], App, "source", null);
1995
- __decorate([
1996
- $_1.$mol_atom2_field
1997
- ], App, "value", null);
1998
- $_1.$mol_assert_equal(App.value, 2);
1999
- App.source.value = 2;
2000
- $_1.$mol_assert_equal(App.value, 3);
2001
- },
2002
- 'Access to cached value'($) {
2003
- class App extends $_1.$mol_object2 {
2004
- static get $() { return $; }
2005
- static get value() { return 1; }
2006
- }
2007
- __decorate([
2008
- $_1.$mol_atom2_field
2009
- ], App, "value", null);
2010
- $_1.$mol_assert_equal($_1.$mol_atom2_value(() => App.value), undefined);
2011
- $_1.$mol_assert_equal(App.value, 1);
2012
- $_1.$mol_assert_equal($_1.$mol_atom2_value(() => App.value), 1);
2013
- },
2014
- 'Do not recalc slaves on equal changes'($) {
2015
- class App extends $_1.$mol_object2 {
2016
- static get $() { return $; }
2017
- static get result() { return this.first[0] + this.counter++; }
2018
- }
2019
- App.first = [1];
2020
- App.counter = 0;
2021
- __decorate([
2022
- $_1.$mol_atom2_field
2023
- ], App, "first", void 0);
2024
- __decorate([
2025
- $_1.$mol_atom2_field
2026
- ], App, "result", null);
2027
- $_1.$mol_assert_equal(App.result, 1);
2028
- App.first = [1];
2029
- $_1.$mol_assert_equal(App.result, 1);
2030
- },
2031
- 'Do not recalc grand slave on equal direct slave result '($) {
2032
- class App extends $_1.$mol_object2 {
2033
- static get $() { return $; }
2034
- static get second() { return Math.abs(this.first); }
2035
- static get result() { return this.second + ++this.counter; }
2036
- }
2037
- App.first = 1;
2038
- App.counter = 0;
2039
- __decorate([
2040
- $_1.$mol_atom2_field
2041
- ], App, "first", void 0);
2042
- __decorate([
2043
- $_1.$mol_atom2_field
2044
- ], App, "second", null);
2045
- __decorate([
2046
- $_1.$mol_atom2_field
2047
- ], App, "result", null);
2048
- $_1.$mol_assert_equal(App.result, 2);
2049
- App.first = -1;
2050
- $_1.$mol_assert_equal(App.result, 2);
2051
- },
2052
- 'Recalc when [not changed master] changes [following master]'($) {
2053
- class App extends $_1.$mol_object2 {
2054
- static get $() { return $; }
2055
- static get second() {
2056
- this.third = this.first;
2057
- return 0;
2058
- }
2059
- static get result() { return this.second + this.third + ++this.counter; }
2060
- }
2061
- App.first = 1;
2062
- App.third = 0;
2063
- App.counter = 0;
2064
- __decorate([
2065
- $_1.$mol_atom2_field
2066
- ], App, "first", void 0);
2067
- __decorate([
2068
- $_1.$mol_atom2_field
2069
- ], App, "second", null);
2070
- __decorate([
2071
- $_1.$mol_atom2_field
2072
- ], App, "third", void 0);
2073
- __decorate([
2074
- $_1.$mol_atom2_field
2075
- ], App, "result", null);
2076
- $_1.$mol_assert_equal(App.result, 2);
2077
- App.first = 5;
2078
- $_1.$mol_assert_equal(App.result, 7);
2079
- },
2080
- 'Branch switching'($) {
2081
- class App extends $_1.$mol_object2 {
2082
- static get $() { return $; }
2083
- static get second() { return 2; }
2084
- static get result() {
2085
- return (this.condition ? this.first : this.second) + this.counter++;
2086
- }
2087
- }
2088
- App.first = 1;
2089
- App.condition = true;
2090
- App.counter = 0;
2091
- __decorate([
2092
- $_1.$mol_atom2_field
2093
- ], App, "first", void 0);
2094
- __decorate([
2095
- $_1.$mol_atom2_field
2096
- ], App, "second", null);
2097
- __decorate([
2098
- $_1.$mol_atom2_field
2099
- ], App, "condition", void 0);
2100
- __decorate([
2101
- $_1.$mol_atom2_field
2102
- ], App, "result", null);
2103
- $_1.$mol_assert_equal(App.result, 1);
2104
- App.condition = false;
2105
- $_1.$mol_assert_equal(App.result, 3);
2106
- App.first = 10;
2107
- $_1.$mol_assert_equal(App.result, 3);
2108
- },
2109
- 'Forbidden self invalidation'($) {
2110
- class App extends $_1.$mol_object2 {
2111
- static get $() { return $; }
2112
- static get second() { return this.first + 1; }
2113
- static get result() {
2114
- this.second;
2115
- return this.first++;
2116
- }
2117
- }
2118
- App.first = 1;
2119
- __decorate([
2120
- $_1.$mol_atom2_field
2121
- ], App, "first", void 0);
2122
- __decorate([
2123
- $_1.$mol_atom2_field
2124
- ], App, "second", null);
2125
- __decorate([
2126
- $_1.$mol_atom2_field
2127
- ], App, "result", null);
2128
- $_1.$mol_assert_fail(() => App.result);
2129
- },
2130
- 'Side effect inside computation'($) {
2131
- class App extends $_1.$mol_object2 {
2132
- static get $() { return $; }
2133
- static increase() { return ++this.first; }
2134
- static get result() {
2135
- return this.increase() + 1;
2136
- }
2137
- }
2138
- App.first = 1;
2139
- __decorate([
2140
- $_1.$mol_atom2_field
2141
- ], App, "first", void 0);
2142
- __decorate([
2143
- $_1.$mol_fiber.method
2144
- ], App, "increase", null);
2145
- __decorate([
2146
- $_1.$mol_atom2_field
2147
- ], App, "result", null);
2148
- $_1.$mol_assert_equal(App.result, 3);
2149
- },
2150
- 'Forbidden cyclic dependency'($) {
2151
- class App extends $_1.$mol_object2 {
2152
- static get $() { return $; }
2153
- static get first() { return this.second - 1; }
2154
- static get second() { return this.first + 1; }
2155
- }
2156
- __decorate([
2157
- $_1.$mol_atom2_field
2158
- ], App, "first", null);
2159
- __decorate([
2160
- $_1.$mol_atom2_field
2161
- ], App, "second", null);
2162
- $_1.$mol_assert_fail(() => App.first);
2163
- },
2164
- 'Forget sub fibers on complete'($) {
2165
- class App extends $_1.$mol_object2 {
2166
- static get $() { return $; }
2167
- static count() { return this.counter++; }
2168
- static get result() { return this.count() + this.data; }
2169
- }
2170
- App.counter = 0;
2171
- App.data = 1;
2172
- __decorate([
2173
- $_1.$mol_fiber.method
2174
- ], App, "count", null);
2175
- __decorate([
2176
- $_1.$mol_atom2_field
2177
- ], App, "data", void 0);
2178
- __decorate([
2179
- $_1.$mol_atom2_field
2180
- ], App, "result", null);
2181
- $_1.$mol_assert_equal(App.result, 1);
2182
- App.data = 2;
2183
- $_1.$mol_assert_equal(App.result, 3);
2184
- },
2185
- async 'Automatic destroy owned value on self destruction'($) {
2186
- let counter = 0;
2187
- class Having extends $_1.$mol_object2 {
2188
- destructor() { counter++; }
2189
- }
2190
- class App extends $_1.$mol_object2 {
2191
- static get $() { return $; }
2192
- static get having() { return Having.create(); }
2193
- static get result() {
2194
- if (this.condition)
2195
- this.having;
2196
- return 0;
2197
- }
2198
- }
2199
- App.condition = true;
2200
- __decorate([
2201
- $_1.$mol_atom2_field
2202
- ], App, "having", null);
2203
- __decorate([
2204
- $_1.$mol_atom2_field
2205
- ], App, "condition", void 0);
2206
- __decorate([
2207
- $_1.$mol_atom2_field
2208
- ], App, "result", null);
2209
- App.result;
2210
- App.condition = false;
2211
- App.result;
2212
- $_1.$mol_assert_equal(counter, 0);
2213
- await $_1.$mol_fiber_warp();
2214
- $_1.$mol_assert_equal(counter, 1);
2215
- },
2216
- async 'Do not destroy putted value'($) {
2217
- class App extends $_1.$mol_object2 {
2218
- static get $() { return $; }
2219
- static get target() {
2220
- return this.condition ? this.source : 0;
2221
- }
2222
- }
2223
- App.condition = true;
2224
- __decorate([
2225
- $_1.$mol_atom2_field
2226
- ], App, "source", void 0);
2227
- __decorate([
2228
- $_1.$mol_atom2_field
2229
- ], App, "condition", void 0);
2230
- __decorate([
2231
- $_1.$mol_atom2_field
2232
- ], App, "target", null);
2233
- App.source = 1;
2234
- $_1.$mol_assert_equal(App.target, 1);
2235
- App.condition = false;
2236
- $_1.$mol_assert_equal(App.target, 0);
2237
- await $_1.$mol_fiber_warp();
2238
- App.condition = true;
2239
- $_1.$mol_assert_equal(App.target, 1);
2240
- },
2241
- 'Restore after error'($) {
2242
- class App extends $_1.$mol_object2 {
2243
- static get $() { return $; }
2244
- static get broken() {
2245
- if (this.condition)
2246
- $_1.$mol_fail(new Error('test error'));
2247
- return 1;
2248
- }
2249
- static get result() { return this.broken; }
2250
- }
2251
- App.condition = false;
2252
- __decorate([
2253
- $_1.$mol_atom2_field
2254
- ], App, "condition", void 0);
2255
- __decorate([
2256
- $_1.$mol_atom2_field
2257
- ], App, "broken", null);
2258
- __decorate([
2259
- $_1.$mol_atom2_field
2260
- ], App, "result", null);
2261
- $_1.$mol_assert_equal(App.result, 1);
2262
- App.condition = true;
2263
- $_1.$mol_assert_fail(() => App.result);
2264
- App.condition = false;
2265
- $_1.$mol_assert_equal(App.result, 1);
2266
- },
2267
- async 'auto fresh only when alive'($) {
2268
- let state = 1;
2269
- const monitor = new $.$mol_atom2;
2270
- monitor.$ = $;
2271
- monitor.calculate = () => {
2272
- new $.$mol_after_frame($_1.$mol_atom2.current.fresh);
2273
- return state;
2274
- };
2275
- $_1.$mol_assert_equal(monitor.get(), 1);
2276
- state = 2;
2277
- $_1.$mol_assert_equal(monitor.get(), 1);
2278
- $.$mol_after_mock_warp();
2279
- $_1.$mol_assert_equal(monitor.get(), 2);
2280
- state = 3;
2281
- $_1.$mol_assert_equal(monitor.get(), 2);
2282
- monitor.destructor();
2283
- $_1.$mol_assert_equal(monitor.value, undefined);
2284
- $.$mol_after_mock_warp();
2285
- await $.$mol_fiber_warp();
2286
- $_1.$mol_assert_equal(monitor.value, undefined);
2287
- },
2288
- });
2289
- })($ || ($ = {}));
2290
- //atom2.test.js.map
1052
+ "use strict";
1053
+ var $;
1054
+ (function ($_1) {
1055
+ $mol_test({
1056
+ 'inserting'($) {
1057
+ $mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
1058
+ .insert($mol_tree2.struct('x'), 'a', 'b', 'c')
1059
+ .toString(), 'a b x\n');
1060
+ $mol_assert_equal($.$mol_tree2_from_string('a b\n')
1061
+ .insert($mol_tree2.struct('x'), 'a', 'b', 'c', 'd')
1062
+ .toString(), 'a b c x\n');
1063
+ $mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
1064
+ .insert($mol_tree2.struct('x'), 0, 0, 0)
1065
+ .toString(), 'a b x\n');
1066
+ $mol_assert_equal($.$mol_tree2_from_string('a b\n')
1067
+ .insert($mol_tree2.struct('x'), 0, 0, 0, 0)
1068
+ .toString(), 'a b \\\n\tx\n');
1069
+ $mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
1070
+ .insert($mol_tree2.struct('x'), null, null, null)
1071
+ .toString(), 'a b x\n');
1072
+ $mol_assert_equal($.$mol_tree2_from_string('a b\n')
1073
+ .insert($mol_tree2.struct('x'), null, null, null, null)
1074
+ .toString(), 'a b \\\n\tx\n');
1075
+ },
1076
+ 'deleting'($) {
1077
+ $mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
1078
+ .insert(null, 'a', 'b', 'c')
1079
+ .toString(), 'a b\n');
1080
+ $mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
1081
+ .insert(null, 0, 0, 0)
1082
+ .toString(), 'a b\n');
1083
+ },
1084
+ 'hack'($) {
1085
+ const res = $.$mol_tree2_from_string(`foo bar xxx\n`)
1086
+ .hack({
1087
+ 'bar': (input, belt) => [input.struct('777', input.hack(belt))],
1088
+ });
1089
+ $mol_assert_equal(res.toString(), 'foo 777 xxx\n');
1090
+ },
1091
+ });
1092
+ })($ || ($ = {}));
1093
+ //mol/tree2/tree2.test.ts
2291
1094
  ;
2292
- "use strict";
2293
- var $;
2294
- (function ($) {
2295
- function $mol_atom2_value(task, next) {
2296
- const cached = $mol_atom2.cached;
2297
- try {
2298
- $mol_atom2.cached = true;
2299
- $mol_atom2.cached_next = next;
2300
- return task();
2301
- }
2302
- finally {
2303
- $mol_atom2.cached = cached;
2304
- }
2305
- }
2306
- $.$mol_atom2_value = $mol_atom2_value;
2307
- class $mol_atom2 extends $.$mol_fiber {
2308
- constructor() {
2309
- super(...arguments);
2310
- this.slaves = [];
2311
- }
2312
- static get current() {
2313
- const atom = $.$mol_fiber.current;
2314
- if (atom instanceof $mol_atom2)
2315
- return atom;
2316
- return null;
2317
- }
2318
- static reap(atom) {
2319
- this.reap_queue.push(atom);
2320
- if (this.reap_task)
2321
- return;
2322
- this.reap_task = $.$mol_fiber_defer(() => {
2323
- this.reap_task = null;
2324
- while (true) {
2325
- const atom = this.reap_queue.pop();
2326
- if (!atom)
2327
- break;
2328
- if (!atom.alone)
2329
- continue;
2330
- atom.destructor();
2331
- }
2332
- });
2333
- }
2334
- rescue(master, cursor) {
2335
- if (!(master instanceof $mol_atom2))
2336
- return;
2337
- const master_index = this.masters.length;
2338
- const slave_index = this.masters[cursor + 1] + 1;
2339
- master.slaves[slave_index] = master_index;
2340
- this.masters.push(master, this.masters[cursor + 1]);
2341
- }
2342
- subscribe(promise) {
2343
- const obsolete = () => this.obsolete();
2344
- return promise.then(obsolete, obsolete);
2345
- }
2346
- get() {
2347
- if ($mol_atom2.cached) {
2348
- if ($mol_atom2.cached_next !== undefined) {
2349
- this.push($mol_atom2.cached_next);
2350
- $mol_atom2.cached_next = undefined;
2351
- }
2352
- return this.value;
2353
- }
2354
- const value = super.get();
2355
- if (value === undefined)
2356
- $.$mol_fail(new Error(`Not defined: ${this}`));
2357
- return value;
2358
- }
2359
- pull() {
2360
- if (this.cursor === 0)
2361
- return super.pull();
2362
- if ($mol_atom2.logs)
2363
- this.$.$mol_log3_come({
2364
- place: this,
2365
- message: 'Check doubt masters',
2366
- });
2367
- const masters = this.masters;
2368
- for (let index = 0; index < masters.length; index += 2) {
2369
- const master = masters[index];
2370
- if (!master)
2371
- continue;
2372
- try {
2373
- master.get();
2374
- }
2375
- catch (error) {
2376
- if ('then' in error)
2377
- $.$mol_fail_hidden(error);
2378
- this.cursor = 0;
2379
- }
2380
- if (this.cursor !== 0)
2381
- continue;
2382
- if ($mol_atom2.logs)
2383
- this.$.$mol_log3_done({
2384
- place: this,
2385
- message: 'Obsoleted while checking',
2386
- });
2387
- return super.pull();
2388
- }
2389
- if ($mol_atom2.logs)
2390
- this.$.$mol_log3_done({
2391
- place: this,
2392
- message: 'Masters not changed',
2393
- });
2394
- this.cursor = -2;
2395
- }
2396
- get value() { return this._value; }
2397
- set value(next) {
2398
- const prev = this._value;
2399
- if (prev && this.$.$mol_owning_check(this, prev))
2400
- prev.destructor();
2401
- if (next && this.$.$mol_owning_catch(this, next)) {
2402
- try {
2403
- next[Symbol.toStringTag] = this[Symbol.toStringTag];
2404
- }
2405
- catch (_a) { }
2406
- next[$.$mol_object_field] = this[$.$mol_object_field];
2407
- }
2408
- this._value = next;
2409
- }
2410
- get error() { return this._error; }
2411
- set error(next) {
2412
- const prev = this._error;
2413
- if (prev && this.$.$mol_owning_check(this, prev))
2414
- prev.destructor();
2415
- if (next && this.$.$mol_owning_catch(this, next)) {
2416
- next[Symbol.toStringTag] = this[Symbol.toStringTag];
2417
- next[$.$mol_object_field] = this[$.$mol_object_field];
2418
- }
2419
- this._error = next;
2420
- }
2421
- put(next) {
2422
- this.cursor = this.masters.length;
2423
- next = this.push(next);
2424
- this.cursor = -3;
2425
- return next;
2426
- }
2427
- complete_master(master_index) {
2428
- if (this.masters[master_index] instanceof $mol_atom2) {
2429
- if (master_index >= this.cursor)
2430
- this.disobey(master_index);
2431
- }
2432
- else {
2433
- this.disobey(master_index);
2434
- }
2435
- }
2436
- obey(master, master_index) {
2437
- return master.lead(this, master_index);
2438
- }
2439
- lead(slave, master_index) {
2440
- if ($mol_atom2.logs)
2441
- this.$.$mol_log3_rise({
2442
- place: this,
2443
- message: 'Leads',
2444
- slave,
2445
- });
2446
- const slave_index = this.slaves.length;
2447
- this.slaves[slave_index] = slave;
2448
- this.slaves[slave_index + 1] = master_index;
2449
- return slave_index;
2450
- }
2451
- dislead(slave_index) {
2452
- if (slave_index < 0)
2453
- return;
2454
- if ($mol_atom2.logs)
2455
- this.$.$mol_log3_rise({
2456
- place: this,
2457
- message: 'Disleads',
2458
- slave: this.slaves[slave_index],
2459
- });
2460
- this.slaves[slave_index] = undefined;
2461
- this.slaves[slave_index + 1] = undefined;
2462
- $.$mol_array_trim(this.slaves);
2463
- if (this.cursor > -3 && this.alone)
2464
- $mol_atom2.reap(this);
2465
- }
2466
- obsolete(master_index = -1) {
2467
- if (this.cursor > 0) {
2468
- if (master_index >= this.cursor - 2)
2469
- return;
2470
- const path = [];
2471
- let current = this;
2472
- collect: while (current) {
2473
- path.push(current);
2474
- current = current.masters[current.cursor - 2];
2475
- }
2476
- this.$.$mol_fail(new Error(`Obsoleted while calculation \n\n${path.join('\n')}\n`));
2477
- }
2478
- if (this.cursor === 0)
2479
- return;
2480
- if ($mol_atom2.logs)
2481
- this.$.$mol_log3_rise({
2482
- place: this,
2483
- message: 'Obsoleted',
2484
- });
2485
- if (this.cursor !== -1)
2486
- this.doubt_slaves();
2487
- this.cursor = 0;
2488
- }
2489
- doubt(master_index = -1) {
2490
- if (this.cursor > 0) {
2491
- if (master_index >= this.cursor - 2)
2492
- return;
2493
- const path = [];
2494
- let current = this;
2495
- collect: while (current) {
2496
- path.push(current);
2497
- current = current.masters[current.cursor - 2];
2498
- }
2499
- this.$.$mol_fail(new Error(`Doubted while calculation \n\n${path.join('\n')}\n`));
2500
- }
2501
- if (this.cursor >= -1)
2502
- return;
2503
- if ($mol_atom2.logs)
2504
- this.$.$mol_log3_rise({
2505
- place: this,
2506
- message: 'Doubted',
2507
- });
2508
- this.cursor = -1;
2509
- this.doubt_slaves();
2510
- }
2511
- obsolete_slaves() {
2512
- for (let index = 0; index < this.slaves.length; index += 2) {
2513
- const slave = this.slaves[index];
2514
- if (slave)
2515
- slave.obsolete(this.slaves[index + 1]);
2516
- }
2517
- }
2518
- doubt_slaves() {
2519
- for (let index = 0; index < this.slaves.length; index += 2) {
2520
- const slave = this.slaves[index];
2521
- if (slave)
2522
- slave.doubt(this.slaves[index + 1]);
2523
- }
2524
- }
2525
- get fresh() {
2526
- return () => {
2527
- if (this.cursor !== -2)
2528
- return;
2529
- this.cursor = 0;
2530
- $.$mol_fiber_solid.run(() => this.update());
2531
- };
2532
- }
2533
- get alone() {
2534
- return this.slaves.length === 0;
2535
- }
2536
- get derived() {
2537
- for (let index = 0; index < this.masters.length; index += 2) {
2538
- if (this.masters[index])
2539
- return true;
2540
- }
2541
- return false;
2542
- }
2543
- destructor() {
2544
- if (!this.abort())
2545
- return;
2546
- if ($mol_atom2.logs)
2547
- this.$.$mol_log3_rise({
2548
- place: this,
2549
- message: 'Destructed'
2550
- });
2551
- this.cursor = -3;
2552
- for (let index = 0; index < this.masters.length; index += 2) {
2553
- this.complete_master(index);
2554
- }
2555
- }
2556
- }
2557
- $mol_atom2.logs = false;
2558
- $mol_atom2.cached = false;
2559
- $mol_atom2.cached_next = undefined;
2560
- $mol_atom2.reap_task = null;
2561
- $mol_atom2.reap_queue = [];
2562
- $.$mol_atom2 = $mol_atom2;
2563
- })($ || ($ = {}));
2564
- //atom2.js.map
1095
+ "use strict";
1096
+ var $;
1097
+ (function ($) {
1098
+ $mol_test({
1099
+ 'fromJSON'() {
1100
+ $mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
1101
+ $mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
1102
+ $mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
1103
+ $mol_assert_equal($mol_tree2_from_json(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
1104
+ $mol_assert_equal($mol_tree2_from_json({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
1105
+ },
1106
+ });
1107
+ })($ || ($ = {}));
1108
+ //mol/tree2/from/json/json.test.ts
2565
1109
  ;
2566
- "use strict";
2567
- //param.test.js.map
1110
+ "use strict";
1111
+ //mol/type/unary/unary.ts
2568
1112
  ;
2569
- "use strict";
2570
- //param.js.map
1113
+ "use strict";
1114
+ //mol/type/param/param.test.ts
2571
1115
  ;
2572
- "use strict";
2573
- //result.test.js.map
1116
+ "use strict";
1117
+ //mol/type/param/param.ts
2574
1118
  ;
2575
- "use strict";
2576
- //result.js.map
1119
+ "use strict";
1120
+ //mol/type/tail/tail.test.ts
2577
1121
  ;
2578
- "use strict";
2579
- var $;
2580
- (function ($) {
2581
- class $mol_mem_force extends Object {
2582
- constructor() {
2583
- super();
2584
- this.$mol_mem_force = true;
2585
- }
2586
- static toString() { return this.name; }
2587
- }
2588
- $mol_mem_force.$mol_mem_force = true;
2589
- $.$mol_mem_force = $mol_mem_force;
2590
- class $mol_mem_force_cache extends $mol_mem_force {
2591
- }
2592
- $.$mol_mem_force_cache = $mol_mem_force_cache;
2593
- class $mol_mem_force_update extends $mol_mem_force {
2594
- }
2595
- $.$mol_mem_force_update = $mol_mem_force_update;
2596
- class $mol_mem_force_fail extends $mol_mem_force_cache {
2597
- }
2598
- $.$mol_mem_force_fail = $mol_mem_force_fail;
2599
- })($ || ($ = {}));
2600
- //force.js.map
1122
+ "use strict";
1123
+ //mol/type/tail/tail.ts
2601
1124
  ;
2602
- "use strict";
2603
- var $;
2604
- (function ($_1) {
2605
- $_1.$mol_test({
2606
- 'Property method'($) {
2607
- class App extends $_1.$mol_object2 {
2608
- static value(next = 1) { return next + 1; }
2609
- }
2610
- App.$ = $;
2611
- __decorate([
2612
- $_1.$mol_mem
2613
- ], App, "value", null);
2614
- $_1.$mol_assert_equal(App.value(), 2);
2615
- App.value(2);
2616
- $_1.$mol_assert_equal(App.value(), 3);
2617
- },
2618
- 'auto sync of properties'($) {
2619
- class X extends $_1.$mol_object2 {
2620
- foo(next) {
2621
- return next || 1;
2622
- }
2623
- bar() {
2624
- return this.foo() + 1;
2625
- }
2626
- xxx() {
2627
- return this.bar() + 1;
2628
- }
2629
- }
2630
- __decorate([
2631
- $_1.$mol_mem
2632
- ], X.prototype, "foo", null);
2633
- __decorate([
2634
- $_1.$mol_mem
2635
- ], X.prototype, "bar", null);
2636
- __decorate([
2637
- $_1.$mol_mem
2638
- ], X.prototype, "xxx", null);
2639
- const x = new X;
2640
- x.$ = $;
2641
- $_1.$mol_assert_equal(x.bar(), 2);
2642
- $_1.$mol_assert_equal(x.xxx(), 3);
2643
- x.foo(5);
2644
- $_1.$mol_assert_equal(x.xxx(), 7);
2645
- },
2646
- async 'must be deferred destroyed when no longer referenced'($) {
2647
- let foo;
2648
- let foo_destroyed = false;
2649
- class B extends $_1.$mol_object2 {
2650
- showing(next) {
2651
- if (next === void 0)
2652
- return true;
2653
- return next;
2654
- }
2655
- foo() {
2656
- return foo = new class extends $_1.$mol_object {
2657
- destructor() {
2658
- foo_destroyed = true;
2659
- }
2660
- };
2661
- }
2662
- bar() {
2663
- return this.showing() ? this.foo() : null;
2664
- }
2665
- }
2666
- __decorate([
2667
- $_1.$mol_mem
2668
- ], B.prototype, "showing", null);
2669
- __decorate([
2670
- $_1.$mol_mem
2671
- ], B.prototype, "foo", null);
2672
- __decorate([
2673
- $_1.$mol_mem
2674
- ], B.prototype, "bar", null);
2675
- var b = new B;
2676
- b.$ = $;
2677
- var bar = b.bar();
2678
- $_1.$mol_assert_ok(bar);
2679
- b.showing(false);
2680
- b.bar();
2681
- await $_1.$mol_fiber_warp();
2682
- $_1.$mol_assert_ok(foo_destroyed);
2683
- $_1.$mol_assert_not(b.bar());
2684
- b.showing(true);
2685
- $_1.$mol_defer.run();
2686
- $_1.$mol_assert_unique(b.bar(), bar);
2687
- },
2688
- async 'wait for data'($) {
2689
- class Test extends $_1.$mol_object2 {
2690
- source() {
2691
- return $_1.$mol_fiber_sync(() => new Promise(done => done('Jin')))();
2692
- }
2693
- middle() {
2694
- return this.source();
2695
- }
2696
- target() {
2697
- return this.middle();
2698
- }
2699
- }
2700
- __decorate([
2701
- $_1.$mol_mem
2702
- ], Test.prototype, "source", null);
2703
- __decorate([
2704
- $_1.$mol_mem
2705
- ], Test.prototype, "middle", null);
2706
- __decorate([
2707
- $_1.$mol_mem
2708
- ], Test.prototype, "target", null);
2709
- const t = new Test;
2710
- t.$ = $;
2711
- $_1.$mol_assert_fail(() => t.target().valueOf(), Promise);
2712
- await $_1.$mol_fiber_warp();
2713
- $_1.$mol_assert_equal(t.target(), 'Jin');
2714
- },
2715
- });
2716
- })($ || ($ = {}));
2717
- //mem.test.js.map
1125
+ "use strict";
1126
+ //mol/data/value/value.ts
2718
1127
  ;
2719
- "use strict";
2720
- var $;
2721
- (function ($) {
2722
- $.$mol_mem_cached = $.$mol_atom2_value;
2723
- function $mol_mem_persist() {
2724
- const atom = $.$mol_atom2.current;
2725
- if (!atom)
2726
- return;
2727
- if (atom.hasOwnProperty('destructor'))
2728
- return;
2729
- atom.destructor = () => { };
2730
- }
2731
- $.$mol_mem_persist = $mol_mem_persist;
2732
- function $mol_mem(proto, name, descr) {
2733
- if (!descr)
2734
- descr = Reflect.getOwnPropertyDescriptor(proto, name);
2735
- const orig = descr.value;
2736
- const store = new WeakMap();
2737
- Object.defineProperty(proto, name + "()", {
2738
- get: function () {
2739
- return store.get(this);
2740
- }
2741
- });
2742
- const get_cache = (host) => {
2743
- let cache = store.get(host);
2744
- if (cache)
2745
- return cache;
2746
- let cache2 = new $.$mol_atom2;
2747
- cache2.calculate = orig.bind(host);
2748
- cache2[Symbol.toStringTag] = `${host}.${name}()`;
2749
- cache2.abort = () => {
2750
- store.delete(host);
2751
- cache2.forget();
2752
- return true;
2753
- };
2754
- $.$mol_owning_catch(host, cache2);
2755
- cache2[$.$mol_object_field] = name;
2756
- store.set(host, cache2);
2757
- return cache2;
2758
- };
2759
- function value(next, force) {
2760
- if (next === undefined) {
2761
- const cache = get_cache(this);
2762
- if (force === $.$mol_mem_force_cache)
2763
- return cache.obsolete(Number.NaN);
2764
- if ($.$mol_atom2.current)
2765
- return cache.get();
2766
- else
2767
- return $.$mol_fiber.run(() => cache.get());
2768
- }
2769
- return $.$mol_fiber.run(() => {
2770
- if (force === $.$mol_mem_force_fail)
2771
- return get_cache(this).fail(next);
2772
- if (force !== $.$mol_mem_force_cache)
2773
- next = orig.call(this, next);
2774
- return get_cache(this).put(next);
2775
- });
2776
- }
2777
- return Object.assign(Object.assign({}, descr || {}), { value: Object.assign(value, { orig }) });
2778
- }
2779
- $.$mol_mem = $mol_mem;
2780
- })($ || ($ = {}));
2781
- //mem.js.map
1128
+ "use strict";
1129
+ var $;
1130
+ (function ($) {
1131
+ $mol_test({
1132
+ 'config by value'() {
1133
+ const N = $mol_data_setup((a) => a, 5);
1134
+ $mol_assert_equal(N.config, 5);
1135
+ },
1136
+ });
1137
+ })($ || ($ = {}));
1138
+ //mol/data/setup/setup.test.ts
2782
1139
  ;
2783
- "use strict";
2784
- var $;
2785
- (function ($) {
2786
- $.$mol_test({
2787
- 'const returns stored value'() {
2788
- const foo = { bar: $.$mol_const(Math.random()) };
2789
- $.$mol_assert_equal(foo.bar(), foo.bar());
2790
- $.$mol_assert_equal(foo.bar(), foo.bar['()']);
2791
- },
2792
- });
2793
- })($ || ($ = {}));
2794
- //const.test.js.map
1140
+ "use strict";
1141
+ var $;
1142
+ (function ($) {
1143
+ function $mol_data_setup(value, config) {
1144
+ return Object.assign(value, {
1145
+ config,
1146
+ Value: null
1147
+ });
1148
+ }
1149
+ $.$mol_data_setup = $mol_data_setup;
1150
+ })($ || ($ = {}));
1151
+ //mol/data/setup/setup.ts
2795
1152
  ;
2796
- "use strict";
2797
- var $;
2798
- (function ($) {
2799
- function $mol_const(value) {
2800
- var getter = (() => value);
2801
- getter['()'] = value;
2802
- getter[Symbol.toStringTag] = value;
2803
- return getter;
2804
- }
2805
- $.$mol_const = $mol_const;
2806
- })($ || ($ = {}));
2807
- //const.js.map
1153
+ "use strict";
1154
+ var $;
1155
+ (function ($) {
1156
+ $mol_test({
1157
+ 'function'() {
1158
+ $mol_assert_not($mol_func_is_class(function () { }));
1159
+ },
1160
+ 'generator'() {
1161
+ $mol_assert_not($mol_func_is_class(function* () { }));
1162
+ },
1163
+ 'async'() {
1164
+ $mol_assert_not($mol_func_is_class(async function () { }));
1165
+ },
1166
+ 'arrow'() {
1167
+ $mol_assert_not($mol_func_is_class(() => null));
1168
+ },
1169
+ 'named class'() {
1170
+ $mol_assert_ok($mol_func_is_class(class Foo {
1171
+ }));
1172
+ },
1173
+ 'unnamed class'() {
1174
+ $mol_assert_ok($mol_func_is_class(class {
1175
+ }));
1176
+ },
1177
+ });
1178
+ })($ || ($ = {}));
1179
+ //mol/func/is/class/class.test.ts
2808
1180
  ;
2809
- "use strict";
2810
- var $;
2811
- (function ($) {
2812
- function $mol_atom2_field(proto, name, descr) {
2813
- if (!descr)
2814
- descr = Object.getOwnPropertyDescriptor(proto, name);
2815
- const get = descr ? (descr.get || $.$mol_const(descr.value)) : (() => undefined);
2816
- const set = descr && descr.set || function (next) { get_cache(this).put(next); };
2817
- const store = new WeakMap();
2818
- Object.defineProperty(proto, name + "@", {
2819
- get: function () {
2820
- return store.get(this);
2821
- }
2822
- });
2823
- const get_cache = (host) => {
2824
- let cache = store.get(host);
2825
- if (!cache) {
2826
- cache = new $.$mol_atom2;
2827
- cache.calculate = get.bind(host);
2828
- cache[Symbol.toStringTag] = `${host}.${name}`;
2829
- cache.abort = () => {
2830
- store.delete(host);
2831
- cache.forget();
2832
- return true;
2833
- };
2834
- $.$mol_owning_catch(host, cache);
2835
- store.set(host, cache);
2836
- }
2837
- return cache;
2838
- };
2839
- return {
2840
- get() {
2841
- return get_cache(this).get();
2842
- },
2843
- set,
2844
- };
2845
- }
2846
- $.$mol_atom2_field = $mol_atom2_field;
2847
- })($ || ($ = {}));
2848
- //field.js.map
1181
+ "use strict";
1182
+ var $;
1183
+ (function ($) {
1184
+ function $mol_func_is_class(func) {
1185
+ return Object.getOwnPropertyDescriptor(func, 'prototype')?.writable === false;
1186
+ }
1187
+ $.$mol_func_is_class = $mol_func_is_class;
1188
+ })($ || ($ = {}));
1189
+ //mol/func/is/class/class.ts
2849
1190
  ;
2850
- "use strict";
2851
- var $;
2852
- (function ($_1) {
2853
- $_1.$mol_test({
2854
- async 'Autorun'($) {
2855
- class App extends $_1.$mol_object2 {
2856
- static get init() {
2857
- ++this.counter;
2858
- return this.state;
2859
- }
2860
- }
2861
- App.$ = $;
2862
- App.state = 1;
2863
- App.counter = 0;
2864
- __decorate([
2865
- $_1.$mol_atom2_field
2866
- ], App, "state", void 0);
2867
- __decorate([
2868
- $_1.$mol_atom2_field
2869
- ], App, "init", null);
2870
- const autorun = $_1.$mol_atom2_autorun(() => App.init);
2871
- autorun.$ = $;
2872
- try {
2873
- await $_1.$mol_fiber_warp();
2874
- $_1.$mol_assert_equal(App.counter, 1);
2875
- App.state = 2;
2876
- $_1.$mol_assert_equal(App.counter, 1);
2877
- await $_1.$mol_fiber_warp();
2878
- $_1.$mol_assert_equal(App.counter, 2);
2879
- App.state = 3;
2880
- }
2881
- finally {
2882
- autorun.destructor();
2883
- }
2884
- App.state = 4;
2885
- await $_1.$mol_fiber_warp();
2886
- $_1.$mol_assert_equal(App.counter, 2);
2887
- },
2888
- });
2889
- })($ || ($ = {}));
2890
- //autorun.test.js.map
1191
+ "use strict";
1192
+ //mol/type/result/result.test.ts
2891
1193
  ;
2892
- "use strict";
2893
- var $;
2894
- (function ($) {
2895
- function $mol_atom2_autorun(calculate) {
2896
- return $.$mol_atom2.create(atom => {
2897
- atom.calculate = calculate;
2898
- atom.obsolete_slaves = atom.schedule;
2899
- atom.doubt_slaves = atom.schedule;
2900
- if (Symbol.toStringTag in calculate) {
2901
- atom[Symbol.toStringTag] = calculate[Symbol.toStringTag];
2902
- }
2903
- else {
2904
- atom[Symbol.toStringTag] = calculate.name || '$mol_atom2_autorun';
2905
- }
2906
- atom.schedule();
2907
- });
2908
- }
2909
- $.$mol_atom2_autorun = $mol_atom2_autorun;
2910
- })($ || ($ = {}));
2911
- //autorun.js.map
1194
+ "use strict";
1195
+ //mol/type/result/result.ts
2912
1196
  ;
2913
- "use strict";
2914
- var $;
2915
- (function ($_1) {
2916
- $_1.$mol_test({
2917
- 'Class as component'() {
2918
- class Foo extends $_1.$mol_jsx_view {
2919
- constructor() {
2920
- super(...arguments);
2921
- this.title = '';
2922
- }
2923
- render() {
2924
- return $_1.$mol_jsx("div", null,
2925
- this.title,
2926
- " ",
2927
- this.childNodes.join('-'));
2928
- }
2929
- }
2930
- const dom = $_1.$mol_jsx(Foo, { id: "/foo", title: "bar" },
2931
- "xxx",
2932
- 123);
2933
- $_1.$mol_assert_equal(dom.outerHTML, '<div id="/foo">bar xxx-123</div>');
2934
- },
2935
- 'View by element'() {
2936
- class Br extends $_1.$mol_jsx_view {
2937
- render() {
2938
- view = this;
2939
- return $_1.$mol_jsx("br", { id: "/foo" });
2940
- }
2941
- }
2942
- let view;
2943
- $_1.$mol_assert_equal(Br.of($_1.$mol_jsx(Br, null)), view);
2944
- },
2945
- 'Attached view rerender'() {
2946
- const doc = $_1.$mol_dom_parse('<html><body id="/foo"></body></html>');
2947
- class Title extends $_1.$mol_jsx_view {
2948
- constructor() {
2949
- super(...arguments);
2950
- this.value = 'foo';
2951
- }
2952
- render() {
2953
- return $_1.$mol_jsx("div", null, this.value);
2954
- }
2955
- }
2956
- const dom = $_1.$mol_jsx_attach(doc, () => $_1.$mol_jsx(Title, { id: "/foo" }));
2957
- const title = Title.of(dom);
2958
- $_1.$mol_assert_equal(title.ownerDocument, doc);
2959
- $_1.$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">foo</body></html>');
2960
- title.value = 'bar';
2961
- title.valueOf();
2962
- $_1.$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">bar</body></html>');
2963
- },
2964
- async 'Reactive attached view'($) {
2965
- const doc = $_1.$mol_dom_parse('<html><body id="/foo"></body></html>');
2966
- class Task extends $_1.$mol_object2 {
2967
- title(next) { return next || 'foo'; }
2968
- }
2969
- __decorate([
2970
- $_1.$mol_mem
2971
- ], Task.prototype, "title", null);
2972
- class App extends $_1.$mol_jsx_view {
2973
- task() { return new Task; }
2974
- valueOf() {
2975
- return super.valueOf();
2976
- }
2977
- render() {
2978
- return $_1.$mol_jsx("div", null, this.task().title());
2979
- }
2980
- }
2981
- __decorate([
2982
- $_1.$mol_mem
2983
- ], App.prototype, "task", null);
2984
- __decorate([
2985
- $_1.$mol_mem
2986
- ], App.prototype, "valueOf", null);
2987
- const task = new Task;
2988
- task.$ = $;
2989
- const autorun = $.$mol_atom2_autorun(() => $_1.$mol_jsx_attach(doc, () => $_1.$mol_jsx(App, { "$": $, id: "/foo", task: () => task })));
2990
- autorun.$ = $;
2991
- await $_1.$mol_fiber_warp();
2992
- $_1.$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">foo</body></html>');
2993
- task.title('bar');
2994
- await $_1.$mol_fiber_warp();
2995
- $_1.$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">bar</body></html>');
2996
- },
2997
- });
2998
- })($ || ($ = {}));
2999
- //view.test.js.map
1197
+ "use strict";
1198
+ //mol/type/foot/foot.test.ts
3000
1199
  ;
3001
- "use strict";
3002
- var $;
3003
- (function ($) {
3004
- class $mol_jsx_view extends $.$mol_object2 {
3005
- static of(node) {
3006
- return node[this];
3007
- }
3008
- valueOf() {
3009
- const prefix = $.$mol_jsx_prefix;
3010
- const booked = $.$mol_jsx_booked;
3011
- const document = $.$mol_jsx_document;
3012
- try {
3013
- $.$mol_jsx_prefix = this[Symbol.toStringTag];
3014
- $.$mol_jsx_booked = new Set;
3015
- $.$mol_jsx_document = this.ownerDocument;
3016
- return this.render();
3017
- }
3018
- finally {
3019
- $.$mol_jsx_prefix = prefix;
3020
- $.$mol_jsx_booked = booked;
3021
- $.$mol_jsx_document = document;
3022
- }
3023
- }
3024
- render() {
3025
- return $.$mol_fail(new Error('dom_tree() not implemented'));
3026
- }
3027
- }
3028
- $.$mol_jsx_view = $mol_jsx_view;
3029
- })($ || ($ = {}));
3030
- //view.js.map
1200
+ "use strict";
1201
+ //mol/type/foot/foot.ts
3031
1202
  ;
3032
- "use strict";
3033
- //equals.test.js.map
1203
+ "use strict";
1204
+ var $;
1205
+ (function ($) {
1206
+ $mol_test({
1207
+ 'single function'() {
1208
+ const stringify = $mol_data_pipe((input) => input.toString());
1209
+ $mol_assert_equal(stringify(5), '5');
1210
+ },
1211
+ 'two functions'() {
1212
+ const isLong = $mol_data_pipe((input) => input.toString(), (input) => input.length > 2);
1213
+ $mol_assert_equal(isLong(5.0), false);
1214
+ $mol_assert_equal(isLong(5.1), true);
1215
+ },
1216
+ 'three functions'() {
1217
+ const pattern = $mol_data_pipe((input) => input.toString(), (input) => new RegExp(input), (input) => input.toString());
1218
+ $mol_assert_equal(pattern(5), '/5/');
1219
+ },
1220
+ 'classes'() {
1221
+ class Box {
1222
+ value;
1223
+ constructor(value) {
1224
+ this.value = value;
1225
+ }
1226
+ }
1227
+ const boxify = $mol_data_pipe((input) => input.toString(), Box);
1228
+ $mol_assert_ok(boxify(5) instanceof Box);
1229
+ $mol_assert_like(boxify(5).value, '5');
1230
+ },
1231
+ });
1232
+ })($ || ($ = {}));
1233
+ //mol/data/pipe/pipe.test.ts
3034
1234
  ;
3035
- "use strict";
3036
- //equals.js.map
1235
+ "use strict";
1236
+ var $;
1237
+ (function ($) {
1238
+ function $mol_data_pipe(...funcs) {
1239
+ return $mol_data_setup(function (input) {
1240
+ let value = input;
1241
+ for (const func of funcs)
1242
+ value = $mol_func_is_class(func) ? new func(value) : func.call(this, value);
1243
+ return value;
1244
+ }, { funcs });
1245
+ }
1246
+ $.$mol_data_pipe = $mol_data_pipe;
1247
+ })($ || ($ = {}));
1248
+ //mol/data/pipe/pipe.ts
3037
1249
  ;
3038
- "use strict";
3039
- var $;
3040
- (function ($) {
3041
- $.$mol_test({
3042
- 'equal paths'() {
3043
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
3044
- $.$mol_assert_like(diff, {
3045
- prefix: [1, 2, 3, 4],
3046
- suffix: [[], [], []],
3047
- });
3048
- },
3049
- 'different suffix'() {
3050
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
3051
- $.$mol_assert_like(diff, {
3052
- prefix: [1, 2],
3053
- suffix: [[3, 4], [3, 5], [5, 4]],
3054
- });
3055
- },
3056
- 'one contains other'() {
3057
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
3058
- $.$mol_assert_like(diff, {
3059
- prefix: [1, 2],
3060
- suffix: [[3, 4], [], [3]],
3061
- });
3062
- },
3063
- 'fully different'() {
3064
- const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
3065
- $.$mol_assert_like(diff, {
3066
- prefix: [],
3067
- suffix: [[1, 2], [3, 4], [5, 6]],
3068
- });
3069
- },
3070
- });
3071
- })($ || ($ = {}));
3072
- //path.test.js.map
1250
+ "use strict";
1251
+ var $;
1252
+ (function ($) {
1253
+ const convert = $mol_data_pipe($mol_tree2_from_string, $mol_tree2_js_to_text, $mol_tree2_text_to_string);
1254
+ $mol_test({
1255
+ 'boolean'() {
1256
+ $mol_assert_equal(convert(`
1257
+ true
1258
+ `), 'true\n');
1259
+ },
1260
+ 'number'() {
1261
+ $mol_assert_equal(convert(`
1262
+ 1.2
1263
+ `), '1.2\n');
1264
+ $mol_assert_equal(convert(`
1265
+ 1e+2
1266
+ `), '1e+2\n');
1267
+ $mol_assert_equal(convert(`
1268
+ -Infinity
1269
+ `), '-Infinity\n');
1270
+ $mol_assert_equal(convert(`
1271
+ NaN
1272
+ `), 'NaN\n');
1273
+ },
1274
+ 'variable'() {
1275
+ $mol_assert_equal(convert(`
1276
+ a
1277
+ `), 'a\n');
1278
+ $mol_assert_equal(convert(`
1279
+ $
1280
+ `), '$\n');
1281
+ $mol_assert_equal(convert(`
1282
+ a0
1283
+ `), 'a0\n');
1284
+ },
1285
+ 'string'() {
1286
+ $mol_assert_equal(convert(`
1287
+ \\
1288
+ \\foo
1289
+ \\bar
1290
+ `), '"foo\\nbar"\n');
1291
+ $mol_assert_equal(convert(`
1292
+ \`\`
1293
+ \\foo
1294
+ bar
1295
+ `), '`foo${bar}`\n');
1296
+ },
1297
+ 'wrong name'() {
1298
+ $mol_assert_fail(() => convert(`
1299
+ foo+bar
1300
+ `), 'Wrong node type\nfoo+bar\nunknown#2:6/7');
1301
+ },
1302
+ 'array'() {
1303
+ $mol_assert_equal(convert(`
1304
+ [,]
1305
+ `), '[]\n');
1306
+ $mol_assert_equal(convert(`
1307
+ [,]
1308
+ 1
1309
+ 2
1310
+ `), '[1, 2]\n');
1311
+ },
1312
+ 'last'() {
1313
+ $mol_assert_equal(convert(`
1314
+ (,)
1315
+ 1
1316
+ 2
1317
+ `), '(1, 2)\n');
1318
+ },
1319
+ 'scope'() {
1320
+ $mol_assert_equal(convert(`
1321
+ {;}
1322
+ 1
1323
+ 2
1324
+ `), '{1; 2}\n');
1325
+ },
1326
+ 'object'() {
1327
+ $mol_assert_equal(convert(`
1328
+ {,}
1329
+ `), '{}\n');
1330
+ $mol_assert_equal(convert(`
1331
+ {,}
1332
+ foo
1333
+ bar
1334
+ `), '{foo, bar}\n');
1335
+ $mol_assert_equal(convert(`
1336
+ {,}
1337
+ :
1338
+ \\foo
1339
+ 1
1340
+ :
1341
+ bar
1342
+ 2
1343
+ `), '{"foo": 1, [bar]: 2}\n');
1344
+ },
1345
+ 'regexp'() {
1346
+ $mol_assert_equal(convert(`
1347
+ /./
1348
+ .source \\foo\\n
1349
+ .multiline
1350
+ .ignoreCase
1351
+ .global
1352
+ `), '/foo\\\\n/mig\n');
1353
+ },
1354
+ 'unary'() {
1355
+ $mol_assert_equal(convert(`
1356
+ void yield* yield await ~ ! - + 1
1357
+ `), 'void yield* yield await ~!-+1\n');
1358
+ },
1359
+ 'binary'() {
1360
+ $mol_assert_equal(convert(`
1361
+ (+)
1362
+ 1
1363
+ 2
1364
+ 3
1365
+ `), '(\n\t1 + \n\t2 + \n\t3\n)\n');
1366
+ $mol_assert_equal(convert(`
1367
+ @++ foo
1368
+ `), 'foo++\n');
1369
+ },
1370
+ 'chain'() {
1371
+ $mol_assert_equal(convert(`
1372
+ ()
1373
+ foo
1374
+ [] \\bar
1375
+ [] 1
1376
+ `), '(foo.bar[1])\n');
1377
+ $mol_assert_equal(convert(`
1378
+ ()
1379
+ foo
1380
+ [] 1
1381
+ (,)
1382
+ `), '(foo[1]())\n');
1383
+ $mol_assert_equal(convert(`
1384
+ ()
1385
+ [,] 0
1386
+ [] 1
1387
+ (,)
1388
+ 2
1389
+ 3
1390
+ `), '([0][1](2, 3))\n');
1391
+ },
1392
+ 'function'() {
1393
+ $mol_assert_equal(convert(`
1394
+ =>
1395
+ (,)
1396
+ 1
1397
+ `), '() => 1\n');
1398
+ $mol_assert_equal(convert(`
1399
+ async=>
1400
+ (,)
1401
+ 1
1402
+ `), 'async () => 1\n');
1403
+ $mol_assert_equal(convert(`
1404
+ function
1405
+ foo
1406
+ (,)
1407
+ {;}
1408
+ `), 'function foo(){}\n');
1409
+ $mol_assert_equal(convert(`
1410
+ function
1411
+ (,) foo
1412
+ {;} debugger
1413
+ `), 'function (foo){debugger}\n');
1414
+ $mol_assert_equal(convert(`
1415
+ function*
1416
+ (,)
1417
+ {;}
1418
+ `), 'function* (){}\n');
1419
+ $mol_assert_equal(convert(`
1420
+ async
1421
+ (,)
1422
+ {;}
1423
+ `), 'async function (){}\n');
1424
+ $mol_assert_equal(convert(`
1425
+ async*
1426
+ (,) foo
1427
+ {;} debugger
1428
+ `), 'async function* (foo){debugger}\n');
1429
+ },
1430
+ 'class'() {
1431
+ $mol_assert_equal(convert(`
1432
+ class
1433
+ Foo
1434
+ {}
1435
+ `), 'class Foo {}\n');
1436
+ $mol_assert_equal(convert(`
1437
+ class
1438
+ Foo
1439
+ extends Bar
1440
+ {}
1441
+ `), 'class Foo extends Bar {}\n');
1442
+ $mol_assert_equal(convert(`
1443
+ class {}
1444
+ .
1445
+ \\foo
1446
+ (,)
1447
+ {;}
1448
+ `), 'class {foo(){}}\n');
1449
+ $mol_assert_equal(convert(`
1450
+ class {}
1451
+ static
1452
+ \\foo
1453
+ (,)
1454
+ {;}
1455
+ `), 'class {static ["foo"](){}}\n');
1456
+ $mol_assert_equal(convert(`
1457
+ class {}
1458
+ get
1459
+ \\foo
1460
+ (,)
1461
+ {;}
1462
+ `), 'class {get ["foo"](){}}\n');
1463
+ $mol_assert_equal(convert(`
1464
+ class {}
1465
+ set
1466
+ \\foo
1467
+ (,) bar
1468
+ {;}
1469
+ `), 'class {set ["foo"](bar){}}\n');
1470
+ },
1471
+ 'if'() {
1472
+ $mol_assert_equal(convert(`
1473
+ ?:
1474
+ 1
1475
+ 2
1476
+ 3
1477
+ `), '1 ? 2 : 3\n');
1478
+ $mol_assert_equal(convert(`
1479
+ if
1480
+ () 1
1481
+ {;} 2
1482
+ `), 'if(1) {2}\n');
1483
+ $mol_assert_equal(convert(`
1484
+ if
1485
+ () 1
1486
+ {;} 2
1487
+ {;} 3
1488
+ `), 'if(1) {2}else{3}\n');
1489
+ },
1490
+ 'assign'() {
1491
+ $mol_assert_equal(convert(`
1492
+ =
1493
+ foo
1494
+ bar
1495
+ `), 'foo = bar\n');
1496
+ $mol_assert_equal(convert(`
1497
+ =
1498
+ [,]
1499
+ foo
1500
+ bar
1501
+ [,]
1502
+ 1
1503
+ 2
1504
+ `), '[foo, bar] = [1, 2]\n');
1505
+ $mol_assert_equal(convert(`
1506
+ let foo
1507
+ `), 'let foo\n');
1508
+ $mol_assert_equal(convert(`
1509
+ let
1510
+ foo
1511
+ bar
1512
+ `), 'let foo = bar\n');
1513
+ $mol_assert_equal(convert(`
1514
+ +=
1515
+ foo
1516
+ bar
1517
+ `), 'foo += bar\n');
1518
+ },
1519
+ });
1520
+ })($ || ($ = {}));
1521
+ //mol/tree2/js/to/text/text.test.ts
3073
1522
  ;
3074
- "use strict";
3075
- var $;
3076
- (function ($) {
3077
- function $mol_diff_path(...paths) {
3078
- const limit = Math.min(...paths.map(path => path.length));
3079
- lookup: for (var i = 0; i < limit; ++i) {
3080
- const first = paths[0][i];
3081
- for (let j = 1; j < paths.length; ++j) {
3082
- if (paths[j][i] !== first)
3083
- break lookup;
3084
- }
3085
- }
3086
- return {
3087
- prefix: paths[0].slice(0, i),
3088
- suffix: paths.map(path => path.slice(i)),
3089
- };
3090
- }
3091
- $.$mol_diff_path = $mol_diff_path;
3092
- })($ || ($ = {}));
3093
- //path.js.map
1523
+ "use strict";
1524
+ var $;
1525
+ (function ($) {
1526
+ $mol_test({
1527
+ 'min'() {
1528
+ $mol_assert_equal($mol_vlq_encode(Number.MIN_SAFE_INTEGER), '//////H');
1529
+ },
1530
+ 'negative'() {
1531
+ $mol_assert_equal($mol_vlq_encode(-1), 'D');
1532
+ },
1533
+ 'zero'() {
1534
+ $mol_assert_equal($mol_vlq_encode(0), 'A');
1535
+ },
1536
+ 'binom'() {
1537
+ $mol_assert_equal($mol_vlq_encode(67), 'mE');
1538
+ },
1539
+ 'max'() {
1540
+ $mol_assert_equal($mol_vlq_encode(Number.MAX_SAFE_INTEGER), '+/////H');
1541
+ },
1542
+ });
1543
+ })($ || ($ = {}));
1544
+ //mol/vlq/vlq.test.ts
3094
1545
  ;
3095
- "use strict";
3096
- var $;
3097
- (function ($) {
3098
- class $mol_error_mix extends Error {
3099
- constructor(message, ...errors) {
3100
- super(message);
3101
- this.errors = errors;
3102
- if (errors.length) {
3103
- const stacks = [...errors.map(error => error.message), this.stack];
3104
- const diff = $.$mol_diff_path(...stacks.map(stack => {
3105
- if (!stack)
3106
- return [];
3107
- return stack.split('\n').reverse();
3108
- }));
3109
- const head = diff.prefix.reverse().join('\n');
3110
- const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
3111
- this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
3112
- this.message += errors.map(error => '\n' + error.message).join('');
3113
- }
3114
- }
3115
- toJSON() {
3116
- return this.message;
3117
- }
3118
- }
3119
- $.$mol_error_mix = $mol_error_mix;
3120
- })($ || ($ = {}));
3121
- //mix.js.map
1546
+ "use strict";
1547
+ var $;
1548
+ (function ($_1) {
1549
+ $mol_test({
1550
+ 'sample source mapped lang'($) {
1551
+ const source = {
1552
+ script1: `1@\n2`,
1553
+ script2: `***`
1554
+ };
1555
+ const span = {
1556
+ script1: $mol_span.entire('script1', source.script1),
1557
+ script2: $mol_span.entire('script2', source.script2),
1558
+ };
1559
+ const tree = $mol_tree2.list([
1560
+ $mol_tree2.struct('line', [
1561
+ $mol_tree2.data('"use strict";', [], span.script1.after()),
1562
+ $mol_tree2.data('console.log(11);', [], span.script1.slice(0, 1)),
1563
+ $mol_tree2.data('console.log(21);', [], span.script2),
1564
+ $mol_tree2.data('console.log(12);', [], span.script1.span(2, 1, 1)),
1565
+ ], span.script1),
1566
+ ], span.script1);
1567
+ $mol_assert_like($.$mol_tree2_text_to_string(tree), '"use strict";console.log(11);console.log(21);console.log(12);\n');
1568
+ $mol_assert_like($.$mol_tree2_text_to_sourcemap(tree), {
1569
+ "version": 3,
1570
+ "sources": [
1571
+ "script1",
1572
+ "script2"
1573
+ ],
1574
+ "sourcesContent": [source.script1, source.script2],
1575
+ "mappings": "AAAA,AAAI,aAAJ,gBCAA,gBDCA;"
1576
+ });
1577
+ }
1578
+ });
1579
+ })($ || ($ = {}));
1580
+ //mol/tree2/text/to/sourcemap/sourcemap.test.ts
3122
1581
  ;
3123
- "use strict";
3124
- var $;
3125
- (function ($_1) {
3126
- $_1.$mol_test({
3127
- 'tree parsing'($) {
3128
- $_1.$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
3129
- $_1.$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
3130
- $_1.$mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
3131
- $_1.$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
3132
- $_1.$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
3133
- $_1.$mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
3134
- $_1.$mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
3135
- $_1.$mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
3136
- },
3137
- 'Too many tabs'($) {
3138
- const tree = `
3139
- foo
3140
- bar
3141
- `;
3142
- $_1.$mol_assert_fail(() => {
3143
- $.$mol_tree2_from_string(tree, 'test');
3144
- }, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
3145
- },
3146
- 'Too few tabs'($) {
3147
- const tree = `
3148
- foo
3149
- bar
3150
- `;
3151
- $_1.$mol_assert_fail(() => {
3152
- $.$mol_tree2_from_string(tree, 'test');
3153
- }, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
3154
- },
3155
- 'Wrong nodes separator'($) {
3156
- const tree = `foo bar\n`;
3157
- $_1.$mol_assert_fail(() => {
3158
- $.$mol_tree2_from_string(tree, 'test');
3159
- }, 'Wrong nodes separator\ntest#1:4/2\n !!\nfoo bar');
3160
- },
3161
- 'Undexpected EOF, LF required'($) {
3162
- const tree = ` foo`;
3163
- $_1.$mol_assert_fail(() => {
3164
- $.$mol_tree2_from_string(tree, 'test');
3165
- }, 'Undexpected EOF, LF required\ntest#1:5/1\n !\n foo');
3166
- },
3167
- 'Errors skip and collect'($) {
3168
- const tree = `foo bar`;
3169
- const errors = [];
3170
- const $$ = $.$mol_ambient({
3171
- $mol_fail: (error) => {
3172
- errors.push(error.message);
3173
- return null;
3174
- }
3175
- });
3176
- const res = $$.$mol_tree2_from_string(tree, 'test');
3177
- $_1.$mol_assert_like(errors, [
3178
- 'Wrong nodes separator\ntest#1:4/2\n !!\nfoo bar',
3179
- 'Undexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
3180
- ]);
3181
- $_1.$mol_assert_equal(res.toString(), 'foo bar\n');
3182
- },
3183
- });
3184
- })($ || ($ = {}));
3185
- //string.test.js.map
1582
+ "use strict";
1583
+ var $;
1584
+ (function ($_1) {
1585
+ $mol_test({
1586
+ 'atoms'($) {
1587
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("null\n").kids[0]), null);
1588
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("true\n").kids[0]), true);
1589
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("false\n").kids[0]), false);
1590
+ },
1591
+ 'numbers'($) {
1592
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("1\n").kids[0]), 1);
1593
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("1.2\n").kids[0]), 1.2);
1594
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("1.2e+2\n").kids[0]), 120);
1595
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("NaN\n").kids[0]), Number.NaN);
1596
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("+Infinity\n").kids[0]), Number.POSITIVE_INFINITY);
1597
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("-Infinity\n").kids[0]), Number.NEGATIVE_INFINITY);
1598
+ },
1599
+ 'string'($) {
1600
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("\\foo\n").kids[0]), 'foo');
1601
+ $mol_assert_equal($.$mol_tree2_to_json($.$mol_tree2_from_string("\\\n\t\\foo\n\t\\bar\n").kids[0]), 'foo\nbar');
1602
+ },
1603
+ 'array'($) {
1604
+ $mol_assert_like($.$mol_tree2_to_json($.$mol_tree2_from_string("/\n").kids[0]), []);
1605
+ $mol_assert_like($.$mol_tree2_to_json($.$mol_tree2_from_string("/\n\t\\foo\n\t\\bar\n").kids[0]), ['foo', 'bar']);
1606
+ $mol_assert_like($.$mol_tree2_to_json($.$mol_tree2_from_string("/\n\t- \\foo\n\t\\bar\n").kids[0]), ['bar']);
1607
+ },
1608
+ 'object'($) {
1609
+ $mol_assert_like($.$mol_tree2_to_json($.$mol_tree2_from_string("*\n").kids[0]), {});
1610
+ $mol_assert_like($.$mol_tree2_to_json($.$mol_tree2_from_string("*\n\t\\foo\n\t\t\\bar\n").kids[0]), { foo: 'bar' });
1611
+ $mol_assert_like($.$mol_tree2_to_json($.$mol_tree2_from_string("*\n\t\\\n\t\t\\foo\n\t\t\\bar\n\t\t\\lol\n").kids[0]), { 'foo\nbar': 'lol' });
1612
+ },
1613
+ });
1614
+ })($ || ($ = {}));
1615
+ //mol/tree2/to/json/json.test.ts
3186
1616
 
3187
1617
  //# sourceMappingURL=web.test.js.map