mol_jsx_lib 0.0.1602 → 0.0.1604
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 +265 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +261 -13
- package/node.js.map +1 -1
- package/node.mjs +261 -13
- package/node.test.js +381 -14
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +219 -0
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +205 -9
- package/web.js.map +1 -1
- package/web.mjs +205 -9
- package/web.test.js +120 -1
- package/web.test.js.map +1 -1
package/node.d.ts
CHANGED
|
@@ -73,11 +73,17 @@ declare namespace $ {
|
|
|
73
73
|
|
|
74
74
|
declare namespace $ {
|
|
75
75
|
const $mol_ambient_ref: unique symbol;
|
|
76
|
+
/** @deprecated use $ instead */
|
|
76
77
|
type $mol_ambient_context = $;
|
|
77
78
|
function $mol_ambient(this: $ | void, overrides: Partial<$>): $;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
declare namespace $ {
|
|
82
|
+
/**
|
|
83
|
+
* Proxy that delegates all to lazy returned target.
|
|
84
|
+
*
|
|
85
|
+
* $mol_delegate( Array.prototype , ()=> fetch_array() )
|
|
86
|
+
*/
|
|
81
87
|
function $mol_delegate<Value extends object>(proto: Value, target: () => Value): Value;
|
|
82
88
|
}
|
|
83
89
|
|
|
@@ -141,57 +147,130 @@ declare namespace $ {
|
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
declare namespace $ {
|
|
150
|
+
/** Generates unique identifier. */
|
|
144
151
|
function $mol_guid(length?: number, exists?: (id: string) => boolean): string;
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
declare namespace $ {
|
|
155
|
+
/** Special status statuses. */
|
|
148
156
|
enum $mol_wire_cursor {
|
|
157
|
+
/** Update required. */
|
|
149
158
|
stale = -1,
|
|
159
|
+
/** Some of (transitive) pub update required. */
|
|
150
160
|
doubt = -2,
|
|
161
|
+
/** Actual state but may be dropped. */
|
|
151
162
|
fresh = -3,
|
|
163
|
+
/** State will never be changed. */
|
|
152
164
|
final = -4
|
|
153
165
|
}
|
|
154
166
|
}
|
|
155
167
|
|
|
156
168
|
declare namespace $ {
|
|
169
|
+
/**
|
|
170
|
+
* Collects subscribers in compact array. 28B
|
|
171
|
+
*/
|
|
157
172
|
class $mol_wire_pub extends Object {
|
|
158
173
|
constructor(id?: string);
|
|
159
174
|
[Symbol.toStringTag]: string;
|
|
160
175
|
data: unknown[];
|
|
161
176
|
static get [Symbol.species](): ArrayConstructor;
|
|
177
|
+
/**
|
|
178
|
+
* Index of first subscriber.
|
|
179
|
+
*/
|
|
162
180
|
protected sub_from: number;
|
|
181
|
+
/**
|
|
182
|
+
* All current subscribers.
|
|
183
|
+
*/
|
|
163
184
|
get sub_list(): readonly $mol_wire_sub[];
|
|
185
|
+
/**
|
|
186
|
+
* Has any subscribers or not.
|
|
187
|
+
*/
|
|
164
188
|
get sub_empty(): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
|
|
191
|
+
*/
|
|
165
192
|
sub_on(sub: $mol_wire_pub, pub_pos: number): number;
|
|
193
|
+
/**
|
|
194
|
+
* Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
|
|
195
|
+
*/
|
|
166
196
|
sub_off(sub_pos: number): void;
|
|
197
|
+
/**
|
|
198
|
+
* Called when last sub was unsubscribed.
|
|
199
|
+
**/
|
|
167
200
|
reap(): void;
|
|
201
|
+
/**
|
|
202
|
+
* Autowire this publisher with current subscriber.
|
|
203
|
+
**/
|
|
168
204
|
promote(): void;
|
|
205
|
+
/**
|
|
206
|
+
* Enforce actualization. Should not throw errors.
|
|
207
|
+
*/
|
|
169
208
|
fresh(): void;
|
|
209
|
+
/**
|
|
210
|
+
* Allow to put data to caches in the subtree.
|
|
211
|
+
*/
|
|
170
212
|
complete(): void;
|
|
171
213
|
get incompleted(): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Notify subscribers about self changes.
|
|
216
|
+
*/
|
|
172
217
|
emit(quant?: $mol_wire_cursor): void;
|
|
218
|
+
/**
|
|
219
|
+
* Moves peer from one position to another. Doesn't clear data at old position!
|
|
220
|
+
*/
|
|
173
221
|
peer_move(from_pos: number, to_pos: number): void;
|
|
222
|
+
/**
|
|
223
|
+
* Updates self position in the peer.
|
|
224
|
+
*/
|
|
174
225
|
peer_repos(peer_pos: number, self_pos: number): void;
|
|
175
226
|
}
|
|
176
227
|
}
|
|
177
228
|
|
|
178
229
|
declare namespace $ {
|
|
230
|
+
/** Generic subscriber interface */
|
|
179
231
|
interface $mol_wire_sub extends $mol_wire_pub {
|
|
180
232
|
temp: boolean;
|
|
181
233
|
pub_list: $mol_wire_pub[];
|
|
234
|
+
/**
|
|
235
|
+
* Begin auto wire to publishers.
|
|
236
|
+
* Returns previous auto subscriber that must me transfer to the `end`.
|
|
237
|
+
*/
|
|
182
238
|
track_on(): $mol_wire_sub | null;
|
|
239
|
+
/**
|
|
240
|
+
* Returns next auto wired publisher. It can be easely repormoted.
|
|
241
|
+
* Or promotes next publisher to auto wire its togeter.
|
|
242
|
+
* Must be used only between `track_on` and `track_off`.
|
|
243
|
+
*/
|
|
183
244
|
track_next(pub?: $mol_wire_pub): $mol_wire_pub | null;
|
|
184
245
|
pub_off(pub_pos: number): void;
|
|
246
|
+
/**
|
|
247
|
+
* Unsubscribes from unpromoted publishers.
|
|
248
|
+
*/
|
|
185
249
|
track_cut(sub: $mol_wire_pub | null): void;
|
|
250
|
+
/**
|
|
251
|
+
* Ends auto wire to publishers.
|
|
252
|
+
*/
|
|
186
253
|
track_off(sub: $mol_wire_pub | null): void;
|
|
254
|
+
/**
|
|
255
|
+
* Receive notification about publisher changes.
|
|
256
|
+
*/
|
|
187
257
|
absorb(quant: $mol_wire_cursor, pos: number): void;
|
|
258
|
+
/**
|
|
259
|
+
* Unsubscribes from all publishers.
|
|
260
|
+
*/
|
|
188
261
|
destructor(): void;
|
|
189
262
|
}
|
|
190
263
|
}
|
|
191
264
|
|
|
192
265
|
declare namespace $ {
|
|
193
266
|
let $mol_wire_auto_sub: $mol_wire_sub | null;
|
|
267
|
+
/**
|
|
268
|
+
* When fulfilled, all publishers are promoted to this subscriber on access to its.
|
|
269
|
+
*/
|
|
194
270
|
function $mol_wire_auto(next?: $mol_wire_sub | null): $mol_wire_sub | null;
|
|
271
|
+
/**
|
|
272
|
+
* Affection queue. Used to prevent accidental stack overflow on emit.
|
|
273
|
+
*/
|
|
195
274
|
const $mol_wire_affected: ($mol_wire_sub | number)[];
|
|
196
275
|
}
|
|
197
276
|
|
|
@@ -224,6 +303,13 @@ declare namespace $ {
|
|
|
224
303
|
}
|
|
225
304
|
|
|
226
305
|
declare namespace $ {
|
|
306
|
+
/**
|
|
307
|
+
* Publisher that can auto collect other publishers. 32B
|
|
308
|
+
*
|
|
309
|
+
* P1 P2 P3 P4 S1 S2 S3
|
|
310
|
+
* ^ ^
|
|
311
|
+
* pubs_from subs_from
|
|
312
|
+
*/
|
|
227
313
|
class $mol_wire_pub_sub extends $mol_wire_pub implements $mol_wire_sub {
|
|
228
314
|
protected pub_from: number;
|
|
229
315
|
protected cursor: $mol_wire_cursor;
|
|
@@ -240,6 +326,9 @@ declare namespace $ {
|
|
|
240
326
|
complete_pubs(): void;
|
|
241
327
|
absorb(quant?: $mol_wire_cursor, pos?: number): void;
|
|
242
328
|
[$mol_dev_format_head](): any[];
|
|
329
|
+
/**
|
|
330
|
+
* Is subscribed to any publisher or not.
|
|
331
|
+
*/
|
|
243
332
|
get pub_empty(): boolean;
|
|
244
333
|
}
|
|
245
334
|
}
|
|
@@ -255,6 +344,13 @@ declare namespace $ {
|
|
|
255
344
|
}
|
|
256
345
|
|
|
257
346
|
declare namespace $ {
|
|
347
|
+
/**
|
|
348
|
+
* Suspendable task with support both sync/async api.
|
|
349
|
+
*
|
|
350
|
+
* A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
|
|
351
|
+
* ^ ^ ^
|
|
352
|
+
* args_from pubs_from subs_from
|
|
353
|
+
**/
|
|
258
354
|
abstract class $mol_wire_fiber<Host, Args extends readonly unknown[], Result> extends $mol_wire_pub_sub {
|
|
259
355
|
readonly task: (this: Host, ...args: Args) => Result;
|
|
260
356
|
readonly host?: Host | undefined;
|
|
@@ -281,7 +377,15 @@ declare namespace $ {
|
|
|
281
377
|
fresh(): this | undefined;
|
|
282
378
|
refresh(): void;
|
|
283
379
|
abstract put(next: Result | Error | Promise<Result | Error>): Result | Error | Promise<Result | Error>;
|
|
380
|
+
/**
|
|
381
|
+
* Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
|
|
382
|
+
* Should be called inside SuspenseAPI consumer (ie fiber).
|
|
383
|
+
*/
|
|
284
384
|
sync(): Awaited<Result>;
|
|
385
|
+
/**
|
|
386
|
+
* Asynchronous execution.
|
|
387
|
+
* It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
|
|
388
|
+
*/
|
|
285
389
|
async_raw(): Promise<Result>;
|
|
286
390
|
async(): Promise<Result> & {
|
|
287
391
|
destructor(): void;
|
|
@@ -293,31 +397,48 @@ declare namespace $ {
|
|
|
293
397
|
|
|
294
398
|
declare namespace $ {
|
|
295
399
|
let $mol_compare_deep_cache: WeakMap<any, WeakMap<any, boolean>>;
|
|
400
|
+
/**
|
|
401
|
+
* Deeply compares two values. Returns true if equal.
|
|
402
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
403
|
+
*/
|
|
296
404
|
function $mol_compare_deep<Value>(left: Value, right: Value): boolean;
|
|
297
405
|
}
|
|
298
406
|
|
|
299
407
|
declare namespace $ {
|
|
408
|
+
/** Logger event data */
|
|
300
409
|
type $mol_log3_event<Fields> = {
|
|
301
410
|
[key in string]: unknown;
|
|
302
411
|
} & {
|
|
412
|
+
/** Time of event creation */
|
|
303
413
|
time?: string;
|
|
414
|
+
/** Place of event creation */
|
|
304
415
|
place: unknown;
|
|
416
|
+
/** Short description of event */
|
|
305
417
|
message: string;
|
|
306
418
|
} & Fields;
|
|
419
|
+
/** Logger function */
|
|
307
420
|
type $mol_log3_logger<Fields, Res = void> = (this: $, event: $mol_log3_event<Fields>) => Res;
|
|
421
|
+
/** Log begin of some task */
|
|
308
422
|
let $mol_log3_come: $mol_log3_logger<{}>;
|
|
423
|
+
/** Log end of some task */
|
|
309
424
|
let $mol_log3_done: $mol_log3_logger<{}>;
|
|
425
|
+
/** Log error */
|
|
310
426
|
let $mol_log3_fail: $mol_log3_logger<{}>;
|
|
427
|
+
/** Log warning message */
|
|
311
428
|
let $mol_log3_warn: $mol_log3_logger<{
|
|
312
429
|
hint: string;
|
|
313
430
|
}>;
|
|
431
|
+
/** Log some generic event */
|
|
314
432
|
let $mol_log3_rise: $mol_log3_logger<{}>;
|
|
433
|
+
/** Log begin of log group, returns func to close group */
|
|
315
434
|
let $mol_log3_area: $mol_log3_logger<{}, () => void>;
|
|
435
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
316
436
|
function $mol_log3_area_lazy(this: $, event: $mol_log3_event<{}>): () => void;
|
|
317
437
|
let $mol_log3_stack: (() => void)[];
|
|
318
438
|
}
|
|
319
439
|
|
|
320
440
|
declare namespace $ {
|
|
441
|
+
/** Position in any resource. */
|
|
321
442
|
class $mol_span extends $mol_object2 {
|
|
322
443
|
readonly uri: string;
|
|
323
444
|
readonly source: string;
|
|
@@ -325,9 +446,13 @@ declare namespace $ {
|
|
|
325
446
|
readonly col: number;
|
|
326
447
|
readonly length: number;
|
|
327
448
|
constructor(uri: string, source: string, row: number, col: number, length: number);
|
|
449
|
+
/** Span for begin of unknown resource */
|
|
328
450
|
static unknown: $mol_span;
|
|
451
|
+
/** Makes new span for begin of resource. */
|
|
329
452
|
static begin(uri: string, source?: string): $mol_span;
|
|
453
|
+
/** Makes new span for end of resource. */
|
|
330
454
|
static end(uri: string, source: string): $mol_span;
|
|
455
|
+
/** Makes new span for entire resource. */
|
|
331
456
|
static entire(uri: string, source: string): $mol_span;
|
|
332
457
|
toString(): string;
|
|
333
458
|
toJSON(): {
|
|
@@ -336,14 +461,19 @@ declare namespace $ {
|
|
|
336
461
|
col: number;
|
|
337
462
|
length: number;
|
|
338
463
|
};
|
|
464
|
+
/** Makes new error for this span. */
|
|
339
465
|
error(message: string, Class?: ErrorConstructor): Error;
|
|
466
|
+
/** Makes new span for same uri. */
|
|
340
467
|
span(row: number, col: number, length: number): $mol_span;
|
|
468
|
+
/** Makes new span after end of this. */
|
|
341
469
|
after(length?: number): $mol_span;
|
|
470
|
+
/** Makes new span between begin and end. */
|
|
342
471
|
slice(begin: number, end?: number): $mol_span;
|
|
343
472
|
}
|
|
344
473
|
}
|
|
345
474
|
|
|
346
475
|
declare namespace $ {
|
|
476
|
+
/** Serializes tree to string in tree format. */
|
|
347
477
|
function $mol_tree2_to_string(this: $, tree: $mol_tree2): string;
|
|
348
478
|
}
|
|
349
479
|
|
|
@@ -352,37 +482,74 @@ declare namespace $ {
|
|
|
352
482
|
}
|
|
353
483
|
|
|
354
484
|
declare namespace $ {
|
|
485
|
+
/** Path by types in tree. */
|
|
355
486
|
type $mol_tree2_path = Array<string | number | null>;
|
|
487
|
+
/** Hask tool for processing node. */
|
|
356
488
|
type $mol_tree2_hack<Context> = (input: $mol_tree2, belt: $mol_tree2_belt<Context>, context: Context) => readonly $mol_tree2[];
|
|
489
|
+
/** Collection of hask tools for processing tree. */
|
|
357
490
|
type $mol_tree2_belt<Context> = Record<string, $mol_tree2_hack<Context>>;
|
|
491
|
+
/**
|
|
492
|
+
* Abstract Syntax Tree with human readable serialization.
|
|
493
|
+
* Avoid direct instantiation. Use static factories instead.
|
|
494
|
+
* @see https://github.com/nin-jin/tree.d
|
|
495
|
+
*/
|
|
358
496
|
class $mol_tree2 extends Object {
|
|
497
|
+
/** Type of structural node, `value` should be empty */
|
|
359
498
|
readonly type: string;
|
|
499
|
+
/** Content of data node, `type` should be empty */
|
|
360
500
|
readonly value: string;
|
|
501
|
+
/** Child nodes */
|
|
361
502
|
readonly kids: readonly $mol_tree2[];
|
|
503
|
+
/** Position in most far source resource */
|
|
362
504
|
readonly span: $mol_span;
|
|
363
|
-
constructor(
|
|
505
|
+
constructor(
|
|
506
|
+
/** Type of structural node, `value` should be empty */
|
|
507
|
+
type: string,
|
|
508
|
+
/** Content of data node, `type` should be empty */
|
|
509
|
+
value: string,
|
|
510
|
+
/** Child nodes */
|
|
511
|
+
kids: readonly $mol_tree2[],
|
|
512
|
+
/** Position in most far source resource */
|
|
513
|
+
span: $mol_span);
|
|
514
|
+
/** Makes collection node. */
|
|
364
515
|
static list(kids: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
|
|
516
|
+
/** Makes new derived collection node. */
|
|
365
517
|
list(kids: readonly $mol_tree2[]): $mol_tree2;
|
|
518
|
+
/** Makes data node for any string. */
|
|
366
519
|
static data(value: string, kids?: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
|
|
520
|
+
/** Makes new derived data node. */
|
|
367
521
|
data(value: string, kids?: readonly $mol_tree2[]): $mol_tree2;
|
|
522
|
+
/** Makes struct node. */
|
|
368
523
|
static struct(type: string, kids?: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
|
|
524
|
+
/** Makes new derived structural node. */
|
|
369
525
|
struct(type: string, kids?: readonly $mol_tree2[]): $mol_tree2;
|
|
526
|
+
/** Makes new derived node with different kids id defined. */
|
|
370
527
|
clone(kids: readonly $mol_tree2[], span?: $mol_span): $mol_tree2;
|
|
528
|
+
/** Returns multiline text content. */
|
|
371
529
|
text(): string;
|
|
530
|
+
/** Parses tree format. */
|
|
531
|
+
/** @deprecated Use $mol_tree2_from_string */
|
|
372
532
|
static fromString(str: string, uri?: string): $mol_tree2;
|
|
533
|
+
/** Serializes to tree format. */
|
|
373
534
|
toString(): string;
|
|
535
|
+
/** Makes new tree with node overrided by path. */
|
|
374
536
|
insert(value: $mol_tree2 | null, ...path: $mol_tree2_path): $mol_tree2;
|
|
537
|
+
/** Makes new tree with node overrided by path. */
|
|
375
538
|
update(value: readonly $mol_tree2[], ...path: $mol_tree2_path): readonly $mol_tree2[];
|
|
539
|
+
/** Query nodes by path. */
|
|
376
540
|
select(...path: $mol_tree2_path): $mol_tree2;
|
|
541
|
+
/** Filter kids by path or value. */
|
|
377
542
|
filter(path: string[], value?: string): $mol_tree2;
|
|
378
543
|
hack_self<Context extends {
|
|
379
544
|
span?: $mol_span;
|
|
380
545
|
[key: string]: unknown;
|
|
381
546
|
} = {}>(belt: $mol_tree2_belt<Context>, context?: Context): readonly $mol_tree2[];
|
|
547
|
+
/** Transform tree through context with transformers */
|
|
382
548
|
hack<Context extends {
|
|
383
549
|
span?: $mol_span;
|
|
384
550
|
[key: string]: unknown;
|
|
385
551
|
} = {}>(belt: $mol_tree2_belt<Context>, context?: Context): $mol_tree2[];
|
|
552
|
+
/** Makes Error with node coordinates. */
|
|
386
553
|
error(message: string, Class?: ErrorConstructor): Error;
|
|
387
554
|
}
|
|
388
555
|
class $mol_tree2_empty extends $mol_tree2 {
|
|
@@ -391,6 +558,7 @@ declare namespace $ {
|
|
|
391
558
|
}
|
|
392
559
|
|
|
393
560
|
declare namespace $ {
|
|
561
|
+
/** Syntax error with cordinates and source line snippet. */
|
|
394
562
|
class $mol_error_syntax extends SyntaxError {
|
|
395
563
|
reason: string;
|
|
396
564
|
line: string;
|
|
@@ -400,6 +568,7 @@ declare namespace $ {
|
|
|
400
568
|
}
|
|
401
569
|
|
|
402
570
|
declare namespace $ {
|
|
571
|
+
/** Parses tree format from string. */
|
|
403
572
|
function $mol_tree2_from_string(this: $, str: string, uri?: string): $mol_tree2;
|
|
404
573
|
}
|
|
405
574
|
|
|
@@ -412,6 +581,7 @@ declare namespace $ {
|
|
|
412
581
|
}
|
|
413
582
|
|
|
414
583
|
declare namespace $ {
|
|
584
|
+
/** Module for working with terminal. Text coloring when output in terminal */
|
|
415
585
|
class $mol_term_color {
|
|
416
586
|
static reset: (str: string) => string;
|
|
417
587
|
static bold: (str: string) => string;
|
|
@@ -443,6 +613,7 @@ declare namespace $ {
|
|
|
443
613
|
}
|
|
444
614
|
|
|
445
615
|
declare namespace $ {
|
|
616
|
+
/** One-shot fiber */
|
|
446
617
|
class $mol_wire_task<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
|
|
447
618
|
static getter<Host, Args extends readonly unknown[], Result>(task: (this: Host, ...args: Args) => Result): (host: Host, args: Args) => $mol_wire_task<Host, Args, Result>;
|
|
448
619
|
get temp(): boolean;
|
|
@@ -453,6 +624,10 @@ declare namespace $ {
|
|
|
453
624
|
}
|
|
454
625
|
|
|
455
626
|
declare namespace $ {
|
|
627
|
+
/**
|
|
628
|
+
* Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
|
|
629
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
630
|
+
*/
|
|
456
631
|
export function $mol_wire_sync<Host extends object>(obj: Host): ObjectOrFunctionResultAwaited<Host>;
|
|
457
632
|
type FunctionResultAwaited<Some> = Some extends (...args: infer Args) => infer Res ? (...args: Args) => Awaited<Res> : Some;
|
|
458
633
|
type ConstructorResultAwaited<Some> = Some extends new (...args: infer Args) => infer Res ? new (...args: Args) => Res : {};
|
|
@@ -510,6 +685,11 @@ declare namespace $ {
|
|
|
510
685
|
}
|
|
511
686
|
|
|
512
687
|
declare namespace $ {
|
|
688
|
+
/**
|
|
689
|
+
* Recursive `Partial`.
|
|
690
|
+
*
|
|
691
|
+
* let props : $mol_type_partial_deep< HTMLElement > = { style : { display : 'block' } }
|
|
692
|
+
*/
|
|
513
693
|
type $mol_type_partial_deep<Val> = Val extends object ? Val extends Function ? Val : {
|
|
514
694
|
[field in keyof Val]?: $mol_type_partial_deep<Val[field]> | undefined;
|
|
515
695
|
} : Val;
|
|
@@ -521,6 +701,12 @@ declare namespace $ {
|
|
|
521
701
|
let $mol_jsx_booked: null | Set<string>;
|
|
522
702
|
let $mol_jsx_document: $mol_jsx.JSX.ElementClass['ownerDocument'];
|
|
523
703
|
const $mol_jsx_frag = "";
|
|
704
|
+
/**
|
|
705
|
+
* JSX adapter that makes DOM tree.
|
|
706
|
+
* Generates global unique ids for every DOM-element by components tree with ids.
|
|
707
|
+
* Ensures all local ids are unique.
|
|
708
|
+
* Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
|
|
709
|
+
*/
|
|
524
710
|
function $mol_jsx<Props extends $mol_jsx.JSX.IntrinsicAttributes, Children extends Array<Node | string>>(Elem: string | ((props: Props, ...children: Children) => Element), props: Props, ...childNodes: Children): Element | DocumentFragment;
|
|
525
711
|
namespace $mol_jsx.JSX {
|
|
526
712
|
interface Element extends HTMLElement {
|
|
@@ -535,9 +721,11 @@ declare namespace $ {
|
|
|
535
721
|
type OrString<Dict> = {
|
|
536
722
|
[key in keyof Dict]: Dict[key] | string;
|
|
537
723
|
};
|
|
724
|
+
/** Props for html elements */
|
|
538
725
|
type IntrinsicElements = {
|
|
539
726
|
[key in keyof ElementTagNameMap]?: $.$mol_type_partial_deep<OrString<Element & IntrinsicAttributes & ElementTagNameMap[key]>>;
|
|
540
727
|
};
|
|
728
|
+
/** Additional undeclared props */
|
|
541
729
|
interface IntrinsicAttributes {
|
|
542
730
|
id?: string;
|
|
543
731
|
xmlns?: string;
|
|
@@ -555,6 +743,11 @@ declare namespace $ {
|
|
|
555
743
|
}
|
|
556
744
|
|
|
557
745
|
declare namespace $ {
|
|
746
|
+
/**
|
|
747
|
+
* Returns closure that returns constant value.
|
|
748
|
+
* @example
|
|
749
|
+
* const rnd = $mol_const( Math.random() )
|
|
750
|
+
*/
|
|
558
751
|
function $mol_const<Value>(value: Value): {
|
|
559
752
|
(): Value;
|
|
560
753
|
'()': Value;
|
|
@@ -562,6 +755,7 @@ declare namespace $ {
|
|
|
562
755
|
}
|
|
563
756
|
|
|
564
757
|
declare namespace $ {
|
|
758
|
+
/** Returns string key for any value. */
|
|
565
759
|
function $mol_key<Value>(value: Value): string;
|
|
566
760
|
}
|
|
567
761
|
|
|
@@ -583,6 +777,9 @@ declare namespace $ {
|
|
|
583
777
|
}
|
|
584
778
|
|
|
585
779
|
declare namespace $ {
|
|
780
|
+
/**
|
|
781
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber.
|
|
782
|
+
*/
|
|
586
783
|
function $mol_wire_method<Host extends object, Args extends readonly any[]>(host: Host, field: PropertyKey, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
|
|
587
784
|
value: (this: Host, ...args: Args) => any;
|
|
588
785
|
enumerable?: boolean;
|
|
@@ -594,14 +791,25 @@ declare namespace $ {
|
|
|
594
791
|
}
|
|
595
792
|
|
|
596
793
|
declare namespace $ {
|
|
794
|
+
/**
|
|
795
|
+
* Returns `Tuple` without first element.
|
|
796
|
+
*
|
|
797
|
+
* $mol_type_tail<[ 1 , 2 , 3 ]> // [ 2, 3 ]
|
|
798
|
+
*/
|
|
597
799
|
type $mol_type_tail<Tuple extends readonly any[]> = ((...tail: Tuple) => any) extends ((head: any, ...tail: infer Tail) => any) ? Tail : never;
|
|
598
800
|
}
|
|
599
801
|
|
|
600
802
|
declare namespace $ {
|
|
803
|
+
/**
|
|
804
|
+
* Returns last element of `Tuple`.
|
|
805
|
+
*
|
|
806
|
+
* $mol_type_tail<[ 1 , 2 , 3 ]> // 3
|
|
807
|
+
*/
|
|
601
808
|
type $mol_type_foot<Tuple extends readonly any[]> = Tuple['length'] extends 0 ? never : Tuple[$mol_type_tail<Tuple>['length']];
|
|
602
809
|
}
|
|
603
810
|
|
|
604
811
|
declare namespace $ {
|
|
812
|
+
/** Long-living fiber. */
|
|
605
813
|
class $mol_wire_atom<Host, Args extends readonly unknown[], Result> extends $mol_wire_fiber<Host, Args, Result> {
|
|
606
814
|
static solo<Host, Args extends readonly unknown[], Result>(host: Host, task: (this: Host, ...args: Args) => Result): $mol_wire_atom<Host, Args, Result>;
|
|
607
815
|
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>;
|
|
@@ -609,6 +817,9 @@ declare namespace $ {
|
|
|
609
817
|
static watcher: $mol_after_frame | null;
|
|
610
818
|
static watch(): void;
|
|
611
819
|
watch(): void;
|
|
820
|
+
/**
|
|
821
|
+
* Update atom value through another temp fiber.
|
|
822
|
+
*/
|
|
612
823
|
resync(args: Args): Error | Result | Promise<Error | Result>;
|
|
613
824
|
once(): Awaited<Result>;
|
|
614
825
|
channel(): ((next?: $mol_type_foot<Args>) => Awaited<Result>) & {
|
|
@@ -620,16 +831,19 @@ declare namespace $ {
|
|
|
620
831
|
}
|
|
621
832
|
|
|
622
833
|
declare namespace $ {
|
|
834
|
+
/** Incompatible with instance fields with initializators */
|
|
623
835
|
function $mol_wire_field<Host extends object, Field extends keyof Host, Value extends Host[Field]>(host: Host, field: Field, descr?: TypedPropertyDescriptor<Value>): any;
|
|
624
836
|
}
|
|
625
837
|
|
|
626
838
|
declare namespace $ {
|
|
839
|
+
/** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
|
|
627
840
|
export function $mol_wire_solo<Args extends any[]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): TypedPropertyDescriptor<(...args: First_optional<Args>) => any>;
|
|
628
841
|
type First_optional<Args extends any[]> = Args extends [] ? [] : [Args[0] | undefined, ...$mol_type_tail<Args>];
|
|
629
842
|
export {};
|
|
630
843
|
}
|
|
631
844
|
|
|
632
845
|
declare namespace $ {
|
|
846
|
+
/** Reactive memoizing multiplexed property decorator. */
|
|
633
847
|
function $mol_wire_plex<Args extends [any, ...any[]]>(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): {
|
|
634
848
|
value: (this: typeof host, ...args: Args) => any;
|
|
635
849
|
enumerable?: boolean;
|
|
@@ -641,35 +855,70 @@ declare namespace $ {
|
|
|
641
855
|
}
|
|
642
856
|
|
|
643
857
|
declare namespace $ {
|
|
858
|
+
/**
|
|
859
|
+
* Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
|
|
860
|
+
* @example
|
|
861
|
+
* '@' $mol_mem
|
|
862
|
+
* name(next?: string) {
|
|
863
|
+
* return next ?? 'default'
|
|
864
|
+
* }
|
|
865
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
866
|
+
*/
|
|
644
867
|
let $mol_mem: typeof $mol_wire_solo;
|
|
868
|
+
/**
|
|
869
|
+
* Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
|
|
870
|
+
* @example
|
|
871
|
+
* '@' $mol_mem_key
|
|
872
|
+
* name(id: number, next?: string) {
|
|
873
|
+
* return next ?? 'default'
|
|
874
|
+
* }
|
|
875
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
876
|
+
*/
|
|
645
877
|
let $mol_mem_key: typeof $mol_wire_plex;
|
|
646
878
|
}
|
|
647
879
|
|
|
880
|
+
/** @jsx $mol_jsx */
|
|
648
881
|
declare namespace $ {
|
|
882
|
+
/** Reactive JSX component */
|
|
649
883
|
abstract class $mol_jsx_view extends $mol_object2 {
|
|
884
|
+
/** Returns component instance for DOM node. */
|
|
650
885
|
static of<This extends typeof $mol_jsx_view>(this: This, node: Element): InstanceType<This>;
|
|
651
886
|
attributes: Partial<Pick<this, Exclude<keyof this, 'valueOf'>>>;
|
|
887
|
+
/** Document to reuse DOM elements by ID */
|
|
652
888
|
ownerDocument: typeof $mol_jsx_document;
|
|
889
|
+
/** Autogenerated class names */
|
|
653
890
|
className: string;
|
|
891
|
+
/** Children to render inside */
|
|
654
892
|
get childNodes(): Array<Node | string>;
|
|
893
|
+
/** Memoized render in right context */
|
|
655
894
|
valueOf(): HTMLElement;
|
|
895
|
+
/** Returns actual DOM tree */
|
|
656
896
|
abstract render(): HTMLElement;
|
|
657
897
|
}
|
|
658
898
|
}
|
|
659
899
|
|
|
660
900
|
declare namespace $ {
|
|
901
|
+
/** Run code without state changes */
|
|
661
902
|
function $mol_wire_probe<Value>(task: () => Value, def?: Value): Value | undefined;
|
|
662
903
|
}
|
|
663
904
|
|
|
664
905
|
declare namespace $ {
|
|
906
|
+
/**
|
|
907
|
+
* Disable reaping of current subscriber
|
|
908
|
+
*/
|
|
665
909
|
function $mol_wire_solid(): void;
|
|
666
910
|
}
|
|
667
911
|
|
|
668
912
|
declare namespace $ {
|
|
913
|
+
/**
|
|
914
|
+
* Real-time refresh current atom.
|
|
915
|
+
* Don't use if possible. May reduce performance.
|
|
916
|
+
*/
|
|
669
917
|
function $mol_wire_watch(): void;
|
|
670
918
|
}
|
|
671
919
|
|
|
672
920
|
declare namespace $ {
|
|
921
|
+
/** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
|
|
673
922
|
export function $mol_wire_async<Host extends object>(obj: Host): ObjectOrFunctionResultPromisify<Host>;
|
|
674
923
|
type FunctionResultPromisify<Some> = Some extends (...args: infer Args) => infer Res ? Res extends PromiseLike<unknown> ? Some : (...args: Args) => Promise<Res> : Some;
|
|
675
924
|
type MethodsResultPromisify<Host extends Object> = {
|
|
@@ -680,12 +929,14 @@ declare namespace $ {
|
|
|
680
929
|
}
|
|
681
930
|
|
|
682
931
|
declare namespace $ {
|
|
932
|
+
/** Starts subtasks concurrently instead of serial. */
|
|
683
933
|
function $mol_wire_race<Tasks extends ((...args: any) => any)[]>(...tasks: Tasks): {
|
|
684
934
|
[index in keyof Tasks]: ReturnType<Tasks[index]>;
|
|
685
935
|
};
|
|
686
936
|
}
|
|
687
937
|
|
|
688
938
|
declare namespace $ {
|
|
939
|
+
/** State of time moment */
|
|
689
940
|
class $mol_state_time extends $mol_object {
|
|
690
941
|
static task(precision: number, reset?: null): $mol_after_timeout | $mol_after_frame;
|
|
691
942
|
static now(precision: number): number;
|
|
@@ -693,6 +944,7 @@ declare namespace $ {
|
|
|
693
944
|
}
|
|
694
945
|
|
|
695
946
|
declare namespace $ {
|
|
947
|
+
/** Transition atom value */
|
|
696
948
|
function $mol_wire_easing(next: any): any;
|
|
697
949
|
}
|
|
698
950
|
|
|
@@ -701,6 +953,15 @@ declare namespace $ {
|
|
|
701
953
|
}
|
|
702
954
|
|
|
703
955
|
declare namespace $ {
|
|
956
|
+
/**
|
|
957
|
+
* Returns type of function result or class instance.
|
|
958
|
+
*
|
|
959
|
+
* // 777
|
|
960
|
+
* $mol_type_result< ()=> 777 >
|
|
961
|
+
*
|
|
962
|
+
* // 777
|
|
963
|
+
* $mol_type_result< new()=> 777 >
|
|
964
|
+
*/
|
|
704
965
|
type $mol_type_result<Func> = Func extends (...params: any) => infer Result ? Result : Func extends new (...params: any) => infer Result ? Result : never;
|
|
705
966
|
}
|
|
706
967
|
|
|
@@ -711,6 +972,7 @@ declare namespace $ {
|
|
|
711
972
|
}
|
|
712
973
|
|
|
713
974
|
declare namespace $ {
|
|
975
|
+
/** Reactive Set */
|
|
714
976
|
class $mol_wire_set<Value> extends Set<Value> {
|
|
715
977
|
pub: $mol_wire_pub;
|
|
716
978
|
has(value: Value): boolean;
|
|
@@ -733,6 +995,7 @@ declare namespace $ {
|
|
|
733
995
|
}
|
|
734
996
|
|
|
735
997
|
declare namespace $ {
|
|
998
|
+
/** reactive Dictionary */
|
|
736
999
|
class $mol_wire_dict<Key, Value> extends Map<Key, Value> {
|
|
737
1000
|
pub: $mol_wire_pub;
|
|
738
1001
|
has(key: Key): boolean;
|
|
@@ -764,6 +1027,7 @@ declare namespace $ {
|
|
|
764
1027
|
}
|
|
765
1028
|
|
|
766
1029
|
declare namespace $ {
|
|
1030
|
+
/** Watch and logs reactive states. Logger automatically added to test bundle which is adding to `test.html`. */
|
|
767
1031
|
class $mol_wire_log extends $mol_object2 {
|
|
768
1032
|
static watch(task?: () => any): (() => any) | undefined;
|
|
769
1033
|
static track(fiber: $mol_wire_fiber<any, any, any>): any;
|