mol_view_tree2_lib 1.0.196 → 1.0.198

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
 
@@ -82,6 +88,7 @@ declare namespace $ {
82
88
  }
83
89
 
84
90
  declare namespace $ {
91
+ /** Position in any resource. */
85
92
  class $mol_span extends $mol_object2 {
86
93
  readonly uri: string;
87
94
  readonly source: string;
@@ -89,9 +96,13 @@ declare namespace $ {
89
96
  readonly col: number;
90
97
  readonly length: number;
91
98
  constructor(uri: string, source: string, row: number, col: number, length: number);
99
+ /** Span for begin of unknown resource */
92
100
  static unknown: $mol_span;
101
+ /** Makes new span for begin of resource. */
93
102
  static begin(uri: string, source?: string): $mol_span;
103
+ /** Makes new span for end of resource. */
94
104
  static end(uri: string, source: string): $mol_span;
105
+ /** Makes new span for entire resource. */
95
106
  static entire(uri: string, source: string): $mol_span;
96
107
  toString(): string;
97
108
  toJSON(): {
@@ -100,14 +111,19 @@ declare namespace $ {
100
111
  col: number;
101
112
  length: number;
102
113
  };
114
+ /** Makes new error for this span. */
103
115
  error(message: string, Class?: ErrorConstructor): Error;
116
+ /** Makes new span for same uri. */
104
117
  span(row: number, col: number, length: number): $mol_span;
118
+ /** Makes new span after end of this. */
105
119
  after(length?: number): $mol_span;
120
+ /** Makes new span between begin and end. */
106
121
  slice(begin: number, end?: number): $mol_span;
107
122
  }
108
123
  }
109
124
 
110
125
  declare namespace $ {
126
+ /** Syntax error with cordinates and source line snippet. */
111
127
  class $mol_error_syntax extends SyntaxError {
112
128
  reason: string;
113
129
  line: string;
@@ -117,10 +133,12 @@ declare namespace $ {
117
133
  }
118
134
 
119
135
  declare namespace $ {
136
+ /** Parses tree format from string. */
120
137
  function $mol_tree2_from_string(this: $, str: string, uri?: string): $mol_tree2;
121
138
  }
122
139
 
123
140
  declare namespace $ {
141
+ /** Serializes tree to string in tree format. */
124
142
  function $mol_tree2_to_string(this: $, tree: $mol_tree2): string;
125
143
  }
126
144
 
@@ -129,37 +147,74 @@ declare namespace $ {
129
147
  }
130
148
 
131
149
  declare namespace $ {
150
+ /** Path by types in tree. */
132
151
  type $mol_tree2_path = Array<string | number | null>;
152
+ /** Hask tool for processing node. */
133
153
  type $mol_tree2_hack<Context> = (input: $mol_tree2, belt: $mol_tree2_belt<Context>, context: Context) => readonly $mol_tree2[];
154
+ /** Collection of hask tools for processing tree. */
134
155
  type $mol_tree2_belt<Context> = Record<string, $mol_tree2_hack<Context>>;
156
+ /**
157
+ * Abstract Syntax Tree with human readable serialization.
158
+ * Avoid direct instantiation. Use static factories instead.
159
+ * @see https://github.com/nin-jin/tree.d
160
+ */
135
161
  class $mol_tree2 extends Object {
162
+ /** Type of structural node, `value` should be empty */
136
163
  readonly type: string;
164
+ /** Content of data node, `type` should be empty */
137
165
  readonly value: string;
166
+ /** Child nodes */
138
167
  readonly kids: readonly $mol_tree2[];
168
+ /** Position in most far source resource */
139
169
  readonly span: $mol_span;
140
- constructor(type: string, value: string, kids: readonly $mol_tree2[], span: $mol_span);
170
+ constructor(
171
+ /** Type of structural node, `value` should be empty */
172
+ type: string,
173
+ /** Content of data node, `type` should be empty */
174
+ value: string,
175
+ /** Child nodes */
176
+ kids: readonly $mol_tree2[],
177
+ /** Position in most far source resource */
178
+ span: $mol_span);
179
+ /** Makes collection node. */
141
180
  static list(kids: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
181
+ /** Makes new derived collection node. */
142
182
  list(kids: readonly $mol_tree2[]): $mol_tree2;
183
+ /** Makes data node for any string. */
143
184
  static data(value: string, kids?: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
185
+ /** Makes new derived data node. */
144
186
  data(value: string, kids?: readonly $mol_tree2[]): $mol_tree2;
187
+ /** Makes struct node. */
145
188
  static struct(type: string, kids?: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
189
+ /** Makes new derived structural node. */
146
190
  struct(type: string, kids?: readonly $mol_tree2[]): $mol_tree2;
191
+ /** Makes new derived node with different kids id defined. */
147
192
  clone(kids: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
193
+ /** Returns multiline text content. */
148
194
  text(): string;
195
+ /** Parses tree format. */
196
+ /** @deprecated Use $mol_tree2_from_string */
149
197
  static fromString(str: string, uri?: string): $mol_tree2;
198
+ /** Serializes to tree format. */
150
199
  toString(): string;
200
+ /** Makes new tree with node overrided by path. */
151
201
  insert(value: $mol_tree2 | null, ...path: $mol_tree2_path): $mol_tree2;
202
+ /** Makes new tree with node overrided by path. */
152
203
  update(value: readonly $mol_tree2[], ...path: $mol_tree2_path): readonly $mol_tree2[];
204
+ /** Query nodes by path. */
153
205
  select(...path: $mol_tree2_path): $mol_tree2;
206
+ /** Filter kids by path or value. */
154
207
  filter(path: string[], value?: string): $mol_tree2;
155
208
  hack_self<Context extends {
156
209
  span?: $mol_span;
157
210
  [key: string]: unknown;
158
211
  } = {}>(belt: $mol_tree2_belt<Context>, context?: Context): readonly $mol_tree2[];
212
+ /** Transform tree through context with transformers */
159
213
  hack<Context extends {
160
214
  span?: $mol_span;
161
215
  [key: string]: unknown;
162
216
  } = {}>(belt: $mol_tree2_belt<Context>, context?: Context): $mol_tree2[];
217
+ /** Makes Error with node coordinates. */
163
218
  error(message: string, Class?: ErrorConstructor): Error;
164
219
  }
165
220
  class $mol_tree2_empty extends $mol_tree2 {
@@ -272,6 +327,7 @@ declare namespace $ {
272
327
  }
273
328
 
274
329
  declare namespace $ {
330
+ /** Makes JSON from json.tree. */
275
331
  function $mol_tree2_to_json(this: $, tree: $mol_tree2): unknown;
276
332
  }
277
333
 
@@ -295,25 +351,49 @@ declare namespace $ {
295
351
  }
296
352
 
297
353
  declare namespace $ {
298
- type $mol_type_equals<A, B> = (<X>() => X extends A ? 1 : 2) extends (<X>() => X extends B ? 1 : 2) ? unknown : never;
354
+ /**
355
+ * Return `unknown` when `A` and `B` are the same type. `never` otherwise.
356
+ *
357
+ * $mol_type_equals< unknown , any > & number // true
358
+ * $mol_type_equals< never , never > & number // false
359
+ */
360
+ type $mol_type_equals<A, B> = (<X>() => X extends A ? 1 : 2) extends (<X>() => X extends B ? 1 : 2) ? true : false;
299
361
  }
300
362
 
301
363
  declare namespace $ {
302
- 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<{
364
+ /**
365
+ * Reqursive converts intersection of records to record of intersections
366
+ *
367
+ * // { a : { x : 1 , y : 2 } }
368
+ * $mol_type_merge< { a : { x : 1 } }&{ a : { y : 2 } } >
369
+ */
370
+ 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<{
303
371
  [Key in keyof Intersection]: Intersection[Key];
304
372
  }, Intersection> ? Intersection : {
305
373
  [Key in keyof Intersection]: $mol_type_merge<Intersection[Key]>;
306
374
  } : Intersection : Intersection;
375
+ /**
376
+ * Flat converts intersection of records to record of intersections
377
+ *
378
+ * // { a: 1, b: 2 }
379
+ * $mol_type_merge< { a: 1 } & { b: 2 } >
380
+ */
307
381
  type $mol_type_merge_object<Intersection> = {
308
382
  [Key in keyof Intersection]: Intersection[Key];
309
383
  };
310
384
  }
311
385
 
312
386
  declare namespace $ {
387
+ /**
388
+ * Converts union of types to intersection of same types
389
+ *
390
+ * $mol_type_intersect< number | string > // number & string
391
+ */
313
392
  type $mol_type_intersect<Union> = (Union extends any ? (_: Union) => void : never) extends ((_: infer Intersection) => void) ? Intersection : never;
314
393
  }
315
394
 
316
395
  declare namespace $ {
396
+ /** Replaces properties of `Base` record by properties from `Over`. */
317
397
  type $mol_type_override<Base, Over> = Omit<Base, keyof Over> & Over;
318
398
  }
319
399
 
@@ -346,15 +426,19 @@ declare namespace $ {
346
426
  readonly [k in key]: Source[key] extends string ? Source[key] : string;
347
427
  }> & $mol_regexp_groups<Source[key]>>;
348
428
  }[keyof Source]>> : never;
429
+ /** Type safe reguar expression builder */
349
430
  export class $mol_regexp<Groups extends Record<string, string>> extends RegExp {
350
431
  readonly groups: (Extract<keyof Groups, string>)[];
432
+ /** Prefer to use $mol_regexp.from */
351
433
  constructor(source: string, flags?: string, groups?: (Extract<keyof Groups, string>)[]);
352
434
  [Symbol.matchAll](str: string): RegExpStringIterator<RegExpExecArray & $mol_type_override<RegExpExecArray, {
353
435
  groups?: {
354
436
  [key in keyof Groups]: string;
355
437
  };
356
438
  }>>;
439
+ /** Parses input and returns found capture groups or null */
357
440
  [Symbol.match](str: string): null | RegExpMatchArray;
441
+ /** Splits string by regexp edges */
358
442
  [Symbol.split](str: string): string[];
359
443
  test(str: string): boolean;
360
444
  exec(str: string): RegExpExecArray & $mol_type_override<RegExpExecArray, {
@@ -364,6 +448,7 @@ declare namespace $ {
364
448
  }> | null;
365
449
  generate(params: Groups_to_params<Groups>): string | null;
366
450
  get native(): RegExp;
451
+ /** Makes regexp that greedy repeats this pattern with delimiter */
367
452
  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 {
368
453
  readonly [x: string]: $mol_regexp_source;
369
454
  } ? $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 {
@@ -371,14 +456,23 @@ declare namespace $ {
371
456
  } ? $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 {
372
457
  readonly [x: string]: $mol_regexp_source;
373
458
  } ? $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>;
459
+ /** Makes regexp that non-greedy repeats this pattern from min to max count */
374
460
  static repeat<Source extends $mol_regexp_source>(source: Source, min?: number, max?: number): $mol_regexp<$mol_regexp_groups<Source>>;
461
+ /** Makes regexp that greedy repeats this pattern from min to max count */
375
462
  static repeat_greedy<Source extends $mol_regexp_source>(source: Source, min?: number, max?: number): $mol_regexp<$mol_regexp_groups<Source>>;
463
+ /** Makes regexp that match any of options */
376
464
  static vary<Sources extends readonly $mol_regexp_source[]>(sources: Sources, flags?: string): $mol_regexp<$mol_regexp_groups<Sources[number]>>;
465
+ /** Makes regexp that allow absent of this pattern */
377
466
  static optional<Source extends $mol_regexp_source>(source: Source): $mol_regexp<$mol_regexp_groups<Source>>;
467
+ /** Makes regexp that look ahead for pattern */
378
468
  static force_after(source: $mol_regexp_source): $mol_regexp<Record<string, string>>;
469
+ /** Makes regexp that look ahead for pattern */
379
470
  static forbid_after(source: $mol_regexp_source): $mol_regexp<Record<string, string>>;
471
+ /** Converts some js values to regexp */
380
472
  static from<Source extends $mol_regexp_source>(source: Source, { ignoreCase, multiline }?: Partial<Pick<RegExp, 'ignoreCase' | 'multiline'>>): $mol_regexp<$mol_regexp_groups<Source>>;
473
+ /** Makes regexp which includes only unicode category */
381
474
  static unicode_only(...category: $mol_unicode_category): $mol_regexp<Record<string, string>>;
475
+ /** Makes regexp which excludes unicode category */
382
476
  static unicode_except(...category: $mol_unicode_category): $mol_regexp<Record<string, string>>;
383
477
  static char_range(from: number, to: number): $mol_regexp<{}>;
384
478
  static char_only(...allowed: readonly [$mol_regexp_source, ...$mol_regexp_source[]]): $mol_regexp<{}>;
@@ -427,6 +521,9 @@ declare namespace $ {
427
521
  }
428
522
 
429
523
  declare namespace $ {
524
+ /**
525
+ * Fails if `Actual` type is not subtype of `Expected`.
526
+ */
430
527
  type $mol_type_enforce<Actual extends Expected, Expected> = Actual;
431
528
  }
432
529
 
@@ -455,57 +552,130 @@ declare namespace $ {
455
552
  }
456
553
 
457
554
  declare namespace $ {
555
+ /** Generates unique identifier. */
458
556
  function $mol_guid(length?: number, exists?: (id: string) => boolean): string;
459
557
  }
460
558
 
461
559
  declare namespace $ {
560
+ /** Special status statuses. */
462
561
  enum $mol_wire_cursor {
562
+ /** Update required. */
463
563
  stale = -1,
564
+ /** Some of (transitive) pub update required. */
464
565
  doubt = -2,
566
+ /** Actual state but may be dropped. */
465
567
  fresh = -3,
568
+ /** State will never be changed. */
466
569
  final = -4
467
570
  }
468
571
  }
469
572
 
470
573
  declare namespace $ {
574
+ /**
575
+ * Collects subscribers in compact array. 28B
576
+ */
471
577
  class $mol_wire_pub extends Object {
472
578
  constructor(id?: string);
473
579
  [Symbol.toStringTag]: string;
474
580
  data: unknown[];
475
581
  static get [Symbol.species](): ArrayConstructor;
582
+ /**
583
+ * Index of first subscriber.
584
+ */
476
585
  protected sub_from: number;
586
+ /**
587
+ * All current subscribers.
588
+ */
477
589
  get sub_list(): readonly $mol_wire_sub[];
590
+ /**
591
+ * Has any subscribers or not.
592
+ */
478
593
  get sub_empty(): boolean;
594
+ /**
595
+ * Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
596
+ */
479
597
  sub_on(sub: $mol_wire_pub, pub_pos: number): number;
598
+ /**
599
+ * Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
600
+ */
480
601
  sub_off(sub_pos: number): void;
602
+ /**
603
+ * Called when last sub was unsubscribed.
604
+ **/
481
605
  reap(): void;
606
+ /**
607
+ * Autowire this publisher with current subscriber.
608
+ **/
482
609
  promote(): void;
610
+ /**
611
+ * Enforce actualization. Should not throw errors.
612
+ */
483
613
  fresh(): void;
614
+ /**
615
+ * Allow to put data to caches in the subtree.
616
+ */
484
617
  complete(): void;
485
618
  get incompleted(): boolean;
619
+ /**
620
+ * Notify subscribers about self changes.
621
+ */
486
622
  emit(quant?: $mol_wire_cursor): void;
623
+ /**
624
+ * Moves peer from one position to another. Doesn't clear data at old position!
625
+ */
487
626
  peer_move(from_pos: number, to_pos: number): void;
627
+ /**
628
+ * Updates self position in the peer.
629
+ */
488
630
  peer_repos(peer_pos: number, self_pos: number): void;
489
631
  }
490
632
  }
491
633
 
492
634
  declare namespace $ {
635
+ /** Generic subscriber interface */
493
636
  interface $mol_wire_sub extends $mol_wire_pub {
494
637
  temp: boolean;
495
638
  pub_list: $mol_wire_pub[];
639
+ /**
640
+ * Begin auto wire to publishers.
641
+ * Returns previous auto subscriber that must me transfer to the `end`.
642
+ */
496
643
  track_on(): $mol_wire_sub | null;
644
+ /**
645
+ * Returns next auto wired publisher. It can be easely repormoted.
646
+ * Or promotes next publisher to auto wire its togeter.
647
+ * Must be used only between `track_on` and `track_off`.
648
+ */
497
649
  track_next(pub?: $mol_wire_pub): $mol_wire_pub | null;
498
650
  pub_off(pub_pos: number): void;
651
+ /**
652
+ * Unsubscribes from unpromoted publishers.
653
+ */
499
654
  track_cut(sub: $mol_wire_pub | null): void;
655
+ /**
656
+ * Ends auto wire to publishers.
657
+ */
500
658
  track_off(sub: $mol_wire_pub | null): void;
659
+ /**
660
+ * Receive notification about publisher changes.
661
+ */
501
662
  absorb(quant: $mol_wire_cursor, pos: number): void;
663
+ /**
664
+ * Unsubscribes from all publishers.
665
+ */
502
666
  destructor(): void;
503
667
  }
504
668
  }
505
669
 
506
670
  declare namespace $ {
507
671
  let $mol_wire_auto_sub: $mol_wire_sub | null;
672
+ /**
673
+ * When fulfilled, all publishers are promoted to this subscriber on access to its.
674
+ */
508
675
  function $mol_wire_auto(next?: $mol_wire_sub | null): $mol_wire_sub | null;
676
+ /**
677
+ * Affection queue. Used to prevent accidental stack overflow on emit.
678
+ */
509
679
  const $mol_wire_affected: ($mol_wire_sub | number)[];
510
680
  }
511
681
 
@@ -538,6 +708,13 @@ declare namespace $ {
538
708
  }
539
709
 
540
710
  declare namespace $ {
711
+ /**
712
+ * Publisher that can auto collect other publishers. 32B
713
+ *
714
+ * P1 P2 P3 P4 S1 S2 S3
715
+ * ^ ^
716
+ * pubs_from subs_from
717
+ */
541
718
  class $mol_wire_pub_sub extends $mol_wire_pub implements $mol_wire_sub {
542
719
  protected pub_from: number;
543
720
  protected cursor: $mol_wire_cursor;
@@ -554,6 +731,9 @@ declare namespace $ {
554
731
  complete_pubs(): void;
555
732
  absorb(quant?: $mol_wire_cursor, pos?: number): void;
556
733
  [$mol_dev_format_head](): any[];
734
+ /**
735
+ * Is subscribed to any publisher or not.
736
+ */
557
737
  get pub_empty(): boolean;
558
738
  }
559
739
  }
@@ -573,6 +753,13 @@ declare namespace $ {
573
753
  }
574
754
 
575
755
  declare namespace $ {
756
+ /**
757
+ * Suspendable task with support both sync/async api.
758
+ *
759
+ * A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
760
+ * ^ ^ ^
761
+ * args_from pubs_from subs_from
762
+ **/
576
763
  abstract class $mol_wire_fiber<Host, Args extends readonly unknown[], Result> extends $mol_wire_pub_sub {
577
764
  readonly task: (this: Host, ...args: Args) => Result;
578
765
  readonly host?: Host | undefined;
@@ -599,7 +786,15 @@ declare namespace $ {
599
786
  fresh(): this | undefined;
600
787
  refresh(): void;
601
788
  abstract put(next: Result | Error | Promise<Result | Error>): Result | Error | Promise<Result | Error>;
789
+ /**
790
+ * Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
791
+ * Should be called inside SuspenseAPI consumer (ie fiber).
792
+ */
602
793
  sync(): Awaited<Result>;
794
+ /**
795
+ * Asynchronous execution.
796
+ * It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
797
+ */
603
798
  async_raw(): Promise<Result>;
604
799
  async(): Promise<Result> & {
605
800
  destructor(): void;
@@ -610,6 +805,7 @@ declare namespace $ {
610
805
  }
611
806
 
612
807
  declare namespace $ {
808
+ /** Returns string key for any value. */
613
809
  function $mol_key<Value>(value: Value): string;
614
810
  }
615
811
 
@@ -632,31 +828,48 @@ declare namespace $ {
632
828
 
633
829
  declare namespace $ {
634
830
  let $mol_compare_deep_cache: WeakMap<any, WeakMap<any, boolean>>;
831
+ /**
832
+ * Deeply compares two values. Returns true if equal.
833
+ * Define `Symbol.toPrimitive` to customize.
834
+ */
635
835
  function $mol_compare_deep<Value>(left: Value, right: Value): boolean;
636
836
  }
637
837
 
638
838
  declare namespace $ {
839
+ /** Logger event data */
639
840
  type $mol_log3_event<Fields> = {
640
841
  [key in string]: unknown;
641
842
  } & {
843
+ /** Time of event creation */
642
844
  time?: string;
845
+ /** Place of event creation */
643
846
  place: unknown;
847
+ /** Short description of event */
644
848
  message: string;
645
849
  } & Fields;
850
+ /** Logger function */
646
851
  type $mol_log3_logger<Fields, Res = void> = (this: $, event: $mol_log3_event<Fields>) => Res;
852
+ /** Log begin of some task */
647
853
  let $mol_log3_come: $mol_log3_logger<{}>;
854
+ /** Log end of some task */
648
855
  let $mol_log3_done: $mol_log3_logger<{}>;
856
+ /** Log error */
649
857
  let $mol_log3_fail: $mol_log3_logger<{}>;
858
+ /** Log warning message */
650
859
  let $mol_log3_warn: $mol_log3_logger<{
651
860
  hint: string;
652
861
  }>;
862
+ /** Log some generic event */
653
863
  let $mol_log3_rise: $mol_log3_logger<{}>;
864
+ /** Log begin of log group, returns func to close group */
654
865
  let $mol_log3_area: $mol_log3_logger<{}, () => void>;
866
+ /** Log begin of collapsed group only when some logged inside, returns func to close group */
655
867
  function $mol_log3_area_lazy(this: $, event: $mol_log3_event<{}>): () => void;
656
868
  let $mol_log3_stack: (() => void)[];
657
869
  }
658
870
 
659
871
  declare namespace $ {
872
+ /** Module for working with terminal. Text coloring when output in terminal */
660
873
  class $mol_term_color {
661
874
  static reset: (str: string) => string;
662
875
  static bold: (str: string) => string;
@@ -688,6 +901,7 @@ declare namespace $ {
688
901
  }
689
902
 
690
903
  declare namespace $ {
904
+ /** One-shot fiber */
691
905
  class $mol_wire_task<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
692
906
  static getter<Host, Args extends readonly unknown[], Result>(task: (this: Host, ...args: Args) => Result): (host: Host, args: Args) => $mol_wire_task<Host, Args, Result>;
693
907
  get temp(): boolean;
@@ -698,6 +912,9 @@ declare namespace $ {
698
912
  }
699
913
 
700
914
  declare namespace $ {
915
+ /**
916
+ * Decorates method to fiber to ensure it is executed only once inside other fiber.
917
+ */
701
918
  function $mol_wire_method<Host extends object, Args extends readonly any[]>(host: Host, field: PropertyKey, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
702
919
  value: (this: Host, ...args: Args) => any;
703
920
  enumerable?: boolean;
@@ -709,10 +926,20 @@ declare namespace $ {
709
926
  }
710
927
 
711
928
  declare namespace $ {
929
+ /**
930
+ * Returns `Tuple` without first element.
931
+ *
932
+ * $mol_type_tail<[ 1 , 2 , 3 ]> // [ 2, 3 ]
933
+ */
712
934
  type $mol_type_tail<Tuple extends readonly any[]> = ((...tail: Tuple) => any) extends ((head: any, ...tail: infer Tail) => any) ? Tail : never;
713
935
  }
714
936
 
715
937
  declare namespace $ {
938
+ /**
939
+ * Returns last element of `Tuple`.
940
+ *
941
+ * $mol_type_tail<[ 1 , 2 , 3 ]> // 3
942
+ */
716
943
  type $mol_type_foot<Tuple extends readonly any[]> = Tuple['length'] extends 0 ? never : Tuple[$mol_type_tail<Tuple>['length']];
717
944
  }
718
945
 
@@ -729,6 +956,7 @@ declare namespace $ {
729
956
  }
730
957
 
731
958
  declare namespace $ {
959
+ /** Long-living fiber. */
732
960
  class $mol_wire_atom<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
733
961
  static solo<Host, Args extends readonly unknown[], Result>(host: Host, task: (this: Host, ...args: Args) => Result): $mol_wire_atom<Host, Args, Result>;
734
962
  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>;
@@ -736,6 +964,9 @@ declare namespace $ {
736
964
  static watcher: $mol_after_frame | null;
737
965
  static watch(): void;
738
966
  watch(): void;
967
+ /**
968
+ * Update atom value through another temp fiber.
969
+ */
739
970
  resync(args: Args): Error | Result | Promise<Error | Result>;
740
971
  once(): Awaited<Result>;
741
972
  channel(): ((next?: $mol_type_foot<Args>) => Awaited<Result>) & {
@@ -747,12 +978,14 @@ declare namespace $ {
747
978
  }
748
979
 
749
980
  declare namespace $ {
981
+ /** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
750
982
  export function $mol_wire_solo<Args extends any[]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): TypedPropertyDescriptor<(...args: First_optional<Args>) => any>;
751
983
  type First_optional<Args extends any[]> = Args extends [] ? [] : [Args[0] | undefined, ...$mol_type_tail<Args>];
752
984
  export {};
753
985
  }
754
986
 
755
987
  declare namespace $ {
988
+ /** Reactive memoizing multiplexed property decorator. */
756
989
  function $mol_wire_plex<Args extends [any, ...any[]]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
757
990
  value: (this: typeof host, ...args: Args) => any;
758
991
  enumerable?: boolean;
@@ -764,7 +997,25 @@ declare namespace $ {
764
997
  }
765
998
 
766
999
  declare namespace $ {
1000
+ /**
1001
+ * Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
1002
+ * @example
1003
+ * '@' $mol_mem
1004
+ * name(next?: string) {
1005
+ * return next ?? 'default'
1006
+ * }
1007
+ * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
1008
+ */
767
1009
  let $mol_mem: typeof $mol_wire_solo;
1010
+ /**
1011
+ * Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
1012
+ * @example
1013
+ * '@' $mol_mem_key
1014
+ * name(id: number, next?: string) {
1015
+ * return next ?? 'default'
1016
+ * }
1017
+ * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
1018
+ */
768
1019
  let $mol_mem_key: typeof $mol_wire_plex;
769
1020
  }
770
1021
 
@@ -804,6 +1055,10 @@ declare namespace $ {
804
1055
  }
805
1056
 
806
1057
  declare namespace $ {
1058
+ /**
1059
+ * Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
1060
+ * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
1061
+ */
807
1062
  export function $mol_wire_sync<Host extends object>(obj: Host): ObjectOrFunctionResultAwaited<Host>;
808
1063
  type FunctionResultAwaited<Some> = Some extends (...args: infer Args) => infer Res ? (...args: Args) => Awaited<Res> : Some;
809
1064
  type ConstructorResultAwaited<Some> = Some extends new (...args: infer Args) => infer Res ? new (...args: Args) => Res : {};
@@ -853,6 +1108,9 @@ declare namespace $ {
853
1108
  }
854
1109
 
855
1110
  declare namespace $ {
1111
+ /**
1112
+ * Disable reaping of current subscriber
1113
+ */
856
1114
  function $mol_wire_solid(): void;
857
1115
  }
858
1116
 
@@ -861,6 +1119,7 @@ declare namespace $ {
861
1119
  }
862
1120
 
863
1121
  declare namespace $ {
1122
+ /** Run code without state changes */
864
1123
  function $mol_wire_probe<Value>(task: () => Value, def?: Value): Value | undefined;
865
1124
  }
866
1125
 
@@ -902,6 +1161,11 @@ declare namespace $ {
902
1161
  }
903
1162
 
904
1163
  declare namespace $ {
1164
+ /**
1165
+ * Returns closure that returns constant value.
1166
+ * @example
1167
+ * const rnd = $mol_const( Math.random() )
1168
+ */
905
1169
  function $mol_const<Value>(value: Value): {
906
1170
  (): Value;
907
1171
  '()': Value;
@@ -909,10 +1173,15 @@ declare namespace $ {
909
1173
  }
910
1174
 
911
1175
  declare namespace $ {
1176
+ /**
1177
+ * Decorates method to fiber to ensure it is executed only once inside other fiber from [mol_wire](../wire/README.md)
1178
+ * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
1179
+ */
912
1180
  let $mol_action: typeof $mol_wire_method;
913
1181
  }
914
1182
 
915
1183
  declare namespace $ {
1184
+ /** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
916
1185
  export function $mol_wire_async<Host extends object>(obj: Host): ObjectOrFunctionResultPromisify<Host>;
917
1186
  type FunctionResultPromisify<Some> = Some extends (...args: infer Args) => infer Res ? Res extends PromiseLike<unknown> ? Some : (...args: Args) => Promise<Res> : Some;
918
1187
  type MethodsResultPromisify<Host extends Object> = {
@@ -943,6 +1212,7 @@ declare namespace $ {
943
1212
  }
944
1213
 
945
1214
  declare namespace $ {
1215
+ /** Temporary buffer. Recursive usage isn't supported. */
946
1216
  function $mol_charset_buffer(size: number): Uint8Array<ArrayBuffer>;
947
1217
  }
948
1218
 
@@ -1001,6 +1271,10 @@ declare namespace $ {
1001
1271
  protected static changed: Set<$mol_file_base>;
1002
1272
  protected static frame: null | $mol_after_timeout;
1003
1273
  protected static changed_add(type: 'change' | 'rename', path: string): void;
1274
+ /**
1275
+ * Должно быть больше, чем время между событиями от вотчера при записи внешним процессом.
1276
+ * Иначе запуск ресетов паралельно с изменением может привести к неконсистентности.
1277
+ */
1004
1278
  static watch_debounce(): number;
1005
1279
  static flush(): void;
1006
1280
  protected static watching: boolean;
@@ -1102,6 +1376,10 @@ declare namespace $ {
1102
1376
  interface $mol_locale_dict {
1103
1377
  [key: string]: string;
1104
1378
  }
1379
+ /**
1380
+ * Localisation in $mol framework
1381
+ * @see https://mol.hyoo.ru/#!section=docs/=s5aqnb_odub8l
1382
+ */
1105
1383
  class $mol_locale extends $mol_object {
1106
1384
  static lang_default(): string;
1107
1385
  static lang(next?: string): string;