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/node.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,29 +79,57 @@ 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
90
|
declare namespace $ {
|
|
79
|
-
|
|
91
|
+
/** Temporary buffer. Recursive usage isn't supported. */
|
|
92
|
+
function $mol_charset_buffer(size: number): Uint8Array<ArrayBuffer>;
|
|
80
93
|
}
|
|
81
94
|
|
|
82
95
|
declare namespace $ {
|
|
83
|
-
function $
|
|
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;
|
|
84
99
|
}
|
|
85
100
|
|
|
86
101
|
declare namespace $ {
|
|
87
|
-
|
|
102
|
+
type $mol_int62_string = `${string}_${string}`;
|
|
103
|
+
function $mol_int62_string_ensure(str: unknown): `${string}_${string}` | null;
|
|
104
|
+
type $mol_int62_pair = {
|
|
105
|
+
readonly lo: number;
|
|
106
|
+
readonly hi: number;
|
|
107
|
+
};
|
|
108
|
+
const $mol_int62_max: number;
|
|
109
|
+
const $mol_int62_min: number;
|
|
110
|
+
const $mol_int62_range: number;
|
|
111
|
+
function $mol_int62_to_string({ lo, hi }: $mol_int62_pair): $mol_int62_string;
|
|
112
|
+
function $mol_int62_from_string(str: string): null | $mol_int62_pair;
|
|
113
|
+
function $mol_int62_compare(left_lo: number, left_hi: number, right_lo: number, right_hi: number): number;
|
|
114
|
+
function $mol_int62_inc(lo: number, hi: number, max?: number): $mol_int62_pair;
|
|
115
|
+
function $mol_int62_random(): $mol_int62_pair;
|
|
116
|
+
function $mol_int62_hash_string(str: string): `${string}_${string}`;
|
|
117
|
+
function $mol_int62_hash_buffer(buf: Uint8Array, seed?: {
|
|
118
|
+
lo: number;
|
|
119
|
+
hi: number;
|
|
120
|
+
}): $mol_int62_pair;
|
|
88
121
|
}
|
|
89
122
|
|
|
90
|
-
|
|
91
|
-
|
|
123
|
+
declare namespace $ {
|
|
124
|
+
type $mol_data_value<Input = any, Output = any> = (val: Input) => Output;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare namespace $ {
|
|
128
|
+
function $mol_data_setup<Value extends $mol_data_value, Config = never>(value: Value, config: Config): Value & {
|
|
129
|
+
config: Config;
|
|
130
|
+
Value: ReturnType<Value>;
|
|
131
|
+
};
|
|
92
132
|
}
|
|
93
|
-
declare var $node: $node;
|
|
94
|
-
declare const cache: Map<string, any>;
|
|
95
133
|
|
|
96
134
|
declare namespace $ {
|
|
97
135
|
class $mol_error_mix<Cause extends {} = {}> extends AggregateError {
|
|
@@ -104,6 +142,54 @@ declare namespace $ {
|
|
|
104
142
|
}
|
|
105
143
|
}
|
|
106
144
|
|
|
145
|
+
declare namespace $ {
|
|
146
|
+
class $mol_data_error extends $mol_error_mix {
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
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
|
+
*/
|
|
155
|
+
function $mol_data_enum<Dict extends Record<number | string, number | string>>(name: string, dict: Dict): ((value: Dict[keyof Dict]) => Dict[keyof Dict]) & {
|
|
156
|
+
config: {
|
|
157
|
+
name: string;
|
|
158
|
+
dict: Dict;
|
|
159
|
+
};
|
|
160
|
+
Value: Dict[keyof Dict];
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
declare namespace $ {
|
|
165
|
+
function $node_internal_check(name: string): boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
declare namespace $ {
|
|
169
|
+
function $mol_promise_like(val: any): val is Promise<any>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
declare namespace $ {
|
|
173
|
+
function $mol_fail_catch(error: unknown): boolean;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare namespace $ {
|
|
177
|
+
function $mol_try<Result>(handler: () => Result): Result | Error;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare namespace $ {
|
|
181
|
+
function $mol_fail_log(error: unknown): boolean;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
declare namespace $ {
|
|
185
|
+
function $node_autoinstall(this: typeof $, name: string): void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface $node {
|
|
189
|
+
[key: string]: any;
|
|
190
|
+
}
|
|
191
|
+
declare var $node: $node;
|
|
192
|
+
|
|
107
193
|
declare namespace $ {
|
|
108
194
|
namespace $$ { }
|
|
109
195
|
const $mol_object_field: unique symbol;
|
|
@@ -120,51 +206,130 @@ declare namespace $ {
|
|
|
120
206
|
}
|
|
121
207
|
|
|
122
208
|
declare namespace $ {
|
|
209
|
+
/** Generates unique identifier. */
|
|
210
|
+
function $mol_guid(length?: number, exists?: (id: string) => boolean): string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare namespace $ {
|
|
214
|
+
/** Special status statuses. */
|
|
123
215
|
enum $mol_wire_cursor {
|
|
216
|
+
/** Update required. */
|
|
124
217
|
stale = -1,
|
|
218
|
+
/** Some of (transitive) pub update required. */
|
|
125
219
|
doubt = -2,
|
|
220
|
+
/** Actual state but may be dropped. */
|
|
126
221
|
fresh = -3,
|
|
222
|
+
/** State will never be changed. */
|
|
127
223
|
final = -4
|
|
128
224
|
}
|
|
129
225
|
}
|
|
130
226
|
|
|
131
227
|
declare namespace $ {
|
|
228
|
+
/**
|
|
229
|
+
* Collects subscribers in compact array. 28B
|
|
230
|
+
*/
|
|
132
231
|
class $mol_wire_pub extends Object {
|
|
232
|
+
constructor(id?: string);
|
|
233
|
+
[Symbol.toStringTag]: string;
|
|
133
234
|
data: unknown[];
|
|
134
235
|
static get [Symbol.species](): ArrayConstructor;
|
|
236
|
+
/**
|
|
237
|
+
* Index of first subscriber.
|
|
238
|
+
*/
|
|
135
239
|
protected sub_from: number;
|
|
240
|
+
/**
|
|
241
|
+
* All current subscribers.
|
|
242
|
+
*/
|
|
136
243
|
get sub_list(): readonly $mol_wire_sub[];
|
|
244
|
+
/**
|
|
245
|
+
* Has any subscribers or not.
|
|
246
|
+
*/
|
|
137
247
|
get sub_empty(): boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
|
|
250
|
+
*/
|
|
138
251
|
sub_on(sub: $mol_wire_pub, pub_pos: number): number;
|
|
252
|
+
/**
|
|
253
|
+
* Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
|
|
254
|
+
*/
|
|
139
255
|
sub_off(sub_pos: number): void;
|
|
256
|
+
/**
|
|
257
|
+
* Called when last sub was unsubscribed.
|
|
258
|
+
**/
|
|
140
259
|
reap(): void;
|
|
260
|
+
/**
|
|
261
|
+
* Autowire this publisher with current subscriber.
|
|
262
|
+
**/
|
|
141
263
|
promote(): void;
|
|
264
|
+
/**
|
|
265
|
+
* Enforce actualization. Should not throw errors.
|
|
266
|
+
*/
|
|
142
267
|
fresh(): void;
|
|
268
|
+
/**
|
|
269
|
+
* Allow to put data to caches in the subtree.
|
|
270
|
+
*/
|
|
143
271
|
complete(): void;
|
|
144
272
|
get incompleted(): boolean;
|
|
273
|
+
/**
|
|
274
|
+
* Notify subscribers about self changes.
|
|
275
|
+
*/
|
|
145
276
|
emit(quant?: $mol_wire_cursor): void;
|
|
277
|
+
/**
|
|
278
|
+
* Moves peer from one position to another. Doesn't clear data at old position!
|
|
279
|
+
*/
|
|
146
280
|
peer_move(from_pos: number, to_pos: number): void;
|
|
281
|
+
/**
|
|
282
|
+
* Updates self position in the peer.
|
|
283
|
+
*/
|
|
147
284
|
peer_repos(peer_pos: number, self_pos: number): void;
|
|
148
285
|
}
|
|
149
286
|
}
|
|
150
287
|
|
|
151
288
|
declare namespace $ {
|
|
289
|
+
/** Generic subscriber interface */
|
|
152
290
|
interface $mol_wire_sub extends $mol_wire_pub {
|
|
153
291
|
temp: boolean;
|
|
154
292
|
pub_list: $mol_wire_pub[];
|
|
293
|
+
/**
|
|
294
|
+
* Begin auto wire to publishers.
|
|
295
|
+
* Returns previous auto subscriber that must me transfer to the `end`.
|
|
296
|
+
*/
|
|
155
297
|
track_on(): $mol_wire_sub | null;
|
|
298
|
+
/**
|
|
299
|
+
* Returns next auto wired publisher. It can be easely repormoted.
|
|
300
|
+
* Or promotes next publisher to auto wire its togeter.
|
|
301
|
+
* Must be used only between `track_on` and `track_off`.
|
|
302
|
+
*/
|
|
156
303
|
track_next(pub?: $mol_wire_pub): $mol_wire_pub | null;
|
|
157
304
|
pub_off(pub_pos: number): void;
|
|
305
|
+
/**
|
|
306
|
+
* Unsubscribes from unpromoted publishers.
|
|
307
|
+
*/
|
|
158
308
|
track_cut(sub: $mol_wire_pub | null): void;
|
|
309
|
+
/**
|
|
310
|
+
* Ends auto wire to publishers.
|
|
311
|
+
*/
|
|
159
312
|
track_off(sub: $mol_wire_pub | null): void;
|
|
160
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Receive notification about publisher changes.
|
|
315
|
+
*/
|
|
316
|
+
absorb(quant: $mol_wire_cursor, pos: number): void;
|
|
317
|
+
/**
|
|
318
|
+
* Unsubscribes from all publishers.
|
|
319
|
+
*/
|
|
161
320
|
destructor(): void;
|
|
162
321
|
}
|
|
163
322
|
}
|
|
164
323
|
|
|
165
324
|
declare namespace $ {
|
|
166
325
|
let $mol_wire_auto_sub: $mol_wire_sub | null;
|
|
326
|
+
/**
|
|
327
|
+
* When fulfilled, all publishers are promoted to this subscriber on access to its.
|
|
328
|
+
*/
|
|
167
329
|
function $mol_wire_auto(next?: $mol_wire_sub | null): $mol_wire_sub | null;
|
|
330
|
+
/**
|
|
331
|
+
* Affection queue. Used to prevent accidental stack overflow on emit.
|
|
332
|
+
*/
|
|
168
333
|
const $mol_wire_affected: ($mol_wire_sub | number)[];
|
|
169
334
|
}
|
|
170
335
|
|
|
@@ -182,7 +347,7 @@ declare namespace $ {
|
|
|
182
347
|
function $mol_dev_format_native(obj: any): any[];
|
|
183
348
|
function $mol_dev_format_auto(obj: any): any[];
|
|
184
349
|
function $mol_dev_format_element(element: string, style: object, ...content: any[]): any[];
|
|
185
|
-
|
|
350
|
+
let $mol_dev_format_span: (style: object, ...content: any[]) => any[];
|
|
186
351
|
let $mol_dev_format_div: (style: object, ...content: any[]) => any[];
|
|
187
352
|
let $mol_dev_format_ol: (style: object, ...content: any[]) => any[];
|
|
188
353
|
let $mol_dev_format_li: (style: object, ...content: any[]) => any[];
|
|
@@ -197,6 +362,13 @@ declare namespace $ {
|
|
|
197
362
|
}
|
|
198
363
|
|
|
199
364
|
declare namespace $ {
|
|
365
|
+
/**
|
|
366
|
+
* Publisher that can auto collect other publishers. 32B
|
|
367
|
+
*
|
|
368
|
+
* P1 P2 P3 P4 S1 S2 S3
|
|
369
|
+
* ^ ^
|
|
370
|
+
* pubs_from subs_from
|
|
371
|
+
*/
|
|
200
372
|
class $mol_wire_pub_sub extends $mol_wire_pub implements $mol_wire_sub {
|
|
201
373
|
protected pub_from: number;
|
|
202
374
|
protected cursor: $mol_wire_cursor;
|
|
@@ -211,8 +383,11 @@ declare namespace $ {
|
|
|
211
383
|
track_cut(): void;
|
|
212
384
|
complete(): void;
|
|
213
385
|
complete_pubs(): void;
|
|
214
|
-
absorb(quant?: $mol_wire_cursor): void;
|
|
386
|
+
absorb(quant?: $mol_wire_cursor, pos?: number): void;
|
|
215
387
|
[$mol_dev_format_head](): any[];
|
|
388
|
+
/**
|
|
389
|
+
* Is subscribed to any publisher or not.
|
|
390
|
+
*/
|
|
216
391
|
get pub_empty(): boolean;
|
|
217
392
|
}
|
|
218
393
|
}
|
|
@@ -228,6 +403,13 @@ declare namespace $ {
|
|
|
228
403
|
}
|
|
229
404
|
|
|
230
405
|
declare namespace $ {
|
|
406
|
+
/**
|
|
407
|
+
* Suspendable task with support both sync/async api.
|
|
408
|
+
*
|
|
409
|
+
* A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
|
|
410
|
+
* ^ ^ ^
|
|
411
|
+
* args_from pubs_from subs_from
|
|
412
|
+
**/
|
|
231
413
|
abstract class $mol_wire_fiber<Host, Args extends readonly unknown[], Result> extends $mol_wire_pub_sub {
|
|
232
414
|
readonly task: (this: Host, ...args: Args) => Result;
|
|
233
415
|
readonly host?: Host | undefined;
|
|
@@ -237,7 +419,6 @@ declare namespace $ {
|
|
|
237
419
|
static plan_task: $mol_after_tick | null;
|
|
238
420
|
static plan(): void;
|
|
239
421
|
static sync(): void;
|
|
240
|
-
[Symbol.toStringTag]: string;
|
|
241
422
|
cache: Result | Error | Promise<Result | Error>;
|
|
242
423
|
get args(): Args;
|
|
243
424
|
result(): Result | undefined;
|
|
@@ -249,12 +430,21 @@ declare namespace $ {
|
|
|
249
430
|
toString(): string;
|
|
250
431
|
toJSON(): string;
|
|
251
432
|
[$mol_dev_format_head](): any[];
|
|
433
|
+
[$mol_dev_format_body](): null;
|
|
252
434
|
get $(): any;
|
|
253
435
|
emit(quant?: $mol_wire_cursor): void;
|
|
254
436
|
fresh(): this | undefined;
|
|
255
437
|
refresh(): void;
|
|
256
438
|
abstract put(next: Result | Error | Promise<Result | Error>): Result | Error | Promise<Result | Error>;
|
|
439
|
+
/**
|
|
440
|
+
* Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
|
|
441
|
+
* Should be called inside SuspenseAPI consumer (ie fiber).
|
|
442
|
+
*/
|
|
257
443
|
sync(): Awaited<Result>;
|
|
444
|
+
/**
|
|
445
|
+
* Asynchronous execution.
|
|
446
|
+
* It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
|
|
447
|
+
*/
|
|
258
448
|
async_raw(): Promise<Result>;
|
|
259
449
|
async(): Promise<Result> & {
|
|
260
450
|
destructor(): void;
|
|
@@ -266,31 +456,48 @@ declare namespace $ {
|
|
|
266
456
|
|
|
267
457
|
declare namespace $ {
|
|
268
458
|
let $mol_compare_deep_cache: WeakMap<any, WeakMap<any, boolean>>;
|
|
459
|
+
/**
|
|
460
|
+
* Deeply compares two values. Returns true if equal.
|
|
461
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
462
|
+
*/
|
|
269
463
|
function $mol_compare_deep<Value>(left: Value, right: Value): boolean;
|
|
270
464
|
}
|
|
271
465
|
|
|
272
466
|
declare namespace $ {
|
|
467
|
+
/** Logger event data */
|
|
273
468
|
type $mol_log3_event<Fields> = {
|
|
274
469
|
[key in string]: unknown;
|
|
275
470
|
} & {
|
|
471
|
+
/** Time of event creation */
|
|
276
472
|
time?: string;
|
|
473
|
+
/** Place of event creation */
|
|
277
474
|
place: unknown;
|
|
475
|
+
/** Short description of event */
|
|
278
476
|
message: string;
|
|
279
477
|
} & Fields;
|
|
478
|
+
/** Logger function */
|
|
280
479
|
type $mol_log3_logger<Fields, Res = void> = (this: $, event: $mol_log3_event<Fields>) => Res;
|
|
480
|
+
/** Log begin of some task */
|
|
281
481
|
let $mol_log3_come: $mol_log3_logger<{}>;
|
|
482
|
+
/** Log end of some task */
|
|
282
483
|
let $mol_log3_done: $mol_log3_logger<{}>;
|
|
484
|
+
/** Log error */
|
|
283
485
|
let $mol_log3_fail: $mol_log3_logger<{}>;
|
|
486
|
+
/** Log warning message */
|
|
284
487
|
let $mol_log3_warn: $mol_log3_logger<{
|
|
285
488
|
hint: string;
|
|
286
489
|
}>;
|
|
490
|
+
/** Log some generic event */
|
|
287
491
|
let $mol_log3_rise: $mol_log3_logger<{}>;
|
|
492
|
+
/** Log begin of log group, returns func to close group */
|
|
288
493
|
let $mol_log3_area: $mol_log3_logger<{}, () => void>;
|
|
494
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
289
495
|
function $mol_log3_area_lazy(this: $, event: $mol_log3_event<{}>): () => void;
|
|
290
496
|
let $mol_log3_stack: (() => void)[];
|
|
291
497
|
}
|
|
292
498
|
|
|
293
499
|
declare namespace $ {
|
|
500
|
+
/** Position in any resource. */
|
|
294
501
|
class $mol_span extends $mol_object2 {
|
|
295
502
|
readonly uri: string;
|
|
296
503
|
readonly source: string;
|
|
@@ -298,9 +505,13 @@ declare namespace $ {
|
|
|
298
505
|
readonly col: number;
|
|
299
506
|
readonly length: number;
|
|
300
507
|
constructor(uri: string, source: string, row: number, col: number, length: number);
|
|
508
|
+
/** Span for begin of unknown resource */
|
|
301
509
|
static unknown: $mol_span;
|
|
510
|
+
/** Makes new span for begin of resource. */
|
|
302
511
|
static begin(uri: string, source?: string): $mol_span;
|
|
512
|
+
/** Makes new span for end of resource. */
|
|
303
513
|
static end(uri: string, source: string): $mol_span;
|
|
514
|
+
/** Makes new span for entire resource. */
|
|
304
515
|
static entire(uri: string, source: string): $mol_span;
|
|
305
516
|
toString(): string;
|
|
306
517
|
toJSON(): {
|
|
@@ -309,48 +520,95 @@ declare namespace $ {
|
|
|
309
520
|
col: number;
|
|
310
521
|
length: number;
|
|
311
522
|
};
|
|
523
|
+
/** Makes new error for this span. */
|
|
312
524
|
error(message: string, Class?: ErrorConstructor): Error;
|
|
525
|
+
/** Makes new span for same uri. */
|
|
313
526
|
span(row: number, col: number, length: number): $mol_span;
|
|
527
|
+
/** Makes new span after end of this. */
|
|
314
528
|
after(length?: number): $mol_span;
|
|
529
|
+
/** Makes new span between begin and end. */
|
|
315
530
|
slice(begin: number, end?: number): $mol_span;
|
|
316
531
|
}
|
|
317
532
|
}
|
|
318
533
|
|
|
319
534
|
declare namespace $ {
|
|
535
|
+
/** Serializes tree to string in tree format. */
|
|
320
536
|
function $mol_tree2_to_string(this: $, tree: $mol_tree2): string;
|
|
321
537
|
}
|
|
322
538
|
|
|
323
539
|
declare namespace $ {
|
|
540
|
+
function $mol_maybe<Value>(value: Value | null | undefined): Value[];
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
declare namespace $ {
|
|
544
|
+
/** Path by types in tree. */
|
|
324
545
|
type $mol_tree2_path = Array<string | number | null>;
|
|
546
|
+
/** Hask tool for processing node. */
|
|
325
547
|
type $mol_tree2_hack<Context> = (input: $mol_tree2, belt: $mol_tree2_belt<Context>, context: Context) => readonly $mol_tree2[];
|
|
548
|
+
/** Collection of hask tools for processing tree. */
|
|
326
549
|
type $mol_tree2_belt<Context> = Record<string, $mol_tree2_hack<Context>>;
|
|
550
|
+
/**
|
|
551
|
+
* Abstract Syntax Tree with human readable serialization.
|
|
552
|
+
* Avoid direct instantiation. Use static factories instead.
|
|
553
|
+
* @see https://github.com/nin-jin/tree.d
|
|
554
|
+
*/
|
|
327
555
|
class $mol_tree2 extends Object {
|
|
556
|
+
/** Type of structural node, `value` should be empty */
|
|
328
557
|
readonly type: string;
|
|
558
|
+
/** Content of data node, `type` should be empty */
|
|
329
559
|
readonly value: string;
|
|
560
|
+
/** Child nodes */
|
|
330
561
|
readonly kids: readonly $mol_tree2[];
|
|
562
|
+
/** Position in most far source resource */
|
|
331
563
|
readonly span: $mol_span;
|
|
332
|
-
constructor(
|
|
564
|
+
constructor(
|
|
565
|
+
/** Type of structural node, `value` should be empty */
|
|
566
|
+
type: string,
|
|
567
|
+
/** Content of data node, `type` should be empty */
|
|
568
|
+
value: string,
|
|
569
|
+
/** Child nodes */
|
|
570
|
+
kids: readonly $mol_tree2[],
|
|
571
|
+
/** Position in most far source resource */
|
|
572
|
+
span: $mol_span);
|
|
573
|
+
/** Makes collection node. */
|
|
333
574
|
static list(kids: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
|
|
575
|
+
/** Makes new derived collection node. */
|
|
334
576
|
list(kids: readonly $mol_tree2[]): $mol_tree2;
|
|
577
|
+
/** Makes data node for any string. */
|
|
335
578
|
static data(value: string, kids?: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
|
|
579
|
+
/** Makes new derived data node. */
|
|
336
580
|
data(value: string, kids?: readonly $mol_tree2[]): $mol_tree2;
|
|
581
|
+
/** Makes struct node. */
|
|
337
582
|
static struct(type: string, kids?: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
|
|
583
|
+
/** Makes new derived structural node. */
|
|
338
584
|
struct(type: string, kids?: readonly $mol_tree2[]): $mol_tree2;
|
|
585
|
+
/** Makes new derived node with different kids id defined. */
|
|
339
586
|
clone(kids: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
|
|
587
|
+
/** Returns multiline text content. */
|
|
340
588
|
text(): string;
|
|
589
|
+
/** Parses tree format. */
|
|
590
|
+
/** @deprecated Use $mol_tree2_from_string */
|
|
341
591
|
static fromString(str: string, uri?: string): $mol_tree2;
|
|
592
|
+
/** Serializes to tree format. */
|
|
342
593
|
toString(): string;
|
|
594
|
+
/** Makes new tree with node overrided by path. */
|
|
343
595
|
insert(value: $mol_tree2 | null, ...path: $mol_tree2_path): $mol_tree2;
|
|
596
|
+
/** Makes new tree with node overrided by path. */
|
|
597
|
+
update(value: readonly $mol_tree2[], ...path: $mol_tree2_path): readonly $mol_tree2[];
|
|
598
|
+
/** Query nodes by path. */
|
|
344
599
|
select(...path: $mol_tree2_path): $mol_tree2;
|
|
600
|
+
/** Filter kids by path or value. */
|
|
345
601
|
filter(path: string[], value?: string): $mol_tree2;
|
|
346
602
|
hack_self<Context extends {
|
|
347
603
|
span?: $mol_span;
|
|
348
604
|
[key: string]: unknown;
|
|
349
605
|
} = {}>(belt: $mol_tree2_belt<Context>, context?: Context): readonly $mol_tree2[];
|
|
606
|
+
/** Transform tree through context with transformers */
|
|
350
607
|
hack<Context extends {
|
|
351
608
|
span?: $mol_span;
|
|
352
609
|
[key: string]: unknown;
|
|
353
610
|
} = {}>(belt: $mol_tree2_belt<Context>, context?: Context): $mol_tree2[];
|
|
611
|
+
/** Makes Error with node coordinates. */
|
|
354
612
|
error(message: string, Class?: ErrorConstructor): Error;
|
|
355
613
|
}
|
|
356
614
|
class $mol_tree2_empty extends $mol_tree2 {
|
|
@@ -359,6 +617,7 @@ declare namespace $ {
|
|
|
359
617
|
}
|
|
360
618
|
|
|
361
619
|
declare namespace $ {
|
|
620
|
+
/** Syntax error with cordinates and source line snippet. */
|
|
362
621
|
class $mol_error_syntax extends SyntaxError {
|
|
363
622
|
reason: string;
|
|
364
623
|
line: string;
|
|
@@ -368,14 +627,20 @@ declare namespace $ {
|
|
|
368
627
|
}
|
|
369
628
|
|
|
370
629
|
declare namespace $ {
|
|
630
|
+
/** Parses tree format from string. */
|
|
371
631
|
function $mol_tree2_from_string(this: $, str: string, uri?: string): $mol_tree2;
|
|
372
632
|
}
|
|
373
633
|
|
|
634
|
+
declare namespace $ {
|
|
635
|
+
function $mol_array_chunks<Item>(array: readonly Item[], rule: number | ((item: Item, index: number) => boolean)): Item[][];
|
|
636
|
+
}
|
|
637
|
+
|
|
374
638
|
declare namespace $ {
|
|
375
639
|
function $mol_tree2_from_json(json: any, span?: $mol_span): $mol_tree2;
|
|
376
640
|
}
|
|
377
641
|
|
|
378
642
|
declare namespace $ {
|
|
643
|
+
/** Module for working with terminal. Text coloring when output in terminal */
|
|
379
644
|
class $mol_term_color {
|
|
380
645
|
static reset: (str: string) => string;
|
|
381
646
|
static bold: (str: string) => string;
|
|
@@ -407,15 +672,21 @@ declare namespace $ {
|
|
|
407
672
|
}
|
|
408
673
|
|
|
409
674
|
declare namespace $ {
|
|
675
|
+
/** One-shot fiber */
|
|
410
676
|
class $mol_wire_task<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
|
|
411
677
|
static getter<Host, Args extends readonly unknown[], Result>(task: (this: Host, ...args: Args) => Result): (host: Host, args: Args) => $mol_wire_task<Host, Args, Result>;
|
|
412
678
|
get temp(): boolean;
|
|
413
679
|
complete(): void;
|
|
414
680
|
put(next: Result | Error | Promise<Result | Error>): Error | Result | Promise<Error | Result>;
|
|
681
|
+
destructor(): void;
|
|
415
682
|
}
|
|
416
683
|
}
|
|
417
684
|
|
|
418
685
|
declare namespace $ {
|
|
686
|
+
/**
|
|
687
|
+
* Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
|
|
688
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
689
|
+
*/
|
|
419
690
|
export function $mol_wire_sync<Host extends object>(obj: Host): ObjectOrFunctionResultAwaited<Host>;
|
|
420
691
|
type FunctionResultAwaited<Some> = Some extends (...args: infer Args) => infer Res ? (...args: Args) => Awaited<Res> : Some;
|
|
421
692
|
type ConstructorResultAwaited<Some> = Some extends new (...args: infer Args) => infer Res ? new (...args: Args) => Res : {};
|
|
@@ -441,8 +712,8 @@ declare namespace $ {
|
|
|
441
712
|
dir: string;
|
|
442
713
|
}> {
|
|
443
714
|
}
|
|
444
|
-
const $mol_run_spawn: (
|
|
445
|
-
const $mol_run_spawn_sync: (
|
|
715
|
+
const $mol_run_spawn: (...args: Parameters<(typeof $node)["child_process"]["spawn"]>) => import("node:child_process").ChildProcess;
|
|
716
|
+
const $mol_run_spawn_sync: (...args: Parameters<(typeof $node)["child_process"]["spawnSync"]>) => import("node:child_process").SpawnSyncReturns<string | NonSharedBuffer>;
|
|
446
717
|
type $mol_run_options = {
|
|
447
718
|
command: readonly string[] | string;
|
|
448
719
|
dir: string;
|
|
@@ -451,131 +722,76 @@ declare namespace $ {
|
|
|
451
722
|
};
|
|
452
723
|
class $mol_run extends $mol_object {
|
|
453
724
|
static async_enabled(): boolean;
|
|
454
|
-
static spawn(options: $mol_run_options): import("child_process").SpawnSyncReturns<string |
|
|
725
|
+
static spawn(options: $mol_run_options): import("node:child_process").SpawnSyncReturns<string | NonSharedBuffer> | $mol_run_error_context;
|
|
455
726
|
static spawn_async({ dir, sync, timeout, command, env }: $mol_run_options & {
|
|
456
727
|
sync?: boolean;
|
|
457
|
-
}): import("child_process").SpawnSyncReturns<string |
|
|
728
|
+
}): import("node:child_process").SpawnSyncReturns<string | NonSharedBuffer> | (Promise<$mol_run_error_context> & {
|
|
458
729
|
destructor: () => void;
|
|
459
730
|
});
|
|
460
731
|
static error_message(res?: $mol_run_error_context): string;
|
|
461
732
|
}
|
|
462
733
|
}
|
|
463
734
|
|
|
464
|
-
declare namespace $ {
|
|
465
|
-
function $mol_exec(this: $, dir: string, command: string, ...args: readonly string[]): import("child_process").SpawnSyncReturns<string | Buffer<ArrayBufferLike>> | $mol_run_error_context;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
declare namespace $ {
|
|
469
|
-
function $mol_charset_encode(value: string): Uint8Array<ArrayBuffer>;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
declare namespace $ {
|
|
473
|
-
type $mol_int62_string = `${string}_${string}`;
|
|
474
|
-
function $mol_int62_string_ensure(str: unknown): `${string}_${string}` | null;
|
|
475
|
-
type $mol_int62_pair = {
|
|
476
|
-
readonly lo: number;
|
|
477
|
-
readonly hi: number;
|
|
478
|
-
};
|
|
479
|
-
const $mol_int62_max: number;
|
|
480
|
-
const $mol_int62_min: number;
|
|
481
|
-
const $mol_int62_range: number;
|
|
482
|
-
function $mol_int62_to_string({ lo, hi }: $mol_int62_pair): $mol_int62_string;
|
|
483
|
-
function $mol_int62_from_string(str: string): null | $mol_int62_pair;
|
|
484
|
-
function $mol_int62_compare(left_lo: number, left_hi: number, right_lo: number, right_hi: number): number;
|
|
485
|
-
function $mol_int62_inc(lo: number, hi: number, max?: number): $mol_int62_pair;
|
|
486
|
-
function $mol_int62_random(): $mol_int62_pair;
|
|
487
|
-
function $mol_int62_hash_string(str: string): `${string}_${string}`;
|
|
488
|
-
function $mol_int62_hash_buffer(buf: Uint8Array, seed?: {
|
|
489
|
-
lo: number;
|
|
490
|
-
hi: number;
|
|
491
|
-
}): $mol_int62_pair;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
declare namespace $ {
|
|
495
|
-
type $mol_data_value<Input = any, Output = any> = (val: Input) => Output;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
declare namespace $ {
|
|
499
|
-
function $mol_data_setup<Value extends $mol_data_value, Config = never>(value: Value, config: Config): Value & {
|
|
500
|
-
config: Config;
|
|
501
|
-
Value: ReturnType<Value>;
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
declare namespace $ {
|
|
506
|
-
class $mol_data_error extends $mol_error_mix {
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
declare namespace $ {
|
|
511
|
-
function $mol_data_enum<Dict extends Record<number | string, number | string>>(name: string, dict: Dict): ((value: Dict[keyof Dict]) => Dict[keyof Dict]) & {
|
|
512
|
-
config: {
|
|
513
|
-
name: string;
|
|
514
|
-
dict: Dict;
|
|
515
|
-
};
|
|
516
|
-
Value: Dict[keyof Dict];
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
|
|
520
735
|
declare namespace $ {
|
|
521
736
|
var $mol_crypto_native: Crypto;
|
|
522
737
|
}
|
|
523
738
|
|
|
524
739
|
declare namespace $ {
|
|
525
|
-
function $
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
declare namespace $ {
|
|
529
|
-
function $mol_base64_encode_node(str: string | Uint8Array): string;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
declare namespace $ {
|
|
533
|
-
function $mol_base64_decode(base64: string): Uint8Array<ArrayBuffer>;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
declare namespace $ {
|
|
537
|
-
function $mol_base64_decode_node(base64Str: string): Uint8Array<ArrayBuffer>;
|
|
740
|
+
function $mol_base64_url_encode(buffer: Uint8Array<ArrayBuffer>): string;
|
|
741
|
+
function $mol_base64_url_decode(str: string): Uint8Array<ArrayBuffer>;
|
|
538
742
|
}
|
|
539
743
|
|
|
540
744
|
declare namespace $ {
|
|
541
|
-
function $
|
|
542
|
-
function $
|
|
745
|
+
function $mol_base64_url_encode_node(str: Uint8Array<ArrayBuffer>): string;
|
|
746
|
+
function $mol_base64_url_decode_node(str: string): Uint8Array<ArrayBuffer>;
|
|
543
747
|
}
|
|
544
748
|
|
|
545
749
|
declare namespace $ {
|
|
750
|
+
/** Asymmetric signing pair with shortest payload */
|
|
546
751
|
function $mol_crypto_auditor_pair(this: $): Promise<{
|
|
547
752
|
public: $mol_crypto_auditor_public;
|
|
548
753
|
private: $mol_crypto_auditor_private;
|
|
549
754
|
}>;
|
|
755
|
+
/** Asymmetric signing public key wrapper with shortest payload */
|
|
550
756
|
class $mol_crypto_auditor_public extends Object {
|
|
551
757
|
readonly native: CryptoKey & {
|
|
552
758
|
type: 'public';
|
|
553
759
|
};
|
|
760
|
+
/** Key size in bytes. */
|
|
554
761
|
static size_str: number;
|
|
555
762
|
static size_bin: number;
|
|
556
763
|
constructor(native: CryptoKey & {
|
|
557
764
|
type: 'public';
|
|
558
765
|
});
|
|
559
|
-
static from(serial: string | Uint8Array): Promise<$mol_crypto_auditor_public>;
|
|
766
|
+
static from(serial: string | Uint8Array<ArrayBuffer>): Promise<$mol_crypto_auditor_public>;
|
|
767
|
+
/** 86 bytes */
|
|
560
768
|
serial(): Promise<string>;
|
|
561
|
-
|
|
769
|
+
/** 64 bytes */
|
|
770
|
+
toArray(): Promise<Uint8Array<ArrayBuffer>>;
|
|
562
771
|
verify(data: BufferSource, sign: BufferSource): Promise<boolean>;
|
|
563
772
|
}
|
|
773
|
+
/** Asymmetric signing private key wrapper with shortest payload */
|
|
564
774
|
class $mol_crypto_auditor_private extends Object {
|
|
565
775
|
readonly native: CryptoKey & {
|
|
566
776
|
type: 'private';
|
|
567
777
|
};
|
|
778
|
+
/** Key size in bytes. */
|
|
568
779
|
static size_str: number;
|
|
569
780
|
static size_bin: number;
|
|
570
781
|
constructor(native: CryptoKey & {
|
|
571
782
|
type: 'private';
|
|
572
783
|
});
|
|
573
|
-
static from(serial: string | Uint8Array): Promise<$mol_crypto_auditor_private>;
|
|
784
|
+
static from(serial: string | Uint8Array<ArrayBuffer>): Promise<$mol_crypto_auditor_private>;
|
|
785
|
+
/** 129 bytes */
|
|
574
786
|
serial(): Promise<string>;
|
|
575
|
-
|
|
787
|
+
/** 96 bytes */
|
|
788
|
+
toArray(): Promise<Uint8Array<ArrayBuffer>>;
|
|
789
|
+
/** 64 bytes */
|
|
576
790
|
sign(data: BufferSource): Promise<ArrayBuffer>;
|
|
791
|
+
/** Makes public key from private */
|
|
577
792
|
public(): Promise<$mol_crypto_auditor_public>;
|
|
578
793
|
}
|
|
794
|
+
/** Sign size in bytes. */
|
|
579
795
|
const $mol_crypto_auditor_sign_size = 64;
|
|
580
796
|
function $mol_crypto_auditor_private_to_public(serial: string): string;
|
|
581
797
|
}
|
|
@@ -604,32 +820,64 @@ declare namespace $ {
|
|
|
604
820
|
}
|
|
605
821
|
|
|
606
822
|
declare namespace $ {
|
|
607
|
-
function $mol_charset_decode(buffer:
|
|
823
|
+
function $mol_charset_decode(buffer: AllowSharedBufferSource, encoding?: $mol_charset_encoding): string;
|
|
608
824
|
}
|
|
609
825
|
|
|
610
826
|
declare namespace $ {
|
|
611
827
|
type $hyoo_crowd_unit_id = `${$mol_int62_string}!${$mol_int62_string}`;
|
|
612
828
|
enum $hyoo_crowd_unit_kind {
|
|
829
|
+
/** Grab Land by King */
|
|
613
830
|
grab = 0,
|
|
831
|
+
/** Join Peer to Land */
|
|
614
832
|
join = 1,
|
|
615
833
|
give = 2,
|
|
834
|
+
/** Add Data to Land by joined Peer with right Level */
|
|
616
835
|
data = 3
|
|
617
836
|
}
|
|
618
837
|
enum $hyoo_crowd_unit_group {
|
|
838
|
+
/** Join and Give units */
|
|
619
839
|
auth = 0,
|
|
840
|
+
/** Data units */
|
|
620
841
|
data = 1
|
|
621
842
|
}
|
|
843
|
+
/** Independent part of data. */
|
|
622
844
|
class $hyoo_crowd_unit extends Object {
|
|
845
|
+
/** Identifier of land. */
|
|
623
846
|
readonly land: $mol_int62_string;
|
|
847
|
+
/** Identifier of auth. */
|
|
624
848
|
readonly auth: $mol_int62_string;
|
|
849
|
+
/** Identifier of head node. */
|
|
625
850
|
readonly head: $mol_int62_string;
|
|
851
|
+
/** Self identifier inside head after prev before next. */
|
|
626
852
|
readonly self: $mol_int62_string;
|
|
853
|
+
/** Identifier of next node. */
|
|
627
854
|
readonly next: $mol_int62_string;
|
|
855
|
+
/** Identifier of prev node. */
|
|
628
856
|
readonly prev: $mol_int62_string;
|
|
857
|
+
/** Monotonic real clock. 4B / info = 31b */
|
|
629
858
|
readonly time: number;
|
|
859
|
+
/** type-size = bin<0 | null=0 | json>0 */
|
|
860
|
+
/** Associated atomic data. mem = 4B+ / bin = (0|8B)+ / type-size-info = 16b */
|
|
630
861
|
readonly data: unknown;
|
|
631
862
|
bin: $hyoo_crowd_unit_bin | null;
|
|
632
|
-
constructor(
|
|
863
|
+
constructor(
|
|
864
|
+
/** Identifier of land. */
|
|
865
|
+
land: $mol_int62_string,
|
|
866
|
+
/** Identifier of auth. */
|
|
867
|
+
auth: $mol_int62_string,
|
|
868
|
+
/** Identifier of head node. */
|
|
869
|
+
head: $mol_int62_string,
|
|
870
|
+
/** Self identifier inside head after prev before next. */
|
|
871
|
+
self: $mol_int62_string,
|
|
872
|
+
/** Identifier of next node. */
|
|
873
|
+
next: $mol_int62_string,
|
|
874
|
+
/** Identifier of prev node. */
|
|
875
|
+
prev: $mol_int62_string,
|
|
876
|
+
/** Monotonic real clock. 4B / info = 31b */
|
|
877
|
+
time: number,
|
|
878
|
+
/** type-size = bin<0 | null=0 | json>0 */
|
|
879
|
+
/** Associated atomic data. mem = 4B+ / bin = (0|8B)+ / type-size-info = 16b */
|
|
880
|
+
data: unknown, bin: $hyoo_crowd_unit_bin | null);
|
|
633
881
|
kind(): $hyoo_crowd_unit_kind;
|
|
634
882
|
group(): $hyoo_crowd_unit_group;
|
|
635
883
|
level(): $hyoo_crowd_peer_level;
|
|
@@ -648,11 +896,7 @@ declare namespace $ {
|
|
|
648
896
|
}
|
|
649
897
|
|
|
650
898
|
declare namespace $ {
|
|
651
|
-
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
declare namespace $ {
|
|
655
|
-
const $mol_key_store: WeakMap<object, string>;
|
|
899
|
+
/** Returns string key for any value. */
|
|
656
900
|
function $mol_key<Value>(value: Value): string;
|
|
657
901
|
}
|
|
658
902
|
|
|
@@ -674,6 +918,9 @@ declare namespace $ {
|
|
|
674
918
|
}
|
|
675
919
|
|
|
676
920
|
declare namespace $ {
|
|
921
|
+
/**
|
|
922
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber.
|
|
923
|
+
*/
|
|
677
924
|
function $mol_wire_method<Host extends object, Args extends readonly any[]>(host: Host, field: PropertyKey, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
|
|
678
925
|
value: (this: Host, ...args: Args) => any;
|
|
679
926
|
enumerable?: boolean;
|
|
@@ -685,14 +932,25 @@ declare namespace $ {
|
|
|
685
932
|
}
|
|
686
933
|
|
|
687
934
|
declare namespace $ {
|
|
935
|
+
/**
|
|
936
|
+
* Returns `Tuple` without first element.
|
|
937
|
+
*
|
|
938
|
+
* $mol_type_tail<[ 1 , 2 , 3 ]> // [ 2, 3 ]
|
|
939
|
+
*/
|
|
688
940
|
type $mol_type_tail<Tuple extends readonly any[]> = ((...tail: Tuple) => any) extends ((head: any, ...tail: infer Tail) => any) ? Tail : never;
|
|
689
941
|
}
|
|
690
942
|
|
|
691
943
|
declare namespace $ {
|
|
944
|
+
/**
|
|
945
|
+
* Returns last element of `Tuple`.
|
|
946
|
+
*
|
|
947
|
+
* $mol_type_tail<[ 1 , 2 , 3 ]> // 3
|
|
948
|
+
*/
|
|
692
949
|
type $mol_type_foot<Tuple extends readonly any[]> = Tuple['length'] extends 0 ? never : Tuple[$mol_type_tail<Tuple>['length']];
|
|
693
950
|
}
|
|
694
951
|
|
|
695
952
|
declare namespace $ {
|
|
953
|
+
/** Long-living fiber. */
|
|
696
954
|
class $mol_wire_atom<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
|
|
697
955
|
static solo<Host, Args extends readonly unknown[], Result>(host: Host, task: (this: Host, ...args: Args) => Result): $mol_wire_atom<Host, Args, Result>;
|
|
698
956
|
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>;
|
|
@@ -700,6 +958,9 @@ declare namespace $ {
|
|
|
700
958
|
static watcher: $mol_after_frame | null;
|
|
701
959
|
static watch(): void;
|
|
702
960
|
watch(): void;
|
|
961
|
+
/**
|
|
962
|
+
* Update atom value through another temp fiber.
|
|
963
|
+
*/
|
|
703
964
|
resync(args: Args): Error | Result | Promise<Error | Result>;
|
|
704
965
|
once(): Awaited<Result>;
|
|
705
966
|
channel(): ((next?: $mol_type_foot<Args>) => Awaited<Result>) & {
|
|
@@ -711,12 +972,14 @@ declare namespace $ {
|
|
|
711
972
|
}
|
|
712
973
|
|
|
713
974
|
declare namespace $ {
|
|
975
|
+
/** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
|
|
714
976
|
export function $mol_wire_solo<Args extends any[]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): TypedPropertyDescriptor<(...args: First_optional<Args>) => any>;
|
|
715
977
|
type First_optional<Args extends any[]> = Args extends [] ? [] : [Args[0] | undefined, ...$mol_type_tail<Args>];
|
|
716
978
|
export {};
|
|
717
979
|
}
|
|
718
980
|
|
|
719
981
|
declare namespace $ {
|
|
982
|
+
/** Reactive memoizing multiplexed property decorator. */
|
|
720
983
|
function $mol_wire_plex<Args extends [any, ...any[]]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
|
|
721
984
|
value: (this: typeof host, ...args: Args) => any;
|
|
722
985
|
enumerable?: boolean;
|
|
@@ -728,7 +991,25 @@ declare namespace $ {
|
|
|
728
991
|
}
|
|
729
992
|
|
|
730
993
|
declare namespace $ {
|
|
994
|
+
/**
|
|
995
|
+
* Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
|
|
996
|
+
* @example
|
|
997
|
+
* '@' $mol_mem
|
|
998
|
+
* name(next?: string) {
|
|
999
|
+
* return next ?? 'default'
|
|
1000
|
+
* }
|
|
1001
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
1002
|
+
*/
|
|
731
1003
|
let $mol_mem: typeof $mol_wire_solo;
|
|
1004
|
+
/**
|
|
1005
|
+
* Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
|
|
1006
|
+
* @example
|
|
1007
|
+
* '@' $mol_mem_key
|
|
1008
|
+
* name(id: number, next?: string) {
|
|
1009
|
+
* return next ?? 'default'
|
|
1010
|
+
* }
|
|
1011
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
1012
|
+
*/
|
|
732
1013
|
let $mol_mem_key: typeof $mol_wire_plex;
|
|
733
1014
|
}
|
|
734
1015
|
|
|
@@ -740,27 +1021,44 @@ declare namespace $ {
|
|
|
740
1021
|
}
|
|
741
1022
|
|
|
742
1023
|
declare namespace $ {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
1024
|
+
class $mol_storage extends $mol_object2 {
|
|
1025
|
+
/** Is storage a long term. */
|
|
1026
|
+
static persisted(next?: boolean): boolean;
|
|
1027
|
+
/** Total storage quota in bytes. */
|
|
1028
|
+
static total(): number;
|
|
1029
|
+
/** Total storage usage in bytes. */
|
|
1030
|
+
static used(): number;
|
|
1031
|
+
/** Minimum available free space in bytes. */
|
|
1032
|
+
static free(): number;
|
|
1033
|
+
/** Fulfillness of storage. */
|
|
1034
|
+
static portion(): number;
|
|
1035
|
+
/**
|
|
1036
|
+
* Fulfillness logarithmic level.
|
|
1037
|
+
* `0` - empty
|
|
1038
|
+
* `1` - half free
|
|
1039
|
+
* `2` - quart free
|
|
1040
|
+
* `Infinity` - fulfilled
|
|
1041
|
+
*/
|
|
1042
|
+
static level(): number;
|
|
1043
|
+
}
|
|
752
1044
|
}
|
|
753
1045
|
|
|
754
1046
|
declare namespace $ {
|
|
755
|
-
|
|
1047
|
+
/** State of time moment */
|
|
1048
|
+
class $mol_state_time extends $mol_object {
|
|
1049
|
+
static task(precision: number, reset?: null): $mol_after_timeout | $mol_after_frame;
|
|
1050
|
+
static now(precision: number): number;
|
|
1051
|
+
}
|
|
756
1052
|
}
|
|
757
1053
|
|
|
758
1054
|
declare namespace $ {
|
|
759
|
-
class $
|
|
760
|
-
static
|
|
761
|
-
static
|
|
762
|
-
static
|
|
763
|
-
static
|
|
1055
|
+
class $mol_storage_node extends $mol_storage {
|
|
1056
|
+
static persisted(): boolean;
|
|
1057
|
+
static stats(): import("node:fs").StatsFs;
|
|
1058
|
+
static total(): number;
|
|
1059
|
+
static used(): number;
|
|
1060
|
+
static free(): number;
|
|
1061
|
+
static portion(): number;
|
|
764
1062
|
}
|
|
765
1063
|
}
|
|
766
1064
|
|
|
@@ -780,6 +1078,11 @@ declare namespace $ {
|
|
|
780
1078
|
}
|
|
781
1079
|
|
|
782
1080
|
declare namespace $ {
|
|
1081
|
+
/**
|
|
1082
|
+
* Returns closure that returns constant value.
|
|
1083
|
+
* @example
|
|
1084
|
+
* const rnd = $mol_const( Math.random() )
|
|
1085
|
+
*/
|
|
783
1086
|
function $mol_const<Value>(value: Value): {
|
|
784
1087
|
(): Value;
|
|
785
1088
|
'()': Value;
|
|
@@ -787,10 +1090,15 @@ declare namespace $ {
|
|
|
787
1090
|
}
|
|
788
1091
|
|
|
789
1092
|
declare namespace $ {
|
|
1093
|
+
/**
|
|
1094
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber from [mol_wire](../wire/README.md)
|
|
1095
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
1096
|
+
*/
|
|
790
1097
|
let $mol_action: typeof $mol_wire_method;
|
|
791
1098
|
}
|
|
792
1099
|
|
|
793
1100
|
declare namespace $ {
|
|
1101
|
+
/** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
|
|
794
1102
|
export function $mol_wire_async<Host extends object>(obj: Host): ObjectOrFunctionResultPromisify<Host>;
|
|
795
1103
|
type FunctionResultPromisify<Some> = Some extends (...args: infer Args) => infer Res ? Res extends PromiseLike<unknown> ? Some : (...args: Args) => Promise<Res> : Some;
|
|
796
1104
|
type MethodsResultPromisify<Host extends Object> = {
|
|
@@ -800,6 +1108,11 @@ declare namespace $ {
|
|
|
800
1108
|
export {};
|
|
801
1109
|
}
|
|
802
1110
|
|
|
1111
|
+
declare namespace $ {
|
|
1112
|
+
/** Run code without state changes */
|
|
1113
|
+
function $mol_wire_probe<Value>(task: () => Value, def?: Value): Value | undefined;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
803
1116
|
declare namespace $ {
|
|
804
1117
|
class $mol_lock extends $mol_object {
|
|
805
1118
|
protected promise: null | Promise<void>;
|
|
@@ -808,6 +1121,10 @@ declare namespace $ {
|
|
|
808
1121
|
}
|
|
809
1122
|
}
|
|
810
1123
|
|
|
1124
|
+
declare namespace $ {
|
|
1125
|
+
let $mol_mem_cached: typeof $mol_wire_probe;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
811
1128
|
declare namespace $ {
|
|
812
1129
|
function $mol_compare_array<Value extends ArrayLike<unknown>>(a: Value, b: Value): boolean;
|
|
813
1130
|
}
|
|
@@ -826,11 +1143,19 @@ declare namespace $ {
|
|
|
826
1143
|
}): number;
|
|
827
1144
|
read(): Uint8Array<ArrayBuffer>;
|
|
828
1145
|
truncate(size: number): void;
|
|
1146
|
+
flush(): void;
|
|
829
1147
|
close(): void;
|
|
830
1148
|
destructor(): void;
|
|
831
1149
|
}
|
|
832
1150
|
}
|
|
833
1151
|
|
|
1152
|
+
declare namespace $ {
|
|
1153
|
+
/**
|
|
1154
|
+
* Disable reaping of current subscriber
|
|
1155
|
+
*/
|
|
1156
|
+
function $mol_wire_solid(): void;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
834
1159
|
declare namespace $ {
|
|
835
1160
|
class $mol_file_transaction_node extends $mol_file_transaction {
|
|
836
1161
|
protected descr(): number;
|
|
@@ -842,6 +1167,7 @@ declare namespace $ {
|
|
|
842
1167
|
}): number;
|
|
843
1168
|
truncate(size: number): void;
|
|
844
1169
|
read(): Uint8Array<ArrayBuffer>;
|
|
1170
|
+
flush(): void;
|
|
845
1171
|
close(): void;
|
|
846
1172
|
}
|
|
847
1173
|
}
|
|
@@ -859,6 +1185,10 @@ declare namespace $ {
|
|
|
859
1185
|
protected static changed: Set<$mol_file_base>;
|
|
860
1186
|
protected static frame: null | $mol_after_timeout;
|
|
861
1187
|
protected static changed_add(type: 'change' | 'rename', path: string): void;
|
|
1188
|
+
/**
|
|
1189
|
+
* Должно быть больше, чем время между событиями от вотчера при записи внешним процессом.
|
|
1190
|
+
* Иначе запуск ресетов паралельно с изменением может привести к неконсистентности.
|
|
1191
|
+
*/
|
|
862
1192
|
static watch_debounce(): number;
|
|
863
1193
|
static flush(): void;
|
|
864
1194
|
protected static watching: boolean;
|
|
@@ -935,7 +1265,7 @@ declare namespace $ {
|
|
|
935
1265
|
protected copy(to: string): void;
|
|
936
1266
|
protected drop(): void;
|
|
937
1267
|
protected read(): Uint8Array<ArrayBuffer>;
|
|
938
|
-
protected write(buffer: Uint8Array): undefined;
|
|
1268
|
+
protected write(buffer: Uint8Array<ArrayBuffer>): undefined;
|
|
939
1269
|
protected kids(): this[];
|
|
940
1270
|
resolve(path: string): this;
|
|
941
1271
|
relate(base?: $mol_file): string;
|
|
@@ -970,8 +1300,8 @@ declare namespace $ {
|
|
|
970
1300
|
static run<Result>(task: () => Result): Result;
|
|
971
1301
|
static func<Args extends any[], Result, Host = void>(func: (this: Host, ...args: Args) => Result): (this: Host, ...args: Args) => Result;
|
|
972
1302
|
static get class(): <Class extends new (...args: any[]) => any>(Class: Class) => Class;
|
|
973
|
-
static get method(): (obj: object, name: PropertyKey, descr
|
|
974
|
-
static get field(): <Host, Field extends keyof Host, Args extends any[], Result>(obj: Host, name: Field, descr
|
|
1303
|
+
static get method(): (obj: object, name: PropertyKey, descr?: TypedPropertyDescriptor<any>) => TypedPropertyDescriptor<any>;
|
|
1304
|
+
static get field(): <Host extends object, Field extends keyof Host, Args extends any[], Result>(obj: Host, name: Field, descr?: TypedPropertyDescriptor<Result>) => TypedPropertyDescriptor<Result>;
|
|
975
1305
|
}
|
|
976
1306
|
}
|
|
977
1307
|
|
|
@@ -982,24 +1312,34 @@ declare namespace $ {
|
|
|
982
1312
|
}
|
|
983
1313
|
|
|
984
1314
|
declare namespace $ {
|
|
1315
|
+
/** Internal int31 representation of current time. */
|
|
985
1316
|
function $hyoo_crowd_time_now(): number;
|
|
1317
|
+
/** Returns unix timestamp for internal time representation. */
|
|
986
1318
|
function $hyoo_crowd_time_stamp(time: number): number;
|
|
987
1319
|
}
|
|
988
1320
|
|
|
989
1321
|
declare namespace $ {
|
|
1322
|
+
/** Vector clock. Stores real timestamps. */
|
|
990
1323
|
class $hyoo_crowd_clock extends Map<$mol_int62_string, number> {
|
|
991
1324
|
static begin: number;
|
|
1325
|
+
/** Maximum time for all peers. */
|
|
992
1326
|
last_time: number;
|
|
993
1327
|
constructor(entries?: Iterable<readonly [$mol_int62_string, number]>);
|
|
1328
|
+
/** Synchronize this clock with another. */
|
|
994
1329
|
sync(right: $hyoo_crowd_clock): void;
|
|
1330
|
+
/** Increase `last` to latest. */
|
|
995
1331
|
see_time(time: number): void;
|
|
1332
|
+
/** Add new `time` for `peer` and increase `last`. */
|
|
996
1333
|
see_peer(peer: $mol_int62_string, time: number): void;
|
|
997
1334
|
see_bin(bin: $hyoo_crowd_clock_bin, group: $hyoo_crowd_unit_group): void;
|
|
1335
|
+
/** Checks if time from future. */
|
|
998
1336
|
fresh(peer: $mol_int62_string, time: number): boolean;
|
|
1337
|
+
/** Checks if this clock from future of another. */
|
|
999
1338
|
ahead(clock: $hyoo_crowd_clock): boolean;
|
|
1000
1339
|
time(peer: $mol_int62_string): number;
|
|
1001
1340
|
now(): number;
|
|
1002
1341
|
last_stamp(): number;
|
|
1342
|
+
/** Gererates new time for peer that greater then other seen. */
|
|
1003
1343
|
tick(peer: $mol_int62_string): number;
|
|
1004
1344
|
[$mol_dev_format_head](): any[];
|
|
1005
1345
|
}
|
|
@@ -1011,6 +1351,7 @@ declare namespace $ {
|
|
|
1011
1351
|
}
|
|
1012
1352
|
|
|
1013
1353
|
declare namespace $ {
|
|
1354
|
+
/** Stateless non-unique adapter to CROWD Tree for given Head. */
|
|
1014
1355
|
class $hyoo_crowd_node extends $mol_object2 {
|
|
1015
1356
|
readonly land: $hyoo_crowd_land;
|
|
1016
1357
|
readonly head: $mol_int62_string;
|
|
@@ -1019,9 +1360,13 @@ declare namespace $ {
|
|
|
1019
1360
|
static toJSON(): string;
|
|
1020
1361
|
id(): `${string}_${string}`;
|
|
1021
1362
|
world(): $hyoo_crowd_world | null;
|
|
1363
|
+
/** Returns another representation of this node. */
|
|
1022
1364
|
as<Node extends typeof $hyoo_crowd_node>(Node: Node): InstanceType<Node>;
|
|
1365
|
+
/** Ordered inner alive Units. */
|
|
1023
1366
|
units(): readonly $hyoo_crowd_unit[];
|
|
1367
|
+
/** Ordered inner alive Node. */
|
|
1024
1368
|
nodes<Node extends typeof $hyoo_crowd_node>(Node: Node): InstanceType<Node>[];
|
|
1369
|
+
/** Returns true when node value is never changed. */
|
|
1025
1370
|
virgin(): boolean;
|
|
1026
1371
|
[Symbol.toPrimitive](): string;
|
|
1027
1372
|
toJSON(): `${string}_${string}`;
|
|
@@ -1031,9 +1376,13 @@ declare namespace $ {
|
|
|
1031
1376
|
|
|
1032
1377
|
declare namespace $ {
|
|
1033
1378
|
class $hyoo_crowd_reg extends $hyoo_crowd_node {
|
|
1379
|
+
/** Atomic value. */
|
|
1034
1380
|
value(next?: unknown): {} | null;
|
|
1381
|
+
/** Atomic string. */
|
|
1035
1382
|
str(next?: string): string;
|
|
1383
|
+
/** Atomic number. */
|
|
1036
1384
|
numb(next?: number): number;
|
|
1385
|
+
/** Atomic boolean. */
|
|
1037
1386
|
bool(next?: boolean): boolean;
|
|
1038
1387
|
yoke(law?: readonly ($mol_int62_string | "")[], mod?: readonly ($mol_int62_string | "")[], add?: readonly ($mol_int62_string | "")[]): $hyoo_crowd_land | null;
|
|
1039
1388
|
}
|
|
@@ -1041,12 +1390,14 @@ declare namespace $ {
|
|
|
1041
1390
|
|
|
1042
1391
|
declare namespace $ {
|
|
1043
1392
|
class $hyoo_crowd_struct extends $hyoo_crowd_node {
|
|
1393
|
+
/** Returns inner node for key. */
|
|
1044
1394
|
sub<Node extends typeof $hyoo_crowd_node>(key: string, Node: Node): InstanceType<Node>;
|
|
1045
1395
|
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;
|
|
1046
1396
|
}
|
|
1047
1397
|
}
|
|
1048
1398
|
|
|
1049
1399
|
declare namespace $ {
|
|
1400
|
+
/** Conflict-free Reinterpretable Ordered Washed Data Tree */
|
|
1050
1401
|
class $hyoo_crowd_land extends $mol_object {
|
|
1051
1402
|
id(): `${string}_${string}`;
|
|
1052
1403
|
toJSON(): `${string}_${string}`;
|
|
@@ -1059,51 +1410,73 @@ declare namespace $ {
|
|
|
1059
1410
|
get clocks_bin(): Uint8Array<ArrayBuffer>;
|
|
1060
1411
|
readonly pub: $mol_wire_pub;
|
|
1061
1412
|
readonly _clocks: readonly [$hyoo_crowd_clock, $hyoo_crowd_clock];
|
|
1413
|
+
/** unit by head + self */
|
|
1062
1414
|
_unit_all: Map<`${string}_${string}!${string}_${string}`, $hyoo_crowd_unit>;
|
|
1063
1415
|
unit(head: $mol_int62_string, self: $mol_int62_string): $hyoo_crowd_unit | undefined;
|
|
1416
|
+
/** units by head */
|
|
1064
1417
|
_unit_lists: Map<`${string}_${string}`, ($hyoo_crowd_unit[] & {
|
|
1065
1418
|
dirty: boolean;
|
|
1066
1419
|
}) | undefined>;
|
|
1420
|
+
/** Units by Head without tombstones */
|
|
1067
1421
|
_unit_alives: Map<`${string}_${string}`, $hyoo_crowd_unit[] | undefined>;
|
|
1068
1422
|
size(): number;
|
|
1423
|
+
/** Returns list of all Units for Node. */
|
|
1069
1424
|
unit_list(head: $mol_int62_string): $hyoo_crowd_unit[] & {
|
|
1070
1425
|
dirty: boolean;
|
|
1071
1426
|
};
|
|
1427
|
+
/** Returns list of alive Units for Node. */
|
|
1072
1428
|
unit_alives(head: $mol_int62_string): readonly $hyoo_crowd_unit[];
|
|
1429
|
+
/** Node by id and type. */
|
|
1073
1430
|
node<Node extends typeof $hyoo_crowd_node>(head: $mol_int62_string, Node: Node): InstanceType<Node>;
|
|
1431
|
+
/** Root Node. */
|
|
1074
1432
|
chief: $hyoo_crowd_struct;
|
|
1433
|
+
/** Generates new identifier. */
|
|
1075
1434
|
id_new(): $mol_int62_string;
|
|
1435
|
+
/** Makes independent clone with defined peer. */
|
|
1076
1436
|
fork(auth: $hyoo_crowd_peer): $hyoo_crowd_land;
|
|
1437
|
+
/** Makes Delta bettween Clock and now. */
|
|
1077
1438
|
delta(clocks?: readonly [$hyoo_crowd_clock, $hyoo_crowd_clock]): readonly $hyoo_crowd_unit[];
|
|
1078
1439
|
resort(head: $mol_int62_string): $hyoo_crowd_unit[] & {
|
|
1079
1440
|
dirty: boolean;
|
|
1080
1441
|
};
|
|
1442
|
+
/** Applies Delta to current state. */
|
|
1081
1443
|
apply(delta: readonly $hyoo_crowd_unit[]): this;
|
|
1082
1444
|
_joined: boolean;
|
|
1445
|
+
/** Register public key of current peer **/
|
|
1083
1446
|
join(): true | undefined;
|
|
1447
|
+
/** Unregister public key of current peer **/
|
|
1084
1448
|
leave(): false | undefined;
|
|
1085
1449
|
allowed_add(peer?: `${string}_${string}`): boolean;
|
|
1086
1450
|
allowed_mod(peer?: `${string}_${string}`): boolean;
|
|
1087
1451
|
allowed_law(peer?: `${string}_${string}`): boolean;
|
|
1088
1452
|
level_base(next?: $hyoo_crowd_peer_level): void;
|
|
1453
|
+
/** Access level for peer. Use empty string for current peer. **/
|
|
1089
1454
|
level(peer: $mol_int62_string | '', next?: $hyoo_crowd_peer_level): $hyoo_crowd_peer_level;
|
|
1090
1455
|
grabbed(): boolean;
|
|
1456
|
+
/** All peers who have special rights to write o land. */
|
|
1091
1457
|
peers(): Readonly<`${string}_${string}`[]>;
|
|
1458
|
+
/** All peers who joined to land except king. */
|
|
1092
1459
|
residents(): Readonly<`${string}_${string}`[]>;
|
|
1460
|
+
/** All peers who have alive data inside land. */
|
|
1093
1461
|
authors(): Set<`${string}_${string}`>;
|
|
1094
1462
|
steal_rights(donor: $hyoo_crowd_land): void;
|
|
1095
1463
|
first_stamp(): number | null;
|
|
1096
1464
|
last_stamp(): number;
|
|
1097
1465
|
selection(peer: $mol_int62_string): $hyoo_crowd_reg;
|
|
1466
|
+
/** Places data to tree. */
|
|
1098
1467
|
put(head: $mol_int62_string, self: $mol_int62_string, prev: $mol_int62_string, data: unknown): $hyoo_crowd_unit;
|
|
1468
|
+
/** Marks unit as deleted and wipes its data. */
|
|
1099
1469
|
wipe(unit: $hyoo_crowd_unit): $hyoo_crowd_unit;
|
|
1470
|
+
/** Moves Unit after another Prev inside some Head. */
|
|
1100
1471
|
move(unit: $hyoo_crowd_unit, head: $mol_int62_string, prev: $mol_int62_string): void;
|
|
1472
|
+
/** Moves Unit at given Seat inside given Head. */
|
|
1101
1473
|
insert(unit: $hyoo_crowd_unit, head: $mol_int62_string, seat: number): void;
|
|
1102
1474
|
[$mol_dev_format_head](): any[];
|
|
1103
1475
|
}
|
|
1104
1476
|
}
|
|
1105
1477
|
|
|
1106
1478
|
declare namespace $ {
|
|
1479
|
+
/** Registry of nodes as domain entities. */
|
|
1107
1480
|
class $hyoo_crowd_fund<Node extends typeof $hyoo_crowd_node> extends $mol_object {
|
|
1108
1481
|
world: $hyoo_crowd_world;
|
|
1109
1482
|
node_class: Node;
|
|
@@ -1114,7 +1487,11 @@ declare namespace $ {
|
|
|
1114
1487
|
}
|
|
1115
1488
|
|
|
1116
1489
|
declare namespace $ {
|
|
1490
|
+
/** @deprecated */
|
|
1117
1491
|
let $mol_dict_key: typeof $mol_key;
|
|
1492
|
+
/**
|
|
1493
|
+
* Dictionary with extended keys support
|
|
1494
|
+
*/
|
|
1118
1495
|
class $mol_dict<Key, Value> extends Map<Key, Value> {
|
|
1119
1496
|
get(key: Key): Value | undefined;
|
|
1120
1497
|
has(key: Key): boolean;
|
|
@@ -1172,6 +1549,7 @@ declare namespace $ {
|
|
|
1172
1549
|
}
|
|
1173
1550
|
|
|
1174
1551
|
declare namespace $ {
|
|
1552
|
+
/** Starts subtasks concurrently instead of serial. */
|
|
1175
1553
|
function $mol_wire_race<Tasks extends ((...args: any) => any)[]>(...tasks: Tasks): {
|
|
1176
1554
|
[index in keyof Tasks]: ReturnType<Tasks[index]>;
|
|
1177
1555
|
};
|
|
@@ -1232,33 +1610,52 @@ declare namespace $ {
|
|
|
1232
1610
|
}
|
|
1233
1611
|
|
|
1234
1612
|
declare namespace $ {
|
|
1613
|
+
/** Converts IDBResult to Promise */
|
|
1235
1614
|
function $mol_db_response<Result>(request: IDBRequest<Result>): Promise<Result>;
|
|
1236
1615
|
}
|
|
1237
1616
|
|
|
1238
1617
|
declare namespace $ {
|
|
1618
|
+
/**
|
|
1619
|
+
* Creates new or returns existen database with automatic schema migration.
|
|
1620
|
+
* Schema version is based on migrations count.
|
|
1621
|
+
* Migrations code mustn't be changed after deploy.
|
|
1622
|
+
* Only adding migrations at the end is allowed.
|
|
1623
|
+
* Only new migrations will be applyed to existen DB.
|
|
1624
|
+
* Schema changes allowed only through migratios.
|
|
1625
|
+
*/
|
|
1239
1626
|
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>>;
|
|
1240
1627
|
}
|
|
1241
1628
|
|
|
1242
1629
|
declare namespace $ {
|
|
1630
|
+
/** IndexedDB ObjectStore wrapper. */
|
|
1243
1631
|
class $mol_db_store<Schema extends $mol_db_store_schema> {
|
|
1244
1632
|
readonly native: IDBObjectStore;
|
|
1245
1633
|
constructor(native: IDBObjectStore);
|
|
1246
1634
|
get name(): string;
|
|
1247
|
-
get path(): string | string[];
|
|
1635
|
+
get path(): string | string[] | null;
|
|
1248
1636
|
get incremental(): boolean;
|
|
1637
|
+
/** Returns dictionary of all existen Indexes. */
|
|
1249
1638
|
get indexes(): { [Name in keyof Schema["Indexes"]]: $mol_db_index<{
|
|
1250
1639
|
Key: Schema["Indexes"][Name];
|
|
1251
1640
|
Doc: Schema["Doc"];
|
|
1252
1641
|
}>; };
|
|
1642
|
+
/** Creates new Index */
|
|
1253
1643
|
index_make(name: string, path?: string[], unique?: boolean, multiEntry?: boolean): IDBIndex;
|
|
1644
|
+
/** Drops existen Index */
|
|
1254
1645
|
index_drop(name: string): this;
|
|
1255
1646
|
get transaction(): $mol_db_transaction<$mol_db_schema>;
|
|
1256
1647
|
get db(): $mol_db_database<$mol_db_schema>;
|
|
1648
|
+
/** Deletes all stored Documents */
|
|
1257
1649
|
clear(): Promise<undefined>;
|
|
1650
|
+
/** Counts Documents by primary key(s) */
|
|
1258
1651
|
count(keys?: Schema['Key'] | IDBKeyRange): Promise<number>;
|
|
1652
|
+
/** Stores single Document by primary key. */
|
|
1259
1653
|
put(doc: Schema['Doc'], key?: Schema['Key']): Promise<IDBValidKey>;
|
|
1654
|
+
/** Returns Document by primary key. */
|
|
1260
1655
|
get(key: Schema['Key']): Promise<Schema["Doc"] | undefined>;
|
|
1656
|
+
/** Selects Documents by primary keys. */
|
|
1261
1657
|
select(key?: Schema['Key'] | IDBKeyRange | null, count?: number): Promise<Schema["Doc"][]>;
|
|
1658
|
+
/** Deletes Documents by primary key(s). */
|
|
1262
1659
|
drop(keys: Schema['Key'] | IDBKeyRange): Promise<undefined>;
|
|
1263
1660
|
}
|
|
1264
1661
|
}
|
|
@@ -1272,6 +1669,7 @@ declare namespace $ {
|
|
|
1272
1669
|
}
|
|
1273
1670
|
|
|
1274
1671
|
declare namespace $ {
|
|
1672
|
+
/** IndexedDB Index wrapper. */
|
|
1275
1673
|
class $mol_db_index<Schema extends $mol_db_index_schema> {
|
|
1276
1674
|
readonly native: IDBIndex;
|
|
1277
1675
|
constructor(native: IDBIndex);
|
|
@@ -1282,8 +1680,11 @@ declare namespace $ {
|
|
|
1282
1680
|
get store(): $mol_db_store<$mol_db_store_schema>;
|
|
1283
1681
|
get transaction(): $mol_db_transaction<$mol_db_schema>;
|
|
1284
1682
|
get db(): $mol_db_database<$mol_db_schema>;
|
|
1683
|
+
/** Counts Documents by key(s) */
|
|
1285
1684
|
count(keys?: Schema['Key'] | IDBKeyRange): Promise<number>;
|
|
1685
|
+
/** Returns Document by primary key. */
|
|
1286
1686
|
get(key: Schema['Key']): Promise<Schema["Doc"] | undefined>;
|
|
1687
|
+
/** Selects Documents by primary keys. */
|
|
1287
1688
|
select(key?: Schema['Key'] | IDBKeyRange | null, count?: number): Promise<Schema["Doc"][]>;
|
|
1288
1689
|
}
|
|
1289
1690
|
}
|
|
@@ -1303,15 +1704,29 @@ declare namespace $ {
|
|
|
1303
1704
|
}
|
|
1304
1705
|
|
|
1305
1706
|
declare namespace $ {
|
|
1707
|
+
/** IndexedDB instance wrapper. */
|
|
1306
1708
|
class $mol_db_database<Schema extends $mol_db_schema> {
|
|
1307
1709
|
readonly native: IDBDatabase;
|
|
1308
1710
|
constructor(native: IDBDatabase);
|
|
1711
|
+
/** Returns database name. */
|
|
1309
1712
|
get name(): string;
|
|
1713
|
+
/** Returns database schema version. */
|
|
1310
1714
|
get version(): number;
|
|
1715
|
+
/** Returns all stores names. */
|
|
1311
1716
|
get stores(): (keyof Schema)[];
|
|
1312
|
-
|
|
1717
|
+
/** Create read-only transaction. */
|
|
1718
|
+
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;
|
|
1719
|
+
/** Create read/write transaction. */
|
|
1313
1720
|
change<Names extends Exclude<keyof Schema, symbol | number>>(...names: Names[]): $mol_db_transaction<Pick<Schema, Names>>;
|
|
1721
|
+
/**
|
|
1722
|
+
* Deletes database.
|
|
1723
|
+
* DB can be deleted only after end of all transactions.
|
|
1724
|
+
*/
|
|
1314
1725
|
kill(): Promise<IDBDatabase>;
|
|
1726
|
+
/**
|
|
1727
|
+
* Closes DB connection.
|
|
1728
|
+
* Connection really be closed only after end of all transactions.
|
|
1729
|
+
*/
|
|
1315
1730
|
destructor(): void;
|
|
1316
1731
|
}
|
|
1317
1732
|
}
|
|
@@ -1320,13 +1735,19 @@ interface IDBTransaction {
|
|
|
1320
1735
|
commit(): void;
|
|
1321
1736
|
}
|
|
1322
1737
|
declare namespace $ {
|
|
1738
|
+
/** IndexedDB Transaction wrapper. */
|
|
1323
1739
|
class $mol_db_transaction<Schema extends $mol_db_schema> {
|
|
1324
1740
|
readonly native: IDBTransaction;
|
|
1325
1741
|
constructor(native: IDBTransaction);
|
|
1742
|
+
/** Returns dictionary of all existen Stores. */
|
|
1326
1743
|
get stores(): { [Name in keyof Schema]: $mol_db_store<Schema[Name]>; };
|
|
1744
|
+
/** Creates new Store */
|
|
1327
1745
|
store_make(name: string): IDBObjectStore;
|
|
1746
|
+
/** Drops existen Store */
|
|
1328
1747
|
store_drop(name: string): this;
|
|
1748
|
+
/** Instant abort transaction. Any errors aborts transactions automatically. */
|
|
1329
1749
|
abort(): void;
|
|
1750
|
+
/** Instant commits transaction. Without errors commit proceed automatically later. */
|
|
1330
1751
|
commit(): Promise<void>;
|
|
1331
1752
|
get db(): $mol_db_database<$mol_db_schema>;
|
|
1332
1753
|
}
|