hyoo_sync_client 0.0.376 → 0.0.377
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 +177 -175
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +1780 -1775
- package/node.js.map +1 -1
- package/node.mjs +1780 -1775
- package/node.test.js +1850 -1845
- package/node.test.js.map +1 -1
- package/package.json +17 -17
- package/web.js +1 -1
- package/web.js.map +1 -1
- package/web.mjs +1 -1
package/node.js
CHANGED
|
@@ -244,1852 +244,2083 @@ var $;
|
|
|
244
244
|
"use strict";
|
|
245
245
|
var $;
|
|
246
246
|
(function ($) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
let $mol_wire_cursor;
|
|
248
|
+
(function ($mol_wire_cursor) {
|
|
249
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
250
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
251
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
252
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
253
|
+
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
251
254
|
})($ || ($ = {}));
|
|
252
255
|
|
|
253
256
|
;
|
|
254
257
|
"use strict";
|
|
255
258
|
var $;
|
|
256
259
|
(function ($) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
class $mol_wire_pub extends Object {
|
|
261
|
+
data = [];
|
|
262
|
+
static get [Symbol.species]() {
|
|
263
|
+
return Array;
|
|
264
|
+
}
|
|
265
|
+
sub_from = 0;
|
|
266
|
+
get sub_list() {
|
|
267
|
+
const res = [];
|
|
268
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
269
|
+
res.push(this.data[i]);
|
|
270
|
+
}
|
|
271
|
+
return res;
|
|
272
|
+
}
|
|
273
|
+
get sub_empty() {
|
|
274
|
+
return this.sub_from === this.data.length;
|
|
275
|
+
}
|
|
276
|
+
sub_on(sub, pub_pos) {
|
|
277
|
+
const pos = this.data.length;
|
|
278
|
+
this.data.push(sub, pub_pos);
|
|
279
|
+
return pos;
|
|
280
|
+
}
|
|
281
|
+
sub_off(sub_pos) {
|
|
282
|
+
if (!(sub_pos < this.data.length)) {
|
|
283
|
+
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
284
|
+
}
|
|
285
|
+
const end = this.data.length - 2;
|
|
286
|
+
if (sub_pos !== end) {
|
|
287
|
+
this.peer_move(end, sub_pos);
|
|
288
|
+
}
|
|
289
|
+
this.data.pop();
|
|
290
|
+
this.data.pop();
|
|
291
|
+
if (this.data.length === this.sub_from)
|
|
292
|
+
this.reap();
|
|
293
|
+
}
|
|
294
|
+
reap() { }
|
|
295
|
+
promote() {
|
|
296
|
+
$mol_wire_auto()?.track_next(this);
|
|
297
|
+
}
|
|
298
|
+
fresh() { }
|
|
299
|
+
complete() { }
|
|
300
|
+
get incompleted() {
|
|
264
301
|
return false;
|
|
265
|
-
|
|
266
|
-
|
|
302
|
+
}
|
|
303
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
304
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
305
|
+
;
|
|
306
|
+
this.data[i].absorb(quant);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
peer_move(from_pos, to_pos) {
|
|
310
|
+
const peer = this.data[from_pos];
|
|
311
|
+
const self_pos = this.data[from_pos + 1];
|
|
312
|
+
this.data[to_pos] = peer;
|
|
313
|
+
this.data[to_pos + 1] = self_pos;
|
|
314
|
+
peer.peer_repos(self_pos, to_pos);
|
|
315
|
+
}
|
|
316
|
+
peer_repos(peer_pos, self_pos) {
|
|
317
|
+
this.data[peer_pos + 1] = self_pos;
|
|
318
|
+
}
|
|
267
319
|
}
|
|
268
|
-
$.$
|
|
320
|
+
$.$mol_wire_pub = $mol_wire_pub;
|
|
269
321
|
})($ || ($ = {}));
|
|
270
322
|
|
|
323
|
+
;
|
|
324
|
+
"use strict";
|
|
325
|
+
|
|
271
326
|
;
|
|
272
327
|
"use strict";
|
|
273
328
|
var $;
|
|
274
329
|
(function ($) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if (!$mol_fail_catch(error))
|
|
279
|
-
return false;
|
|
280
|
-
console.error(error);
|
|
281
|
-
return true;
|
|
330
|
+
$.$mol_wire_auto_sub = null;
|
|
331
|
+
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
332
|
+
return $.$mol_wire_auto_sub = next;
|
|
282
333
|
}
|
|
283
|
-
$.$
|
|
334
|
+
$.$mol_wire_auto = $mol_wire_auto;
|
|
335
|
+
$.$mol_wire_affected = [];
|
|
284
336
|
})($ || ($ = {}));
|
|
285
337
|
|
|
286
338
|
;
|
|
287
339
|
"use strict";
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
if (parent === dir) {
|
|
305
|
-
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
340
|
+
var $;
|
|
341
|
+
(function ($) {
|
|
342
|
+
$['devtoolsFormatters'] ||= [];
|
|
343
|
+
function $mol_dev_format_register(config) {
|
|
344
|
+
$['devtoolsFormatters'].push(config);
|
|
345
|
+
}
|
|
346
|
+
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
347
|
+
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
348
|
+
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
349
|
+
$mol_dev_format_register({
|
|
350
|
+
header: (val, config = false) => {
|
|
351
|
+
if (config)
|
|
352
|
+
return null;
|
|
353
|
+
if (!val)
|
|
354
|
+
return null;
|
|
355
|
+
if ($.$mol_dev_format_head in val) {
|
|
306
356
|
try {
|
|
307
|
-
|
|
357
|
+
return val[$.$mol_dev_format_head]();
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
308
361
|
}
|
|
309
|
-
catch { }
|
|
310
|
-
break;
|
|
311
362
|
}
|
|
312
|
-
|
|
313
|
-
|
|
363
|
+
if (typeof val === 'function') {
|
|
364
|
+
return $mol_dev_format_native(val);
|
|
365
|
+
}
|
|
366
|
+
if (Symbol.toStringTag in val) {
|
|
367
|
+
return $mol_dev_format_native(val);
|
|
314
368
|
}
|
|
315
|
-
}
|
|
316
|
-
try {
|
|
317
|
-
return target.require(name);
|
|
318
|
-
}
|
|
319
|
-
catch (error) {
|
|
320
|
-
$.$mol_fail_log(error);
|
|
321
369
|
return null;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
(function ($) {
|
|
337
|
-
function $mol_log3_area_lazy(event) {
|
|
338
|
-
const self = this;
|
|
339
|
-
const stack = self.$mol_log3_stack;
|
|
340
|
-
const deep = stack.length;
|
|
341
|
-
let logged = false;
|
|
342
|
-
stack.push(() => {
|
|
343
|
-
logged = true;
|
|
344
|
-
self.$mol_log3_area.call(self, event);
|
|
345
|
-
});
|
|
346
|
-
return () => {
|
|
347
|
-
if (logged)
|
|
348
|
-
self.console.groupEnd();
|
|
349
|
-
if (stack.length > deep)
|
|
350
|
-
stack.length = deep;
|
|
351
|
-
};
|
|
370
|
+
},
|
|
371
|
+
hasBody: val => val[$.$mol_dev_format_body],
|
|
372
|
+
body: val => val[$.$mol_dev_format_body](),
|
|
373
|
+
});
|
|
374
|
+
function $mol_dev_format_native(obj) {
|
|
375
|
+
if (typeof obj === 'undefined')
|
|
376
|
+
return $.$mol_dev_format_shade('undefined');
|
|
377
|
+
return [
|
|
378
|
+
'object',
|
|
379
|
+
{
|
|
380
|
+
object: obj,
|
|
381
|
+
config: true,
|
|
382
|
+
},
|
|
383
|
+
];
|
|
352
384
|
}
|
|
353
|
-
$.$
|
|
354
|
-
|
|
385
|
+
$.$mol_dev_format_native = $mol_dev_format_native;
|
|
386
|
+
function $mol_dev_format_auto(obj) {
|
|
387
|
+
if (obj == null)
|
|
388
|
+
return $.$mol_dev_format_shade(String(obj));
|
|
389
|
+
return [
|
|
390
|
+
'object',
|
|
391
|
+
{
|
|
392
|
+
object: obj,
|
|
393
|
+
config: false,
|
|
394
|
+
},
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
|
398
|
+
function $mol_dev_format_element(element, style, ...content) {
|
|
399
|
+
const styles = [];
|
|
400
|
+
for (let key in style)
|
|
401
|
+
styles.push(`${key} : ${style[key]}`);
|
|
402
|
+
return [
|
|
403
|
+
element,
|
|
404
|
+
{
|
|
405
|
+
style: styles.join(' ; '),
|
|
406
|
+
},
|
|
407
|
+
...content,
|
|
408
|
+
];
|
|
409
|
+
}
|
|
410
|
+
$.$mol_dev_format_element = $mol_dev_format_element;
|
|
411
|
+
function $mol_dev_format_span(style, ...content) {
|
|
412
|
+
return $mol_dev_format_element('span', {
|
|
413
|
+
...style,
|
|
414
|
+
}, ...content);
|
|
415
|
+
}
|
|
416
|
+
$.$mol_dev_format_span = $mol_dev_format_span;
|
|
417
|
+
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
|
418
|
+
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
|
419
|
+
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
|
420
|
+
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
|
421
|
+
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
|
422
|
+
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
|
423
|
+
$.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
|
|
424
|
+
'color': 'magenta',
|
|
425
|
+
});
|
|
426
|
+
$.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
|
|
427
|
+
'font-weight': 'bold',
|
|
428
|
+
});
|
|
429
|
+
$.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
|
|
430
|
+
'color': 'green',
|
|
431
|
+
});
|
|
432
|
+
$.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
|
|
433
|
+
'color': 'gray',
|
|
434
|
+
});
|
|
435
|
+
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
|
436
|
+
'margin-left': '13px'
|
|
437
|
+
});
|
|
355
438
|
})($ || ($ = {}));
|
|
356
439
|
|
|
357
440
|
;
|
|
358
441
|
"use strict";
|
|
359
442
|
var $;
|
|
360
443
|
(function ($) {
|
|
361
|
-
class $
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
length;
|
|
367
|
-
constructor(uri, source, row, col, length) {
|
|
368
|
-
super();
|
|
369
|
-
this.uri = uri;
|
|
370
|
-
this.source = source;
|
|
371
|
-
this.row = row;
|
|
372
|
-
this.col = col;
|
|
373
|
-
this.length = length;
|
|
374
|
-
this[Symbol.toStringTag] = `${this.uri}#${this.row}:${this.col}/${this.length}`;
|
|
444
|
+
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
445
|
+
pub_from = 0;
|
|
446
|
+
cursor = $mol_wire_cursor.stale;
|
|
447
|
+
get temp() {
|
|
448
|
+
return false;
|
|
375
449
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
450
|
+
get pub_list() {
|
|
451
|
+
const res = [];
|
|
452
|
+
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
|
453
|
+
for (let i = this.pub_from; i < max; i += 2) {
|
|
454
|
+
if (this.data[i])
|
|
455
|
+
res.push(this.data[i]);
|
|
456
|
+
}
|
|
457
|
+
return res;
|
|
379
458
|
}
|
|
380
|
-
|
|
381
|
-
|
|
459
|
+
track_on() {
|
|
460
|
+
this.cursor = this.pub_from;
|
|
461
|
+
const sub = $mol_wire_auto();
|
|
462
|
+
$mol_wire_auto(this);
|
|
463
|
+
return sub;
|
|
382
464
|
}
|
|
383
|
-
|
|
384
|
-
|
|
465
|
+
promote() {
|
|
466
|
+
if (this.cursor >= this.pub_from) {
|
|
467
|
+
$mol_fail(new Error('Circular subscription'));
|
|
468
|
+
}
|
|
469
|
+
super.promote();
|
|
385
470
|
}
|
|
386
|
-
|
|
387
|
-
|
|
471
|
+
track_next(pub) {
|
|
472
|
+
if (this.cursor < 0)
|
|
473
|
+
$mol_fail(new Error('Promo to non begun sub'));
|
|
474
|
+
if (this.cursor < this.sub_from) {
|
|
475
|
+
const next = this.data[this.cursor];
|
|
476
|
+
if (pub === undefined)
|
|
477
|
+
return next ?? null;
|
|
478
|
+
if (next === pub) {
|
|
479
|
+
this.cursor += 2;
|
|
480
|
+
return next;
|
|
481
|
+
}
|
|
482
|
+
if (next) {
|
|
483
|
+
if (this.sub_from < this.data.length) {
|
|
484
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
485
|
+
}
|
|
486
|
+
this.peer_move(this.cursor, this.sub_from);
|
|
487
|
+
this.sub_from += 2;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
if (pub === undefined)
|
|
492
|
+
return null;
|
|
493
|
+
if (this.sub_from < this.data.length) {
|
|
494
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
495
|
+
}
|
|
496
|
+
this.sub_from += 2;
|
|
497
|
+
}
|
|
498
|
+
this.data[this.cursor] = pub;
|
|
499
|
+
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
|
500
|
+
this.cursor += 2;
|
|
501
|
+
return pub;
|
|
388
502
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
503
|
+
track_off(sub) {
|
|
504
|
+
$mol_wire_auto(sub);
|
|
505
|
+
if (this.cursor < 0) {
|
|
506
|
+
$mol_fail(new Error('End of non begun sub'));
|
|
507
|
+
}
|
|
508
|
+
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
509
|
+
const pub = this.data[cursor];
|
|
510
|
+
pub.fresh();
|
|
511
|
+
}
|
|
512
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
396
513
|
}
|
|
397
|
-
|
|
398
|
-
|
|
514
|
+
pub_off(sub_pos) {
|
|
515
|
+
this.data[sub_pos] = undefined;
|
|
516
|
+
this.data[sub_pos + 1] = undefined;
|
|
399
517
|
}
|
|
400
|
-
|
|
401
|
-
|
|
518
|
+
destructor() {
|
|
519
|
+
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
520
|
+
const sub = this.data[cursor];
|
|
521
|
+
const pos = this.data[cursor + 1];
|
|
522
|
+
sub.pub_off(pos);
|
|
523
|
+
this.data.pop();
|
|
524
|
+
this.data.pop();
|
|
525
|
+
}
|
|
526
|
+
this.cursor = this.pub_from;
|
|
527
|
+
this.track_cut();
|
|
528
|
+
this.cursor = $mol_wire_cursor.final;
|
|
402
529
|
}
|
|
403
|
-
|
|
404
|
-
|
|
530
|
+
track_cut() {
|
|
531
|
+
if (this.cursor < this.pub_from) {
|
|
532
|
+
$mol_fail(new Error('Cut of non begun sub'));
|
|
533
|
+
}
|
|
534
|
+
let tail = 0;
|
|
535
|
+
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
|
536
|
+
const pub = this.data[cursor];
|
|
537
|
+
pub?.sub_off(this.data[cursor + 1]);
|
|
538
|
+
if (this.sub_from < this.data.length) {
|
|
539
|
+
this.peer_move(this.data.length - 2, cursor);
|
|
540
|
+
this.data.pop();
|
|
541
|
+
this.data.pop();
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
++tail;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
for (; tail; --tail) {
|
|
548
|
+
this.data.pop();
|
|
549
|
+
this.data.pop();
|
|
550
|
+
}
|
|
551
|
+
this.sub_from = this.cursor;
|
|
405
552
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
553
|
+
complete() { }
|
|
554
|
+
complete_pubs() {
|
|
555
|
+
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
|
556
|
+
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
557
|
+
const pub = this.data[cursor];
|
|
558
|
+
if (pub?.incompleted)
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
562
|
+
const pub = this.data[cursor];
|
|
563
|
+
pub?.complete();
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
absorb(quant = $mol_wire_cursor.stale) {
|
|
567
|
+
if (this.cursor === $mol_wire_cursor.final)
|
|
568
|
+
return;
|
|
569
|
+
if (this.cursor >= quant)
|
|
570
|
+
return;
|
|
571
|
+
this.cursor = quant;
|
|
572
|
+
this.emit($mol_wire_cursor.doubt);
|
|
573
|
+
}
|
|
574
|
+
[$mol_dev_format_head]() {
|
|
575
|
+
return $mol_dev_format_native(this);
|
|
576
|
+
}
|
|
577
|
+
get pub_empty() {
|
|
578
|
+
return this.sub_from === this.pub_from;
|
|
419
579
|
}
|
|
420
580
|
}
|
|
421
|
-
$.$
|
|
581
|
+
$.$mol_wire_pub_sub = $mol_wire_pub_sub;
|
|
422
582
|
})($ || ($ = {}));
|
|
423
583
|
|
|
424
584
|
;
|
|
425
585
|
"use strict";
|
|
426
586
|
var $;
|
|
427
587
|
(function ($) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
output.push("\n");
|
|
442
|
-
}
|
|
443
|
-
else if (tree.value.length || prefix.length) {
|
|
444
|
-
output.push("\\" + tree.value + "\n");
|
|
445
|
-
}
|
|
446
|
-
for (const kid of tree.kids) {
|
|
447
|
-
output.push(prefix);
|
|
448
|
-
dump(kid, prefix + "\t");
|
|
449
|
-
}
|
|
588
|
+
class $mol_after_timeout extends $mol_object2 {
|
|
589
|
+
delay;
|
|
590
|
+
task;
|
|
591
|
+
id;
|
|
592
|
+
constructor(delay, task) {
|
|
593
|
+
super();
|
|
594
|
+
this.delay = delay;
|
|
595
|
+
this.task = task;
|
|
596
|
+
this.id = setTimeout(task, delay);
|
|
597
|
+
}
|
|
598
|
+
destructor() {
|
|
599
|
+
clearTimeout(this.id);
|
|
450
600
|
}
|
|
451
|
-
dump(tree);
|
|
452
|
-
return output.join('');
|
|
453
601
|
}
|
|
454
|
-
$.$
|
|
602
|
+
$.$mol_after_timeout = $mol_after_timeout;
|
|
455
603
|
})($ || ($ = {}));
|
|
456
604
|
|
|
457
605
|
;
|
|
458
606
|
"use strict";
|
|
459
607
|
var $;
|
|
460
608
|
(function ($) {
|
|
461
|
-
class $
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
constructor(type, value, kids, span) {
|
|
467
|
-
super();
|
|
468
|
-
this.type = type;
|
|
469
|
-
this.value = value;
|
|
470
|
-
this.kids = kids;
|
|
471
|
-
this.span = span;
|
|
472
|
-
this[Symbol.toStringTag] = type || '\\' + value;
|
|
473
|
-
}
|
|
474
|
-
static list(kids, span = $mol_span.unknown) {
|
|
475
|
-
return new $mol_tree2('', '', kids, span);
|
|
476
|
-
}
|
|
477
|
-
list(kids) {
|
|
478
|
-
return $mol_tree2.list(kids, this.span);
|
|
479
|
-
}
|
|
480
|
-
static data(value, kids = [], span = $mol_span.unknown) {
|
|
481
|
-
const chunks = value.split('\n');
|
|
482
|
-
if (chunks.length > 1) {
|
|
483
|
-
let kid_span = span.span(span.row, span.col, 0);
|
|
484
|
-
const data = chunks.map(chunk => {
|
|
485
|
-
kid_span = kid_span.after(chunk.length);
|
|
486
|
-
return new $mol_tree2('', chunk, [], kid_span);
|
|
487
|
-
});
|
|
488
|
-
kids = [...data, ...kids];
|
|
489
|
-
value = '';
|
|
490
|
-
}
|
|
491
|
-
return new $mol_tree2('', value, kids, span);
|
|
492
|
-
}
|
|
493
|
-
data(value, kids = []) {
|
|
494
|
-
return $mol_tree2.data(value, kids, this.span);
|
|
495
|
-
}
|
|
496
|
-
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
497
|
-
if (/[ \n\t\\]/.test(type)) {
|
|
498
|
-
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
499
|
-
}
|
|
500
|
-
return new $mol_tree2(type, '', kids, span);
|
|
501
|
-
}
|
|
502
|
-
struct(type, kids = []) {
|
|
503
|
-
return $mol_tree2.struct(type, kids, this.span);
|
|
504
|
-
}
|
|
505
|
-
clone(kids, span = this.span) {
|
|
506
|
-
return new $mol_tree2(this.type, this.value, kids, span);
|
|
507
|
-
}
|
|
508
|
-
text() {
|
|
509
|
-
var values = [];
|
|
510
|
-
for (var kid of this.kids) {
|
|
511
|
-
if (kid.type)
|
|
512
|
-
continue;
|
|
513
|
-
values.push(kid.value);
|
|
514
|
-
}
|
|
515
|
-
return this.value + values.join('\n');
|
|
516
|
-
}
|
|
517
|
-
static fromString(str, uri = 'unknown') {
|
|
518
|
-
return $$.$mol_tree2_from_string(str, uri);
|
|
519
|
-
}
|
|
520
|
-
toString() {
|
|
521
|
-
return $$.$mol_tree2_to_string(this);
|
|
522
|
-
}
|
|
523
|
-
insert(value, ...path) {
|
|
524
|
-
if (path.length === 0)
|
|
525
|
-
return value;
|
|
526
|
-
const type = path[0];
|
|
527
|
-
if (typeof type === 'string') {
|
|
528
|
-
let replaced = false;
|
|
529
|
-
const sub = this.kids.map((item, index) => {
|
|
530
|
-
if (item.type !== type)
|
|
531
|
-
return item;
|
|
532
|
-
replaced = true;
|
|
533
|
-
return item.insert(value, ...path.slice(1));
|
|
534
|
-
}).filter(Boolean);
|
|
535
|
-
if (!replaced && value) {
|
|
536
|
-
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
537
|
-
}
|
|
538
|
-
return this.clone(sub);
|
|
539
|
-
}
|
|
540
|
-
else if (typeof type === 'number') {
|
|
541
|
-
const sub = this.kids.slice();
|
|
542
|
-
sub[type] = (sub[type] || this.list([]))
|
|
543
|
-
.insert(value, ...path.slice(1));
|
|
544
|
-
return this.clone(sub.filter(Boolean));
|
|
545
|
-
}
|
|
546
|
-
else {
|
|
547
|
-
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
548
|
-
.map(item => item.insert(value, ...path.slice(1)))
|
|
549
|
-
.filter(Boolean);
|
|
550
|
-
return this.clone(kids);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
select(...path) {
|
|
554
|
-
let next = [this];
|
|
555
|
-
for (const type of path) {
|
|
556
|
-
if (!next.length)
|
|
557
|
-
break;
|
|
558
|
-
const prev = next;
|
|
559
|
-
next = [];
|
|
560
|
-
for (var item of prev) {
|
|
561
|
-
switch (typeof (type)) {
|
|
562
|
-
case 'string':
|
|
563
|
-
for (var child of item.kids) {
|
|
564
|
-
if (child.type == type) {
|
|
565
|
-
next.push(child);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
break;
|
|
569
|
-
case 'number':
|
|
570
|
-
if (type < item.kids.length)
|
|
571
|
-
next.push(item.kids[type]);
|
|
572
|
-
break;
|
|
573
|
-
default: next.push(...item.kids);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
return this.list(next);
|
|
578
|
-
}
|
|
579
|
-
filter(path, value) {
|
|
580
|
-
const sub = this.kids.filter(item => {
|
|
581
|
-
var found = item.select(...path);
|
|
582
|
-
if (value === undefined) {
|
|
583
|
-
return Boolean(found.kids.length);
|
|
584
|
-
}
|
|
585
|
-
else {
|
|
586
|
-
return found.kids.some(child => child.value == value);
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
return this.clone(sub);
|
|
590
|
-
}
|
|
591
|
-
hack_self(belt, context = {}) {
|
|
592
|
-
let handle = belt[this.type] || belt[''];
|
|
593
|
-
if (!handle || handle === Object.prototype[this.type]) {
|
|
594
|
-
handle = (input, belt, context) => [
|
|
595
|
-
input.clone(input.hack(belt, context), context.span)
|
|
596
|
-
];
|
|
597
|
-
}
|
|
598
|
-
try {
|
|
599
|
-
return handle(this, belt, context);
|
|
600
|
-
}
|
|
601
|
-
catch (error) {
|
|
602
|
-
error.message += `\n${this.clone([])}${this.span}`;
|
|
603
|
-
$mol_fail_hidden(error);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
hack(belt, context = {}) {
|
|
607
|
-
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
608
|
-
}
|
|
609
|
-
error(message, Class = Error) {
|
|
610
|
-
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
$.$mol_tree2 = $mol_tree2;
|
|
614
|
-
class $mol_tree2_empty extends $mol_tree2 {
|
|
615
|
-
constructor() {
|
|
616
|
-
super('', '', [], $mol_span.unknown);
|
|
609
|
+
class $mol_after_frame extends $mol_after_timeout {
|
|
610
|
+
task;
|
|
611
|
+
constructor(task) {
|
|
612
|
+
super(16, task);
|
|
613
|
+
this.task = task;
|
|
617
614
|
}
|
|
618
615
|
}
|
|
619
|
-
$.$
|
|
616
|
+
$.$mol_after_frame = $mol_after_frame;
|
|
620
617
|
})($ || ($ = {}));
|
|
621
618
|
|
|
622
619
|
;
|
|
623
620
|
"use strict";
|
|
624
621
|
var $;
|
|
625
622
|
(function ($) {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
line;
|
|
629
|
-
span;
|
|
630
|
-
constructor(reason, line, span) {
|
|
631
|
-
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
632
|
-
this.reason = reason;
|
|
633
|
-
this.line = line;
|
|
634
|
-
this.span = span;
|
|
635
|
-
}
|
|
623
|
+
function $mol_promise_like(val) {
|
|
624
|
+
return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
|
|
636
625
|
}
|
|
637
|
-
$.$
|
|
626
|
+
$.$mol_promise_like = $mol_promise_like;
|
|
638
627
|
})($ || ($ = {}));
|
|
639
628
|
|
|
640
629
|
;
|
|
641
630
|
"use strict";
|
|
642
631
|
var $;
|
|
643
632
|
(function ($) {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
min_indent = indent;
|
|
659
|
-
}
|
|
660
|
-
indent -= min_indent;
|
|
661
|
-
if (indent < 0 || indent >= stack.length) {
|
|
662
|
-
const sp = span.span(row, 1, pos - line_start);
|
|
663
|
-
while (str.length > pos && str[pos] != '\n') {
|
|
664
|
-
pos++;
|
|
665
|
-
}
|
|
666
|
-
if (indent < 0) {
|
|
667
|
-
if (str.length > pos) {
|
|
668
|
-
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
else {
|
|
672
|
-
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
stack.length = indent + 1;
|
|
676
|
-
var parent = stack[indent];
|
|
677
|
-
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
678
|
-
var error_start = pos;
|
|
679
|
-
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
680
|
-
pos++;
|
|
681
|
-
}
|
|
682
|
-
if (pos > error_start) {
|
|
683
|
-
let line_end = str.indexOf('\n', pos);
|
|
684
|
-
if (line_end === -1)
|
|
685
|
-
line_end = str.length;
|
|
686
|
-
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
687
|
-
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
688
|
-
}
|
|
689
|
-
var type_start = pos;
|
|
690
|
-
while (str.length > pos &&
|
|
691
|
-
str[pos] != '\\' &&
|
|
692
|
-
str[pos] != ' ' &&
|
|
693
|
-
str[pos] != '\t' &&
|
|
694
|
-
str[pos] != '\n') {
|
|
695
|
-
pos++;
|
|
633
|
+
const handled = new WeakSet();
|
|
634
|
+
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
635
|
+
task;
|
|
636
|
+
host;
|
|
637
|
+
static warm = true;
|
|
638
|
+
static planning = new Set();
|
|
639
|
+
static reaping = new Set();
|
|
640
|
+
static plan_task = null;
|
|
641
|
+
static plan() {
|
|
642
|
+
if (this.plan_task)
|
|
643
|
+
return;
|
|
644
|
+
this.plan_task = new $mol_after_frame(() => {
|
|
645
|
+
try {
|
|
646
|
+
this.sync();
|
|
696
647
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
const parent_kids = parent.kids;
|
|
700
|
-
parent_kids.push(next);
|
|
701
|
-
parent = next;
|
|
648
|
+
finally {
|
|
649
|
+
$mol_wire_fiber.plan_task = null;
|
|
702
650
|
}
|
|
703
|
-
|
|
704
|
-
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
static sync() {
|
|
654
|
+
while (this.planning.size) {
|
|
655
|
+
for (const fiber of this.planning) {
|
|
656
|
+
this.planning.delete(fiber);
|
|
657
|
+
if (fiber.cursor >= 0)
|
|
658
|
+
continue;
|
|
659
|
+
if (fiber.cursor === $mol_wire_cursor.final)
|
|
660
|
+
continue;
|
|
661
|
+
fiber.fresh();
|
|
705
662
|
}
|
|
706
663
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
664
|
+
while (this.reaping.size) {
|
|
665
|
+
const fibers = this.reaping;
|
|
666
|
+
this.reaping = new Set;
|
|
667
|
+
for (const fiber of fibers) {
|
|
668
|
+
if (!fiber.sub_empty)
|
|
669
|
+
continue;
|
|
670
|
+
fiber.destructor();
|
|
711
671
|
}
|
|
712
|
-
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
713
|
-
const parent_kids = parent.kids;
|
|
714
|
-
parent_kids.push(next);
|
|
715
|
-
parent = next;
|
|
716
|
-
}
|
|
717
|
-
if (str.length === pos && stack.length > 0) {
|
|
718
|
-
const sp = span.span(row, pos - line_start + 1, 1);
|
|
719
|
-
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
720
672
|
}
|
|
721
|
-
stack.push(parent);
|
|
722
|
-
pos++;
|
|
723
|
-
}
|
|
724
|
-
return root;
|
|
725
|
-
}
|
|
726
|
-
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
727
|
-
})($ || ($ = {}));
|
|
728
|
-
|
|
729
|
-
;
|
|
730
|
-
"use strict";
|
|
731
|
-
var $;
|
|
732
|
-
(function ($) {
|
|
733
|
-
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
734
|
-
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
735
|
-
return new $mol_tree2(String(json), '', [], span);
|
|
736
673
|
}
|
|
737
|
-
|
|
738
|
-
|
|
674
|
+
[Symbol.toStringTag];
|
|
675
|
+
cache = undefined;
|
|
676
|
+
get args() {
|
|
677
|
+
return this.data.slice(0, this.pub_from);
|
|
739
678
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
679
|
+
result() {
|
|
680
|
+
if ($mol_promise_like(this.cache))
|
|
681
|
+
return;
|
|
682
|
+
if (this.cache instanceof Error)
|
|
683
|
+
return;
|
|
684
|
+
return this.cache;
|
|
743
685
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
686
|
+
get incompleted() {
|
|
687
|
+
return $mol_promise_like(this.cache);
|
|
747
688
|
}
|
|
748
|
-
|
|
749
|
-
return
|
|
689
|
+
field() {
|
|
690
|
+
return this.task.name + '<>';
|
|
750
691
|
}
|
|
751
|
-
|
|
752
|
-
|
|
692
|
+
constructor(id, task, host, args) {
|
|
693
|
+
super();
|
|
694
|
+
this.task = task;
|
|
695
|
+
this.host = host;
|
|
696
|
+
if (args)
|
|
697
|
+
this.data.push(...args);
|
|
698
|
+
this.pub_from = this.sub_from = args?.length ?? 0;
|
|
699
|
+
this[Symbol.toStringTag] = id;
|
|
753
700
|
}
|
|
754
|
-
|
|
755
|
-
|
|
701
|
+
plan() {
|
|
702
|
+
$mol_wire_fiber.planning.add(this);
|
|
703
|
+
$mol_wire_fiber.plan();
|
|
756
704
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
705
|
+
reap() {
|
|
706
|
+
$mol_wire_fiber.reaping.add(this);
|
|
707
|
+
$mol_wire_fiber.plan();
|
|
760
708
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
709
|
+
toString() {
|
|
710
|
+
return this[Symbol.toStringTag];
|
|
711
|
+
}
|
|
712
|
+
toJSON() {
|
|
713
|
+
return this[Symbol.toStringTag];
|
|
714
|
+
}
|
|
715
|
+
[$mol_dev_format_head]() {
|
|
716
|
+
const cursor = {
|
|
717
|
+
[$mol_wire_cursor.stale]: '🔴',
|
|
718
|
+
[$mol_wire_cursor.doubt]: '🟡',
|
|
719
|
+
[$mol_wire_cursor.fresh]: '🟢',
|
|
720
|
+
[$mol_wire_cursor.final]: '🔵',
|
|
721
|
+
}[this.cursor] ?? this.cursor.toString();
|
|
722
|
+
return $mol_dev_format_div({}, $mol_owning_check(this, this.cache)
|
|
723
|
+
? $mol_dev_format_auto({
|
|
724
|
+
[$mol_dev_format_head]: () => $mol_dev_format_shade(cursor),
|
|
725
|
+
[$mol_dev_format_body]: () => $mol_dev_format_native(this),
|
|
726
|
+
})
|
|
727
|
+
: $mol_dev_format_shade($mol_dev_format_native(this), cursor), $mol_dev_format_auto(this.cache));
|
|
728
|
+
}
|
|
729
|
+
get $() {
|
|
730
|
+
return (this.host ?? this.task)['$'];
|
|
731
|
+
}
|
|
732
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
733
|
+
if (this.sub_empty)
|
|
734
|
+
this.plan();
|
|
735
|
+
else
|
|
736
|
+
super.emit(quant);
|
|
737
|
+
}
|
|
738
|
+
fresh() {
|
|
739
|
+
if (this.cursor === $mol_wire_cursor.fresh)
|
|
740
|
+
return;
|
|
741
|
+
if (this.cursor === $mol_wire_cursor.final)
|
|
742
|
+
return;
|
|
743
|
+
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
744
|
+
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
745
|
+
;
|
|
746
|
+
this.data[i]?.fresh();
|
|
747
|
+
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
748
|
+
break check;
|
|
749
|
+
}
|
|
750
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
751
|
+
return;
|
|
769
752
|
}
|
|
770
|
-
|
|
771
|
-
|
|
753
|
+
const bu = this.track_on();
|
|
754
|
+
let result;
|
|
755
|
+
try {
|
|
756
|
+
switch (this.pub_from) {
|
|
757
|
+
case 0:
|
|
758
|
+
result = this.task.call(this.host);
|
|
759
|
+
break;
|
|
760
|
+
case 1:
|
|
761
|
+
result = this.task.call(this.host, this.data[0]);
|
|
762
|
+
break;
|
|
763
|
+
default:
|
|
764
|
+
result = this.task.call(this.host, ...this.args);
|
|
765
|
+
break;
|
|
766
|
+
}
|
|
767
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
768
|
+
const put = (res) => {
|
|
769
|
+
if (this.cache === result)
|
|
770
|
+
this.put(res);
|
|
771
|
+
return res;
|
|
772
|
+
};
|
|
773
|
+
result = result.then(put, put);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
catch (error) {
|
|
777
|
+
if (error instanceof Error || $mol_promise_like(error)) {
|
|
778
|
+
result = error;
|
|
779
|
+
}
|
|
780
|
+
else {
|
|
781
|
+
result = new Error(String(error), { cause: error });
|
|
782
|
+
}
|
|
783
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
784
|
+
result = result.finally(() => {
|
|
785
|
+
if (this.cache === result)
|
|
786
|
+
this.absorb();
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
791
|
+
result = Object.assign(result, {
|
|
792
|
+
destructor: result['destructor'] ?? (() => { })
|
|
793
|
+
});
|
|
794
|
+
handled.add(result);
|
|
795
|
+
const error = new Error(`Promise in ${this}`);
|
|
796
|
+
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
797
|
+
}
|
|
798
|
+
if (!$mol_promise_like(result)) {
|
|
799
|
+
this.track_cut();
|
|
772
800
|
}
|
|
801
|
+
this.track_off(bu);
|
|
802
|
+
this.put(result);
|
|
773
803
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
(
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
};
|
|
804
|
+
refresh() {
|
|
805
|
+
this.cursor = $mol_wire_cursor.stale;
|
|
806
|
+
this.fresh();
|
|
807
|
+
}
|
|
808
|
+
sync() {
|
|
809
|
+
if (!$mol_wire_fiber.warm) {
|
|
810
|
+
return this.result();
|
|
811
|
+
}
|
|
812
|
+
this.promote();
|
|
813
|
+
this.fresh();
|
|
814
|
+
if (this.cache instanceof Error) {
|
|
815
|
+
return $mol_fail_hidden(this.cache);
|
|
816
|
+
}
|
|
817
|
+
if ($mol_promise_like(this.cache)) {
|
|
818
|
+
return $mol_fail_hidden(this.cache);
|
|
819
|
+
}
|
|
820
|
+
return this.cache;
|
|
821
|
+
}
|
|
822
|
+
async async() {
|
|
823
|
+
while (true) {
|
|
824
|
+
this.fresh();
|
|
825
|
+
if (this.cache instanceof Error) {
|
|
826
|
+
$mol_fail_hidden(this.cache);
|
|
827
|
+
}
|
|
828
|
+
if (!$mol_promise_like(this.cache))
|
|
829
|
+
return this.cache;
|
|
830
|
+
await Promise.race([this.cache, this.step()]);
|
|
831
|
+
if (!$mol_promise_like(this.cache))
|
|
832
|
+
return this.cache;
|
|
833
|
+
if (this.cursor === $mol_wire_cursor.final) {
|
|
834
|
+
await new Promise(() => { });
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
step() {
|
|
839
|
+
return new Promise(done => {
|
|
840
|
+
const sub = new $mol_wire_pub_sub;
|
|
841
|
+
const prev = sub.track_on();
|
|
842
|
+
sub.track_next(this);
|
|
843
|
+
sub.track_off(prev);
|
|
844
|
+
sub.absorb = () => {
|
|
845
|
+
done(null);
|
|
846
|
+
sub.destructor();
|
|
847
|
+
};
|
|
848
|
+
});
|
|
820
849
|
}
|
|
821
850
|
}
|
|
822
|
-
$.$
|
|
851
|
+
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
823
852
|
})($ || ($ = {}));
|
|
824
853
|
|
|
825
854
|
;
|
|
826
855
|
"use strict";
|
|
827
856
|
var $;
|
|
828
857
|
(function ($) {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
return
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
;
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
(
|
|
854
|
-
|
|
855
|
-
|
|
858
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
859
|
+
function $mol_compare_deep(left, right) {
|
|
860
|
+
if (Object.is(left, right))
|
|
861
|
+
return true;
|
|
862
|
+
if (left === null)
|
|
863
|
+
return false;
|
|
864
|
+
if (right === null)
|
|
865
|
+
return false;
|
|
866
|
+
if (typeof left !== 'object')
|
|
867
|
+
return false;
|
|
868
|
+
if (typeof right !== 'object')
|
|
869
|
+
return false;
|
|
870
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
871
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
872
|
+
if (left_proto !== right_proto)
|
|
873
|
+
return false;
|
|
874
|
+
if (left instanceof Boolean)
|
|
875
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
876
|
+
if (left instanceof Number)
|
|
877
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
878
|
+
if (left instanceof String)
|
|
879
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
880
|
+
if (left instanceof Date)
|
|
881
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
882
|
+
if (left instanceof RegExp)
|
|
883
|
+
return left.source === right.source && left.flags === right.flags;
|
|
884
|
+
if (left instanceof Error)
|
|
885
|
+
return left.message === right.message && left.stack === right.stack;
|
|
886
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
887
|
+
if (left_cache) {
|
|
888
|
+
const right_cache = left_cache.get(right);
|
|
889
|
+
if (typeof right_cache === 'boolean')
|
|
890
|
+
return right_cache;
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
left_cache = new WeakMap([[right, true]]);
|
|
894
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
895
|
+
}
|
|
896
|
+
let result;
|
|
897
|
+
try {
|
|
898
|
+
if (!left_proto)
|
|
899
|
+
result = compare_pojo(left, right);
|
|
900
|
+
else if (!Reflect.getPrototypeOf(left_proto))
|
|
901
|
+
result = compare_pojo(left, right);
|
|
902
|
+
else if (Symbol.toPrimitive in left)
|
|
903
|
+
result = compare_primitive(left, right);
|
|
904
|
+
else if (Array.isArray(left))
|
|
905
|
+
result = compare_array(left, right);
|
|
906
|
+
else if (left instanceof Set)
|
|
907
|
+
result = compare_set(left, right);
|
|
908
|
+
else if (left instanceof Map)
|
|
909
|
+
result = compare_map(left, right);
|
|
910
|
+
else if (ArrayBuffer.isView(left))
|
|
911
|
+
result = compare_buffer(left, right);
|
|
912
|
+
else if (Symbol.iterator in left)
|
|
913
|
+
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
914
|
+
else
|
|
915
|
+
result = false;
|
|
916
|
+
}
|
|
917
|
+
finally {
|
|
918
|
+
left_cache.set(right, result);
|
|
919
|
+
}
|
|
920
|
+
return result;
|
|
921
|
+
}
|
|
922
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
923
|
+
function compare_array(left, right) {
|
|
924
|
+
const len = left.length;
|
|
925
|
+
if (len !== right.length)
|
|
926
|
+
return false;
|
|
927
|
+
for (let i = 0; i < len; ++i) {
|
|
928
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
return true;
|
|
932
|
+
}
|
|
933
|
+
function compare_buffer(left, right) {
|
|
934
|
+
const len = left.byteLength;
|
|
935
|
+
if (len !== right.byteLength)
|
|
936
|
+
return false;
|
|
937
|
+
if (left instanceof DataView)
|
|
938
|
+
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
|
939
|
+
for (let i = 0; i < len; ++i) {
|
|
940
|
+
if (left[i] !== right[i])
|
|
941
|
+
return false;
|
|
942
|
+
}
|
|
943
|
+
return true;
|
|
944
|
+
}
|
|
945
|
+
function compare_iterator(left, right) {
|
|
946
|
+
while (true) {
|
|
947
|
+
const left_next = left.next();
|
|
948
|
+
const right_next = right.next();
|
|
949
|
+
if (left_next.done !== right_next.done)
|
|
950
|
+
return false;
|
|
951
|
+
if (left_next.done)
|
|
952
|
+
break;
|
|
953
|
+
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
954
|
+
return false;
|
|
955
|
+
}
|
|
956
|
+
return true;
|
|
957
|
+
}
|
|
958
|
+
function compare_set(left, right) {
|
|
959
|
+
if (left.size !== right.size)
|
|
960
|
+
return false;
|
|
961
|
+
return compare_iterator(left.values(), right.values());
|
|
962
|
+
}
|
|
963
|
+
function compare_map(left, right) {
|
|
964
|
+
if (left.size !== right.size)
|
|
965
|
+
return false;
|
|
966
|
+
return compare_iterator(left.keys(), right.keys())
|
|
967
|
+
&& compare_iterator(left.values(), right.values());
|
|
968
|
+
}
|
|
969
|
+
function compare_pojo(left, right) {
|
|
970
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
971
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
972
|
+
if (!compare_array(left_keys, right_keys))
|
|
973
|
+
return false;
|
|
974
|
+
for (let key of left_keys) {
|
|
975
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
976
|
+
return false;
|
|
977
|
+
}
|
|
978
|
+
const left_syms = Object.getOwnPropertySymbols(left);
|
|
979
|
+
const right_syms = Object.getOwnPropertySymbols(right);
|
|
980
|
+
if (!compare_array(left_syms, right_syms))
|
|
981
|
+
return false;
|
|
982
|
+
for (let key of left_syms) {
|
|
983
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
984
|
+
return false;
|
|
985
|
+
}
|
|
986
|
+
return true;
|
|
987
|
+
}
|
|
988
|
+
function compare_primitive(left, right) {
|
|
989
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
856
990
|
}
|
|
857
|
-
$.$mol_env = $mol_env;
|
|
858
|
-
})($ || ($ = {}));
|
|
859
|
-
|
|
860
|
-
;
|
|
861
|
-
"use strict";
|
|
862
|
-
var $;
|
|
863
|
-
(function ($) {
|
|
864
|
-
$.$mol_env = function $mol_env() {
|
|
865
|
-
return this.process.env;
|
|
866
|
-
};
|
|
867
991
|
})($ || ($ = {}));
|
|
868
992
|
|
|
869
993
|
;
|
|
870
994
|
"use strict";
|
|
871
995
|
var $;
|
|
872
996
|
(function ($) {
|
|
873
|
-
function $
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
});
|
|
882
|
-
var res = $node['child_process'].spawnSync(app, args, {
|
|
883
|
-
cwd: $node.path.resolve(dir),
|
|
884
|
-
shell: true,
|
|
885
|
-
env: this.$mol_env(),
|
|
997
|
+
function $mol_log3_area_lazy(event) {
|
|
998
|
+
const self = this;
|
|
999
|
+
const stack = self.$mol_log3_stack;
|
|
1000
|
+
const deep = stack.length;
|
|
1001
|
+
let logged = false;
|
|
1002
|
+
stack.push(() => {
|
|
1003
|
+
logged = true;
|
|
1004
|
+
self.$mol_log3_area.call(self, event);
|
|
886
1005
|
});
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1006
|
+
return () => {
|
|
1007
|
+
if (logged)
|
|
1008
|
+
self.console.groupEnd();
|
|
1009
|
+
if (stack.length > deep)
|
|
1010
|
+
stack.length = deep;
|
|
1011
|
+
};
|
|
893
1012
|
}
|
|
894
|
-
$.$
|
|
1013
|
+
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1014
|
+
$.$mol_log3_stack = [];
|
|
895
1015
|
})($ || ($ = {}));
|
|
896
1016
|
|
|
897
1017
|
;
|
|
898
1018
|
"use strict";
|
|
899
1019
|
var $;
|
|
900
1020
|
(function ($) {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
1021
|
+
class $mol_span extends $mol_object2 {
|
|
1022
|
+
uri;
|
|
1023
|
+
source;
|
|
1024
|
+
row;
|
|
1025
|
+
col;
|
|
1026
|
+
length;
|
|
1027
|
+
constructor(uri, source, row, col, length) {
|
|
1028
|
+
super();
|
|
1029
|
+
this.uri = uri;
|
|
1030
|
+
this.source = source;
|
|
1031
|
+
this.row = row;
|
|
1032
|
+
this.col = col;
|
|
1033
|
+
this.length = length;
|
|
1034
|
+
this[Symbol.toStringTag] = `${this.uri}#${this.row}:${this.col}/${this.length}`;
|
|
1035
|
+
}
|
|
1036
|
+
static unknown = $mol_span.begin('?');
|
|
1037
|
+
static begin(uri, source = '') {
|
|
1038
|
+
return new $mol_span(uri, source, 1, 1, 0);
|
|
1039
|
+
}
|
|
1040
|
+
static end(uri, source) {
|
|
1041
|
+
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1042
|
+
}
|
|
1043
|
+
static entire(uri, source) {
|
|
1044
|
+
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1045
|
+
}
|
|
1046
|
+
toString() {
|
|
1047
|
+
return this[Symbol.toStringTag];
|
|
1048
|
+
}
|
|
1049
|
+
toJSON() {
|
|
1050
|
+
return {
|
|
1051
|
+
uri: this.uri,
|
|
1052
|
+
row: this.row,
|
|
1053
|
+
col: this.col,
|
|
1054
|
+
length: this.length
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
error(message, Class = Error) {
|
|
1058
|
+
return new Class(`${message} (${this})`);
|
|
1059
|
+
}
|
|
1060
|
+
span(row, col, length) {
|
|
1061
|
+
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1062
|
+
}
|
|
1063
|
+
after(length = 0) {
|
|
1064
|
+
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1065
|
+
}
|
|
1066
|
+
slice(begin, end = -1) {
|
|
1067
|
+
let len = this.length;
|
|
1068
|
+
if (begin < 0)
|
|
1069
|
+
begin += len;
|
|
1070
|
+
if (end < 0)
|
|
1071
|
+
end += len;
|
|
1072
|
+
if (begin < 0 || begin > len)
|
|
1073
|
+
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
1074
|
+
if (end < 0 || end > len)
|
|
1075
|
+
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
1076
|
+
if (end < begin)
|
|
1077
|
+
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
1078
|
+
return this.span(this.row, this.col + begin, end - begin);
|
|
1079
|
+
}
|
|
905
1080
|
}
|
|
906
|
-
$.$
|
|
1081
|
+
$.$mol_span = $mol_span;
|
|
907
1082
|
})($ || ($ = {}));
|
|
908
1083
|
|
|
909
1084
|
;
|
|
910
1085
|
"use strict";
|
|
911
1086
|
var $;
|
|
912
1087
|
(function ($) {
|
|
913
|
-
function $
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1088
|
+
function $mol_tree2_to_string(tree) {
|
|
1089
|
+
let output = [];
|
|
1090
|
+
function dump(tree, prefix = '') {
|
|
1091
|
+
if (tree.type.length) {
|
|
1092
|
+
if (!prefix.length) {
|
|
1093
|
+
prefix = "\t";
|
|
1094
|
+
}
|
|
1095
|
+
output.push(tree.type);
|
|
1096
|
+
if (tree.kids.length == 1) {
|
|
1097
|
+
output.push(' ');
|
|
1098
|
+
dump(tree.kids[0], prefix);
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
output.push("\n");
|
|
1102
|
+
}
|
|
1103
|
+
else if (tree.value.length || prefix.length) {
|
|
1104
|
+
output.push("\\" + tree.value + "\n");
|
|
1105
|
+
}
|
|
1106
|
+
for (const kid of tree.kids) {
|
|
1107
|
+
output.push(prefix);
|
|
1108
|
+
dump(kid, prefix + "\t");
|
|
1109
|
+
}
|
|
934
1110
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
hi: (int_hi - $.$mol_int62_min) % $.$mol_int62_range + $.$mol_int62_min,
|
|
938
|
-
};
|
|
939
|
-
}
|
|
940
|
-
$.$mol_int62_from_string = $mol_int62_from_string;
|
|
941
|
-
function $mol_int62_compare(left_lo, left_hi, right_lo, right_hi) {
|
|
942
|
-
return (right_hi - left_hi) || (right_lo - left_lo);
|
|
1111
|
+
dump(tree);
|
|
1112
|
+
return output.join('');
|
|
943
1113
|
}
|
|
944
|
-
$.$
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1114
|
+
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
1115
|
+
})($ || ($ = {}));
|
|
1116
|
+
|
|
1117
|
+
;
|
|
1118
|
+
"use strict";
|
|
1119
|
+
var $;
|
|
1120
|
+
(function ($) {
|
|
1121
|
+
class $mol_tree2 extends Object {
|
|
1122
|
+
type;
|
|
1123
|
+
value;
|
|
1124
|
+
kids;
|
|
1125
|
+
span;
|
|
1126
|
+
constructor(type, value, kids, span) {
|
|
1127
|
+
super();
|
|
1128
|
+
this.type = type;
|
|
1129
|
+
this.value = value;
|
|
1130
|
+
this.kids = kids;
|
|
1131
|
+
this.span = span;
|
|
1132
|
+
this[Symbol.toStringTag] = type || '\\' + value;
|
|
948
1133
|
}
|
|
949
|
-
|
|
950
|
-
return
|
|
1134
|
+
static list(kids, span = $mol_span.unknown) {
|
|
1135
|
+
return new $mol_tree2('', '', kids, span);
|
|
1136
|
+
}
|
|
1137
|
+
list(kids) {
|
|
1138
|
+
return $mol_tree2.list(kids, this.span);
|
|
1139
|
+
}
|
|
1140
|
+
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1141
|
+
const chunks = value.split('\n');
|
|
1142
|
+
if (chunks.length > 1) {
|
|
1143
|
+
let kid_span = span.span(span.row, span.col, 0);
|
|
1144
|
+
const data = chunks.map(chunk => {
|
|
1145
|
+
kid_span = kid_span.after(chunk.length);
|
|
1146
|
+
return new $mol_tree2('', chunk, [], kid_span);
|
|
1147
|
+
});
|
|
1148
|
+
kids = [...data, ...kids];
|
|
1149
|
+
value = '';
|
|
1150
|
+
}
|
|
1151
|
+
return new $mol_tree2('', value, kids, span);
|
|
1152
|
+
}
|
|
1153
|
+
data(value, kids = []) {
|
|
1154
|
+
return $mol_tree2.data(value, kids, this.span);
|
|
1155
|
+
}
|
|
1156
|
+
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1157
|
+
if (/[ \n\t\\]/.test(type)) {
|
|
1158
|
+
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1159
|
+
}
|
|
1160
|
+
return new $mol_tree2(type, '', kids, span);
|
|
1161
|
+
}
|
|
1162
|
+
struct(type, kids = []) {
|
|
1163
|
+
return $mol_tree2.struct(type, kids, this.span);
|
|
1164
|
+
}
|
|
1165
|
+
clone(kids, span = this.span) {
|
|
1166
|
+
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1167
|
+
}
|
|
1168
|
+
text() {
|
|
1169
|
+
var values = [];
|
|
1170
|
+
for (var kid of this.kids) {
|
|
1171
|
+
if (kid.type)
|
|
1172
|
+
continue;
|
|
1173
|
+
values.push(kid.value);
|
|
1174
|
+
}
|
|
1175
|
+
return this.value + values.join('\n');
|
|
1176
|
+
}
|
|
1177
|
+
static fromString(str, uri = 'unknown') {
|
|
1178
|
+
return $$.$mol_tree2_from_string(str, uri);
|
|
1179
|
+
}
|
|
1180
|
+
toString() {
|
|
1181
|
+
return $$.$mol_tree2_to_string(this);
|
|
1182
|
+
}
|
|
1183
|
+
insert(value, ...path) {
|
|
1184
|
+
if (path.length === 0)
|
|
1185
|
+
return value;
|
|
1186
|
+
const type = path[0];
|
|
1187
|
+
if (typeof type === 'string') {
|
|
1188
|
+
let replaced = false;
|
|
1189
|
+
const sub = this.kids.map((item, index) => {
|
|
1190
|
+
if (item.type !== type)
|
|
1191
|
+
return item;
|
|
1192
|
+
replaced = true;
|
|
1193
|
+
return item.insert(value, ...path.slice(1));
|
|
1194
|
+
}).filter(Boolean);
|
|
1195
|
+
if (!replaced && value) {
|
|
1196
|
+
sub.push(this.struct(type, []).insert(value, ...path.slice(1)));
|
|
1197
|
+
}
|
|
1198
|
+
return this.clone(sub);
|
|
1199
|
+
}
|
|
1200
|
+
else if (typeof type === 'number') {
|
|
1201
|
+
const sub = this.kids.slice();
|
|
1202
|
+
sub[type] = (sub[type] || this.list([]))
|
|
1203
|
+
.insert(value, ...path.slice(1));
|
|
1204
|
+
return this.clone(sub.filter(Boolean));
|
|
1205
|
+
}
|
|
1206
|
+
else {
|
|
1207
|
+
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1208
|
+
.map(item => item.insert(value, ...path.slice(1)))
|
|
1209
|
+
.filter(Boolean);
|
|
1210
|
+
return this.clone(kids);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
select(...path) {
|
|
1214
|
+
let next = [this];
|
|
1215
|
+
for (const type of path) {
|
|
1216
|
+
if (!next.length)
|
|
1217
|
+
break;
|
|
1218
|
+
const prev = next;
|
|
1219
|
+
next = [];
|
|
1220
|
+
for (var item of prev) {
|
|
1221
|
+
switch (typeof (type)) {
|
|
1222
|
+
case 'string':
|
|
1223
|
+
for (var child of item.kids) {
|
|
1224
|
+
if (child.type == type) {
|
|
1225
|
+
next.push(child);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
break;
|
|
1229
|
+
case 'number':
|
|
1230
|
+
if (type < item.kids.length)
|
|
1231
|
+
next.push(item.kids[type]);
|
|
1232
|
+
break;
|
|
1233
|
+
default: next.push(...item.kids);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
return this.list(next);
|
|
1238
|
+
}
|
|
1239
|
+
filter(path, value) {
|
|
1240
|
+
const sub = this.kids.filter(item => {
|
|
1241
|
+
var found = item.select(...path);
|
|
1242
|
+
if (value === undefined) {
|
|
1243
|
+
return Boolean(found.kids.length);
|
|
1244
|
+
}
|
|
1245
|
+
else {
|
|
1246
|
+
return found.kids.some(child => child.value == value);
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
return this.clone(sub);
|
|
1250
|
+
}
|
|
1251
|
+
hack_self(belt, context = {}) {
|
|
1252
|
+
let handle = belt[this.type] || belt[''];
|
|
1253
|
+
if (!handle || handle === Object.prototype[this.type]) {
|
|
1254
|
+
handle = (input, belt, context) => [
|
|
1255
|
+
input.clone(input.hack(belt, context), context.span)
|
|
1256
|
+
];
|
|
1257
|
+
}
|
|
1258
|
+
try {
|
|
1259
|
+
return handle(this, belt, context);
|
|
1260
|
+
}
|
|
1261
|
+
catch (error) {
|
|
1262
|
+
error.message += `\n${this.clone([])}${this.span}`;
|
|
1263
|
+
$mol_fail_hidden(error);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
hack(belt, context = {}) {
|
|
1267
|
+
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
1268
|
+
}
|
|
1269
|
+
error(message, Class = Error) {
|
|
1270
|
+
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
951
1271
|
}
|
|
952
1272
|
}
|
|
953
|
-
$.$
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
hi: Math.floor(Math.random() * $.$mol_int62_range + $.$mol_int62_min),
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
$.$mol_int62_random = $mol_int62_random;
|
|
961
|
-
function $mol_int62_hash_string(str) {
|
|
962
|
-
return $mol_int62_to_string($mol_int62_hash_buffer($mol_charset_encode(str)));
|
|
963
|
-
}
|
|
964
|
-
$.$mol_int62_hash_string = $mol_int62_hash_string;
|
|
965
|
-
function $mol_int62_hash_buffer(buf, seed = { lo: 0, hi: 0 }) {
|
|
966
|
-
let h1 = 0xdeadbeef ^ seed.lo;
|
|
967
|
-
let h2 = 0x41c6ce57 ^ seed.hi;
|
|
968
|
-
for (const byte of buf) {
|
|
969
|
-
h1 = Math.imul(h1 ^ byte, 2654435761);
|
|
970
|
-
h2 = Math.imul(h2 ^ byte, 1597334677);
|
|
1273
|
+
$.$mol_tree2 = $mol_tree2;
|
|
1274
|
+
class $mol_tree2_empty extends $mol_tree2 {
|
|
1275
|
+
constructor() {
|
|
1276
|
+
super('', '', [], $mol_span.unknown);
|
|
971
1277
|
}
|
|
972
|
-
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
973
|
-
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
974
|
-
return { lo: h1 << 1 >> 1, hi: h2 << 1 >> 1 };
|
|
975
1278
|
}
|
|
976
|
-
$.$
|
|
1279
|
+
$.$mol_tree2_empty = $mol_tree2_empty;
|
|
977
1280
|
})($ || ($ = {}));
|
|
978
1281
|
|
|
979
|
-
;
|
|
980
|
-
"use strict";
|
|
981
|
-
|
|
982
1282
|
;
|
|
983
1283
|
"use strict";
|
|
984
1284
|
var $;
|
|
985
1285
|
(function ($) {
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1286
|
+
class $mol_error_syntax extends SyntaxError {
|
|
1287
|
+
reason;
|
|
1288
|
+
line;
|
|
1289
|
+
span;
|
|
1290
|
+
constructor(reason, line, span) {
|
|
1291
|
+
super(`${reason}\n${span}\n${line.substring(0, span.col - 1).replace(/\S/g, ' ')}${''.padEnd(span.length, '!')}\n${line}`);
|
|
1292
|
+
this.reason = reason;
|
|
1293
|
+
this.line = line;
|
|
1294
|
+
this.span = span;
|
|
1295
|
+
}
|
|
991
1296
|
}
|
|
992
|
-
$.$
|
|
1297
|
+
$.$mol_error_syntax = $mol_error_syntax;
|
|
993
1298
|
})($ || ($ = {}));
|
|
994
1299
|
|
|
995
1300
|
;
|
|
996
1301
|
"use strict";
|
|
997
1302
|
var $;
|
|
998
1303
|
(function ($) {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1304
|
+
function $mol_tree2_from_string(str, uri = '?') {
|
|
1305
|
+
const span = $mol_span.entire(uri, str);
|
|
1306
|
+
var root = $mol_tree2.list([], span);
|
|
1307
|
+
var stack = [root];
|
|
1308
|
+
var pos = 0, row = 0, min_indent = 0;
|
|
1309
|
+
while (str.length > pos) {
|
|
1310
|
+
var indent = 0;
|
|
1311
|
+
var line_start = pos;
|
|
1312
|
+
row++;
|
|
1313
|
+
while (str.length > pos && str[pos] == '\t') {
|
|
1314
|
+
indent++;
|
|
1315
|
+
pos++;
|
|
1316
|
+
}
|
|
1317
|
+
if (!root.kids.length) {
|
|
1318
|
+
min_indent = indent;
|
|
1319
|
+
}
|
|
1320
|
+
indent -= min_indent;
|
|
1321
|
+
if (indent < 0 || indent >= stack.length) {
|
|
1322
|
+
const sp = span.span(row, 1, pos - line_start);
|
|
1323
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1324
|
+
pos++;
|
|
1325
|
+
}
|
|
1326
|
+
if (indent < 0) {
|
|
1327
|
+
if (str.length > pos) {
|
|
1328
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too few tabs`, str.substring(line_start, pos), sp));
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
else {
|
|
1332
|
+
this.$mol_fail(new this.$mol_error_syntax(`Too many tabs`, str.substring(line_start, pos), sp));
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
stack.length = indent + 1;
|
|
1336
|
+
var parent = stack[indent];
|
|
1337
|
+
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1338
|
+
var error_start = pos;
|
|
1339
|
+
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1340
|
+
pos++;
|
|
1341
|
+
}
|
|
1342
|
+
if (pos > error_start) {
|
|
1343
|
+
let line_end = str.indexOf('\n', pos);
|
|
1344
|
+
if (line_end === -1)
|
|
1345
|
+
line_end = str.length;
|
|
1346
|
+
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1347
|
+
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1348
|
+
}
|
|
1349
|
+
var type_start = pos;
|
|
1350
|
+
while (str.length > pos &&
|
|
1351
|
+
str[pos] != '\\' &&
|
|
1352
|
+
str[pos] != ' ' &&
|
|
1353
|
+
str[pos] != '\t' &&
|
|
1354
|
+
str[pos] != '\n') {
|
|
1355
|
+
pos++;
|
|
1356
|
+
}
|
|
1357
|
+
if (pos > type_start) {
|
|
1358
|
+
let next = new $mol_tree2(str.slice(type_start, pos), '', [], span.span(row, type_start - line_start + 1, pos - type_start));
|
|
1359
|
+
const parent_kids = parent.kids;
|
|
1360
|
+
parent_kids.push(next);
|
|
1361
|
+
parent = next;
|
|
1362
|
+
}
|
|
1363
|
+
if (str.length > pos && str[pos] == ' ') {
|
|
1364
|
+
pos++;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
if (str.length > pos && str[pos] == '\\') {
|
|
1368
|
+
var data_start = pos;
|
|
1369
|
+
while (str.length > pos && str[pos] != '\n') {
|
|
1370
|
+
pos++;
|
|
1371
|
+
}
|
|
1372
|
+
let next = new $mol_tree2('', str.slice(data_start + 1, pos), [], span.span(row, data_start - line_start + 2, pos - data_start - 1));
|
|
1373
|
+
const parent_kids = parent.kids;
|
|
1374
|
+
parent_kids.push(next);
|
|
1375
|
+
parent = next;
|
|
1376
|
+
}
|
|
1377
|
+
if (str.length === pos && stack.length > 0) {
|
|
1378
|
+
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1379
|
+
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
1380
|
+
}
|
|
1381
|
+
stack.push(parent);
|
|
1382
|
+
pos++;
|
|
1011
1383
|
}
|
|
1384
|
+
return root;
|
|
1012
1385
|
}
|
|
1013
|
-
$.$
|
|
1014
|
-
})($ || ($ = {}));
|
|
1015
|
-
|
|
1016
|
-
;
|
|
1017
|
-
"use strict";
|
|
1018
|
-
var $;
|
|
1019
|
-
(function ($) {
|
|
1020
|
-
class $mol_data_error extends $mol_error_mix {
|
|
1021
|
-
}
|
|
1022
|
-
$.$mol_data_error = $mol_data_error;
|
|
1386
|
+
$.$mol_tree2_from_string = $mol_tree2_from_string;
|
|
1023
1387
|
})($ || ($ = {}));
|
|
1024
1388
|
|
|
1025
1389
|
;
|
|
1026
1390
|
"use strict";
|
|
1027
1391
|
var $;
|
|
1028
1392
|
(function ($) {
|
|
1029
|
-
function $
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
if (Number.isNaN(Number(key))) {
|
|
1033
|
-
index[dict[key]] = key;
|
|
1034
|
-
}
|
|
1393
|
+
function $mol_tree2_from_json(json, span = $mol_span.unknown) {
|
|
1394
|
+
if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
|
|
1395
|
+
return new $mol_tree2(String(json), '', [], span);
|
|
1035
1396
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1397
|
+
if (typeof json === 'string') {
|
|
1398
|
+
return $mol_tree2.data(json, [], span);
|
|
1399
|
+
}
|
|
1400
|
+
if (Array.isArray(json)) {
|
|
1401
|
+
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
1402
|
+
return new $mol_tree2('/', '', sub, span);
|
|
1403
|
+
}
|
|
1404
|
+
if (ArrayBuffer.isView(json)) {
|
|
1405
|
+
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
1406
|
+
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
1407
|
+
}
|
|
1408
|
+
if (json instanceof Date) {
|
|
1409
|
+
return new $mol_tree2('', json.toISOString(), [], span);
|
|
1410
|
+
}
|
|
1411
|
+
if (typeof json.toJSON === 'function') {
|
|
1412
|
+
return $mol_tree2_from_json(json.toJSON());
|
|
1413
|
+
}
|
|
1414
|
+
if (json.toString !== Object.prototype.toString) {
|
|
1415
|
+
return $mol_tree2.data(json.toString(), [], span);
|
|
1416
|
+
}
|
|
1417
|
+
if (json instanceof Error) {
|
|
1418
|
+
const { name, message, stack } = json;
|
|
1419
|
+
json = { ...json, name, message, stack };
|
|
1420
|
+
}
|
|
1421
|
+
const sub = [];
|
|
1422
|
+
for (var key in json) {
|
|
1423
|
+
const val = json[key];
|
|
1424
|
+
if (val === undefined)
|
|
1425
|
+
continue;
|
|
1426
|
+
const subsub = $mol_tree2_from_json(val, span);
|
|
1427
|
+
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
1428
|
+
sub.push(new $mol_tree2(key, '', [subsub], span));
|
|
1039
1429
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
;
|
|
1047
|
-
"use strict";
|
|
1048
|
-
var $;
|
|
1049
|
-
(function ($) {
|
|
1050
|
-
$.$mol_crypto_native = $node.crypto.webcrypto;
|
|
1051
|
-
})($ || ($ = {}));
|
|
1052
|
-
|
|
1053
|
-
;
|
|
1054
|
-
"use strict";
|
|
1055
|
-
var $;
|
|
1056
|
-
(function ($) {
|
|
1057
|
-
function $mol_base64_encode(src) {
|
|
1058
|
-
throw new Error('Not implemented');
|
|
1059
|
-
}
|
|
1060
|
-
$.$mol_base64_encode = $mol_base64_encode;
|
|
1061
|
-
})($ || ($ = {}));
|
|
1062
|
-
|
|
1063
|
-
;
|
|
1064
|
-
"use strict";
|
|
1065
|
-
var $;
|
|
1066
|
-
(function ($) {
|
|
1067
|
-
function $mol_base64_encode_node(str) {
|
|
1068
|
-
if (!str)
|
|
1069
|
-
return '';
|
|
1070
|
-
if (Buffer.isBuffer(str))
|
|
1071
|
-
return str.toString('base64');
|
|
1072
|
-
return Buffer.from(str).toString('base64');
|
|
1430
|
+
else {
|
|
1431
|
+
sub.push($mol_tree2.data(key, [subsub], span));
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
return new $mol_tree2('*', '', sub, span);
|
|
1073
1435
|
}
|
|
1074
|
-
$.$
|
|
1075
|
-
$.$mol_base64_encode = $mol_base64_encode_node;
|
|
1436
|
+
$.$mol_tree2_from_json = $mol_tree2_from_json;
|
|
1076
1437
|
})($ || ($ = {}));
|
|
1077
1438
|
|
|
1078
1439
|
;
|
|
1079
1440
|
"use strict";
|
|
1080
1441
|
var $;
|
|
1081
1442
|
(function ($) {
|
|
1082
|
-
|
|
1083
|
-
|
|
1443
|
+
class $mol_term_color {
|
|
1444
|
+
static reset = this.ansi(0, 0);
|
|
1445
|
+
static bold = this.ansi(1, 22);
|
|
1446
|
+
static italic = this.ansi(3, 23);
|
|
1447
|
+
static underline = this.ansi(4, 24);
|
|
1448
|
+
static inverse = this.ansi(7, 27);
|
|
1449
|
+
static hidden = this.ansi(8, 28);
|
|
1450
|
+
static strike = this.ansi(9, 29);
|
|
1451
|
+
static gray = this.ansi(90, 39);
|
|
1452
|
+
static red = this.ansi(91, 39);
|
|
1453
|
+
static green = this.ansi(92, 39);
|
|
1454
|
+
static yellow = this.ansi(93, 39);
|
|
1455
|
+
static blue = this.ansi(94, 39);
|
|
1456
|
+
static magenta = this.ansi(95, 39);
|
|
1457
|
+
static cyan = this.ansi(96, 39);
|
|
1458
|
+
static Gray = (str) => this.inverse(this.gray(str));
|
|
1459
|
+
static Red = (str) => this.inverse(this.red(str));
|
|
1460
|
+
static Green = (str) => this.inverse(this.green(str));
|
|
1461
|
+
static Yellow = (str) => this.inverse(this.yellow(str));
|
|
1462
|
+
static Blue = (str) => this.inverse(this.blue(str));
|
|
1463
|
+
static Magenta = (str) => this.inverse(this.magenta(str));
|
|
1464
|
+
static Cyan = (str) => this.inverse(this.cyan(str));
|
|
1465
|
+
static ansi(open, close) {
|
|
1466
|
+
if (typeof process === 'undefined')
|
|
1467
|
+
return String;
|
|
1468
|
+
if (!process.stdout.isTTY)
|
|
1469
|
+
return String;
|
|
1470
|
+
const prefix = `\x1b[${open}m`;
|
|
1471
|
+
const postfix = `\x1b[${close}m`;
|
|
1472
|
+
const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
|
|
1473
|
+
return function colorer(str) {
|
|
1474
|
+
str = String(str);
|
|
1475
|
+
if (str === '')
|
|
1476
|
+
return str;
|
|
1477
|
+
const suffix = str.replace(suffix_regexp, prefix);
|
|
1478
|
+
return prefix + suffix + postfix;
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1084
1481
|
}
|
|
1085
|
-
$.$
|
|
1482
|
+
$.$mol_term_color = $mol_term_color;
|
|
1086
1483
|
})($ || ($ = {}));
|
|
1087
1484
|
|
|
1088
1485
|
;
|
|
1089
1486
|
"use strict";
|
|
1090
1487
|
var $;
|
|
1091
1488
|
(function ($) {
|
|
1092
|
-
function $
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1489
|
+
function $mol_log3_node_make(level, output, type, color) {
|
|
1490
|
+
return function $mol_log3_logger(event) {
|
|
1491
|
+
if (!event.time)
|
|
1492
|
+
event = { time: new Date().toISOString(), ...event };
|
|
1493
|
+
let tree = this.$mol_tree2_from_json(event);
|
|
1494
|
+
tree = tree.struct(type, tree.kids);
|
|
1495
|
+
let str = color(tree.toString());
|
|
1496
|
+
this.console[level](str);
|
|
1497
|
+
const self = this;
|
|
1498
|
+
return () => self.console.groupEnd();
|
|
1499
|
+
};
|
|
1096
1500
|
}
|
|
1097
|
-
$.$
|
|
1098
|
-
$.$
|
|
1501
|
+
$.$mol_log3_node_make = $mol_log3_node_make;
|
|
1502
|
+
$.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
|
|
1503
|
+
$.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
|
|
1504
|
+
$.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
|
|
1505
|
+
$.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
|
|
1506
|
+
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
|
|
1507
|
+
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
|
|
1099
1508
|
})($ || ($ = {}));
|
|
1100
1509
|
|
|
1101
1510
|
;
|
|
1102
1511
|
"use strict";
|
|
1103
1512
|
var $;
|
|
1104
1513
|
(function ($) {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1514
|
+
class $mol_wire_task extends $mol_wire_fiber {
|
|
1515
|
+
static getter(task) {
|
|
1516
|
+
return function $mol_wire_task_get(host, args) {
|
|
1517
|
+
const sub = $mol_wire_auto();
|
|
1518
|
+
const existen = sub?.track_next();
|
|
1519
|
+
reuse: if (existen) {
|
|
1520
|
+
if (!existen.temp)
|
|
1521
|
+
break reuse;
|
|
1522
|
+
if (existen.host !== host)
|
|
1523
|
+
break reuse;
|
|
1524
|
+
if (existen.task !== task)
|
|
1525
|
+
break reuse;
|
|
1526
|
+
if (!$mol_compare_deep(existen.args, args))
|
|
1527
|
+
break reuse;
|
|
1528
|
+
return existen;
|
|
1529
|
+
}
|
|
1530
|
+
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}<#>`, task, host, args);
|
|
1531
|
+
if (existen?.temp) {
|
|
1532
|
+
$$.$mol_log3_warn({
|
|
1533
|
+
place: '$mol_wire_task',
|
|
1534
|
+
message: `Non idempotency`,
|
|
1535
|
+
existen,
|
|
1536
|
+
next,
|
|
1537
|
+
hint: 'Ignore it',
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
return next;
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
get temp() {
|
|
1544
|
+
return true;
|
|
1545
|
+
}
|
|
1546
|
+
complete() {
|
|
1547
|
+
if ($mol_promise_like(this.cache))
|
|
1548
|
+
return;
|
|
1549
|
+
this.destructor();
|
|
1550
|
+
}
|
|
1551
|
+
put(next) {
|
|
1552
|
+
const prev = this.cache;
|
|
1553
|
+
this.cache = next;
|
|
1554
|
+
if ($mol_promise_like(next)) {
|
|
1555
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
1556
|
+
if (next !== prev)
|
|
1557
|
+
this.emit();
|
|
1558
|
+
return next;
|
|
1559
|
+
}
|
|
1560
|
+
this.cursor = $mol_wire_cursor.final;
|
|
1561
|
+
if (this.sub_empty)
|
|
1562
|
+
this.destructor();
|
|
1563
|
+
else if (next !== prev)
|
|
1564
|
+
this.emit();
|
|
1565
|
+
return next;
|
|
1566
|
+
}
|
|
1111
1567
|
}
|
|
1112
|
-
$.$
|
|
1568
|
+
$.$mol_wire_task = $mol_wire_task;
|
|
1113
1569
|
})($ || ($ = {}));
|
|
1114
1570
|
|
|
1115
1571
|
;
|
|
1116
1572
|
"use strict";
|
|
1117
1573
|
var $;
|
|
1118
1574
|
(function ($) {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
super();
|
|
1138
|
-
this.native = native;
|
|
1139
|
-
}
|
|
1140
|
-
static async from(serial) {
|
|
1141
|
-
if (typeof serial !== 'string') {
|
|
1142
|
-
serial = $mol_base64_url_encode(serial.subarray(0, 32))
|
|
1143
|
-
+ $mol_base64_url_encode(serial.subarray(32, 64));
|
|
1144
|
-
}
|
|
1145
|
-
return new this(await $mol_crypto_native.subtle.importKey('jwk', {
|
|
1146
|
-
crv: "P-256",
|
|
1147
|
-
ext: true,
|
|
1148
|
-
key_ops: ['verify'],
|
|
1149
|
-
kty: "EC",
|
|
1150
|
-
x: serial.slice(0, 43),
|
|
1151
|
-
y: serial.slice(43, 86),
|
|
1152
|
-
}, algorithm, true, ['verify']));
|
|
1153
|
-
}
|
|
1154
|
-
async serial() {
|
|
1155
|
-
const { x, y } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
|
|
1156
|
-
return x + y;
|
|
1157
|
-
}
|
|
1158
|
-
async toArray() {
|
|
1159
|
-
const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
|
|
1160
|
-
return new Uint8Array([
|
|
1161
|
-
...$mol_base64_url_decode(x),
|
|
1162
|
-
...$mol_base64_url_decode(y),
|
|
1163
|
-
]);
|
|
1164
|
-
}
|
|
1165
|
-
async verify(data, sign) {
|
|
1166
|
-
return await $mol_crypto_native.subtle.verify(algorithm, this.native, sign, data);
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
$.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
|
|
1170
|
-
class $mol_crypto_auditor_private extends Object {
|
|
1171
|
-
native;
|
|
1172
|
-
static size_str = 129;
|
|
1173
|
-
static size_bin = 96;
|
|
1174
|
-
constructor(native) {
|
|
1175
|
-
super();
|
|
1176
|
-
this.native = native;
|
|
1177
|
-
}
|
|
1178
|
-
static async from(serial) {
|
|
1179
|
-
if (typeof serial !== 'string') {
|
|
1180
|
-
serial = $mol_base64_url_encode(serial.subarray(0, 32))
|
|
1181
|
-
+ $mol_base64_url_encode(serial.subarray(32, 64))
|
|
1182
|
-
+ $mol_base64_url_encode(serial.subarray(64));
|
|
1183
|
-
}
|
|
1184
|
-
return new this(await $mol_crypto_native.subtle.importKey('jwk', {
|
|
1185
|
-
crv: "P-256",
|
|
1186
|
-
ext: true,
|
|
1187
|
-
key_ops: ['sign'],
|
|
1188
|
-
kty: "EC",
|
|
1189
|
-
x: serial.slice(0, 43),
|
|
1190
|
-
y: serial.slice(43, 86),
|
|
1191
|
-
d: serial.slice(86, 129),
|
|
1192
|
-
}, algorithm, true, ['sign']));
|
|
1193
|
-
}
|
|
1194
|
-
async serial() {
|
|
1195
|
-
const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
|
|
1196
|
-
return x + y + d;
|
|
1197
|
-
}
|
|
1198
|
-
async toArray() {
|
|
1199
|
-
const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
|
|
1200
|
-
return new Uint8Array([
|
|
1201
|
-
...$mol_base64_url_decode(x),
|
|
1202
|
-
...$mol_base64_url_decode(y),
|
|
1203
|
-
...$mol_base64_url_decode(d),
|
|
1204
|
-
]);
|
|
1205
|
-
}
|
|
1206
|
-
async sign(data) {
|
|
1207
|
-
return await $mol_crypto_native.subtle.sign(algorithm, this.native, data);
|
|
1208
|
-
}
|
|
1209
|
-
async public() {
|
|
1210
|
-
return await $mol_crypto_auditor_public.from($mol_crypto_auditor_private_to_public(await this.serial()));
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
$.$mol_crypto_auditor_private = $mol_crypto_auditor_private;
|
|
1214
|
-
$.$mol_crypto_auditor_sign_size = 64;
|
|
1215
|
-
function $mol_crypto_auditor_private_to_public(serial) {
|
|
1216
|
-
return serial.slice(0, 86);
|
|
1575
|
+
function $mol_wire_sync(obj) {
|
|
1576
|
+
return new Proxy(obj, {
|
|
1577
|
+
get(obj, field) {
|
|
1578
|
+
const val = obj[field];
|
|
1579
|
+
if (typeof val !== 'function')
|
|
1580
|
+
return val;
|
|
1581
|
+
const temp = $mol_wire_task.getter(val);
|
|
1582
|
+
return function $mol_wire_sync(...args) {
|
|
1583
|
+
const fiber = temp(obj, args);
|
|
1584
|
+
return fiber.sync();
|
|
1585
|
+
};
|
|
1586
|
+
},
|
|
1587
|
+
apply(obj, self, args) {
|
|
1588
|
+
const temp = $mol_wire_task.getter(obj);
|
|
1589
|
+
const fiber = temp(self, args);
|
|
1590
|
+
return fiber.sync();
|
|
1591
|
+
},
|
|
1592
|
+
});
|
|
1217
1593
|
}
|
|
1218
|
-
$.$
|
|
1594
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
|
1219
1595
|
})($ || ($ = {}));
|
|
1220
1596
|
|
|
1221
1597
|
;
|
|
1222
1598
|
"use strict";
|
|
1223
1599
|
var $;
|
|
1224
1600
|
(function ($) {
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
$
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
key_private;
|
|
1236
|
-
key_private_serial;
|
|
1237
|
-
id;
|
|
1238
|
-
constructor(key_public, key_public_serial, key_private, key_private_serial) {
|
|
1239
|
-
super();
|
|
1240
|
-
this.key_public = key_public;
|
|
1241
|
-
this.key_public_serial = key_public_serial;
|
|
1242
|
-
this.key_private = key_private;
|
|
1243
|
-
this.key_private_serial = key_private_serial;
|
|
1244
|
-
this.id = $mol_int62_hash_string(this.key_public_serial);
|
|
1245
|
-
}
|
|
1246
|
-
static async generate() {
|
|
1247
|
-
const pair = await $$.$mol_crypto_auditor_pair();
|
|
1248
|
-
const serial = await pair.private.serial();
|
|
1249
|
-
return new this(pair.public, $mol_crypto_auditor_private_to_public(serial), pair.private, serial);
|
|
1250
|
-
}
|
|
1251
|
-
static async restore(serial) {
|
|
1252
|
-
return new this(await $$.$mol_crypto_auditor_public.from(serial), $mol_crypto_auditor_private_to_public(serial), await $$.$mol_crypto_auditor_private.from(serial), serial);
|
|
1253
|
-
}
|
|
1601
|
+
const catched = new WeakMap();
|
|
1602
|
+
function $mol_fail_catch(error) {
|
|
1603
|
+
if (typeof error !== 'object')
|
|
1604
|
+
return false;
|
|
1605
|
+
if ($mol_promise_like(error))
|
|
1606
|
+
$mol_fail_hidden(error);
|
|
1607
|
+
if (catched.get(error))
|
|
1608
|
+
return false;
|
|
1609
|
+
catched.set(error, true);
|
|
1610
|
+
return true;
|
|
1254
1611
|
}
|
|
1255
|
-
$.$
|
|
1612
|
+
$.$mol_fail_catch = $mol_fail_catch;
|
|
1256
1613
|
})($ || ($ = {}));
|
|
1257
1614
|
|
|
1258
1615
|
;
|
|
1259
1616
|
"use strict";
|
|
1260
1617
|
var $;
|
|
1261
1618
|
(function ($) {
|
|
1262
|
-
$
|
|
1263
|
-
|
|
1264
|
-
|
|
1619
|
+
function $mol_fail_log(error) {
|
|
1620
|
+
if ($mol_promise_like(error))
|
|
1621
|
+
return false;
|
|
1622
|
+
if (!$mol_fail_catch(error))
|
|
1623
|
+
return false;
|
|
1624
|
+
console.error(error);
|
|
1625
|
+
return true;
|
|
1265
1626
|
}
|
|
1266
|
-
$.$
|
|
1267
|
-
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
1268
|
-
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
1269
|
-
$mol_dev_format_register({
|
|
1270
|
-
header: (val, config = false) => {
|
|
1271
|
-
if (config)
|
|
1272
|
-
return null;
|
|
1273
|
-
if (!val)
|
|
1274
|
-
return null;
|
|
1275
|
-
if ($.$mol_dev_format_head in val) {
|
|
1276
|
-
try {
|
|
1277
|
-
return val[$.$mol_dev_format_head]();
|
|
1278
|
-
}
|
|
1279
|
-
catch (error) {
|
|
1280
|
-
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
if (typeof val === 'function') {
|
|
1284
|
-
return $mol_dev_format_native(val);
|
|
1285
|
-
}
|
|
1286
|
-
if (Symbol.toStringTag in val) {
|
|
1287
|
-
return $mol_dev_format_native(val);
|
|
1288
|
-
}
|
|
1289
|
-
return null;
|
|
1290
|
-
},
|
|
1291
|
-
hasBody: val => val[$.$mol_dev_format_body],
|
|
1292
|
-
body: val => val[$.$mol_dev_format_body](),
|
|
1293
|
-
});
|
|
1294
|
-
function $mol_dev_format_native(obj) {
|
|
1295
|
-
if (typeof obj === 'undefined')
|
|
1296
|
-
return $.$mol_dev_format_shade('undefined');
|
|
1297
|
-
return [
|
|
1298
|
-
'object',
|
|
1299
|
-
{
|
|
1300
|
-
object: obj,
|
|
1301
|
-
config: true,
|
|
1302
|
-
},
|
|
1303
|
-
];
|
|
1304
|
-
}
|
|
1305
|
-
$.$mol_dev_format_native = $mol_dev_format_native;
|
|
1306
|
-
function $mol_dev_format_auto(obj) {
|
|
1307
|
-
if (obj == null)
|
|
1308
|
-
return $.$mol_dev_format_shade(String(obj));
|
|
1309
|
-
return [
|
|
1310
|
-
'object',
|
|
1311
|
-
{
|
|
1312
|
-
object: obj,
|
|
1313
|
-
config: false,
|
|
1314
|
-
},
|
|
1315
|
-
];
|
|
1316
|
-
}
|
|
1317
|
-
$.$mol_dev_format_auto = $mol_dev_format_auto;
|
|
1318
|
-
function $mol_dev_format_element(element, style, ...content) {
|
|
1319
|
-
const styles = [];
|
|
1320
|
-
for (let key in style)
|
|
1321
|
-
styles.push(`${key} : ${style[key]}`);
|
|
1322
|
-
return [
|
|
1323
|
-
element,
|
|
1324
|
-
{
|
|
1325
|
-
style: styles.join(' ; '),
|
|
1326
|
-
},
|
|
1327
|
-
...content,
|
|
1328
|
-
];
|
|
1329
|
-
}
|
|
1330
|
-
$.$mol_dev_format_element = $mol_dev_format_element;
|
|
1331
|
-
function $mol_dev_format_span(style, ...content) {
|
|
1332
|
-
return $mol_dev_format_element('span', {
|
|
1333
|
-
...style,
|
|
1334
|
-
}, ...content);
|
|
1335
|
-
}
|
|
1336
|
-
$.$mol_dev_format_span = $mol_dev_format_span;
|
|
1337
|
-
$.$mol_dev_format_div = $mol_dev_format_element.bind(null, 'div');
|
|
1338
|
-
$.$mol_dev_format_ol = $mol_dev_format_element.bind(null, 'ol');
|
|
1339
|
-
$.$mol_dev_format_li = $mol_dev_format_element.bind(null, 'li');
|
|
1340
|
-
$.$mol_dev_format_table = $mol_dev_format_element.bind(null, 'table');
|
|
1341
|
-
$.$mol_dev_format_tr = $mol_dev_format_element.bind(null, 'tr');
|
|
1342
|
-
$.$mol_dev_format_td = $mol_dev_format_element.bind(null, 'td');
|
|
1343
|
-
$.$mol_dev_format_accent = $mol_dev_format_span.bind(null, {
|
|
1344
|
-
'color': 'magenta',
|
|
1345
|
-
});
|
|
1346
|
-
$.$mol_dev_format_strong = $mol_dev_format_span.bind(null, {
|
|
1347
|
-
'font-weight': 'bold',
|
|
1348
|
-
});
|
|
1349
|
-
$.$mol_dev_format_string = $mol_dev_format_span.bind(null, {
|
|
1350
|
-
'color': 'green',
|
|
1351
|
-
});
|
|
1352
|
-
$.$mol_dev_format_shade = $mol_dev_format_span.bind(null, {
|
|
1353
|
-
'color': 'gray',
|
|
1354
|
-
});
|
|
1355
|
-
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
|
1356
|
-
'margin-left': '13px'
|
|
1357
|
-
});
|
|
1627
|
+
$.$mol_fail_log = $mol_fail_log;
|
|
1358
1628
|
})($ || ($ = {}));
|
|
1359
1629
|
|
|
1360
1630
|
;
|
|
1361
1631
|
"use strict";
|
|
1632
|
+
var $node = new Proxy({ require }, {
|
|
1633
|
+
get(target, name, wrapper) {
|
|
1634
|
+
if (target[name])
|
|
1635
|
+
return target[name];
|
|
1636
|
+
const mod = target.require('module');
|
|
1637
|
+
if (mod.builtinModules.indexOf(name) >= 0)
|
|
1638
|
+
return target.require(name);
|
|
1639
|
+
if (name[0] === '.')
|
|
1640
|
+
return target.require(name);
|
|
1641
|
+
const path = target.require('path');
|
|
1642
|
+
const fs = target.require('fs');
|
|
1643
|
+
let dir = path.resolve('.');
|
|
1644
|
+
const suffix = `./node_modules/${name}`;
|
|
1645
|
+
const $$ = $;
|
|
1646
|
+
while (!fs.existsSync(path.join(dir, suffix))) {
|
|
1647
|
+
const parent = path.resolve(dir, '..');
|
|
1648
|
+
if (parent === dir) {
|
|
1649
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
|
|
1650
|
+
try {
|
|
1651
|
+
$$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
|
|
1652
|
+
}
|
|
1653
|
+
catch { }
|
|
1654
|
+
break;
|
|
1655
|
+
}
|
|
1656
|
+
else {
|
|
1657
|
+
dir = parent;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
try {
|
|
1661
|
+
return $.$mol_wire_sync(target).require(name);
|
|
1662
|
+
}
|
|
1663
|
+
catch (error) {
|
|
1664
|
+
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
1665
|
+
return importSync(name);
|
|
1666
|
+
}
|
|
1667
|
+
$.$mol_fail_log(error);
|
|
1668
|
+
return null;
|
|
1669
|
+
}
|
|
1670
|
+
},
|
|
1671
|
+
set(target, name, value) {
|
|
1672
|
+
target[name] = value;
|
|
1673
|
+
return true;
|
|
1674
|
+
},
|
|
1675
|
+
});
|
|
1676
|
+
const importAsync = async (uri) => import(uri);
|
|
1677
|
+
const importSync = $.$mol_wire_sync(importAsync);
|
|
1678
|
+
require = (req => Object.assign(function require(name) {
|
|
1679
|
+
return $node[name];
|
|
1680
|
+
}, req))(require);
|
|
1362
1681
|
|
|
1363
1682
|
;
|
|
1364
1683
|
"use strict";
|
|
1365
1684
|
var $;
|
|
1366
1685
|
(function ($) {
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
let decoder = decoders[encoding];
|
|
1370
|
-
if (!decoder)
|
|
1371
|
-
decoder = decoders[encoding] = new TextDecoder(encoding);
|
|
1372
|
-
return decoder.decode(buffer);
|
|
1686
|
+
function $mol_env() {
|
|
1687
|
+
return {};
|
|
1373
1688
|
}
|
|
1374
|
-
$.$
|
|
1689
|
+
$.$mol_env = $mol_env;
|
|
1375
1690
|
})($ || ($ = {}));
|
|
1376
1691
|
|
|
1377
1692
|
;
|
|
1378
1693
|
"use strict";
|
|
1379
1694
|
var $;
|
|
1380
1695
|
(function ($) {
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
this.land = land;
|
|
1407
|
-
this.auth = auth;
|
|
1408
|
-
this.head = head;
|
|
1409
|
-
this.self = self;
|
|
1410
|
-
this.next = next;
|
|
1411
|
-
this.prev = prev;
|
|
1412
|
-
this.time = time;
|
|
1413
|
-
this.data = data;
|
|
1414
|
-
this.bin = bin;
|
|
1696
|
+
$.$mol_env = function $mol_env() {
|
|
1697
|
+
return this.process.env;
|
|
1698
|
+
};
|
|
1699
|
+
})($ || ($ = {}));
|
|
1700
|
+
|
|
1701
|
+
;
|
|
1702
|
+
"use strict";
|
|
1703
|
+
var $;
|
|
1704
|
+
(function ($) {
|
|
1705
|
+
function $mol_exec(dir, command, ...args) {
|
|
1706
|
+
let [app, ...args0] = command.split(' ');
|
|
1707
|
+
args = [...args0, ...args];
|
|
1708
|
+
this.$mol_log3_come({
|
|
1709
|
+
place: '$mol_exec',
|
|
1710
|
+
dir: $node.path.relative('', dir),
|
|
1711
|
+
message: 'Run',
|
|
1712
|
+
command: `${app} ${args.join(' ')}`,
|
|
1713
|
+
});
|
|
1714
|
+
var res = $node['child_process'].spawnSync(app, args, {
|
|
1715
|
+
cwd: $node.path.resolve(dir),
|
|
1716
|
+
shell: true,
|
|
1717
|
+
env: this.$mol_env(),
|
|
1718
|
+
});
|
|
1719
|
+
if (res.status || res.error) {
|
|
1720
|
+
return $mol_fail(res.error || new Error(res.stderr.toString(), { cause: res.stdout }));
|
|
1415
1721
|
}
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1722
|
+
if (!res.stdout)
|
|
1723
|
+
res.stdout = Buffer.from([]);
|
|
1724
|
+
return res;
|
|
1725
|
+
}
|
|
1726
|
+
$.$mol_exec = $mol_exec;
|
|
1727
|
+
})($ || ($ = {}));
|
|
1728
|
+
|
|
1729
|
+
;
|
|
1730
|
+
"use strict";
|
|
1731
|
+
var $;
|
|
1732
|
+
(function ($) {
|
|
1733
|
+
const TextEncoder = globalThis.TextEncoder ?? $node.util.TextEncoder;
|
|
1734
|
+
const encoder = new TextEncoder();
|
|
1735
|
+
function $mol_charset_encode(value) {
|
|
1736
|
+
return encoder.encode(value);
|
|
1737
|
+
}
|
|
1738
|
+
$.$mol_charset_encode = $mol_charset_encode;
|
|
1739
|
+
})($ || ($ = {}));
|
|
1740
|
+
|
|
1741
|
+
;
|
|
1742
|
+
"use strict";
|
|
1743
|
+
var $;
|
|
1744
|
+
(function ($) {
|
|
1745
|
+
function $mol_int62_string_ensure(str) {
|
|
1746
|
+
if (typeof str !== 'string')
|
|
1747
|
+
return null;
|
|
1748
|
+
return $mol_int62_from_string(str) && str;
|
|
1749
|
+
}
|
|
1750
|
+
$.$mol_int62_string_ensure = $mol_int62_string_ensure;
|
|
1751
|
+
$.$mol_int62_max = (2 ** 30) - 1;
|
|
1752
|
+
$.$mol_int62_min = -(2 ** 30);
|
|
1753
|
+
$.$mol_int62_range = $.$mol_int62_max - $.$mol_int62_min + 1;
|
|
1754
|
+
function $mol_int62_to_string({ lo, hi }) {
|
|
1755
|
+
lo = (lo + $.$mol_int62_range) % $.$mol_int62_range;
|
|
1756
|
+
hi = (hi + $.$mol_int62_range) % $.$mol_int62_range;
|
|
1757
|
+
return lo.toString(36) + '_' + hi.toString(36);
|
|
1758
|
+
}
|
|
1759
|
+
$.$mol_int62_to_string = $mol_int62_to_string;
|
|
1760
|
+
function $mol_int62_from_string(str) {
|
|
1761
|
+
const [str_lo, str_hi] = str.split('_');
|
|
1762
|
+
const int_lo = parseInt(str_lo, 36);
|
|
1763
|
+
const int_hi = parseInt(str_hi, 36);
|
|
1764
|
+
if (int_lo.toString(36) !== str_lo || int_hi.toString(36) !== str_hi) {
|
|
1765
|
+
return null;
|
|
1429
1766
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1767
|
+
return {
|
|
1768
|
+
lo: (int_lo - $.$mol_int62_min) % $.$mol_int62_range + $.$mol_int62_min,
|
|
1769
|
+
hi: (int_hi - $.$mol_int62_min) % $.$mol_int62_range + $.$mol_int62_min,
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
$.$mol_int62_from_string = $mol_int62_from_string;
|
|
1773
|
+
function $mol_int62_compare(left_lo, left_hi, right_lo, right_hi) {
|
|
1774
|
+
return (right_hi - left_hi) || (right_lo - left_lo);
|
|
1775
|
+
}
|
|
1776
|
+
$.$mol_int62_compare = $mol_int62_compare;
|
|
1777
|
+
function $mol_int62_inc(lo, hi, max = $.$mol_int62_max) {
|
|
1778
|
+
if (lo === max) {
|
|
1779
|
+
return { lo: -max, hi: hi + 1 };
|
|
1434
1780
|
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
case $hyoo_crowd_unit_kind.grab: return $hyoo_crowd_peer_level.law;
|
|
1438
|
-
case $hyoo_crowd_unit_kind.give: return level(this.data);
|
|
1439
|
-
default: $mol_fail(new Error(`Wrong unit kind for getting level: ${this.kind()}`));
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
[Symbol.toPrimitive]() {
|
|
1443
|
-
return JSON.stringify(this);
|
|
1444
|
-
}
|
|
1445
|
-
[$mol_dev_format_head]() {
|
|
1446
|
-
switch (this.kind()) {
|
|
1447
|
-
case $hyoo_crowd_unit_kind.grab:
|
|
1448
|
-
return $mol_dev_format_div({}, $mol_dev_format_native(this), ' 👑');
|
|
1449
|
-
case $hyoo_crowd_unit_kind.join:
|
|
1450
|
-
return $mol_dev_format_div({}, $mol_dev_format_native(this), $mol_dev_format_shade(' 🔑 ', this.self));
|
|
1451
|
-
case $hyoo_crowd_unit_kind.give:
|
|
1452
|
-
return $mol_dev_format_div({}, $mol_dev_format_native(this), $mol_dev_format_shade(' 🏅 ', this.self, ' '), $mol_dev_format_native($hyoo_crowd_peer_level[this.data] ?? this.data));
|
|
1453
|
-
case $hyoo_crowd_unit_kind.data:
|
|
1454
|
-
return $mol_dev_format_div({}, $mol_dev_format_native(this), $mol_dev_format_shade(' 📦 ', this.head, '!', this.self, ' '), $mol_dev_format_native(this.data));
|
|
1455
|
-
}
|
|
1781
|
+
else {
|
|
1782
|
+
return { lo: lo + 1, hi };
|
|
1456
1783
|
}
|
|
1457
1784
|
}
|
|
1458
|
-
$.$
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
class $hyoo_crowd_unit_bin extends DataView {
|
|
1477
|
-
static from_buffer(buffer) {
|
|
1478
|
-
const size = Math.ceil(Math.abs(buffer[offset.size / 2]) / 8) * 8 + offset.data + $mol_crypto_auditor_sign_size;
|
|
1479
|
-
return new this(buffer.slice(0, size / 2).buffer);
|
|
1480
|
-
}
|
|
1481
|
-
static from_unit(unit) {
|
|
1482
|
-
if (unit.bin)
|
|
1483
|
-
return unit.bin;
|
|
1484
|
-
const type = unit.data === null
|
|
1485
|
-
? 0
|
|
1486
|
-
: unit.data instanceof Uint8Array
|
|
1487
|
-
? -1
|
|
1488
|
-
: 1;
|
|
1489
|
-
const buff = type === 0 ? null
|
|
1490
|
-
: type > 0 ? $mol_charset_encode(JSON.stringify(unit.data))
|
|
1491
|
-
: unit.data;
|
|
1492
|
-
const size = buff?.byteLength ?? 0;
|
|
1493
|
-
if (type > 0 && size > 2 ** 15 - 1)
|
|
1494
|
-
throw new Error(`Too large json data: ${size} > ${2 ** 15 - 1}`);
|
|
1495
|
-
if (type < 0 && size > 2 ** 15)
|
|
1496
|
-
throw new Error(`Too large binary data: ${size} > ${2 ** 15}`);
|
|
1497
|
-
const total = offset.data + Math.ceil(size / 8) * 8 + $mol_crypto_auditor_sign_size;
|
|
1498
|
-
const mem = new Uint8Array(total);
|
|
1499
|
-
const bin = new $hyoo_crowd_unit_bin(mem.buffer);
|
|
1500
|
-
const land = $mol_int62_from_string(unit.land);
|
|
1501
|
-
bin.setInt32(offset.land_lo, land.lo, true);
|
|
1502
|
-
bin.setInt32(offset.land_hi, land.hi, true);
|
|
1503
|
-
const auth = $mol_int62_from_string(unit.auth);
|
|
1504
|
-
bin.setInt32(offset.auth_lo, auth.lo, true);
|
|
1505
|
-
bin.setInt32(offset.auth_hi, auth.hi, true);
|
|
1506
|
-
const head = $mol_int62_from_string(unit.head);
|
|
1507
|
-
bin.setInt32(offset.head_lo, head.lo, true);
|
|
1508
|
-
bin.setInt32(offset.head_hi, head.hi, true);
|
|
1509
|
-
const self = $mol_int62_from_string(unit.self);
|
|
1510
|
-
bin.setInt32(offset.self_lo, self.lo, true);
|
|
1511
|
-
bin.setInt32(offset.self_hi, self.hi, true);
|
|
1512
|
-
const next = $mol_int62_from_string(unit.next);
|
|
1513
|
-
bin.setInt32(offset.next_lo, next.lo, true);
|
|
1514
|
-
bin.setInt32(offset.next_hi, next.hi, true);
|
|
1515
|
-
const prev = $mol_int62_from_string(unit.prev);
|
|
1516
|
-
bin.setInt32(offset.prev_lo, prev.lo, true);
|
|
1517
|
-
bin.setInt32(offset.prev_hi, prev.hi, true);
|
|
1518
|
-
bin.setInt32(offset.time, unit.time, true);
|
|
1519
|
-
bin.setInt16(offset.size, type * size, true);
|
|
1520
|
-
if (buff)
|
|
1521
|
-
mem.set(buff, offset.data);
|
|
1522
|
-
return bin;
|
|
1523
|
-
}
|
|
1524
|
-
sign(next) {
|
|
1525
|
-
const sign_offset = this.byteOffset + this.byteLength - $mol_crypto_auditor_sign_size;
|
|
1526
|
-
const buff = new Uint8Array(this.buffer, sign_offset, $mol_crypto_auditor_sign_size);
|
|
1527
|
-
if (!next)
|
|
1528
|
-
return buff;
|
|
1529
|
-
buff.set(next);
|
|
1530
|
-
return buff;
|
|
1531
|
-
}
|
|
1532
|
-
size() {
|
|
1533
|
-
return Math.ceil(Math.abs(this.getInt16(offset.size, true)) / 8) * 8 + offset.data + $mol_crypto_auditor_sign_size;
|
|
1534
|
-
}
|
|
1535
|
-
sens() {
|
|
1536
|
-
return new Uint8Array(this.buffer, this.byteOffset, this.size() - $mol_crypto_auditor_sign_size);
|
|
1785
|
+
$.$mol_int62_inc = $mol_int62_inc;
|
|
1786
|
+
function $mol_int62_random() {
|
|
1787
|
+
return {
|
|
1788
|
+
lo: Math.floor(Math.random() * $.$mol_int62_range + $.$mol_int62_min),
|
|
1789
|
+
hi: Math.floor(Math.random() * $.$mol_int62_range + $.$mol_int62_min),
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
$.$mol_int62_random = $mol_int62_random;
|
|
1793
|
+
function $mol_int62_hash_string(str) {
|
|
1794
|
+
return $mol_int62_to_string($mol_int62_hash_buffer($mol_charset_encode(str)));
|
|
1795
|
+
}
|
|
1796
|
+
$.$mol_int62_hash_string = $mol_int62_hash_string;
|
|
1797
|
+
function $mol_int62_hash_buffer(buf, seed = { lo: 0, hi: 0 }) {
|
|
1798
|
+
let h1 = 0xdeadbeef ^ seed.lo;
|
|
1799
|
+
let h2 = 0x41c6ce57 ^ seed.hi;
|
|
1800
|
+
for (const byte of buf) {
|
|
1801
|
+
h1 = Math.imul(h1 ^ byte, 2654435761);
|
|
1802
|
+
h2 = Math.imul(h2 ^ byte, 1597334677);
|
|
1537
1803
|
}
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1804
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
1805
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
1806
|
+
return { lo: h1 << 1 >> 1, hi: h2 << 1 >> 1 };
|
|
1807
|
+
}
|
|
1808
|
+
$.$mol_int62_hash_buffer = $mol_int62_hash_buffer;
|
|
1809
|
+
})($ || ($ = {}));
|
|
1810
|
+
|
|
1811
|
+
;
|
|
1812
|
+
"use strict";
|
|
1813
|
+
|
|
1814
|
+
;
|
|
1815
|
+
"use strict";
|
|
1816
|
+
var $;
|
|
1817
|
+
(function ($) {
|
|
1818
|
+
function $mol_data_setup(value, config) {
|
|
1819
|
+
return Object.assign(value, {
|
|
1820
|
+
config,
|
|
1821
|
+
Value: null
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
$.$mol_data_setup = $mol_data_setup;
|
|
1825
|
+
})($ || ($ = {}));
|
|
1826
|
+
|
|
1827
|
+
;
|
|
1828
|
+
"use strict";
|
|
1829
|
+
var $;
|
|
1830
|
+
(function ($) {
|
|
1831
|
+
class $mol_error_mix extends AggregateError {
|
|
1832
|
+
cause;
|
|
1833
|
+
name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
|
|
1834
|
+
constructor(message, cause = {}, ...errors) {
|
|
1835
|
+
super(errors, message, { cause });
|
|
1836
|
+
this.cause = cause;
|
|
1837
|
+
const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
|
|
1838
|
+
Object.defineProperty(this, 'stack', {
|
|
1839
|
+
get: () => (stack_get.call(this) ?? this.message) + '\n' + [JSON.stringify(this.cause, null, ' ') ?? 'no cause', ...this.errors.map(e => e.stack)].map(e => e.trim()
|
|
1840
|
+
.replace(/at /gm, ' at ')
|
|
1841
|
+
.replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
|
|
1562
1842
|
});
|
|
1563
|
-
const time = this.getInt32(offset.time, true) << 1 >> 1;
|
|
1564
|
-
const type_size = this.getInt16(offset.size, true);
|
|
1565
|
-
let data = null;
|
|
1566
|
-
if (type_size) {
|
|
1567
|
-
try {
|
|
1568
|
-
var buff = new Uint8Array(this.buffer, this.byteOffset + offset.data, Math.abs(type_size));
|
|
1569
|
-
}
|
|
1570
|
-
catch (error) {
|
|
1571
|
-
error['message'] += `\nhead=${head};self=${self}`;
|
|
1572
|
-
$mol_fail_hidden(error);
|
|
1573
|
-
}
|
|
1574
|
-
if (type_size < 0)
|
|
1575
|
-
data = buff;
|
|
1576
|
-
else
|
|
1577
|
-
data = JSON.parse($mol_charset_decode(buff));
|
|
1578
|
-
}
|
|
1579
|
-
return new $hyoo_crowd_unit(land, auth, head, self, next, prev, time, data, this);
|
|
1580
1843
|
}
|
|
1581
1844
|
}
|
|
1582
|
-
$.$
|
|
1583
|
-
function $hyoo_crowd_unit_compare(left, right) {
|
|
1584
|
-
return (left.group() - right.group())
|
|
1585
|
-
|| (left.time - right.time)
|
|
1586
|
-
|| ((left.auth > right.auth) ? 1 : (left.auth < right.auth) ? -1 : 0)
|
|
1587
|
-
|| ((left.self > right.self) ? 1 : (left.self < right.self) ? -1 : 0)
|
|
1588
|
-
|| ((left.head > right.head) ? 1 : (left.head < right.head) ? -1 : 0)
|
|
1589
|
-
|| ((left.prev > right.prev) ? 1 : (left.prev < right.prev) ? -1 : 0)
|
|
1590
|
-
|| ((left.next > right.next) ? 1 : (left.next < right.next) ? -1 : 0)
|
|
1591
|
-
|| ((left.land > right.land) ? 1 : (left.land < right.land) ? -1 : 0);
|
|
1592
|
-
}
|
|
1593
|
-
$.$hyoo_crowd_unit_compare = $hyoo_crowd_unit_compare;
|
|
1845
|
+
$.$mol_error_mix = $mol_error_mix;
|
|
1594
1846
|
})($ || ($ = {}));
|
|
1595
1847
|
|
|
1596
1848
|
;
|
|
1597
1849
|
"use strict";
|
|
1598
1850
|
var $;
|
|
1599
1851
|
(function ($) {
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
1604
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
1605
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
1606
|
-
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
1852
|
+
class $mol_data_error extends $mol_error_mix {
|
|
1853
|
+
}
|
|
1854
|
+
$.$mol_data_error = $mol_data_error;
|
|
1607
1855
|
})($ || ($ = {}));
|
|
1608
1856
|
|
|
1609
1857
|
;
|
|
1610
1858
|
"use strict";
|
|
1611
1859
|
var $;
|
|
1612
1860
|
(function ($) {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
sub_from = 0;
|
|
1619
|
-
get sub_list() {
|
|
1620
|
-
const res = [];
|
|
1621
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
1622
|
-
res.push(this.data[i]);
|
|
1861
|
+
function $mol_data_enum(name, dict) {
|
|
1862
|
+
const index = {};
|
|
1863
|
+
for (let key in dict) {
|
|
1864
|
+
if (Number.isNaN(Number(key))) {
|
|
1865
|
+
index[dict[key]] = key;
|
|
1623
1866
|
}
|
|
1624
|
-
return res;
|
|
1625
|
-
}
|
|
1626
|
-
get sub_empty() {
|
|
1627
|
-
return this.sub_from === this.data.length;
|
|
1628
|
-
}
|
|
1629
|
-
sub_on(sub, pub_pos) {
|
|
1630
|
-
const pos = this.data.length;
|
|
1631
|
-
this.data.push(sub, pub_pos);
|
|
1632
|
-
return pos;
|
|
1633
1867
|
}
|
|
1634
|
-
|
|
1635
|
-
if (
|
|
1636
|
-
$mol_fail(new
|
|
1637
|
-
}
|
|
1638
|
-
const end = this.data.length - 2;
|
|
1639
|
-
if (sub_pos !== end) {
|
|
1640
|
-
this.peer_move(end, sub_pos);
|
|
1868
|
+
return $mol_data_setup((value) => {
|
|
1869
|
+
if (typeof index[value] !== 'string') {
|
|
1870
|
+
return $mol_fail(new $mol_data_error(`${value} is not value of ${name} enum`));
|
|
1641
1871
|
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
if (this.data.length === this.sub_from)
|
|
1645
|
-
this.reap();
|
|
1646
|
-
}
|
|
1647
|
-
reap() { }
|
|
1648
|
-
promote() {
|
|
1649
|
-
$mol_wire_auto()?.track_next(this);
|
|
1650
|
-
}
|
|
1651
|
-
fresh() { }
|
|
1652
|
-
complete() { }
|
|
1653
|
-
get incompleted() {
|
|
1654
|
-
return false;
|
|
1655
|
-
}
|
|
1656
|
-
emit(quant = $mol_wire_cursor.stale) {
|
|
1657
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
1658
|
-
;
|
|
1659
|
-
this.data[i].absorb(quant);
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
peer_move(from_pos, to_pos) {
|
|
1663
|
-
const peer = this.data[from_pos];
|
|
1664
|
-
const self_pos = this.data[from_pos + 1];
|
|
1665
|
-
this.data[to_pos] = peer;
|
|
1666
|
-
this.data[to_pos + 1] = self_pos;
|
|
1667
|
-
peer.peer_repos(self_pos, to_pos);
|
|
1668
|
-
}
|
|
1669
|
-
peer_repos(peer_pos, self_pos) {
|
|
1670
|
-
this.data[peer_pos + 1] = self_pos;
|
|
1671
|
-
}
|
|
1872
|
+
return value;
|
|
1873
|
+
}, { name, dict });
|
|
1672
1874
|
}
|
|
1673
|
-
$.$
|
|
1875
|
+
$.$mol_data_enum = $mol_data_enum;
|
|
1674
1876
|
})($ || ($ = {}));
|
|
1675
1877
|
|
|
1676
1878
|
;
|
|
1677
1879
|
"use strict";
|
|
1880
|
+
var $;
|
|
1881
|
+
(function ($) {
|
|
1882
|
+
$.$mol_crypto_native = $node.crypto.webcrypto;
|
|
1883
|
+
})($ || ($ = {}));
|
|
1678
1884
|
|
|
1679
1885
|
;
|
|
1680
1886
|
"use strict";
|
|
1681
1887
|
var $;
|
|
1682
1888
|
(function ($) {
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
return $.$mol_wire_auto_sub = next;
|
|
1889
|
+
function $mol_base64_encode(src) {
|
|
1890
|
+
throw new Error('Not implemented');
|
|
1686
1891
|
}
|
|
1687
|
-
$.$
|
|
1688
|
-
$.$mol_wire_affected = [];
|
|
1892
|
+
$.$mol_base64_encode = $mol_base64_encode;
|
|
1689
1893
|
})($ || ($ = {}));
|
|
1690
1894
|
|
|
1691
1895
|
;
|
|
1692
1896
|
"use strict";
|
|
1693
1897
|
var $;
|
|
1694
1898
|
(function ($) {
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
return
|
|
1700
|
-
|
|
1701
|
-
get pub_list() {
|
|
1702
|
-
const res = [];
|
|
1703
|
-
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
|
1704
|
-
for (let i = this.pub_from; i < max; i += 2) {
|
|
1705
|
-
if (this.data[i])
|
|
1706
|
-
res.push(this.data[i]);
|
|
1707
|
-
}
|
|
1708
|
-
return res;
|
|
1709
|
-
}
|
|
1710
|
-
track_on() {
|
|
1711
|
-
this.cursor = this.pub_from;
|
|
1712
|
-
const sub = $mol_wire_auto();
|
|
1713
|
-
$mol_wire_auto(this);
|
|
1714
|
-
return sub;
|
|
1715
|
-
}
|
|
1716
|
-
promote() {
|
|
1717
|
-
if (this.cursor >= this.pub_from) {
|
|
1718
|
-
$mol_fail(new Error('Circular subscription'));
|
|
1719
|
-
}
|
|
1720
|
-
super.promote();
|
|
1721
|
-
}
|
|
1722
|
-
track_next(pub) {
|
|
1723
|
-
if (this.cursor < 0)
|
|
1724
|
-
$mol_fail(new Error('Promo to non begun sub'));
|
|
1725
|
-
if (this.cursor < this.sub_from) {
|
|
1726
|
-
const next = this.data[this.cursor];
|
|
1727
|
-
if (pub === undefined)
|
|
1728
|
-
return next ?? null;
|
|
1729
|
-
if (next === pub) {
|
|
1730
|
-
this.cursor += 2;
|
|
1731
|
-
return next;
|
|
1732
|
-
}
|
|
1733
|
-
if (next) {
|
|
1734
|
-
if (this.sub_from < this.data.length) {
|
|
1735
|
-
this.peer_move(this.sub_from, this.data.length);
|
|
1736
|
-
}
|
|
1737
|
-
this.peer_move(this.cursor, this.sub_from);
|
|
1738
|
-
this.sub_from += 2;
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
else {
|
|
1742
|
-
if (pub === undefined)
|
|
1743
|
-
return null;
|
|
1744
|
-
if (this.sub_from < this.data.length) {
|
|
1745
|
-
this.peer_move(this.sub_from, this.data.length);
|
|
1746
|
-
}
|
|
1747
|
-
this.sub_from += 2;
|
|
1748
|
-
}
|
|
1749
|
-
this.data[this.cursor] = pub;
|
|
1750
|
-
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
|
1751
|
-
this.cursor += 2;
|
|
1752
|
-
return pub;
|
|
1753
|
-
}
|
|
1754
|
-
track_off(sub) {
|
|
1755
|
-
$mol_wire_auto(sub);
|
|
1756
|
-
if (this.cursor < 0) {
|
|
1757
|
-
$mol_fail(new Error('End of non begun sub'));
|
|
1758
|
-
}
|
|
1759
|
-
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
1760
|
-
const pub = this.data[cursor];
|
|
1761
|
-
pub.fresh();
|
|
1762
|
-
}
|
|
1763
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
1764
|
-
}
|
|
1765
|
-
pub_off(sub_pos) {
|
|
1766
|
-
this.data[sub_pos] = undefined;
|
|
1767
|
-
this.data[sub_pos + 1] = undefined;
|
|
1768
|
-
}
|
|
1769
|
-
destructor() {
|
|
1770
|
-
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
1771
|
-
const sub = this.data[cursor];
|
|
1772
|
-
const pos = this.data[cursor + 1];
|
|
1773
|
-
sub.pub_off(pos);
|
|
1774
|
-
this.data.pop();
|
|
1775
|
-
this.data.pop();
|
|
1776
|
-
}
|
|
1777
|
-
this.cursor = this.pub_from;
|
|
1778
|
-
this.track_cut();
|
|
1779
|
-
this.cursor = $mol_wire_cursor.final;
|
|
1780
|
-
}
|
|
1781
|
-
track_cut() {
|
|
1782
|
-
if (this.cursor < this.pub_from) {
|
|
1783
|
-
$mol_fail(new Error('Cut of non begun sub'));
|
|
1784
|
-
}
|
|
1785
|
-
let tail = 0;
|
|
1786
|
-
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
|
1787
|
-
const pub = this.data[cursor];
|
|
1788
|
-
pub?.sub_off(this.data[cursor + 1]);
|
|
1789
|
-
if (this.sub_from < this.data.length) {
|
|
1790
|
-
this.peer_move(this.data.length - 2, cursor);
|
|
1791
|
-
this.data.pop();
|
|
1792
|
-
this.data.pop();
|
|
1793
|
-
}
|
|
1794
|
-
else {
|
|
1795
|
-
++tail;
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
for (; tail; --tail) {
|
|
1799
|
-
this.data.pop();
|
|
1800
|
-
this.data.pop();
|
|
1801
|
-
}
|
|
1802
|
-
this.sub_from = this.cursor;
|
|
1803
|
-
}
|
|
1804
|
-
complete() { }
|
|
1805
|
-
complete_pubs() {
|
|
1806
|
-
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
|
1807
|
-
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
1808
|
-
const pub = this.data[cursor];
|
|
1809
|
-
if (pub?.incompleted)
|
|
1810
|
-
return;
|
|
1811
|
-
}
|
|
1812
|
-
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
1813
|
-
const pub = this.data[cursor];
|
|
1814
|
-
pub?.complete();
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
absorb(quant = $mol_wire_cursor.stale) {
|
|
1818
|
-
if (this.cursor === $mol_wire_cursor.final)
|
|
1819
|
-
return;
|
|
1820
|
-
if (this.cursor >= quant)
|
|
1821
|
-
return;
|
|
1822
|
-
this.cursor = quant;
|
|
1823
|
-
this.emit($mol_wire_cursor.doubt);
|
|
1824
|
-
}
|
|
1825
|
-
[$mol_dev_format_head]() {
|
|
1826
|
-
return $mol_dev_format_native(this);
|
|
1827
|
-
}
|
|
1828
|
-
get pub_empty() {
|
|
1829
|
-
return this.sub_from === this.pub_from;
|
|
1830
|
-
}
|
|
1899
|
+
function $mol_base64_encode_node(str) {
|
|
1900
|
+
if (!str)
|
|
1901
|
+
return '';
|
|
1902
|
+
if (Buffer.isBuffer(str))
|
|
1903
|
+
return str.toString('base64');
|
|
1904
|
+
return Buffer.from(str).toString('base64');
|
|
1831
1905
|
}
|
|
1832
|
-
$.$
|
|
1906
|
+
$.$mol_base64_encode_node = $mol_base64_encode_node;
|
|
1907
|
+
$.$mol_base64_encode = $mol_base64_encode_node;
|
|
1833
1908
|
})($ || ($ = {}));
|
|
1834
1909
|
|
|
1835
1910
|
;
|
|
1836
1911
|
"use strict";
|
|
1837
1912
|
var $;
|
|
1838
1913
|
(function ($) {
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
task;
|
|
1842
|
-
id;
|
|
1843
|
-
constructor(delay, task) {
|
|
1844
|
-
super();
|
|
1845
|
-
this.delay = delay;
|
|
1846
|
-
this.task = task;
|
|
1847
|
-
this.id = setTimeout(task, delay);
|
|
1848
|
-
}
|
|
1849
|
-
destructor() {
|
|
1850
|
-
clearTimeout(this.id);
|
|
1851
|
-
}
|
|
1914
|
+
function $mol_base64_decode(base64) {
|
|
1915
|
+
throw new Error('Not implemented');
|
|
1852
1916
|
}
|
|
1853
|
-
$.$
|
|
1917
|
+
$.$mol_base64_decode = $mol_base64_decode;
|
|
1854
1918
|
})($ || ($ = {}));
|
|
1855
1919
|
|
|
1856
1920
|
;
|
|
1857
1921
|
"use strict";
|
|
1858
1922
|
var $;
|
|
1859
1923
|
(function ($) {
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
this.task = task;
|
|
1865
|
-
}
|
|
1924
|
+
function $mol_base64_decode_node(base64Str) {
|
|
1925
|
+
base64Str = base64Str.replace(/-/g, '+').replace(/_/g, '/');
|
|
1926
|
+
const buffer = Buffer.from(base64Str, 'base64');
|
|
1927
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
1866
1928
|
}
|
|
1867
|
-
$.$
|
|
1929
|
+
$.$mol_base64_decode_node = $mol_base64_decode_node;
|
|
1930
|
+
$.$mol_base64_decode = $mol_base64_decode_node;
|
|
1868
1931
|
})($ || ($ = {}));
|
|
1869
1932
|
|
|
1870
1933
|
;
|
|
1871
1934
|
"use strict";
|
|
1872
1935
|
var $;
|
|
1873
1936
|
(function ($) {
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
for (const fiber of fibers) {
|
|
1909
|
-
if (!fiber.sub_empty)
|
|
1910
|
-
continue;
|
|
1911
|
-
fiber.destructor();
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1915
|
-
[Symbol.toStringTag];
|
|
1916
|
-
cache = undefined;
|
|
1917
|
-
get args() {
|
|
1918
|
-
return this.data.slice(0, this.pub_from);
|
|
1937
|
+
function $mol_base64_url_encode(buffer) {
|
|
1938
|
+
return $mol_base64_encode(buffer).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
1939
|
+
}
|
|
1940
|
+
$.$mol_base64_url_encode = $mol_base64_url_encode;
|
|
1941
|
+
function $mol_base64_url_decode(str) {
|
|
1942
|
+
return $mol_base64_decode(str.replace(/-/g, '+').replace(/_/g, '/'));
|
|
1943
|
+
}
|
|
1944
|
+
$.$mol_base64_url_decode = $mol_base64_url_decode;
|
|
1945
|
+
})($ || ($ = {}));
|
|
1946
|
+
|
|
1947
|
+
;
|
|
1948
|
+
"use strict";
|
|
1949
|
+
var $;
|
|
1950
|
+
(function ($) {
|
|
1951
|
+
const algorithm = {
|
|
1952
|
+
name: 'ECDSA',
|
|
1953
|
+
hash: 'SHA-256',
|
|
1954
|
+
namedCurve: "P-256",
|
|
1955
|
+
};
|
|
1956
|
+
async function $mol_crypto_auditor_pair() {
|
|
1957
|
+
const pair = await $mol_crypto_native.subtle.generateKey(algorithm, true, ['sign', 'verify']);
|
|
1958
|
+
return {
|
|
1959
|
+
public: new $mol_crypto_auditor_public(pair.publicKey),
|
|
1960
|
+
private: new $mol_crypto_auditor_private(pair.privateKey),
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
$.$mol_crypto_auditor_pair = $mol_crypto_auditor_pair;
|
|
1964
|
+
class $mol_crypto_auditor_public extends Object {
|
|
1965
|
+
native;
|
|
1966
|
+
static size_str = 86;
|
|
1967
|
+
static size_bin = 64;
|
|
1968
|
+
constructor(native) {
|
|
1969
|
+
super();
|
|
1970
|
+
this.native = native;
|
|
1919
1971
|
}
|
|
1920
|
-
|
|
1921
|
-
if (
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
return this.
|
|
1972
|
+
static async from(serial) {
|
|
1973
|
+
if (typeof serial !== 'string') {
|
|
1974
|
+
serial = $mol_base64_url_encode(serial.subarray(0, 32))
|
|
1975
|
+
+ $mol_base64_url_encode(serial.subarray(32, 64));
|
|
1976
|
+
}
|
|
1977
|
+
return new this(await $mol_crypto_native.subtle.importKey('jwk', {
|
|
1978
|
+
crv: "P-256",
|
|
1979
|
+
ext: true,
|
|
1980
|
+
key_ops: ['verify'],
|
|
1981
|
+
kty: "EC",
|
|
1982
|
+
x: serial.slice(0, 43),
|
|
1983
|
+
y: serial.slice(43, 86),
|
|
1984
|
+
}, algorithm, true, ['verify']));
|
|
1926
1985
|
}
|
|
1927
|
-
|
|
1928
|
-
|
|
1986
|
+
async serial() {
|
|
1987
|
+
const { x, y } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
|
|
1988
|
+
return x + y;
|
|
1929
1989
|
}
|
|
1930
|
-
|
|
1931
|
-
|
|
1990
|
+
async toArray() {
|
|
1991
|
+
const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
|
|
1992
|
+
return new Uint8Array([
|
|
1993
|
+
...$mol_base64_url_decode(x),
|
|
1994
|
+
...$mol_base64_url_decode(y),
|
|
1995
|
+
]);
|
|
1932
1996
|
}
|
|
1933
|
-
|
|
1997
|
+
async verify(data, sign) {
|
|
1998
|
+
return await $mol_crypto_native.subtle.verify(algorithm, this.native, sign, data);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
$.$mol_crypto_auditor_public = $mol_crypto_auditor_public;
|
|
2002
|
+
class $mol_crypto_auditor_private extends Object {
|
|
2003
|
+
native;
|
|
2004
|
+
static size_str = 129;
|
|
2005
|
+
static size_bin = 96;
|
|
2006
|
+
constructor(native) {
|
|
1934
2007
|
super();
|
|
1935
|
-
this.
|
|
1936
|
-
this.host = host;
|
|
1937
|
-
if (args)
|
|
1938
|
-
this.data.push(...args);
|
|
1939
|
-
this.pub_from = this.sub_from = args?.length ?? 0;
|
|
1940
|
-
this[Symbol.toStringTag] = id;
|
|
2008
|
+
this.native = native;
|
|
1941
2009
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
2010
|
+
static async from(serial) {
|
|
2011
|
+
if (typeof serial !== 'string') {
|
|
2012
|
+
serial = $mol_base64_url_encode(serial.subarray(0, 32))
|
|
2013
|
+
+ $mol_base64_url_encode(serial.subarray(32, 64))
|
|
2014
|
+
+ $mol_base64_url_encode(serial.subarray(64));
|
|
2015
|
+
}
|
|
2016
|
+
return new this(await $mol_crypto_native.subtle.importKey('jwk', {
|
|
2017
|
+
crv: "P-256",
|
|
2018
|
+
ext: true,
|
|
2019
|
+
key_ops: ['sign'],
|
|
2020
|
+
kty: "EC",
|
|
2021
|
+
x: serial.slice(0, 43),
|
|
2022
|
+
y: serial.slice(43, 86),
|
|
2023
|
+
d: serial.slice(86, 129),
|
|
2024
|
+
}, algorithm, true, ['sign']));
|
|
1945
2025
|
}
|
|
1946
|
-
|
|
1947
|
-
$
|
|
1948
|
-
|
|
2026
|
+
async serial() {
|
|
2027
|
+
const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
|
|
2028
|
+
return x + y + d;
|
|
1949
2029
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
2030
|
+
async toArray() {
|
|
2031
|
+
const { x, y, d } = await $mol_crypto_native.subtle.exportKey('jwk', this.native);
|
|
2032
|
+
return new Uint8Array([
|
|
2033
|
+
...$mol_base64_url_decode(x),
|
|
2034
|
+
...$mol_base64_url_decode(y),
|
|
2035
|
+
...$mol_base64_url_decode(d),
|
|
2036
|
+
]);
|
|
1952
2037
|
}
|
|
1953
|
-
|
|
1954
|
-
return this
|
|
2038
|
+
async sign(data) {
|
|
2039
|
+
return await $mol_crypto_native.subtle.sign(algorithm, this.native, data);
|
|
1955
2040
|
}
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
[$mol_wire_cursor.stale]: '🔴',
|
|
1959
|
-
[$mol_wire_cursor.doubt]: '🟡',
|
|
1960
|
-
[$mol_wire_cursor.fresh]: '🟢',
|
|
1961
|
-
[$mol_wire_cursor.final]: '🔵',
|
|
1962
|
-
}[this.cursor] ?? this.cursor.toString();
|
|
1963
|
-
return $mol_dev_format_div({}, $mol_owning_check(this, this.cache)
|
|
1964
|
-
? $mol_dev_format_auto({
|
|
1965
|
-
[$mol_dev_format_head]: () => $mol_dev_format_shade(cursor),
|
|
1966
|
-
[$mol_dev_format_body]: () => $mol_dev_format_native(this),
|
|
1967
|
-
})
|
|
1968
|
-
: $mol_dev_format_shade($mol_dev_format_native(this), cursor), $mol_dev_format_auto(this.cache));
|
|
2041
|
+
async public() {
|
|
2042
|
+
return await $mol_crypto_auditor_public.from($mol_crypto_auditor_private_to_public(await this.serial()));
|
|
1969
2043
|
}
|
|
1970
|
-
|
|
1971
|
-
|
|
2044
|
+
}
|
|
2045
|
+
$.$mol_crypto_auditor_private = $mol_crypto_auditor_private;
|
|
2046
|
+
$.$mol_crypto_auditor_sign_size = 64;
|
|
2047
|
+
function $mol_crypto_auditor_private_to_public(serial) {
|
|
2048
|
+
return serial.slice(0, 86);
|
|
2049
|
+
}
|
|
2050
|
+
$.$mol_crypto_auditor_private_to_public = $mol_crypto_auditor_private_to_public;
|
|
2051
|
+
})($ || ($ = {}));
|
|
2052
|
+
|
|
2053
|
+
;
|
|
2054
|
+
"use strict";
|
|
2055
|
+
var $;
|
|
2056
|
+
(function ($) {
|
|
2057
|
+
let $hyoo_crowd_peer_level;
|
|
2058
|
+
(function ($hyoo_crowd_peer_level) {
|
|
2059
|
+
$hyoo_crowd_peer_level[$hyoo_crowd_peer_level["get"] = 0] = "get";
|
|
2060
|
+
$hyoo_crowd_peer_level[$hyoo_crowd_peer_level["add"] = 1] = "add";
|
|
2061
|
+
$hyoo_crowd_peer_level[$hyoo_crowd_peer_level["mod"] = 2] = "mod";
|
|
2062
|
+
$hyoo_crowd_peer_level[$hyoo_crowd_peer_level["law"] = 3] = "law";
|
|
2063
|
+
})($hyoo_crowd_peer_level = $.$hyoo_crowd_peer_level || ($.$hyoo_crowd_peer_level = {}));
|
|
2064
|
+
class $hyoo_crowd_peer extends Object {
|
|
2065
|
+
key_public;
|
|
2066
|
+
key_public_serial;
|
|
2067
|
+
key_private;
|
|
2068
|
+
key_private_serial;
|
|
2069
|
+
id;
|
|
2070
|
+
constructor(key_public, key_public_serial, key_private, key_private_serial) {
|
|
2071
|
+
super();
|
|
2072
|
+
this.key_public = key_public;
|
|
2073
|
+
this.key_public_serial = key_public_serial;
|
|
2074
|
+
this.key_private = key_private;
|
|
2075
|
+
this.key_private_serial = key_private_serial;
|
|
2076
|
+
this.id = $mol_int62_hash_string(this.key_public_serial);
|
|
1972
2077
|
}
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
super.emit(quant);
|
|
2078
|
+
static async generate() {
|
|
2079
|
+
const pair = await $$.$mol_crypto_auditor_pair();
|
|
2080
|
+
const serial = await pair.private.serial();
|
|
2081
|
+
return new this(pair.public, $mol_crypto_auditor_private_to_public(serial), pair.private, serial);
|
|
1978
2082
|
}
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2083
|
+
static async restore(serial) {
|
|
2084
|
+
return new this(await $$.$mol_crypto_auditor_public.from(serial), $mol_crypto_auditor_private_to_public(serial), await $$.$mol_crypto_auditor_private.from(serial), serial);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
$.$hyoo_crowd_peer = $hyoo_crowd_peer;
|
|
2088
|
+
})($ || ($ = {}));
|
|
2089
|
+
|
|
2090
|
+
;
|
|
2091
|
+
"use strict";
|
|
2092
|
+
|
|
2093
|
+
;
|
|
2094
|
+
"use strict";
|
|
2095
|
+
var $;
|
|
2096
|
+
(function ($) {
|
|
2097
|
+
const decoders = {};
|
|
2098
|
+
function $mol_charset_decode(buffer, encoding = 'utf8') {
|
|
2099
|
+
let decoder = decoders[encoding];
|
|
2100
|
+
if (!decoder)
|
|
2101
|
+
decoder = decoders[encoding] = new TextDecoder(encoding);
|
|
2102
|
+
return decoder.decode(buffer);
|
|
2103
|
+
}
|
|
2104
|
+
$.$mol_charset_decode = $mol_charset_decode;
|
|
2105
|
+
})($ || ($ = {}));
|
|
2106
|
+
|
|
2107
|
+
;
|
|
2108
|
+
"use strict";
|
|
2109
|
+
var $;
|
|
2110
|
+
(function ($) {
|
|
2111
|
+
const level = $mol_data_enum('level', $hyoo_crowd_peer_level);
|
|
2112
|
+
let $hyoo_crowd_unit_kind;
|
|
2113
|
+
(function ($hyoo_crowd_unit_kind) {
|
|
2114
|
+
$hyoo_crowd_unit_kind[$hyoo_crowd_unit_kind["grab"] = 0] = "grab";
|
|
2115
|
+
$hyoo_crowd_unit_kind[$hyoo_crowd_unit_kind["join"] = 1] = "join";
|
|
2116
|
+
$hyoo_crowd_unit_kind[$hyoo_crowd_unit_kind["give"] = 2] = "give";
|
|
2117
|
+
$hyoo_crowd_unit_kind[$hyoo_crowd_unit_kind["data"] = 3] = "data";
|
|
2118
|
+
})($hyoo_crowd_unit_kind = $.$hyoo_crowd_unit_kind || ($.$hyoo_crowd_unit_kind = {}));
|
|
2119
|
+
let $hyoo_crowd_unit_group;
|
|
2120
|
+
(function ($hyoo_crowd_unit_group) {
|
|
2121
|
+
$hyoo_crowd_unit_group[$hyoo_crowd_unit_group["auth"] = 0] = "auth";
|
|
2122
|
+
$hyoo_crowd_unit_group[$hyoo_crowd_unit_group["data"] = 1] = "data";
|
|
2123
|
+
})($hyoo_crowd_unit_group = $.$hyoo_crowd_unit_group || ($.$hyoo_crowd_unit_group = {}));
|
|
2124
|
+
class $hyoo_crowd_unit extends Object {
|
|
2125
|
+
land;
|
|
2126
|
+
auth;
|
|
2127
|
+
head;
|
|
2128
|
+
self;
|
|
2129
|
+
next;
|
|
2130
|
+
prev;
|
|
2131
|
+
time;
|
|
2132
|
+
data;
|
|
2133
|
+
bin;
|
|
2134
|
+
constructor(land, auth, head, self, next, prev, time, data, bin) {
|
|
2135
|
+
super();
|
|
2136
|
+
this.land = land;
|
|
2137
|
+
this.auth = auth;
|
|
2138
|
+
this.head = head;
|
|
2139
|
+
this.self = self;
|
|
2140
|
+
this.next = next;
|
|
2141
|
+
this.prev = prev;
|
|
2142
|
+
this.time = time;
|
|
2143
|
+
this.data = data;
|
|
2144
|
+
this.bin = bin;
|
|
2145
|
+
}
|
|
2146
|
+
kind() {
|
|
2147
|
+
if (this.head === this.self && this.auth === this.self) {
|
|
2148
|
+
if (this.head === this.land) {
|
|
2149
|
+
return $hyoo_crowd_unit_kind.grab;
|
|
2020
2150
|
}
|
|
2021
2151
|
else {
|
|
2022
|
-
|
|
2023
|
-
}
|
|
2024
|
-
if ($mol_promise_like(result) && !handled.has(result)) {
|
|
2025
|
-
result = result.finally(() => {
|
|
2026
|
-
if (this.cache === result)
|
|
2027
|
-
this.absorb();
|
|
2028
|
-
});
|
|
2152
|
+
return $hyoo_crowd_unit_kind.join;
|
|
2029
2153
|
}
|
|
2030
2154
|
}
|
|
2031
|
-
if (
|
|
2032
|
-
|
|
2033
|
-
destructor: result['destructor'] ?? (() => { })
|
|
2034
|
-
});
|
|
2035
|
-
handled.add(result);
|
|
2036
|
-
const error = new Error();
|
|
2037
|
-
Object.defineProperty(result, 'stack', { get: () => error.stack });
|
|
2038
|
-
}
|
|
2039
|
-
if (!$mol_promise_like(result)) {
|
|
2040
|
-
this.track_cut();
|
|
2155
|
+
if (this.head === this.land) {
|
|
2156
|
+
return $hyoo_crowd_unit_kind.give;
|
|
2041
2157
|
}
|
|
2042
|
-
|
|
2043
|
-
this.put(result);
|
|
2158
|
+
return $hyoo_crowd_unit_kind.data;
|
|
2044
2159
|
}
|
|
2045
|
-
|
|
2046
|
-
this.
|
|
2047
|
-
|
|
2160
|
+
group() {
|
|
2161
|
+
return this.kind() === $hyoo_crowd_unit_kind.data
|
|
2162
|
+
? $hyoo_crowd_unit_group.data
|
|
2163
|
+
: $hyoo_crowd_unit_group.auth;
|
|
2048
2164
|
}
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
return
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
this.fresh();
|
|
2055
|
-
if (this.cache instanceof Error) {
|
|
2056
|
-
return $mol_fail_hidden(this.cache);
|
|
2165
|
+
level() {
|
|
2166
|
+
switch (this.kind()) {
|
|
2167
|
+
case $hyoo_crowd_unit_kind.grab: return $hyoo_crowd_peer_level.law;
|
|
2168
|
+
case $hyoo_crowd_unit_kind.give: return level(this.data);
|
|
2169
|
+
default: $mol_fail(new Error(`Wrong unit kind for getting level: ${this.kind()}`));
|
|
2057
2170
|
}
|
|
2058
|
-
|
|
2059
|
-
|
|
2171
|
+
}
|
|
2172
|
+
[Symbol.toPrimitive]() {
|
|
2173
|
+
return JSON.stringify(this);
|
|
2174
|
+
}
|
|
2175
|
+
[$mol_dev_format_head]() {
|
|
2176
|
+
switch (this.kind()) {
|
|
2177
|
+
case $hyoo_crowd_unit_kind.grab:
|
|
2178
|
+
return $mol_dev_format_div({}, $mol_dev_format_native(this), ' 👑');
|
|
2179
|
+
case $hyoo_crowd_unit_kind.join:
|
|
2180
|
+
return $mol_dev_format_div({}, $mol_dev_format_native(this), $mol_dev_format_shade(' 🔑 ', this.self));
|
|
2181
|
+
case $hyoo_crowd_unit_kind.give:
|
|
2182
|
+
return $mol_dev_format_div({}, $mol_dev_format_native(this), $mol_dev_format_shade(' 🏅 ', this.self, ' '), $mol_dev_format_native($hyoo_crowd_peer_level[this.data] ?? this.data));
|
|
2183
|
+
case $hyoo_crowd_unit_kind.data:
|
|
2184
|
+
return $mol_dev_format_div({}, $mol_dev_format_native(this), $mol_dev_format_shade(' 📦 ', this.head, '!', this.self, ' '), $mol_dev_format_native(this.data));
|
|
2060
2185
|
}
|
|
2061
|
-
return this.cache;
|
|
2062
2186
|
}
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2187
|
+
}
|
|
2188
|
+
$.$hyoo_crowd_unit = $hyoo_crowd_unit;
|
|
2189
|
+
const offset = {
|
|
2190
|
+
land_lo: 0,
|
|
2191
|
+
land_hi: 4,
|
|
2192
|
+
auth_lo: 8,
|
|
2193
|
+
auth_hi: 12,
|
|
2194
|
+
head_lo: 16,
|
|
2195
|
+
head_hi: 20,
|
|
2196
|
+
self_lo: 24,
|
|
2197
|
+
self_hi: 28,
|
|
2198
|
+
next_lo: 32,
|
|
2199
|
+
next_hi: 36,
|
|
2200
|
+
prev_lo: 40,
|
|
2201
|
+
prev_hi: 44,
|
|
2202
|
+
time: 48,
|
|
2203
|
+
size: 54,
|
|
2204
|
+
data: 56,
|
|
2205
|
+
};
|
|
2206
|
+
class $hyoo_crowd_unit_bin extends DataView {
|
|
2207
|
+
static from_buffer(buffer) {
|
|
2208
|
+
const size = Math.ceil(Math.abs(buffer[offset.size / 2]) / 8) * 8 + offset.data + $mol_crypto_auditor_sign_size;
|
|
2209
|
+
return new this(buffer.slice(0, size / 2).buffer);
|
|
2210
|
+
}
|
|
2211
|
+
static from_unit(unit) {
|
|
2212
|
+
if (unit.bin)
|
|
2213
|
+
return unit.bin;
|
|
2214
|
+
const type = unit.data === null
|
|
2215
|
+
? 0
|
|
2216
|
+
: unit.data instanceof Uint8Array
|
|
2217
|
+
? -1
|
|
2218
|
+
: 1;
|
|
2219
|
+
const buff = type === 0 ? null
|
|
2220
|
+
: type > 0 ? $mol_charset_encode(JSON.stringify(unit.data))
|
|
2221
|
+
: unit.data;
|
|
2222
|
+
const size = buff?.byteLength ?? 0;
|
|
2223
|
+
if (type > 0 && size > 2 ** 15 - 1)
|
|
2224
|
+
throw new Error(`Too large json data: ${size} > ${2 ** 15 - 1}`);
|
|
2225
|
+
if (type < 0 && size > 2 ** 15)
|
|
2226
|
+
throw new Error(`Too large binary data: ${size} > ${2 ** 15}`);
|
|
2227
|
+
const total = offset.data + Math.ceil(size / 8) * 8 + $mol_crypto_auditor_sign_size;
|
|
2228
|
+
const mem = new Uint8Array(total);
|
|
2229
|
+
const bin = new $hyoo_crowd_unit_bin(mem.buffer);
|
|
2230
|
+
const land = $mol_int62_from_string(unit.land);
|
|
2231
|
+
bin.setInt32(offset.land_lo, land.lo, true);
|
|
2232
|
+
bin.setInt32(offset.land_hi, land.hi, true);
|
|
2233
|
+
const auth = $mol_int62_from_string(unit.auth);
|
|
2234
|
+
bin.setInt32(offset.auth_lo, auth.lo, true);
|
|
2235
|
+
bin.setInt32(offset.auth_hi, auth.hi, true);
|
|
2236
|
+
const head = $mol_int62_from_string(unit.head);
|
|
2237
|
+
bin.setInt32(offset.head_lo, head.lo, true);
|
|
2238
|
+
bin.setInt32(offset.head_hi, head.hi, true);
|
|
2239
|
+
const self = $mol_int62_from_string(unit.self);
|
|
2240
|
+
bin.setInt32(offset.self_lo, self.lo, true);
|
|
2241
|
+
bin.setInt32(offset.self_hi, self.hi, true);
|
|
2242
|
+
const next = $mol_int62_from_string(unit.next);
|
|
2243
|
+
bin.setInt32(offset.next_lo, next.lo, true);
|
|
2244
|
+
bin.setInt32(offset.next_hi, next.hi, true);
|
|
2245
|
+
const prev = $mol_int62_from_string(unit.prev);
|
|
2246
|
+
bin.setInt32(offset.prev_lo, prev.lo, true);
|
|
2247
|
+
bin.setInt32(offset.prev_hi, prev.hi, true);
|
|
2248
|
+
bin.setInt32(offset.time, unit.time, true);
|
|
2249
|
+
bin.setInt16(offset.size, type * size, true);
|
|
2250
|
+
if (buff)
|
|
2251
|
+
mem.set(buff, offset.data);
|
|
2252
|
+
return bin;
|
|
2253
|
+
}
|
|
2254
|
+
sign(next) {
|
|
2255
|
+
const sign_offset = this.byteOffset + this.byteLength - $mol_crypto_auditor_sign_size;
|
|
2256
|
+
const buff = new Uint8Array(this.buffer, sign_offset, $mol_crypto_auditor_sign_size);
|
|
2257
|
+
if (!next)
|
|
2258
|
+
return buff;
|
|
2259
|
+
buff.set(next);
|
|
2260
|
+
return buff;
|
|
2261
|
+
}
|
|
2262
|
+
size() {
|
|
2263
|
+
return Math.ceil(Math.abs(this.getInt16(offset.size, true)) / 8) * 8 + offset.data + $mol_crypto_auditor_sign_size;
|
|
2264
|
+
}
|
|
2265
|
+
sens() {
|
|
2266
|
+
return new Uint8Array(this.buffer, this.byteOffset, this.size() - $mol_crypto_auditor_sign_size);
|
|
2267
|
+
}
|
|
2268
|
+
unit() {
|
|
2269
|
+
const land = $mol_int62_to_string({
|
|
2270
|
+
lo: this.getInt32(offset.land_lo, true) << 1 >> 1,
|
|
2271
|
+
hi: this.getInt32(offset.land_hi, true) << 1 >> 1,
|
|
2272
|
+
});
|
|
2273
|
+
const auth = $mol_int62_to_string({
|
|
2274
|
+
lo: this.getInt32(offset.auth_lo, true) << 1 >> 1,
|
|
2275
|
+
hi: this.getInt32(offset.auth_hi, true) << 1 >> 1,
|
|
2276
|
+
});
|
|
2277
|
+
const head = $mol_int62_to_string({
|
|
2278
|
+
lo: this.getInt32(offset.head_lo, true) << 1 >> 1,
|
|
2279
|
+
hi: this.getInt32(offset.head_hi, true) << 1 >> 1,
|
|
2280
|
+
});
|
|
2281
|
+
const self = $mol_int62_to_string({
|
|
2282
|
+
lo: this.getInt32(offset.self_lo, true) << 1 >> 1,
|
|
2283
|
+
hi: this.getInt32(offset.self_hi, true) << 1 >> 1,
|
|
2284
|
+
});
|
|
2285
|
+
const next = $mol_int62_to_string({
|
|
2286
|
+
lo: this.getInt32(offset.next_lo, true) << 1 >> 1,
|
|
2287
|
+
hi: this.getInt32(offset.next_hi, true) << 1 >> 1,
|
|
2288
|
+
});
|
|
2289
|
+
const prev = $mol_int62_to_string({
|
|
2290
|
+
lo: this.getInt32(offset.prev_lo, true) << 1 >> 1,
|
|
2291
|
+
hi: this.getInt32(offset.prev_hi, true) << 1 >> 1,
|
|
2292
|
+
});
|
|
2293
|
+
const time = this.getInt32(offset.time, true) << 1 >> 1;
|
|
2294
|
+
const type_size = this.getInt16(offset.size, true);
|
|
2295
|
+
let data = null;
|
|
2296
|
+
if (type_size) {
|
|
2297
|
+
try {
|
|
2298
|
+
var buff = new Uint8Array(this.buffer, this.byteOffset + offset.data, Math.abs(type_size));
|
|
2068
2299
|
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
if (!$mol_promise_like(this.cache))
|
|
2073
|
-
return this.cache;
|
|
2074
|
-
if (this.cursor === $mol_wire_cursor.final) {
|
|
2075
|
-
await new Promise(() => { });
|
|
2300
|
+
catch (error) {
|
|
2301
|
+
error['message'] += `\nhead=${head};self=${self}`;
|
|
2302
|
+
$mol_fail_hidden(error);
|
|
2076
2303
|
}
|
|
2304
|
+
if (type_size < 0)
|
|
2305
|
+
data = buff;
|
|
2306
|
+
else
|
|
2307
|
+
data = JSON.parse($mol_charset_decode(buff));
|
|
2077
2308
|
}
|
|
2078
|
-
|
|
2079
|
-
step() {
|
|
2080
|
-
return new Promise(done => {
|
|
2081
|
-
const sub = new $mol_wire_pub_sub;
|
|
2082
|
-
const prev = sub.track_on();
|
|
2083
|
-
sub.track_next(this);
|
|
2084
|
-
sub.track_off(prev);
|
|
2085
|
-
sub.absorb = () => {
|
|
2086
|
-
done(null);
|
|
2087
|
-
sub.destructor();
|
|
2088
|
-
};
|
|
2089
|
-
});
|
|
2309
|
+
return new $hyoo_crowd_unit(land, auth, head, self, next, prev, time, data, this);
|
|
2090
2310
|
}
|
|
2091
2311
|
}
|
|
2092
|
-
$.$
|
|
2312
|
+
$.$hyoo_crowd_unit_bin = $hyoo_crowd_unit_bin;
|
|
2313
|
+
function $hyoo_crowd_unit_compare(left, right) {
|
|
2314
|
+
return (left.group() - right.group())
|
|
2315
|
+
|| (left.time - right.time)
|
|
2316
|
+
|| ((left.auth > right.auth) ? 1 : (left.auth < right.auth) ? -1 : 0)
|
|
2317
|
+
|| ((left.self > right.self) ? 1 : (left.self < right.self) ? -1 : 0)
|
|
2318
|
+
|| ((left.head > right.head) ? 1 : (left.head < right.head) ? -1 : 0)
|
|
2319
|
+
|| ((left.prev > right.prev) ? 1 : (left.prev < right.prev) ? -1 : 0)
|
|
2320
|
+
|| ((left.next > right.next) ? 1 : (left.next < right.next) ? -1 : 0)
|
|
2321
|
+
|| ((left.land > right.land) ? 1 : (left.land < right.land) ? -1 : 0);
|
|
2322
|
+
}
|
|
2323
|
+
$.$hyoo_crowd_unit_compare = $hyoo_crowd_unit_compare;
|
|
2093
2324
|
})($ || ($ = {}));
|
|
2094
2325
|
|
|
2095
2326
|
;
|
|
@@ -2154,206 +2385,6 @@ var $;
|
|
|
2154
2385
|
$.$mol_key = $mol_key;
|
|
2155
2386
|
})($ || ($ = {}));
|
|
2156
2387
|
|
|
2157
|
-
;
|
|
2158
|
-
"use strict";
|
|
2159
|
-
var $;
|
|
2160
|
-
(function ($) {
|
|
2161
|
-
$.$mol_compare_deep_cache = new WeakMap();
|
|
2162
|
-
function $mol_compare_deep(left, right) {
|
|
2163
|
-
if (Object.is(left, right))
|
|
2164
|
-
return true;
|
|
2165
|
-
if (left === null)
|
|
2166
|
-
return false;
|
|
2167
|
-
if (right === null)
|
|
2168
|
-
return false;
|
|
2169
|
-
if (typeof left !== 'object')
|
|
2170
|
-
return false;
|
|
2171
|
-
if (typeof right !== 'object')
|
|
2172
|
-
return false;
|
|
2173
|
-
const left_proto = Reflect.getPrototypeOf(left);
|
|
2174
|
-
const right_proto = Reflect.getPrototypeOf(right);
|
|
2175
|
-
if (left_proto !== right_proto)
|
|
2176
|
-
return false;
|
|
2177
|
-
if (left instanceof Boolean)
|
|
2178
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
2179
|
-
if (left instanceof Number)
|
|
2180
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
2181
|
-
if (left instanceof String)
|
|
2182
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
2183
|
-
if (left instanceof Date)
|
|
2184
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
2185
|
-
if (left instanceof RegExp)
|
|
2186
|
-
return left.source === right.source && left.flags === right.flags;
|
|
2187
|
-
if (left instanceof Error)
|
|
2188
|
-
return left.message === right.message && left.stack === right.stack;
|
|
2189
|
-
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
2190
|
-
if (left_cache) {
|
|
2191
|
-
const right_cache = left_cache.get(right);
|
|
2192
|
-
if (typeof right_cache === 'boolean')
|
|
2193
|
-
return right_cache;
|
|
2194
|
-
}
|
|
2195
|
-
else {
|
|
2196
|
-
left_cache = new WeakMap([[right, true]]);
|
|
2197
|
-
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
2198
|
-
}
|
|
2199
|
-
let result;
|
|
2200
|
-
try {
|
|
2201
|
-
if (!left_proto)
|
|
2202
|
-
result = compare_pojo(left, right);
|
|
2203
|
-
else if (!Reflect.getPrototypeOf(left_proto))
|
|
2204
|
-
result = compare_pojo(left, right);
|
|
2205
|
-
else if (Symbol.toPrimitive in left)
|
|
2206
|
-
result = compare_primitive(left, right);
|
|
2207
|
-
else if (Array.isArray(left))
|
|
2208
|
-
result = compare_array(left, right);
|
|
2209
|
-
else if (left instanceof Set)
|
|
2210
|
-
result = compare_set(left, right);
|
|
2211
|
-
else if (left instanceof Map)
|
|
2212
|
-
result = compare_map(left, right);
|
|
2213
|
-
else if (ArrayBuffer.isView(left))
|
|
2214
|
-
result = compare_buffer(left, right);
|
|
2215
|
-
else if (Symbol.iterator in left)
|
|
2216
|
-
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
2217
|
-
else
|
|
2218
|
-
result = false;
|
|
2219
|
-
}
|
|
2220
|
-
finally {
|
|
2221
|
-
left_cache.set(right, result);
|
|
2222
|
-
}
|
|
2223
|
-
return result;
|
|
2224
|
-
}
|
|
2225
|
-
$.$mol_compare_deep = $mol_compare_deep;
|
|
2226
|
-
function compare_array(left, right) {
|
|
2227
|
-
const len = left.length;
|
|
2228
|
-
if (len !== right.length)
|
|
2229
|
-
return false;
|
|
2230
|
-
for (let i = 0; i < len; ++i) {
|
|
2231
|
-
if (!$mol_compare_deep(left[i], right[i]))
|
|
2232
|
-
return false;
|
|
2233
|
-
}
|
|
2234
|
-
return true;
|
|
2235
|
-
}
|
|
2236
|
-
function compare_buffer(left, right) {
|
|
2237
|
-
const len = left.byteLength;
|
|
2238
|
-
if (len !== right.byteLength)
|
|
2239
|
-
return false;
|
|
2240
|
-
if (left instanceof DataView)
|
|
2241
|
-
return compare_buffer(new Uint8Array(left.buffer, left.byteOffset, left.byteLength), new Uint8Array(right.buffer, left.byteOffset, left.byteLength));
|
|
2242
|
-
for (let i = 0; i < len; ++i) {
|
|
2243
|
-
if (left[i] !== right[i])
|
|
2244
|
-
return false;
|
|
2245
|
-
}
|
|
2246
|
-
return true;
|
|
2247
|
-
}
|
|
2248
|
-
function compare_iterator(left, right) {
|
|
2249
|
-
while (true) {
|
|
2250
|
-
const left_next = left.next();
|
|
2251
|
-
const right_next = right.next();
|
|
2252
|
-
if (left_next.done !== right_next.done)
|
|
2253
|
-
return false;
|
|
2254
|
-
if (left_next.done)
|
|
2255
|
-
break;
|
|
2256
|
-
if (!$mol_compare_deep(left_next.value, right_next.value))
|
|
2257
|
-
return false;
|
|
2258
|
-
}
|
|
2259
|
-
return true;
|
|
2260
|
-
}
|
|
2261
|
-
function compare_set(left, right) {
|
|
2262
|
-
if (left.size !== right.size)
|
|
2263
|
-
return false;
|
|
2264
|
-
return compare_iterator(left.values(), right.values());
|
|
2265
|
-
}
|
|
2266
|
-
function compare_map(left, right) {
|
|
2267
|
-
if (left.size !== right.size)
|
|
2268
|
-
return false;
|
|
2269
|
-
return compare_iterator(left.keys(), right.keys())
|
|
2270
|
-
&& compare_iterator(left.values(), right.values());
|
|
2271
|
-
}
|
|
2272
|
-
function compare_pojo(left, right) {
|
|
2273
|
-
const left_keys = Object.getOwnPropertyNames(left);
|
|
2274
|
-
const right_keys = Object.getOwnPropertyNames(right);
|
|
2275
|
-
if (!compare_array(left_keys, right_keys))
|
|
2276
|
-
return false;
|
|
2277
|
-
for (let key of left_keys) {
|
|
2278
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
2279
|
-
return false;
|
|
2280
|
-
}
|
|
2281
|
-
const left_syms = Object.getOwnPropertySymbols(left);
|
|
2282
|
-
const right_syms = Object.getOwnPropertySymbols(right);
|
|
2283
|
-
if (!compare_array(left_syms, right_syms))
|
|
2284
|
-
return false;
|
|
2285
|
-
for (let key of left_syms) {
|
|
2286
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
2287
|
-
return false;
|
|
2288
|
-
}
|
|
2289
|
-
return true;
|
|
2290
|
-
}
|
|
2291
|
-
function compare_primitive(left, right) {
|
|
2292
|
-
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
2293
|
-
}
|
|
2294
|
-
})($ || ($ = {}));
|
|
2295
|
-
|
|
2296
|
-
;
|
|
2297
|
-
"use strict";
|
|
2298
|
-
var $;
|
|
2299
|
-
(function ($) {
|
|
2300
|
-
class $mol_wire_task extends $mol_wire_fiber {
|
|
2301
|
-
static getter(task) {
|
|
2302
|
-
return function $mol_wire_task_get(host, args) {
|
|
2303
|
-
const sub = $mol_wire_auto();
|
|
2304
|
-
const existen = sub?.track_next();
|
|
2305
|
-
reuse: if (existen) {
|
|
2306
|
-
if (!existen.temp)
|
|
2307
|
-
break reuse;
|
|
2308
|
-
if (existen.host !== host)
|
|
2309
|
-
break reuse;
|
|
2310
|
-
if (existen.task !== task)
|
|
2311
|
-
break reuse;
|
|
2312
|
-
if (!$mol_compare_deep(existen.args, args))
|
|
2313
|
-
break reuse;
|
|
2314
|
-
return existen;
|
|
2315
|
-
}
|
|
2316
|
-
const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}<#>`, task, host, args);
|
|
2317
|
-
if (existen?.temp) {
|
|
2318
|
-
$$.$mol_log3_warn({
|
|
2319
|
-
place: '$mol_wire_task',
|
|
2320
|
-
message: `Non idempotency`,
|
|
2321
|
-
existen,
|
|
2322
|
-
next,
|
|
2323
|
-
hint: 'Ignore it',
|
|
2324
|
-
});
|
|
2325
|
-
}
|
|
2326
|
-
return next;
|
|
2327
|
-
};
|
|
2328
|
-
}
|
|
2329
|
-
get temp() {
|
|
2330
|
-
return true;
|
|
2331
|
-
}
|
|
2332
|
-
complete() {
|
|
2333
|
-
if ($mol_promise_like(this.cache))
|
|
2334
|
-
return;
|
|
2335
|
-
this.destructor();
|
|
2336
|
-
}
|
|
2337
|
-
put(next) {
|
|
2338
|
-
const prev = this.cache;
|
|
2339
|
-
this.cache = next;
|
|
2340
|
-
if ($mol_promise_like(next)) {
|
|
2341
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
2342
|
-
if (next !== prev)
|
|
2343
|
-
this.emit();
|
|
2344
|
-
return next;
|
|
2345
|
-
}
|
|
2346
|
-
this.cursor = $mol_wire_cursor.final;
|
|
2347
|
-
if (this.sub_empty)
|
|
2348
|
-
this.destructor();
|
|
2349
|
-
else if (next !== prev)
|
|
2350
|
-
this.emit();
|
|
2351
|
-
return next;
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
$.$mol_wire_task = $mol_wire_task;
|
|
2355
|
-
})($ || ($ = {}));
|
|
2356
|
-
|
|
2357
2388
|
;
|
|
2358
2389
|
"use strict";
|
|
2359
2390
|
var $;
|
|
@@ -2600,32 +2631,6 @@ var $;
|
|
|
2600
2631
|
$.$mol_mem_key = $mol_wire_plex;
|
|
2601
2632
|
})($ || ($ = {}));
|
|
2602
2633
|
|
|
2603
|
-
;
|
|
2604
|
-
"use strict";
|
|
2605
|
-
var $;
|
|
2606
|
-
(function ($) {
|
|
2607
|
-
function $mol_wire_sync(obj) {
|
|
2608
|
-
return new Proxy(obj, {
|
|
2609
|
-
get(obj, field) {
|
|
2610
|
-
const val = obj[field];
|
|
2611
|
-
if (typeof val !== 'function')
|
|
2612
|
-
return val;
|
|
2613
|
-
const temp = $mol_wire_task.getter(val);
|
|
2614
|
-
return function $mol_wire_sync(...args) {
|
|
2615
|
-
const fiber = temp(obj, args);
|
|
2616
|
-
return fiber.sync();
|
|
2617
|
-
};
|
|
2618
|
-
},
|
|
2619
|
-
apply(obj, self, args) {
|
|
2620
|
-
const temp = $mol_wire_task.getter(obj);
|
|
2621
|
-
const fiber = temp(self, args);
|
|
2622
|
-
return fiber.sync();
|
|
2623
|
-
},
|
|
2624
|
-
});
|
|
2625
|
-
}
|
|
2626
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
|
2627
|
-
})($ || ($ = {}));
|
|
2628
|
-
|
|
2629
2634
|
;
|
|
2630
2635
|
"use strict";
|
|
2631
2636
|
var $;
|