mol_plot_all 1.2.1491 → 1.2.1492
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 +336 -97
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +1360 -365
- package/node.js.map +1 -1
- package/node.mjs +1360 -365
- package/node.test.js +1610 -510
- package/node.test.js.map +1 -1
- package/package.json +31 -14
- package/web.d.ts +172 -80
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +1295 -910
- package/web.js.map +1 -1
- package/web.mjs +1295 -910
- package/web.test.js +778 -751
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
function require( path ){ return $node[ path ] };
|
|
3
3
|
"use strict";
|
|
4
|
-
|
|
5
|
-
;
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
;
|
|
9
|
-
"use strict";
|
|
10
|
-
|
|
11
|
-
;
|
|
12
|
-
"use strict";
|
|
13
|
-
|
|
14
|
-
;
|
|
15
|
-
"use strict";
|
|
16
4
|
var $;
|
|
17
5
|
(function ($_1) {
|
|
18
6
|
function $mol_test(set) {
|
|
@@ -109,107 +97,15 @@ var $;
|
|
|
109
97
|
|
|
110
98
|
;
|
|
111
99
|
"use strict";
|
|
112
|
-
var $;
|
|
113
|
-
(function ($) {
|
|
114
|
-
function $mol_assert_ok(value) {
|
|
115
|
-
if (value)
|
|
116
|
-
return;
|
|
117
|
-
$mol_fail(new Error(`${value} ≠ true`));
|
|
118
|
-
}
|
|
119
|
-
$.$mol_assert_ok = $mol_assert_ok;
|
|
120
|
-
function $mol_assert_not(value) {
|
|
121
|
-
if (!value)
|
|
122
|
-
return;
|
|
123
|
-
$mol_fail(new Error(`${value} ≠ false`));
|
|
124
|
-
}
|
|
125
|
-
$.$mol_assert_not = $mol_assert_not;
|
|
126
|
-
function $mol_assert_fail(handler, ErrorRight) {
|
|
127
|
-
const fail = $.$mol_fail;
|
|
128
|
-
try {
|
|
129
|
-
$.$mol_fail = $.$mol_fail_hidden;
|
|
130
|
-
handler();
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
$.$mol_fail = fail;
|
|
134
|
-
if (typeof ErrorRight === 'string') {
|
|
135
|
-
$mol_assert_equal(error.message ?? error, ErrorRight);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
139
|
-
}
|
|
140
|
-
return error;
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
$.$mol_fail = fail;
|
|
144
|
-
}
|
|
145
|
-
$mol_fail(new Error('Not failed'));
|
|
146
|
-
}
|
|
147
|
-
$.$mol_assert_fail = $mol_assert_fail;
|
|
148
|
-
function $mol_assert_like(...args) {
|
|
149
|
-
$mol_assert_equal(...args);
|
|
150
|
-
}
|
|
151
|
-
$.$mol_assert_like = $mol_assert_like;
|
|
152
|
-
function $mol_assert_unique(...args) {
|
|
153
|
-
for (let i = 0; i < args.length; ++i) {
|
|
154
|
-
for (let j = 0; j < args.length; ++j) {
|
|
155
|
-
if (i === j)
|
|
156
|
-
continue;
|
|
157
|
-
if (!$mol_compare_deep(args[i], args[j]))
|
|
158
|
-
continue;
|
|
159
|
-
return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
$.$mol_assert_unique = $mol_assert_unique;
|
|
164
|
-
function $mol_assert_equal(...args) {
|
|
165
|
-
for (let i = 1; i < args.length; ++i) {
|
|
166
|
-
if ($mol_compare_deep(args[0], args[i]))
|
|
167
|
-
continue;
|
|
168
|
-
if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
|
|
169
|
-
continue;
|
|
170
|
-
return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
$.$mol_assert_equal = $mol_assert_equal;
|
|
174
|
-
})($ || ($ = {}));
|
|
175
100
|
|
|
176
101
|
;
|
|
177
102
|
"use strict";
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
'must be true'() {
|
|
185
|
-
$mol_assert_ok(1);
|
|
186
|
-
},
|
|
187
|
-
'two must be equal'() {
|
|
188
|
-
$mol_assert_equal(2, 2);
|
|
189
|
-
},
|
|
190
|
-
'three must be equal'() {
|
|
191
|
-
$mol_assert_equal(2, 2, 2);
|
|
192
|
-
},
|
|
193
|
-
'two must be unique'() {
|
|
194
|
-
$mol_assert_unique([2], [3]);
|
|
195
|
-
},
|
|
196
|
-
'three must be unique'() {
|
|
197
|
-
$mol_assert_unique([1], [2], [3]);
|
|
198
|
-
},
|
|
199
|
-
'two must be alike'() {
|
|
200
|
-
$mol_assert_like([3], [3]);
|
|
201
|
-
},
|
|
202
|
-
'three must be alike'() {
|
|
203
|
-
$mol_assert_like([3], [3], [3]);
|
|
204
|
-
},
|
|
205
|
-
'two object must be alike'() {
|
|
206
|
-
$mol_assert_like({ a: 1 }, { a: 1 });
|
|
207
|
-
},
|
|
208
|
-
'three object must be alike'() {
|
|
209
|
-
$mol_assert_like({ a: 1 }, { a: 1 }, { a: 1 });
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
})($ || ($ = {}));
|
|
103
|
+
|
|
104
|
+
;
|
|
105
|
+
"use strict";
|
|
106
|
+
|
|
107
|
+
;
|
|
108
|
+
"use strict";
|
|
213
109
|
|
|
214
110
|
;
|
|
215
111
|
"use strict";
|
|
@@ -329,227 +225,125 @@ var $;
|
|
|
329
225
|
"use strict";
|
|
330
226
|
var $;
|
|
331
227
|
(function ($) {
|
|
332
|
-
$
|
|
333
|
-
'
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
228
|
+
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
229
|
+
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
230
|
+
if (typeof item !== 'function') {
|
|
231
|
+
item = index => source[index];
|
|
232
|
+
size = () => source.length;
|
|
233
|
+
}
|
|
234
|
+
return new Proxy(source, {
|
|
235
|
+
get(target, field) {
|
|
236
|
+
if (typeof field === 'string') {
|
|
237
|
+
if (field === 'length')
|
|
238
|
+
return size();
|
|
239
|
+
const index = Number(field);
|
|
240
|
+
if (index < 0)
|
|
241
|
+
return undefined;
|
|
242
|
+
if (index >= size())
|
|
243
|
+
return undefined;
|
|
244
|
+
if (index === Math.trunc(index))
|
|
245
|
+
return item(index);
|
|
246
|
+
}
|
|
247
|
+
return $mol_range2_array.prototype[field];
|
|
248
|
+
},
|
|
249
|
+
set(target, field) {
|
|
250
|
+
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
|
251
|
+
},
|
|
252
|
+
ownKeys(target) {
|
|
253
|
+
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
|
254
|
+
},
|
|
255
|
+
getOwnPropertyDescriptor(target, field) {
|
|
256
|
+
if (field === "length")
|
|
257
|
+
return {
|
|
258
|
+
value: size(),
|
|
259
|
+
writable: true,
|
|
260
|
+
enumerable: false,
|
|
261
|
+
configurable: false,
|
|
262
|
+
};
|
|
263
|
+
const index = Number(field);
|
|
264
|
+
if (index === Math.trunc(index))
|
|
265
|
+
return {
|
|
266
|
+
get: () => this.get(target, field, this),
|
|
267
|
+
enumerable: true,
|
|
268
|
+
configurable: true,
|
|
269
|
+
};
|
|
270
|
+
return Object.getOwnPropertyDescriptor(target, field);
|
|
362
271
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
$.$mol_range2 = $mol_range2;
|
|
275
|
+
class $mol_range2_array extends Array {
|
|
276
|
+
concat(...tail) {
|
|
277
|
+
if (tail.length === 0)
|
|
278
|
+
return this;
|
|
279
|
+
if (tail.length > 1) {
|
|
280
|
+
let list = this;
|
|
281
|
+
for (let item of tail)
|
|
282
|
+
list = list.concat(item);
|
|
283
|
+
return list;
|
|
368
284
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
285
|
+
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
286
|
+
}
|
|
287
|
+
filter(check, context) {
|
|
288
|
+
const filtered = [];
|
|
289
|
+
let cursor = -1;
|
|
290
|
+
return $mol_range2(index => {
|
|
291
|
+
while (cursor < this.length && index >= filtered.length - 1) {
|
|
292
|
+
const val = this[++cursor];
|
|
293
|
+
if (check(val, cursor, this))
|
|
294
|
+
filtered.push(val);
|
|
295
|
+
}
|
|
296
|
+
return filtered[index];
|
|
297
|
+
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
298
|
+
}
|
|
299
|
+
forEach(proceed, context) {
|
|
300
|
+
for (let [key, value] of this.entries())
|
|
301
|
+
proceed.call(context, value, key, this);
|
|
302
|
+
}
|
|
303
|
+
map(proceed, context) {
|
|
304
|
+
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
305
|
+
}
|
|
306
|
+
reduce(merge, result) {
|
|
307
|
+
let index = 0;
|
|
308
|
+
if (arguments.length === 1) {
|
|
309
|
+
result = this[index++];
|
|
376
310
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
380
|
-
},
|
|
381
|
-
'autobind'() {
|
|
382
|
-
class Foo {
|
|
311
|
+
for (; index < this.length; ++index) {
|
|
312
|
+
result = merge(result, this[index], index, this);
|
|
383
313
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
;
|
|
398
|
-
"use strict";
|
|
399
|
-
|
|
400
|
-
;
|
|
401
|
-
"use strict";
|
|
402
|
-
|
|
403
|
-
;
|
|
404
|
-
"use strict";
|
|
405
|
-
var $;
|
|
406
|
-
(function ($_1) {
|
|
407
|
-
$mol_test_mocks.push($ => {
|
|
408
|
-
$.$mol_log3_come = () => { };
|
|
409
|
-
$.$mol_log3_done = () => { };
|
|
410
|
-
$.$mol_log3_fail = () => { };
|
|
411
|
-
$.$mol_log3_warn = () => { };
|
|
412
|
-
$.$mol_log3_rise = () => { };
|
|
413
|
-
$.$mol_log3_area = () => () => { };
|
|
414
|
-
});
|
|
415
|
-
})($ || ($ = {}));
|
|
416
|
-
|
|
417
|
-
;
|
|
418
|
-
"use strict";
|
|
419
|
-
var $;
|
|
420
|
-
(function ($_1) {
|
|
421
|
-
$mol_test({
|
|
422
|
-
'FQN of anon function'($) {
|
|
423
|
-
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
424
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
425
|
-
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
426
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
427
|
-
},
|
|
428
|
-
});
|
|
429
|
-
})($ || ($ = {}));
|
|
430
|
-
|
|
431
|
-
;
|
|
432
|
-
"use strict";
|
|
433
|
-
var $;
|
|
434
|
-
(function ($) {
|
|
435
|
-
$mol_test({
|
|
436
|
-
'init with overload'() {
|
|
437
|
-
class X extends $mol_object {
|
|
438
|
-
foo() {
|
|
439
|
-
return 1;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
var x = X.make({
|
|
443
|
-
foo: () => 2,
|
|
444
|
-
});
|
|
445
|
-
$mol_assert_equal(x.foo(), 2);
|
|
446
|
-
},
|
|
447
|
-
});
|
|
448
|
-
})($ || ($ = {}));
|
|
449
|
-
|
|
450
|
-
;
|
|
451
|
-
"use strict";
|
|
452
|
-
var $;
|
|
453
|
-
(function ($_1) {
|
|
454
|
-
$mol_test({
|
|
455
|
-
'Collect deps'() {
|
|
456
|
-
const pub1 = new $mol_wire_pub;
|
|
457
|
-
const pub2 = new $mol_wire_pub;
|
|
458
|
-
const sub = new $mol_wire_pub_sub;
|
|
459
|
-
const bu1 = sub.track_on();
|
|
460
|
-
try {
|
|
461
|
-
pub1.promote();
|
|
462
|
-
pub2.promote();
|
|
463
|
-
pub2.promote();
|
|
464
|
-
}
|
|
465
|
-
finally {
|
|
466
|
-
sub.track_cut();
|
|
467
|
-
sub.track_off(bu1);
|
|
468
|
-
}
|
|
469
|
-
pub1.emit();
|
|
470
|
-
pub2.emit();
|
|
471
|
-
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
472
|
-
const bu2 = sub.track_on();
|
|
473
|
-
try {
|
|
474
|
-
pub1.promote();
|
|
475
|
-
pub1.promote();
|
|
476
|
-
pub2.promote();
|
|
477
|
-
}
|
|
478
|
-
finally {
|
|
479
|
-
sub.track_cut();
|
|
480
|
-
sub.track_off(bu2);
|
|
481
|
-
}
|
|
482
|
-
pub1.emit();
|
|
483
|
-
pub2.emit();
|
|
484
|
-
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
485
|
-
},
|
|
486
|
-
'cyclic detection'($) {
|
|
487
|
-
const sub1 = new $mol_wire_pub_sub;
|
|
488
|
-
const sub2 = new $mol_wire_pub_sub;
|
|
489
|
-
const bu1 = sub1.track_on();
|
|
490
|
-
try {
|
|
491
|
-
const bu2 = sub2.track_on();
|
|
492
|
-
try {
|
|
493
|
-
$mol_assert_fail(() => sub1.promote(), 'Circular subscription');
|
|
494
|
-
}
|
|
495
|
-
finally {
|
|
496
|
-
sub2.track_cut();
|
|
497
|
-
sub2.track_off(bu2);
|
|
498
|
-
}
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
toReversed() {
|
|
317
|
+
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
318
|
+
}
|
|
319
|
+
slice(from = 0, to = this.length) {
|
|
320
|
+
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
321
|
+
}
|
|
322
|
+
some(check, context) {
|
|
323
|
+
for (let index = 0; index < this.length; ++index) {
|
|
324
|
+
if (check.call(context, this[index], index, this))
|
|
325
|
+
return true;
|
|
499
326
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
every(check, context) {
|
|
330
|
+
for (let index = 0; index < this.length; ++index) {
|
|
331
|
+
if (!check.call(context, this[index], index, this))
|
|
332
|
+
return false;
|
|
503
333
|
}
|
|
504
|
-
|
|
505
|
-
});
|
|
506
|
-
})($ || ($ = {}));
|
|
507
|
-
|
|
508
|
-
;
|
|
509
|
-
"use strict";
|
|
510
|
-
var $;
|
|
511
|
-
(function ($) {
|
|
512
|
-
$.$mol_after_mock_queue = [];
|
|
513
|
-
function $mol_after_mock_warp() {
|
|
514
|
-
const queue = $.$mol_after_mock_queue.splice(0);
|
|
515
|
-
for (const task of queue)
|
|
516
|
-
task();
|
|
517
|
-
}
|
|
518
|
-
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
|
519
|
-
class $mol_after_mock_commmon extends $mol_object2 {
|
|
520
|
-
task;
|
|
521
|
-
promise = Promise.resolve();
|
|
522
|
-
cancelled = false;
|
|
523
|
-
id;
|
|
524
|
-
constructor(task) {
|
|
525
|
-
super();
|
|
526
|
-
this.task = task;
|
|
527
|
-
$.$mol_after_mock_queue.push(task);
|
|
334
|
+
return true;
|
|
528
335
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
if (index >= 0)
|
|
532
|
-
$.$mol_after_mock_queue.splice(index, 1);
|
|
336
|
+
reverse() {
|
|
337
|
+
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
|
533
338
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
super(task);
|
|
540
|
-
this.delay = delay;
|
|
339
|
+
sort() {
|
|
340
|
+
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
341
|
+
}
|
|
342
|
+
[Symbol.toPrimitive]() {
|
|
343
|
+
return $mol_guid();
|
|
541
344
|
}
|
|
542
345
|
}
|
|
543
|
-
$.$
|
|
544
|
-
})($ || ($ = {}));
|
|
545
|
-
|
|
546
|
-
;
|
|
547
|
-
"use strict";
|
|
548
|
-
var $;
|
|
549
|
-
(function ($_1) {
|
|
550
|
-
$mol_test_mocks.push($ => {
|
|
551
|
-
$.$mol_after_tick = $mol_after_mock_commmon;
|
|
552
|
-
});
|
|
346
|
+
$.$mol_range2_array = $mol_range2_array;
|
|
553
347
|
})($ || ($ = {}));
|
|
554
348
|
|
|
555
349
|
;
|
|
@@ -557,256 +351,46 @@ var $;
|
|
|
557
351
|
var $;
|
|
558
352
|
(function ($) {
|
|
559
353
|
$mol_test({
|
|
560
|
-
'
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
354
|
+
'lazy calls'() {
|
|
355
|
+
let calls = 0;
|
|
356
|
+
const list = $mol_range2(index => (++calls, index), () => 10);
|
|
357
|
+
$mol_assert_equal(true, list instanceof Array);
|
|
358
|
+
$mol_assert_equal(list.length, 10);
|
|
359
|
+
$mol_assert_equal(list[-1], undefined);
|
|
360
|
+
$mol_assert_equal(list[0], 0);
|
|
361
|
+
$mol_assert_equal(list[9], 9);
|
|
362
|
+
$mol_assert_equal(list[9.5], undefined);
|
|
363
|
+
$mol_assert_equal(list[10], undefined);
|
|
364
|
+
$mol_assert_equal(calls, 2);
|
|
365
|
+
},
|
|
366
|
+
'infinity list'() {
|
|
367
|
+
let calls = 0;
|
|
368
|
+
const list = $mol_range2(index => (++calls, index));
|
|
369
|
+
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
|
370
|
+
$mol_assert_equal(list[0], 0);
|
|
371
|
+
$mol_assert_equal(list[4], 4);
|
|
372
|
+
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
|
373
|
+
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
|
374
|
+
$mol_assert_equal(calls, 3);
|
|
375
|
+
},
|
|
376
|
+
'stringify'() {
|
|
377
|
+
const list = $mol_range2(i => i, () => 5);
|
|
378
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
379
|
+
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
|
380
|
+
},
|
|
381
|
+
'for-of'() {
|
|
382
|
+
let log = '';
|
|
383
|
+
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
384
|
+
log += i;
|
|
565
385
|
}
|
|
566
|
-
|
|
567
|
-
$mol_wire_method
|
|
568
|
-
], Sync, "calc", null);
|
|
569
|
-
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
386
|
+
$mol_assert_equal(log, '12345');
|
|
570
387
|
},
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
576
|
-
static sum(a, b) {
|
|
577
|
-
const syn = $mol_wire_sync(this);
|
|
578
|
-
return syn.val(a) + syn.val(b);
|
|
579
|
-
}
|
|
580
|
-
static async calc(a, b) {
|
|
581
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
582
|
-
}
|
|
388
|
+
'for-in'() {
|
|
389
|
+
let log = '';
|
|
390
|
+
for (let i in $mol_range2(i => i, () => 5)) {
|
|
391
|
+
log += i;
|
|
583
392
|
}
|
|
584
|
-
$mol_assert_equal(
|
|
585
|
-
},
|
|
586
|
-
async 'Idempotence control'() {
|
|
587
|
-
class Idempotence extends $mol_object2 {
|
|
588
|
-
static logs_idemp = 0;
|
|
589
|
-
static logs_unidemp = 0;
|
|
590
|
-
static log_idemp() {
|
|
591
|
-
this.logs_idemp += 1;
|
|
592
|
-
}
|
|
593
|
-
static log_unidemp() {
|
|
594
|
-
this.logs_unidemp += 1;
|
|
595
|
-
}
|
|
596
|
-
static async val(a) {
|
|
597
|
-
return a;
|
|
598
|
-
}
|
|
599
|
-
static sum(a, b) {
|
|
600
|
-
this.log_idemp();
|
|
601
|
-
this.log_unidemp();
|
|
602
|
-
const syn = $mol_wire_sync(this);
|
|
603
|
-
return syn.val(a) + syn.val(b);
|
|
604
|
-
}
|
|
605
|
-
static async calc(a, b) {
|
|
606
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
__decorate([
|
|
610
|
-
$mol_wire_method
|
|
611
|
-
], Idempotence, "log_idemp", null);
|
|
612
|
-
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
613
|
-
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
614
|
-
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
615
|
-
},
|
|
616
|
-
async 'Error handling'() {
|
|
617
|
-
class Handle extends $mol_object2 {
|
|
618
|
-
static async sum(a, b) {
|
|
619
|
-
$mol_fail(new Error('test error ' + (a + b)));
|
|
620
|
-
}
|
|
621
|
-
static check() {
|
|
622
|
-
try {
|
|
623
|
-
return $mol_wire_sync(Handle).sum(1, 2);
|
|
624
|
-
}
|
|
625
|
-
catch (error) {
|
|
626
|
-
if ($mol_promise_like(error))
|
|
627
|
-
$mol_fail_hidden(error);
|
|
628
|
-
$mol_assert_equal(error.message, 'test error 3');
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
await $mol_wire_async(Handle).check();
|
|
633
|
-
},
|
|
634
|
-
});
|
|
635
|
-
})($ || ($ = {}));
|
|
636
|
-
|
|
637
|
-
;
|
|
638
|
-
"use strict";
|
|
639
|
-
|
|
640
|
-
;
|
|
641
|
-
"use strict";
|
|
642
|
-
var $;
|
|
643
|
-
(function ($) {
|
|
644
|
-
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
645
|
-
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
646
|
-
if (typeof item !== 'function') {
|
|
647
|
-
item = index => source[index];
|
|
648
|
-
size = () => source.length;
|
|
649
|
-
}
|
|
650
|
-
return new Proxy(source, {
|
|
651
|
-
get(target, field) {
|
|
652
|
-
if (typeof field === 'string') {
|
|
653
|
-
if (field === 'length')
|
|
654
|
-
return size();
|
|
655
|
-
const index = Number(field);
|
|
656
|
-
if (index < 0)
|
|
657
|
-
return undefined;
|
|
658
|
-
if (index >= size())
|
|
659
|
-
return undefined;
|
|
660
|
-
if (index === Math.trunc(index))
|
|
661
|
-
return item(index);
|
|
662
|
-
}
|
|
663
|
-
return $mol_range2_array.prototype[field];
|
|
664
|
-
},
|
|
665
|
-
set(target, field) {
|
|
666
|
-
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
|
667
|
-
},
|
|
668
|
-
ownKeys(target) {
|
|
669
|
-
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
|
670
|
-
},
|
|
671
|
-
getOwnPropertyDescriptor(target, field) {
|
|
672
|
-
if (field === "length")
|
|
673
|
-
return {
|
|
674
|
-
value: size(),
|
|
675
|
-
writable: true,
|
|
676
|
-
enumerable: false,
|
|
677
|
-
configurable: false,
|
|
678
|
-
};
|
|
679
|
-
const index = Number(field);
|
|
680
|
-
if (index === Math.trunc(index))
|
|
681
|
-
return {
|
|
682
|
-
get: () => this.get(target, field, this),
|
|
683
|
-
enumerable: true,
|
|
684
|
-
configurable: true,
|
|
685
|
-
};
|
|
686
|
-
return Object.getOwnPropertyDescriptor(target, field);
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
$.$mol_range2 = $mol_range2;
|
|
691
|
-
class $mol_range2_array extends Array {
|
|
692
|
-
concat(...tail) {
|
|
693
|
-
if (tail.length === 0)
|
|
694
|
-
return this;
|
|
695
|
-
if (tail.length > 1) {
|
|
696
|
-
let list = this;
|
|
697
|
-
for (let item of tail)
|
|
698
|
-
list = list.concat(item);
|
|
699
|
-
return list;
|
|
700
|
-
}
|
|
701
|
-
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
702
|
-
}
|
|
703
|
-
filter(check, context) {
|
|
704
|
-
const filtered = [];
|
|
705
|
-
let cursor = -1;
|
|
706
|
-
return $mol_range2(index => {
|
|
707
|
-
while (cursor < this.length && index >= filtered.length - 1) {
|
|
708
|
-
const val = this[++cursor];
|
|
709
|
-
if (check(val, cursor, this))
|
|
710
|
-
filtered.push(val);
|
|
711
|
-
}
|
|
712
|
-
return filtered[index];
|
|
713
|
-
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
714
|
-
}
|
|
715
|
-
forEach(proceed, context) {
|
|
716
|
-
for (let [key, value] of this.entries())
|
|
717
|
-
proceed.call(context, value, key, this);
|
|
718
|
-
}
|
|
719
|
-
map(proceed, context) {
|
|
720
|
-
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
721
|
-
}
|
|
722
|
-
reduce(merge, result) {
|
|
723
|
-
let index = 0;
|
|
724
|
-
if (arguments.length === 1) {
|
|
725
|
-
result = this[index++];
|
|
726
|
-
}
|
|
727
|
-
for (; index < this.length; ++index) {
|
|
728
|
-
result = merge(result, this[index], index, this);
|
|
729
|
-
}
|
|
730
|
-
return result;
|
|
731
|
-
}
|
|
732
|
-
toReversed() {
|
|
733
|
-
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
734
|
-
}
|
|
735
|
-
slice(from = 0, to = this.length) {
|
|
736
|
-
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
737
|
-
}
|
|
738
|
-
some(check, context) {
|
|
739
|
-
for (let index = 0; index < this.length; ++index) {
|
|
740
|
-
if (check.call(context, this[index], index, this))
|
|
741
|
-
return true;
|
|
742
|
-
}
|
|
743
|
-
return false;
|
|
744
|
-
}
|
|
745
|
-
every(check, context) {
|
|
746
|
-
for (let index = 0; index < this.length; ++index) {
|
|
747
|
-
if (!check.call(context, this[index], index, this))
|
|
748
|
-
return false;
|
|
749
|
-
}
|
|
750
|
-
return true;
|
|
751
|
-
}
|
|
752
|
-
reverse() {
|
|
753
|
-
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
|
754
|
-
}
|
|
755
|
-
sort() {
|
|
756
|
-
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
757
|
-
}
|
|
758
|
-
[Symbol.toPrimitive]() {
|
|
759
|
-
return $mol_guid();
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
$.$mol_range2_array = $mol_range2_array;
|
|
763
|
-
})($ || ($ = {}));
|
|
764
|
-
|
|
765
|
-
;
|
|
766
|
-
"use strict";
|
|
767
|
-
var $;
|
|
768
|
-
(function ($) {
|
|
769
|
-
$mol_test({
|
|
770
|
-
'lazy calls'() {
|
|
771
|
-
let calls = 0;
|
|
772
|
-
const list = $mol_range2(index => (++calls, index), () => 10);
|
|
773
|
-
$mol_assert_equal(true, list instanceof Array);
|
|
774
|
-
$mol_assert_equal(list.length, 10);
|
|
775
|
-
$mol_assert_equal(list[-1], undefined);
|
|
776
|
-
$mol_assert_equal(list[0], 0);
|
|
777
|
-
$mol_assert_equal(list[9], 9);
|
|
778
|
-
$mol_assert_equal(list[9.5], undefined);
|
|
779
|
-
$mol_assert_equal(list[10], undefined);
|
|
780
|
-
$mol_assert_equal(calls, 2);
|
|
781
|
-
},
|
|
782
|
-
'infinity list'() {
|
|
783
|
-
let calls = 0;
|
|
784
|
-
const list = $mol_range2(index => (++calls, index));
|
|
785
|
-
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
|
786
|
-
$mol_assert_equal(list[0], 0);
|
|
787
|
-
$mol_assert_equal(list[4], 4);
|
|
788
|
-
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
|
789
|
-
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
|
790
|
-
$mol_assert_equal(calls, 3);
|
|
791
|
-
},
|
|
792
|
-
'stringify'() {
|
|
793
|
-
const list = $mol_range2(i => i, () => 5);
|
|
794
|
-
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
795
|
-
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
|
796
|
-
},
|
|
797
|
-
'for-of'() {
|
|
798
|
-
let log = '';
|
|
799
|
-
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
800
|
-
log += i;
|
|
801
|
-
}
|
|
802
|
-
$mol_assert_equal(log, '12345');
|
|
803
|
-
},
|
|
804
|
-
'for-in'() {
|
|
805
|
-
let log = '';
|
|
806
|
-
for (let i in $mol_range2(i => i, () => 5)) {
|
|
807
|
-
log += i;
|
|
808
|
-
}
|
|
809
|
-
$mol_assert_equal(log, '01234');
|
|
393
|
+
$mol_assert_equal(log, '01234');
|
|
810
394
|
},
|
|
811
395
|
'forEach'() {
|
|
812
396
|
let log = '';
|
|
@@ -927,129 +511,545 @@ var $;
|
|
|
927
511
|
var $;
|
|
928
512
|
(function ($) {
|
|
929
513
|
$mol_test({
|
|
930
|
-
'nulls & undefineds'() {
|
|
931
|
-
$mol_assert_ok($mol_compare_deep(null, null));
|
|
932
|
-
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
933
|
-
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
934
|
-
$mol_assert_not($mol_compare_deep({}, null));
|
|
935
|
-
},
|
|
936
|
-
'number'() {
|
|
937
|
-
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
938
|
-
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
939
|
-
$mol_assert_not($mol_compare_deep(1, 2));
|
|
940
|
-
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
941
|
-
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
942
|
-
},
|
|
943
|
-
'POJO'() {
|
|
944
|
-
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
945
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
946
|
-
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
947
|
-
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
948
|
-
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
949
|
-
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
950
|
-
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
|
951
|
-
},
|
|
952
|
-
'Array'() {
|
|
953
|
-
$mol_assert_ok($mol_compare_deep([], []));
|
|
954
|
-
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
955
|
-
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
956
|
-
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
957
|
-
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
958
|
-
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
959
|
-
},
|
|
960
|
-
'Non POJO are different'() {
|
|
961
|
-
class Thing extends Object {
|
|
514
|
+
'nulls & undefineds'() {
|
|
515
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
516
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
517
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
518
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
519
|
+
},
|
|
520
|
+
'number'() {
|
|
521
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
522
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
523
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
524
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
525
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
526
|
+
},
|
|
527
|
+
'POJO'() {
|
|
528
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
529
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
530
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
531
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
532
|
+
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
533
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
534
|
+
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
|
535
|
+
},
|
|
536
|
+
'Array'() {
|
|
537
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
538
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
539
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
540
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
541
|
+
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
542
|
+
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
543
|
+
},
|
|
544
|
+
'Non POJO are different'() {
|
|
545
|
+
class Thing extends Object {
|
|
546
|
+
}
|
|
547
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
548
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
549
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
550
|
+
},
|
|
551
|
+
'POJO with symbols'() {
|
|
552
|
+
const sym = Symbol();
|
|
553
|
+
$mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
|
|
554
|
+
$mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
|
|
555
|
+
},
|
|
556
|
+
'same POJOs with cyclic reference'() {
|
|
557
|
+
const a = { foo: {} };
|
|
558
|
+
a['self'] = a;
|
|
559
|
+
const b = { foo: {} };
|
|
560
|
+
b['self'] = b;
|
|
561
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
562
|
+
},
|
|
563
|
+
'same POJOs with cyclic reference with cache warmup'() {
|
|
564
|
+
const obj1 = { test: 1, obj3: null };
|
|
565
|
+
const obj1_copy = { test: 1, obj3: null };
|
|
566
|
+
const obj2 = { test: 2, obj1 };
|
|
567
|
+
const obj2_copy = { test: 2, obj1: obj1_copy };
|
|
568
|
+
const obj3 = { test: 3, obj2 };
|
|
569
|
+
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
570
|
+
obj1.obj3 = obj3;
|
|
571
|
+
obj1_copy.obj3 = obj3_copy;
|
|
572
|
+
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
573
|
+
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
574
|
+
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
575
|
+
$mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
|
|
576
|
+
},
|
|
577
|
+
'Date'() {
|
|
578
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
579
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
580
|
+
},
|
|
581
|
+
'RegExp'() {
|
|
582
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
583
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
584
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
585
|
+
},
|
|
586
|
+
'Error'() {
|
|
587
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
588
|
+
const fail = (message) => new Error(message);
|
|
589
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
590
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
591
|
+
},
|
|
592
|
+
'Map'() {
|
|
593
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
594
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
595
|
+
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
596
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
597
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
598
|
+
},
|
|
599
|
+
'Set'() {
|
|
600
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
601
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
602
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
603
|
+
},
|
|
604
|
+
'Uint8Array'() {
|
|
605
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
606
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
607
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
608
|
+
},
|
|
609
|
+
'DataView'() {
|
|
610
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array().buffer), new DataView(new Uint8Array().buffer)));
|
|
611
|
+
$mol_assert_ok($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([0]).buffer)));
|
|
612
|
+
$mol_assert_not($mol_compare_deep(new DataView(new Uint8Array([0]).buffer), new DataView(new Uint8Array([1]).buffer)));
|
|
613
|
+
},
|
|
614
|
+
'Serializale'() {
|
|
615
|
+
class User {
|
|
616
|
+
name;
|
|
617
|
+
rand;
|
|
618
|
+
constructor(name, rand = Math.random()) {
|
|
619
|
+
this.name = name;
|
|
620
|
+
this.rand = rand;
|
|
621
|
+
}
|
|
622
|
+
[Symbol.toPrimitive](mode) {
|
|
623
|
+
return this.name;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
627
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
628
|
+
},
|
|
629
|
+
'Iterable'() {
|
|
630
|
+
$mol_assert_ok($mol_compare_deep(new URLSearchParams({ foo: 'bar' }), new URLSearchParams({ foo: 'bar' })));
|
|
631
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx' }), new URLSearchParams({ foo: 'yyy' })));
|
|
632
|
+
$mol_assert_not($mol_compare_deep(new URLSearchParams({ foo: 'xxx', bar: 'yyy' }), new URLSearchParams({ bar: 'yyy', foo: 'xxx' })));
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
})($ || ($ = {}));
|
|
636
|
+
|
|
637
|
+
;
|
|
638
|
+
"use strict";
|
|
639
|
+
var $;
|
|
640
|
+
(function ($) {
|
|
641
|
+
function $mol_assert_ok(value) {
|
|
642
|
+
if (value)
|
|
643
|
+
return;
|
|
644
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
645
|
+
}
|
|
646
|
+
$.$mol_assert_ok = $mol_assert_ok;
|
|
647
|
+
function $mol_assert_not(value) {
|
|
648
|
+
if (!value)
|
|
649
|
+
return;
|
|
650
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
651
|
+
}
|
|
652
|
+
$.$mol_assert_not = $mol_assert_not;
|
|
653
|
+
function $mol_assert_fail(handler, ErrorRight) {
|
|
654
|
+
const fail = $.$mol_fail;
|
|
655
|
+
try {
|
|
656
|
+
$.$mol_fail = $.$mol_fail_hidden;
|
|
657
|
+
handler();
|
|
658
|
+
}
|
|
659
|
+
catch (error) {
|
|
660
|
+
$.$mol_fail = fail;
|
|
661
|
+
if (typeof ErrorRight === 'string') {
|
|
662
|
+
$mol_assert_equal(error.message ?? error, ErrorRight);
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
666
|
+
}
|
|
667
|
+
return error;
|
|
668
|
+
}
|
|
669
|
+
finally {
|
|
670
|
+
$.$mol_fail = fail;
|
|
671
|
+
}
|
|
672
|
+
$mol_fail(new Error('Not failed'));
|
|
673
|
+
}
|
|
674
|
+
$.$mol_assert_fail = $mol_assert_fail;
|
|
675
|
+
function $mol_assert_like(...args) {
|
|
676
|
+
$mol_assert_equal(...args);
|
|
677
|
+
}
|
|
678
|
+
$.$mol_assert_like = $mol_assert_like;
|
|
679
|
+
function $mol_assert_unique(...args) {
|
|
680
|
+
for (let i = 0; i < args.length; ++i) {
|
|
681
|
+
for (let j = 0; j < args.length; ++j) {
|
|
682
|
+
if (i === j)
|
|
683
|
+
continue;
|
|
684
|
+
if (!$mol_compare_deep(args[i], args[j]))
|
|
685
|
+
continue;
|
|
686
|
+
return $mol_fail(new Error(`Uniquesess assertion failure`, { cause: { [i]: args[i], [i]: args[i] } }));
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
$.$mol_assert_unique = $mol_assert_unique;
|
|
691
|
+
function $mol_assert_equal(...args) {
|
|
692
|
+
for (let i = 1; i < args.length; ++i) {
|
|
693
|
+
if ($mol_compare_deep(args[0], args[i]))
|
|
694
|
+
continue;
|
|
695
|
+
if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
|
|
696
|
+
continue;
|
|
697
|
+
return $mol_fail(new Error(`Equality assertion failure`, { cause: { 0: args[0], [i]: args[i] } }));
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
|
701
|
+
})($ || ($ = {}));
|
|
702
|
+
|
|
703
|
+
;
|
|
704
|
+
"use strict";
|
|
705
|
+
var $;
|
|
706
|
+
(function ($) {
|
|
707
|
+
$mol_test({
|
|
708
|
+
'must be false'() {
|
|
709
|
+
$mol_assert_not(0);
|
|
710
|
+
},
|
|
711
|
+
'must be true'() {
|
|
712
|
+
$mol_assert_ok(1);
|
|
713
|
+
},
|
|
714
|
+
'two must be equal'() {
|
|
715
|
+
$mol_assert_equal(2, 2);
|
|
716
|
+
},
|
|
717
|
+
'three must be equal'() {
|
|
718
|
+
$mol_assert_equal(2, 2, 2);
|
|
719
|
+
},
|
|
720
|
+
'two must be unique'() {
|
|
721
|
+
$mol_assert_unique([2], [3]);
|
|
722
|
+
},
|
|
723
|
+
'three must be unique'() {
|
|
724
|
+
$mol_assert_unique([1], [2], [3]);
|
|
725
|
+
},
|
|
726
|
+
'two must be alike'() {
|
|
727
|
+
$mol_assert_like([3], [3]);
|
|
728
|
+
},
|
|
729
|
+
'three must be alike'() {
|
|
730
|
+
$mol_assert_like([3], [3], [3]);
|
|
731
|
+
},
|
|
732
|
+
'two object must be alike'() {
|
|
733
|
+
$mol_assert_like({ a: 1 }, { a: 1 });
|
|
734
|
+
},
|
|
735
|
+
'three object must be alike'() {
|
|
736
|
+
$mol_assert_like({ a: 1 }, { a: 1 }, { a: 1 });
|
|
737
|
+
},
|
|
738
|
+
});
|
|
739
|
+
})($ || ($ = {}));
|
|
740
|
+
|
|
741
|
+
;
|
|
742
|
+
"use strict";
|
|
743
|
+
|
|
744
|
+
;
|
|
745
|
+
"use strict";
|
|
746
|
+
|
|
747
|
+
;
|
|
748
|
+
"use strict";
|
|
749
|
+
|
|
750
|
+
;
|
|
751
|
+
"use strict";
|
|
752
|
+
var $;
|
|
753
|
+
(function ($_1) {
|
|
754
|
+
$mol_test_mocks.push($ => {
|
|
755
|
+
$.$mol_log3_come = () => { };
|
|
756
|
+
$.$mol_log3_done = () => { };
|
|
757
|
+
$.$mol_log3_fail = () => { };
|
|
758
|
+
$.$mol_log3_warn = () => { };
|
|
759
|
+
$.$mol_log3_rise = () => { };
|
|
760
|
+
$.$mol_log3_area = () => () => { };
|
|
761
|
+
});
|
|
762
|
+
})($ || ($ = {}));
|
|
763
|
+
|
|
764
|
+
;
|
|
765
|
+
"use strict";
|
|
766
|
+
var $;
|
|
767
|
+
(function ($_1) {
|
|
768
|
+
$mol_test({
|
|
769
|
+
'FQN of anon function'($) {
|
|
770
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
771
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
772
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
773
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
774
|
+
},
|
|
775
|
+
});
|
|
776
|
+
})($ || ($ = {}));
|
|
777
|
+
|
|
778
|
+
;
|
|
779
|
+
"use strict";
|
|
780
|
+
var $;
|
|
781
|
+
(function ($) {
|
|
782
|
+
$mol_test({
|
|
783
|
+
'get'() {
|
|
784
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
785
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
786
|
+
},
|
|
787
|
+
'has'() {
|
|
788
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
789
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
790
|
+
},
|
|
791
|
+
'set'() {
|
|
792
|
+
const target = { foo: 777 };
|
|
793
|
+
const proxy = $mol_delegate({}, () => target);
|
|
794
|
+
proxy.foo = 123;
|
|
795
|
+
$mol_assert_equal(target.foo, 123);
|
|
796
|
+
},
|
|
797
|
+
'getOwnPropertyDescriptor'() {
|
|
798
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
799
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
800
|
+
value: 777,
|
|
801
|
+
writable: true,
|
|
802
|
+
enumerable: true,
|
|
803
|
+
configurable: true,
|
|
804
|
+
});
|
|
805
|
+
},
|
|
806
|
+
'ownKeys'() {
|
|
807
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
808
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
809
|
+
},
|
|
810
|
+
'getPrototypeOf'() {
|
|
811
|
+
class Foo {
|
|
812
|
+
}
|
|
813
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
814
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
815
|
+
},
|
|
816
|
+
'setPrototypeOf'() {
|
|
817
|
+
class Foo {
|
|
818
|
+
}
|
|
819
|
+
const target = {};
|
|
820
|
+
const proxy = $mol_delegate({}, () => target);
|
|
821
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
822
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
823
|
+
},
|
|
824
|
+
'instanceof'() {
|
|
825
|
+
class Foo {
|
|
826
|
+
}
|
|
827
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
828
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
829
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
830
|
+
},
|
|
831
|
+
'autobind'() {
|
|
832
|
+
class Foo {
|
|
833
|
+
}
|
|
834
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
835
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
836
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
837
|
+
},
|
|
838
|
+
});
|
|
839
|
+
})($ || ($ = {}));
|
|
840
|
+
|
|
841
|
+
;
|
|
842
|
+
"use strict";
|
|
843
|
+
|
|
844
|
+
;
|
|
845
|
+
"use strict";
|
|
846
|
+
var $;
|
|
847
|
+
(function ($) {
|
|
848
|
+
$mol_test({
|
|
849
|
+
'init with overload'() {
|
|
850
|
+
class X extends $mol_object {
|
|
851
|
+
foo() {
|
|
852
|
+
return 1;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
var x = X.make({
|
|
856
|
+
foo: () => 2,
|
|
857
|
+
});
|
|
858
|
+
$mol_assert_equal(x.foo(), 2);
|
|
859
|
+
},
|
|
860
|
+
});
|
|
861
|
+
})($ || ($ = {}));
|
|
862
|
+
|
|
863
|
+
;
|
|
864
|
+
"use strict";
|
|
865
|
+
var $;
|
|
866
|
+
(function ($_1) {
|
|
867
|
+
$mol_test({
|
|
868
|
+
'Collect deps'() {
|
|
869
|
+
const pub1 = new $mol_wire_pub;
|
|
870
|
+
const pub2 = new $mol_wire_pub;
|
|
871
|
+
const sub = new $mol_wire_pub_sub;
|
|
872
|
+
const bu1 = sub.track_on();
|
|
873
|
+
try {
|
|
874
|
+
pub1.promote();
|
|
875
|
+
pub2.promote();
|
|
876
|
+
pub2.promote();
|
|
877
|
+
}
|
|
878
|
+
finally {
|
|
879
|
+
sub.track_cut();
|
|
880
|
+
sub.track_off(bu1);
|
|
881
|
+
}
|
|
882
|
+
pub1.emit();
|
|
883
|
+
pub2.emit();
|
|
884
|
+
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
885
|
+
const bu2 = sub.track_on();
|
|
886
|
+
try {
|
|
887
|
+
pub1.promote();
|
|
888
|
+
pub1.promote();
|
|
889
|
+
pub2.promote();
|
|
890
|
+
}
|
|
891
|
+
finally {
|
|
892
|
+
sub.track_cut();
|
|
893
|
+
sub.track_off(bu2);
|
|
894
|
+
}
|
|
895
|
+
pub1.emit();
|
|
896
|
+
pub2.emit();
|
|
897
|
+
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
898
|
+
},
|
|
899
|
+
'cyclic detection'($) {
|
|
900
|
+
const sub1 = new $mol_wire_pub_sub;
|
|
901
|
+
const sub2 = new $mol_wire_pub_sub;
|
|
902
|
+
const bu1 = sub1.track_on();
|
|
903
|
+
try {
|
|
904
|
+
const bu2 = sub2.track_on();
|
|
905
|
+
try {
|
|
906
|
+
$mol_assert_fail(() => sub1.promote(), 'Circular subscription');
|
|
907
|
+
}
|
|
908
|
+
finally {
|
|
909
|
+
sub2.track_cut();
|
|
910
|
+
sub2.track_off(bu2);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
finally {
|
|
914
|
+
sub1.track_cut();
|
|
915
|
+
sub1.track_off(bu1);
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
});
|
|
919
|
+
})($ || ($ = {}));
|
|
920
|
+
|
|
921
|
+
;
|
|
922
|
+
"use strict";
|
|
923
|
+
var $;
|
|
924
|
+
(function ($) {
|
|
925
|
+
$.$mol_after_mock_queue = [];
|
|
926
|
+
function $mol_after_mock_warp() {
|
|
927
|
+
const queue = $.$mol_after_mock_queue.splice(0);
|
|
928
|
+
for (const task of queue)
|
|
929
|
+
task();
|
|
930
|
+
}
|
|
931
|
+
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
|
932
|
+
class $mol_after_mock_commmon extends $mol_object2 {
|
|
933
|
+
task;
|
|
934
|
+
promise = Promise.resolve();
|
|
935
|
+
cancelled = false;
|
|
936
|
+
id;
|
|
937
|
+
constructor(task) {
|
|
938
|
+
super();
|
|
939
|
+
this.task = task;
|
|
940
|
+
$.$mol_after_mock_queue.push(task);
|
|
941
|
+
}
|
|
942
|
+
destructor() {
|
|
943
|
+
const index = $.$mol_after_mock_queue.indexOf(this.task);
|
|
944
|
+
if (index >= 0)
|
|
945
|
+
$.$mol_after_mock_queue.splice(index, 1);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
|
949
|
+
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
|
950
|
+
delay;
|
|
951
|
+
constructor(delay, task) {
|
|
952
|
+
super(task);
|
|
953
|
+
this.delay = delay;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
|
957
|
+
})($ || ($ = {}));
|
|
958
|
+
|
|
959
|
+
;
|
|
960
|
+
"use strict";
|
|
961
|
+
var $;
|
|
962
|
+
(function ($_1) {
|
|
963
|
+
$mol_test_mocks.push($ => {
|
|
964
|
+
$.$mol_after_tick = $mol_after_mock_commmon;
|
|
965
|
+
});
|
|
966
|
+
})($ || ($ = {}));
|
|
967
|
+
|
|
968
|
+
;
|
|
969
|
+
"use strict";
|
|
970
|
+
var $;
|
|
971
|
+
(function ($) {
|
|
972
|
+
$mol_test({
|
|
973
|
+
'Sync execution'() {
|
|
974
|
+
class Sync extends $mol_object2 {
|
|
975
|
+
static calc(a, b) {
|
|
976
|
+
return a + b;
|
|
977
|
+
}
|
|
962
978
|
}
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
'POJO with symbols'() {
|
|
968
|
-
const sym = Symbol();
|
|
969
|
-
$mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
|
|
970
|
-
$mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
|
|
971
|
-
},
|
|
972
|
-
'same POJOs with cyclic reference'() {
|
|
973
|
-
const a = { foo: {} };
|
|
974
|
-
a['self'] = a;
|
|
975
|
-
const b = { foo: {} };
|
|
976
|
-
b['self'] = b;
|
|
977
|
-
$mol_assert_ok($mol_compare_deep(a, b));
|
|
978
|
-
},
|
|
979
|
-
'same POJOs with cyclic reference with cache warmup'() {
|
|
980
|
-
const obj1 = { test: 1, obj3: null };
|
|
981
|
-
const obj1_copy = { test: 1, obj3: null };
|
|
982
|
-
const obj2 = { test: 2, obj1 };
|
|
983
|
-
const obj2_copy = { test: 2, obj1: obj1_copy };
|
|
984
|
-
const obj3 = { test: 3, obj2 };
|
|
985
|
-
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
986
|
-
obj1.obj3 = obj3;
|
|
987
|
-
obj1_copy.obj3 = obj3_copy;
|
|
988
|
-
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
989
|
-
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
990
|
-
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
991
|
-
$mol_assert_ok($mol_compare_deep(obj3, obj3_copy));
|
|
992
|
-
},
|
|
993
|
-
'Date'() {
|
|
994
|
-
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
995
|
-
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
996
|
-
},
|
|
997
|
-
'RegExp'() {
|
|
998
|
-
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
999
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
1000
|
-
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
1001
|
-
},
|
|
1002
|
-
'Error'() {
|
|
1003
|
-
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
1004
|
-
const fail = (message) => new Error(message);
|
|
1005
|
-
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
1006
|
-
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
1007
|
-
},
|
|
1008
|
-
'Map'() {
|
|
1009
|
-
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
1010
|
-
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
1011
|
-
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
1012
|
-
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1013
|
-
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
1014
|
-
},
|
|
1015
|
-
'Set'() {
|
|
1016
|
-
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
1017
|
-
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
1018
|
-
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
1019
|
-
},
|
|
1020
|
-
'Uint8Array'() {
|
|
1021
|
-
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
1022
|
-
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
1023
|
-
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
979
|
+
__decorate([
|
|
980
|
+
$mol_wire_method
|
|
981
|
+
], Sync, "calc", null);
|
|
982
|
+
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
1024
983
|
},
|
|
1025
|
-
'
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
984
|
+
async 'async <=> sync'() {
|
|
985
|
+
class SyncAsync extends $mol_object2 {
|
|
986
|
+
static async val(a) {
|
|
987
|
+
return a;
|
|
988
|
+
}
|
|
989
|
+
static sum(a, b) {
|
|
990
|
+
const syn = $mol_wire_sync(this);
|
|
991
|
+
return syn.val(a) + syn.val(b);
|
|
992
|
+
}
|
|
993
|
+
static async calc(a, b) {
|
|
994
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
1029
998
|
},
|
|
1030
|
-
'
|
|
1031
|
-
class
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
this.
|
|
1036
|
-
this.rand = rand;
|
|
999
|
+
async 'Idempotence control'() {
|
|
1000
|
+
class Idempotence extends $mol_object2 {
|
|
1001
|
+
static logs_idemp = 0;
|
|
1002
|
+
static logs_unidemp = 0;
|
|
1003
|
+
static log_idemp() {
|
|
1004
|
+
this.logs_idemp += 1;
|
|
1037
1005
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1006
|
+
static log_unidemp() {
|
|
1007
|
+
this.logs_unidemp += 1;
|
|
1008
|
+
}
|
|
1009
|
+
static async val(a) {
|
|
1010
|
+
return a;
|
|
1011
|
+
}
|
|
1012
|
+
static sum(a, b) {
|
|
1013
|
+
this.log_idemp();
|
|
1014
|
+
this.log_unidemp();
|
|
1015
|
+
const syn = $mol_wire_sync(this);
|
|
1016
|
+
return syn.val(a) + syn.val(b);
|
|
1017
|
+
}
|
|
1018
|
+
static async calc(a, b) {
|
|
1019
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
1040
1020
|
}
|
|
1041
1021
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1022
|
+
__decorate([
|
|
1023
|
+
$mol_wire_method
|
|
1024
|
+
], Idempotence, "log_idemp", null);
|
|
1025
|
+
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
1026
|
+
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
1027
|
+
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
1044
1028
|
},
|
|
1045
|
-
'
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1029
|
+
async 'Error handling'() {
|
|
1030
|
+
class Handle extends $mol_object2 {
|
|
1031
|
+
static async sum(a, b) {
|
|
1032
|
+
$mol_fail(new Error('test error ' + (a + b)));
|
|
1033
|
+
}
|
|
1034
|
+
static check() {
|
|
1035
|
+
try {
|
|
1036
|
+
return $mol_wire_sync(Handle).sum(1, 2);
|
|
1037
|
+
}
|
|
1038
|
+
catch (error) {
|
|
1039
|
+
if ($mol_promise_like(error))
|
|
1040
|
+
$mol_fail_hidden(error);
|
|
1041
|
+
$mol_assert_equal(error.message, 'test error 3');
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
await $mol_wire_async(Handle).check();
|
|
1049
1046
|
},
|
|
1050
1047
|
});
|
|
1051
1048
|
})($ || ($ = {}));
|
|
1052
1049
|
|
|
1050
|
+
;
|
|
1051
|
+
"use strict";
|
|
1052
|
+
|
|
1053
1053
|
;
|
|
1054
1054
|
"use strict";
|
|
1055
1055
|
var $;
|
|
@@ -1112,68 +1112,6 @@ var $;
|
|
|
1112
1112
|
});
|
|
1113
1113
|
})($ || ($ = {}));
|
|
1114
1114
|
|
|
1115
|
-
;
|
|
1116
|
-
"use strict";
|
|
1117
|
-
var $;
|
|
1118
|
-
(function ($) {
|
|
1119
|
-
const factories = new WeakMap();
|
|
1120
|
-
function factory(val) {
|
|
1121
|
-
let make = factories.get(val);
|
|
1122
|
-
if (make)
|
|
1123
|
-
return make;
|
|
1124
|
-
make = $mol_func_name_from((...args) => new val(...args), val);
|
|
1125
|
-
factories.set(val, make);
|
|
1126
|
-
return make;
|
|
1127
|
-
}
|
|
1128
|
-
const getters = new WeakMap();
|
|
1129
|
-
function get_prop(host, field) {
|
|
1130
|
-
let props = getters.get(host);
|
|
1131
|
-
let get_val = props?.[field];
|
|
1132
|
-
if (get_val)
|
|
1133
|
-
return get_val;
|
|
1134
|
-
get_val = (next) => {
|
|
1135
|
-
if (next !== undefined)
|
|
1136
|
-
host[field] = next;
|
|
1137
|
-
return host[field];
|
|
1138
|
-
};
|
|
1139
|
-
Object.defineProperty(get_val, 'name', { value: field });
|
|
1140
|
-
if (!props) {
|
|
1141
|
-
props = {};
|
|
1142
|
-
getters.set(host, props);
|
|
1143
|
-
}
|
|
1144
|
-
props[field] = get_val;
|
|
1145
|
-
return get_val;
|
|
1146
|
-
}
|
|
1147
|
-
function $mol_wire_sync(obj) {
|
|
1148
|
-
return new Proxy(obj, {
|
|
1149
|
-
get(obj, field) {
|
|
1150
|
-
let val = obj[field];
|
|
1151
|
-
const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
|
|
1152
|
-
if (typeof val !== 'function')
|
|
1153
|
-
return temp(obj, []).sync();
|
|
1154
|
-
return function $mol_wire_sync(...args) {
|
|
1155
|
-
const fiber = temp(obj, args);
|
|
1156
|
-
return fiber.sync();
|
|
1157
|
-
};
|
|
1158
|
-
},
|
|
1159
|
-
set(obj, field, next) {
|
|
1160
|
-
const temp = $mol_wire_task.getter(get_prop(obj, field));
|
|
1161
|
-
temp(obj, [next]).sync();
|
|
1162
|
-
return true;
|
|
1163
|
-
},
|
|
1164
|
-
construct(obj, args) {
|
|
1165
|
-
const temp = $mol_wire_task.getter(factory(obj));
|
|
1166
|
-
return temp(obj, args).sync();
|
|
1167
|
-
},
|
|
1168
|
-
apply(obj, self, args) {
|
|
1169
|
-
const temp = $mol_wire_task.getter(obj);
|
|
1170
|
-
return temp(self, args).sync();
|
|
1171
|
-
},
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
|
1175
|
-
})($ || ($ = {}));
|
|
1176
|
-
|
|
1177
1115
|
;
|
|
1178
1116
|
"use strict";
|
|
1179
1117
|
var $;
|
|
@@ -1929,6 +1867,15 @@ var $;
|
|
|
1929
1867
|
});
|
|
1930
1868
|
})($ || ($ = {}));
|
|
1931
1869
|
|
|
1870
|
+
;
|
|
1871
|
+
"use strict";
|
|
1872
|
+
var $;
|
|
1873
|
+
(function ($_1) {
|
|
1874
|
+
$mol_test_mocks.push($ => {
|
|
1875
|
+
$.$mol_after_frame = $mol_after_mock_commmon;
|
|
1876
|
+
});
|
|
1877
|
+
})($ || ($ = {}));
|
|
1878
|
+
|
|
1932
1879
|
;
|
|
1933
1880
|
"use strict";
|
|
1934
1881
|
var $;
|
|
@@ -1990,15 +1937,6 @@ var $;
|
|
|
1990
1937
|
});
|
|
1991
1938
|
})($ || ($ = {}));
|
|
1992
1939
|
|
|
1993
|
-
;
|
|
1994
|
-
"use strict";
|
|
1995
|
-
var $;
|
|
1996
|
-
(function ($_1) {
|
|
1997
|
-
$mol_test_mocks.push($ => {
|
|
1998
|
-
$.$mol_after_frame = $mol_after_mock_commmon;
|
|
1999
|
-
});
|
|
2000
|
-
})($ || ($ = {}));
|
|
2001
|
-
|
|
2002
1940
|
;
|
|
2003
1941
|
"use strict";
|
|
2004
1942
|
|
|
@@ -2093,6 +2031,95 @@ var $;
|
|
|
2093
2031
|
$mol_wire_log.active();
|
|
2094
2032
|
})($ || ($ = {}));
|
|
2095
2033
|
|
|
2034
|
+
;
|
|
2035
|
+
"use strict";
|
|
2036
|
+
var $;
|
|
2037
|
+
(function ($_1) {
|
|
2038
|
+
$mol_test_mocks.push(context => {
|
|
2039
|
+
class $mol_state_arg_mock extends $mol_state_arg {
|
|
2040
|
+
static $ = context;
|
|
2041
|
+
static href(next) { return next || ''; }
|
|
2042
|
+
static go(next) {
|
|
2043
|
+
this.href(this.link(next));
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
__decorate([
|
|
2047
|
+
$mol_mem
|
|
2048
|
+
], $mol_state_arg_mock, "href", null);
|
|
2049
|
+
__decorate([
|
|
2050
|
+
$mol_action
|
|
2051
|
+
], $mol_state_arg_mock, "go", null);
|
|
2052
|
+
context.$mol_state_arg = $mol_state_arg_mock;
|
|
2053
|
+
});
|
|
2054
|
+
$mol_test({
|
|
2055
|
+
'args as dictionary'($) {
|
|
2056
|
+
$.$mol_state_arg.href('#!foo=bar/xxx');
|
|
2057
|
+
$mol_assert_equal($.$mol_state_arg.dict(), { foo: 'bar', xxx: '' });
|
|
2058
|
+
$.$mol_state_arg.dict({ foo: null, yyy: '', lol: '123' });
|
|
2059
|
+
$mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!yyy/lol=123');
|
|
2060
|
+
},
|
|
2061
|
+
'one value from args'($) {
|
|
2062
|
+
$.$mol_state_arg.href('#!foo=bar/xxx');
|
|
2063
|
+
$mol_assert_equal($.$mol_state_arg.value('foo'), 'bar');
|
|
2064
|
+
$mol_assert_equal($.$mol_state_arg.value('xxx'), '');
|
|
2065
|
+
$.$mol_state_arg.value('foo', 'lol');
|
|
2066
|
+
$mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!foo=lol/xxx');
|
|
2067
|
+
$.$mol_state_arg.value('foo', '');
|
|
2068
|
+
$mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!foo/xxx');
|
|
2069
|
+
$.$mol_state_arg.value('foo', null);
|
|
2070
|
+
$mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!xxx');
|
|
2071
|
+
},
|
|
2072
|
+
'nested args'($) {
|
|
2073
|
+
const base = new $.$mol_state_arg('nested.');
|
|
2074
|
+
class Nested extends $mol_state_arg {
|
|
2075
|
+
constructor(prefix) {
|
|
2076
|
+
super(base.prefix + prefix);
|
|
2077
|
+
}
|
|
2078
|
+
static value = (key, next) => base.value(key, next);
|
|
2079
|
+
}
|
|
2080
|
+
$.$mol_state_arg.href('#!foo=bar/nested.xxx=123');
|
|
2081
|
+
$mol_assert_equal(Nested.value('foo'), null);
|
|
2082
|
+
$mol_assert_equal(Nested.value('xxx'), '123');
|
|
2083
|
+
Nested.value('foo', 'lol');
|
|
2084
|
+
$mol_assert_equal($.$mol_state_arg.href().replace(/.*#/, '#'), '#!foo=bar/nested.xxx=123/nested.foo=lol');
|
|
2085
|
+
},
|
|
2086
|
+
});
|
|
2087
|
+
})($ || ($ = {}));
|
|
2088
|
+
|
|
2089
|
+
;
|
|
2090
|
+
"use strict";
|
|
2091
|
+
var $;
|
|
2092
|
+
(function ($) {
|
|
2093
|
+
$mol_test({
|
|
2094
|
+
'local get set delete'() {
|
|
2095
|
+
var key = '$mol_state_local_test:' + Math.random();
|
|
2096
|
+
$mol_assert_equal($mol_state_local.value(key), null);
|
|
2097
|
+
$mol_state_local.value(key, 123);
|
|
2098
|
+
$mol_assert_equal($mol_state_local.value(key), 123);
|
|
2099
|
+
$mol_state_local.value(key, null);
|
|
2100
|
+
$mol_assert_equal($mol_state_local.value(key), null);
|
|
2101
|
+
},
|
|
2102
|
+
});
|
|
2103
|
+
})($ || ($ = {}));
|
|
2104
|
+
|
|
2105
|
+
;
|
|
2106
|
+
"use strict";
|
|
2107
|
+
var $;
|
|
2108
|
+
(function ($) {
|
|
2109
|
+
$mol_test_mocks.push(context => {
|
|
2110
|
+
class $mol_state_local_mock extends $mol_state_local {
|
|
2111
|
+
static state = {};
|
|
2112
|
+
static value(key, next = this.state[key]) {
|
|
2113
|
+
return this.state[key] = (next || null);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
__decorate([
|
|
2117
|
+
$mol_mem_key
|
|
2118
|
+
], $mol_state_local_mock, "value", null);
|
|
2119
|
+
context.$mol_state_local = $mol_state_local_mock;
|
|
2120
|
+
});
|
|
2121
|
+
})($ || ($ = {}));
|
|
2122
|
+
|
|
2096
2123
|
;
|
|
2097
2124
|
"use strict";
|
|
2098
2125
|
var $;
|