mam 1.11.921 → 1.11.923

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/node.d.ts CHANGED
@@ -16,11 +16,17 @@ declare namespace $ {
16
16
 
17
17
  declare namespace $ {
18
18
  const $mol_ambient_ref: unique symbol;
19
+ /** @deprecated use $ instead */
19
20
  type $mol_ambient_context = $;
20
21
  function $mol_ambient(this: $ | void, overrides: Partial<$>): $;
21
22
  }
22
23
 
23
24
  declare namespace $ {
25
+ /**
26
+ * Proxy that delegates all to lazy returned target.
27
+ *
28
+ * $mol_delegate( Array.prototype , ()=> fetch_array() )
29
+ */
24
30
  function $mol_delegate<Value extends object>(proto: Value, target: () => Value): Value;
25
31
  }
26
32
 
@@ -90,57 +96,130 @@ declare namespace $ {
90
96
  }
91
97
 
92
98
  declare namespace $ {
99
+ /** Generates unique identifier. */
93
100
  function $mol_guid(length?: number, exists?: (id: string) => boolean): string;
94
101
  }
95
102
 
96
103
  declare namespace $ {
104
+ /** Special status statuses. */
97
105
  enum $mol_wire_cursor {
106
+ /** Update required. */
98
107
  stale = -1,
108
+ /** Some of (transitive) pub update required. */
99
109
  doubt = -2,
110
+ /** Actual state but may be dropped. */
100
111
  fresh = -3,
112
+ /** State will never be changed. */
101
113
  final = -4
102
114
  }
103
115
  }
104
116
 
105
117
  declare namespace $ {
118
+ /**
119
+ * Collects subscribers in compact array. 28B
120
+ */
106
121
  class $mol_wire_pub extends Object {
107
122
  constructor(id?: string);
108
123
  [Symbol.toStringTag]: string;
109
124
  data: unknown[];
110
125
  static get [Symbol.species](): ArrayConstructor;
126
+ /**
127
+ * Index of first subscriber.
128
+ */
111
129
  protected sub_from: number;
130
+ /**
131
+ * All current subscribers.
132
+ */
112
133
  get sub_list(): readonly $mol_wire_sub[];
134
+ /**
135
+ * Has any subscribers or not.
136
+ */
113
137
  get sub_empty(): boolean;
138
+ /**
139
+ * Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
140
+ */
114
141
  sub_on(sub: $mol_wire_pub, pub_pos: number): number;
142
+ /**
143
+ * Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
144
+ */
115
145
  sub_off(sub_pos: number): void;
146
+ /**
147
+ * Called when last sub was unsubscribed.
148
+ **/
116
149
  reap(): void;
150
+ /**
151
+ * Autowire this publisher with current subscriber.
152
+ **/
117
153
  promote(): void;
154
+ /**
155
+ * Enforce actualization. Should not throw errors.
156
+ */
118
157
  fresh(): void;
158
+ /**
159
+ * Allow to put data to caches in the subtree.
160
+ */
119
161
  complete(): void;
120
162
  get incompleted(): boolean;
163
+ /**
164
+ * Notify subscribers about self changes.
165
+ */
121
166
  emit(quant?: $mol_wire_cursor): void;
167
+ /**
168
+ * Moves peer from one position to another. Doesn't clear data at old position!
169
+ */
122
170
  peer_move(from_pos: number, to_pos: number): void;
171
+ /**
172
+ * Updates self position in the peer.
173
+ */
123
174
  peer_repos(peer_pos: number, self_pos: number): void;
124
175
  }
125
176
  }
126
177
 
127
178
  declare namespace $ {
179
+ /** Generic subscriber interface */
128
180
  interface $mol_wire_sub extends $mol_wire_pub {
129
181
  temp: boolean;
130
182
  pub_list: $mol_wire_pub[];
183
+ /**
184
+ * Begin auto wire to publishers.
185
+ * Returns previous auto subscriber that must me transfer to the `end`.
186
+ */
131
187
  track_on(): $mol_wire_sub | null;
188
+ /**
189
+ * Returns next auto wired publisher. It can be easely repormoted.
190
+ * Or promotes next publisher to auto wire its togeter.
191
+ * Must be used only between `track_on` and `track_off`.
192
+ */
132
193
  track_next(pub?: $mol_wire_pub): $mol_wire_pub | null;
133
194
  pub_off(pub_pos: number): void;
195
+ /**
196
+ * Unsubscribes from unpromoted publishers.
197
+ */
134
198
  track_cut(sub: $mol_wire_pub | null): void;
199
+ /**
200
+ * Ends auto wire to publishers.
201
+ */
135
202
  track_off(sub: $mol_wire_pub | null): void;
203
+ /**
204
+ * Receive notification about publisher changes.
205
+ */
136
206
  absorb(quant: $mol_wire_cursor, pos: number): void;
207
+ /**
208
+ * Unsubscribes from all publishers.
209
+ */
137
210
  destructor(): void;
138
211
  }
139
212
  }
140
213
 
141
214
  declare namespace $ {
142
215
  let $mol_wire_auto_sub: $mol_wire_sub | null;
216
+ /**
217
+ * When fulfilled, all publishers are promoted to this subscriber on access to its.
218
+ */
143
219
  function $mol_wire_auto(next?: $mol_wire_sub | null): $mol_wire_sub | null;
220
+ /**
221
+ * Affection queue. Used to prevent accidental stack overflow on emit.
222
+ */
144
223
  const $mol_wire_affected: ($mol_wire_sub | number)[];
145
224
  }
146
225
 
@@ -173,6 +252,13 @@ declare namespace $ {
173
252
  }
174
253
 
175
254
  declare namespace $ {
255
+ /**
256
+ * Publisher that can auto collect other publishers. 32B
257
+ *
258
+ * P1 P2 P3 P4 S1 S2 S3
259
+ * ^ ^
260
+ * pubs_from subs_from
261
+ */
176
262
  class $mol_wire_pub_sub extends $mol_wire_pub implements $mol_wire_sub {
177
263
  protected pub_from: number;
178
264
  protected cursor: $mol_wire_cursor;
@@ -189,6 +275,9 @@ declare namespace $ {
189
275
  complete_pubs(): void;
190
276
  absorb(quant?: $mol_wire_cursor, pos?: number): void;
191
277
  [$mol_dev_format_head](): any[];
278
+ /**
279
+ * Is subscribed to any publisher or not.
280
+ */
192
281
  get pub_empty(): boolean;
193
282
  }
194
283
  }
@@ -208,6 +297,13 @@ declare namespace $ {
208
297
  }
209
298
 
210
299
  declare namespace $ {
300
+ /**
301
+ * Suspendable task with support both sync/async api.
302
+ *
303
+ * A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
304
+ * ^ ^ ^
305
+ * args_from pubs_from subs_from
306
+ **/
211
307
  abstract class $mol_wire_fiber<Host, Args extends readonly unknown[], Result> extends $mol_wire_pub_sub {
212
308
  readonly task: (this: Host, ...args: Args) => Result;
213
309
  readonly host?: Host | undefined;
@@ -234,7 +330,15 @@ declare namespace $ {
234
330
  fresh(): this | undefined;
235
331
  refresh(): void;
236
332
  abstract put(next: Result | Error | Promise<Result | Error>): Result | Error | Promise<Result | Error>;
333
+ /**
334
+ * Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
335
+ * Should be called inside SuspenseAPI consumer (ie fiber).
336
+ */
237
337
  sync(): Awaited<Result>;
338
+ /**
339
+ * Asynchronous execution.
340
+ * It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
341
+ */
238
342
  async_raw(): Promise<Result>;
239
343
  async(): Promise<Result> & {
240
344
  destructor(): void;
@@ -246,31 +350,48 @@ declare namespace $ {
246
350
 
247
351
  declare namespace $ {
248
352
  let $mol_compare_deep_cache: WeakMap<any, WeakMap<any, boolean>>;
353
+ /**
354
+ * Deeply compares two values. Returns true if equal.
355
+ * Define `Symbol.toPrimitive` to customize.
356
+ */
249
357
  function $mol_compare_deep<Value>(left: Value, right: Value): boolean;
250
358
  }
251
359
 
252
360
  declare namespace $ {
361
+ /** Logger event data */
253
362
  type $mol_log3_event<Fields> = {
254
363
  [key in string]: unknown;
255
364
  } & {
365
+ /** Time of event creation */
256
366
  time?: string;
367
+ /** Place of event creation */
257
368
  place: unknown;
369
+ /** Short description of event */
258
370
  message: string;
259
371
  } & Fields;
372
+ /** Logger function */
260
373
  type $mol_log3_logger<Fields, Res = void> = (this: $, event: $mol_log3_event<Fields>) => Res;
374
+ /** Log begin of some task */
261
375
  let $mol_log3_come: $mol_log3_logger<{}>;
376
+ /** Log end of some task */
262
377
  let $mol_log3_done: $mol_log3_logger<{}>;
378
+ /** Log error */
263
379
  let $mol_log3_fail: $mol_log3_logger<{}>;
380
+ /** Log warning message */
264
381
  let $mol_log3_warn: $mol_log3_logger<{
265
382
  hint: string;
266
383
  }>;
384
+ /** Log some generic event */
267
385
  let $mol_log3_rise: $mol_log3_logger<{}>;
386
+ /** Log begin of log group, returns func to close group */
268
387
  let $mol_log3_area: $mol_log3_logger<{}, () => void>;
388
+ /** Log begin of collapsed group only when some logged inside, returns func to close group */
269
389
  function $mol_log3_area_lazy(this: $, event: $mol_log3_event<{}>): () => void;
270
390
  let $mol_log3_stack: (() => void)[];
271
391
  }
272
392
 
273
393
  declare namespace $ {
394
+ /** Position in any resource. */
274
395
  class $mol_span extends $mol_object2 {
275
396
  readonly uri: string;
276
397
  readonly source: string;
@@ -278,9 +399,13 @@ declare namespace $ {
278
399
  readonly col: number;
279
400
  readonly length: number;
280
401
  constructor(uri: string, source: string, row: number, col: number, length: number);
402
+ /** Span for begin of unknown resource */
281
403
  static unknown: $mol_span;
404
+ /** Makes new span for begin of resource. */
282
405
  static begin(uri: string, source?: string): $mol_span;
406
+ /** Makes new span for end of resource. */
283
407
  static end(uri: string, source: string): $mol_span;
408
+ /** Makes new span for entire resource. */
284
409
  static entire(uri: string, source: string): $mol_span;
285
410
  toString(): string;
286
411
  toJSON(): {
@@ -289,14 +414,19 @@ declare namespace $ {
289
414
  col: number;
290
415
  length: number;
291
416
  };
417
+ /** Makes new error for this span. */
292
418
  error(message: string, Class?: ErrorConstructor): Error;
419
+ /** Makes new span for same uri. */
293
420
  span(row: number, col: number, length: number): $mol_span;
421
+ /** Makes new span after end of this. */
294
422
  after(length?: number): $mol_span;
423
+ /** Makes new span between begin and end. */
295
424
  slice(begin: number, end?: number): $mol_span;
296
425
  }
297
426
  }
298
427
 
299
428
  declare namespace $ {
429
+ /** Serializes tree to string in tree format. */
300
430
  function $mol_tree2_to_string(this: $, tree: $mol_tree2): string;
301
431
  }
302
432
 
@@ -305,37 +435,74 @@ declare namespace $ {
305
435
  }
306
436
 
307
437
  declare namespace $ {
438
+ /** Path by types in tree. */
308
439
  type $mol_tree2_path = Array<string | number | null>;
440
+ /** Hask tool for processing node. */
309
441
  type $mol_tree2_hack<Context> = (input: $mol_tree2, belt: $mol_tree2_belt<Context>, context: Context) => readonly $mol_tree2[];
442
+ /** Collection of hask tools for processing tree. */
310
443
  type $mol_tree2_belt<Context> = Record<string, $mol_tree2_hack<Context>>;
444
+ /**
445
+ * Abstract Syntax Tree with human readable serialization.
446
+ * Avoid direct instantiation. Use static factories instead.
447
+ * @see https://github.com/nin-jin/tree.d
448
+ */
311
449
  class $mol_tree2 extends Object {
450
+ /** Type of structural node, `value` should be empty */
312
451
  readonly type: string;
452
+ /** Content of data node, `type` should be empty */
313
453
  readonly value: string;
454
+ /** Child nodes */
314
455
  readonly kids: readonly $mol_tree2[];
456
+ /** Position in most far source resource */
315
457
  readonly span: $mol_span;
316
- constructor(type: string, value: string, kids: readonly $mol_tree2[], span: $mol_span);
458
+ constructor(
459
+ /** Type of structural node, `value` should be empty */
460
+ type: string,
461
+ /** Content of data node, `type` should be empty */
462
+ value: string,
463
+ /** Child nodes */
464
+ kids: readonly $mol_tree2[],
465
+ /** Position in most far source resource */
466
+ span: $mol_span);
467
+ /** Makes collection node. */
317
468
  static list(kids: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
469
+ /** Makes new derived collection node. */
318
470
  list(kids: readonly $mol_tree2[]): $mol_tree2;
471
+ /** Makes data node for any string. */
319
472
  static data(value: string, kids?: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
473
+ /** Makes new derived data node. */
320
474
  data(value: string, kids?: readonly $mol_tree2[]): $mol_tree2;
475
+ /** Makes struct node. */
321
476
  static struct(type: string, kids?: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
477
+ /** Makes new derived structural node. */
322
478
  struct(type: string, kids?: readonly $mol_tree2[]): $mol_tree2;
479
+ /** Makes new derived node with different kids id defined. */
323
480
  clone(kids: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
481
+ /** Returns multiline text content. */
324
482
  text(): string;
483
+ /** Parses tree format. */
484
+ /** @deprecated Use $mol_tree2_from_string */
325
485
  static fromString(str: string, uri?: string): $mol_tree2;
486
+ /** Serializes to tree format. */
326
487
  toString(): string;
488
+ /** Makes new tree with node overrided by path. */
327
489
  insert(value: $mol_tree2 | null, ...path: $mol_tree2_path): $mol_tree2;
490
+ /** Makes new tree with node overrided by path. */
328
491
  update(value: readonly $mol_tree2[], ...path: $mol_tree2_path): readonly $mol_tree2[];
492
+ /** Query nodes by path. */
329
493
  select(...path: $mol_tree2_path): $mol_tree2;
494
+ /** Filter kids by path or value. */
330
495
  filter(path: string[], value?: string): $mol_tree2;
331
496
  hack_self<Context extends {
332
497
  span?: $mol_span;
333
498
  [key: string]: unknown;
334
499
  } = {}>(belt: $mol_tree2_belt<Context>, context?: Context): readonly $mol_tree2[];
500
+ /** Transform tree through context with transformers */
335
501
  hack<Context extends {
336
502
  span?: $mol_span;
337
503
  [key: string]: unknown;
338
504
  } = {}>(belt: $mol_tree2_belt<Context>, context?: Context): $mol_tree2[];
505
+ /** Makes Error with node coordinates. */
339
506
  error(message: string, Class?: ErrorConstructor): Error;
340
507
  }
341
508
  class $mol_tree2_empty extends $mol_tree2 {
@@ -344,6 +511,7 @@ declare namespace $ {
344
511
  }
345
512
 
346
513
  declare namespace $ {
514
+ /** Syntax error with cordinates and source line snippet. */
347
515
  class $mol_error_syntax extends SyntaxError {
348
516
  reason: string;
349
517
  line: string;
@@ -353,6 +521,7 @@ declare namespace $ {
353
521
  }
354
522
 
355
523
  declare namespace $ {
524
+ /** Parses tree format from string. */
356
525
  function $mol_tree2_from_string(this: $, str: string, uri?: string): $mol_tree2;
357
526
  }
358
527
 
@@ -365,6 +534,7 @@ declare namespace $ {
365
534
  }
366
535
 
367
536
  declare namespace $ {
537
+ /** Module for working with terminal. Text coloring when output in terminal */
368
538
  class $mol_term_color {
369
539
  static reset: (str: string) => string;
370
540
  static bold: (str: string) => string;
@@ -396,6 +566,7 @@ declare namespace $ {
396
566
  }
397
567
 
398
568
  declare namespace $ {
569
+ /** One-shot fiber */
399
570
  class $mol_wire_task<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
400
571
  static getter<Host, Args extends readonly unknown[], Result>(task: (this: Host, ...args: Args) => Result): (host: Host, args: Args) => $mol_wire_task<Host, Args, Result>;
401
572
  get temp(): boolean;
@@ -406,6 +577,7 @@ declare namespace $ {
406
577
  }
407
578
 
408
579
  declare namespace $ {
580
+ /** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
409
581
  export function $mol_wire_async<Host extends object>(obj: Host): ObjectOrFunctionResultPromisify<Host>;
410
582
  type FunctionResultPromisify<Some> = Some extends (...args: infer Args) => infer Res ? Res extends PromiseLike<unknown> ? Some : (...args: Args) => Promise<Res> : Some;
411
583
  type MethodsResultPromisify<Host extends Object> = {
@@ -428,6 +600,7 @@ declare namespace $ {
428
600
  }
429
601
 
430
602
  declare namespace $ {
603
+ /** Returns string key for any value. */
431
604
  function $mol_key<Value>(value: Value): string;
432
605
  }
433
606
 
@@ -449,6 +622,9 @@ declare namespace $ {
449
622
  }
450
623
 
451
624
  declare namespace $ {
625
+ /**
626
+ * Decorates method to fiber to ensure it is executed only once inside other fiber.
627
+ */
452
628
  function $mol_wire_method<Host extends object, Args extends readonly any[]>(host: Host, field: PropertyKey, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
453
629
  value: (this: Host, ...args: Args) => any;
454
630
  enumerable?: boolean;
@@ -460,14 +636,25 @@ declare namespace $ {
460
636
  }
461
637
 
462
638
  declare namespace $ {
639
+ /**
640
+ * Returns `Tuple` without first element.
641
+ *
642
+ * $mol_type_tail<[ 1 , 2 , 3 ]> // [ 2, 3 ]
643
+ */
463
644
  type $mol_type_tail<Tuple extends readonly any[]> = ((...tail: Tuple) => any) extends ((head: any, ...tail: infer Tail) => any) ? Tail : never;
464
645
  }
465
646
 
466
647
  declare namespace $ {
648
+ /**
649
+ * Returns last element of `Tuple`.
650
+ *
651
+ * $mol_type_tail<[ 1 , 2 , 3 ]> // 3
652
+ */
467
653
  type $mol_type_foot<Tuple extends readonly any[]> = Tuple['length'] extends 0 ? never : Tuple[$mol_type_tail<Tuple>['length']];
468
654
  }
469
655
 
470
656
  declare namespace $ {
657
+ /** Long-living fiber. */
471
658
  class $mol_wire_atom<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
472
659
  static solo<Host, Args extends readonly unknown[], Result>(host: Host, task: (this: Host, ...args: Args) => Result): $mol_wire_atom<Host, Args, Result>;
473
660
  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>;
@@ -475,6 +662,9 @@ declare namespace $ {
475
662
  static watcher: $mol_after_frame | null;
476
663
  static watch(): void;
477
664
  watch(): void;
665
+ /**
666
+ * Update atom value through another temp fiber.
667
+ */
478
668
  resync(args: Args): Error | Result | Promise<Error | Result>;
479
669
  once(): Awaited<Result>;
480
670
  channel(): ((next?: $mol_type_foot<Args>) => Awaited<Result>) & {
@@ -486,12 +676,14 @@ declare namespace $ {
486
676
  }
487
677
 
488
678
  declare namespace $ {
679
+ /** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
489
680
  export function $mol_wire_solo<Args extends any[]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): TypedPropertyDescriptor<(...args: First_optional<Args>) => any>;
490
681
  type First_optional<Args extends any[]> = Args extends [] ? [] : [Args[0] | undefined, ...$mol_type_tail<Args>];
491
682
  export {};
492
683
  }
493
684
 
494
685
  declare namespace $ {
686
+ /** Reactive memoizing multiplexed property decorator. */
495
687
  function $mol_wire_plex<Args extends [any, ...any[]]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
496
688
  value: (this: typeof host, ...args: Args) => any;
497
689
  enumerable?: boolean;
@@ -503,11 +695,33 @@ declare namespace $ {
503
695
  }
504
696
 
505
697
  declare namespace $ {
698
+ /**
699
+ * Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
700
+ * @example
701
+ * '@' $mol_mem
702
+ * name(next?: string) {
703
+ * return next ?? 'default'
704
+ * }
705
+ * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
706
+ */
506
707
  let $mol_mem: typeof $mol_wire_solo;
708
+ /**
709
+ * Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
710
+ * @example
711
+ * '@' $mol_mem_key
712
+ * name(id: number, next?: string) {
713
+ * return next ?? 'default'
714
+ * }
715
+ * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
716
+ */
507
717
  let $mol_mem_key: typeof $mol_wire_plex;
508
718
  }
509
719
 
510
720
  declare namespace $ {
721
+ /**
722
+ * Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
723
+ * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
724
+ */
511
725
  export function $mol_wire_sync<Host extends object>(obj: Host): ObjectOrFunctionResultAwaited<Host>;
512
726
  type FunctionResultAwaited<Some> = Some extends (...args: infer Args) => infer Res ? (...args: Args) => Awaited<Res> : Some;
513
727
  type ConstructorResultAwaited<Some> = Some extends new (...args: infer Args) => infer Res ? new (...args: Args) => Res : {};
@@ -553,6 +767,7 @@ interface $node {
553
767
  declare var $node: $node;
554
768
 
555
769
  declare namespace $ {
770
+ /** Run code without state changes */
556
771
  function $mol_wire_probe<Value>(task: () => Value, def?: Value): Value | undefined;
557
772
  }
558
773
 
@@ -631,6 +846,10 @@ declare namespace $ {
631
846
  }
632
847
 
633
848
  declare namespace $ {
849
+ /**
850
+ * Decorates method to fiber to ensure it is executed only once inside other fiber from [mol_wire](../wire/README.md)
851
+ * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
852
+ */
634
853
  let $mol_action: typeof $mol_wire_method;
635
854
  }
636
855
 
@@ -700,6 +919,11 @@ declare namespace $ {
700
919
  }
701
920
 
702
921
  declare namespace $ {
922
+ /**
923
+ * Returns closure that returns constant value.
924
+ * @example
925
+ * const rnd = $mol_const( Math.random() )
926
+ */
703
927
  function $mol_const<Value>(value: Value): {
704
928
  (): Value;
705
929
  '()': Value;
@@ -731,6 +955,7 @@ declare namespace $ {
731
955
  }
732
956
 
733
957
  declare namespace $ {
958
+ /** Temporary buffer. Recursive usage isn't supported. */
734
959
  function $mol_charset_buffer(size: number): Uint8Array<ArrayBuffer>;
735
960
  }
736
961
 
@@ -761,6 +986,9 @@ declare namespace $ {
761
986
  }
762
987
 
763
988
  declare namespace $ {
989
+ /**
990
+ * Disable reaping of current subscriber
991
+ */
764
992
  function $mol_wire_solid(): void;
765
993
  }
766
994
 
@@ -793,6 +1021,10 @@ declare namespace $ {
793
1021
  protected static changed: Set<$mol_file_base>;
794
1022
  protected static frame: null | $mol_after_timeout;
795
1023
  protected static changed_add(type: 'change' | 'rename', path: string): void;
1024
+ /**
1025
+ * Должно быть больше, чем время между событиями от вотчера при записи внешним процессом.
1026
+ * Иначе запуск ресетов паралельно с изменением может привести к неконсистентности.
1027
+ */
796
1028
  static watch_debounce(): number;
797
1029
  static flush(): void;
798
1030
  protected static watching: boolean;
@@ -922,25 +1154,49 @@ declare namespace $ {
922
1154
  }
923
1155
 
924
1156
  declare namespace $ {
925
- type $mol_type_equals<A, B> = (<X>() => X extends A ? 1 : 2) extends (<X>() => X extends B ? 1 : 2) ? unknown : never;
1157
+ /**
1158
+ * Return `unknown` when `A` and `B` are the same type. `never` otherwise.
1159
+ *
1160
+ * $mol_type_equals< unknown , any > & number // true
1161
+ * $mol_type_equals< never , never > & number // false
1162
+ */
1163
+ type $mol_type_equals<A, B> = (<X>() => X extends A ? 1 : 2) extends (<X>() => X extends B ? 1 : 2) ? true : false;
926
1164
  }
927
1165
 
928
1166
  declare namespace $ {
929
- type $mol_type_merge<Intersection> = Intersection extends (...a: any[]) => any ? Intersection : Intersection extends new (...a: any[]) => any ? Intersection : Intersection extends object ? $mol_type_merge_object<Intersection> extends Intersection ? unknown extends $mol_type_equals<{
1167
+ /**
1168
+ * Reqursive converts intersection of records to record of intersections
1169
+ *
1170
+ * // { a : { x : 1 , y : 2 } }
1171
+ * $mol_type_merge< { a : { x : 1 } }&{ a : { y : 2 } } >
1172
+ */
1173
+ type $mol_type_merge<Intersection> = Intersection extends (...a: any[]) => any ? Intersection : Intersection extends new (...a: any[]) => any ? Intersection : Intersection extends object ? $mol_type_merge_object<Intersection> extends Intersection ? true extends $mol_type_equals<{
930
1174
  [Key in keyof Intersection]: Intersection[Key];
931
1175
  }, Intersection> ? Intersection : {
932
1176
  [Key in keyof Intersection]: $mol_type_merge<Intersection[Key]>;
933
1177
  } : Intersection : Intersection;
1178
+ /**
1179
+ * Flat converts intersection of records to record of intersections
1180
+ *
1181
+ * // { a: 1, b: 2 }
1182
+ * $mol_type_merge< { a: 1 } & { b: 2 } >
1183
+ */
934
1184
  type $mol_type_merge_object<Intersection> = {
935
1185
  [Key in keyof Intersection]: Intersection[Key];
936
1186
  };
937
1187
  }
938
1188
 
939
1189
  declare namespace $ {
1190
+ /**
1191
+ * Converts union of types to intersection of same types
1192
+ *
1193
+ * $mol_type_intersect< number | string > // number & string
1194
+ */
940
1195
  type $mol_type_intersect<Union> = (Union extends any ? (_: Union) => void : never) extends ((_: infer Intersection) => void) ? Intersection : never;
941
1196
  }
942
1197
 
943
1198
  declare namespace $ {
1199
+ /** Replaces properties of `Base` record by properties from `Over`. */
944
1200
  type $mol_type_override<Base, Over> = Omit<Base, keyof Over> & Over;
945
1201
  }
946
1202
 
@@ -973,15 +1229,19 @@ declare namespace $ {
973
1229
  readonly [k in key]: Source[key] extends string ? Source[key] : string;
974
1230
  }> & $mol_regexp_groups<Source[key]>>;
975
1231
  }[keyof Source]>> : never;
1232
+ /** Type safe reguar expression builder */
976
1233
  export class $mol_regexp<Groups extends Record<string, string>> extends RegExp {
977
1234
  readonly groups: (Extract<keyof Groups, string>)[];
1235
+ /** Prefer to use $mol_regexp.from */
978
1236
  constructor(source: string, flags?: string, groups?: (Extract<keyof Groups, string>)[]);
979
1237
  [Symbol.matchAll](str: string): RegExpStringIterator<RegExpExecArray & $mol_type_override<RegExpExecArray, {
980
1238
  groups?: {
981
1239
  [key in keyof Groups]: string;
982
1240
  };
983
1241
  }>>;
1242
+ /** Parses input and returns found capture groups or null */
984
1243
  [Symbol.match](str: string): null | RegExpMatchArray;
1244
+ /** Splits string by regexp edges */
985
1245
  [Symbol.split](str: string): string[];
986
1246
  test(str: string): boolean;
987
1247
  exec(str: string): RegExpExecArray & $mol_type_override<RegExpExecArray, {
@@ -991,6 +1251,7 @@ declare namespace $ {
991
1251
  }> | null;
992
1252
  generate(params: Groups_to_params<Groups>): string | null;
993
1253
  get native(): RegExp;
1254
+ /** Makes regexp that greedy repeats this pattern with delimiter */
994
1255
  static separated<Chunk extends $mol_regexp_source, Sep extends $mol_regexp_source>(chunk: Chunk, sep: Sep): $mol_regexp<[$mol_regexp<[[Chunk], Sep] extends infer T ? T extends [[Chunk], Sep] ? T extends $mol_regexp_source[] ? $mol_type_merge<$mol_type_intersect<{ [key in Extract<keyof T, number>]: $mol_regexp_groups<T[key]>; }[Extract<keyof T, number>]>> : T extends RegExp ? Record<string, string> extends NonNullable<NonNullable<ReturnType<T["exec"]>>["groups"]> ? {} : NonNullable<NonNullable<ReturnType<T["exec"]>>["groups"]> : T extends {
995
1256
  readonly [x: string]: $mol_regexp_source;
996
1257
  } ? $mol_type_merge<$mol_type_intersect<{ [key_1 in keyof T]: $mol_type_merge<Omit<{ readonly [k in Extract<keyof T, string>]: string; }, key_1> & { readonly [k_1 in key_1]: T[key_1] extends string ? T[key_1] : string; } & $mol_regexp_groups<T[key_1]>>; }[keyof T]>> : never : never : never>, Chunk] extends infer T_1 ? T_1 extends [$mol_regexp<[[Chunk], Sep] extends infer T_2 ? T_2 extends [[Chunk], Sep] ? T_2 extends $mol_regexp_source[] ? $mol_type_merge<$mol_type_intersect<{ [key_4 in Extract<keyof T_2, number>]: $mol_regexp_groups<T_2[key_4]>; }[Extract<keyof T_2, number>]>> : T_2 extends RegExp ? Record<string, string> extends NonNullable<NonNullable<ReturnType<T_2["exec"]>>["groups"]> ? {} : NonNullable<NonNullable<ReturnType<T_2["exec"]>>["groups"]> : T_2 extends {
@@ -998,14 +1259,23 @@ declare namespace $ {
998
1259
  } ? $mol_type_merge<$mol_type_intersect<{ [key_5 in keyof T_2]: $mol_type_merge<Omit<{ readonly [k in Extract<keyof T_2, string>]: string; }, key_5> & { readonly [k_1 in key_5]: T_2[key_5] extends string ? T_2[key_5] : string; } & $mol_regexp_groups<T_2[key_5]>>; }[keyof T_2]>> : never : never : never>, Chunk] ? T_1 extends $mol_regexp_source[] ? $mol_type_merge<$mol_type_intersect<{ [key_2 in Extract<keyof T_1, number>]: $mol_regexp_groups<T_1[key_2]>; }[Extract<keyof T_1, number>]>> : T_1 extends RegExp ? Record<string, string> extends NonNullable<NonNullable<ReturnType<T_1["exec"]>>["groups"]> ? {} : NonNullable<NonNullable<ReturnType<T_1["exec"]>>["groups"]> : T_1 extends {
999
1260
  readonly [x: string]: $mol_regexp_source;
1000
1261
  } ? $mol_type_merge<$mol_type_intersect<{ [key_3 in keyof T_1]: $mol_type_merge<Omit<{ readonly [k in Extract<keyof T_1, string>]: string; }, key_3> & { readonly [k_1 in key_3]: T_1[key_3] extends string ? T_1[key_3] : string; } & $mol_regexp_groups<T_1[key_3]>>; }[keyof T_1]>> : never : never : never>;
1262
+ /** Makes regexp that non-greedy repeats this pattern from min to max count */
1001
1263
  static repeat<Source extends $mol_regexp_source>(source: Source, min?: number, max?: number): $mol_regexp<$mol_regexp_groups<Source>>;
1264
+ /** Makes regexp that greedy repeats this pattern from min to max count */
1002
1265
  static repeat_greedy<Source extends $mol_regexp_source>(source: Source, min?: number, max?: number): $mol_regexp<$mol_regexp_groups<Source>>;
1266
+ /** Makes regexp that match any of options */
1003
1267
  static vary<Sources extends readonly $mol_regexp_source[]>(sources: Sources, flags?: string): $mol_regexp<$mol_regexp_groups<Sources[number]>>;
1268
+ /** Makes regexp that allow absent of this pattern */
1004
1269
  static optional<Source extends $mol_regexp_source>(source: Source): $mol_regexp<$mol_regexp_groups<Source>>;
1270
+ /** Makes regexp that look ahead for pattern */
1005
1271
  static force_after(source: $mol_regexp_source): $mol_regexp<Record<string, string>>;
1272
+ /** Makes regexp that look ahead for pattern */
1006
1273
  static forbid_after(source: $mol_regexp_source): $mol_regexp<Record<string, string>>;
1274
+ /** Converts some js values to regexp */
1007
1275
  static from<Source extends $mol_regexp_source>(source: Source, { ignoreCase, multiline }?: Partial<Pick<RegExp, 'ignoreCase' | 'multiline'>>): $mol_regexp<$mol_regexp_groups<Source>>;
1276
+ /** Makes regexp which includes only unicode category */
1008
1277
  static unicode_only(...category: $mol_unicode_category): $mol_regexp<Record<string, string>>;
1278
+ /** Makes regexp which excludes unicode category */
1009
1279
  static unicode_except(...category: $mol_unicode_category): $mol_regexp<Record<string, string>>;
1010
1280
  static char_range(from: number, to: number): $mol_regexp<{}>;
1011
1281
  static char_only(...allowed: readonly [$mol_regexp_source, ...$mol_regexp_source[]]): $mol_regexp<{}>;
@@ -1120,6 +1390,10 @@ declare namespace $ {
1120
1390
  interface $mol_locale_dict {
1121
1391
  [key: string]: string;
1122
1392
  }
1393
+ /**
1394
+ * Localisation in $mol framework
1395
+ * @see https://mol.hyoo.ru/#!section=docs/=s5aqnb_odub8l
1396
+ */
1123
1397
  class $mol_locale extends $mol_object {
1124
1398
  static lang_default(): string;
1125
1399
  static lang(next?: string): string;
@@ -1139,6 +1413,9 @@ declare namespace $ {
1139
1413
  }
1140
1414
 
1141
1415
  declare namespace $ {
1416
+ /**
1417
+ * Fails if `Actual` type is not subtype of `Expected`.
1418
+ */
1142
1419
  type $mol_type_enforce<Actual extends Expected, Expected> = Actual;
1143
1420
  }
1144
1421
 
@@ -1178,21 +1455,54 @@ declare namespace $ {
1178
1455
  }
1179
1456
 
1180
1457
  declare namespace $ {
1458
+ /**
1459
+ * # Generic Graph model
1460
+ * - Supports any type of Nodes and Edges.
1461
+ * - All links are ordered, but this may be ignored.
1462
+ * - Multigraph supported using arrays of Edges.
1463
+ * - Hypergraph supported by reusing same Edge on set of links.
1464
+ * - Ubergraph supported using Edges as Nodes to.
1465
+ **/
1181
1466
  class $mol_graph<Node, Edge> {
1467
+ /** All registered Nodes */
1182
1468
  nodes: Set<Node>;
1469
+ /** Edges for Nodes pairs (from-to-edge) */
1183
1470
  edges_out: Map<Node, Map<Node, Edge>>;
1471
+ /** Edges for Nodes pairs (to-from-edge) */
1184
1472
  edges_in: Map<Node, Map<Node, Edge>>;
1473
+ /** Full connect two Nodes */
1185
1474
  link(from: Node, to: Node, edge: Edge): void;
1475
+ /** Full disconnect two Nodes */
1186
1476
  unlink(from: Node, to: Node): void;
1477
+ /** Forward connect two Nodes */
1187
1478
  link_out(from: Node, to: Node, edge: Edge): void;
1479
+ /** Backward connect two Nodes */
1188
1480
  link_in(to: Node, from: Node, edge: Edge): void;
1481
+ /** Return any Edge for two Nodes or null */
1189
1482
  edge(from: Node, to: Node): NonNullable<Edge> | null;
1483
+ /** Return output Edge for two Nodes or null */
1190
1484
  edge_out(from: Node, to: Node): NonNullable<Edge> | null;
1485
+ /** Return input Edge for two Nodes or null */
1191
1486
  edge_in(to: Node, from: Node): NonNullable<Edge> | null;
1487
+ /** Cut cycles at lowest priority of Edges */
1192
1488
  acyclic(get_weight: (edge: Edge) => number): void;
1489
+ /** Topoligical ordered set of all Nodes for acyclic graph */
1193
1490
  get sorted(): Set<Node>;
1491
+ /** All Nodes which don't have input Edges */
1194
1492
  get roots(): Node[];
1493
+ /**
1494
+ * Nodes depth statistics for acyclic graph
1495
+ * @example
1496
+ * graph.depth_stat( Math.min )
1497
+ * graph.depth_stat( Math.max )
1498
+ **/
1195
1499
  nodes_depth(select: (left: number, right: number) => number): Map<Node, number>;
1500
+ /**
1501
+ * Depth's Nodes statistics for acyclic graph
1502
+ * @example
1503
+ * graph.depth_nodes( Math.min )
1504
+ * graph.depth_nodes( Math.max )
1505
+ **/
1196
1506
  depth_nodes(select: (left: number, right: number) => number): Node[][];
1197
1507
  }
1198
1508
  }
@@ -1555,6 +1865,10 @@ declare namespace $ {
1555
1865
  socket(): import("ws").Server<typeof import("ws").default, typeof import("node:http").IncomingMessage>;
1556
1866
  start(): import("ws").Server<typeof import("ws").default, typeof import("node:http").IncomingMessage>;
1557
1867
  protected bundles_count(reset?: null): number;
1868
+ /**
1869
+ * Держать в памяти собранные бандлы плохо, т.к. gc их может долго не утилизировать и node сожрет память и упадет.
1870
+ * Логичнее удалять отложенно, после того как reload-сокет отписался от пути и повторно не подписался.
1871
+ */
1558
1872
  protected bundles_keep(): void;
1559
1873
  protected path_bundles: Record<string, Set<string>>;
1560
1874
  protected path_doubted: Set<string>;