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