hyoo_sync_client 0.0.604 → 0.0.606
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/manifest.json +10 -0
- package/node.d.ts +541 -120
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +1332 -470
- package/node.js.map +1 -1
- package/node.meta.tree +7 -3
- package/node.mjs +1332 -470
- package/node.test.js +1734 -623
- package/node.test.js.map +1 -1
- package/package.json +29 -23
- package/test.html +1 -1
- package/web.d.ts +439 -38
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +965 -158
- package/web.js.map +1 -1
- package/web.meta.tree +7 -3
- package/web.mjs +965 -158
- package/web.test.js +297 -101
- package/web.test.js.map +1 -1
package/web.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare class $ extends _$_ {
|
|
|
6
6
|
declare namespace $ {
|
|
7
7
|
export type $ = typeof $$;
|
|
8
8
|
export class $$ extends $ {
|
|
9
|
+
static $: $;
|
|
9
10
|
}
|
|
10
11
|
namespace $$ {
|
|
11
12
|
type $$ = $;
|
|
@@ -13,15 +14,19 @@ declare namespace $ {
|
|
|
13
14
|
export {};
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
declare let $hyoo_sync_revision: string;
|
|
17
|
-
|
|
18
17
|
declare namespace $ {
|
|
19
18
|
const $mol_ambient_ref: unique symbol;
|
|
19
|
+
/** @deprecated use $ instead */
|
|
20
20
|
type $mol_ambient_context = $;
|
|
21
21
|
function $mol_ambient(this: $ | void, overrides: Partial<$>): $;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
declare namespace $ {
|
|
25
|
+
/**
|
|
26
|
+
* Proxy that delegates all to lazy returned target.
|
|
27
|
+
*
|
|
28
|
+
* $mol_delegate( Array.prototype , ()=> fetch_array() )
|
|
29
|
+
*/
|
|
25
30
|
function $mol_delegate<Value extends object>(proto: Value, target: () => Value): Value;
|
|
26
31
|
}
|
|
27
32
|
|
|
@@ -58,6 +63,11 @@ declare namespace $ {
|
|
|
58
63
|
function $mol_func_name_from<Target extends Function>(target: Target, source: Function): Target;
|
|
59
64
|
}
|
|
60
65
|
|
|
66
|
+
declare namespace $ {
|
|
67
|
+
const $mol_key_handle: unique symbol;
|
|
68
|
+
const $mol_key_store: WeakMap<object, string>;
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
declare namespace $ {
|
|
62
72
|
class $mol_object2 {
|
|
63
73
|
static $: $;
|
|
@@ -69,16 +79,23 @@ declare namespace $ {
|
|
|
69
79
|
static [Symbol.toPrimitive](): any;
|
|
70
80
|
static toString(): any;
|
|
71
81
|
static toJSON(): any;
|
|
82
|
+
static [$mol_key_handle](): any;
|
|
72
83
|
destructor(): void;
|
|
73
84
|
static destructor(): void;
|
|
85
|
+
[Symbol.dispose](): void;
|
|
74
86
|
toString(): string;
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
|
|
78
|
-
declare
|
|
90
|
+
declare namespace $ {
|
|
91
|
+
/** Temporary buffer. Recursive usage isn't supported. */
|
|
92
|
+
function $mol_charset_buffer(size: number): Uint8Array<ArrayBuffer>;
|
|
93
|
+
}
|
|
79
94
|
|
|
80
95
|
declare namespace $ {
|
|
81
|
-
function $mol_charset_encode(
|
|
96
|
+
function $mol_charset_encode(str: string): Uint8Array<ArrayBuffer>;
|
|
97
|
+
function $mol_charset_encode_to(str: string, buf: Uint8Array<ArrayBuffer>, from?: number): number;
|
|
98
|
+
function $mol_charset_encode_size(str: string): number;
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
declare namespace $ {
|
|
@@ -131,6 +148,10 @@ declare namespace $ {
|
|
|
131
148
|
}
|
|
132
149
|
|
|
133
150
|
declare namespace $ {
|
|
151
|
+
/**
|
|
152
|
+
* Checks for value of given enum and returns expected type.
|
|
153
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_data_enum_demo
|
|
154
|
+
*/
|
|
134
155
|
function $mol_data_enum<Dict extends Record<number | string, number | string>>(name: string, dict: Dict): ((value: Dict[keyof Dict]) => Dict[keyof Dict]) & {
|
|
135
156
|
config: {
|
|
136
157
|
name: string;
|
|
@@ -145,7 +166,12 @@ declare namespace $ {
|
|
|
145
166
|
}
|
|
146
167
|
|
|
147
168
|
declare namespace $ {
|
|
148
|
-
function $
|
|
169
|
+
function $mol_base64_url_encode(buffer: Uint8Array<ArrayBuffer>): string;
|
|
170
|
+
function $mol_base64_url_decode(str: string): Uint8Array<ArrayBuffer>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
declare namespace $ {
|
|
174
|
+
function $mol_base64_encode(src: Uint8Array<ArrayBuffer>): string;
|
|
149
175
|
}
|
|
150
176
|
|
|
151
177
|
declare namespace $ {
|
|
@@ -160,7 +186,7 @@ declare namespace $ {
|
|
|
160
186
|
}
|
|
161
187
|
|
|
162
188
|
declare namespace $ {
|
|
163
|
-
function $mol_base64_encode_web(str:
|
|
189
|
+
function $mol_base64_encode_web(str: Uint8Array<ArrayBuffer>): string;
|
|
164
190
|
}
|
|
165
191
|
|
|
166
192
|
declare namespace $ {
|
|
@@ -172,44 +198,56 @@ declare namespace $ {
|
|
|
172
198
|
}
|
|
173
199
|
|
|
174
200
|
declare namespace $ {
|
|
175
|
-
function $
|
|
176
|
-
function $
|
|
201
|
+
function $mol_base64_url_encode_web(buffer: Uint8Array<ArrayBuffer>): string;
|
|
202
|
+
function $mol_base64_url_decode_web(str: string): Uint8Array<ArrayBuffer>;
|
|
177
203
|
}
|
|
178
204
|
|
|
179
205
|
declare namespace $ {
|
|
206
|
+
/** Asymmetric signing pair with shortest payload */
|
|
180
207
|
function $mol_crypto_auditor_pair(this: $): Promise<{
|
|
181
208
|
public: $mol_crypto_auditor_public;
|
|
182
209
|
private: $mol_crypto_auditor_private;
|
|
183
210
|
}>;
|
|
211
|
+
/** Asymmetric signing public key wrapper with shortest payload */
|
|
184
212
|
class $mol_crypto_auditor_public extends Object {
|
|
185
213
|
readonly native: CryptoKey & {
|
|
186
214
|
type: 'public';
|
|
187
215
|
};
|
|
216
|
+
/** Key size in bytes. */
|
|
188
217
|
static size_str: number;
|
|
189
218
|
static size_bin: number;
|
|
190
219
|
constructor(native: CryptoKey & {
|
|
191
220
|
type: 'public';
|
|
192
221
|
});
|
|
193
|
-
static from(serial: string | Uint8Array): Promise<$mol_crypto_auditor_public>;
|
|
222
|
+
static from(serial: string | Uint8Array<ArrayBuffer>): Promise<$mol_crypto_auditor_public>;
|
|
223
|
+
/** 86 bytes */
|
|
194
224
|
serial(): Promise<string>;
|
|
195
|
-
|
|
225
|
+
/** 64 bytes */
|
|
226
|
+
toArray(): Promise<Uint8Array<ArrayBuffer>>;
|
|
196
227
|
verify(data: BufferSource, sign: BufferSource): Promise<boolean>;
|
|
197
228
|
}
|
|
229
|
+
/** Asymmetric signing private key wrapper with shortest payload */
|
|
198
230
|
class $mol_crypto_auditor_private extends Object {
|
|
199
231
|
readonly native: CryptoKey & {
|
|
200
232
|
type: 'private';
|
|
201
233
|
};
|
|
234
|
+
/** Key size in bytes. */
|
|
202
235
|
static size_str: number;
|
|
203
236
|
static size_bin: number;
|
|
204
237
|
constructor(native: CryptoKey & {
|
|
205
238
|
type: 'private';
|
|
206
239
|
});
|
|
207
|
-
static from(serial: string | Uint8Array): Promise<$mol_crypto_auditor_private>;
|
|
240
|
+
static from(serial: string | Uint8Array<ArrayBuffer>): Promise<$mol_crypto_auditor_private>;
|
|
241
|
+
/** 129 bytes */
|
|
208
242
|
serial(): Promise<string>;
|
|
209
|
-
|
|
243
|
+
/** 96 bytes */
|
|
244
|
+
toArray(): Promise<Uint8Array<ArrayBuffer>>;
|
|
245
|
+
/** 64 bytes */
|
|
210
246
|
sign(data: BufferSource): Promise<ArrayBuffer>;
|
|
247
|
+
/** Makes public key from private */
|
|
211
248
|
public(): Promise<$mol_crypto_auditor_public>;
|
|
212
249
|
}
|
|
250
|
+
/** Sign size in bytes. */
|
|
213
251
|
const $mol_crypto_auditor_sign_size = 64;
|
|
214
252
|
function $mol_crypto_auditor_private_to_public(serial: string): string;
|
|
215
253
|
}
|
|
@@ -247,7 +285,7 @@ declare namespace $ {
|
|
|
247
285
|
function $mol_dev_format_native(obj: any): any[];
|
|
248
286
|
function $mol_dev_format_auto(obj: any): any[];
|
|
249
287
|
function $mol_dev_format_element(element: string, style: object, ...content: any[]): any[];
|
|
250
|
-
|
|
288
|
+
let $mol_dev_format_span: (style: object, ...content: any[]) => any[];
|
|
251
289
|
let $mol_dev_format_div: (style: object, ...content: any[]) => any[];
|
|
252
290
|
let $mol_dev_format_ol: (style: object, ...content: any[]) => any[];
|
|
253
291
|
let $mol_dev_format_li: (style: object, ...content: any[]) => any[];
|
|
@@ -266,32 +304,64 @@ declare namespace $ {
|
|
|
266
304
|
}
|
|
267
305
|
|
|
268
306
|
declare namespace $ {
|
|
269
|
-
function $mol_charset_decode(buffer:
|
|
307
|
+
function $mol_charset_decode(buffer: AllowSharedBufferSource, encoding?: $mol_charset_encoding): string;
|
|
270
308
|
}
|
|
271
309
|
|
|
272
310
|
declare namespace $ {
|
|
273
311
|
type $hyoo_crowd_unit_id = `${$mol_int62_string}!${$mol_int62_string}`;
|
|
274
312
|
enum $hyoo_crowd_unit_kind {
|
|
313
|
+
/** Grab Land by King */
|
|
275
314
|
grab = 0,
|
|
315
|
+
/** Join Peer to Land */
|
|
276
316
|
join = 1,
|
|
277
317
|
give = 2,
|
|
318
|
+
/** Add Data to Land by joined Peer with right Level */
|
|
278
319
|
data = 3
|
|
279
320
|
}
|
|
280
321
|
enum $hyoo_crowd_unit_group {
|
|
322
|
+
/** Join and Give units */
|
|
281
323
|
auth = 0,
|
|
324
|
+
/** Data units */
|
|
282
325
|
data = 1
|
|
283
326
|
}
|
|
327
|
+
/** Independent part of data. */
|
|
284
328
|
class $hyoo_crowd_unit extends Object {
|
|
329
|
+
/** Identifier of land. */
|
|
285
330
|
readonly land: $mol_int62_string;
|
|
331
|
+
/** Identifier of auth. */
|
|
286
332
|
readonly auth: $mol_int62_string;
|
|
333
|
+
/** Identifier of head node. */
|
|
287
334
|
readonly head: $mol_int62_string;
|
|
335
|
+
/** Self identifier inside head after prev before next. */
|
|
288
336
|
readonly self: $mol_int62_string;
|
|
337
|
+
/** Identifier of next node. */
|
|
289
338
|
readonly next: $mol_int62_string;
|
|
339
|
+
/** Identifier of prev node. */
|
|
290
340
|
readonly prev: $mol_int62_string;
|
|
341
|
+
/** Monotonic real clock. 4B / info = 31b */
|
|
291
342
|
readonly time: number;
|
|
343
|
+
/** type-size = bin<0 | null=0 | json>0 */
|
|
344
|
+
/** Associated atomic data. mem = 4B+ / bin = (0|8B)+ / type-size-info = 16b */
|
|
292
345
|
readonly data: unknown;
|
|
293
346
|
bin: $hyoo_crowd_unit_bin | null;
|
|
294
|
-
constructor(
|
|
347
|
+
constructor(
|
|
348
|
+
/** Identifier of land. */
|
|
349
|
+
land: $mol_int62_string,
|
|
350
|
+
/** Identifier of auth. */
|
|
351
|
+
auth: $mol_int62_string,
|
|
352
|
+
/** Identifier of head node. */
|
|
353
|
+
head: $mol_int62_string,
|
|
354
|
+
/** Self identifier inside head after prev before next. */
|
|
355
|
+
self: $mol_int62_string,
|
|
356
|
+
/** Identifier of next node. */
|
|
357
|
+
next: $mol_int62_string,
|
|
358
|
+
/** Identifier of prev node. */
|
|
359
|
+
prev: $mol_int62_string,
|
|
360
|
+
/** Monotonic real clock. 4B / info = 31b */
|
|
361
|
+
time: number,
|
|
362
|
+
/** type-size = bin<0 | null=0 | json>0 */
|
|
363
|
+
/** Associated atomic data. mem = 4B+ / bin = (0|8B)+ / type-size-info = 16b */
|
|
364
|
+
data: unknown, bin: $hyoo_crowd_unit_bin | null);
|
|
295
365
|
kind(): $hyoo_crowd_unit_kind;
|
|
296
366
|
group(): $hyoo_crowd_unit_group;
|
|
297
367
|
level(): $hyoo_crowd_peer_level;
|
|
@@ -310,55 +380,141 @@ declare namespace $ {
|
|
|
310
380
|
}
|
|
311
381
|
|
|
312
382
|
declare namespace $ {
|
|
383
|
+
/** Generates unique identifier. */
|
|
384
|
+
function $mol_guid(length?: number, exists?: (id: string) => boolean): string;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
declare namespace $ {
|
|
388
|
+
/** Special status statuses. */
|
|
313
389
|
enum $mol_wire_cursor {
|
|
390
|
+
/** Update required. */
|
|
314
391
|
stale = -1,
|
|
392
|
+
/** Some of (transitive) pub update required. */
|
|
315
393
|
doubt = -2,
|
|
394
|
+
/** Actual state but may be dropped. */
|
|
316
395
|
fresh = -3,
|
|
396
|
+
/** State will never be changed. */
|
|
317
397
|
final = -4
|
|
318
398
|
}
|
|
319
399
|
}
|
|
320
400
|
|
|
321
401
|
declare namespace $ {
|
|
402
|
+
/**
|
|
403
|
+
* Collects subscribers in compact array. 28B
|
|
404
|
+
*/
|
|
322
405
|
class $mol_wire_pub extends Object {
|
|
406
|
+
constructor(id?: string);
|
|
407
|
+
[Symbol.toStringTag]: string;
|
|
323
408
|
data: unknown[];
|
|
324
409
|
static get [Symbol.species](): ArrayConstructor;
|
|
410
|
+
/**
|
|
411
|
+
* Index of first subscriber.
|
|
412
|
+
*/
|
|
325
413
|
protected sub_from: number;
|
|
414
|
+
/**
|
|
415
|
+
* All current subscribers.
|
|
416
|
+
*/
|
|
326
417
|
get sub_list(): readonly $mol_wire_sub[];
|
|
418
|
+
/**
|
|
419
|
+
* Has any subscribers or not.
|
|
420
|
+
*/
|
|
327
421
|
get sub_empty(): boolean;
|
|
422
|
+
/**
|
|
423
|
+
* Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
|
|
424
|
+
*/
|
|
328
425
|
sub_on(sub: $mol_wire_pub, pub_pos: number): number;
|
|
426
|
+
/**
|
|
427
|
+
* Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
|
|
428
|
+
*/
|
|
329
429
|
sub_off(sub_pos: number): void;
|
|
430
|
+
/**
|
|
431
|
+
* Called when last sub was unsubscribed.
|
|
432
|
+
**/
|
|
330
433
|
reap(): void;
|
|
434
|
+
/**
|
|
435
|
+
* Autowire this publisher with current subscriber.
|
|
436
|
+
**/
|
|
331
437
|
promote(): void;
|
|
438
|
+
/**
|
|
439
|
+
* Enforce actualization. Should not throw errors.
|
|
440
|
+
*/
|
|
332
441
|
fresh(): void;
|
|
442
|
+
/**
|
|
443
|
+
* Allow to put data to caches in the subtree.
|
|
444
|
+
*/
|
|
333
445
|
complete(): void;
|
|
334
446
|
get incompleted(): boolean;
|
|
447
|
+
/**
|
|
448
|
+
* Notify subscribers about self changes.
|
|
449
|
+
*/
|
|
335
450
|
emit(quant?: $mol_wire_cursor): void;
|
|
451
|
+
/**
|
|
452
|
+
* Moves peer from one position to another. Doesn't clear data at old position!
|
|
453
|
+
*/
|
|
336
454
|
peer_move(from_pos: number, to_pos: number): void;
|
|
455
|
+
/**
|
|
456
|
+
* Updates self position in the peer.
|
|
457
|
+
*/
|
|
337
458
|
peer_repos(peer_pos: number, self_pos: number): void;
|
|
338
459
|
}
|
|
339
460
|
}
|
|
340
461
|
|
|
341
462
|
declare namespace $ {
|
|
463
|
+
/** Generic subscriber interface */
|
|
342
464
|
interface $mol_wire_sub extends $mol_wire_pub {
|
|
343
465
|
temp: boolean;
|
|
344
466
|
pub_list: $mol_wire_pub[];
|
|
467
|
+
/**
|
|
468
|
+
* Begin auto wire to publishers.
|
|
469
|
+
* Returns previous auto subscriber that must me transfer to the `end`.
|
|
470
|
+
*/
|
|
345
471
|
track_on(): $mol_wire_sub | null;
|
|
472
|
+
/**
|
|
473
|
+
* Returns next auto wired publisher. It can be easely repormoted.
|
|
474
|
+
* Or promotes next publisher to auto wire its togeter.
|
|
475
|
+
* Must be used only between `track_on` and `track_off`.
|
|
476
|
+
*/
|
|
346
477
|
track_next(pub?: $mol_wire_pub): $mol_wire_pub | null;
|
|
347
478
|
pub_off(pub_pos: number): void;
|
|
479
|
+
/**
|
|
480
|
+
* Unsubscribes from unpromoted publishers.
|
|
481
|
+
*/
|
|
348
482
|
track_cut(sub: $mol_wire_pub | null): void;
|
|
483
|
+
/**
|
|
484
|
+
* Ends auto wire to publishers.
|
|
485
|
+
*/
|
|
349
486
|
track_off(sub: $mol_wire_pub | null): void;
|
|
350
|
-
|
|
487
|
+
/**
|
|
488
|
+
* Receive notification about publisher changes.
|
|
489
|
+
*/
|
|
490
|
+
absorb(quant: $mol_wire_cursor, pos: number): void;
|
|
491
|
+
/**
|
|
492
|
+
* Unsubscribes from all publishers.
|
|
493
|
+
*/
|
|
351
494
|
destructor(): void;
|
|
352
495
|
}
|
|
353
496
|
}
|
|
354
497
|
|
|
355
498
|
declare namespace $ {
|
|
356
499
|
let $mol_wire_auto_sub: $mol_wire_sub | null;
|
|
500
|
+
/**
|
|
501
|
+
* When fulfilled, all publishers are promoted to this subscriber on access to its.
|
|
502
|
+
*/
|
|
357
503
|
function $mol_wire_auto(next?: $mol_wire_sub | null): $mol_wire_sub | null;
|
|
504
|
+
/**
|
|
505
|
+
* Affection queue. Used to prevent accidental stack overflow on emit.
|
|
506
|
+
*/
|
|
358
507
|
const $mol_wire_affected: ($mol_wire_sub | number)[];
|
|
359
508
|
}
|
|
360
509
|
|
|
361
510
|
declare namespace $ {
|
|
511
|
+
/**
|
|
512
|
+
* Publisher that can auto collect other publishers. 32B
|
|
513
|
+
*
|
|
514
|
+
* P1 P2 P3 P4 S1 S2 S3
|
|
515
|
+
* ^ ^
|
|
516
|
+
* pubs_from subs_from
|
|
517
|
+
*/
|
|
362
518
|
class $mol_wire_pub_sub extends $mol_wire_pub implements $mol_wire_sub {
|
|
363
519
|
protected pub_from: number;
|
|
364
520
|
protected cursor: $mol_wire_cursor;
|
|
@@ -373,8 +529,11 @@ declare namespace $ {
|
|
|
373
529
|
track_cut(): void;
|
|
374
530
|
complete(): void;
|
|
375
531
|
complete_pubs(): void;
|
|
376
|
-
absorb(quant?: $mol_wire_cursor): void;
|
|
532
|
+
absorb(quant?: $mol_wire_cursor, pos?: number): void;
|
|
377
533
|
[$mol_dev_format_head](): any[];
|
|
534
|
+
/**
|
|
535
|
+
* Is subscribed to any publisher or not.
|
|
536
|
+
*/
|
|
378
537
|
get pub_empty(): boolean;
|
|
379
538
|
}
|
|
380
539
|
}
|
|
@@ -394,6 +553,13 @@ declare namespace $ {
|
|
|
394
553
|
}
|
|
395
554
|
|
|
396
555
|
declare namespace $ {
|
|
556
|
+
/**
|
|
557
|
+
* Suspendable task with support both sync/async api.
|
|
558
|
+
*
|
|
559
|
+
* A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
|
|
560
|
+
* ^ ^ ^
|
|
561
|
+
* args_from pubs_from subs_from
|
|
562
|
+
**/
|
|
397
563
|
abstract class $mol_wire_fiber<Host, Args extends readonly unknown[], Result> extends $mol_wire_pub_sub {
|
|
398
564
|
readonly task: (this: Host, ...args: Args) => Result;
|
|
399
565
|
readonly host?: Host | undefined;
|
|
@@ -403,7 +569,6 @@ declare namespace $ {
|
|
|
403
569
|
static plan_task: $mol_after_tick | null;
|
|
404
570
|
static plan(): void;
|
|
405
571
|
static sync(): void;
|
|
406
|
-
[Symbol.toStringTag]: string;
|
|
407
572
|
cache: Result | Error | Promise<Result | Error>;
|
|
408
573
|
get args(): Args;
|
|
409
574
|
result(): Result | undefined;
|
|
@@ -415,12 +580,21 @@ declare namespace $ {
|
|
|
415
580
|
toString(): string;
|
|
416
581
|
toJSON(): string;
|
|
417
582
|
[$mol_dev_format_head](): any[];
|
|
583
|
+
[$mol_dev_format_body](): null;
|
|
418
584
|
get $(): any;
|
|
419
585
|
emit(quant?: $mol_wire_cursor): void;
|
|
420
586
|
fresh(): this | undefined;
|
|
421
587
|
refresh(): void;
|
|
422
588
|
abstract put(next: Result | Error | Promise<Result | Error>): Result | Error | Promise<Result | Error>;
|
|
589
|
+
/**
|
|
590
|
+
* Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
|
|
591
|
+
* Should be called inside SuspenseAPI consumer (ie fiber).
|
|
592
|
+
*/
|
|
423
593
|
sync(): Awaited<Result>;
|
|
594
|
+
/**
|
|
595
|
+
* Asynchronous execution.
|
|
596
|
+
* It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
|
|
597
|
+
*/
|
|
424
598
|
async_raw(): Promise<Result>;
|
|
425
599
|
async(): Promise<Result> & {
|
|
426
600
|
destructor(): void;
|
|
@@ -431,11 +605,7 @@ declare namespace $ {
|
|
|
431
605
|
}
|
|
432
606
|
|
|
433
607
|
declare namespace $ {
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
declare namespace $ {
|
|
438
|
-
const $mol_key_store: WeakMap<object, string>;
|
|
608
|
+
/** Returns string key for any value. */
|
|
439
609
|
function $mol_key<Value>(value: Value): string;
|
|
440
610
|
}
|
|
441
611
|
|
|
@@ -453,31 +623,52 @@ declare namespace $ {
|
|
|
453
623
|
|
|
454
624
|
declare namespace $ {
|
|
455
625
|
let $mol_compare_deep_cache: WeakMap<any, WeakMap<any, boolean>>;
|
|
626
|
+
/**
|
|
627
|
+
* Deeply compares two values. Returns true if equal.
|
|
628
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
629
|
+
*/
|
|
456
630
|
function $mol_compare_deep<Value>(left: Value, right: Value): boolean;
|
|
457
631
|
}
|
|
458
632
|
|
|
459
633
|
declare namespace $ {
|
|
634
|
+
/** Logger event data */
|
|
460
635
|
type $mol_log3_event<Fields> = {
|
|
461
636
|
[key in string]: unknown;
|
|
462
637
|
} & {
|
|
638
|
+
/** Time of event creation */
|
|
463
639
|
time?: string;
|
|
640
|
+
/** Place of event creation */
|
|
464
641
|
place: unknown;
|
|
642
|
+
/** Short description of event */
|
|
465
643
|
message: string;
|
|
466
644
|
} & Fields;
|
|
645
|
+
/** Logger function */
|
|
467
646
|
type $mol_log3_logger<Fields, Res = void> = (this: $, event: $mol_log3_event<Fields>) => Res;
|
|
647
|
+
/** Log begin of some task */
|
|
468
648
|
let $mol_log3_come: $mol_log3_logger<{}>;
|
|
649
|
+
/** Log end of some task */
|
|
469
650
|
let $mol_log3_done: $mol_log3_logger<{}>;
|
|
651
|
+
/** Log error */
|
|
470
652
|
let $mol_log3_fail: $mol_log3_logger<{}>;
|
|
653
|
+
/** Log warning message */
|
|
471
654
|
let $mol_log3_warn: $mol_log3_logger<{
|
|
472
655
|
hint: string;
|
|
473
656
|
}>;
|
|
657
|
+
/** Log some generic event */
|
|
474
658
|
let $mol_log3_rise: $mol_log3_logger<{}>;
|
|
659
|
+
/** Log begin of log group, returns func to close group */
|
|
475
660
|
let $mol_log3_area: $mol_log3_logger<{}, () => void>;
|
|
661
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
476
662
|
function $mol_log3_area_lazy(this: $, event: $mol_log3_event<{}>): () => void;
|
|
477
663
|
let $mol_log3_stack: (() => void)[];
|
|
478
664
|
}
|
|
479
665
|
|
|
480
666
|
declare namespace $ {
|
|
667
|
+
/**
|
|
668
|
+
* Extracts keys from `Input` which values extends `Upper` and extendable by `Lower`.
|
|
669
|
+
*
|
|
670
|
+
* type MathConstants = $mol_type_keys_extract< Math , number > // "E" | "PI" ...
|
|
671
|
+
*/
|
|
481
672
|
type $mol_type_keys_extract<Input, Upper, Lower = never> = {
|
|
482
673
|
[Field in keyof Input]: unknown extends Input[Field] ? never : Input[Field] extends never ? never : Input[Field] extends Upper ? [
|
|
483
674
|
Lower
|
|
@@ -490,15 +681,20 @@ declare namespace $ {
|
|
|
490
681
|
}
|
|
491
682
|
|
|
492
683
|
declare namespace $ {
|
|
684
|
+
/** One-shot fiber */
|
|
493
685
|
class $mol_wire_task<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
|
|
494
686
|
static getter<Host, Args extends readonly unknown[], Result>(task: (this: Host, ...args: Args) => Result): (host: Host, args: Args) => $mol_wire_task<Host, Args, Result>;
|
|
495
687
|
get temp(): boolean;
|
|
496
688
|
complete(): void;
|
|
497
689
|
put(next: Result | Error | Promise<Result | Error>): Error | Result | Promise<Error | Result>;
|
|
690
|
+
destructor(): void;
|
|
498
691
|
}
|
|
499
692
|
}
|
|
500
693
|
|
|
501
694
|
declare namespace $ {
|
|
695
|
+
/**
|
|
696
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber.
|
|
697
|
+
*/
|
|
502
698
|
function $mol_wire_method<Host extends object, Args extends readonly any[]>(host: Host, field: PropertyKey, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
|
|
503
699
|
value: (this: Host, ...args: Args) => any;
|
|
504
700
|
enumerable?: boolean;
|
|
@@ -510,10 +706,20 @@ declare namespace $ {
|
|
|
510
706
|
}
|
|
511
707
|
|
|
512
708
|
declare namespace $ {
|
|
709
|
+
/**
|
|
710
|
+
* Returns `Tuple` without first element.
|
|
711
|
+
*
|
|
712
|
+
* $mol_type_tail<[ 1 , 2 , 3 ]> // [ 2, 3 ]
|
|
713
|
+
*/
|
|
513
714
|
type $mol_type_tail<Tuple extends readonly any[]> = ((...tail: Tuple) => any) extends ((head: any, ...tail: infer Tail) => any) ? Tail : never;
|
|
514
715
|
}
|
|
515
716
|
|
|
516
717
|
declare namespace $ {
|
|
718
|
+
/**
|
|
719
|
+
* Returns last element of `Tuple`.
|
|
720
|
+
*
|
|
721
|
+
* $mol_type_tail<[ 1 , 2 , 3 ]> // 3
|
|
722
|
+
*/
|
|
517
723
|
type $mol_type_foot<Tuple extends readonly any[]> = Tuple['length'] extends 0 ? never : Tuple[$mol_type_tail<Tuple>['length']];
|
|
518
724
|
}
|
|
519
725
|
|
|
@@ -521,11 +727,20 @@ declare namespace $ {
|
|
|
521
727
|
function $mol_fail_catch(error: unknown): boolean;
|
|
522
728
|
}
|
|
523
729
|
|
|
730
|
+
declare namespace $ {
|
|
731
|
+
function $mol_try<Result>(handler: () => Result): Result | Error;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
declare namespace $ {
|
|
735
|
+
function $mol_try_web<Result>(handler2: () => Result): Result | Error;
|
|
736
|
+
}
|
|
737
|
+
|
|
524
738
|
declare namespace $ {
|
|
525
739
|
function $mol_fail_log(error: unknown): boolean;
|
|
526
740
|
}
|
|
527
741
|
|
|
528
742
|
declare namespace $ {
|
|
743
|
+
/** Long-living fiber. */
|
|
529
744
|
class $mol_wire_atom<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
|
|
530
745
|
static solo<Host, Args extends readonly unknown[], Result>(host: Host, task: (this: Host, ...args: Args) => Result): $mol_wire_atom<Host, Args, Result>;
|
|
531
746
|
static plex<Host, Args extends readonly unknown[], Result>(host: Host, task: (this: Host, ...args: Args) => Result, key: Args[0]): $mol_wire_atom<Host, Args, Result>;
|
|
@@ -533,6 +748,9 @@ declare namespace $ {
|
|
|
533
748
|
static watcher: $mol_after_frame | null;
|
|
534
749
|
static watch(): void;
|
|
535
750
|
watch(): void;
|
|
751
|
+
/**
|
|
752
|
+
* Update atom value through another temp fiber.
|
|
753
|
+
*/
|
|
536
754
|
resync(args: Args): Error | Result | Promise<Error | Result>;
|
|
537
755
|
once(): Awaited<Result>;
|
|
538
756
|
channel(): ((next?: $mol_type_foot<Args>) => Awaited<Result>) & {
|
|
@@ -544,12 +762,14 @@ declare namespace $ {
|
|
|
544
762
|
}
|
|
545
763
|
|
|
546
764
|
declare namespace $ {
|
|
765
|
+
/** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
|
|
547
766
|
export function $mol_wire_solo<Args extends any[]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): TypedPropertyDescriptor<(...args: First_optional<Args>) => any>;
|
|
548
767
|
type First_optional<Args extends any[]> = Args extends [] ? [] : [Args[0] | undefined, ...$mol_type_tail<Args>];
|
|
549
768
|
export {};
|
|
550
769
|
}
|
|
551
770
|
|
|
552
771
|
declare namespace $ {
|
|
772
|
+
/** Reactive memoizing multiplexed property decorator. */
|
|
553
773
|
function $mol_wire_plex<Args extends [any, ...any[]]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
|
|
554
774
|
value: (this: typeof host, ...args: Args) => any;
|
|
555
775
|
enumerable?: boolean;
|
|
@@ -561,11 +781,33 @@ declare namespace $ {
|
|
|
561
781
|
}
|
|
562
782
|
|
|
563
783
|
declare namespace $ {
|
|
784
|
+
/**
|
|
785
|
+
* Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
|
|
786
|
+
* @example
|
|
787
|
+
* '@' $mol_mem
|
|
788
|
+
* name(next?: string) {
|
|
789
|
+
* return next ?? 'default'
|
|
790
|
+
* }
|
|
791
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
792
|
+
*/
|
|
564
793
|
let $mol_mem: typeof $mol_wire_solo;
|
|
794
|
+
/**
|
|
795
|
+
* Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
|
|
796
|
+
* @example
|
|
797
|
+
* '@' $mol_mem_key
|
|
798
|
+
* name(id: number, next?: string) {
|
|
799
|
+
* return next ?? 'default'
|
|
800
|
+
* }
|
|
801
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
802
|
+
*/
|
|
565
803
|
let $mol_mem_key: typeof $mol_wire_plex;
|
|
566
804
|
}
|
|
567
805
|
|
|
568
806
|
declare namespace $ {
|
|
807
|
+
/**
|
|
808
|
+
* Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
|
|
809
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
810
|
+
*/
|
|
569
811
|
export function $mol_wire_sync<Host extends object>(obj: Host): ObjectOrFunctionResultAwaited<Host>;
|
|
570
812
|
type FunctionResultAwaited<Some> = Some extends (...args: infer Args) => infer Res ? (...args: Args) => Awaited<Res> : Some;
|
|
571
813
|
type ConstructorResultAwaited<Some> = Some extends new (...args: infer Args) => infer Res ? new (...args: Args) => Res : {};
|
|
@@ -581,6 +823,11 @@ declare namespace $ {
|
|
|
581
823
|
}
|
|
582
824
|
|
|
583
825
|
declare namespace $ {
|
|
826
|
+
/**
|
|
827
|
+
* Recursive `Partial`.
|
|
828
|
+
*
|
|
829
|
+
* let props : $mol_type_partial_deep< HTMLElement > = { style : { display : 'block' } }
|
|
830
|
+
*/
|
|
584
831
|
type $mol_type_partial_deep<Val> = Val extends object ? Val extends Function ? Val : {
|
|
585
832
|
[field in keyof Val]?: $mol_type_partial_deep<Val[field]> | undefined;
|
|
586
833
|
} : Val;
|
|
@@ -592,6 +839,12 @@ declare namespace $ {
|
|
|
592
839
|
let $mol_jsx_booked: null | Set<string>;
|
|
593
840
|
let $mol_jsx_document: $mol_jsx.JSX.ElementClass['ownerDocument'];
|
|
594
841
|
const $mol_jsx_frag = "";
|
|
842
|
+
/**
|
|
843
|
+
* JSX adapter that makes DOM tree.
|
|
844
|
+
* Generates global unique ids for every DOM-element by components tree with ids.
|
|
845
|
+
* Ensures all local ids are unique.
|
|
846
|
+
* Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
|
|
847
|
+
*/
|
|
595
848
|
function $mol_jsx<Props extends $mol_jsx.JSX.IntrinsicAttributes, Children extends Array<Node | string>>(Elem: string | ((props: Props, ...children: Children) => Element), props: Props, ...childNodes: Children): Element | DocumentFragment;
|
|
596
849
|
namespace $mol_jsx.JSX {
|
|
597
850
|
interface Element extends HTMLElement {
|
|
@@ -606,9 +859,11 @@ declare namespace $ {
|
|
|
606
859
|
type OrString<Dict> = {
|
|
607
860
|
[key in keyof Dict]: Dict[key] | string;
|
|
608
861
|
};
|
|
862
|
+
/** Props for html elements */
|
|
609
863
|
type IntrinsicElements = {
|
|
610
864
|
[key in keyof ElementTagNameMap]?: $.$mol_type_partial_deep<OrString<Element & IntrinsicAttributes & ElementTagNameMap[key]>>;
|
|
611
865
|
};
|
|
866
|
+
/** Additional undeclared props */
|
|
612
867
|
interface IntrinsicAttributes {
|
|
613
868
|
id?: string;
|
|
614
869
|
xmlns?: string;
|
|
@@ -630,6 +885,32 @@ declare namespace $ {
|
|
|
630
885
|
}
|
|
631
886
|
|
|
632
887
|
declare namespace $ {
|
|
888
|
+
class $mol_storage extends $mol_object2 {
|
|
889
|
+
/** Is storage a long term. */
|
|
890
|
+
static persisted(next?: boolean): boolean;
|
|
891
|
+
/** Total storage quota in bytes. */
|
|
892
|
+
static total(): number;
|
|
893
|
+
/** Total storage usage in bytes. */
|
|
894
|
+
static used(): number;
|
|
895
|
+
/** Minimum available free space in bytes. */
|
|
896
|
+
static free(): number;
|
|
897
|
+
/** Fulfillness of storage. */
|
|
898
|
+
static portion(): number;
|
|
899
|
+
/**
|
|
900
|
+
* Fulfillness logarithmic level.
|
|
901
|
+
* `0` - empty
|
|
902
|
+
* `1` - half free
|
|
903
|
+
* `2` - quart free
|
|
904
|
+
* `Infinity` - fulfilled
|
|
905
|
+
*/
|
|
906
|
+
static level(): number;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
declare namespace $ {
|
|
911
|
+
/**
|
|
912
|
+
* Disable reaping of current subscriber
|
|
913
|
+
*/
|
|
633
914
|
function $mol_wire_solid(): void;
|
|
634
915
|
}
|
|
635
916
|
|
|
@@ -638,6 +919,7 @@ declare namespace $ {
|
|
|
638
919
|
}
|
|
639
920
|
|
|
640
921
|
declare namespace $ {
|
|
922
|
+
/** Run code without state changes */
|
|
641
923
|
function $mol_wire_probe<Value>(task: () => Value, def?: Value): Value | undefined;
|
|
642
924
|
}
|
|
643
925
|
|
|
@@ -646,10 +928,37 @@ declare namespace $ {
|
|
|
646
928
|
}
|
|
647
929
|
|
|
648
930
|
declare namespace $ {
|
|
649
|
-
|
|
931
|
+
function $mol_wait_user_async(this: $): Promise<unknown>;
|
|
932
|
+
function $mol_wait_user(this: $): unknown;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
declare namespace $ {
|
|
936
|
+
class $mol_after_timeout extends $mol_object2 {
|
|
937
|
+
delay: number;
|
|
938
|
+
task: () => void;
|
|
939
|
+
id: any;
|
|
940
|
+
constructor(delay: number, task: () => void);
|
|
941
|
+
destructor(): void;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
declare namespace $ {
|
|
946
|
+
/** State of time moment */
|
|
947
|
+
class $mol_state_time extends $mol_object {
|
|
948
|
+
static task(precision: number, reset?: null): $mol_after_timeout | $mol_after_frame;
|
|
949
|
+
static now(precision: number): number;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
declare namespace $ {
|
|
954
|
+
class $mol_storage_web extends $mol_storage {
|
|
650
955
|
static native(): StorageManager;
|
|
651
956
|
static persisted(next?: boolean, cache?: 'cache'): boolean;
|
|
652
957
|
static estimate(): StorageEstimate;
|
|
958
|
+
static total(): number;
|
|
959
|
+
static used(): number;
|
|
960
|
+
static free(): number;
|
|
961
|
+
static portion(): number;
|
|
653
962
|
static dir(): FileSystemDirectoryHandle;
|
|
654
963
|
}
|
|
655
964
|
}
|
|
@@ -672,6 +981,7 @@ declare namespace $ {
|
|
|
672
981
|
declare namespace $ {
|
|
673
982
|
}
|
|
674
983
|
|
|
984
|
+
/** @jsx $mol_jsx */
|
|
675
985
|
declare namespace $ {
|
|
676
986
|
function $hyoo_sync_peer(path: string, next?: string): Promise<$hyoo_crowd_peer>;
|
|
677
987
|
}
|
|
@@ -682,8 +992,8 @@ declare namespace $ {
|
|
|
682
992
|
static run<Result>(task: () => Result): Result;
|
|
683
993
|
static func<Args extends any[], Result, Host = void>(func: (this: Host, ...args: Args) => Result): (this: Host, ...args: Args) => Result;
|
|
684
994
|
static get class(): <Class extends new (...args: any[]) => any>(Class: Class) => Class;
|
|
685
|
-
static get method(): (obj: object, name: PropertyKey, descr
|
|
686
|
-
static get field(): <Host, Field extends keyof Host, Args extends any[], Result>(obj: Host, name: Field, descr
|
|
995
|
+
static get method(): (obj: object, name: PropertyKey, descr?: TypedPropertyDescriptor<any>) => TypedPropertyDescriptor<any>;
|
|
996
|
+
static get field(): <Host extends object, Field extends keyof Host, Args extends any[], Result>(obj: Host, name: Field, descr?: TypedPropertyDescriptor<Result>) => TypedPropertyDescriptor<Result>;
|
|
687
997
|
}
|
|
688
998
|
}
|
|
689
999
|
|
|
@@ -694,24 +1004,34 @@ declare namespace $ {
|
|
|
694
1004
|
}
|
|
695
1005
|
|
|
696
1006
|
declare namespace $ {
|
|
1007
|
+
/** Internal int31 representation of current time. */
|
|
697
1008
|
function $hyoo_crowd_time_now(): number;
|
|
1009
|
+
/** Returns unix timestamp for internal time representation. */
|
|
698
1010
|
function $hyoo_crowd_time_stamp(time: number): number;
|
|
699
1011
|
}
|
|
700
1012
|
|
|
701
1013
|
declare namespace $ {
|
|
1014
|
+
/** Vector clock. Stores real timestamps. */
|
|
702
1015
|
class $hyoo_crowd_clock extends Map<$mol_int62_string, number> {
|
|
703
1016
|
static begin: number;
|
|
1017
|
+
/** Maximum time for all peers. */
|
|
704
1018
|
last_time: number;
|
|
705
1019
|
constructor(entries?: Iterable<readonly [$mol_int62_string, number]>);
|
|
1020
|
+
/** Synchronize this clock with another. */
|
|
706
1021
|
sync(right: $hyoo_crowd_clock): void;
|
|
1022
|
+
/** Increase `last` to latest. */
|
|
707
1023
|
see_time(time: number): void;
|
|
1024
|
+
/** Add new `time` for `peer` and increase `last`. */
|
|
708
1025
|
see_peer(peer: $mol_int62_string, time: number): void;
|
|
709
1026
|
see_bin(bin: $hyoo_crowd_clock_bin, group: $hyoo_crowd_unit_group): void;
|
|
1027
|
+
/** Checks if time from future. */
|
|
710
1028
|
fresh(peer: $mol_int62_string, time: number): boolean;
|
|
1029
|
+
/** Checks if this clock from future of another. */
|
|
711
1030
|
ahead(clock: $hyoo_crowd_clock): boolean;
|
|
712
1031
|
time(peer: $mol_int62_string): number;
|
|
713
1032
|
now(): number;
|
|
714
1033
|
last_stamp(): number;
|
|
1034
|
+
/** Gererates new time for peer that greater then other seen. */
|
|
715
1035
|
tick(peer: $mol_int62_string): number;
|
|
716
1036
|
[$mol_dev_format_head](): any[];
|
|
717
1037
|
}
|
|
@@ -723,6 +1043,7 @@ declare namespace $ {
|
|
|
723
1043
|
}
|
|
724
1044
|
|
|
725
1045
|
declare namespace $ {
|
|
1046
|
+
/** Stateless non-unique adapter to CROWD Tree for given Head. */
|
|
726
1047
|
class $hyoo_crowd_node extends $mol_object2 {
|
|
727
1048
|
readonly land: $hyoo_crowd_land;
|
|
728
1049
|
readonly head: $mol_int62_string;
|
|
@@ -731,9 +1052,13 @@ declare namespace $ {
|
|
|
731
1052
|
static toJSON(): string;
|
|
732
1053
|
id(): `${string}_${string}`;
|
|
733
1054
|
world(): $hyoo_crowd_world | null;
|
|
1055
|
+
/** Returns another representation of this node. */
|
|
734
1056
|
as<Node extends typeof $hyoo_crowd_node>(Node: Node): InstanceType<Node>;
|
|
1057
|
+
/** Ordered inner alive Units. */
|
|
735
1058
|
units(): readonly $hyoo_crowd_unit[];
|
|
1059
|
+
/** Ordered inner alive Node. */
|
|
736
1060
|
nodes<Node extends typeof $hyoo_crowd_node>(Node: Node): InstanceType<Node>[];
|
|
1061
|
+
/** Returns true when node value is never changed. */
|
|
737
1062
|
virgin(): boolean;
|
|
738
1063
|
[Symbol.toPrimitive](): string;
|
|
739
1064
|
toJSON(): `${string}_${string}`;
|
|
@@ -743,9 +1068,13 @@ declare namespace $ {
|
|
|
743
1068
|
|
|
744
1069
|
declare namespace $ {
|
|
745
1070
|
class $hyoo_crowd_reg extends $hyoo_crowd_node {
|
|
1071
|
+
/** Atomic value. */
|
|
746
1072
|
value(next?: unknown): {} | null;
|
|
1073
|
+
/** Atomic string. */
|
|
747
1074
|
str(next?: string): string;
|
|
1075
|
+
/** Atomic number. */
|
|
748
1076
|
numb(next?: number): number;
|
|
1077
|
+
/** Atomic boolean. */
|
|
749
1078
|
bool(next?: boolean): boolean;
|
|
750
1079
|
yoke(law?: readonly ($mol_int62_string | "")[], mod?: readonly ($mol_int62_string | "")[], add?: readonly ($mol_int62_string | "")[]): $hyoo_crowd_land | null;
|
|
751
1080
|
}
|
|
@@ -753,12 +1082,18 @@ declare namespace $ {
|
|
|
753
1082
|
|
|
754
1083
|
declare namespace $ {
|
|
755
1084
|
class $hyoo_crowd_struct extends $hyoo_crowd_node {
|
|
1085
|
+
/** Returns inner node for key. */
|
|
756
1086
|
sub<Node extends typeof $hyoo_crowd_node>(key: string, Node: Node): InstanceType<Node>;
|
|
757
1087
|
yoke<Node extends typeof $hyoo_crowd_node>(key: string, Node: Node, law?: readonly ($mol_int62_string | "")[], mod?: readonly ($mol_int62_string | "")[], add?: readonly ($mol_int62_string | "")[]): InstanceType<Node> | null;
|
|
758
1088
|
}
|
|
759
1089
|
}
|
|
760
1090
|
|
|
761
1091
|
declare namespace $ {
|
|
1092
|
+
/**
|
|
1093
|
+
* Returns closure that returns constant value.
|
|
1094
|
+
* @example
|
|
1095
|
+
* const rnd = $mol_const( Math.random() )
|
|
1096
|
+
*/
|
|
762
1097
|
function $mol_const<Value>(value: Value): {
|
|
763
1098
|
(): Value;
|
|
764
1099
|
'()': Value;
|
|
@@ -766,6 +1101,7 @@ declare namespace $ {
|
|
|
766
1101
|
}
|
|
767
1102
|
|
|
768
1103
|
declare namespace $ {
|
|
1104
|
+
/** Conflict-free Reinterpretable Ordered Washed Data Tree */
|
|
769
1105
|
class $hyoo_crowd_land extends $mol_object {
|
|
770
1106
|
id(): `${string}_${string}`;
|
|
771
1107
|
toJSON(): `${string}_${string}`;
|
|
@@ -778,55 +1114,81 @@ declare namespace $ {
|
|
|
778
1114
|
get clocks_bin(): Uint8Array<ArrayBuffer>;
|
|
779
1115
|
readonly pub: $mol_wire_pub;
|
|
780
1116
|
readonly _clocks: readonly [$hyoo_crowd_clock, $hyoo_crowd_clock];
|
|
1117
|
+
/** unit by head + self */
|
|
781
1118
|
_unit_all: Map<`${string}_${string}!${string}_${string}`, $hyoo_crowd_unit>;
|
|
782
1119
|
unit(head: $mol_int62_string, self: $mol_int62_string): $hyoo_crowd_unit | undefined;
|
|
1120
|
+
/** units by head */
|
|
783
1121
|
_unit_lists: Map<`${string}_${string}`, ($hyoo_crowd_unit[] & {
|
|
784
1122
|
dirty: boolean;
|
|
785
1123
|
}) | undefined>;
|
|
1124
|
+
/** Units by Head without tombstones */
|
|
786
1125
|
_unit_alives: Map<`${string}_${string}`, $hyoo_crowd_unit[] | undefined>;
|
|
787
1126
|
size(): number;
|
|
1127
|
+
/** Returns list of all Units for Node. */
|
|
788
1128
|
unit_list(head: $mol_int62_string): $hyoo_crowd_unit[] & {
|
|
789
1129
|
dirty: boolean;
|
|
790
1130
|
};
|
|
1131
|
+
/** Returns list of alive Units for Node. */
|
|
791
1132
|
unit_alives(head: $mol_int62_string): readonly $hyoo_crowd_unit[];
|
|
1133
|
+
/** Node by id and type. */
|
|
792
1134
|
node<Node extends typeof $hyoo_crowd_node>(head: $mol_int62_string, Node: Node): InstanceType<Node>;
|
|
1135
|
+
/** Root Node. */
|
|
793
1136
|
chief: $hyoo_crowd_struct;
|
|
1137
|
+
/** Generates new identifier. */
|
|
794
1138
|
id_new(): $mol_int62_string;
|
|
1139
|
+
/** Makes independent clone with defined peer. */
|
|
795
1140
|
fork(auth: $hyoo_crowd_peer): $hyoo_crowd_land;
|
|
1141
|
+
/** Makes Delta bettween Clock and now. */
|
|
796
1142
|
delta(clocks?: readonly [$hyoo_crowd_clock, $hyoo_crowd_clock]): readonly $hyoo_crowd_unit[];
|
|
797
1143
|
resort(head: $mol_int62_string): $hyoo_crowd_unit[] & {
|
|
798
1144
|
dirty: boolean;
|
|
799
1145
|
};
|
|
1146
|
+
/** Applies Delta to current state. */
|
|
800
1147
|
apply(delta: readonly $hyoo_crowd_unit[]): this;
|
|
801
1148
|
_joined: boolean;
|
|
1149
|
+
/** Register public key of current peer **/
|
|
802
1150
|
join(): true | undefined;
|
|
1151
|
+
/** Unregister public key of current peer **/
|
|
803
1152
|
leave(): false | undefined;
|
|
804
1153
|
allowed_add(peer?: `${string}_${string}`): boolean;
|
|
805
1154
|
allowed_mod(peer?: `${string}_${string}`): boolean;
|
|
806
1155
|
allowed_law(peer?: `${string}_${string}`): boolean;
|
|
807
1156
|
level_base(next?: $hyoo_crowd_peer_level): void;
|
|
1157
|
+
/** Access level for peer. Use empty string for current peer. **/
|
|
808
1158
|
level(peer: $mol_int62_string | '', next?: $hyoo_crowd_peer_level): $hyoo_crowd_peer_level;
|
|
809
1159
|
grabbed(): boolean;
|
|
1160
|
+
/** All peers who have special rights to write o land. */
|
|
810
1161
|
peers(): Readonly<`${string}_${string}`[]>;
|
|
1162
|
+
/** All peers who joined to land except king. */
|
|
811
1163
|
residents(): Readonly<`${string}_${string}`[]>;
|
|
1164
|
+
/** All peers who have alive data inside land. */
|
|
812
1165
|
authors(): Set<`${string}_${string}`>;
|
|
813
1166
|
steal_rights(donor: $hyoo_crowd_land): void;
|
|
814
1167
|
first_stamp(): number | null;
|
|
815
1168
|
last_stamp(): number;
|
|
816
1169
|
selection(peer: $mol_int62_string): $hyoo_crowd_reg;
|
|
1170
|
+
/** Places data to tree. */
|
|
817
1171
|
put(head: $mol_int62_string, self: $mol_int62_string, prev: $mol_int62_string, data: unknown): $hyoo_crowd_unit;
|
|
1172
|
+
/** Marks unit as deleted and wipes its data. */
|
|
818
1173
|
wipe(unit: $hyoo_crowd_unit): $hyoo_crowd_unit;
|
|
1174
|
+
/** Moves Unit after another Prev inside some Head. */
|
|
819
1175
|
move(unit: $hyoo_crowd_unit, head: $mol_int62_string, prev: $mol_int62_string): void;
|
|
1176
|
+
/** Moves Unit at given Seat inside given Head. */
|
|
820
1177
|
insert(unit: $hyoo_crowd_unit, head: $mol_int62_string, seat: number): void;
|
|
821
1178
|
[$mol_dev_format_head](): any[];
|
|
822
1179
|
}
|
|
823
1180
|
}
|
|
824
1181
|
|
|
825
1182
|
declare namespace $ {
|
|
1183
|
+
/**
|
|
1184
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber from [mol_wire](../wire/README.md)
|
|
1185
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
1186
|
+
*/
|
|
826
1187
|
let $mol_action: typeof $mol_wire_method;
|
|
827
1188
|
}
|
|
828
1189
|
|
|
829
1190
|
declare namespace $ {
|
|
1191
|
+
/** Registry of nodes as domain entities. */
|
|
830
1192
|
class $hyoo_crowd_fund<Node extends typeof $hyoo_crowd_node> extends $mol_object {
|
|
831
1193
|
world: $hyoo_crowd_world;
|
|
832
1194
|
node_class: Node;
|
|
@@ -837,7 +1199,11 @@ declare namespace $ {
|
|
|
837
1199
|
}
|
|
838
1200
|
|
|
839
1201
|
declare namespace $ {
|
|
1202
|
+
/** @deprecated */
|
|
840
1203
|
let $mol_dict_key: typeof $mol_key;
|
|
1204
|
+
/**
|
|
1205
|
+
* Dictionary with extended keys support
|
|
1206
|
+
*/
|
|
841
1207
|
class $mol_dict<Key, Value> extends Map<Key, Value> {
|
|
842
1208
|
get(key: Key): Value | undefined;
|
|
843
1209
|
has(key: Key): boolean;
|
|
@@ -889,22 +1255,13 @@ declare namespace $ {
|
|
|
889
1255
|
}
|
|
890
1256
|
}
|
|
891
1257
|
|
|
892
|
-
declare namespace $ {
|
|
893
|
-
class $mol_after_timeout extends $mol_object2 {
|
|
894
|
-
delay: number;
|
|
895
|
-
task: () => void;
|
|
896
|
-
id: any;
|
|
897
|
-
constructor(delay: number, task: () => void);
|
|
898
|
-
destructor(): void;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
|
|
902
1258
|
declare namespace $ {
|
|
903
1259
|
function $mol_wait_timeout_async(this: $, timeout: number): Promise<void>;
|
|
904
1260
|
function $mol_wait_timeout(this: $, timeout: number): void;
|
|
905
1261
|
}
|
|
906
1262
|
|
|
907
1263
|
declare namespace $ {
|
|
1264
|
+
/** Starts subtasks concurrently instead of serial. */
|
|
908
1265
|
function $mol_wire_race<Tasks extends ((...args: any) => any)[]>(...tasks: Tasks): {
|
|
909
1266
|
[index in keyof Tasks]: ReturnType<Tasks[index]>;
|
|
910
1267
|
};
|
|
@@ -915,6 +1272,7 @@ declare namespace $ {
|
|
|
915
1272
|
}
|
|
916
1273
|
|
|
917
1274
|
declare namespace $ {
|
|
1275
|
+
/** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
|
|
918
1276
|
export function $mol_wire_async<Host extends object>(obj: Host): ObjectOrFunctionResultPromisify<Host>;
|
|
919
1277
|
type FunctionResultPromisify<Some> = Some extends (...args: infer Args) => infer Res ? Res extends PromiseLike<unknown> ? Some : (...args: Args) => Promise<Res> : Some;
|
|
920
1278
|
type MethodsResultPromisify<Host extends Object> = {
|
|
@@ -975,29 +1333,40 @@ declare namespace $ {
|
|
|
975
1333
|
}
|
|
976
1334
|
|
|
977
1335
|
declare namespace $ {
|
|
1336
|
+
/** Converts IDBResult to Promise */
|
|
978
1337
|
function $mol_db_response<Result>(request: IDBRequest<Result>): Promise<Result>;
|
|
979
1338
|
}
|
|
980
1339
|
|
|
981
1340
|
declare namespace $ {
|
|
1341
|
+
/** IndexedDB ObjectStore wrapper. */
|
|
982
1342
|
class $mol_db_store<Schema extends $mol_db_store_schema> {
|
|
983
1343
|
readonly native: IDBObjectStore;
|
|
984
1344
|
constructor(native: IDBObjectStore);
|
|
985
1345
|
get name(): string;
|
|
986
|
-
get path(): string | string[];
|
|
1346
|
+
get path(): string | string[] | null;
|
|
987
1347
|
get incremental(): boolean;
|
|
1348
|
+
/** Returns dictionary of all existen Indexes. */
|
|
988
1349
|
get indexes(): { [Name in keyof Schema["Indexes"]]: $mol_db_index<{
|
|
989
1350
|
Key: Schema["Indexes"][Name];
|
|
990
1351
|
Doc: Schema["Doc"];
|
|
991
1352
|
}>; };
|
|
1353
|
+
/** Creates new Index */
|
|
992
1354
|
index_make(name: string, path?: string[], unique?: boolean, multiEntry?: boolean): IDBIndex;
|
|
1355
|
+
/** Drops existen Index */
|
|
993
1356
|
index_drop(name: string): this;
|
|
994
1357
|
get transaction(): $mol_db_transaction<$mol_db_schema>;
|
|
995
1358
|
get db(): $mol_db_database<$mol_db_schema>;
|
|
1359
|
+
/** Deletes all stored Documents */
|
|
996
1360
|
clear(): Promise<undefined>;
|
|
1361
|
+
/** Counts Documents by primary key(s) */
|
|
997
1362
|
count(keys?: Schema['Key'] | IDBKeyRange): Promise<number>;
|
|
1363
|
+
/** Stores single Document by primary key. */
|
|
998
1364
|
put(doc: Schema['Doc'], key?: Schema['Key']): Promise<IDBValidKey>;
|
|
1365
|
+
/** Returns Document by primary key. */
|
|
999
1366
|
get(key: Schema['Key']): Promise<Schema["Doc"] | undefined>;
|
|
1367
|
+
/** Selects Documents by primary keys. */
|
|
1000
1368
|
select(key?: Schema['Key'] | IDBKeyRange | null, count?: number): Promise<Schema["Doc"][]>;
|
|
1369
|
+
/** Deletes Documents by primary key(s). */
|
|
1001
1370
|
drop(keys: Schema['Key'] | IDBKeyRange): Promise<undefined>;
|
|
1002
1371
|
}
|
|
1003
1372
|
}
|
|
@@ -1011,6 +1380,7 @@ declare namespace $ {
|
|
|
1011
1380
|
}
|
|
1012
1381
|
|
|
1013
1382
|
declare namespace $ {
|
|
1383
|
+
/** IndexedDB Index wrapper. */
|
|
1014
1384
|
class $mol_db_index<Schema extends $mol_db_index_schema> {
|
|
1015
1385
|
readonly native: IDBIndex;
|
|
1016
1386
|
constructor(native: IDBIndex);
|
|
@@ -1021,8 +1391,11 @@ declare namespace $ {
|
|
|
1021
1391
|
get store(): $mol_db_store<$mol_db_store_schema>;
|
|
1022
1392
|
get transaction(): $mol_db_transaction<$mol_db_schema>;
|
|
1023
1393
|
get db(): $mol_db_database<$mol_db_schema>;
|
|
1394
|
+
/** Counts Documents by key(s) */
|
|
1024
1395
|
count(keys?: Schema['Key'] | IDBKeyRange): Promise<number>;
|
|
1396
|
+
/** Returns Document by primary key. */
|
|
1025
1397
|
get(key: Schema['Key']): Promise<Schema["Doc"] | undefined>;
|
|
1398
|
+
/** Selects Documents by primary keys. */
|
|
1026
1399
|
select(key?: Schema['Key'] | IDBKeyRange | null, count?: number): Promise<Schema["Doc"][]>;
|
|
1027
1400
|
}
|
|
1028
1401
|
}
|
|
@@ -1035,6 +1408,14 @@ declare namespace $ {
|
|
|
1035
1408
|
}
|
|
1036
1409
|
|
|
1037
1410
|
declare namespace $ {
|
|
1411
|
+
/**
|
|
1412
|
+
* Creates new or returns existen database with automatic schema migration.
|
|
1413
|
+
* Schema version is based on migrations count.
|
|
1414
|
+
* Migrations code mustn't be changed after deploy.
|
|
1415
|
+
* Only adding migrations at the end is allowed.
|
|
1416
|
+
* Only new migrations will be applyed to existen DB.
|
|
1417
|
+
* Schema changes allowed only through migratios.
|
|
1418
|
+
*/
|
|
1038
1419
|
function $mol_db<Schema extends $mol_db_schema>(this: $, name: string, ...migrations: ((transaction: $mol_db_transaction<$mol_db_schema>) => void)[]): Promise<$mol_db_database<Schema>>;
|
|
1039
1420
|
}
|
|
1040
1421
|
|
|
@@ -1043,15 +1424,29 @@ declare namespace $ {
|
|
|
1043
1424
|
}
|
|
1044
1425
|
|
|
1045
1426
|
declare namespace $ {
|
|
1427
|
+
/** IndexedDB instance wrapper. */
|
|
1046
1428
|
class $mol_db_database<Schema extends $mol_db_schema> {
|
|
1047
1429
|
readonly native: IDBDatabase;
|
|
1048
1430
|
constructor(native: IDBDatabase);
|
|
1431
|
+
/** Returns database name. */
|
|
1049
1432
|
get name(): string;
|
|
1433
|
+
/** Returns database schema version. */
|
|
1050
1434
|
get version(): number;
|
|
1435
|
+
/** Returns all stores names. */
|
|
1051
1436
|
get stores(): (keyof Schema)[];
|
|
1052
|
-
|
|
1437
|
+
/** Create read-only transaction. */
|
|
1438
|
+
read<Names extends Exclude<keyof Schema, symbol | number>>(...names: Names[]): Pick<Schema, Names> extends infer T extends $mol_db_schema ? { [Name in keyof T]: $mol_db_store<T[Name]>; } : never;
|
|
1439
|
+
/** Create read/write transaction. */
|
|
1053
1440
|
change<Names extends Exclude<keyof Schema, symbol | number>>(...names: Names[]): $mol_db_transaction<Pick<Schema, Names>>;
|
|
1441
|
+
/**
|
|
1442
|
+
* Deletes database.
|
|
1443
|
+
* DB can be deleted only after end of all transactions.
|
|
1444
|
+
*/
|
|
1054
1445
|
kill(): Promise<IDBDatabase>;
|
|
1446
|
+
/**
|
|
1447
|
+
* Closes DB connection.
|
|
1448
|
+
* Connection really be closed only after end of all transactions.
|
|
1449
|
+
*/
|
|
1055
1450
|
destructor(): void;
|
|
1056
1451
|
}
|
|
1057
1452
|
}
|
|
@@ -1060,13 +1455,19 @@ interface IDBTransaction {
|
|
|
1060
1455
|
commit(): void;
|
|
1061
1456
|
}
|
|
1062
1457
|
declare namespace $ {
|
|
1458
|
+
/** IndexedDB Transaction wrapper. */
|
|
1063
1459
|
class $mol_db_transaction<Schema extends $mol_db_schema> {
|
|
1064
1460
|
readonly native: IDBTransaction;
|
|
1065
1461
|
constructor(native: IDBTransaction);
|
|
1462
|
+
/** Returns dictionary of all existen Stores. */
|
|
1066
1463
|
get stores(): { [Name in keyof Schema]: $mol_db_store<Schema[Name]>; };
|
|
1464
|
+
/** Creates new Store */
|
|
1067
1465
|
store_make(name: string): IDBObjectStore;
|
|
1466
|
+
/** Drops existen Store */
|
|
1068
1467
|
store_drop(name: string): this;
|
|
1468
|
+
/** Instant abort transaction. Any errors aborts transactions automatically. */
|
|
1069
1469
|
abort(): void;
|
|
1470
|
+
/** Instant commits transaction. Without errors commit proceed automatically later. */
|
|
1070
1471
|
commit(): Promise<void>;
|
|
1071
1472
|
get db(): $mol_db_database<$mol_db_schema>;
|
|
1072
1473
|
}
|