mol_view_tree2_lib 1.0.195 → 1.0.197
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 +278 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +371 -19
- package/node.js.map +1 -1
- package/node.mjs +371 -19
- package/node.test.js +675 -36
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +282 -1
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +364 -16
- package/web.js.map +1 -1
- package/web.mjs +364 -16
- package/web.test.js +304 -17
- package/web.test.js.map +1 -1
package/web.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(
|
|
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,21 +351,44 @@ declare namespace $ {
|
|
|
295
351
|
}
|
|
296
352
|
|
|
297
353
|
declare namespace $ {
|
|
354
|
+
/**
|
|
355
|
+
* Return `unknown` when `A` and `B` are the same type. `never` otherwise.
|
|
356
|
+
*
|
|
357
|
+
* $mol_type_equals< unknown , any > & number // never
|
|
358
|
+
* $mol_type_equals< never , never > & number // number
|
|
359
|
+
*/
|
|
298
360
|
type $mol_type_equals<A, B> = (<X>() => X extends A ? 1 : 2) extends (<X>() => X extends B ? 1 : 2) ? unknown : never;
|
|
299
361
|
}
|
|
300
362
|
|
|
301
363
|
declare namespace $ {
|
|
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
|
+
*/
|
|
302
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 ? unknown 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
|
|
|
@@ -346,15 +425,19 @@ declare namespace $ {
|
|
|
346
425
|
readonly [k in key]: Source[key] extends string ? Source[key] : string;
|
|
347
426
|
}> & $mol_regexp_groups<Source[key]>>;
|
|
348
427
|
}[keyof Source]>> : never;
|
|
428
|
+
/** Type safe reguar expression builder */
|
|
349
429
|
export class $mol_regexp<Groups extends Record<string, string>> extends RegExp {
|
|
350
430
|
readonly groups: (Extract<keyof Groups, string>)[];
|
|
431
|
+
/** Prefer to use $mol_regexp.from */
|
|
351
432
|
constructor(source: string, flags?: string, groups?: (Extract<keyof Groups, string>)[]);
|
|
352
433
|
[Symbol.matchAll](str: string): RegExpStringIterator<RegExpExecArray & $mol_type_override<RegExpExecArray, {
|
|
353
434
|
groups?: {
|
|
354
435
|
[key in keyof Groups]: string;
|
|
355
436
|
};
|
|
356
437
|
}>>;
|
|
438
|
+
/** Parses input and returns found capture groups or null */
|
|
357
439
|
[Symbol.match](str: string): null | RegExpMatchArray;
|
|
440
|
+
/** Splits string by regexp edges */
|
|
358
441
|
[Symbol.split](str: string): string[];
|
|
359
442
|
test(str: string): boolean;
|
|
360
443
|
exec(str: string): RegExpExecArray & $mol_type_override<RegExpExecArray, {
|
|
@@ -364,6 +447,7 @@ declare namespace $ {
|
|
|
364
447
|
}> | null;
|
|
365
448
|
generate(params: Groups_to_params<Groups>): string | null;
|
|
366
449
|
get native(): RegExp;
|
|
450
|
+
/** Makes regexp that greedy repeats this pattern with delimiter */
|
|
367
451
|
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
452
|
readonly [x: string]: $mol_regexp_source;
|
|
369
453
|
} ? $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 +455,23 @@ declare namespace $ {
|
|
|
371
455
|
} ? $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
456
|
readonly [x: string]: $mol_regexp_source;
|
|
373
457
|
} ? $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>;
|
|
458
|
+
/** Makes regexp that non-greedy repeats this pattern from min to max count */
|
|
374
459
|
static repeat<Source extends $mol_regexp_source>(source: Source, min?: number, max?: number): $mol_regexp<$mol_regexp_groups<Source>>;
|
|
460
|
+
/** Makes regexp that greedy repeats this pattern from min to max count */
|
|
375
461
|
static repeat_greedy<Source extends $mol_regexp_source>(source: Source, min?: number, max?: number): $mol_regexp<$mol_regexp_groups<Source>>;
|
|
462
|
+
/** Makes regexp that match any of options */
|
|
376
463
|
static vary<Sources extends readonly $mol_regexp_source[]>(sources: Sources, flags?: string): $mol_regexp<$mol_regexp_groups<Sources[number]>>;
|
|
464
|
+
/** Makes regexp that allow absent of this pattern */
|
|
377
465
|
static optional<Source extends $mol_regexp_source>(source: Source): $mol_regexp<$mol_regexp_groups<Source>>;
|
|
466
|
+
/** Makes regexp that look ahead for pattern */
|
|
378
467
|
static force_after(source: $mol_regexp_source): $mol_regexp<Record<string, string>>;
|
|
468
|
+
/** Makes regexp that look ahead for pattern */
|
|
379
469
|
static forbid_after(source: $mol_regexp_source): $mol_regexp<Record<string, string>>;
|
|
470
|
+
/** Converts some js values to regexp */
|
|
380
471
|
static from<Source extends $mol_regexp_source>(source: Source, { ignoreCase, multiline }?: Partial<Pick<RegExp, 'ignoreCase' | 'multiline'>>): $mol_regexp<$mol_regexp_groups<Source>>;
|
|
472
|
+
/** Makes regexp which includes only unicode category */
|
|
381
473
|
static unicode_only(...category: $mol_unicode_category): $mol_regexp<Record<string, string>>;
|
|
474
|
+
/** Makes regexp which excludes unicode category */
|
|
382
475
|
static unicode_except(...category: $mol_unicode_category): $mol_regexp<Record<string, string>>;
|
|
383
476
|
static char_range(from: number, to: number): $mol_regexp<{}>;
|
|
384
477
|
static char_only(...allowed: readonly [$mol_regexp_source, ...$mol_regexp_source[]]): $mol_regexp<{}>;
|
|
@@ -427,6 +520,9 @@ declare namespace $ {
|
|
|
427
520
|
}
|
|
428
521
|
|
|
429
522
|
declare namespace $ {
|
|
523
|
+
/**
|
|
524
|
+
* Fails if `Actual` type is not subtype of `Expected`.
|
|
525
|
+
*/
|
|
430
526
|
type $mol_type_enforce<Actual extends Expected, Expected> = Actual;
|
|
431
527
|
}
|
|
432
528
|
|
|
@@ -455,57 +551,130 @@ declare namespace $ {
|
|
|
455
551
|
}
|
|
456
552
|
|
|
457
553
|
declare namespace $ {
|
|
554
|
+
/** Generates unique identifier. */
|
|
458
555
|
function $mol_guid(length?: number, exists?: (id: string) => boolean): string;
|
|
459
556
|
}
|
|
460
557
|
|
|
461
558
|
declare namespace $ {
|
|
559
|
+
/** Special status statuses. */
|
|
462
560
|
enum $mol_wire_cursor {
|
|
561
|
+
/** Update required. */
|
|
463
562
|
stale = -1,
|
|
563
|
+
/** Some of (transitive) pub update required. */
|
|
464
564
|
doubt = -2,
|
|
565
|
+
/** Actual state but may be dropped. */
|
|
465
566
|
fresh = -3,
|
|
567
|
+
/** State will never be changed. */
|
|
466
568
|
final = -4
|
|
467
569
|
}
|
|
468
570
|
}
|
|
469
571
|
|
|
470
572
|
declare namespace $ {
|
|
573
|
+
/**
|
|
574
|
+
* Collects subscribers in compact array. 28B
|
|
575
|
+
*/
|
|
471
576
|
class $mol_wire_pub extends Object {
|
|
472
577
|
constructor(id?: string);
|
|
473
578
|
[Symbol.toStringTag]: string;
|
|
474
579
|
data: unknown[];
|
|
475
580
|
static get [Symbol.species](): ArrayConstructor;
|
|
581
|
+
/**
|
|
582
|
+
* Index of first subscriber.
|
|
583
|
+
*/
|
|
476
584
|
protected sub_from: number;
|
|
585
|
+
/**
|
|
586
|
+
* All current subscribers.
|
|
587
|
+
*/
|
|
477
588
|
get sub_list(): readonly $mol_wire_sub[];
|
|
589
|
+
/**
|
|
590
|
+
* Has any subscribers or not.
|
|
591
|
+
*/
|
|
478
592
|
get sub_empty(): boolean;
|
|
593
|
+
/**
|
|
594
|
+
* Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
|
|
595
|
+
*/
|
|
479
596
|
sub_on(sub: $mol_wire_pub, pub_pos: number): number;
|
|
597
|
+
/**
|
|
598
|
+
* Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
|
|
599
|
+
*/
|
|
480
600
|
sub_off(sub_pos: number): void;
|
|
601
|
+
/**
|
|
602
|
+
* Called when last sub was unsubscribed.
|
|
603
|
+
**/
|
|
481
604
|
reap(): void;
|
|
605
|
+
/**
|
|
606
|
+
* Autowire this publisher with current subscriber.
|
|
607
|
+
**/
|
|
482
608
|
promote(): void;
|
|
609
|
+
/**
|
|
610
|
+
* Enforce actualization. Should not throw errors.
|
|
611
|
+
*/
|
|
483
612
|
fresh(): void;
|
|
613
|
+
/**
|
|
614
|
+
* Allow to put data to caches in the subtree.
|
|
615
|
+
*/
|
|
484
616
|
complete(): void;
|
|
485
617
|
get incompleted(): boolean;
|
|
618
|
+
/**
|
|
619
|
+
* Notify subscribers about self changes.
|
|
620
|
+
*/
|
|
486
621
|
emit(quant?: $mol_wire_cursor): void;
|
|
622
|
+
/**
|
|
623
|
+
* Moves peer from one position to another. Doesn't clear data at old position!
|
|
624
|
+
*/
|
|
487
625
|
peer_move(from_pos: number, to_pos: number): void;
|
|
626
|
+
/**
|
|
627
|
+
* Updates self position in the peer.
|
|
628
|
+
*/
|
|
488
629
|
peer_repos(peer_pos: number, self_pos: number): void;
|
|
489
630
|
}
|
|
490
631
|
}
|
|
491
632
|
|
|
492
633
|
declare namespace $ {
|
|
634
|
+
/** Generic subscriber interface */
|
|
493
635
|
interface $mol_wire_sub extends $mol_wire_pub {
|
|
494
636
|
temp: boolean;
|
|
495
637
|
pub_list: $mol_wire_pub[];
|
|
638
|
+
/**
|
|
639
|
+
* Begin auto wire to publishers.
|
|
640
|
+
* Returns previous auto subscriber that must me transfer to the `end`.
|
|
641
|
+
*/
|
|
496
642
|
track_on(): $mol_wire_sub | null;
|
|
643
|
+
/**
|
|
644
|
+
* Returns next auto wired publisher. It can be easely repormoted.
|
|
645
|
+
* Or promotes next publisher to auto wire its togeter.
|
|
646
|
+
* Must be used only between `track_on` and `track_off`.
|
|
647
|
+
*/
|
|
497
648
|
track_next(pub?: $mol_wire_pub): $mol_wire_pub | null;
|
|
498
649
|
pub_off(pub_pos: number): void;
|
|
650
|
+
/**
|
|
651
|
+
* Unsubscribes from unpromoted publishers.
|
|
652
|
+
*/
|
|
499
653
|
track_cut(sub: $mol_wire_pub | null): void;
|
|
654
|
+
/**
|
|
655
|
+
* Ends auto wire to publishers.
|
|
656
|
+
*/
|
|
500
657
|
track_off(sub: $mol_wire_pub | null): void;
|
|
658
|
+
/**
|
|
659
|
+
* Receive notification about publisher changes.
|
|
660
|
+
*/
|
|
501
661
|
absorb(quant: $mol_wire_cursor, pos: number): void;
|
|
662
|
+
/**
|
|
663
|
+
* Unsubscribes from all publishers.
|
|
664
|
+
*/
|
|
502
665
|
destructor(): void;
|
|
503
666
|
}
|
|
504
667
|
}
|
|
505
668
|
|
|
506
669
|
declare namespace $ {
|
|
507
670
|
let $mol_wire_auto_sub: $mol_wire_sub | null;
|
|
671
|
+
/**
|
|
672
|
+
* When fulfilled, all publishers are promoted to this subscriber on access to its.
|
|
673
|
+
*/
|
|
508
674
|
function $mol_wire_auto(next?: $mol_wire_sub | null): $mol_wire_sub | null;
|
|
675
|
+
/**
|
|
676
|
+
* Affection queue. Used to prevent accidental stack overflow on emit.
|
|
677
|
+
*/
|
|
509
678
|
const $mol_wire_affected: ($mol_wire_sub | number)[];
|
|
510
679
|
}
|
|
511
680
|
|
|
@@ -538,6 +707,13 @@ declare namespace $ {
|
|
|
538
707
|
}
|
|
539
708
|
|
|
540
709
|
declare namespace $ {
|
|
710
|
+
/**
|
|
711
|
+
* Publisher that can auto collect other publishers. 32B
|
|
712
|
+
*
|
|
713
|
+
* P1 P2 P3 P4 S1 S2 S3
|
|
714
|
+
* ^ ^
|
|
715
|
+
* pubs_from subs_from
|
|
716
|
+
*/
|
|
541
717
|
class $mol_wire_pub_sub extends $mol_wire_pub implements $mol_wire_sub {
|
|
542
718
|
protected pub_from: number;
|
|
543
719
|
protected cursor: $mol_wire_cursor;
|
|
@@ -554,6 +730,9 @@ declare namespace $ {
|
|
|
554
730
|
complete_pubs(): void;
|
|
555
731
|
absorb(quant?: $mol_wire_cursor, pos?: number): void;
|
|
556
732
|
[$mol_dev_format_head](): any[];
|
|
733
|
+
/**
|
|
734
|
+
* Is subscribed to any publisher or not.
|
|
735
|
+
*/
|
|
557
736
|
get pub_empty(): boolean;
|
|
558
737
|
}
|
|
559
738
|
}
|
|
@@ -573,6 +752,13 @@ declare namespace $ {
|
|
|
573
752
|
}
|
|
574
753
|
|
|
575
754
|
declare namespace $ {
|
|
755
|
+
/**
|
|
756
|
+
* Suspendable task with support both sync/async api.
|
|
757
|
+
*
|
|
758
|
+
* A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
|
|
759
|
+
* ^ ^ ^
|
|
760
|
+
* args_from pubs_from subs_from
|
|
761
|
+
**/
|
|
576
762
|
abstract class $mol_wire_fiber<Host, Args extends readonly unknown[], Result> extends $mol_wire_pub_sub {
|
|
577
763
|
readonly task: (this: Host, ...args: Args) => Result;
|
|
578
764
|
readonly host?: Host | undefined;
|
|
@@ -599,7 +785,15 @@ declare namespace $ {
|
|
|
599
785
|
fresh(): this | undefined;
|
|
600
786
|
refresh(): void;
|
|
601
787
|
abstract put(next: Result | Error | Promise<Result | Error>): Result | Error | Promise<Result | Error>;
|
|
788
|
+
/**
|
|
789
|
+
* Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
|
|
790
|
+
* Should be called inside SuspenseAPI consumer (ie fiber).
|
|
791
|
+
*/
|
|
602
792
|
sync(): Awaited<Result>;
|
|
793
|
+
/**
|
|
794
|
+
* Asynchronous execution.
|
|
795
|
+
* It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
|
|
796
|
+
*/
|
|
603
797
|
async_raw(): Promise<Result>;
|
|
604
798
|
async(): Promise<Result> & {
|
|
605
799
|
destructor(): void;
|
|
@@ -610,6 +804,7 @@ declare namespace $ {
|
|
|
610
804
|
}
|
|
611
805
|
|
|
612
806
|
declare namespace $ {
|
|
807
|
+
/** Returns string key for any value. */
|
|
613
808
|
function $mol_key<Value>(value: Value): string;
|
|
614
809
|
}
|
|
615
810
|
|
|
@@ -627,31 +822,52 @@ declare namespace $ {
|
|
|
627
822
|
|
|
628
823
|
declare namespace $ {
|
|
629
824
|
let $mol_compare_deep_cache: WeakMap<any, WeakMap<any, boolean>>;
|
|
825
|
+
/**
|
|
826
|
+
* Deeply compares two values. Returns true if equal.
|
|
827
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
828
|
+
*/
|
|
630
829
|
function $mol_compare_deep<Value>(left: Value, right: Value): boolean;
|
|
631
830
|
}
|
|
632
831
|
|
|
633
832
|
declare namespace $ {
|
|
833
|
+
/** Logger event data */
|
|
634
834
|
type $mol_log3_event<Fields> = {
|
|
635
835
|
[key in string]: unknown;
|
|
636
836
|
} & {
|
|
837
|
+
/** Time of event creation */
|
|
637
838
|
time?: string;
|
|
839
|
+
/** Place of event creation */
|
|
638
840
|
place: unknown;
|
|
841
|
+
/** Short description of event */
|
|
639
842
|
message: string;
|
|
640
843
|
} & Fields;
|
|
844
|
+
/** Logger function */
|
|
641
845
|
type $mol_log3_logger<Fields, Res = void> = (this: $, event: $mol_log3_event<Fields>) => Res;
|
|
846
|
+
/** Log begin of some task */
|
|
642
847
|
let $mol_log3_come: $mol_log3_logger<{}>;
|
|
848
|
+
/** Log end of some task */
|
|
643
849
|
let $mol_log3_done: $mol_log3_logger<{}>;
|
|
850
|
+
/** Log error */
|
|
644
851
|
let $mol_log3_fail: $mol_log3_logger<{}>;
|
|
852
|
+
/** Log warning message */
|
|
645
853
|
let $mol_log3_warn: $mol_log3_logger<{
|
|
646
854
|
hint: string;
|
|
647
855
|
}>;
|
|
856
|
+
/** Log some generic event */
|
|
648
857
|
let $mol_log3_rise: $mol_log3_logger<{}>;
|
|
858
|
+
/** Log begin of log group, returns func to close group */
|
|
649
859
|
let $mol_log3_area: $mol_log3_logger<{}, () => void>;
|
|
860
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
650
861
|
function $mol_log3_area_lazy(this: $, event: $mol_log3_event<{}>): () => void;
|
|
651
862
|
let $mol_log3_stack: (() => void)[];
|
|
652
863
|
}
|
|
653
864
|
|
|
654
865
|
declare namespace $ {
|
|
866
|
+
/**
|
|
867
|
+
* Extracts keys from `Input` which values extends `Upper` and extendable by `Lower`.
|
|
868
|
+
*
|
|
869
|
+
* type MathConstants = $mol_type_keys_extract< Math , number > // "E" | "PI" ...
|
|
870
|
+
*/
|
|
655
871
|
type $mol_type_keys_extract<Input, Upper, Lower = never> = {
|
|
656
872
|
[Field in keyof Input]: unknown extends Input[Field] ? never : Input[Field] extends never ? never : Input[Field] extends Upper ? [
|
|
657
873
|
Lower
|
|
@@ -664,6 +880,7 @@ declare namespace $ {
|
|
|
664
880
|
}
|
|
665
881
|
|
|
666
882
|
declare namespace $ {
|
|
883
|
+
/** One-shot fiber */
|
|
667
884
|
class $mol_wire_task<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
|
|
668
885
|
static getter<Host, Args extends readonly unknown[], Result>(task: (this: Host, ...args: Args) => Result): (host: Host, args: Args) => $mol_wire_task<Host, Args, Result>;
|
|
669
886
|
get temp(): boolean;
|
|
@@ -674,6 +891,9 @@ declare namespace $ {
|
|
|
674
891
|
}
|
|
675
892
|
|
|
676
893
|
declare namespace $ {
|
|
894
|
+
/**
|
|
895
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber.
|
|
896
|
+
*/
|
|
677
897
|
function $mol_wire_method<Host extends object, Args extends readonly any[]>(host: Host, field: PropertyKey, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
|
|
678
898
|
value: (this: Host, ...args: Args) => any;
|
|
679
899
|
enumerable?: boolean;
|
|
@@ -685,10 +905,20 @@ declare namespace $ {
|
|
|
685
905
|
}
|
|
686
906
|
|
|
687
907
|
declare namespace $ {
|
|
908
|
+
/**
|
|
909
|
+
* Returns `Tuple` without first element.
|
|
910
|
+
*
|
|
911
|
+
* $mol_type_tail<[ 1 , 2 , 3 ]> // [ 2, 3 ]
|
|
912
|
+
*/
|
|
688
913
|
type $mol_type_tail<Tuple extends readonly any[]> = ((...tail: Tuple) => any) extends ((head: any, ...tail: infer Tail) => any) ? Tail : never;
|
|
689
914
|
}
|
|
690
915
|
|
|
691
916
|
declare namespace $ {
|
|
917
|
+
/**
|
|
918
|
+
* Returns last element of `Tuple`.
|
|
919
|
+
*
|
|
920
|
+
* $mol_type_tail<[ 1 , 2 , 3 ]> // 3
|
|
921
|
+
*/
|
|
692
922
|
type $mol_type_foot<Tuple extends readonly any[]> = Tuple['length'] extends 0 ? never : Tuple[$mol_type_tail<Tuple>['length']];
|
|
693
923
|
}
|
|
694
924
|
|
|
@@ -709,6 +939,7 @@ declare namespace $ {
|
|
|
709
939
|
}
|
|
710
940
|
|
|
711
941
|
declare namespace $ {
|
|
942
|
+
/** Long-living fiber. */
|
|
712
943
|
class $mol_wire_atom<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
|
|
713
944
|
static solo<Host, Args extends readonly unknown[], Result>(host: Host, task: (this: Host, ...args: Args) => Result): $mol_wire_atom<Host, Args, Result>;
|
|
714
945
|
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>;
|
|
@@ -716,6 +947,9 @@ declare namespace $ {
|
|
|
716
947
|
static watcher: $mol_after_frame | null;
|
|
717
948
|
static watch(): void;
|
|
718
949
|
watch(): void;
|
|
950
|
+
/**
|
|
951
|
+
* Update atom value through another temp fiber.
|
|
952
|
+
*/
|
|
719
953
|
resync(args: Args): Error | Result | Promise<Error | Result>;
|
|
720
954
|
once(): Awaited<Result>;
|
|
721
955
|
channel(): ((next?: $mol_type_foot<Args>) => Awaited<Result>) & {
|
|
@@ -727,12 +961,14 @@ declare namespace $ {
|
|
|
727
961
|
}
|
|
728
962
|
|
|
729
963
|
declare namespace $ {
|
|
964
|
+
/** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
|
|
730
965
|
export function $mol_wire_solo<Args extends any[]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): TypedPropertyDescriptor<(...args: First_optional<Args>) => any>;
|
|
731
966
|
type First_optional<Args extends any[]> = Args extends [] ? [] : [Args[0] | undefined, ...$mol_type_tail<Args>];
|
|
732
967
|
export {};
|
|
733
968
|
}
|
|
734
969
|
|
|
735
970
|
declare namespace $ {
|
|
971
|
+
/** Reactive memoizing multiplexed property decorator. */
|
|
736
972
|
function $mol_wire_plex<Args extends [any, ...any[]]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
|
|
737
973
|
value: (this: typeof host, ...args: Args) => any;
|
|
738
974
|
enumerable?: boolean;
|
|
@@ -744,7 +980,25 @@ declare namespace $ {
|
|
|
744
980
|
}
|
|
745
981
|
|
|
746
982
|
declare namespace $ {
|
|
983
|
+
/**
|
|
984
|
+
* Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
|
|
985
|
+
* @example
|
|
986
|
+
* '@' $mol_mem
|
|
987
|
+
* name(next?: string) {
|
|
988
|
+
* return next ?? 'default'
|
|
989
|
+
* }
|
|
990
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
991
|
+
*/
|
|
747
992
|
let $mol_mem: typeof $mol_wire_solo;
|
|
993
|
+
/**
|
|
994
|
+
* Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
|
|
995
|
+
* @example
|
|
996
|
+
* '@' $mol_mem_key
|
|
997
|
+
* name(id: number, next?: string) {
|
|
998
|
+
* return next ?? 'default'
|
|
999
|
+
* }
|
|
1000
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
1001
|
+
*/
|
|
748
1002
|
let $mol_mem_key: typeof $mol_wire_plex;
|
|
749
1003
|
}
|
|
750
1004
|
|
|
@@ -756,6 +1010,9 @@ declare namespace $ {
|
|
|
756
1010
|
}
|
|
757
1011
|
|
|
758
1012
|
declare namespace $ {
|
|
1013
|
+
/**
|
|
1014
|
+
* Disable reaping of current subscriber
|
|
1015
|
+
*/
|
|
759
1016
|
function $mol_wire_solid(): void;
|
|
760
1017
|
}
|
|
761
1018
|
|
|
@@ -764,6 +1021,7 @@ declare namespace $ {
|
|
|
764
1021
|
}
|
|
765
1022
|
|
|
766
1023
|
declare namespace $ {
|
|
1024
|
+
/** Run code without state changes */
|
|
767
1025
|
function $mol_wire_probe<Value>(task: () => Value, def?: Value): Value | undefined;
|
|
768
1026
|
}
|
|
769
1027
|
|
|
@@ -776,6 +1034,10 @@ declare namespace $ {
|
|
|
776
1034
|
}
|
|
777
1035
|
|
|
778
1036
|
declare namespace $ {
|
|
1037
|
+
/**
|
|
1038
|
+
* Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
|
|
1039
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
1040
|
+
*/
|
|
779
1041
|
export function $mol_wire_sync<Host extends object>(obj: Host): ObjectOrFunctionResultAwaited<Host>;
|
|
780
1042
|
type FunctionResultAwaited<Some> = Some extends (...args: infer Args) => infer Res ? (...args: Args) => Awaited<Res> : Some;
|
|
781
1043
|
type ConstructorResultAwaited<Some> = Some extends new (...args: infer Args) => infer Res ? new (...args: Args) => Res : {};
|
|
@@ -819,6 +1081,11 @@ declare namespace $ {
|
|
|
819
1081
|
}
|
|
820
1082
|
|
|
821
1083
|
declare namespace $ {
|
|
1084
|
+
/**
|
|
1085
|
+
* Returns closure that returns constant value.
|
|
1086
|
+
* @example
|
|
1087
|
+
* const rnd = $mol_const( Math.random() )
|
|
1088
|
+
*/
|
|
822
1089
|
function $mol_const<Value>(value: Value): {
|
|
823
1090
|
(): Value;
|
|
824
1091
|
'()': Value;
|
|
@@ -826,6 +1093,10 @@ declare namespace $ {
|
|
|
826
1093
|
}
|
|
827
1094
|
|
|
828
1095
|
declare namespace $ {
|
|
1096
|
+
/**
|
|
1097
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber from [mol_wire](../wire/README.md)
|
|
1098
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
1099
|
+
*/
|
|
829
1100
|
let $mol_action: typeof $mol_wire_method;
|
|
830
1101
|
}
|
|
831
1102
|
|
|
@@ -840,6 +1111,7 @@ declare namespace $ {
|
|
|
840
1111
|
}
|
|
841
1112
|
|
|
842
1113
|
declare namespace $ {
|
|
1114
|
+
/** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
|
|
843
1115
|
export function $mol_wire_async<Host extends object>(obj: Host): ObjectOrFunctionResultPromisify<Host>;
|
|
844
1116
|
type FunctionResultPromisify<Some> = Some extends (...args: infer Args) => infer Res ? Res extends PromiseLike<unknown> ? Some : (...args: Args) => Promise<Res> : Some;
|
|
845
1117
|
type MethodsResultPromisify<Host extends Object> = {
|
|
@@ -870,6 +1142,7 @@ declare namespace $ {
|
|
|
870
1142
|
}
|
|
871
1143
|
|
|
872
1144
|
declare namespace $ {
|
|
1145
|
+
/** Temporary buffer. Recursive usage isn't supported. */
|
|
873
1146
|
function $mol_charset_buffer(size: number): Uint8Array<ArrayBuffer>;
|
|
874
1147
|
}
|
|
875
1148
|
|
|
@@ -912,6 +1185,10 @@ declare namespace $ {
|
|
|
912
1185
|
protected static changed: Set<$mol_file_base>;
|
|
913
1186
|
protected static frame: null | $mol_after_timeout;
|
|
914
1187
|
protected static changed_add(type: 'change' | 'rename', path: string): void;
|
|
1188
|
+
/**
|
|
1189
|
+
* Должно быть больше, чем время между событиями от вотчера при записи внешним процессом.
|
|
1190
|
+
* Иначе запуск ресетов паралельно с изменением может привести к неконсистентности.
|
|
1191
|
+
*/
|
|
915
1192
|
static watch_debounce(): number;
|
|
916
1193
|
static flush(): void;
|
|
917
1194
|
protected static watching: boolean;
|
|
@@ -1138,6 +1415,10 @@ declare namespace $ {
|
|
|
1138
1415
|
interface $mol_locale_dict {
|
|
1139
1416
|
[key: string]: string;
|
|
1140
1417
|
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Localisation in $mol framework
|
|
1420
|
+
* @see https://mol.hyoo.ru/#!section=docs/=s5aqnb_odub8l
|
|
1421
|
+
*/
|
|
1141
1422
|
class $mol_locale extends $mol_object {
|
|
1142
1423
|
static lang_default(): string;
|
|
1143
1424
|
static lang(next?: string): string;
|