mol_wire_lib 1.0.1739 → 1.0.1741
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 +244 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +243 -10
- package/node.js.map +1 -1
- package/node.mjs +243 -10
- package/node.test.js +371 -14
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +198 -0
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +191 -9
- package/web.js.map +1 -1
- package/web.mjs +191 -9
- package/web.test.js +124 -1
- package/web.test.js.map +1 -1
package/node.js
CHANGED
|
@@ -32,6 +32,7 @@ $.$$ = $
|
|
|
32
32
|
"use strict";
|
|
33
33
|
var $;
|
|
34
34
|
(function ($) {
|
|
35
|
+
/** Generates unique identifier. */
|
|
35
36
|
function $mol_guid(length = 8, exists = () => false) {
|
|
36
37
|
for (;;) {
|
|
37
38
|
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
@@ -57,11 +58,16 @@ var $;
|
|
|
57
58
|
"use strict";
|
|
58
59
|
var $;
|
|
59
60
|
(function ($) {
|
|
61
|
+
/** Special status statuses. */
|
|
60
62
|
let $mol_wire_cursor;
|
|
61
63
|
(function ($mol_wire_cursor) {
|
|
64
|
+
/** Update required. */
|
|
62
65
|
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
66
|
+
/** Some of (transitive) pub update required. */
|
|
63
67
|
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
68
|
+
/** Actual state but may be dropped. */
|
|
64
69
|
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
70
|
+
/** State will never be changed. */
|
|
65
71
|
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
66
72
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
67
73
|
})($ || ($ = {}));
|
|
@@ -70,6 +76,9 @@ var $;
|
|
|
70
76
|
"use strict";
|
|
71
77
|
var $;
|
|
72
78
|
(function ($) {
|
|
79
|
+
/**
|
|
80
|
+
* Collects subscribers in compact array. 28B
|
|
81
|
+
*/
|
|
73
82
|
class $mol_wire_pub extends Object {
|
|
74
83
|
constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
|
|
75
84
|
super();
|
|
@@ -77,10 +86,17 @@ var $;
|
|
|
77
86
|
}
|
|
78
87
|
[Symbol.toStringTag];
|
|
79
88
|
data = [];
|
|
89
|
+
// Derived objects should be Arrays.
|
|
80
90
|
static get [Symbol.species]() {
|
|
81
91
|
return Array;
|
|
82
92
|
}
|
|
83
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Index of first subscriber.
|
|
95
|
+
*/
|
|
96
|
+
sub_from = 0; // 4B
|
|
97
|
+
/**
|
|
98
|
+
* All current subscribers.
|
|
99
|
+
*/
|
|
84
100
|
get sub_list() {
|
|
85
101
|
const res = [];
|
|
86
102
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
@@ -88,14 +104,23 @@ var $;
|
|
|
88
104
|
}
|
|
89
105
|
return res;
|
|
90
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Has any subscribers or not.
|
|
109
|
+
*/
|
|
91
110
|
get sub_empty() {
|
|
92
111
|
return this.sub_from === this.data.length;
|
|
93
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
|
|
115
|
+
*/
|
|
94
116
|
sub_on(sub, pub_pos) {
|
|
95
117
|
const pos = this.data.length;
|
|
96
118
|
this.data.push(sub, pub_pos);
|
|
97
119
|
return pos;
|
|
98
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
|
|
123
|
+
*/
|
|
99
124
|
sub_off(sub_pos) {
|
|
100
125
|
if (!(sub_pos < this.data.length)) {
|
|
101
126
|
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
@@ -108,21 +133,39 @@ var $;
|
|
|
108
133
|
if (end === this.sub_from)
|
|
109
134
|
this.reap();
|
|
110
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Called when last sub was unsubscribed.
|
|
138
|
+
**/
|
|
111
139
|
reap() { }
|
|
140
|
+
/**
|
|
141
|
+
* Autowire this publisher with current subscriber.
|
|
142
|
+
**/
|
|
112
143
|
promote() {
|
|
113
144
|
$mol_wire_auto()?.track_next(this);
|
|
114
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Enforce actualization. Should not throw errors.
|
|
148
|
+
*/
|
|
115
149
|
fresh() { }
|
|
150
|
+
/**
|
|
151
|
+
* Allow to put data to caches in the subtree.
|
|
152
|
+
*/
|
|
116
153
|
complete() { }
|
|
117
154
|
get incompleted() {
|
|
118
155
|
return false;
|
|
119
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Notify subscribers about self changes.
|
|
159
|
+
*/
|
|
120
160
|
emit(quant = $mol_wire_cursor.stale) {
|
|
121
161
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
122
162
|
;
|
|
123
163
|
this.data[i].absorb(quant, this.data[i + 1]);
|
|
124
164
|
}
|
|
125
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Moves peer from one position to another. Doesn't clear data at old position!
|
|
168
|
+
*/
|
|
126
169
|
peer_move(from_pos, to_pos) {
|
|
127
170
|
const peer = this.data[from_pos];
|
|
128
171
|
const self_pos = this.data[from_pos + 1];
|
|
@@ -130,6 +173,9 @@ var $;
|
|
|
130
173
|
this.data[to_pos + 1] = self_pos;
|
|
131
174
|
peer.peer_repos(self_pos, to_pos);
|
|
132
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Updates self position in the peer.
|
|
178
|
+
*/
|
|
133
179
|
peer_repos(peer_pos, self_pos) {
|
|
134
180
|
this.data[peer_pos + 1] = self_pos;
|
|
135
181
|
}
|
|
@@ -145,10 +191,16 @@ var $;
|
|
|
145
191
|
var $;
|
|
146
192
|
(function ($) {
|
|
147
193
|
$.$mol_wire_auto_sub = null;
|
|
194
|
+
/**
|
|
195
|
+
* When fulfilled, all publishers are promoted to this subscriber on access to its.
|
|
196
|
+
*/
|
|
148
197
|
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
149
198
|
return $.$mol_wire_auto_sub = next;
|
|
150
199
|
}
|
|
151
200
|
$.$mol_wire_auto = $mol_wire_auto;
|
|
201
|
+
/**
|
|
202
|
+
* Affection queue. Used to prevent accidental stack overflow on emit.
|
|
203
|
+
*/
|
|
152
204
|
$.$mol_wire_affected = [];
|
|
153
205
|
})($ || ($ = {}));
|
|
154
206
|
|
|
@@ -157,7 +209,7 @@ var $;
|
|
|
157
209
|
var $;
|
|
158
210
|
(function ($) {
|
|
159
211
|
function $mol_fail_hidden(error) {
|
|
160
|
-
throw error;
|
|
212
|
+
throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
|
|
161
213
|
}
|
|
162
214
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
163
215
|
})($ || ($ = {}));
|
|
@@ -166,6 +218,7 @@ var $;
|
|
|
166
218
|
"use strict";
|
|
167
219
|
var $;
|
|
168
220
|
(function ($) {
|
|
221
|
+
// https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
|
|
169
222
|
$['devtoolsFormatters'] ||= [];
|
|
170
223
|
function $mol_dev_format_register(config) {
|
|
171
224
|
$['devtoolsFormatters'].push(config);
|
|
@@ -217,6 +270,7 @@ var $;
|
|
|
217
270
|
return false;
|
|
218
271
|
if (!val)
|
|
219
272
|
return false;
|
|
273
|
+
// if( Error.isError( val ) ) true
|
|
220
274
|
if (val[$.$mol_dev_format_body])
|
|
221
275
|
return true;
|
|
222
276
|
return false;
|
|
@@ -234,12 +288,16 @@ var $;
|
|
|
234
288
|
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
235
289
|
}
|
|
236
290
|
}
|
|
291
|
+
// if( Error.isError( val ) ) {
|
|
292
|
+
// return $mol_dev_format_native( val )
|
|
293
|
+
// }
|
|
237
294
|
return null;
|
|
238
295
|
},
|
|
239
296
|
});
|
|
240
297
|
function $mol_dev_format_native(obj) {
|
|
241
298
|
if (typeof obj === 'undefined')
|
|
242
299
|
return $.$mol_dev_format_shade('undefined');
|
|
300
|
+
// if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
|
|
243
301
|
return [
|
|
244
302
|
'object',
|
|
245
303
|
{
|
|
@@ -297,6 +355,9 @@ var $;
|
|
|
297
355
|
'margin-left': '13px'
|
|
298
356
|
});
|
|
299
357
|
class Stack extends Array {
|
|
358
|
+
// [ Symbol.toPrimitive ]() {
|
|
359
|
+
// return this.toString()
|
|
360
|
+
// }
|
|
300
361
|
toString() {
|
|
301
362
|
return this.join('\n');
|
|
302
363
|
}
|
|
@@ -319,6 +380,7 @@ var $;
|
|
|
319
380
|
this.method = call.getMethodName() ?? '';
|
|
320
381
|
if (this.method === this.function)
|
|
321
382
|
this.method = '';
|
|
383
|
+
// const func = c.getFunction()
|
|
322
384
|
this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
|
|
323
385
|
this.eval = call.getEvalOrigin() ?? '';
|
|
324
386
|
this.source = call.getScriptNameOrSourceURL() ?? '';
|
|
@@ -365,9 +427,16 @@ var $;
|
|
|
365
427
|
"use strict";
|
|
366
428
|
var $;
|
|
367
429
|
(function ($) {
|
|
430
|
+
/**
|
|
431
|
+
* Publisher that can auto collect other publishers. 32B
|
|
432
|
+
*
|
|
433
|
+
* P1 P2 P3 P4 S1 S2 S3
|
|
434
|
+
* ^ ^
|
|
435
|
+
* pubs_from subs_from
|
|
436
|
+
*/
|
|
368
437
|
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
369
|
-
pub_from = 0;
|
|
370
|
-
cursor = $mol_wire_cursor.stale;
|
|
438
|
+
pub_from = 0; // 4B
|
|
439
|
+
cursor = $mol_wire_cursor.stale; // 4B
|
|
371
440
|
get temp() {
|
|
372
441
|
return false;
|
|
373
442
|
}
|
|
@@ -485,10 +554,27 @@ var $;
|
|
|
485
554
|
return;
|
|
486
555
|
this.cursor = quant;
|
|
487
556
|
this.emit($mol_wire_cursor.doubt);
|
|
557
|
+
// if( pos >= 0 && pos < this.sub_from - 2 ) {
|
|
558
|
+
// const pub = this.data[ pos ] as $mol_wire_pub
|
|
559
|
+
// if( pub instanceof $mol_wire_task ) return
|
|
560
|
+
// for(
|
|
561
|
+
// let cursor = this.pub_from;
|
|
562
|
+
// cursor < this.sub_from;
|
|
563
|
+
// cursor += 2
|
|
564
|
+
// ) {
|
|
565
|
+
// const pub = this.data[ cursor ] as $mol_wire_pub
|
|
566
|
+
// if( pub instanceof $mol_wire_task ) {
|
|
567
|
+
// pub.destructor()
|
|
568
|
+
// }
|
|
569
|
+
// }
|
|
570
|
+
// }
|
|
488
571
|
}
|
|
489
572
|
[$mol_dev_format_head]() {
|
|
490
573
|
return $mol_dev_format_native(this);
|
|
491
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* Is subscribed to any publisher or not.
|
|
577
|
+
*/
|
|
492
578
|
get pub_empty() {
|
|
493
579
|
return this.sub_from === this.pub_from;
|
|
494
580
|
}
|
|
@@ -512,6 +598,11 @@ var $;
|
|
|
512
598
|
var $;
|
|
513
599
|
(function ($) {
|
|
514
600
|
const instances = new WeakSet();
|
|
601
|
+
/**
|
|
602
|
+
* Proxy that delegates all to lazy returned target.
|
|
603
|
+
*
|
|
604
|
+
* $mol_delegate( Array.prototype , ()=> fetch_array() )
|
|
605
|
+
*/
|
|
515
606
|
function $mol_delegate(proto, target) {
|
|
516
607
|
const proxy = new Proxy(proto, {
|
|
517
608
|
get: (_, field) => {
|
|
@@ -687,6 +778,9 @@ var $;
|
|
|
687
778
|
[Symbol.dispose]() {
|
|
688
779
|
this.destructor();
|
|
689
780
|
}
|
|
781
|
+
//[ Symbol.toPrimitive ]( hint: string ) {
|
|
782
|
+
// return hint === 'number' ? this.valueOf() : this.toString()
|
|
783
|
+
//}
|
|
690
784
|
toString() {
|
|
691
785
|
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
|
692
786
|
}
|
|
@@ -742,6 +836,13 @@ var $;
|
|
|
742
836
|
var $;
|
|
743
837
|
(function ($) {
|
|
744
838
|
const wrappers = new WeakMap();
|
|
839
|
+
/**
|
|
840
|
+
* Suspendable task with support both sync/async api.
|
|
841
|
+
*
|
|
842
|
+
* A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
|
|
843
|
+
* ^ ^ ^
|
|
844
|
+
* args_from pubs_from subs_from
|
|
845
|
+
**/
|
|
745
846
|
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
746
847
|
task;
|
|
747
848
|
host;
|
|
@@ -762,6 +863,7 @@ var $;
|
|
|
762
863
|
});
|
|
763
864
|
}
|
|
764
865
|
static sync() {
|
|
866
|
+
// Sync whole fiber graph
|
|
765
867
|
while (this.planning.size) {
|
|
766
868
|
for (const fiber of this.planning) {
|
|
767
869
|
this.planning.delete(fiber);
|
|
@@ -772,6 +874,7 @@ var $;
|
|
|
772
874
|
fiber.fresh();
|
|
773
875
|
}
|
|
774
876
|
}
|
|
877
|
+
// Collect garbage
|
|
775
878
|
while (this.reaping.size) {
|
|
776
879
|
const fibers = this.reaping;
|
|
777
880
|
this.reaping = new Set;
|
|
@@ -923,6 +1026,10 @@ var $;
|
|
|
923
1026
|
this.cursor = $mol_wire_cursor.stale;
|
|
924
1027
|
this.fresh();
|
|
925
1028
|
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
|
|
1031
|
+
* Should be called inside SuspenseAPI consumer (ie fiber).
|
|
1032
|
+
*/
|
|
926
1033
|
sync() {
|
|
927
1034
|
if (!$mol_wire_fiber.warm) {
|
|
928
1035
|
return this.result();
|
|
@@ -937,6 +1044,10 @@ var $;
|
|
|
937
1044
|
}
|
|
938
1045
|
return this.cache;
|
|
939
1046
|
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Asynchronous execution.
|
|
1049
|
+
* It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
|
|
1050
|
+
*/
|
|
940
1051
|
async async_raw() {
|
|
941
1052
|
while (true) {
|
|
942
1053
|
this.fresh();
|
|
@@ -949,6 +1060,7 @@ var $;
|
|
|
949
1060
|
if (!$mol_promise_like(this.cache))
|
|
950
1061
|
return this.cache;
|
|
951
1062
|
if (this.cursor === $mol_wire_cursor.final) {
|
|
1063
|
+
// never ends on destructed fiber
|
|
952
1064
|
await new Promise(() => { });
|
|
953
1065
|
}
|
|
954
1066
|
}
|
|
@@ -996,6 +1108,10 @@ var $;
|
|
|
996
1108
|
var $;
|
|
997
1109
|
(function ($) {
|
|
998
1110
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
1111
|
+
/**
|
|
1112
|
+
* Deeply compares two values. Returns true if equal.
|
|
1113
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
1114
|
+
*/
|
|
999
1115
|
function $mol_compare_deep(left, right) {
|
|
1000
1116
|
if (Object.is(left, right))
|
|
1001
1117
|
return true;
|
|
@@ -1135,6 +1251,7 @@ var $;
|
|
|
1135
1251
|
"use strict";
|
|
1136
1252
|
var $;
|
|
1137
1253
|
(function ($) {
|
|
1254
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
1138
1255
|
function $mol_log3_area_lazy(event) {
|
|
1139
1256
|
const self = this.$;
|
|
1140
1257
|
const stack = self.$mol_log3_stack;
|
|
@@ -1159,6 +1276,7 @@ var $;
|
|
|
1159
1276
|
"use strict";
|
|
1160
1277
|
var $;
|
|
1161
1278
|
(function ($) {
|
|
1279
|
+
/** Position in any resource. */
|
|
1162
1280
|
class $mol_span extends $mol_object2 {
|
|
1163
1281
|
uri;
|
|
1164
1282
|
source;
|
|
@@ -1174,13 +1292,17 @@ var $;
|
|
|
1174
1292
|
this.length = length;
|
|
1175
1293
|
this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
|
|
1176
1294
|
}
|
|
1295
|
+
/** Span for begin of unknown resource */
|
|
1177
1296
|
static unknown = $mol_span.begin('?');
|
|
1297
|
+
/** Makes new span for begin of resource. */
|
|
1178
1298
|
static begin(uri, source = '') {
|
|
1179
1299
|
return new $mol_span(uri, source, 1, 1, 0);
|
|
1180
1300
|
}
|
|
1301
|
+
/** Makes new span for end of resource. */
|
|
1181
1302
|
static end(uri, source) {
|
|
1182
1303
|
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
1183
1304
|
}
|
|
1305
|
+
/** Makes new span for entire resource. */
|
|
1184
1306
|
static entire(uri, source) {
|
|
1185
1307
|
return new $mol_span(uri, source, 1, 1, source.length);
|
|
1186
1308
|
}
|
|
@@ -1195,15 +1317,19 @@ var $;
|
|
|
1195
1317
|
length: this.length
|
|
1196
1318
|
};
|
|
1197
1319
|
}
|
|
1320
|
+
/** Makes new error for this span. */
|
|
1198
1321
|
error(message, Class = Error) {
|
|
1199
1322
|
return new Class(`${message} (${this})`);
|
|
1200
1323
|
}
|
|
1324
|
+
/** Makes new span for same uri. */
|
|
1201
1325
|
span(row, col, length) {
|
|
1202
1326
|
return new $mol_span(this.uri, this.source, row, col, length);
|
|
1203
1327
|
}
|
|
1328
|
+
/** Makes new span after end of this. */
|
|
1204
1329
|
after(length = 0) {
|
|
1205
1330
|
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
1206
1331
|
}
|
|
1332
|
+
/** Makes new span between begin and end. */
|
|
1207
1333
|
slice(begin, end = -1) {
|
|
1208
1334
|
let len = this.length;
|
|
1209
1335
|
if (begin < 0)
|
|
@@ -1226,6 +1352,7 @@ var $;
|
|
|
1226
1352
|
"use strict";
|
|
1227
1353
|
var $;
|
|
1228
1354
|
(function ($) {
|
|
1355
|
+
/** Serializes tree to string in tree format. */
|
|
1229
1356
|
function $mol_tree2_to_string(tree) {
|
|
1230
1357
|
let output = [];
|
|
1231
1358
|
function dump(tree, prefix = '') {
|
|
@@ -1269,12 +1396,25 @@ var $;
|
|
|
1269
1396
|
"use strict";
|
|
1270
1397
|
var $;
|
|
1271
1398
|
(function ($) {
|
|
1399
|
+
/**
|
|
1400
|
+
* Abstract Syntax Tree with human readable serialization.
|
|
1401
|
+
* Avoid direct instantiation. Use static factories instead.
|
|
1402
|
+
* @see https://github.com/nin-jin/tree.d
|
|
1403
|
+
*/
|
|
1272
1404
|
class $mol_tree2 extends Object {
|
|
1273
1405
|
type;
|
|
1274
1406
|
value;
|
|
1275
1407
|
kids;
|
|
1276
1408
|
span;
|
|
1277
|
-
constructor(
|
|
1409
|
+
constructor(
|
|
1410
|
+
/** Type of structural node, `value` should be empty */
|
|
1411
|
+
type,
|
|
1412
|
+
/** Content of data node, `type` should be empty */
|
|
1413
|
+
value,
|
|
1414
|
+
/** Child nodes */
|
|
1415
|
+
kids,
|
|
1416
|
+
/** Position in most far source resource */
|
|
1417
|
+
span) {
|
|
1278
1418
|
super();
|
|
1279
1419
|
this.type = type;
|
|
1280
1420
|
this.value = value;
|
|
@@ -1282,12 +1422,15 @@ var $;
|
|
|
1282
1422
|
this.span = span;
|
|
1283
1423
|
this[Symbol.toStringTag] = type || '\\' + value;
|
|
1284
1424
|
}
|
|
1425
|
+
/** Makes collection node. */
|
|
1285
1426
|
static list(kids, span = $mol_span.unknown) {
|
|
1286
1427
|
return new $mol_tree2('', '', kids, span);
|
|
1287
1428
|
}
|
|
1429
|
+
/** Makes new derived collection node. */
|
|
1288
1430
|
list(kids) {
|
|
1289
1431
|
return $mol_tree2.list(kids, this.span);
|
|
1290
1432
|
}
|
|
1433
|
+
/** Makes data node for any string. */
|
|
1291
1434
|
static data(value, kids = [], span = $mol_span.unknown) {
|
|
1292
1435
|
const chunks = value.split('\n');
|
|
1293
1436
|
if (chunks.length > 1) {
|
|
@@ -1301,21 +1444,26 @@ var $;
|
|
|
1301
1444
|
}
|
|
1302
1445
|
return new $mol_tree2('', value, kids, span);
|
|
1303
1446
|
}
|
|
1447
|
+
/** Makes new derived data node. */
|
|
1304
1448
|
data(value, kids = []) {
|
|
1305
1449
|
return $mol_tree2.data(value, kids, this.span);
|
|
1306
1450
|
}
|
|
1451
|
+
/** Makes struct node. */
|
|
1307
1452
|
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
1308
1453
|
if (/[ \n\t\\]/.test(type)) {
|
|
1309
1454
|
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
1310
1455
|
}
|
|
1311
1456
|
return new $mol_tree2(type, '', kids, span);
|
|
1312
1457
|
}
|
|
1458
|
+
/** Makes new derived structural node. */
|
|
1313
1459
|
struct(type, kids = []) {
|
|
1314
1460
|
return $mol_tree2.struct(type, kids, this.span);
|
|
1315
1461
|
}
|
|
1462
|
+
/** Makes new derived node with different kids id defined. */
|
|
1316
1463
|
clone(kids, span = this.span) {
|
|
1317
1464
|
return new $mol_tree2(this.type, this.value, kids, span);
|
|
1318
1465
|
}
|
|
1466
|
+
/** Returns multiline text content. */
|
|
1319
1467
|
text() {
|
|
1320
1468
|
var values = [];
|
|
1321
1469
|
for (var kid of this.kids) {
|
|
@@ -1325,15 +1473,20 @@ var $;
|
|
|
1325
1473
|
}
|
|
1326
1474
|
return this.value + values.join('\n');
|
|
1327
1475
|
}
|
|
1476
|
+
/** Parses tree format. */
|
|
1477
|
+
/** @deprecated Use $mol_tree2_from_string */
|
|
1328
1478
|
static fromString(str, uri = 'unknown') {
|
|
1329
1479
|
return $$.$mol_tree2_from_string(str, uri);
|
|
1330
1480
|
}
|
|
1481
|
+
/** Serializes to tree format. */
|
|
1331
1482
|
toString() {
|
|
1332
1483
|
return $$.$mol_tree2_to_string(this);
|
|
1333
1484
|
}
|
|
1485
|
+
/** Makes new tree with node overrided by path. */
|
|
1334
1486
|
insert(value, ...path) {
|
|
1335
1487
|
return this.update($mol_maybe(value), ...path)[0];
|
|
1336
1488
|
}
|
|
1489
|
+
/** Makes new tree with node overrided by path. */
|
|
1337
1490
|
update(value, ...path) {
|
|
1338
1491
|
if (path.length === 0)
|
|
1339
1492
|
return value;
|
|
@@ -1366,6 +1519,7 @@ var $;
|
|
|
1366
1519
|
return [this.clone(kids)];
|
|
1367
1520
|
}
|
|
1368
1521
|
}
|
|
1522
|
+
/** Query nodes by path. */
|
|
1369
1523
|
select(...path) {
|
|
1370
1524
|
let next = [this];
|
|
1371
1525
|
for (const type of path) {
|
|
@@ -1392,6 +1546,7 @@ var $;
|
|
|
1392
1546
|
}
|
|
1393
1547
|
return this.list(next);
|
|
1394
1548
|
}
|
|
1549
|
+
/** Filter kids by path or value. */
|
|
1395
1550
|
filter(path, value) {
|
|
1396
1551
|
const sub = this.kids.filter(item => {
|
|
1397
1552
|
var found = item.select(...path);
|
|
@@ -1419,9 +1574,11 @@ var $;
|
|
|
1419
1574
|
$mol_fail_hidden(error);
|
|
1420
1575
|
}
|
|
1421
1576
|
}
|
|
1577
|
+
/** Transform tree through context with transformers */
|
|
1422
1578
|
hack(belt, context = {}) {
|
|
1423
1579
|
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
1424
1580
|
}
|
|
1581
|
+
/** Makes Error with node coordinates. */
|
|
1425
1582
|
error(message, Class = Error) {
|
|
1426
1583
|
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
1427
1584
|
}
|
|
@@ -1439,6 +1596,7 @@ var $;
|
|
|
1439
1596
|
"use strict";
|
|
1440
1597
|
var $;
|
|
1441
1598
|
(function ($) {
|
|
1599
|
+
/** Syntax error with cordinates and source line snippet. */
|
|
1442
1600
|
class $mol_error_syntax extends SyntaxError {
|
|
1443
1601
|
reason;
|
|
1444
1602
|
line;
|
|
@@ -1457,6 +1615,7 @@ var $;
|
|
|
1457
1615
|
"use strict";
|
|
1458
1616
|
var $;
|
|
1459
1617
|
(function ($) {
|
|
1618
|
+
/** Parses tree format from string. */
|
|
1460
1619
|
function $mol_tree2_from_string(str, uri = '?') {
|
|
1461
1620
|
const span = $mol_span.entire(uri, str);
|
|
1462
1621
|
var root = $mol_tree2.list([], span);
|
|
@@ -1466,6 +1625,7 @@ var $;
|
|
|
1466
1625
|
var indent = 0;
|
|
1467
1626
|
var line_start = pos;
|
|
1468
1627
|
row++;
|
|
1628
|
+
// read indent
|
|
1469
1629
|
while (str.length > pos && str[pos] == '\t') {
|
|
1470
1630
|
indent++;
|
|
1471
1631
|
pos++;
|
|
@@ -1474,8 +1634,10 @@ var $;
|
|
|
1474
1634
|
min_indent = indent;
|
|
1475
1635
|
}
|
|
1476
1636
|
indent -= min_indent;
|
|
1637
|
+
// invalid tab size
|
|
1477
1638
|
if (indent < 0 || indent >= stack.length) {
|
|
1478
1639
|
const sp = span.span(row, 1, pos - line_start);
|
|
1640
|
+
// skip error line
|
|
1479
1641
|
while (str.length > pos && str[pos] != '\n') {
|
|
1480
1642
|
pos++;
|
|
1481
1643
|
}
|
|
@@ -1490,7 +1652,9 @@ var $;
|
|
|
1490
1652
|
}
|
|
1491
1653
|
stack.length = indent + 1;
|
|
1492
1654
|
var parent = stack[indent];
|
|
1655
|
+
// parse types
|
|
1493
1656
|
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
1657
|
+
// type can not contain space and tab
|
|
1494
1658
|
var error_start = pos;
|
|
1495
1659
|
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
1496
1660
|
pos++;
|
|
@@ -1502,6 +1666,7 @@ var $;
|
|
|
1502
1666
|
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
1503
1667
|
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
1504
1668
|
}
|
|
1669
|
+
// read type
|
|
1505
1670
|
var type_start = pos;
|
|
1506
1671
|
while (str.length > pos &&
|
|
1507
1672
|
str[pos] != '\\' &&
|
|
@@ -1516,10 +1681,12 @@ var $;
|
|
|
1516
1681
|
parent_kids.push(next);
|
|
1517
1682
|
parent = next;
|
|
1518
1683
|
}
|
|
1684
|
+
// read one space if exists
|
|
1519
1685
|
if (str.length > pos && str[pos] == ' ') {
|
|
1520
1686
|
pos++;
|
|
1521
1687
|
}
|
|
1522
1688
|
}
|
|
1689
|
+
// read data
|
|
1523
1690
|
if (str.length > pos && str[pos] == '\\') {
|
|
1524
1691
|
var data_start = pos;
|
|
1525
1692
|
while (str.length > pos && str[pos] != '\n') {
|
|
@@ -1530,6 +1697,7 @@ var $;
|
|
|
1530
1697
|
parent_kids.push(next);
|
|
1531
1698
|
parent = next;
|
|
1532
1699
|
}
|
|
1700
|
+
// now must be end of text
|
|
1533
1701
|
if (str.length === pos && stack.length > 0) {
|
|
1534
1702
|
const sp = span.span(row, pos - line_start + 1, 1);
|
|
1535
1703
|
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
@@ -1622,6 +1790,7 @@ var $;
|
|
|
1622
1790
|
"use strict";
|
|
1623
1791
|
var $;
|
|
1624
1792
|
(function ($) {
|
|
1793
|
+
/** Module for working with terminal. Text coloring when output in terminal */
|
|
1625
1794
|
class $mol_term_color {
|
|
1626
1795
|
static reset = this.ansi(0, 0);
|
|
1627
1796
|
static bold = this.ansi(1, 22);
|
|
@@ -1693,6 +1862,7 @@ var $;
|
|
|
1693
1862
|
"use strict";
|
|
1694
1863
|
var $;
|
|
1695
1864
|
(function ($) {
|
|
1865
|
+
/** One-shot fiber */
|
|
1696
1866
|
class $mol_wire_task extends $mol_wire_fiber {
|
|
1697
1867
|
static getter(task) {
|
|
1698
1868
|
return function $mol_wire_task_get(host, args) {
|
|
@@ -1718,6 +1888,7 @@ var $;
|
|
|
1718
1888
|
}
|
|
1719
1889
|
const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
|
|
1720
1890
|
const next = new $mol_wire_task(key, task, host, args);
|
|
1891
|
+
// Disabled because non-idempotency is required for try-catch
|
|
1721
1892
|
if (existen?.temp) {
|
|
1722
1893
|
$$.$mol_log3_warn({
|
|
1723
1894
|
place: '$mol_wire_task',
|
|
@@ -1750,7 +1921,7 @@ var $;
|
|
|
1750
1921
|
try {
|
|
1751
1922
|
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
1752
1923
|
}
|
|
1753
|
-
catch {
|
|
1924
|
+
catch { // Promises throw in strict mode
|
|
1754
1925
|
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
1755
1926
|
}
|
|
1756
1927
|
}
|
|
@@ -1776,6 +1947,7 @@ var $;
|
|
|
1776
1947
|
var $;
|
|
1777
1948
|
(function ($) {
|
|
1778
1949
|
const TypedArray = Object.getPrototypeOf(Uint8Array);
|
|
1950
|
+
/** Returns string key for any value. */
|
|
1779
1951
|
function $mol_key(value) {
|
|
1780
1952
|
primitives: {
|
|
1781
1953
|
if (typeof value === 'bigint')
|
|
@@ -1783,9 +1955,9 @@ var $;
|
|
|
1783
1955
|
if (typeof value === 'symbol')
|
|
1784
1956
|
return `Symbol(${value.description})`;
|
|
1785
1957
|
if (!value)
|
|
1786
|
-
return JSON.stringify(value);
|
|
1958
|
+
return JSON.stringify(value); // 0, null, ""
|
|
1787
1959
|
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1788
|
-
return JSON.stringify(value);
|
|
1960
|
+
return JSON.stringify(value); // boolean, number, string
|
|
1789
1961
|
}
|
|
1790
1962
|
caching: {
|
|
1791
1963
|
let key = $mol_key_store.get(value);
|
|
@@ -1862,6 +2034,9 @@ var $;
|
|
|
1862
2034
|
"use strict";
|
|
1863
2035
|
var $;
|
|
1864
2036
|
(function ($) {
|
|
2037
|
+
/**
|
|
2038
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber.
|
|
2039
|
+
*/
|
|
1865
2040
|
function $mol_wire_method(host, field, descr) {
|
|
1866
2041
|
if (!descr)
|
|
1867
2042
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -1943,6 +2118,7 @@ var $;
|
|
|
1943
2118
|
"use strict";
|
|
1944
2119
|
var $;
|
|
1945
2120
|
(function ($) {
|
|
2121
|
+
/** Long-living fiber. */
|
|
1946
2122
|
class $mol_wire_atom extends $mol_wire_fiber {
|
|
1947
2123
|
static solo(host, task) {
|
|
1948
2124
|
const field = task.name + '()';
|
|
@@ -1993,7 +2169,11 @@ var $;
|
|
|
1993
2169
|
}
|
|
1994
2170
|
$mol_wire_atom.watching.add(this);
|
|
1995
2171
|
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Update atom value through another temp fiber.
|
|
2174
|
+
*/
|
|
1996
2175
|
resync(args) {
|
|
2176
|
+
// enforce pulling tasks abort
|
|
1997
2177
|
for (let cursor = this.pub_from; cursor < this.sub_from; cursor += 2) {
|
|
1998
2178
|
const pub = this.data[cursor];
|
|
1999
2179
|
if (pub && pub instanceof $mol_wire_task) {
|
|
@@ -2054,7 +2234,7 @@ var $;
|
|
|
2054
2234
|
try {
|
|
2055
2235
|
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
2056
2236
|
}
|
|
2057
|
-
catch {
|
|
2237
|
+
catch { // Promises throw in strict mode
|
|
2058
2238
|
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
2059
2239
|
}
|
|
2060
2240
|
}
|
|
@@ -2082,6 +2262,7 @@ var $;
|
|
|
2082
2262
|
"use strict";
|
|
2083
2263
|
var $;
|
|
2084
2264
|
(function ($) {
|
|
2265
|
+
/** Run code without state changes */
|
|
2085
2266
|
function $mol_wire_probe(task, def) {
|
|
2086
2267
|
const warm = $mol_wire_fiber.warm;
|
|
2087
2268
|
try {
|
|
@@ -2102,6 +2283,9 @@ var $;
|
|
|
2102
2283
|
"use strict";
|
|
2103
2284
|
var $;
|
|
2104
2285
|
(function ($) {
|
|
2286
|
+
/**
|
|
2287
|
+
* Disable reaping of current subscriber
|
|
2288
|
+
*/
|
|
2105
2289
|
function $mol_wire_solid() {
|
|
2106
2290
|
let current = $mol_wire_auto();
|
|
2107
2291
|
if (current.temp)
|
|
@@ -2120,6 +2304,10 @@ var $;
|
|
|
2120
2304
|
"use strict";
|
|
2121
2305
|
var $;
|
|
2122
2306
|
(function ($) {
|
|
2307
|
+
/**
|
|
2308
|
+
* Real-time refresh current atom.
|
|
2309
|
+
* Don't use if possible. May reduce performance.
|
|
2310
|
+
*/
|
|
2123
2311
|
function $mol_wire_watch() {
|
|
2124
2312
|
const atom = $mol_wire_auto();
|
|
2125
2313
|
if (atom instanceof $mol_wire_atom) {
|
|
@@ -2164,6 +2352,10 @@ var $;
|
|
|
2164
2352
|
props[field] = get_val;
|
|
2165
2353
|
return get_val;
|
|
2166
2354
|
}
|
|
2355
|
+
/**
|
|
2356
|
+
* Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
|
|
2357
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
2358
|
+
*/
|
|
2167
2359
|
function $mol_wire_sync(obj) {
|
|
2168
2360
|
return new Proxy(obj, {
|
|
2169
2361
|
get(obj, field) {
|
|
@@ -2198,6 +2390,7 @@ var $;
|
|
|
2198
2390
|
"use strict";
|
|
2199
2391
|
var $;
|
|
2200
2392
|
(function ($) {
|
|
2393
|
+
/** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
|
|
2201
2394
|
function $mol_wire_async(obj) {
|
|
2202
2395
|
let fiber;
|
|
2203
2396
|
const temp = $mol_wire_task.getter(obj);
|
|
@@ -2228,6 +2421,7 @@ var $;
|
|
|
2228
2421
|
"use strict";
|
|
2229
2422
|
var $;
|
|
2230
2423
|
(function ($) {
|
|
2424
|
+
/** Starts subtasks concurrently instead of serial. */
|
|
2231
2425
|
function $mol_wire_race(...tasks) {
|
|
2232
2426
|
const results = tasks.map(task => {
|
|
2233
2427
|
try {
|
|
@@ -2252,6 +2446,7 @@ var $;
|
|
|
2252
2446
|
"use strict";
|
|
2253
2447
|
var $;
|
|
2254
2448
|
(function ($) {
|
|
2449
|
+
/** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
|
|
2255
2450
|
function $mol_wire_solo(host, field, descr) {
|
|
2256
2451
|
if (!descr)
|
|
2257
2452
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -2290,6 +2485,7 @@ var $;
|
|
|
2290
2485
|
"use strict";
|
|
2291
2486
|
var $;
|
|
2292
2487
|
(function ($) {
|
|
2488
|
+
/** Reactive memoizing multiplexed property decorator. */
|
|
2293
2489
|
function $mol_wire_plex(host, field, descr) {
|
|
2294
2490
|
if (!descr)
|
|
2295
2491
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -2328,6 +2524,11 @@ var $;
|
|
|
2328
2524
|
"use strict";
|
|
2329
2525
|
var $;
|
|
2330
2526
|
(function ($) {
|
|
2527
|
+
/**
|
|
2528
|
+
* Returns closure that returns constant value.
|
|
2529
|
+
* @example
|
|
2530
|
+
* const rnd = $mol_const( Math.random() )
|
|
2531
|
+
*/
|
|
2331
2532
|
function $mol_const(value) {
|
|
2332
2533
|
const getter = (() => value);
|
|
2333
2534
|
getter['()'] = value;
|
|
@@ -2342,6 +2543,7 @@ var $;
|
|
|
2342
2543
|
"use strict";
|
|
2343
2544
|
var $;
|
|
2344
2545
|
(function ($) {
|
|
2546
|
+
/** Incompatible with instance fields with initializators */
|
|
2345
2547
|
function $mol_wire_field(host, field, descr) {
|
|
2346
2548
|
if (!descr)
|
|
2347
2549
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -2395,7 +2597,25 @@ var $;
|
|
|
2395
2597
|
"use strict";
|
|
2396
2598
|
var $;
|
|
2397
2599
|
(function ($) {
|
|
2600
|
+
/**
|
|
2601
|
+
* Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
|
|
2602
|
+
* @example
|
|
2603
|
+
* '@' $mol_mem
|
|
2604
|
+
* name(next?: string) {
|
|
2605
|
+
* return next ?? 'default'
|
|
2606
|
+
* }
|
|
2607
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
2608
|
+
*/
|
|
2398
2609
|
$.$mol_mem = $mol_wire_solo;
|
|
2610
|
+
/**
|
|
2611
|
+
* Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
|
|
2612
|
+
* @example
|
|
2613
|
+
* '@' $mol_mem_key
|
|
2614
|
+
* name(id: number, next?: string) {
|
|
2615
|
+
* return next ?? 'default'
|
|
2616
|
+
* }
|
|
2617
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
2618
|
+
*/
|
|
2399
2619
|
$.$mol_mem_key = $mol_wire_plex;
|
|
2400
2620
|
})($ || ($ = {}));
|
|
2401
2621
|
|
|
@@ -2403,6 +2623,7 @@ var $;
|
|
|
2403
2623
|
"use strict";
|
|
2404
2624
|
var $;
|
|
2405
2625
|
(function ($) {
|
|
2626
|
+
/** State of time moment */
|
|
2406
2627
|
class $mol_state_time extends $mol_object {
|
|
2407
2628
|
static task(precision, reset) {
|
|
2408
2629
|
if (precision) {
|
|
@@ -2430,6 +2651,7 @@ var $;
|
|
|
2430
2651
|
"use strict";
|
|
2431
2652
|
var $;
|
|
2432
2653
|
(function ($) {
|
|
2654
|
+
/** Transition atom value */
|
|
2433
2655
|
function $mol_wire_easing(next) {
|
|
2434
2656
|
const atom = $mol_wire_auto();
|
|
2435
2657
|
if (!(atom instanceof $mol_wire_atom))
|
|
@@ -2499,8 +2721,10 @@ var $;
|
|
|
2499
2721
|
"use strict";
|
|
2500
2722
|
var $;
|
|
2501
2723
|
(function ($) {
|
|
2724
|
+
/** Reactive Set */
|
|
2502
2725
|
class $mol_wire_set extends Set {
|
|
2503
2726
|
pub = new $mol_wire_pub;
|
|
2727
|
+
// Accessors
|
|
2504
2728
|
has(value) {
|
|
2505
2729
|
this.pub.promote();
|
|
2506
2730
|
return super.has(value);
|
|
@@ -2529,6 +2753,7 @@ var $;
|
|
|
2529
2753
|
this.pub.promote();
|
|
2530
2754
|
return super.size;
|
|
2531
2755
|
}
|
|
2756
|
+
// Mutators
|
|
2532
2757
|
add(value) {
|
|
2533
2758
|
if (super.has(value))
|
|
2534
2759
|
return this;
|
|
@@ -2548,6 +2773,7 @@ var $;
|
|
|
2548
2773
|
super.clear();
|
|
2549
2774
|
this.pub.emit();
|
|
2550
2775
|
}
|
|
2776
|
+
// Extensions
|
|
2551
2777
|
item(val, next) {
|
|
2552
2778
|
if (next === undefined)
|
|
2553
2779
|
return this.has(val);
|
|
@@ -2580,6 +2806,7 @@ var $;
|
|
|
2580
2806
|
if (type !== 'object' && type !== 'function')
|
|
2581
2807
|
return target;
|
|
2582
2808
|
return new Proxy(target, {
|
|
2809
|
+
// Readers
|
|
2583
2810
|
get(target, property) {
|
|
2584
2811
|
$mol_wire_proxy_pub(id, target).promote();
|
|
2585
2812
|
const suffix = '.' + (typeof property === 'symbol' ? property.description : property);
|
|
@@ -2605,6 +2832,7 @@ var $;
|
|
|
2605
2832
|
$mol_wire_proxy_pub(id, target).promote();
|
|
2606
2833
|
return Reflect.isExtensible(target);
|
|
2607
2834
|
},
|
|
2835
|
+
// Writers
|
|
2608
2836
|
set(target, property, next) {
|
|
2609
2837
|
const pub = pubs.get(target);
|
|
2610
2838
|
if (pub) {
|
|
@@ -2640,8 +2868,10 @@ var $;
|
|
|
2640
2868
|
"use strict";
|
|
2641
2869
|
var $;
|
|
2642
2870
|
(function ($) {
|
|
2871
|
+
/** reactive Dictionary */
|
|
2643
2872
|
class $mol_wire_dict extends Map {
|
|
2644
2873
|
pub = new $mol_wire_pub;
|
|
2874
|
+
// Accessors
|
|
2645
2875
|
has(key) {
|
|
2646
2876
|
this.pub.promote();
|
|
2647
2877
|
return super.has(key);
|
|
@@ -2674,11 +2904,12 @@ var $;
|
|
|
2674
2904
|
this.pub.promote();
|
|
2675
2905
|
return super.size;
|
|
2676
2906
|
}
|
|
2907
|
+
// Mutators
|
|
2677
2908
|
set(key, value) {
|
|
2678
2909
|
if (super.get(key) === value)
|
|
2679
2910
|
return this;
|
|
2680
2911
|
super.set(key, value);
|
|
2681
|
-
this.pub?.emit();
|
|
2912
|
+
this.pub?.emit(); // undefined in constructor
|
|
2682
2913
|
return this;
|
|
2683
2914
|
}
|
|
2684
2915
|
delete(key) {
|
|
@@ -2693,6 +2924,7 @@ var $;
|
|
|
2693
2924
|
super.clear();
|
|
2694
2925
|
this.pub.emit();
|
|
2695
2926
|
}
|
|
2927
|
+
// Extensions
|
|
2696
2928
|
item(key, next) {
|
|
2697
2929
|
if (next === undefined)
|
|
2698
2930
|
return this.get(key) ?? null;
|
|
@@ -2750,6 +2982,7 @@ var $;
|
|
|
2750
2982
|
"use strict";
|
|
2751
2983
|
var $;
|
|
2752
2984
|
(function ($) {
|
|
2985
|
+
/** Watch and logs reactive states. Logger automatically added to test bundle which is adding to `test.html`. */
|
|
2753
2986
|
class $mol_wire_log extends $mol_object2 {
|
|
2754
2987
|
static watch(task) {
|
|
2755
2988
|
return task;
|