mol_plot_all 1.2.192 → 1.2.196
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node.d.ts +0 -1416
- package/node.deps.json +1 -1
- package/node.esm.js +1737 -1967
- package/node.esm.js.map +1 -1
- package/node.js +1737 -1967
- package/node.js.map +1 -1
- package/node.test.js +4077 -3831
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/test.html +2 -2
- package/web.d.ts +0 -1384
- package/web.deps.json +1 -1
- package/web.esm.js +1277 -1509
- package/web.esm.js.map +1 -1
- package/web.js +1277 -1509
- package/web.js.map +1 -1
- package/web.test.js +1375 -896
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -16,12 +16,18 @@ var $;
|
|
|
16
16
|
$_1.$mol_test_all = [];
|
|
17
17
|
async function $mol_test_run() {
|
|
18
18
|
for (var test of $_1.$mol_test_all) {
|
|
19
|
-
let context = Object.create(
|
|
19
|
+
let context = Object.create($$);
|
|
20
20
|
for (let mock of $_1.$mol_test_mocks)
|
|
21
21
|
await mock(context);
|
|
22
|
-
|
|
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
|
+
}
|
|
23
29
|
}
|
|
24
|
-
|
|
30
|
+
$$.$mol_log3_done({
|
|
25
31
|
place: '$mol_test',
|
|
26
32
|
message: 'All tests passed',
|
|
27
33
|
count: $_1.$mol_test_all.length,
|
|
@@ -39,7 +45,7 @@ var $;
|
|
|
39
45
|
await $mol_test_run();
|
|
40
46
|
}
|
|
41
47
|
finally {
|
|
42
|
-
|
|
48
|
+
$$.$mol_test_complete();
|
|
43
49
|
}
|
|
44
50
|
}, 0);
|
|
45
51
|
}
|
|
@@ -52,10 +58,10 @@ var $;
|
|
|
52
58
|
for (let api of forbidden) {
|
|
53
59
|
context[api] = new Proxy(function () { }, {
|
|
54
60
|
get() {
|
|
55
|
-
$
|
|
61
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
56
62
|
},
|
|
57
63
|
apply() {
|
|
58
|
-
$
|
|
64
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
59
65
|
},
|
|
60
66
|
});
|
|
61
67
|
}
|
|
@@ -83,7 +89,7 @@ var $;
|
|
|
83
89
|
},
|
|
84
90
|
});
|
|
85
91
|
})($ || ($ = {}));
|
|
86
|
-
//test.test.
|
|
92
|
+
//mol/test/test.test.ts
|
|
87
93
|
;
|
|
88
94
|
"use strict";
|
|
89
95
|
var $;
|
|
@@ -92,88 +98,88 @@ var $;
|
|
|
92
98
|
}
|
|
93
99
|
$.$mol_test_complete = $mol_test_complete;
|
|
94
100
|
})($ || ($ = {}));
|
|
95
|
-
//test.web.test.
|
|
101
|
+
//mol/test/test.web.test.ts
|
|
96
102
|
;
|
|
97
103
|
"use strict";
|
|
98
|
-
//error.
|
|
104
|
+
//mol/type/error/error.ts
|
|
99
105
|
;
|
|
100
106
|
"use strict";
|
|
101
|
-
//assert.test.
|
|
107
|
+
//mol/type/assert/assert.test.ts
|
|
102
108
|
;
|
|
103
109
|
"use strict";
|
|
104
|
-
//assert.
|
|
110
|
+
//mol/type/assert/assert.ts
|
|
105
111
|
;
|
|
106
112
|
"use strict";
|
|
107
|
-
//deep.test.
|
|
113
|
+
//mol/type/partial/deep/deep.test.ts
|
|
108
114
|
;
|
|
109
115
|
"use strict";
|
|
110
|
-
//deep.
|
|
116
|
+
//mol/type/partial/deep/deep.ts
|
|
111
117
|
;
|
|
112
118
|
"use strict";
|
|
113
119
|
var $;
|
|
114
120
|
(function ($) {
|
|
115
|
-
|
|
121
|
+
$mol_test({
|
|
116
122
|
'Make empty div'() {
|
|
117
|
-
|
|
123
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
118
124
|
},
|
|
119
125
|
'Define native field'() {
|
|
120
|
-
const dom =
|
|
121
|
-
|
|
122
|
-
|
|
126
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
127
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
128
|
+
$mol_assert_equal(dom.value, '123');
|
|
123
129
|
},
|
|
124
130
|
'Define classes'() {
|
|
125
|
-
const dom =
|
|
126
|
-
|
|
131
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
132
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
127
133
|
},
|
|
128
134
|
'Define styles'() {
|
|
129
|
-
const dom =
|
|
130
|
-
|
|
135
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
136
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
131
137
|
},
|
|
132
138
|
'Define dataset'() {
|
|
133
|
-
const dom =
|
|
134
|
-
|
|
139
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
140
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
135
141
|
},
|
|
136
142
|
'Define attributes'() {
|
|
137
|
-
const dom =
|
|
138
|
-
|
|
143
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
144
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
139
145
|
},
|
|
140
146
|
'Define child nodes'() {
|
|
141
|
-
const dom =
|
|
147
|
+
const dom = $mol_jsx("div", null,
|
|
142
148
|
"hello",
|
|
143
|
-
|
|
149
|
+
$mol_jsx("strong", null, "world"),
|
|
144
150
|
"!");
|
|
145
|
-
|
|
151
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
146
152
|
},
|
|
147
153
|
'Function as component'() {
|
|
148
154
|
const Button = ({ hint }, target) => {
|
|
149
|
-
return
|
|
155
|
+
return $mol_jsx("button", { title: hint }, target());
|
|
150
156
|
};
|
|
151
|
-
const dom =
|
|
152
|
-
|
|
157
|
+
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
158
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
153
159
|
},
|
|
154
160
|
'Nested guid generation'() {
|
|
155
161
|
const Foo = () => {
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
|
|
162
|
+
return $mol_jsx("div", null,
|
|
163
|
+
$mol_jsx(Bar, { id: "/bar" },
|
|
164
|
+
$mol_jsx("img", { id: "/icon" })));
|
|
159
165
|
};
|
|
160
166
|
const Bar = (props, icon) => {
|
|
161
|
-
return
|
|
167
|
+
return $mol_jsx("span", null, icon);
|
|
162
168
|
};
|
|
163
|
-
const dom =
|
|
164
|
-
|
|
169
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
170
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
165
171
|
},
|
|
166
172
|
'Fail on non unique ids'() {
|
|
167
173
|
const App = () => {
|
|
168
|
-
return
|
|
169
|
-
|
|
170
|
-
|
|
174
|
+
return $mol_jsx("div", null,
|
|
175
|
+
$mol_jsx("span", { id: "/bar" }),
|
|
176
|
+
$mol_jsx("span", { id: "/bar" }));
|
|
171
177
|
};
|
|
172
|
-
|
|
178
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
173
179
|
},
|
|
174
180
|
});
|
|
175
181
|
})($ || ($ = {}));
|
|
176
|
-
//jsx.test.
|
|
182
|
+
//mol/jsx/jsx.test.tsx
|
|
177
183
|
;
|
|
178
184
|
"use strict";
|
|
179
185
|
var $;
|
|
@@ -182,15 +188,15 @@ var $;
|
|
|
182
188
|
$.$mol_jsx_booked = null;
|
|
183
189
|
$.$mol_jsx_document = {
|
|
184
190
|
getElementById: () => null,
|
|
185
|
-
createElementNS: (space, name) =>
|
|
186
|
-
createDocumentFragment: () =>
|
|
191
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
192
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
187
193
|
};
|
|
188
194
|
$.$mol_jsx_frag = '';
|
|
189
195
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
190
196
|
const id = props && props.id || '';
|
|
191
197
|
if (Elem && $.$mol_jsx_booked) {
|
|
192
198
|
if ($.$mol_jsx_booked.has(id)) {
|
|
193
|
-
|
|
199
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
194
200
|
}
|
|
195
201
|
else {
|
|
196
202
|
$.$mol_jsx_booked.add(id);
|
|
@@ -229,7 +235,7 @@ var $;
|
|
|
229
235
|
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
230
236
|
: $.$mol_jsx_document.createDocumentFragment();
|
|
231
237
|
}
|
|
232
|
-
|
|
238
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
233
239
|
if (!Elem)
|
|
234
240
|
return node;
|
|
235
241
|
for (const key in props) {
|
|
@@ -255,77 +261,77 @@ var $;
|
|
|
255
261
|
}
|
|
256
262
|
$.$mol_jsx = $mol_jsx;
|
|
257
263
|
})($ || ($ = {}));
|
|
258
|
-
//jsx.
|
|
264
|
+
//mol/jsx/jsx.ts
|
|
259
265
|
;
|
|
260
266
|
"use strict";
|
|
261
267
|
var $;
|
|
262
268
|
(function ($) {
|
|
263
|
-
|
|
269
|
+
$mol_test({
|
|
264
270
|
'nulls & undefineds'() {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
272
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
273
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
274
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
269
275
|
},
|
|
270
276
|
'number'() {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
278
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
279
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
280
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
281
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
276
282
|
},
|
|
277
283
|
'POJO'() {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
285
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
286
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
287
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
288
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
289
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
284
290
|
},
|
|
285
291
|
'Array'() {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
292
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
293
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
294
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
295
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
290
296
|
},
|
|
291
297
|
'Non POJO are different'() {
|
|
292
298
|
class Thing extends Object {
|
|
293
299
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
300
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
301
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
302
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
297
303
|
},
|
|
298
304
|
'same POJOs with cyclic reference'() {
|
|
299
305
|
const a = { foo: {} };
|
|
300
306
|
a['self'] = a;
|
|
301
307
|
const b = { foo: {} };
|
|
302
308
|
b['self'] = b;
|
|
303
|
-
|
|
309
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
304
310
|
},
|
|
305
311
|
'Date'() {
|
|
306
|
-
|
|
307
|
-
|
|
312
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
313
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
308
314
|
},
|
|
309
315
|
'RegExp'() {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
316
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
317
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
318
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
313
319
|
},
|
|
314
320
|
'Map'() {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
321
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
322
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
323
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
324
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
319
325
|
},
|
|
320
326
|
'Set'() {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
327
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
328
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
329
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
324
330
|
},
|
|
325
331
|
'Uint8Array'() {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
332
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
333
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
334
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
329
335
|
},
|
|
330
336
|
'Custom comparator'() {
|
|
331
337
|
class User {
|
|
@@ -339,55 +345,55 @@ var $;
|
|
|
339
345
|
return this.name;
|
|
340
346
|
}
|
|
341
347
|
}
|
|
342
|
-
|
|
343
|
-
|
|
348
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
349
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
344
350
|
},
|
|
345
351
|
});
|
|
346
352
|
})($ || ($ = {}));
|
|
347
|
-
//deep.test.
|
|
353
|
+
//mol/compare/deep/deep.test.tsx
|
|
348
354
|
;
|
|
349
355
|
"use strict";
|
|
350
356
|
var $;
|
|
351
357
|
(function ($) {
|
|
352
358
|
function $mol_dom_serialize(node) {
|
|
353
|
-
const serializer = new
|
|
359
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
354
360
|
return serializer.serializeToString(node);
|
|
355
361
|
}
|
|
356
362
|
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
357
363
|
})($ || ($ = {}));
|
|
358
|
-
//serialize.
|
|
364
|
+
//mol/dom/serialize/serialize.ts
|
|
359
365
|
;
|
|
360
366
|
"use strict";
|
|
361
367
|
var $;
|
|
362
368
|
(function ($) {
|
|
363
|
-
|
|
369
|
+
$mol_test({
|
|
364
370
|
'must be false'() {
|
|
365
|
-
|
|
371
|
+
$mol_assert_not(0);
|
|
366
372
|
},
|
|
367
373
|
'must be true'() {
|
|
368
|
-
|
|
374
|
+
$mol_assert_ok(1);
|
|
369
375
|
},
|
|
370
376
|
'two must be equal'() {
|
|
371
|
-
|
|
377
|
+
$mol_assert_equal(2, 2);
|
|
372
378
|
},
|
|
373
379
|
'three must be equal'() {
|
|
374
|
-
|
|
380
|
+
$mol_assert_equal(2, 2, 2);
|
|
375
381
|
},
|
|
376
382
|
'two must be unique'() {
|
|
377
|
-
|
|
383
|
+
$mol_assert_unique([3], [3]);
|
|
378
384
|
},
|
|
379
385
|
'three must be unique'() {
|
|
380
|
-
|
|
386
|
+
$mol_assert_unique([3], [3], [3]);
|
|
381
387
|
},
|
|
382
388
|
'two must be alike'() {
|
|
383
|
-
|
|
389
|
+
$mol_assert_like([3], [3]);
|
|
384
390
|
},
|
|
385
391
|
'three must be alike'() {
|
|
386
|
-
|
|
392
|
+
$mol_assert_like([3], [3], [3]);
|
|
387
393
|
},
|
|
388
394
|
});
|
|
389
395
|
})($ || ($ = {}));
|
|
390
|
-
//assert.test.
|
|
396
|
+
//mol/assert/assert.test.ts
|
|
391
397
|
;
|
|
392
398
|
"use strict";
|
|
393
399
|
var $;
|
|
@@ -395,13 +401,13 @@ var $;
|
|
|
395
401
|
function $mol_assert_ok(value) {
|
|
396
402
|
if (value)
|
|
397
403
|
return;
|
|
398
|
-
|
|
404
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
399
405
|
}
|
|
400
406
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
401
407
|
function $mol_assert_not(value) {
|
|
402
408
|
if (!value)
|
|
403
409
|
return;
|
|
404
|
-
|
|
410
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
405
411
|
}
|
|
406
412
|
$.$mol_assert_not = $mol_assert_not;
|
|
407
413
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
@@ -425,7 +431,7 @@ var $;
|
|
|
425
431
|
finally {
|
|
426
432
|
$.$mol_fail = fail;
|
|
427
433
|
}
|
|
428
|
-
|
|
434
|
+
$mol_fail(new Error('Not failed'));
|
|
429
435
|
}
|
|
430
436
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
431
437
|
function $mol_assert_equal(...args) {
|
|
@@ -436,7 +442,7 @@ var $;
|
|
|
436
442
|
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
437
443
|
continue;
|
|
438
444
|
if (args[i] !== args[j])
|
|
439
|
-
|
|
445
|
+
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
440
446
|
}
|
|
441
447
|
}
|
|
442
448
|
}
|
|
@@ -447,7 +453,7 @@ var $;
|
|
|
447
453
|
if (i === j)
|
|
448
454
|
continue;
|
|
449
455
|
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
450
|
-
|
|
456
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
451
457
|
}
|
|
452
458
|
}
|
|
453
459
|
}
|
|
@@ -455,7 +461,7 @@ var $;
|
|
|
455
461
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
456
462
|
function $mol_assert_like(head, ...tail) {
|
|
457
463
|
for (let [index, value] of Object.entries(tail)) {
|
|
458
|
-
if (
|
|
464
|
+
if (!$mol_compare_deep(value, head)) {
|
|
459
465
|
const print = (val) => {
|
|
460
466
|
if (!val)
|
|
461
467
|
return val;
|
|
@@ -471,39 +477,39 @@ var $;
|
|
|
471
477
|
return val;
|
|
472
478
|
}
|
|
473
479
|
};
|
|
474
|
-
return
|
|
480
|
+
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
475
481
|
}
|
|
476
482
|
}
|
|
477
483
|
}
|
|
478
484
|
$.$mol_assert_like = $mol_assert_like;
|
|
479
485
|
function $mol_assert_dom(left, right) {
|
|
480
|
-
$mol_assert_equal(
|
|
486
|
+
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
|
481
487
|
}
|
|
482
488
|
$.$mol_assert_dom = $mol_assert_dom;
|
|
483
489
|
})($ || ($ = {}));
|
|
484
|
-
//assert.
|
|
490
|
+
//mol/assert/assert.ts
|
|
485
491
|
;
|
|
486
492
|
"use strict";
|
|
487
493
|
var $;
|
|
488
494
|
(function ($) {
|
|
489
|
-
|
|
495
|
+
$mol_test({
|
|
490
496
|
'get'() {
|
|
491
|
-
const proxy =
|
|
492
|
-
|
|
497
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
498
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
493
499
|
},
|
|
494
500
|
'has'() {
|
|
495
|
-
const proxy =
|
|
496
|
-
|
|
501
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
502
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
497
503
|
},
|
|
498
504
|
'set'() {
|
|
499
505
|
const target = { foo: 777 };
|
|
500
|
-
const proxy =
|
|
506
|
+
const proxy = $mol_delegate({}, () => target);
|
|
501
507
|
proxy.foo = 123;
|
|
502
|
-
|
|
508
|
+
$mol_assert_equal(target.foo, 123);
|
|
503
509
|
},
|
|
504
510
|
'getOwnPropertyDescriptor'() {
|
|
505
|
-
const proxy =
|
|
506
|
-
|
|
511
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
512
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
507
513
|
value: 777,
|
|
508
514
|
writable: true,
|
|
509
515
|
enumerable: true,
|
|
@@ -511,43 +517,43 @@ var $;
|
|
|
511
517
|
});
|
|
512
518
|
},
|
|
513
519
|
'ownKeys'() {
|
|
514
|
-
const proxy =
|
|
515
|
-
|
|
520
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
521
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
516
522
|
},
|
|
517
523
|
'getPrototypeOf'() {
|
|
518
524
|
class Foo {
|
|
519
525
|
}
|
|
520
|
-
const proxy =
|
|
521
|
-
|
|
526
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
527
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
522
528
|
},
|
|
523
529
|
'setPrototypeOf'() {
|
|
524
530
|
class Foo {
|
|
525
531
|
}
|
|
526
532
|
const target = {};
|
|
527
|
-
const proxy =
|
|
533
|
+
const proxy = $mol_delegate({}, () => target);
|
|
528
534
|
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
529
|
-
|
|
535
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
530
536
|
},
|
|
531
537
|
'instanceof'() {
|
|
532
538
|
class Foo {
|
|
533
539
|
}
|
|
534
|
-
const proxy =
|
|
535
|
-
|
|
536
|
-
|
|
540
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
541
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
542
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
537
543
|
},
|
|
538
544
|
'autobind'() {
|
|
539
545
|
class Foo {
|
|
540
546
|
}
|
|
541
|
-
const proxy =
|
|
542
|
-
|
|
543
|
-
|
|
547
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
548
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
549
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
544
550
|
},
|
|
545
551
|
});
|
|
546
552
|
})($ || ($ = {}));
|
|
547
|
-
//delegate.test.
|
|
553
|
+
//mol/delegate/delegate.test.ts
|
|
548
554
|
;
|
|
549
555
|
"use strict";
|
|
550
|
-
//writable.test.
|
|
556
|
+
//mol/type/writable/writable.test.ts
|
|
551
557
|
;
|
|
552
558
|
"use strict";
|
|
553
559
|
var $;
|
|
@@ -559,7 +565,7 @@ var $;
|
|
|
559
565
|
task();
|
|
560
566
|
}
|
|
561
567
|
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
|
562
|
-
class $mol_after_mock_commmon extends
|
|
568
|
+
class $mol_after_mock_commmon extends $mol_object2 {
|
|
563
569
|
task;
|
|
564
570
|
promise = Promise.resolve();
|
|
565
571
|
cancelled = false;
|
|
@@ -585,23 +591,834 @@ var $;
|
|
|
585
591
|
}
|
|
586
592
|
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
|
587
593
|
})($ || ($ = {}));
|
|
588
|
-
//mock.test.
|
|
594
|
+
//mol/after/mock/mock.test.ts
|
|
595
|
+
;
|
|
596
|
+
"use strict";
|
|
597
|
+
var $;
|
|
598
|
+
(function ($_1) {
|
|
599
|
+
$mol_test_mocks.push($ => {
|
|
600
|
+
$.$mol_after_tick = $mol_after_mock_commmon;
|
|
601
|
+
});
|
|
602
|
+
})($ || ($ = {}));
|
|
603
|
+
//mol/after/tick/tick.test.ts
|
|
604
|
+
;
|
|
605
|
+
"use strict";
|
|
606
|
+
var $;
|
|
607
|
+
(function ($_1) {
|
|
608
|
+
$mol_test({
|
|
609
|
+
async 'Latest Calls Wins on Concurrency'($) {
|
|
610
|
+
class NameLogger extends $mol_object2 {
|
|
611
|
+
static $ = $;
|
|
612
|
+
static first = [];
|
|
613
|
+
static last = [];
|
|
614
|
+
static send(next) {
|
|
615
|
+
$mol_wire_sync(this.first).push(next);
|
|
616
|
+
this.$.$mol_wait_timeout(0);
|
|
617
|
+
this.last.push(next);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
621
|
+
name('john');
|
|
622
|
+
const promise = name('jin');
|
|
623
|
+
$.$mol_after_mock_warp();
|
|
624
|
+
await promise;
|
|
625
|
+
$mol_assert_like(NameLogger.first, ['john', 'jin']);
|
|
626
|
+
$mol_assert_like(NameLogger.last, ['jin']);
|
|
627
|
+
},
|
|
628
|
+
});
|
|
629
|
+
})($ || ($ = {}));
|
|
630
|
+
//mol/wire/async/async.test.ts
|
|
631
|
+
;
|
|
632
|
+
"use strict";
|
|
633
|
+
var $;
|
|
634
|
+
(function ($_1) {
|
|
635
|
+
$mol_test({
|
|
636
|
+
'Collect deps'() {
|
|
637
|
+
const pub1 = new $mol_wire_pub;
|
|
638
|
+
const pub2 = new $mol_wire_pub;
|
|
639
|
+
const sub = new $mol_wire_pub_sub;
|
|
640
|
+
const bu1 = sub.track_on();
|
|
641
|
+
try {
|
|
642
|
+
pub1.track_promote();
|
|
643
|
+
pub2.track_promote();
|
|
644
|
+
pub2.track_promote();
|
|
645
|
+
}
|
|
646
|
+
finally {
|
|
647
|
+
sub.track_off(bu1);
|
|
648
|
+
}
|
|
649
|
+
pub1.emit();
|
|
650
|
+
pub2.emit();
|
|
651
|
+
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
652
|
+
const bu2 = sub.track_on();
|
|
653
|
+
try {
|
|
654
|
+
pub1.track_promote();
|
|
655
|
+
pub1.track_promote();
|
|
656
|
+
pub2.track_promote();
|
|
657
|
+
}
|
|
658
|
+
finally {
|
|
659
|
+
sub.track_off(bu2);
|
|
660
|
+
}
|
|
661
|
+
pub1.emit();
|
|
662
|
+
pub2.emit();
|
|
663
|
+
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
664
|
+
},
|
|
665
|
+
'cyclic detection'($) {
|
|
666
|
+
const sub1 = new $mol_wire_pub_sub;
|
|
667
|
+
const sub2 = new $mol_wire_pub_sub;
|
|
668
|
+
const bu1 = sub1.track_on();
|
|
669
|
+
try {
|
|
670
|
+
const bu2 = sub2.track_on();
|
|
671
|
+
try {
|
|
672
|
+
$mol_assert_fail(() => sub1.track_promote(), 'Circular subscription');
|
|
673
|
+
}
|
|
674
|
+
finally {
|
|
675
|
+
sub2.track_off(bu2);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
finally {
|
|
679
|
+
sub1.track_off(bu1);
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
});
|
|
683
|
+
})($ || ($ = {}));
|
|
684
|
+
//mol/wire/pub/sub/sub.test.ts
|
|
685
|
+
;
|
|
686
|
+
"use strict";
|
|
687
|
+
var $;
|
|
688
|
+
(function ($) {
|
|
689
|
+
$mol_test({
|
|
690
|
+
'Primitives'() {
|
|
691
|
+
$mol_assert_equal($mol_key(null), 'null');
|
|
692
|
+
$mol_assert_equal($mol_key(false), 'false');
|
|
693
|
+
$mol_assert_equal($mol_key(true), 'true');
|
|
694
|
+
$mol_assert_equal($mol_key(0), '0');
|
|
695
|
+
$mol_assert_equal($mol_key(''), '""');
|
|
696
|
+
},
|
|
697
|
+
'Array & POJO'() {
|
|
698
|
+
$mol_assert_equal($mol_key([null]), '[null]');
|
|
699
|
+
$mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
|
|
700
|
+
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
701
|
+
},
|
|
702
|
+
'Function'() {
|
|
703
|
+
const func = () => { };
|
|
704
|
+
$mol_assert_equal($mol_key(func), $mol_key(func));
|
|
705
|
+
$mol_assert_unique($mol_key(func), $mol_key(() => { }));
|
|
706
|
+
},
|
|
707
|
+
'Objects'() {
|
|
708
|
+
class User {
|
|
709
|
+
}
|
|
710
|
+
const jin = new User();
|
|
711
|
+
$mol_assert_equal($mol_key(jin), $mol_key(jin));
|
|
712
|
+
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
713
|
+
},
|
|
714
|
+
'Elements'() {
|
|
715
|
+
const foo = $mol_jsx("div", null, "bar");
|
|
716
|
+
$mol_assert_equal($mol_key(foo), $mol_key(foo));
|
|
717
|
+
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
718
|
+
},
|
|
719
|
+
'Custom JSON representation'() {
|
|
720
|
+
class User {
|
|
721
|
+
name;
|
|
722
|
+
age;
|
|
723
|
+
constructor(name, age) {
|
|
724
|
+
this.name = name;
|
|
725
|
+
this.age = age;
|
|
726
|
+
}
|
|
727
|
+
toJSON() { return { name: this.name }; }
|
|
728
|
+
}
|
|
729
|
+
$mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
730
|
+
},
|
|
731
|
+
'Special native classes'() {
|
|
732
|
+
$mol_assert_equal($mol_key(new Date('xyz')), 'null');
|
|
733
|
+
$mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
734
|
+
$mol_assert_equal($mol_key(/./), '"/./"');
|
|
735
|
+
$mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
736
|
+
},
|
|
737
|
+
});
|
|
738
|
+
})($ || ($ = {}));
|
|
739
|
+
//mol/key/key.test.tsx
|
|
589
740
|
;
|
|
590
741
|
"use strict";
|
|
591
742
|
var $;
|
|
592
743
|
(function ($_1) {
|
|
593
|
-
$
|
|
594
|
-
$.$
|
|
744
|
+
$mol_test_mocks.push($ => {
|
|
745
|
+
$.$mol_after_frame = $mol_after_mock_commmon;
|
|
746
|
+
});
|
|
747
|
+
})($ || ($ = {}));
|
|
748
|
+
//mol/after/frame/frame.test.ts
|
|
749
|
+
;
|
|
750
|
+
"use strict";
|
|
751
|
+
var $;
|
|
752
|
+
(function ($) {
|
|
753
|
+
$mol_test({
|
|
754
|
+
'Sync execution'() {
|
|
755
|
+
class Sync extends $mol_object2 {
|
|
756
|
+
static calc(a, b) {
|
|
757
|
+
return a + b;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
__decorate([
|
|
761
|
+
$mol_wire_method
|
|
762
|
+
], Sync, "calc", null);
|
|
763
|
+
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
764
|
+
},
|
|
765
|
+
async 'async <=> sync'() {
|
|
766
|
+
class SyncAsync extends $mol_object2 {
|
|
767
|
+
static async val(a) {
|
|
768
|
+
return a;
|
|
769
|
+
}
|
|
770
|
+
static sum(a, b) {
|
|
771
|
+
const syn = $mol_wire_sync(this);
|
|
772
|
+
return syn.val(a) + syn.val(b);
|
|
773
|
+
}
|
|
774
|
+
static async calc(a, b) {
|
|
775
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
779
|
+
},
|
|
780
|
+
async 'Idempotence control'() {
|
|
781
|
+
class Idempotence extends $mol_object2 {
|
|
782
|
+
static logs_idemp = 0;
|
|
783
|
+
static logs_unidemp = 0;
|
|
784
|
+
static log_idemp() {
|
|
785
|
+
this.logs_idemp += 1;
|
|
786
|
+
}
|
|
787
|
+
static log_unidemp() {
|
|
788
|
+
this.logs_unidemp += 1;
|
|
789
|
+
}
|
|
790
|
+
static async val(a) {
|
|
791
|
+
return a;
|
|
792
|
+
}
|
|
793
|
+
static sum(a, b) {
|
|
794
|
+
this.log_idemp();
|
|
795
|
+
this.log_unidemp();
|
|
796
|
+
const syn = $mol_wire_sync(this);
|
|
797
|
+
return syn.val(a) + syn.val(b);
|
|
798
|
+
}
|
|
799
|
+
static async calc(a, b) {
|
|
800
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
__decorate([
|
|
804
|
+
$mol_wire_method
|
|
805
|
+
], Idempotence, "log_idemp", null);
|
|
806
|
+
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
807
|
+
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
808
|
+
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
809
|
+
},
|
|
810
|
+
async 'Error handling'() {
|
|
811
|
+
class Handle extends $mol_object2 {
|
|
812
|
+
static async sum(a, b) {
|
|
813
|
+
$mol_fail(new Error('test error ' + (a + b)));
|
|
814
|
+
}
|
|
815
|
+
static check() {
|
|
816
|
+
try {
|
|
817
|
+
return $mol_wire_sync(Handle).sum(1, 2);
|
|
818
|
+
}
|
|
819
|
+
catch (error) {
|
|
820
|
+
if (error instanceof Promise)
|
|
821
|
+
$mol_fail_hidden(error);
|
|
822
|
+
$mol_assert_equal(error.message, 'test error 3');
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
await $mol_wire_async(Handle).check();
|
|
827
|
+
},
|
|
828
|
+
});
|
|
829
|
+
})($ || ($ = {}));
|
|
830
|
+
//mol/wire/fiber/fiber.test.ts
|
|
831
|
+
;
|
|
832
|
+
"use strict";
|
|
833
|
+
var $;
|
|
834
|
+
(function ($) {
|
|
835
|
+
function $mol_wire_sync(obj) {
|
|
836
|
+
return new Proxy(obj, {
|
|
837
|
+
get(obj, field) {
|
|
838
|
+
const val = obj[field];
|
|
839
|
+
if (typeof val !== 'function')
|
|
840
|
+
return val;
|
|
841
|
+
return function $mol_wire_sync(...args) {
|
|
842
|
+
const fiber = $mol_wire_fiber.temp(obj, val, ...args);
|
|
843
|
+
return fiber.sync();
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
|
849
|
+
})($ || ($ = {}));
|
|
850
|
+
//mol/wire/sync/sync.ts
|
|
851
|
+
;
|
|
852
|
+
"use strict";
|
|
853
|
+
var $;
|
|
854
|
+
(function ($_1) {
|
|
855
|
+
$mol_test({
|
|
856
|
+
'Cached channel'($) {
|
|
857
|
+
class App extends $mol_object2 {
|
|
858
|
+
static $ = $;
|
|
859
|
+
static value(next = 1) {
|
|
860
|
+
return next + 1;
|
|
861
|
+
}
|
|
862
|
+
static test() {
|
|
863
|
+
$mol_assert_equal(App.value(), 2);
|
|
864
|
+
App.value(2);
|
|
865
|
+
$mol_assert_equal(App.value(), 3);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
__decorate([
|
|
869
|
+
$mol_wire_mem(0)
|
|
870
|
+
], App, "value", null);
|
|
871
|
+
__decorate([
|
|
872
|
+
$mol_wire_method
|
|
873
|
+
], App, "test", null);
|
|
874
|
+
App.test();
|
|
875
|
+
},
|
|
876
|
+
'Mem overrides mem'($) {
|
|
877
|
+
class Base extends $mol_object2 {
|
|
878
|
+
static $ = $;
|
|
879
|
+
static value(next = 1) {
|
|
880
|
+
return next + 1;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
__decorate([
|
|
884
|
+
$mol_wire_mem(0)
|
|
885
|
+
], Base, "value", null);
|
|
886
|
+
class Middle extends Base {
|
|
887
|
+
static value(next) {
|
|
888
|
+
return super.value(next) + 1;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
__decorate([
|
|
892
|
+
$mol_wire_mem(0)
|
|
893
|
+
], Middle, "value", null);
|
|
894
|
+
class App extends Middle {
|
|
895
|
+
static value(next) {
|
|
896
|
+
return super.value(next) * 3;
|
|
897
|
+
}
|
|
898
|
+
static test() {
|
|
899
|
+
$mol_assert_equal(this.value(), 9);
|
|
900
|
+
$mol_assert_equal(this.value(5), 21);
|
|
901
|
+
$mol_assert_equal(this.value(), 21);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
__decorate([
|
|
905
|
+
$mol_wire_mem(0)
|
|
906
|
+
], App, "value", null);
|
|
907
|
+
__decorate([
|
|
908
|
+
$mol_wire_method
|
|
909
|
+
], App, "test", null);
|
|
910
|
+
App.test();
|
|
911
|
+
},
|
|
912
|
+
'Auto recalculation of cached values'($) {
|
|
913
|
+
class App extends $mol_object2 {
|
|
914
|
+
static $ = $;
|
|
915
|
+
static xxx(next) {
|
|
916
|
+
return next || 1;
|
|
917
|
+
}
|
|
918
|
+
static yyy() {
|
|
919
|
+
return this.xxx() + 1;
|
|
920
|
+
}
|
|
921
|
+
static zzz() {
|
|
922
|
+
return this.yyy() + 1;
|
|
923
|
+
}
|
|
924
|
+
static test() {
|
|
925
|
+
$mol_assert_equal(App.yyy(), 2);
|
|
926
|
+
$mol_assert_equal(App.zzz(), 3);
|
|
927
|
+
App.xxx(5);
|
|
928
|
+
$mol_assert_equal(App.zzz(), 7);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
__decorate([
|
|
932
|
+
$mol_wire_mem(0)
|
|
933
|
+
], App, "xxx", null);
|
|
934
|
+
__decorate([
|
|
935
|
+
$mol_wire_mem(0)
|
|
936
|
+
], App, "yyy", null);
|
|
937
|
+
__decorate([
|
|
938
|
+
$mol_wire_mem(0)
|
|
939
|
+
], App, "zzz", null);
|
|
940
|
+
__decorate([
|
|
941
|
+
$mol_wire_method
|
|
942
|
+
], App, "test", null);
|
|
943
|
+
App.test();
|
|
944
|
+
},
|
|
945
|
+
'Skip recalculation when actually no dependency changes'($) {
|
|
946
|
+
const log = [];
|
|
947
|
+
class App extends $mol_object2 {
|
|
948
|
+
static $ = $;
|
|
949
|
+
static xxx(next) {
|
|
950
|
+
log.push('xxx');
|
|
951
|
+
return next || 1;
|
|
952
|
+
}
|
|
953
|
+
static yyy() {
|
|
954
|
+
log.push('yyy');
|
|
955
|
+
return [Math.sign(this.xxx())];
|
|
956
|
+
}
|
|
957
|
+
static zzz() {
|
|
958
|
+
log.push('zzz');
|
|
959
|
+
return this.yyy()[0] + 1;
|
|
960
|
+
}
|
|
961
|
+
static test() {
|
|
962
|
+
App.zzz();
|
|
963
|
+
$mol_assert_like(log, ['zzz', 'yyy', 'xxx']);
|
|
964
|
+
App.xxx(5);
|
|
965
|
+
App.zzz();
|
|
966
|
+
$mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
__decorate([
|
|
970
|
+
$mol_wire_mem(0)
|
|
971
|
+
], App, "xxx", null);
|
|
972
|
+
__decorate([
|
|
973
|
+
$mol_wire_mem(0)
|
|
974
|
+
], App, "yyy", null);
|
|
975
|
+
__decorate([
|
|
976
|
+
$mol_wire_mem(0)
|
|
977
|
+
], App, "zzz", null);
|
|
978
|
+
__decorate([
|
|
979
|
+
$mol_wire_method
|
|
980
|
+
], App, "test", null);
|
|
981
|
+
App.test();
|
|
982
|
+
},
|
|
983
|
+
'Flow: Auto'($) {
|
|
984
|
+
class App extends $mol_object2 {
|
|
985
|
+
static get $() { return $; }
|
|
986
|
+
static first(next = 1) { return next; }
|
|
987
|
+
static second(next = 2) { return next; }
|
|
988
|
+
static condition(next = true) { return next; }
|
|
989
|
+
static counter = 0;
|
|
990
|
+
static result() {
|
|
991
|
+
const res = this.condition() ? this.first() : this.second();
|
|
992
|
+
return res + this.counter++;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
__decorate([
|
|
996
|
+
$mol_wire_mem(0)
|
|
997
|
+
], App, "first", null);
|
|
998
|
+
__decorate([
|
|
999
|
+
$mol_wire_mem(0)
|
|
1000
|
+
], App, "second", null);
|
|
1001
|
+
__decorate([
|
|
1002
|
+
$mol_wire_mem(0)
|
|
1003
|
+
], App, "condition", null);
|
|
1004
|
+
__decorate([
|
|
1005
|
+
$mol_wire_mem(0)
|
|
1006
|
+
], App, "result", null);
|
|
1007
|
+
$mol_assert_equal(App.result(), 1);
|
|
1008
|
+
$mol_assert_equal(App.counter, 1);
|
|
1009
|
+
App.condition(false);
|
|
1010
|
+
$mol_assert_equal(App.result(), 3);
|
|
1011
|
+
$mol_assert_equal(App.counter, 2);
|
|
1012
|
+
App.first(10);
|
|
1013
|
+
$mol_assert_equal(App.result(), 3);
|
|
1014
|
+
$mol_assert_equal(App.counter, 2);
|
|
1015
|
+
},
|
|
1016
|
+
'Dupes: Equality'($) {
|
|
1017
|
+
let counter = 0;
|
|
1018
|
+
class App extends $mol_object2 {
|
|
1019
|
+
static $ = $;
|
|
1020
|
+
static foo(next) {
|
|
1021
|
+
return next ?? { numbs: [1] };
|
|
1022
|
+
}
|
|
1023
|
+
static bar() {
|
|
1024
|
+
return { ...this.foo(), count: ++counter };
|
|
1025
|
+
}
|
|
1026
|
+
static test() {
|
|
1027
|
+
$mol_assert_like(App.bar(), { numbs: [1], count: 1 });
|
|
1028
|
+
App.foo({ numbs: [1] });
|
|
1029
|
+
$mol_assert_like(App.bar(), { numbs: [1], count: 1 });
|
|
1030
|
+
App.foo({ numbs: [2] });
|
|
1031
|
+
$mol_assert_like(App.bar(), { numbs: [2], count: 2 });
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
__decorate([
|
|
1035
|
+
$mol_wire_mem(0)
|
|
1036
|
+
], App, "foo", null);
|
|
1037
|
+
__decorate([
|
|
1038
|
+
$mol_wire_mem(0)
|
|
1039
|
+
], App, "bar", null);
|
|
1040
|
+
__decorate([
|
|
1041
|
+
$mol_wire_method
|
|
1042
|
+
], App, "test", null);
|
|
1043
|
+
App.test();
|
|
1044
|
+
},
|
|
1045
|
+
'Cycle: Fail'($) {
|
|
1046
|
+
class App extends $mol_object2 {
|
|
1047
|
+
static $ = $;
|
|
1048
|
+
static foo() {
|
|
1049
|
+
return this.bar() + 1;
|
|
1050
|
+
}
|
|
1051
|
+
static bar() {
|
|
1052
|
+
return this.foo() + 1;
|
|
1053
|
+
}
|
|
1054
|
+
static test() {
|
|
1055
|
+
$mol_assert_fail(() => App.foo(), 'Circular subscription');
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
__decorate([
|
|
1059
|
+
$mol_wire_mem(0)
|
|
1060
|
+
], App, "foo", null);
|
|
1061
|
+
__decorate([
|
|
1062
|
+
$mol_wire_mem(0)
|
|
1063
|
+
], App, "bar", null);
|
|
1064
|
+
__decorate([
|
|
1065
|
+
$mol_wire_method
|
|
1066
|
+
], App, "test", null);
|
|
1067
|
+
App.test();
|
|
1068
|
+
},
|
|
1069
|
+
'Different order of pull and push'($) {
|
|
1070
|
+
class App extends $mol_object2 {
|
|
1071
|
+
static $ = $;
|
|
1072
|
+
static store(next = 0) {
|
|
1073
|
+
return next;
|
|
1074
|
+
}
|
|
1075
|
+
static fast(next) {
|
|
1076
|
+
return this.store(next);
|
|
1077
|
+
}
|
|
1078
|
+
static slow(next) {
|
|
1079
|
+
return this.store(next);
|
|
1080
|
+
}
|
|
1081
|
+
static test() {
|
|
1082
|
+
App.fast();
|
|
1083
|
+
$mol_assert_equal(App.slow(666), 666);
|
|
1084
|
+
$mol_assert_equal(App.fast(), App.slow(), 666);
|
|
1085
|
+
App.store(777);
|
|
1086
|
+
$mol_assert_equal(App.fast(), App.slow(), 777);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
__decorate([
|
|
1090
|
+
$mol_wire_mem(0)
|
|
1091
|
+
], App, "store", null);
|
|
1092
|
+
__decorate([
|
|
1093
|
+
$mol_wire_mem(0)
|
|
1094
|
+
], App, "fast", null);
|
|
1095
|
+
__decorate([
|
|
1096
|
+
$mol_wire_mem(0)
|
|
1097
|
+
], App, "slow", null);
|
|
1098
|
+
__decorate([
|
|
1099
|
+
$mol_wire_method
|
|
1100
|
+
], App, "test", null);
|
|
1101
|
+
App.test();
|
|
1102
|
+
},
|
|
1103
|
+
'Actions inside invariant'($) {
|
|
1104
|
+
class App extends $mol_object2 {
|
|
1105
|
+
static $ = $;
|
|
1106
|
+
static count(next = 0) {
|
|
1107
|
+
return next;
|
|
1108
|
+
}
|
|
1109
|
+
static count2() {
|
|
1110
|
+
return this.count();
|
|
1111
|
+
}
|
|
1112
|
+
static res() {
|
|
1113
|
+
const count = this.count2();
|
|
1114
|
+
if (!count)
|
|
1115
|
+
this.count(count + 1);
|
|
1116
|
+
return count + 1;
|
|
1117
|
+
}
|
|
1118
|
+
static test() {
|
|
1119
|
+
$mol_assert_like(App.res(), 1);
|
|
1120
|
+
App.count(5);
|
|
1121
|
+
$mol_assert_like(App.res(), 6);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
__decorate([
|
|
1125
|
+
$mol_wire_mem(0)
|
|
1126
|
+
], App, "count", null);
|
|
1127
|
+
__decorate([
|
|
1128
|
+
$mol_wire_mem(0)
|
|
1129
|
+
], App, "count2", null);
|
|
1130
|
+
__decorate([
|
|
1131
|
+
$mol_wire_mem(0)
|
|
1132
|
+
], App, "res", null);
|
|
1133
|
+
__decorate([
|
|
1134
|
+
$mol_wire_method
|
|
1135
|
+
], App, "test", null);
|
|
1136
|
+
App.test();
|
|
1137
|
+
},
|
|
1138
|
+
'Restore after error'($) {
|
|
1139
|
+
class App extends $mol_object2 {
|
|
1140
|
+
static get $() { return $; }
|
|
1141
|
+
static condition(next = false) { return next; }
|
|
1142
|
+
static broken() {
|
|
1143
|
+
if (this.condition()) {
|
|
1144
|
+
$mol_fail(new Error('test error'));
|
|
1145
|
+
}
|
|
1146
|
+
return 1;
|
|
1147
|
+
}
|
|
1148
|
+
static result() {
|
|
1149
|
+
return this.broken();
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
__decorate([
|
|
1153
|
+
$mol_wire_mem(0)
|
|
1154
|
+
], App, "condition", null);
|
|
1155
|
+
__decorate([
|
|
1156
|
+
$mol_wire_mem(0)
|
|
1157
|
+
], App, "broken", null);
|
|
1158
|
+
__decorate([
|
|
1159
|
+
$mol_wire_mem(0)
|
|
1160
|
+
], App, "result", null);
|
|
1161
|
+
$mol_assert_equal(App.result(), 1);
|
|
1162
|
+
App.condition(true);
|
|
1163
|
+
$mol_assert_fail(() => App.result());
|
|
1164
|
+
App.condition(false);
|
|
1165
|
+
$mol_assert_equal(App.result(), 1);
|
|
1166
|
+
},
|
|
1167
|
+
async 'Wait for data'($) {
|
|
1168
|
+
class App extends $mol_object2 {
|
|
1169
|
+
static $ = $;
|
|
1170
|
+
static async source() {
|
|
1171
|
+
return 'Jin';
|
|
1172
|
+
}
|
|
1173
|
+
static middle() {
|
|
1174
|
+
return $mol_wire_sync(this).source();
|
|
1175
|
+
}
|
|
1176
|
+
static target() {
|
|
1177
|
+
return this.middle();
|
|
1178
|
+
}
|
|
1179
|
+
static test() {
|
|
1180
|
+
$mol_assert_equal(App.target(), 'Jin');
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
__decorate([
|
|
1184
|
+
$mol_wire_mem(0)
|
|
1185
|
+
], App, "middle", null);
|
|
1186
|
+
__decorate([
|
|
1187
|
+
$mol_wire_mem(0)
|
|
1188
|
+
], App, "target", null);
|
|
1189
|
+
__decorate([
|
|
1190
|
+
$mol_wire_method
|
|
1191
|
+
], App, "test", null);
|
|
1192
|
+
await $mol_wire_async(App).test();
|
|
1193
|
+
},
|
|
1194
|
+
'Auto destroy on long alone'($) {
|
|
1195
|
+
let destroyed = false;
|
|
1196
|
+
class App extends $mol_object2 {
|
|
1197
|
+
static $ = $;
|
|
1198
|
+
static showing(next = true) {
|
|
1199
|
+
return next;
|
|
1200
|
+
}
|
|
1201
|
+
static details() {
|
|
1202
|
+
return {
|
|
1203
|
+
destructor() {
|
|
1204
|
+
destroyed = true;
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
static render() {
|
|
1209
|
+
return this.showing() ? this.details() : null;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
__decorate([
|
|
1213
|
+
$mol_wire_mem(0)
|
|
1214
|
+
], App, "showing", null);
|
|
1215
|
+
__decorate([
|
|
1216
|
+
$mol_wire_mem(0)
|
|
1217
|
+
], App, "details", null);
|
|
1218
|
+
__decorate([
|
|
1219
|
+
$mol_wire_mem(0)
|
|
1220
|
+
], App, "render", null);
|
|
1221
|
+
const details = App.render();
|
|
1222
|
+
$mol_assert_ok(details);
|
|
1223
|
+
App.showing(false);
|
|
1224
|
+
$mol_assert_not(App.render());
|
|
1225
|
+
App.showing(true);
|
|
1226
|
+
$mol_assert_equal(App.render(), details);
|
|
1227
|
+
$mol_wire_fiber.sync();
|
|
1228
|
+
$mol_assert_not(destroyed);
|
|
1229
|
+
App.showing(false);
|
|
1230
|
+
$mol_wire_fiber.sync();
|
|
1231
|
+
$mol_assert_ok(destroyed);
|
|
1232
|
+
App.showing(true);
|
|
1233
|
+
$mol_assert_unique(App.render(), details);
|
|
1234
|
+
},
|
|
1235
|
+
'Forget sub fibers on complete'($) {
|
|
1236
|
+
class App extends $mol_object2 {
|
|
1237
|
+
static get $() { return $; }
|
|
1238
|
+
static counter = 0;
|
|
1239
|
+
static count() { return this.counter++; }
|
|
1240
|
+
static data(next = 1) { return next; }
|
|
1241
|
+
static result() {
|
|
1242
|
+
return this.count() + this.data();
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
__decorate([
|
|
1246
|
+
$mol_wire_method
|
|
1247
|
+
], App, "count", null);
|
|
1248
|
+
__decorate([
|
|
1249
|
+
$mol_wire_mem(0)
|
|
1250
|
+
], App, "data", null);
|
|
1251
|
+
__decorate([
|
|
1252
|
+
$mol_wire_mem(0)
|
|
1253
|
+
], App, "result", null);
|
|
1254
|
+
$mol_assert_equal(App.result(), 1);
|
|
1255
|
+
App.data(2);
|
|
1256
|
+
$mol_assert_equal(App.result(), 3);
|
|
1257
|
+
},
|
|
1258
|
+
'Memoize by single simple key'($) {
|
|
1259
|
+
class Team extends $mol_object2 {
|
|
1260
|
+
static $ = $;
|
|
1261
|
+
static user_name(user, next) {
|
|
1262
|
+
return next ?? user;
|
|
1263
|
+
}
|
|
1264
|
+
static user_names() {
|
|
1265
|
+
return [
|
|
1266
|
+
this.user_name('jin'),
|
|
1267
|
+
this.user_name('john'),
|
|
1268
|
+
];
|
|
1269
|
+
}
|
|
1270
|
+
static test() {
|
|
1271
|
+
$mol_assert_like(this.user_names(), ['jin', 'john']);
|
|
1272
|
+
Team.user_name('jin', 'JIN');
|
|
1273
|
+
$mol_assert_like(this.user_names(), ['JIN', 'john']);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
__decorate([
|
|
1277
|
+
$mol_wire_mem(1)
|
|
1278
|
+
], Team, "user_name", null);
|
|
1279
|
+
__decorate([
|
|
1280
|
+
$mol_wire_mem(1)
|
|
1281
|
+
], Team, "user_names", null);
|
|
1282
|
+
__decorate([
|
|
1283
|
+
$mol_wire_method
|
|
1284
|
+
], Team, "test", null);
|
|
1285
|
+
Team.test();
|
|
1286
|
+
},
|
|
1287
|
+
'Memoize by single complex key'($) {
|
|
1288
|
+
class Map extends $mol_object2 {
|
|
1289
|
+
static $ = $;
|
|
1290
|
+
static tile(pos) {
|
|
1291
|
+
return new String(`/tile=${pos}`);
|
|
1292
|
+
}
|
|
1293
|
+
static test() {
|
|
1294
|
+
$mol_assert_like(this.tile([0, 1]), new String('/tile=0,1'));
|
|
1295
|
+
$mol_assert_equal(this.tile([0, 1]), this.tile([0, 1]));
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
__decorate([
|
|
1299
|
+
$mol_wire_mem(1)
|
|
1300
|
+
], Map, "tile", null);
|
|
1301
|
+
__decorate([
|
|
1302
|
+
$mol_wire_method
|
|
1303
|
+
], Map, "test", null);
|
|
1304
|
+
Map.test();
|
|
1305
|
+
},
|
|
1306
|
+
'Memoize by multiple keys'($) {
|
|
1307
|
+
class Map extends $mol_object2 {
|
|
1308
|
+
static $ = $;
|
|
1309
|
+
static tile(x, y) {
|
|
1310
|
+
return new String(`/tile=${x},${y}`);
|
|
1311
|
+
}
|
|
1312
|
+
static test() {
|
|
1313
|
+
$mol_assert_like(this.tile(0, 1), new String('/tile=0,1'));
|
|
1314
|
+
$mol_assert_equal(this.tile(0, 1), this.tile(0, 1));
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
__decorate([
|
|
1318
|
+
$mol_wire_mem(2)
|
|
1319
|
+
], Map, "tile", null);
|
|
1320
|
+
__decorate([
|
|
1321
|
+
$mol_wire_method
|
|
1322
|
+
], Map, "test", null);
|
|
1323
|
+
Map.test();
|
|
1324
|
+
},
|
|
1325
|
+
'Owned value has js-path name'() {
|
|
1326
|
+
class App extends $mol_object2 {
|
|
1327
|
+
static title() {
|
|
1328
|
+
return new $mol_object2;
|
|
1329
|
+
}
|
|
1330
|
+
static like(friend) {
|
|
1331
|
+
return new $mol_object2;
|
|
1332
|
+
}
|
|
1333
|
+
static relation(friend, props) {
|
|
1334
|
+
return new $mol_object2;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
__decorate([
|
|
1338
|
+
$mol_wire_mem(0)
|
|
1339
|
+
], App, "title", null);
|
|
1340
|
+
__decorate([
|
|
1341
|
+
$mol_wire_mem(1)
|
|
1342
|
+
], App, "like", null);
|
|
1343
|
+
__decorate([
|
|
1344
|
+
$mol_wire_mem(2)
|
|
1345
|
+
], App, "relation", null);
|
|
1346
|
+
$mol_assert_equal(`${App.title()}`, 'App.title()');
|
|
1347
|
+
$mol_assert_equal(`${App.like(123)}`, 'App.like(123)');
|
|
1348
|
+
$mol_assert_equal(`${App.relation(123, [456])}`, 'App.relation(123,[456])');
|
|
1349
|
+
},
|
|
1350
|
+
'Deep deps'($) {
|
|
1351
|
+
class Fib extends $mol_object2 {
|
|
1352
|
+
static $ = $;
|
|
1353
|
+
static sums = 0;
|
|
1354
|
+
static value(index, next) {
|
|
1355
|
+
if (next)
|
|
1356
|
+
return next;
|
|
1357
|
+
if (index < 2)
|
|
1358
|
+
return 1;
|
|
1359
|
+
++this.sums;
|
|
1360
|
+
return this.value(index - 1) + this.value(index - 2);
|
|
1361
|
+
}
|
|
1362
|
+
static test() {
|
|
1363
|
+
$mol_assert_equal(this.value(4), 5);
|
|
1364
|
+
$mol_assert_equal(this.sums, 3);
|
|
1365
|
+
this.value(1, 2);
|
|
1366
|
+
$mol_assert_equal(this.value(4), 8);
|
|
1367
|
+
$mol_assert_equal(this.sums, 6);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
__decorate([
|
|
1371
|
+
$mol_wire_mem(1)
|
|
1372
|
+
], Fib, "value", null);
|
|
1373
|
+
__decorate([
|
|
1374
|
+
$mol_wire_method
|
|
1375
|
+
], Fib, "test", null);
|
|
1376
|
+
Fib.test();
|
|
1377
|
+
},
|
|
1378
|
+
'Unsubscribe from temp pubs on complete'($) {
|
|
1379
|
+
class Random extends $mol_object2 {
|
|
1380
|
+
static $ = $;
|
|
1381
|
+
static seed() {
|
|
1382
|
+
return Math.random();
|
|
1383
|
+
}
|
|
1384
|
+
static resets(next) {
|
|
1385
|
+
return Math.random();
|
|
1386
|
+
}
|
|
1387
|
+
static value() {
|
|
1388
|
+
this.resets();
|
|
1389
|
+
return this.seed();
|
|
1390
|
+
}
|
|
1391
|
+
static test() {
|
|
1392
|
+
const first = this.value();
|
|
1393
|
+
this.resets(null);
|
|
1394
|
+
const second = this.value();
|
|
1395
|
+
$mol_assert_unique(first, second);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
__decorate([
|
|
1399
|
+
$mol_wire_method
|
|
1400
|
+
], Random, "seed", null);
|
|
1401
|
+
__decorate([
|
|
1402
|
+
$mol_wire_mem(0)
|
|
1403
|
+
], Random, "resets", null);
|
|
1404
|
+
__decorate([
|
|
1405
|
+
$mol_wire_mem(0)
|
|
1406
|
+
], Random, "value", null);
|
|
1407
|
+
__decorate([
|
|
1408
|
+
$mol_wire_method
|
|
1409
|
+
], Random, "test", null);
|
|
1410
|
+
Random.test();
|
|
1411
|
+
},
|
|
595
1412
|
});
|
|
596
1413
|
})($ || ($ = {}));
|
|
597
|
-
//
|
|
1414
|
+
//mol/wire/mem/mem.test.ts
|
|
598
1415
|
;
|
|
599
1416
|
"use strict";
|
|
600
1417
|
var $;
|
|
601
1418
|
(function ($) {
|
|
602
|
-
|
|
1419
|
+
$mol_test({
|
|
603
1420
|
'init with overload'() {
|
|
604
|
-
class X extends
|
|
1421
|
+
class X extends $mol_object {
|
|
605
1422
|
foo() {
|
|
606
1423
|
return 1;
|
|
607
1424
|
}
|
|
@@ -609,45 +1426,57 @@ var $;
|
|
|
609
1426
|
var x = X.make({
|
|
610
1427
|
foo: () => 2,
|
|
611
1428
|
});
|
|
612
|
-
|
|
1429
|
+
$mol_assert_equal(x.foo(), 2);
|
|
613
1430
|
},
|
|
614
1431
|
});
|
|
615
1432
|
})($ || ($ = {}));
|
|
616
|
-
//object.test.
|
|
1433
|
+
//mol/object/object.test.ts
|
|
617
1434
|
;
|
|
618
1435
|
"use strict";
|
|
619
|
-
|
|
1436
|
+
var $;
|
|
1437
|
+
(function ($) {
|
|
1438
|
+
$mol_test({
|
|
1439
|
+
'all cases of using maybe'() {
|
|
1440
|
+
$mol_assert_equal($mol_maybe(0)[0], 0);
|
|
1441
|
+
$mol_assert_equal($mol_maybe(false)[0], false);
|
|
1442
|
+
$mol_assert_equal($mol_maybe(null)[0], void 0);
|
|
1443
|
+
$mol_assert_equal($mol_maybe(void 0)[0], void 0);
|
|
1444
|
+
$mol_assert_equal($mol_maybe(void 0).map(v => v.toString())[0], void 0);
|
|
1445
|
+
$mol_assert_equal($mol_maybe(0).map(v => v.toString())[0], '0');
|
|
1446
|
+
},
|
|
1447
|
+
});
|
|
1448
|
+
})($ || ($ = {}));
|
|
1449
|
+
//mol/maybe/maybe.test.ts
|
|
620
1450
|
;
|
|
621
1451
|
"use strict";
|
|
622
1452
|
var $;
|
|
623
|
-
(function ($
|
|
624
|
-
$
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
$.$mol_log3_area = () => () => { };
|
|
1453
|
+
(function ($) {
|
|
1454
|
+
$mol_test({
|
|
1455
|
+
'const returns stored value'() {
|
|
1456
|
+
const foo = { bar: $mol_const(Math.random()) };
|
|
1457
|
+
$mol_assert_equal(foo.bar(), foo.bar());
|
|
1458
|
+
$mol_assert_equal(foo.bar(), foo.bar['()']);
|
|
1459
|
+
},
|
|
631
1460
|
});
|
|
632
1461
|
})($ || ($ = {}));
|
|
633
|
-
//
|
|
1462
|
+
//mol/const/const.test.ts
|
|
634
1463
|
;
|
|
635
1464
|
"use strict";
|
|
636
1465
|
var $;
|
|
637
1466
|
(function ($) {
|
|
638
|
-
|
|
1467
|
+
$mol_test({
|
|
639
1468
|
'run callback'() {
|
|
640
|
-
class Plus1 extends
|
|
1469
|
+
class Plus1 extends $mol_wrapper {
|
|
641
1470
|
static wrap(task) {
|
|
642
1471
|
return function (...args) {
|
|
643
1472
|
return task.call(this, ...args) + 1;
|
|
644
1473
|
};
|
|
645
1474
|
}
|
|
646
1475
|
}
|
|
647
|
-
|
|
1476
|
+
$mol_assert_equal(Plus1.run(() => 2), 3);
|
|
648
1477
|
},
|
|
649
1478
|
'wrap function'() {
|
|
650
|
-
class Plus1 extends
|
|
1479
|
+
class Plus1 extends $mol_wrapper {
|
|
651
1480
|
static wrap(task) {
|
|
652
1481
|
return function (...args) {
|
|
653
1482
|
return task.call(this, ...args) + 1;
|
|
@@ -660,10 +1489,10 @@ var $;
|
|
|
660
1489
|
return a ** this.level;
|
|
661
1490
|
})
|
|
662
1491
|
};
|
|
663
|
-
|
|
1492
|
+
$mol_assert_equal(obj.pow(2), 5);
|
|
664
1493
|
},
|
|
665
1494
|
'decorate field getter'() {
|
|
666
|
-
class Plus1 extends
|
|
1495
|
+
class Plus1 extends $mol_wrapper {
|
|
667
1496
|
static last = 0;
|
|
668
1497
|
static wrap(task) {
|
|
669
1498
|
return function (...args) {
|
|
@@ -680,13 +1509,13 @@ var $;
|
|
|
680
1509
|
__decorate([
|
|
681
1510
|
Plus1.field
|
|
682
1511
|
], Foo, "two", null);
|
|
683
|
-
|
|
1512
|
+
$mol_assert_equal(Foo.two, 2);
|
|
684
1513
|
Foo.two = 3;
|
|
685
|
-
|
|
686
|
-
|
|
1514
|
+
$mol_assert_equal(Plus1.last, 2);
|
|
1515
|
+
$mol_assert_equal(Foo.two, 2);
|
|
687
1516
|
},
|
|
688
1517
|
'decorate instance method'() {
|
|
689
|
-
class Plus1 extends
|
|
1518
|
+
class Plus1 extends $mol_wrapper {
|
|
690
1519
|
static wrap(task) {
|
|
691
1520
|
return function (...args) {
|
|
692
1521
|
return task.call(this, ...args) + 1;
|
|
@@ -704,10 +1533,10 @@ var $;
|
|
|
704
1533
|
], Foo1.prototype, "pow", null);
|
|
705
1534
|
const Foo2 = Foo1;
|
|
706
1535
|
const foo = new Foo2;
|
|
707
|
-
|
|
1536
|
+
$mol_assert_equal(foo.pow(2), 5);
|
|
708
1537
|
},
|
|
709
1538
|
'decorate static method'() {
|
|
710
|
-
class Plus1 extends
|
|
1539
|
+
class Plus1 extends $mol_wrapper {
|
|
711
1540
|
static wrap(task) {
|
|
712
1541
|
return function (...args) {
|
|
713
1542
|
return task.call(this, ...args) + 1;
|
|
@@ -723,10 +1552,10 @@ var $;
|
|
|
723
1552
|
__decorate([
|
|
724
1553
|
Plus1.method
|
|
725
1554
|
], Foo, "pow", null);
|
|
726
|
-
|
|
1555
|
+
$mol_assert_equal(Foo.pow(2), 5);
|
|
727
1556
|
},
|
|
728
1557
|
'decorate class'() {
|
|
729
|
-
class BarInc extends
|
|
1558
|
+
class BarInc extends $mol_wrapper {
|
|
730
1559
|
static wrap(task) {
|
|
731
1560
|
return function (...args) {
|
|
732
1561
|
const foo = task.call(this, ...args);
|
|
@@ -744,416 +1573,16 @@ var $;
|
|
|
744
1573
|
Foo = __decorate([
|
|
745
1574
|
BarInc.class
|
|
746
1575
|
], Foo);
|
|
747
|
-
|
|
748
|
-
},
|
|
749
|
-
});
|
|
750
|
-
})($ || ($ = {}));
|
|
751
|
-
//wrapper.test.js.map
|
|
752
|
-
;
|
|
753
|
-
"use strict";
|
|
754
|
-
var $;
|
|
755
|
-
(function ($_1) {
|
|
756
|
-
$_1.$mol_test_mocks.push($ => {
|
|
757
|
-
$.$mol_after_frame = $_1.$mol_after_mock_commmon;
|
|
758
|
-
});
|
|
759
|
-
})($ || ($ = {}));
|
|
760
|
-
//frame.test.js.map
|
|
761
|
-
;
|
|
762
|
-
"use strict";
|
|
763
|
-
var $;
|
|
764
|
-
(function ($) {
|
|
765
|
-
$.$mol_test({
|
|
766
|
-
'trim array'() {
|
|
767
|
-
const array = [undefined, null, 0, false, null, undefined, undefined];
|
|
768
|
-
const correct = [undefined, null, 0, false, null];
|
|
769
|
-
$.$mol_array_trim(array);
|
|
770
|
-
$.$mol_assert_like(array, correct);
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
})($ || ($ = {}));
|
|
774
|
-
//trim.test.js.map
|
|
775
|
-
;
|
|
776
|
-
"use strict";
|
|
777
|
-
var $;
|
|
778
|
-
(function ($_1) {
|
|
779
|
-
$_1.$mol_test_mocks.push(async ($) => {
|
|
780
|
-
await $_1.$mol_fiber_warp();
|
|
781
|
-
$_1.$mol_fiber.deadline = Date.now() + 100;
|
|
782
|
-
});
|
|
783
|
-
$_1.$mol_test({
|
|
784
|
-
'sync to async': async ($) => {
|
|
785
|
-
const sum = $_1.$mol_fiber_async((a, b) => a + b);
|
|
786
|
-
const res = await sum(1, 2);
|
|
787
|
-
$_1.$mol_assert_equal(res, 3);
|
|
788
|
-
},
|
|
789
|
-
});
|
|
790
|
-
})($ || ($ = {}));
|
|
791
|
-
//fiber.test.js.map
|
|
792
|
-
;
|
|
793
|
-
"use strict";
|
|
794
|
-
var $;
|
|
795
|
-
(function ($) {
|
|
796
|
-
class $mol_defer extends $.$mol_object {
|
|
797
|
-
run;
|
|
798
|
-
constructor(run) {
|
|
799
|
-
super();
|
|
800
|
-
this.run = run;
|
|
801
|
-
$mol_defer.add(this);
|
|
802
|
-
}
|
|
803
|
-
destructor() {
|
|
804
|
-
$mol_defer.drop(this);
|
|
805
|
-
}
|
|
806
|
-
static all = [];
|
|
807
|
-
static timer = null;
|
|
808
|
-
static scheduleNative = (typeof requestAnimationFrame == 'function')
|
|
809
|
-
? handler => requestAnimationFrame(handler)
|
|
810
|
-
: handler => setTimeout(handler, 16);
|
|
811
|
-
static schedule() {
|
|
812
|
-
if (this.timer)
|
|
813
|
-
return;
|
|
814
|
-
this.timer = this.scheduleNative(() => {
|
|
815
|
-
this.timer = null;
|
|
816
|
-
this.run();
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
static unschedule() {
|
|
820
|
-
if (!this.timer)
|
|
821
|
-
return;
|
|
822
|
-
cancelAnimationFrame(this.timer);
|
|
823
|
-
this.timer = null;
|
|
824
|
-
}
|
|
825
|
-
static add(defer) {
|
|
826
|
-
this.all.push(defer);
|
|
827
|
-
this.schedule();
|
|
828
|
-
}
|
|
829
|
-
static drop(defer) {
|
|
830
|
-
var index = this.all.indexOf(defer);
|
|
831
|
-
if (index >= 0)
|
|
832
|
-
this.all.splice(index, 1);
|
|
833
|
-
}
|
|
834
|
-
static run() {
|
|
835
|
-
if (this.all.length === 0)
|
|
836
|
-
return;
|
|
837
|
-
this.schedule();
|
|
838
|
-
for (var defer; defer = this.all.shift();)
|
|
839
|
-
defer.run();
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
$.$mol_defer = $mol_defer;
|
|
843
|
-
})($ || ($ = {}));
|
|
844
|
-
//defer.js.map
|
|
845
|
-
;
|
|
846
|
-
"use strict";
|
|
847
|
-
//atom2.test.js.map
|
|
848
|
-
;
|
|
849
|
-
"use strict";
|
|
850
|
-
//param.test.js.map
|
|
851
|
-
;
|
|
852
|
-
"use strict";
|
|
853
|
-
//result.test.js.map
|
|
854
|
-
;
|
|
855
|
-
"use strict";
|
|
856
|
-
var $;
|
|
857
|
-
(function ($_1) {
|
|
858
|
-
$_1.$mol_test({
|
|
859
|
-
'Property method'($) {
|
|
860
|
-
class App extends $_1.$mol_object2 {
|
|
861
|
-
static $ = $;
|
|
862
|
-
static value(next = 1) { return next + 1; }
|
|
863
|
-
}
|
|
864
|
-
__decorate([
|
|
865
|
-
$_1.$mol_mem
|
|
866
|
-
], App, "value", null);
|
|
867
|
-
$_1.$mol_assert_equal(App.value(), 2);
|
|
868
|
-
App.value(2);
|
|
869
|
-
$_1.$mol_assert_equal(App.value(), 3);
|
|
870
|
-
},
|
|
871
|
-
'auto sync of properties'($) {
|
|
872
|
-
class X extends $_1.$mol_object2 {
|
|
873
|
-
foo(next) {
|
|
874
|
-
return next || 1;
|
|
875
|
-
}
|
|
876
|
-
bar() {
|
|
877
|
-
return this.foo() + 1;
|
|
878
|
-
}
|
|
879
|
-
xxx() {
|
|
880
|
-
return this.bar() + 1;
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
__decorate([
|
|
884
|
-
$_1.$mol_mem
|
|
885
|
-
], X.prototype, "foo", null);
|
|
886
|
-
__decorate([
|
|
887
|
-
$_1.$mol_mem
|
|
888
|
-
], X.prototype, "bar", null);
|
|
889
|
-
__decorate([
|
|
890
|
-
$_1.$mol_mem
|
|
891
|
-
], X.prototype, "xxx", null);
|
|
892
|
-
const x = new X;
|
|
893
|
-
x.$ = $;
|
|
894
|
-
$_1.$mol_assert_equal(x.bar(), 2);
|
|
895
|
-
$_1.$mol_assert_equal(x.xxx(), 3);
|
|
896
|
-
x.foo(5);
|
|
897
|
-
$_1.$mol_assert_equal(x.xxx(), 7);
|
|
898
|
-
},
|
|
899
|
-
async 'must be deferred destroyed when no longer referenced'($) {
|
|
900
|
-
let foo;
|
|
901
|
-
let foo_destroyed = false;
|
|
902
|
-
class B extends $_1.$mol_object2 {
|
|
903
|
-
showing(next) {
|
|
904
|
-
if (next === void 0)
|
|
905
|
-
return true;
|
|
906
|
-
return next;
|
|
907
|
-
}
|
|
908
|
-
foo() {
|
|
909
|
-
return foo = new class extends $_1.$mol_object {
|
|
910
|
-
destructor() {
|
|
911
|
-
foo_destroyed = true;
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
bar() {
|
|
916
|
-
return this.showing() ? this.foo() : null;
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
__decorate([
|
|
920
|
-
$_1.$mol_mem
|
|
921
|
-
], B.prototype, "showing", null);
|
|
922
|
-
__decorate([
|
|
923
|
-
$_1.$mol_mem
|
|
924
|
-
], B.prototype, "foo", null);
|
|
925
|
-
__decorate([
|
|
926
|
-
$_1.$mol_mem
|
|
927
|
-
], B.prototype, "bar", null);
|
|
928
|
-
var b = new B;
|
|
929
|
-
b.$ = $;
|
|
930
|
-
var bar = b.bar();
|
|
931
|
-
$_1.$mol_assert_ok(bar);
|
|
932
|
-
b.showing(false);
|
|
933
|
-
b.bar();
|
|
934
|
-
await $_1.$mol_fiber_warp();
|
|
935
|
-
$_1.$mol_assert_ok(foo_destroyed);
|
|
936
|
-
$_1.$mol_assert_not(b.bar());
|
|
937
|
-
b.showing(true);
|
|
938
|
-
$_1.$mol_defer.run();
|
|
939
|
-
$_1.$mol_assert_unique(b.bar(), bar);
|
|
940
|
-
},
|
|
941
|
-
async 'wait for data'($) {
|
|
942
|
-
class Test extends $_1.$mol_object2 {
|
|
943
|
-
source() {
|
|
944
|
-
return $_1.$mol_fiber_sync(() => new Promise(done => done('Jin')))();
|
|
945
|
-
}
|
|
946
|
-
middle() {
|
|
947
|
-
return this.source();
|
|
948
|
-
}
|
|
949
|
-
target() {
|
|
950
|
-
return this.middle();
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
__decorate([
|
|
954
|
-
$_1.$mol_mem
|
|
955
|
-
], Test.prototype, "source", null);
|
|
956
|
-
__decorate([
|
|
957
|
-
$_1.$mol_mem
|
|
958
|
-
], Test.prototype, "middle", null);
|
|
959
|
-
__decorate([
|
|
960
|
-
$_1.$mol_mem
|
|
961
|
-
], Test.prototype, "target", null);
|
|
962
|
-
const t = new Test;
|
|
963
|
-
t.$ = $;
|
|
964
|
-
$_1.$mol_assert_fail(() => t.target().valueOf(), Promise);
|
|
965
|
-
await $_1.$mol_fiber_warp();
|
|
966
|
-
$_1.$mol_assert_equal(t.target(), 'Jin');
|
|
967
|
-
},
|
|
968
|
-
});
|
|
969
|
-
})($ || ($ = {}));
|
|
970
|
-
//mem.test.js.map
|
|
971
|
-
;
|
|
972
|
-
"use strict";
|
|
973
|
-
var $;
|
|
974
|
-
(function ($) {
|
|
975
|
-
$.$mol_test({
|
|
976
|
-
'Primitives'() {
|
|
977
|
-
$.$mol_assert_equal($.$mol_key(null), 'null');
|
|
978
|
-
$.$mol_assert_equal($.$mol_key(false), 'false');
|
|
979
|
-
$.$mol_assert_equal($.$mol_key(true), 'true');
|
|
980
|
-
$.$mol_assert_equal($.$mol_key(0), '0');
|
|
981
|
-
$.$mol_assert_equal($.$mol_key(''), '""');
|
|
982
|
-
},
|
|
983
|
-
'Array & POJO'() {
|
|
984
|
-
$.$mol_assert_equal($.$mol_key([null]), '[null]');
|
|
985
|
-
$.$mol_assert_equal($.$mol_key({ foo: 0 }), '{"foo":0}');
|
|
986
|
-
$.$mol_assert_equal($.$mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
987
|
-
},
|
|
988
|
-
'Function'() {
|
|
989
|
-
const func = () => { };
|
|
990
|
-
$.$mol_assert_equal($.$mol_key(func), $.$mol_key(func));
|
|
991
|
-
$.$mol_assert_unique($.$mol_key(func), $.$mol_key(() => { }));
|
|
992
|
-
},
|
|
993
|
-
'Objects'() {
|
|
994
|
-
class User {
|
|
995
|
-
}
|
|
996
|
-
const jin = new User();
|
|
997
|
-
$.$mol_assert_equal($.$mol_key(jin), $.$mol_key(jin));
|
|
998
|
-
$.$mol_assert_unique($.$mol_key(jin), $.$mol_key(new User()));
|
|
999
|
-
},
|
|
1000
|
-
'Elements'() {
|
|
1001
|
-
const foo = $.$mol_jsx("div", null, "bar");
|
|
1002
|
-
$.$mol_assert_equal($.$mol_key(foo), $.$mol_key(foo));
|
|
1003
|
-
$.$mol_assert_unique($.$mol_key(foo), $.$mol_key($.$mol_jsx("div", null, "bar")));
|
|
1004
|
-
},
|
|
1005
|
-
'Custom JSON representation'() {
|
|
1006
|
-
class User {
|
|
1007
|
-
name;
|
|
1008
|
-
age;
|
|
1009
|
-
constructor(name, age) {
|
|
1010
|
-
this.name = name;
|
|
1011
|
-
this.age = age;
|
|
1012
|
-
}
|
|
1013
|
-
toJSON() { return { name: this.name }; }
|
|
1014
|
-
}
|
|
1015
|
-
$.$mol_assert_equal($.$mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
1016
|
-
},
|
|
1017
|
-
'Special native classes'() {
|
|
1018
|
-
$.$mol_assert_equal($.$mol_key(new Date('xyz')), 'null');
|
|
1019
|
-
$.$mol_assert_equal($.$mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
1020
|
-
$.$mol_assert_equal($.$mol_key(/./), '"/./"');
|
|
1021
|
-
$.$mol_assert_equal($.$mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
1022
|
-
},
|
|
1023
|
-
});
|
|
1024
|
-
})($ || ($ = {}));
|
|
1025
|
-
//key.test.js.map
|
|
1026
|
-
;
|
|
1027
|
-
"use strict";
|
|
1028
|
-
var $;
|
|
1029
|
-
(function ($_1) {
|
|
1030
|
-
$_1.$mol_test({
|
|
1031
|
-
'keyed reactive properties'($) {
|
|
1032
|
-
$_1.$mol_fiber_warp();
|
|
1033
|
-
class Fib extends $_1.$mol_object2 {
|
|
1034
|
-
static $ = $;
|
|
1035
|
-
static value(index, next) {
|
|
1036
|
-
if (next)
|
|
1037
|
-
return next;
|
|
1038
|
-
if (index < 2)
|
|
1039
|
-
return 1;
|
|
1040
|
-
return this.value(index - 1) + this.value(index - 2);
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
__decorate([
|
|
1044
|
-
$_1.$mol_mem_key
|
|
1045
|
-
], Fib, "value", null);
|
|
1046
|
-
$_1.$mol_assert_equal(Fib.value(10), 89);
|
|
1047
|
-
Fib.value(1, 2);
|
|
1048
|
-
$_1.$mol_assert_equal(Fib.value(10), 144);
|
|
1049
|
-
},
|
|
1050
|
-
'cached property with simple key'($) {
|
|
1051
|
-
class X extends $_1.$mol_object2 {
|
|
1052
|
-
foo(id, next) {
|
|
1053
|
-
if (next == null)
|
|
1054
|
-
return new Number(123);
|
|
1055
|
-
return new Number(next);
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
__decorate([
|
|
1059
|
-
$_1.$mol_mem_key
|
|
1060
|
-
], X.prototype, "foo", null);
|
|
1061
|
-
const x = new X;
|
|
1062
|
-
x.$ = $;
|
|
1063
|
-
$_1.$mol_assert_equal(x.foo(0).valueOf(), 123);
|
|
1064
|
-
$_1.$mol_assert_equal(x.foo(0), x.foo(0));
|
|
1065
|
-
$_1.$mol_assert_unique(x.foo(0), x.foo(1));
|
|
1066
|
-
x.foo(0, 321);
|
|
1067
|
-
$_1.$mol_assert_equal(x.foo(0).valueOf(), 321);
|
|
1068
|
-
x.foo(0, null);
|
|
1069
|
-
$_1.$mol_assert_equal(x.foo(0).valueOf(), 123);
|
|
1070
|
-
},
|
|
1071
|
-
'cached property with complex key'($) {
|
|
1072
|
-
class X extends $_1.$mol_object2 {
|
|
1073
|
-
foo(ids) {
|
|
1074
|
-
return Math.random();
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
__decorate([
|
|
1078
|
-
$_1.$mol_mem_key
|
|
1079
|
-
], X.prototype, "foo", null);
|
|
1080
|
-
const x = new X;
|
|
1081
|
-
x.$ = $;
|
|
1082
|
-
$_1.$mol_assert_equal(x.foo([0, 1]), x.foo([0, 1]));
|
|
1083
|
-
$_1.$mol_assert_unique(x.foo([0, 1]), x.foo([0, 2]));
|
|
1084
|
-
},
|
|
1085
|
-
});
|
|
1086
|
-
})($ || ($ = {}));
|
|
1087
|
-
//key.test.js.map
|
|
1088
|
-
;
|
|
1089
|
-
"use strict";
|
|
1090
|
-
var $;
|
|
1091
|
-
(function ($_1) {
|
|
1092
|
-
$_1.$mol_test({
|
|
1093
|
-
async 'Autorun'($) {
|
|
1094
|
-
class App extends $_1.$mol_object2 {
|
|
1095
|
-
static $ = $;
|
|
1096
|
-
static state(next = 1) { return next; }
|
|
1097
|
-
static counter = 0;
|
|
1098
|
-
static init() {
|
|
1099
|
-
++this.counter;
|
|
1100
|
-
return this.state();
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
__decorate([
|
|
1104
|
-
$_1.$mol_mem
|
|
1105
|
-
], App, "state", null);
|
|
1106
|
-
__decorate([
|
|
1107
|
-
$_1.$mol_mem
|
|
1108
|
-
], App, "init", null);
|
|
1109
|
-
const autorun = $_1.$mol_atom2_autorun(() => App.init());
|
|
1110
|
-
autorun.$ = $;
|
|
1111
|
-
try {
|
|
1112
|
-
await $_1.$mol_fiber_warp();
|
|
1113
|
-
$_1.$mol_assert_equal(App.counter, 1);
|
|
1114
|
-
App.state(2);
|
|
1115
|
-
$_1.$mol_assert_equal(App.counter, 1);
|
|
1116
|
-
await $_1.$mol_fiber_warp();
|
|
1117
|
-
$_1.$mol_assert_equal(App.counter, 2);
|
|
1118
|
-
App.state(3);
|
|
1119
|
-
}
|
|
1120
|
-
finally {
|
|
1121
|
-
autorun.destructor();
|
|
1122
|
-
}
|
|
1123
|
-
App.state(4);
|
|
1124
|
-
await $_1.$mol_fiber_warp();
|
|
1125
|
-
$_1.$mol_assert_equal(App.counter, 2);
|
|
1126
|
-
},
|
|
1127
|
-
});
|
|
1128
|
-
})($ || ($ = {}));
|
|
1129
|
-
//autorun.test.js.map
|
|
1130
|
-
;
|
|
1131
|
-
"use strict";
|
|
1132
|
-
var $;
|
|
1133
|
-
(function ($_1) {
|
|
1134
|
-
$_1.$mol_test_mocks.push($ => {
|
|
1135
|
-
$.$mol_after_timeout = $_1.$mol_after_mock_timeout;
|
|
1136
|
-
});
|
|
1137
|
-
})($ || ($ = {}));
|
|
1138
|
-
//timeout.test.js.map
|
|
1139
|
-
;
|
|
1140
|
-
"use strict";
|
|
1141
|
-
var $;
|
|
1142
|
-
(function ($) {
|
|
1143
|
-
$.$mol_test({
|
|
1144
|
-
'const returns stored value'() {
|
|
1145
|
-
const foo = { bar: $.$mol_const(Math.random()) };
|
|
1146
|
-
$.$mol_assert_equal(foo.bar(), foo.bar());
|
|
1147
|
-
$.$mol_assert_equal(foo.bar(), foo.bar['()']);
|
|
1576
|
+
$mol_assert_equal(new Foo(2).bar, 3);
|
|
1148
1577
|
},
|
|
1149
1578
|
});
|
|
1150
1579
|
})($ || ($ = {}));
|
|
1151
|
-
//
|
|
1580
|
+
//mol/wrapper/wrapper.test.ts
|
|
1152
1581
|
;
|
|
1153
1582
|
"use strict";
|
|
1154
1583
|
var $;
|
|
1155
1584
|
(function ($) {
|
|
1156
|
-
|
|
1585
|
+
$mol_test({
|
|
1157
1586
|
'memoize field'() {
|
|
1158
1587
|
class Foo {
|
|
1159
1588
|
static one = 1;
|
|
@@ -1163,60 +1592,77 @@ var $;
|
|
|
1163
1592
|
static set two(next) { }
|
|
1164
1593
|
}
|
|
1165
1594
|
__decorate([
|
|
1166
|
-
|
|
1595
|
+
$mol_memo.field
|
|
1167
1596
|
], Foo, "two", null);
|
|
1168
|
-
|
|
1169
|
-
|
|
1597
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1598
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1170
1599
|
Foo.two = 3;
|
|
1171
|
-
|
|
1172
|
-
|
|
1600
|
+
$mol_assert_equal(Foo.two, 3);
|
|
1601
|
+
$mol_assert_equal(Foo.two, 3);
|
|
1173
1602
|
},
|
|
1174
1603
|
});
|
|
1175
1604
|
})($ || ($ = {}));
|
|
1176
|
-
//memo.test.
|
|
1605
|
+
//mol/memo/memo.test.ts
|
|
1177
1606
|
;
|
|
1178
1607
|
"use strict";
|
|
1179
1608
|
var $;
|
|
1180
1609
|
(function ($_1) {
|
|
1181
|
-
$
|
|
1610
|
+
$mol_test({
|
|
1182
1611
|
'FQN of anon function'($) {
|
|
1183
1612
|
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
1184
|
-
$
|
|
1185
|
-
$
|
|
1186
|
-
$
|
|
1613
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
1614
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
1615
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
1187
1616
|
},
|
|
1188
1617
|
});
|
|
1189
1618
|
})($ || ($ = {}));
|
|
1190
|
-
//name.test.
|
|
1619
|
+
//mol/func/name/name.test.ts
|
|
1620
|
+
;
|
|
1621
|
+
"use strict";
|
|
1622
|
+
//mol/type/keys/extract/extract.test.ts
|
|
1623
|
+
;
|
|
1624
|
+
"use strict";
|
|
1625
|
+
var $;
|
|
1626
|
+
(function ($_1) {
|
|
1627
|
+
$mol_test_mocks.push($ => {
|
|
1628
|
+
$.$mol_log3_come = () => { };
|
|
1629
|
+
$.$mol_log3_done = () => { };
|
|
1630
|
+
$.$mol_log3_fail = () => { };
|
|
1631
|
+
$.$mol_log3_warn = () => { };
|
|
1632
|
+
$.$mol_log3_rise = () => { };
|
|
1633
|
+
$.$mol_log3_area = () => () => { };
|
|
1634
|
+
});
|
|
1635
|
+
})($ || ($ = {}));
|
|
1636
|
+
//mol/log3/log3.test.ts
|
|
1191
1637
|
;
|
|
1192
1638
|
"use strict";
|
|
1193
1639
|
var $;
|
|
1194
1640
|
(function ($_1) {
|
|
1195
|
-
$
|
|
1641
|
+
$mol_test({
|
|
1196
1642
|
'id auto generation'($) {
|
|
1197
|
-
class $mol_view_test_item extends $
|
|
1643
|
+
class $mol_view_test_item extends $mol_view {
|
|
1198
1644
|
}
|
|
1199
|
-
class $mol_view_test_block extends $
|
|
1645
|
+
class $mol_view_test_block extends $mol_view {
|
|
1200
1646
|
static $ = $;
|
|
1201
1647
|
element(id) {
|
|
1202
1648
|
return new $mol_view_test_item();
|
|
1203
1649
|
}
|
|
1204
1650
|
}
|
|
1205
1651
|
__decorate([
|
|
1206
|
-
$
|
|
1652
|
+
$mol_mem_key
|
|
1207
1653
|
], $mol_view_test_block.prototype, "element", null);
|
|
1208
1654
|
var x = $mol_view_test_block.Root(0);
|
|
1209
|
-
$
|
|
1210
|
-
$
|
|
1655
|
+
$mol_assert_equal(x.dom_node().id, '$mol_view_test_block.Root(0)');
|
|
1656
|
+
$mol_assert_equal(x.element(0).dom_node().id, '$mol_view_test_block.Root(0).element(0)');
|
|
1211
1657
|
},
|
|
1212
1658
|
'caching ref to dom node'($) {
|
|
1213
|
-
var x = new class extends $
|
|
1659
|
+
var x = new class extends $mol_view {
|
|
1214
1660
|
};
|
|
1215
1661
|
x.$ = $;
|
|
1216
|
-
$
|
|
1662
|
+
$mol_assert_equal(x.dom_node(), x.dom_node());
|
|
1217
1663
|
},
|
|
1218
1664
|
'content render'($) {
|
|
1219
|
-
class $mol_view_test extends $
|
|
1665
|
+
class $mol_view_test extends $mol_view {
|
|
1220
1666
|
sub() {
|
|
1221
1667
|
return ['lol', 5];
|
|
1222
1668
|
}
|
|
@@ -1224,29 +1670,29 @@ var $;
|
|
|
1224
1670
|
var x = new $mol_view_test();
|
|
1225
1671
|
x.$ = $;
|
|
1226
1672
|
var node = x.dom_tree();
|
|
1227
|
-
$
|
|
1673
|
+
$mol_assert_equal(node.innerHTML, 'lol5');
|
|
1228
1674
|
},
|
|
1229
1675
|
'bem attributes generation'($) {
|
|
1230
|
-
class $mol_view_test_item extends $
|
|
1676
|
+
class $mol_view_test_item extends $mol_view {
|
|
1231
1677
|
}
|
|
1232
|
-
class $mol_view_test_block extends $
|
|
1678
|
+
class $mol_view_test_block extends $mol_view {
|
|
1233
1679
|
Element(id) {
|
|
1234
1680
|
return new $mol_view_test_item();
|
|
1235
1681
|
}
|
|
1236
1682
|
}
|
|
1237
1683
|
__decorate([
|
|
1238
|
-
$
|
|
1684
|
+
$mol_mem_key
|
|
1239
1685
|
], $mol_view_test_block.prototype, "Element", null);
|
|
1240
1686
|
var x = new $mol_view_test_block();
|
|
1241
1687
|
x.$ = $;
|
|
1242
|
-
$
|
|
1243
|
-
$
|
|
1244
|
-
$
|
|
1245
|
-
$
|
|
1246
|
-
$
|
|
1688
|
+
$mol_assert_equal(x.dom_node().getAttribute('mol_view_test_block'), '');
|
|
1689
|
+
$mol_assert_equal(x.dom_node().getAttribute('mol_view'), '');
|
|
1690
|
+
$mol_assert_equal(x.Element(0).dom_node().getAttribute('mol_view_test_block_element'), '');
|
|
1691
|
+
$mol_assert_equal(x.Element(0).dom_node().getAttribute('mol_view_test_item'), '');
|
|
1692
|
+
$mol_assert_equal(x.Element(0).dom_node().getAttribute('mol_view'), '');
|
|
1247
1693
|
},
|
|
1248
1694
|
'render custom attributes'($) {
|
|
1249
|
-
class $mol_view_test extends $
|
|
1695
|
+
class $mol_view_test extends $mol_view {
|
|
1250
1696
|
attr() {
|
|
1251
1697
|
return {
|
|
1252
1698
|
'href': '#haha',
|
|
@@ -1258,12 +1704,12 @@ var $;
|
|
|
1258
1704
|
var x = new $mol_view_test();
|
|
1259
1705
|
x.$ = $;
|
|
1260
1706
|
var node = x.dom_tree();
|
|
1261
|
-
$
|
|
1262
|
-
$
|
|
1263
|
-
$
|
|
1707
|
+
$mol_assert_equal(node.getAttribute('href'), '#haha');
|
|
1708
|
+
$mol_assert_equal(node.getAttribute('required'), 'true');
|
|
1709
|
+
$mol_assert_equal(node.getAttribute('hidden'), null);
|
|
1264
1710
|
},
|
|
1265
1711
|
'render custom fields'($) {
|
|
1266
|
-
class $mol_view_test extends $
|
|
1712
|
+
class $mol_view_test extends $mol_view {
|
|
1267
1713
|
field() {
|
|
1268
1714
|
return {
|
|
1269
1715
|
'hidden': true
|
|
@@ -1273,11 +1719,11 @@ var $;
|
|
|
1273
1719
|
var x = new $mol_view_test();
|
|
1274
1720
|
x.$ = $;
|
|
1275
1721
|
var node = x.dom_tree();
|
|
1276
|
-
$
|
|
1722
|
+
$mol_assert_equal(node.hidden, true);
|
|
1277
1723
|
},
|
|
1278
1724
|
'attach event handlers'($) {
|
|
1279
1725
|
var clicked = false;
|
|
1280
|
-
class $mol_view_test extends $
|
|
1726
|
+
class $mol_view_test extends $mol_view {
|
|
1281
1727
|
event() {
|
|
1282
1728
|
return {
|
|
1283
1729
|
'click': (next) => this.event_click(next)
|
|
@@ -1291,121 +1737,130 @@ var $;
|
|
|
1291
1737
|
x.$ = $;
|
|
1292
1738
|
var node = x.dom_node();
|
|
1293
1739
|
node.click();
|
|
1294
|
-
$
|
|
1740
|
+
$mol_assert_ok(clicked);
|
|
1295
1741
|
},
|
|
1296
1742
|
});
|
|
1297
1743
|
})($ || ($ = {}));
|
|
1298
|
-
//view.test.
|
|
1744
|
+
//mol/view/view/view.test.ts
|
|
1745
|
+
;
|
|
1746
|
+
"use strict";
|
|
1747
|
+
var $;
|
|
1748
|
+
(function ($_1) {
|
|
1749
|
+
$mol_test_mocks.push($ => {
|
|
1750
|
+
$.$mol_after_work = $mol_after_mock_timeout;
|
|
1751
|
+
});
|
|
1752
|
+
})($ || ($ = {}));
|
|
1753
|
+
//mol/after/work/work.test.ts
|
|
1299
1754
|
;
|
|
1300
1755
|
"use strict";
|
|
1301
1756
|
var $;
|
|
1302
1757
|
(function ($_1) {
|
|
1303
|
-
$
|
|
1304
|
-
$.$
|
|
1758
|
+
$mol_test_mocks.push($ => {
|
|
1759
|
+
$.$mol_after_timeout = $mol_after_mock_timeout;
|
|
1305
1760
|
});
|
|
1306
1761
|
})($ || ($ = {}));
|
|
1307
|
-
//
|
|
1762
|
+
//mol/after/timeout/timeout.test.ts
|
|
1308
1763
|
;
|
|
1309
1764
|
"use strict";
|
|
1310
1765
|
var $;
|
|
1311
1766
|
(function ($) {
|
|
1312
|
-
|
|
1767
|
+
$mol_test({
|
|
1313
1768
|
'Vector limiting'() {
|
|
1314
|
-
let point = new
|
|
1769
|
+
let point = new $mol_vector_3d(7, 10, 13);
|
|
1315
1770
|
const res = point.limited([[1, 5], [15, 20], [5, 10]]);
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1771
|
+
$mol_assert_equal(res.x, 5);
|
|
1772
|
+
$mol_assert_equal(res.y, 15);
|
|
1773
|
+
$mol_assert_equal(res.z, 10);
|
|
1319
1774
|
},
|
|
1320
1775
|
'Vector adding scalar'() {
|
|
1321
|
-
let point = new
|
|
1776
|
+
let point = new $mol_vector_3d(1, 2, 3);
|
|
1322
1777
|
let res = point.added0(5);
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1778
|
+
$mol_assert_equal(res.x, 6);
|
|
1779
|
+
$mol_assert_equal(res.y, 7);
|
|
1780
|
+
$mol_assert_equal(res.z, 8);
|
|
1326
1781
|
},
|
|
1327
1782
|
'Vector adding vector'() {
|
|
1328
|
-
let point = new
|
|
1783
|
+
let point = new $mol_vector_3d(1, 2, 3);
|
|
1329
1784
|
let res = point.added1([5, 10, 15]);
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1785
|
+
$mol_assert_equal(res.x, 6);
|
|
1786
|
+
$mol_assert_equal(res.y, 12);
|
|
1787
|
+
$mol_assert_equal(res.z, 18);
|
|
1333
1788
|
},
|
|
1334
1789
|
'Vector multiplying scalar'() {
|
|
1335
|
-
let point = new
|
|
1790
|
+
let point = new $mol_vector_3d(2, 3, 4);
|
|
1336
1791
|
let res = point.multed0(-1);
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1792
|
+
$mol_assert_equal(res.x, -2);
|
|
1793
|
+
$mol_assert_equal(res.y, -3);
|
|
1794
|
+
$mol_assert_equal(res.z, -4);
|
|
1340
1795
|
},
|
|
1341
1796
|
'Vector multiplying vector'() {
|
|
1342
|
-
let point = new
|
|
1797
|
+
let point = new $mol_vector_3d(2, 3, 4);
|
|
1343
1798
|
let res = point.multed1([5, 2, -2]);
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1799
|
+
$mol_assert_equal(res.x, 10);
|
|
1800
|
+
$mol_assert_equal(res.y, 6);
|
|
1801
|
+
$mol_assert_equal(res.z, -8);
|
|
1347
1802
|
},
|
|
1348
1803
|
'Matrix adding matrix'() {
|
|
1349
|
-
let matrix = new
|
|
1804
|
+
let matrix = new $mol_vector_matrix(...[[1, 2], [3, 4], [5, 6]]);
|
|
1350
1805
|
let res = matrix.added2([[10, 20], [30, 40], [50, 60]]);
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1806
|
+
$mol_assert_equal(res[0][0], 11);
|
|
1807
|
+
$mol_assert_equal(res[0][1], 22);
|
|
1808
|
+
$mol_assert_equal(res[1][0], 33);
|
|
1809
|
+
$mol_assert_equal(res[1][1], 44);
|
|
1810
|
+
$mol_assert_equal(res[2][0], 55);
|
|
1811
|
+
$mol_assert_equal(res[2][1], 66);
|
|
1357
1812
|
},
|
|
1358
1813
|
'Matrix multiplying matrix'() {
|
|
1359
|
-
let matrix = new
|
|
1814
|
+
let matrix = new $mol_vector_matrix(...[[2, 3], [4, 5], [6, 7]]);
|
|
1360
1815
|
let res = matrix.multed2([[2, 3], [4, 5], [6, 7]]);
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1816
|
+
$mol_assert_equal(res[0][0], 4);
|
|
1817
|
+
$mol_assert_equal(res[0][1], 9);
|
|
1818
|
+
$mol_assert_equal(res[1][0], 16);
|
|
1819
|
+
$mol_assert_equal(res[1][1], 25);
|
|
1820
|
+
$mol_assert_equal(res[2][0], 36);
|
|
1821
|
+
$mol_assert_equal(res[2][1], 49);
|
|
1367
1822
|
},
|
|
1368
1823
|
'Range expanding'() {
|
|
1369
|
-
let range =
|
|
1824
|
+
let range = $mol_vector_range_full.inversed;
|
|
1370
1825
|
const expanded = range.expanded0(10).expanded0(5);
|
|
1371
|
-
|
|
1826
|
+
$mol_assert_like([...expanded], [5, 10]);
|
|
1372
1827
|
},
|
|
1373
1828
|
'Vector of range expanding by vector'() {
|
|
1374
|
-
let dimensions = new
|
|
1829
|
+
let dimensions = new $mol_vector_2d($mol_vector_range_full.inversed, $mol_vector_range_full.inversed);
|
|
1375
1830
|
const expanded = dimensions.expanded1([1, 7]).expanded1([3, 5]);
|
|
1376
|
-
|
|
1377
|
-
|
|
1831
|
+
$mol_assert_like([...expanded.x], [1, 3]);
|
|
1832
|
+
$mol_assert_like([...expanded.y], [5, 7]);
|
|
1378
1833
|
},
|
|
1379
1834
|
'Vector of range expanding by vector of range'() {
|
|
1380
|
-
let dimensions = new
|
|
1835
|
+
let dimensions = new $mol_vector_2d($mol_vector_range_full.inversed, $mol_vector_range_full.inversed);
|
|
1381
1836
|
const expanded = dimensions
|
|
1382
1837
|
.expanded2([[1, 3], [7, 9]])
|
|
1383
1838
|
.expanded2([[2, 4], [6, 8]]);
|
|
1384
|
-
|
|
1385
|
-
|
|
1839
|
+
$mol_assert_like([...expanded.x], [1, 4]);
|
|
1840
|
+
$mol_assert_like([...expanded.y], [6, 9]);
|
|
1386
1841
|
},
|
|
1387
1842
|
'Vector of infinity range expanding by vector of range'() {
|
|
1388
|
-
let dimensions = new
|
|
1389
|
-
const next = new
|
|
1843
|
+
let dimensions = new $mol_vector_2d($mol_vector_range_full.inversed, $mol_vector_range_full.inversed);
|
|
1844
|
+
const next = new $mol_vector_2d($mol_vector_range_full.inversed, $mol_vector_range_full.inversed);
|
|
1390
1845
|
const expanded = next
|
|
1391
1846
|
.expanded2(dimensions);
|
|
1392
|
-
|
|
1393
|
-
|
|
1847
|
+
$mol_assert_like([...expanded.x], [Infinity, -Infinity]);
|
|
1848
|
+
$mol_assert_like([...expanded.y], [Infinity, -Infinity]);
|
|
1394
1849
|
},
|
|
1395
1850
|
});
|
|
1396
1851
|
})($ || ($ = {}));
|
|
1397
|
-
//vector.test.
|
|
1852
|
+
//mol/vector/vector.test.ts
|
|
1398
1853
|
;
|
|
1399
1854
|
"use strict";
|
|
1400
|
-
//equals.test.
|
|
1855
|
+
//mol/type/equals/equals.test.ts
|
|
1401
1856
|
;
|
|
1402
1857
|
"use strict";
|
|
1403
|
-
//equals.
|
|
1858
|
+
//mol/type/equals/equals.ts
|
|
1404
1859
|
;
|
|
1405
1860
|
"use strict";
|
|
1406
1861
|
var $;
|
|
1407
1862
|
(function ($) {
|
|
1408
|
-
class $mol_view_tree_test_attributes_super extends
|
|
1863
|
+
class $mol_view_tree_test_attributes_super extends $mol_view {
|
|
1409
1864
|
some() {
|
|
1410
1865
|
return {
|
|
1411
1866
|
a: 0,
|
|
@@ -1424,12 +1879,12 @@ var $;
|
|
|
1424
1879
|
}
|
|
1425
1880
|
$.$mol_view_tree_test_attributes = $mol_view_tree_test_attributes;
|
|
1426
1881
|
})($ || ($ = {}));
|
|
1427
|
-
//attributes.test.view.tree.
|
|
1882
|
+
//mol/view/tree/test/-view.tree/attributes.test.view.tree.ts
|
|
1428
1883
|
;
|
|
1429
1884
|
"use strict";
|
|
1430
1885
|
var $;
|
|
1431
1886
|
(function ($) {
|
|
1432
|
-
class $mol_view_tree_test_binding extends
|
|
1887
|
+
class $mol_view_tree_test_binding extends $mol_view {
|
|
1433
1888
|
value(val) {
|
|
1434
1889
|
return this.task_title_new(val);
|
|
1435
1890
|
}
|
|
@@ -1446,16 +1901,16 @@ var $;
|
|
|
1446
1901
|
}
|
|
1447
1902
|
}
|
|
1448
1903
|
__decorate([
|
|
1449
|
-
|
|
1904
|
+
$mol_mem
|
|
1450
1905
|
], $mol_view_tree_test_binding.prototype, "task_title_new", null);
|
|
1451
1906
|
$.$mol_view_tree_test_binding = $mol_view_tree_test_binding;
|
|
1452
1907
|
})($ || ($ = {}));
|
|
1453
|
-
//binding.test.view.tree.
|
|
1908
|
+
//mol/view/tree/test/-view.tree/binding.test.view.tree.ts
|
|
1454
1909
|
;
|
|
1455
1910
|
"use strict";
|
|
1456
1911
|
var $;
|
|
1457
1912
|
(function ($) {
|
|
1458
|
-
class $mol_view_tree_test_binding_right extends
|
|
1913
|
+
class $mol_view_tree_test_binding_right extends $mol_view {
|
|
1459
1914
|
outer_width(v) {
|
|
1460
1915
|
return this.Test().width(v);
|
|
1461
1916
|
}
|
|
@@ -1465,10 +1920,10 @@ var $;
|
|
|
1465
1920
|
}
|
|
1466
1921
|
}
|
|
1467
1922
|
__decorate([
|
|
1468
|
-
|
|
1923
|
+
$mol_mem
|
|
1469
1924
|
], $mol_view_tree_test_binding_right.prototype, "Test", null);
|
|
1470
1925
|
$.$mol_view_tree_test_binding_right = $mol_view_tree_test_binding_right;
|
|
1471
|
-
class $mol_view_tree_test_binding_right_test extends
|
|
1926
|
+
class $mol_view_tree_test_binding_right_test extends $mol_view {
|
|
1472
1927
|
width(val) {
|
|
1473
1928
|
if (val !== undefined)
|
|
1474
1929
|
return val;
|
|
@@ -1476,16 +1931,16 @@ var $;
|
|
|
1476
1931
|
}
|
|
1477
1932
|
}
|
|
1478
1933
|
__decorate([
|
|
1479
|
-
|
|
1934
|
+
$mol_mem
|
|
1480
1935
|
], $mol_view_tree_test_binding_right_test.prototype, "width", null);
|
|
1481
1936
|
$.$mol_view_tree_test_binding_right_test = $mol_view_tree_test_binding_right_test;
|
|
1482
1937
|
})($ || ($ = {}));
|
|
1483
|
-
//binding_right.test.view.tree.
|
|
1938
|
+
//mol/view/tree/test/-view.tree/binding_right.test.view.tree.ts
|
|
1484
1939
|
;
|
|
1485
1940
|
"use strict";
|
|
1486
1941
|
var $;
|
|
1487
1942
|
(function ($) {
|
|
1488
|
-
class $mol_view_tree_test_simple extends
|
|
1943
|
+
class $mol_view_tree_test_simple extends $mol_view {
|
|
1489
1944
|
some() {
|
|
1490
1945
|
return 1;
|
|
1491
1946
|
}
|
|
@@ -1504,12 +1959,12 @@ var $;
|
|
|
1504
1959
|
}
|
|
1505
1960
|
$.$mol_view_tree_test_simple = $mol_view_tree_test_simple;
|
|
1506
1961
|
})($ || ($ = {}));
|
|
1507
|
-
//simple.test.view.tree.
|
|
1962
|
+
//mol/view/tree/test/-view.tree/simple.test.view.tree.ts
|
|
1508
1963
|
;
|
|
1509
1964
|
"use strict";
|
|
1510
1965
|
var $;
|
|
1511
1966
|
(function ($) {
|
|
1512
|
-
class $mol_view_tree_test_attributes_subcomponent extends
|
|
1967
|
+
class $mol_view_tree_test_attributes_subcomponent extends $mol_view {
|
|
1513
1968
|
Page(index) {
|
|
1514
1969
|
const obj = new this.$.$mol_view_tree_test_attributes_subcomponent_page();
|
|
1515
1970
|
obj.Sub = () => this.page(index);
|
|
@@ -1520,130 +1975,130 @@ var $;
|
|
|
1520
1975
|
}
|
|
1521
1976
|
}
|
|
1522
1977
|
__decorate([
|
|
1523
|
-
|
|
1978
|
+
$mol_mem_key
|
|
1524
1979
|
], $mol_view_tree_test_attributes_subcomponent.prototype, "Page", null);
|
|
1525
1980
|
$.$mol_view_tree_test_attributes_subcomponent = $mol_view_tree_test_attributes_subcomponent;
|
|
1526
|
-
class $mol_view_tree_test_attributes_subcomponent_page extends
|
|
1981
|
+
class $mol_view_tree_test_attributes_subcomponent_page extends $mol_view {
|
|
1527
1982
|
Sub() {
|
|
1528
1983
|
return null;
|
|
1529
1984
|
}
|
|
1530
1985
|
}
|
|
1531
1986
|
$.$mol_view_tree_test_attributes_subcomponent_page = $mol_view_tree_test_attributes_subcomponent_page;
|
|
1532
1987
|
})($ || ($ = {}));
|
|
1533
|
-
//subcomponent.test.view.tree.
|
|
1988
|
+
//mol/view/tree/test/-view.tree/subcomponent.test.view.tree.ts
|
|
1534
1989
|
;
|
|
1535
1990
|
"use strict";
|
|
1536
1991
|
var $;
|
|
1537
1992
|
(function ($_1) {
|
|
1538
1993
|
var $$;
|
|
1539
1994
|
(function ($$) {
|
|
1540
|
-
$
|
|
1995
|
+
$mol_test({
|
|
1541
1996
|
'simple props'($) {
|
|
1542
|
-
const app = $
|
|
1543
|
-
$
|
|
1544
|
-
$
|
|
1545
|
-
$
|
|
1546
|
-
$
|
|
1547
|
-
$
|
|
1997
|
+
const app = $mol_view_tree_test_simple.make({ $ });
|
|
1998
|
+
$mol_assert_equal(app.some(), 1);
|
|
1999
|
+
$mol_assert_equal(app.bool(), true);
|
|
2000
|
+
$mol_assert_equal(app.str(), 'test');
|
|
2001
|
+
$mol_assert_ok(Array.isArray(app.arr()));
|
|
2002
|
+
$mol_assert_ok(Array.isArray(app.arr_string()));
|
|
1548
2003
|
},
|
|
1549
2004
|
'default value'($) {
|
|
1550
|
-
const app = $
|
|
1551
|
-
$
|
|
2005
|
+
const app = $mol_view_tree_test_binding.make({ $ });
|
|
2006
|
+
$mol_assert_equal(app.value(), '123');
|
|
1552
2007
|
},
|
|
1553
2008
|
'both binding'($) {
|
|
1554
|
-
const app = $
|
|
1555
|
-
$
|
|
2009
|
+
const app = $mol_view_tree_test_binding.make({ $ });
|
|
2010
|
+
$mol_assert_ok(app.value() !== '1');
|
|
1556
2011
|
app.value('1');
|
|
1557
|
-
$
|
|
2012
|
+
$mol_assert_equal(app.value(), '1');
|
|
1558
2013
|
},
|
|
1559
2014
|
'left binding'($) {
|
|
1560
|
-
const app = $
|
|
1561
|
-
$
|
|
1562
|
-
$
|
|
2015
|
+
const app = $mol_view_tree_test_binding.make({ $ });
|
|
2016
|
+
$mol_assert_not(app.head_complete_enabled());
|
|
2017
|
+
$mol_assert_not(app.enabled());
|
|
1563
2018
|
},
|
|
1564
2019
|
'sub component'($) {
|
|
1565
|
-
const app = $
|
|
1566
|
-
$
|
|
2020
|
+
const app = $mol_view_tree_test_binding_right.make({ $ });
|
|
2021
|
+
$mol_assert_ok(app.Test() instanceof $mol_view_tree_test_binding_right_test);
|
|
1567
2022
|
},
|
|
1568
2023
|
'right binding - change owner property'($) {
|
|
1569
|
-
const app = $
|
|
2024
|
+
const app = $mol_view_tree_test_binding_right.make({ $ });
|
|
1570
2025
|
const val = 123;
|
|
1571
|
-
$
|
|
1572
|
-
$
|
|
2026
|
+
$mol_assert_ok(app.outer_width() !== val);
|
|
2027
|
+
$mol_assert_ok(app.Test().width() !== val);
|
|
1573
2028
|
app.outer_width(val);
|
|
1574
|
-
$
|
|
1575
|
-
$
|
|
2029
|
+
$mol_assert_equal(app.outer_width(), val);
|
|
2030
|
+
$mol_assert_equal(app.Test().width(), val);
|
|
1576
2031
|
},
|
|
1577
2032
|
'right binding - change part property'($) {
|
|
1578
|
-
const app = $
|
|
2033
|
+
const app = $mol_view_tree_test_binding_right.make({ $ });
|
|
1579
2034
|
const val = 123;
|
|
1580
|
-
$
|
|
1581
|
-
$
|
|
2035
|
+
$mol_assert_ok(app.outer_width() !== val);
|
|
2036
|
+
$mol_assert_ok(app.Test().width() !== val);
|
|
1582
2037
|
app.Test().width(val);
|
|
1583
|
-
$
|
|
1584
|
-
$
|
|
2038
|
+
$mol_assert_equal(app.Test().width(), val);
|
|
2039
|
+
$mol_assert_equal(app.outer_width(), val);
|
|
1585
2040
|
},
|
|
1586
2041
|
'attributes merging'($) {
|
|
1587
|
-
const app = $
|
|
1588
|
-
$
|
|
2042
|
+
const app = $mol_view_tree_test_attributes.make({ $ });
|
|
2043
|
+
$mol_assert_like(app.some(), { a: 1, b: 2 });
|
|
1589
2044
|
},
|
|
1590
2045
|
'subcomponent indexed'($) {
|
|
1591
|
-
const app = $
|
|
2046
|
+
const app = $mol_view_tree_test_attributes_subcomponent.make({ $ });
|
|
1592
2047
|
const val = 123;
|
|
1593
2048
|
app.page = (index) => index;
|
|
1594
|
-
$
|
|
2049
|
+
$mol_assert_equal(app.Page(val).Sub(), val);
|
|
1595
2050
|
},
|
|
1596
2051
|
});
|
|
1597
2052
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
1598
2053
|
})($ || ($ = {}));
|
|
1599
|
-
//tree.test.
|
|
2054
|
+
//mol/view/tree/test/tree.test.ts
|
|
1600
2055
|
;
|
|
1601
2056
|
"use strict";
|
|
1602
2057
|
var $;
|
|
1603
2058
|
(function ($_1) {
|
|
1604
|
-
$
|
|
2059
|
+
$mol_test({
|
|
1605
2060
|
'tree parsing'() {
|
|
1606
|
-
$
|
|
1607
|
-
$
|
|
1608
|
-
$
|
|
1609
|
-
$
|
|
1610
|
-
$
|
|
1611
|
-
$
|
|
1612
|
-
$
|
|
1613
|
-
$
|
|
2061
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
2062
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
2063
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
2064
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
2065
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
2066
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
2067
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
2068
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1614
2069
|
},
|
|
1615
2070
|
'inserting'() {
|
|
1616
|
-
$
|
|
1617
|
-
$
|
|
1618
|
-
$
|
|
1619
|
-
$
|
|
1620
|
-
$
|
|
1621
|
-
$
|
|
2071
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
2072
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
2073
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
2074
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
2075
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
2076
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1622
2077
|
},
|
|
1623
2078
|
'fromJSON'() {
|
|
1624
|
-
$
|
|
1625
|
-
$
|
|
1626
|
-
$
|
|
1627
|
-
$
|
|
1628
|
-
$
|
|
2079
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
2080
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
2081
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
2082
|
+
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
2083
|
+
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
1629
2084
|
},
|
|
1630
2085
|
'toJSON'() {
|
|
1631
|
-
$
|
|
1632
|
-
$
|
|
1633
|
-
$
|
|
1634
|
-
$
|
|
1635
|
-
$
|
|
2086
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
2087
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
2088
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
2089
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
2090
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
1636
2091
|
},
|
|
1637
2092
|
'hack'() {
|
|
1638
|
-
const res = $
|
|
2093
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1639
2094
|
'': (tree, context) => [tree.hack(context)],
|
|
1640
2095
|
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1641
2096
|
});
|
|
1642
|
-
$
|
|
2097
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1643
2098
|
},
|
|
1644
2099
|
'errors handling'($) {
|
|
1645
2100
|
const errors = [];
|
|
1646
|
-
class Tree extends $
|
|
2101
|
+
class Tree extends $mol_tree {
|
|
1647
2102
|
static $ = $.$mol_ambient({
|
|
1648
2103
|
$mol_fail: error => errors.push(error.message)
|
|
1649
2104
|
});
|
|
@@ -1652,17 +2107,17 @@ var $;
|
|
|
1652
2107
|
\t \tfoo
|
|
1653
2108
|
bar \\data
|
|
1654
2109
|
`, 'test');
|
|
1655
|
-
$
|
|
2110
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1656
2111
|
},
|
|
1657
2112
|
});
|
|
1658
2113
|
})($ || ($ = {}));
|
|
1659
|
-
//tree.test.
|
|
2114
|
+
//mol/tree/tree.test.ts
|
|
1660
2115
|
;
|
|
1661
2116
|
"use strict";
|
|
1662
2117
|
var $;
|
|
1663
2118
|
(function ($) {
|
|
1664
2119
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1665
|
-
class $mol_tree extends
|
|
2120
|
+
class $mol_tree extends $mol_object2 {
|
|
1666
2121
|
type;
|
|
1667
2122
|
data;
|
|
1668
2123
|
sub;
|
|
@@ -1975,7 +2430,7 @@ var $;
|
|
|
1975
2430
|
const sub = [].concat(...this.sub.map(child => {
|
|
1976
2431
|
const handle = context[child.type] || context[''];
|
|
1977
2432
|
if (!handle)
|
|
1978
|
-
|
|
2433
|
+
$mol_fail(child.error('Handler not defined'));
|
|
1979
2434
|
return handle(child, context);
|
|
1980
2435
|
}));
|
|
1981
2436
|
return this.clone({ sub });
|
|
@@ -1985,22 +2440,22 @@ var $;
|
|
|
1985
2440
|
}
|
|
1986
2441
|
}
|
|
1987
2442
|
__decorate([
|
|
1988
|
-
|
|
2443
|
+
$mol_deprecated('Use $mol_tree:hack')
|
|
1989
2444
|
], $mol_tree.prototype, "transform", null);
|
|
1990
2445
|
$.$mol_tree = $mol_tree;
|
|
1991
2446
|
})($ || ($ = {}));
|
|
1992
|
-
//tree.
|
|
2447
|
+
//mol/tree/tree.ts
|
|
1993
2448
|
;
|
|
1994
2449
|
"use strict";
|
|
1995
2450
|
var $;
|
|
1996
2451
|
(function ($) {
|
|
1997
|
-
class $mol_state_local extends
|
|
2452
|
+
class $mol_state_local extends $mol_object {
|
|
1998
2453
|
static 'native()';
|
|
1999
2454
|
static native() {
|
|
2000
2455
|
if (this['native()'])
|
|
2001
2456
|
return this['native()'];
|
|
2002
2457
|
check: try {
|
|
2003
|
-
const native =
|
|
2458
|
+
const native = $mol_dom_context.localStorage;
|
|
2004
2459
|
if (!native)
|
|
2005
2460
|
break check;
|
|
2006
2461
|
native.setItem('', '');
|
|
@@ -2022,7 +2477,9 @@ var $;
|
|
|
2022
2477
|
}
|
|
2023
2478
|
};
|
|
2024
2479
|
}
|
|
2025
|
-
static
|
|
2480
|
+
static changes(next) { return next; }
|
|
2481
|
+
static value(key, next) {
|
|
2482
|
+
this.changes();
|
|
2026
2483
|
if (next === void 0)
|
|
2027
2484
|
return JSON.parse(this.native().getItem(key) || 'null');
|
|
2028
2485
|
if (next === null)
|
|
@@ -2037,81 +2494,80 @@ var $;
|
|
|
2037
2494
|
}
|
|
2038
2495
|
}
|
|
2039
2496
|
__decorate([
|
|
2040
|
-
|
|
2497
|
+
$mol_mem
|
|
2498
|
+
], $mol_state_local, "changes", null);
|
|
2499
|
+
__decorate([
|
|
2500
|
+
$mol_mem_key
|
|
2041
2501
|
], $mol_state_local, "value", null);
|
|
2042
2502
|
$.$mol_state_local = $mol_state_local;
|
|
2043
2503
|
})($ || ($ = {}));
|
|
2044
|
-
//local.
|
|
2504
|
+
//mol/state/local/local.ts
|
|
2045
2505
|
;
|
|
2046
2506
|
"use strict";
|
|
2047
2507
|
var $;
|
|
2048
2508
|
(function ($) {
|
|
2049
|
-
|
|
2050
|
-
class $mol_state_local_mock extends
|
|
2509
|
+
$mol_test_mocks.push(context => {
|
|
2510
|
+
class $mol_state_local_mock extends $mol_state_local {
|
|
2051
2511
|
static state = {};
|
|
2052
|
-
static value(key, next = this.state[key]
|
|
2512
|
+
static value(key, next = this.state[key]) {
|
|
2053
2513
|
return this.state[key] = (next || null);
|
|
2054
2514
|
}
|
|
2055
2515
|
}
|
|
2056
2516
|
__decorate([
|
|
2057
|
-
|
|
2517
|
+
$mol_mem_key
|
|
2058
2518
|
], $mol_state_local_mock, "value", null);
|
|
2059
2519
|
context.$mol_state_local = $mol_state_local_mock;
|
|
2060
2520
|
});
|
|
2061
2521
|
})($ || ($ = {}));
|
|
2062
|
-
//local.mock.test.
|
|
2522
|
+
//mol/state/local/local.mock.test.ts
|
|
2063
2523
|
;
|
|
2064
2524
|
"use strict";
|
|
2065
2525
|
var $;
|
|
2066
2526
|
(function ($) {
|
|
2067
|
-
|
|
2527
|
+
$mol_test({
|
|
2068
2528
|
'local get set delete'() {
|
|
2069
2529
|
var key = '$mol_state_local_test:' + Math.random();
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2530
|
+
$mol_assert_equal($mol_state_local.value(key), null);
|
|
2531
|
+
$mol_state_local.value(key, 123);
|
|
2532
|
+
$mol_assert_equal($mol_state_local.value(key), 123);
|
|
2533
|
+
$mol_state_local.value(key, null);
|
|
2534
|
+
$mol_assert_equal($mol_state_local.value(key), null);
|
|
2075
2535
|
},
|
|
2076
2536
|
});
|
|
2077
2537
|
})($ || ($ = {}));
|
|
2078
|
-
//local.test.
|
|
2538
|
+
//mol/state/local/local.test.ts
|
|
2079
2539
|
;
|
|
2080
2540
|
"use strict";
|
|
2081
2541
|
var $;
|
|
2082
2542
|
(function ($) {
|
|
2083
|
-
self.addEventListener('storage', event =>
|
|
2084
|
-
if (!event.key)
|
|
2085
|
-
return;
|
|
2086
|
-
$.$mol_state_local.value(event.key, undefined, $.$mol_mem_force_cache);
|
|
2087
|
-
});
|
|
2543
|
+
self.addEventListener('storage', event => $.$mol_state_local.changes(event));
|
|
2088
2544
|
})($ || ($ = {}));
|
|
2089
|
-
//local.web.
|
|
2545
|
+
//mol/state/local/local.web.ts
|
|
2090
2546
|
;
|
|
2091
2547
|
"use strict";
|
|
2092
|
-
//node.
|
|
2548
|
+
//node/node.ts
|
|
2093
2549
|
;
|
|
2094
2550
|
"use strict";
|
|
2095
2551
|
var $node = $node || {};
|
|
2096
|
-
//node.web.
|
|
2552
|
+
//node/node.web.ts
|
|
2097
2553
|
;
|
|
2098
2554
|
"use strict";
|
|
2099
2555
|
var $;
|
|
2100
2556
|
(function ($) {
|
|
2101
|
-
|
|
2557
|
+
$mol_test({
|
|
2102
2558
|
'decode utf8 string'() {
|
|
2103
2559
|
const str = 'Hello, ΧΨΩЫ';
|
|
2104
2560
|
const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
|
|
2105
|
-
|
|
2106
|
-
|
|
2561
|
+
$mol_assert_equal($mol_charset_decode(encoded), str);
|
|
2562
|
+
$mol_assert_equal($mol_charset_decode(encoded, 'utf8'), str);
|
|
2107
2563
|
},
|
|
2108
2564
|
'decode empty string'() {
|
|
2109
2565
|
const encoded = new Uint8Array([]);
|
|
2110
|
-
|
|
2566
|
+
$mol_assert_equal($mol_charset_decode(encoded), '');
|
|
2111
2567
|
},
|
|
2112
2568
|
});
|
|
2113
2569
|
})($ || ($ = {}));
|
|
2114
|
-
//decode.test.
|
|
2570
|
+
//mol/charset/decode/decode.test.ts
|
|
2115
2571
|
;
|
|
2116
2572
|
"use strict";
|
|
2117
2573
|
var $;
|
|
@@ -2122,20 +2578,20 @@ var $;
|
|
|
2122
2578
|
}
|
|
2123
2579
|
$.$mol_charset_decode = $mol_charset_decode;
|
|
2124
2580
|
})($ || ($ = {}));
|
|
2125
|
-
//decode.
|
|
2581
|
+
//mol/charset/decode/decode.ts
|
|
2126
2582
|
;
|
|
2127
2583
|
"use strict";
|
|
2128
2584
|
var $;
|
|
2129
2585
|
(function ($) {
|
|
2130
|
-
|
|
2586
|
+
$mol_test({
|
|
2131
2587
|
'encode utf8 string'() {
|
|
2132
2588
|
const str = 'Hello, ΧΨΩЫ';
|
|
2133
2589
|
const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
|
|
2134
|
-
|
|
2590
|
+
$mol_assert_like($mol_charset_encode(str), encoded);
|
|
2135
2591
|
},
|
|
2136
2592
|
});
|
|
2137
2593
|
})($ || ($ = {}));
|
|
2138
|
-
//encode.test.
|
|
2594
|
+
//mol/charset/encode/encode.test.ts
|
|
2139
2595
|
;
|
|
2140
2596
|
"use strict";
|
|
2141
2597
|
var $;
|
|
@@ -2147,7 +2603,7 @@ var $;
|
|
|
2147
2603
|
}
|
|
2148
2604
|
$.$mol_charset_encode = $mol_charset_encode;
|
|
2149
2605
|
})($ || ($ = {}));
|
|
2150
|
-
//encode.
|
|
2606
|
+
//mol/charset/encode/encode.ts
|
|
2151
2607
|
;
|
|
2152
2608
|
"use strict";
|
|
2153
2609
|
var $;
|
|
@@ -2155,7 +2611,7 @@ var $;
|
|
|
2155
2611
|
class $mol_file_not_found extends Error {
|
|
2156
2612
|
}
|
|
2157
2613
|
$.$mol_file_not_found = $mol_file_not_found;
|
|
2158
|
-
class $mol_file extends
|
|
2614
|
+
class $mol_file extends $mol_object {
|
|
2159
2615
|
static absolute(path) {
|
|
2160
2616
|
throw new Error('Not implemented yet');
|
|
2161
2617
|
}
|
|
@@ -2170,16 +2626,16 @@ var $;
|
|
|
2170
2626
|
}
|
|
2171
2627
|
reset() {
|
|
2172
2628
|
try {
|
|
2173
|
-
this.stat(
|
|
2629
|
+
this.stat(null);
|
|
2174
2630
|
}
|
|
2175
2631
|
catch (error) {
|
|
2176
2632
|
if (error instanceof $mol_file_not_found)
|
|
2177
2633
|
return;
|
|
2178
|
-
return
|
|
2634
|
+
return $mol_fail_hidden(error);
|
|
2179
2635
|
}
|
|
2180
2636
|
}
|
|
2181
2637
|
version() {
|
|
2182
|
-
return this.stat()
|
|
2638
|
+
return this.stat()?.mtime.getTime().toString(36).toUpperCase() ?? '';
|
|
2183
2639
|
}
|
|
2184
2640
|
watcher() {
|
|
2185
2641
|
console.warn('$mol_file_web.watcher() not implemented');
|
|
@@ -2187,19 +2643,8 @@ var $;
|
|
|
2187
2643
|
destructor() { }
|
|
2188
2644
|
};
|
|
2189
2645
|
}
|
|
2190
|
-
exists(next
|
|
2191
|
-
let exists =
|
|
2192
|
-
try {
|
|
2193
|
-
this.stat();
|
|
2194
|
-
}
|
|
2195
|
-
catch (error) {
|
|
2196
|
-
if (error instanceof $mol_file_not_found) {
|
|
2197
|
-
exists = false;
|
|
2198
|
-
}
|
|
2199
|
-
else {
|
|
2200
|
-
return $.$mol_fail_hidden(error);
|
|
2201
|
-
}
|
|
2202
|
-
}
|
|
2646
|
+
exists(next) {
|
|
2647
|
+
let exists = Boolean(this.stat());
|
|
2203
2648
|
if (next === undefined)
|
|
2204
2649
|
return exists;
|
|
2205
2650
|
if (next === exists)
|
|
@@ -2211,7 +2656,7 @@ var $;
|
|
|
2211
2656
|
return next;
|
|
2212
2657
|
}
|
|
2213
2658
|
type() {
|
|
2214
|
-
return this.stat()
|
|
2659
|
+
return this.stat()?.type ?? '';
|
|
2215
2660
|
}
|
|
2216
2661
|
name() {
|
|
2217
2662
|
return this.path().replace(/^.*\//, '');
|
|
@@ -2220,35 +2665,27 @@ var $;
|
|
|
2220
2665
|
const match = /((?:\.\w+)+)$/.exec(this.path());
|
|
2221
2666
|
return match ? match[1].substring(1) : '';
|
|
2222
2667
|
}
|
|
2223
|
-
text(next,
|
|
2668
|
+
text(next, virt) {
|
|
2669
|
+
if (virt) {
|
|
2670
|
+
const now = new Date;
|
|
2671
|
+
this.stat({
|
|
2672
|
+
type: 'file',
|
|
2673
|
+
size: 0,
|
|
2674
|
+
atime: now,
|
|
2675
|
+
mtime: now,
|
|
2676
|
+
ctime: now,
|
|
2677
|
+
}, 'virt');
|
|
2678
|
+
return next;
|
|
2679
|
+
}
|
|
2224
2680
|
if (next === undefined) {
|
|
2225
|
-
return
|
|
2681
|
+
return $mol_charset_decode(this.buffer(undefined));
|
|
2226
2682
|
}
|
|
2227
2683
|
else {
|
|
2228
|
-
const buffer = next === undefined ? undefined :
|
|
2229
|
-
this.buffer(buffer
|
|
2684
|
+
const buffer = next === undefined ? undefined : $mol_charset_encode(next);
|
|
2685
|
+
this.buffer(buffer);
|
|
2230
2686
|
return next;
|
|
2231
2687
|
}
|
|
2232
2688
|
}
|
|
2233
|
-
fail(error) {
|
|
2234
|
-
this.buffer(error, $.$mol_mem_force_fail);
|
|
2235
|
-
this.stat(error, $.$mol_mem_force_fail);
|
|
2236
|
-
}
|
|
2237
|
-
buffer_cached(buffer) {
|
|
2238
|
-
const ctime = new Date();
|
|
2239
|
-
const stat = {
|
|
2240
|
-
type: 'file',
|
|
2241
|
-
size: buffer.length,
|
|
2242
|
-
ctime,
|
|
2243
|
-
atime: ctime,
|
|
2244
|
-
mtime: ctime
|
|
2245
|
-
};
|
|
2246
|
-
this.buffer(buffer, $.$mol_mem_force_cache);
|
|
2247
|
-
this.stat(stat, $.$mol_mem_force_cache);
|
|
2248
|
-
}
|
|
2249
|
-
text_cached(content) {
|
|
2250
|
-
this.buffer_cached($.$mol_charset_encode(content));
|
|
2251
|
-
}
|
|
2252
2689
|
find(include, exclude) {
|
|
2253
2690
|
const found = [];
|
|
2254
2691
|
const sub = this.sub();
|
|
@@ -2268,26 +2705,36 @@ var $;
|
|
|
2268
2705
|
}
|
|
2269
2706
|
size() {
|
|
2270
2707
|
switch (this.type()) {
|
|
2271
|
-
case 'file': return this.stat()
|
|
2708
|
+
case 'file': return this.stat()?.size ?? 0;
|
|
2272
2709
|
default: return 0;
|
|
2273
2710
|
}
|
|
2274
2711
|
}
|
|
2275
2712
|
}
|
|
2276
2713
|
__decorate([
|
|
2277
|
-
|
|
2714
|
+
$mol_mem
|
|
2278
2715
|
], $mol_file.prototype, "exists", null);
|
|
2279
2716
|
__decorate([
|
|
2280
|
-
|
|
2717
|
+
$mol_mem
|
|
2718
|
+
], $mol_file.prototype, "text", null);
|
|
2719
|
+
__decorate([
|
|
2720
|
+
$mol_mem_key
|
|
2281
2721
|
], $mol_file, "absolute", null);
|
|
2282
2722
|
$.$mol_file = $mol_file;
|
|
2283
2723
|
})($ || ($ = {}));
|
|
2284
|
-
//file.
|
|
2724
|
+
//mol/file/file.ts
|
|
2725
|
+
;
|
|
2726
|
+
"use strict";
|
|
2727
|
+
var $;
|
|
2728
|
+
(function ($) {
|
|
2729
|
+
$.$mol_action = $mol_wire_method;
|
|
2730
|
+
})($ || ($ = {}));
|
|
2731
|
+
//mol/action/action.ts
|
|
2285
2732
|
;
|
|
2286
2733
|
"use strict";
|
|
2287
2734
|
var $;
|
|
2288
2735
|
(function ($) {
|
|
2289
2736
|
function $mol_dom_parse(text, type = 'application/xhtml+xml') {
|
|
2290
|
-
const parser = new
|
|
2737
|
+
const parser = new $mol_dom_context.DOMParser();
|
|
2291
2738
|
const doc = parser.parseFromString(text, type);
|
|
2292
2739
|
const error = doc.getElementsByTagName('parsererror');
|
|
2293
2740
|
if (error.length)
|
|
@@ -2296,12 +2743,12 @@ var $;
|
|
|
2296
2743
|
}
|
|
2297
2744
|
$.$mol_dom_parse = $mol_dom_parse;
|
|
2298
2745
|
})($ || ($ = {}));
|
|
2299
|
-
//parse.
|
|
2746
|
+
//mol/dom/parse/parse.ts
|
|
2300
2747
|
;
|
|
2301
2748
|
"use strict";
|
|
2302
2749
|
var $;
|
|
2303
2750
|
(function ($) {
|
|
2304
|
-
class $mol_fetch_response extends
|
|
2751
|
+
class $mol_fetch_response extends $mol_object2 {
|
|
2305
2752
|
native;
|
|
2306
2753
|
constructor(native) {
|
|
2307
2754
|
super();
|
|
@@ -2325,67 +2772,62 @@ var $;
|
|
|
2325
2772
|
return decoder.decode(buffer);
|
|
2326
2773
|
}
|
|
2327
2774
|
json() {
|
|
2328
|
-
|
|
2329
|
-
const parse = $.$mol_fiber_sync(response.json);
|
|
2330
|
-
return parse.call(response);
|
|
2775
|
+
return $mol_wire_sync(this.native).json();
|
|
2331
2776
|
}
|
|
2332
2777
|
buffer() {
|
|
2333
|
-
|
|
2334
|
-
const parse = $.$mol_fiber_sync(response.arrayBuffer);
|
|
2335
|
-
return parse.call(response);
|
|
2778
|
+
return $mol_wire_sync(this.native).arrayBuffer();
|
|
2336
2779
|
}
|
|
2337
2780
|
xml() {
|
|
2338
|
-
return
|
|
2781
|
+
return $mol_dom_parse(this.text(), 'application/xml');
|
|
2339
2782
|
}
|
|
2340
2783
|
xhtml() {
|
|
2341
|
-
return
|
|
2784
|
+
return $mol_dom_parse(this.text(), 'application/xhtml+xml');
|
|
2342
2785
|
}
|
|
2343
2786
|
html() {
|
|
2344
|
-
return
|
|
2787
|
+
return $mol_dom_parse(this.text(), 'text/html');
|
|
2345
2788
|
}
|
|
2346
2789
|
}
|
|
2347
2790
|
__decorate([
|
|
2348
|
-
|
|
2791
|
+
$mol_action
|
|
2349
2792
|
], $mol_fetch_response.prototype, "stream", null);
|
|
2350
2793
|
__decorate([
|
|
2351
|
-
|
|
2794
|
+
$mol_action
|
|
2352
2795
|
], $mol_fetch_response.prototype, "text", null);
|
|
2353
2796
|
__decorate([
|
|
2354
|
-
|
|
2355
|
-
], $mol_fetch_response.prototype, "json", null);
|
|
2356
|
-
__decorate([
|
|
2357
|
-
$.$mol_fiber.method
|
|
2797
|
+
$mol_action
|
|
2358
2798
|
], $mol_fetch_response.prototype, "buffer", null);
|
|
2359
2799
|
__decorate([
|
|
2360
|
-
|
|
2800
|
+
$mol_action
|
|
2361
2801
|
], $mol_fetch_response.prototype, "xml", null);
|
|
2362
2802
|
__decorate([
|
|
2363
|
-
|
|
2803
|
+
$mol_action
|
|
2364
2804
|
], $mol_fetch_response.prototype, "xhtml", null);
|
|
2365
2805
|
__decorate([
|
|
2366
|
-
|
|
2806
|
+
$mol_action
|
|
2367
2807
|
], $mol_fetch_response.prototype, "html", null);
|
|
2368
2808
|
$.$mol_fetch_response = $mol_fetch_response;
|
|
2369
|
-
class $mol_fetch extends
|
|
2370
|
-
static request
|
|
2371
|
-
|
|
2372
|
-
var controller = new AbortController();
|
|
2373
|
-
init.signal = controller.signal;
|
|
2374
|
-
const fiber = $.$mol_fiber.current;
|
|
2375
|
-
fiber.abort = () => {
|
|
2376
|
-
if (fiber.cursor === -2)
|
|
2377
|
-
return true;
|
|
2378
|
-
controller.abort();
|
|
2379
|
-
return true;
|
|
2380
|
-
};
|
|
2381
|
-
}
|
|
2382
|
-
let native = $.$mol_dom_context.fetch;
|
|
2809
|
+
class $mol_fetch extends $mol_object2 {
|
|
2810
|
+
static request(input, init = {}) {
|
|
2811
|
+
let native = $mol_dom_context.fetch;
|
|
2383
2812
|
if (!native)
|
|
2384
2813
|
native = $node['node-fetch'];
|
|
2385
|
-
|
|
2386
|
-
|
|
2814
|
+
const controller = new AbortController();
|
|
2815
|
+
let done = false;
|
|
2816
|
+
const promise = native(input, {
|
|
2817
|
+
...init,
|
|
2818
|
+
signal: controller.signal,
|
|
2819
|
+
}).finally(() => {
|
|
2820
|
+
done = true;
|
|
2821
|
+
});
|
|
2822
|
+
return Object.assign(promise, {
|
|
2823
|
+
destructor: () => {
|
|
2824
|
+
if (!done)
|
|
2825
|
+
controller.abort();
|
|
2826
|
+
},
|
|
2827
|
+
});
|
|
2828
|
+
}
|
|
2387
2829
|
static response(input, init) {
|
|
2388
|
-
const response = this.request(input, init);
|
|
2830
|
+
const response = $mol_wire_sync(this).request(input, init);
|
|
2389
2831
|
if (Math.floor(response.status / 100) === 2)
|
|
2390
2832
|
return new $mol_fetch_response(response);
|
|
2391
2833
|
throw new Error(response.statusText || `HTTP Error ${response.status}`);
|
|
@@ -2413,57 +2855,57 @@ var $;
|
|
|
2413
2855
|
}
|
|
2414
2856
|
}
|
|
2415
2857
|
__decorate([
|
|
2416
|
-
|
|
2858
|
+
$mol_action
|
|
2417
2859
|
], $mol_fetch, "response", null);
|
|
2418
2860
|
__decorate([
|
|
2419
|
-
|
|
2861
|
+
$mol_action
|
|
2420
2862
|
], $mol_fetch, "stream", null);
|
|
2421
2863
|
__decorate([
|
|
2422
|
-
|
|
2864
|
+
$mol_action
|
|
2423
2865
|
], $mol_fetch, "text", null);
|
|
2424
2866
|
__decorate([
|
|
2425
|
-
|
|
2867
|
+
$mol_action
|
|
2426
2868
|
], $mol_fetch, "json", null);
|
|
2427
2869
|
__decorate([
|
|
2428
|
-
|
|
2870
|
+
$mol_action
|
|
2429
2871
|
], $mol_fetch, "buffer", null);
|
|
2430
2872
|
__decorate([
|
|
2431
|
-
|
|
2873
|
+
$mol_action
|
|
2432
2874
|
], $mol_fetch, "xml", null);
|
|
2433
2875
|
__decorate([
|
|
2434
|
-
|
|
2876
|
+
$mol_action
|
|
2435
2877
|
], $mol_fetch, "xhtml", null);
|
|
2436
2878
|
__decorate([
|
|
2437
|
-
|
|
2879
|
+
$mol_action
|
|
2438
2880
|
], $mol_fetch, "html", null);
|
|
2439
2881
|
$.$mol_fetch = $mol_fetch;
|
|
2440
2882
|
})($ || ($ = {}));
|
|
2441
|
-
//fetch.
|
|
2883
|
+
//mol/fetch/fetch.ts
|
|
2442
2884
|
;
|
|
2443
2885
|
"use strict";
|
|
2444
2886
|
var $;
|
|
2445
2887
|
(function ($) {
|
|
2446
|
-
class $mol_file_web extends
|
|
2888
|
+
class $mol_file_web extends $mol_file {
|
|
2447
2889
|
static absolute(path) {
|
|
2448
2890
|
return this.make({
|
|
2449
|
-
path:
|
|
2891
|
+
path: $mol_const(path)
|
|
2450
2892
|
});
|
|
2451
2893
|
}
|
|
2452
2894
|
static relative(path) {
|
|
2453
2895
|
return this.absolute(new URL(path, this.base).toString());
|
|
2454
2896
|
}
|
|
2455
|
-
static base =
|
|
2456
|
-
? new URL('.',
|
|
2897
|
+
static base = $mol_dom_context.document
|
|
2898
|
+
? new URL('.', $mol_dom_context.document.currentScript['src']).toString()
|
|
2457
2899
|
: '';
|
|
2458
|
-
buffer(next
|
|
2900
|
+
buffer(next) {
|
|
2459
2901
|
if (next !== undefined)
|
|
2460
2902
|
throw new Error(`Saving content not supported: ${this.path}`);
|
|
2461
|
-
const response =
|
|
2903
|
+
const response = $mol_fetch.response(this.path());
|
|
2462
2904
|
if (response.native.status === 404)
|
|
2463
|
-
throw new
|
|
2905
|
+
throw new $mol_file_not_found(`File not found: ${this.path()}`);
|
|
2464
2906
|
return new Uint8Array(response.buffer());
|
|
2465
2907
|
}
|
|
2466
|
-
stat(next,
|
|
2908
|
+
stat(next, virt) {
|
|
2467
2909
|
let stat = next;
|
|
2468
2910
|
if (next === undefined) {
|
|
2469
2911
|
const content = this.text();
|
|
@@ -2503,34 +2945,34 @@ var $;
|
|
|
2503
2945
|
}
|
|
2504
2946
|
}
|
|
2505
2947
|
__decorate([
|
|
2506
|
-
|
|
2948
|
+
$mol_mem
|
|
2507
2949
|
], $mol_file_web.prototype, "buffer", null);
|
|
2508
2950
|
__decorate([
|
|
2509
|
-
|
|
2951
|
+
$mol_mem
|
|
2510
2952
|
], $mol_file_web.prototype, "stat", null);
|
|
2511
2953
|
__decorate([
|
|
2512
|
-
|
|
2954
|
+
$mol_mem
|
|
2513
2955
|
], $mol_file_web.prototype, "sub", null);
|
|
2514
2956
|
__decorate([
|
|
2515
|
-
|
|
2957
|
+
$mol_mem_key
|
|
2516
2958
|
], $mol_file_web, "absolute", null);
|
|
2517
2959
|
$.$mol_file_web = $mol_file_web;
|
|
2518
2960
|
$.$mol_file = $mol_file_web;
|
|
2519
2961
|
})($ || ($ = {}));
|
|
2520
|
-
//file.web.
|
|
2962
|
+
//mol/file/file.web.ts
|
|
2521
2963
|
;
|
|
2522
2964
|
"use strict";
|
|
2523
2965
|
var $;
|
|
2524
2966
|
(function ($) {
|
|
2525
|
-
class $mol_locale extends
|
|
2967
|
+
class $mol_locale extends $mol_object {
|
|
2526
2968
|
static lang_default() {
|
|
2527
2969
|
return 'en';
|
|
2528
2970
|
}
|
|
2529
2971
|
static lang(next) {
|
|
2530
|
-
return
|
|
2972
|
+
return $mol_state_local.value('locale', next) || $mol_dom_context.navigator.language.replace(/-.*/, '') || this.lang_default();
|
|
2531
2973
|
}
|
|
2532
2974
|
static source(lang) {
|
|
2533
|
-
return JSON.parse(
|
|
2975
|
+
return JSON.parse($mol_file.relative(`web.locale=${lang}.json`).text().toString());
|
|
2534
2976
|
}
|
|
2535
2977
|
static texts(lang, next) {
|
|
2536
2978
|
if (next)
|
|
@@ -2539,8 +2981,8 @@ var $;
|
|
|
2539
2981
|
return this.source(lang).valueOf();
|
|
2540
2982
|
}
|
|
2541
2983
|
catch (error) {
|
|
2542
|
-
if (
|
|
2543
|
-
|
|
2984
|
+
if (error instanceof Promise)
|
|
2985
|
+
$mol_fail_hidden(error);
|
|
2544
2986
|
const def = this.lang_default();
|
|
2545
2987
|
if (lang === def)
|
|
2546
2988
|
throw error;
|
|
@@ -2562,26 +3004,26 @@ var $;
|
|
|
2562
3004
|
}
|
|
2563
3005
|
}
|
|
2564
3006
|
__decorate([
|
|
2565
|
-
|
|
3007
|
+
$mol_mem
|
|
2566
3008
|
], $mol_locale, "lang_default", null);
|
|
2567
3009
|
__decorate([
|
|
2568
|
-
|
|
3010
|
+
$mol_mem
|
|
2569
3011
|
], $mol_locale, "lang", null);
|
|
2570
3012
|
__decorate([
|
|
2571
|
-
|
|
3013
|
+
$mol_mem_key
|
|
2572
3014
|
], $mol_locale, "source", null);
|
|
2573
3015
|
__decorate([
|
|
2574
|
-
|
|
3016
|
+
$mol_mem_key
|
|
2575
3017
|
], $mol_locale, "texts", null);
|
|
2576
3018
|
__decorate([
|
|
2577
|
-
|
|
3019
|
+
$mol_mem_key
|
|
2578
3020
|
], $mol_locale, "text", null);
|
|
2579
3021
|
__decorate([
|
|
2580
|
-
|
|
3022
|
+
$mol_mem_key
|
|
2581
3023
|
], $mol_locale, "warn", null);
|
|
2582
3024
|
$.$mol_locale = $mol_locale;
|
|
2583
3025
|
})($ || ($ = {}));
|
|
2584
|
-
//locale.
|
|
3026
|
+
//mol/locale/locale.ts
|
|
2585
3027
|
;
|
|
2586
3028
|
"use strict";
|
|
2587
3029
|
var $;
|
|
@@ -2862,6 +3304,43 @@ var $;
|
|
|
2862
3304
|
}
|
|
2863
3305
|
$.$mol_view_tree_compile = $mol_view_tree_compile;
|
|
2864
3306
|
})($ || ($ = {}));
|
|
2865
|
-
//tree.
|
|
3307
|
+
//mol/view/tree/tree.ts
|
|
3308
|
+
;
|
|
3309
|
+
"use strict";
|
|
3310
|
+
var $;
|
|
3311
|
+
(function ($) {
|
|
3312
|
+
function $mol_promise() {
|
|
3313
|
+
let done;
|
|
3314
|
+
let fail;
|
|
3315
|
+
const promise = new Promise((d, f) => {
|
|
3316
|
+
done = d;
|
|
3317
|
+
fail = f;
|
|
3318
|
+
});
|
|
3319
|
+
return Object.assign(promise, {
|
|
3320
|
+
done,
|
|
3321
|
+
fail,
|
|
3322
|
+
});
|
|
3323
|
+
}
|
|
3324
|
+
$.$mol_promise = $mol_promise;
|
|
3325
|
+
})($ || ($ = {}));
|
|
3326
|
+
//mol/promise/promise.ts
|
|
3327
|
+
;
|
|
3328
|
+
"use strict";
|
|
3329
|
+
var $;
|
|
3330
|
+
(function ($) {
|
|
3331
|
+
function $mol_wait_timeout_async(timeout) {
|
|
3332
|
+
const promise = $mol_promise();
|
|
3333
|
+
const task = new this.$mol_after_timeout(timeout, () => promise.done());
|
|
3334
|
+
return Object.assign(promise, {
|
|
3335
|
+
destructor: () => task.destructor()
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
$.$mol_wait_timeout_async = $mol_wait_timeout_async;
|
|
3339
|
+
function $mol_wait_timeout(timeout) {
|
|
3340
|
+
return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
|
|
3341
|
+
}
|
|
3342
|
+
$.$mol_wait_timeout = $mol_wait_timeout;
|
|
3343
|
+
})($ || ($ = {}));
|
|
3344
|
+
//mol/wait/timeout/timeout.ts
|
|
2866
3345
|
|
|
2867
3346
|
//# sourceMappingURL=web.test.js.map
|