mol_dump_lib 0.0.1026 → 0.0.1028
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 +693 -3
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +487 -19
- package/node.js.map +1 -1
- package/node.mjs +487 -19
- package/node.test.js +612 -20
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +642 -2
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +429 -15
- package/web.js.map +1 -1
- package/web.mjs +429 -15
- package/web.test.js +128 -4
- package/web.test.js.map +1 -1
package/web.js
CHANGED
|
@@ -125,6 +125,10 @@ var $;
|
|
|
125
125
|
"use strict";
|
|
126
126
|
var $;
|
|
127
127
|
(function ($) {
|
|
128
|
+
/**
|
|
129
|
+
* CSS Units
|
|
130
|
+
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
|
|
131
|
+
*/
|
|
128
132
|
class $mol_style_unit extends $mol_decor {
|
|
129
133
|
literal;
|
|
130
134
|
constructor(value, literal) {
|
|
@@ -171,6 +175,10 @@ var $;
|
|
|
171
175
|
var $;
|
|
172
176
|
(function ($) {
|
|
173
177
|
const { per } = $mol_style_unit;
|
|
178
|
+
/**
|
|
179
|
+
* CSS Functions
|
|
180
|
+
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
|
|
181
|
+
*/
|
|
174
182
|
class $mol_style_func extends $mol_decor {
|
|
175
183
|
name;
|
|
176
184
|
constructor(name, value) {
|
|
@@ -265,6 +273,7 @@ var $;
|
|
|
265
273
|
"use strict";
|
|
266
274
|
var $;
|
|
267
275
|
(function ($) {
|
|
276
|
+
/** Create record of CSS variables. */
|
|
268
277
|
function $mol_style_prop(prefix, keys) {
|
|
269
278
|
const record = keys.reduce((rec, key) => {
|
|
270
279
|
rec[key] = $mol_style_func.vary(`--${prefix}_${key}`);
|
|
@@ -279,6 +288,10 @@ var $;
|
|
|
279
288
|
"use strict";
|
|
280
289
|
var $;
|
|
281
290
|
(function ($) {
|
|
291
|
+
/**
|
|
292
|
+
* Theme css variables
|
|
293
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_textarea_demo
|
|
294
|
+
*/
|
|
282
295
|
$.$mol_theme = $mol_style_prop('mol_theme', [
|
|
283
296
|
'back',
|
|
284
297
|
'hover',
|
|
@@ -307,11 +320,18 @@ var $;
|
|
|
307
320
|
|
|
308
321
|
;
|
|
309
322
|
"use strict";
|
|
323
|
+
// namespace $ {
|
|
324
|
+
// $mol_style_attach( '$mol_theme_lights', `:root { --mol_theme_back: oklch( ${ $$.$mol_lights() ? 92 : 20 }% .01 var(--mol_theme_hue) ) }` )
|
|
325
|
+
// }
|
|
310
326
|
|
|
311
327
|
;
|
|
312
328
|
"use strict";
|
|
313
329
|
var $;
|
|
314
330
|
(function ($) {
|
|
331
|
+
/**
|
|
332
|
+
* Gap in CSS
|
|
333
|
+
* @see https://page.hyoo.ru/#!=msdb74_bm7nsq
|
|
334
|
+
*/
|
|
315
335
|
$.$mol_gap = $mol_style_prop('mol_gap', [
|
|
316
336
|
'page',
|
|
317
337
|
'block',
|
|
@@ -443,6 +463,12 @@ var $;
|
|
|
443
463
|
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
444
464
|
};
|
|
445
465
|
$.$mol_jsx_frag = '';
|
|
466
|
+
/**
|
|
467
|
+
* JSX adapter that makes DOM tree.
|
|
468
|
+
* Generates global unique ids for every DOM-element by components tree with ids.
|
|
469
|
+
* Ensures all local ids are unique.
|
|
470
|
+
* Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
|
|
471
|
+
*/
|
|
446
472
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
447
473
|
const id = props && props.id || '';
|
|
448
474
|
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
@@ -567,6 +593,11 @@ var $;
|
|
|
567
593
|
var $;
|
|
568
594
|
(function ($) {
|
|
569
595
|
const instances = new WeakSet();
|
|
596
|
+
/**
|
|
597
|
+
* Proxy that delegates all to lazy returned target.
|
|
598
|
+
*
|
|
599
|
+
* $mol_delegate( Array.prototype , ()=> fetch_array() )
|
|
600
|
+
*/
|
|
570
601
|
function $mol_delegate(proto, target) {
|
|
571
602
|
const proxy = new Proxy(proto, {
|
|
572
603
|
get: (_, field) => {
|
|
@@ -660,7 +691,7 @@ var $;
|
|
|
660
691
|
var $;
|
|
661
692
|
(function ($) {
|
|
662
693
|
function $mol_fail_hidden(error) {
|
|
663
|
-
throw error;
|
|
694
|
+
throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
|
|
664
695
|
}
|
|
665
696
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
666
697
|
})($ || ($ = {}));
|
|
@@ -720,6 +751,9 @@ var $;
|
|
|
720
751
|
[Symbol.dispose]() {
|
|
721
752
|
this.destructor();
|
|
722
753
|
}
|
|
754
|
+
//[ Symbol.toPrimitive ]( hint: string ) {
|
|
755
|
+
// return hint === 'number' ? this.valueOf() : this.toString()
|
|
756
|
+
//}
|
|
723
757
|
toString() {
|
|
724
758
|
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
|
725
759
|
}
|
|
@@ -751,6 +785,7 @@ var $;
|
|
|
751
785
|
"use strict";
|
|
752
786
|
var $;
|
|
753
787
|
(function ($) {
|
|
788
|
+
/** Generates unique identifier. */
|
|
754
789
|
function $mol_guid(length = 8, exists = () => false) {
|
|
755
790
|
for (;;) {
|
|
756
791
|
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
@@ -766,11 +801,16 @@ var $;
|
|
|
766
801
|
"use strict";
|
|
767
802
|
var $;
|
|
768
803
|
(function ($) {
|
|
804
|
+
/** Special status statuses. */
|
|
769
805
|
let $mol_wire_cursor;
|
|
770
806
|
(function ($mol_wire_cursor) {
|
|
807
|
+
/** Update required. */
|
|
771
808
|
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
809
|
+
/** Some of (transitive) pub update required. */
|
|
772
810
|
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
811
|
+
/** Actual state but may be dropped. */
|
|
773
812
|
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
813
|
+
/** State will never be changed. */
|
|
774
814
|
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
775
815
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
776
816
|
})($ || ($ = {}));
|
|
@@ -779,6 +819,9 @@ var $;
|
|
|
779
819
|
"use strict";
|
|
780
820
|
var $;
|
|
781
821
|
(function ($) {
|
|
822
|
+
/**
|
|
823
|
+
* Collects subscribers in compact array. 28B
|
|
824
|
+
*/
|
|
782
825
|
class $mol_wire_pub extends Object {
|
|
783
826
|
constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
|
|
784
827
|
super();
|
|
@@ -786,10 +829,17 @@ var $;
|
|
|
786
829
|
}
|
|
787
830
|
[Symbol.toStringTag];
|
|
788
831
|
data = [];
|
|
832
|
+
// Derived objects should be Arrays.
|
|
789
833
|
static get [Symbol.species]() {
|
|
790
834
|
return Array;
|
|
791
835
|
}
|
|
792
|
-
|
|
836
|
+
/**
|
|
837
|
+
* Index of first subscriber.
|
|
838
|
+
*/
|
|
839
|
+
sub_from = 0; // 4B
|
|
840
|
+
/**
|
|
841
|
+
* All current subscribers.
|
|
842
|
+
*/
|
|
793
843
|
get sub_list() {
|
|
794
844
|
const res = [];
|
|
795
845
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
@@ -797,14 +847,23 @@ var $;
|
|
|
797
847
|
}
|
|
798
848
|
return res;
|
|
799
849
|
}
|
|
850
|
+
/**
|
|
851
|
+
* Has any subscribers or not.
|
|
852
|
+
*/
|
|
800
853
|
get sub_empty() {
|
|
801
854
|
return this.sub_from === this.data.length;
|
|
802
855
|
}
|
|
856
|
+
/**
|
|
857
|
+
* Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
|
|
858
|
+
*/
|
|
803
859
|
sub_on(sub, pub_pos) {
|
|
804
860
|
const pos = this.data.length;
|
|
805
861
|
this.data.push(sub, pub_pos);
|
|
806
862
|
return pos;
|
|
807
863
|
}
|
|
864
|
+
/**
|
|
865
|
+
* Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
|
|
866
|
+
*/
|
|
808
867
|
sub_off(sub_pos) {
|
|
809
868
|
if (!(sub_pos < this.data.length)) {
|
|
810
869
|
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
@@ -817,21 +876,39 @@ var $;
|
|
|
817
876
|
if (end === this.sub_from)
|
|
818
877
|
this.reap();
|
|
819
878
|
}
|
|
879
|
+
/**
|
|
880
|
+
* Called when last sub was unsubscribed.
|
|
881
|
+
**/
|
|
820
882
|
reap() { }
|
|
883
|
+
/**
|
|
884
|
+
* Autowire this publisher with current subscriber.
|
|
885
|
+
**/
|
|
821
886
|
promote() {
|
|
822
887
|
$mol_wire_auto()?.track_next(this);
|
|
823
888
|
}
|
|
889
|
+
/**
|
|
890
|
+
* Enforce actualization. Should not throw errors.
|
|
891
|
+
*/
|
|
824
892
|
fresh() { }
|
|
893
|
+
/**
|
|
894
|
+
* Allow to put data to caches in the subtree.
|
|
895
|
+
*/
|
|
825
896
|
complete() { }
|
|
826
897
|
get incompleted() {
|
|
827
898
|
return false;
|
|
828
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* Notify subscribers about self changes.
|
|
902
|
+
*/
|
|
829
903
|
emit(quant = $mol_wire_cursor.stale) {
|
|
830
904
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
831
905
|
;
|
|
832
906
|
this.data[i].absorb(quant, this.data[i + 1]);
|
|
833
907
|
}
|
|
834
908
|
}
|
|
909
|
+
/**
|
|
910
|
+
* Moves peer from one position to another. Doesn't clear data at old position!
|
|
911
|
+
*/
|
|
835
912
|
peer_move(from_pos, to_pos) {
|
|
836
913
|
const peer = this.data[from_pos];
|
|
837
914
|
const self_pos = this.data[from_pos + 1];
|
|
@@ -839,6 +916,9 @@ var $;
|
|
|
839
916
|
this.data[to_pos + 1] = self_pos;
|
|
840
917
|
peer.peer_repos(self_pos, to_pos);
|
|
841
918
|
}
|
|
919
|
+
/**
|
|
920
|
+
* Updates self position in the peer.
|
|
921
|
+
*/
|
|
842
922
|
peer_repos(peer_pos, self_pos) {
|
|
843
923
|
this.data[peer_pos + 1] = self_pos;
|
|
844
924
|
}
|
|
@@ -854,10 +934,16 @@ var $;
|
|
|
854
934
|
var $;
|
|
855
935
|
(function ($) {
|
|
856
936
|
$.$mol_wire_auto_sub = null;
|
|
937
|
+
/**
|
|
938
|
+
* When fulfilled, all publishers are promoted to this subscriber on access to its.
|
|
939
|
+
*/
|
|
857
940
|
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
858
941
|
return $.$mol_wire_auto_sub = next;
|
|
859
942
|
}
|
|
860
943
|
$.$mol_wire_auto = $mol_wire_auto;
|
|
944
|
+
/**
|
|
945
|
+
* Affection queue. Used to prevent accidental stack overflow on emit.
|
|
946
|
+
*/
|
|
861
947
|
$.$mol_wire_affected = [];
|
|
862
948
|
})($ || ($ = {}));
|
|
863
949
|
|
|
@@ -865,6 +951,7 @@ var $;
|
|
|
865
951
|
"use strict";
|
|
866
952
|
var $;
|
|
867
953
|
(function ($) {
|
|
954
|
+
// https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
|
|
868
955
|
$['devtoolsFormatters'] ||= [];
|
|
869
956
|
function $mol_dev_format_register(config) {
|
|
870
957
|
$['devtoolsFormatters'].push(config);
|
|
@@ -916,6 +1003,7 @@ var $;
|
|
|
916
1003
|
return false;
|
|
917
1004
|
if (!val)
|
|
918
1005
|
return false;
|
|
1006
|
+
// if( Error.isError( val ) ) true
|
|
919
1007
|
if (val[$.$mol_dev_format_body])
|
|
920
1008
|
return true;
|
|
921
1009
|
return false;
|
|
@@ -933,12 +1021,16 @@ var $;
|
|
|
933
1021
|
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
934
1022
|
}
|
|
935
1023
|
}
|
|
1024
|
+
// if( Error.isError( val ) ) {
|
|
1025
|
+
// return $mol_dev_format_native( val )
|
|
1026
|
+
// }
|
|
936
1027
|
return null;
|
|
937
1028
|
},
|
|
938
1029
|
});
|
|
939
1030
|
function $mol_dev_format_native(obj) {
|
|
940
1031
|
if (typeof obj === 'undefined')
|
|
941
1032
|
return $.$mol_dev_format_shade('undefined');
|
|
1033
|
+
// if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
|
|
942
1034
|
return [
|
|
943
1035
|
'object',
|
|
944
1036
|
{
|
|
@@ -996,6 +1088,9 @@ var $;
|
|
|
996
1088
|
'margin-left': '13px'
|
|
997
1089
|
});
|
|
998
1090
|
class Stack extends Array {
|
|
1091
|
+
// [ Symbol.toPrimitive ]() {
|
|
1092
|
+
// return this.toString()
|
|
1093
|
+
// }
|
|
999
1094
|
toString() {
|
|
1000
1095
|
return this.join('\n');
|
|
1001
1096
|
}
|
|
@@ -1018,6 +1113,7 @@ var $;
|
|
|
1018
1113
|
this.method = call.getMethodName() ?? '';
|
|
1019
1114
|
if (this.method === this.function)
|
|
1020
1115
|
this.method = '';
|
|
1116
|
+
// const func = c.getFunction()
|
|
1021
1117
|
this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
|
|
1022
1118
|
this.eval = call.getEvalOrigin() ?? '';
|
|
1023
1119
|
this.source = call.getScriptNameOrSourceURL() ?? '';
|
|
@@ -1064,9 +1160,16 @@ var $;
|
|
|
1064
1160
|
"use strict";
|
|
1065
1161
|
var $;
|
|
1066
1162
|
(function ($) {
|
|
1163
|
+
/**
|
|
1164
|
+
* Publisher that can auto collect other publishers. 32B
|
|
1165
|
+
*
|
|
1166
|
+
* P1 P2 P3 P4 S1 S2 S3
|
|
1167
|
+
* ^ ^
|
|
1168
|
+
* pubs_from subs_from
|
|
1169
|
+
*/
|
|
1067
1170
|
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
1068
|
-
pub_from = 0;
|
|
1069
|
-
cursor = $mol_wire_cursor.stale;
|
|
1171
|
+
pub_from = 0; // 4B
|
|
1172
|
+
cursor = $mol_wire_cursor.stale; // 4B
|
|
1070
1173
|
get temp() {
|
|
1071
1174
|
return false;
|
|
1072
1175
|
}
|
|
@@ -1184,10 +1287,27 @@ var $;
|
|
|
1184
1287
|
return;
|
|
1185
1288
|
this.cursor = quant;
|
|
1186
1289
|
this.emit($mol_wire_cursor.doubt);
|
|
1290
|
+
// if( pos >= 0 && pos < this.sub_from - 2 ) {
|
|
1291
|
+
// const pub = this.data[ pos ] as $mol_wire_pub
|
|
1292
|
+
// if( pub instanceof $mol_wire_task ) return
|
|
1293
|
+
// for(
|
|
1294
|
+
// let cursor = this.pub_from;
|
|
1295
|
+
// cursor < this.sub_from;
|
|
1296
|
+
// cursor += 2
|
|
1297
|
+
// ) {
|
|
1298
|
+
// const pub = this.data[ cursor ] as $mol_wire_pub
|
|
1299
|
+
// if( pub instanceof $mol_wire_task ) {
|
|
1300
|
+
// pub.destructor()
|
|
1301
|
+
// }
|
|
1302
|
+
// }
|
|
1303
|
+
// }
|
|
1187
1304
|
}
|
|
1188
1305
|
[$mol_dev_format_head]() {
|
|
1189
1306
|
return $mol_dev_format_native(this);
|
|
1190
1307
|
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Is subscribed to any publisher or not.
|
|
1310
|
+
*/
|
|
1191
1311
|
get pub_empty() {
|
|
1192
1312
|
return this.sub_from === this.pub_from;
|
|
1193
1313
|
}
|
|
@@ -1243,6 +1363,13 @@ var $;
|
|
|
1243
1363
|
var $;
|
|
1244
1364
|
(function ($) {
|
|
1245
1365
|
const wrappers = new WeakMap();
|
|
1366
|
+
/**
|
|
1367
|
+
* Suspendable task with support both sync/async api.
|
|
1368
|
+
*
|
|
1369
|
+
* A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
|
|
1370
|
+
* ^ ^ ^
|
|
1371
|
+
* args_from pubs_from subs_from
|
|
1372
|
+
**/
|
|
1246
1373
|
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
1247
1374
|
task;
|
|
1248
1375
|
host;
|
|
@@ -1263,6 +1390,7 @@ var $;
|
|
|
1263
1390
|
});
|
|
1264
1391
|
}
|
|
1265
1392
|
static sync() {
|
|
1393
|
+
// Sync whole fiber graph
|
|
1266
1394
|
while (this.planning.size) {
|
|
1267
1395
|
for (const fiber of this.planning) {
|
|
1268
1396
|
this.planning.delete(fiber);
|
|
@@ -1273,6 +1401,7 @@ var $;
|
|
|
1273
1401
|
fiber.fresh();
|
|
1274
1402
|
}
|
|
1275
1403
|
}
|
|
1404
|
+
// Collect garbage
|
|
1276
1405
|
while (this.reaping.size) {
|
|
1277
1406
|
const fibers = this.reaping;
|
|
1278
1407
|
this.reaping = new Set;
|
|
@@ -1424,6 +1553,10 @@ var $;
|
|
|
1424
1553
|
this.cursor = $mol_wire_cursor.stale;
|
|
1425
1554
|
this.fresh();
|
|
1426
1555
|
}
|
|
1556
|
+
/**
|
|
1557
|
+
* Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
|
|
1558
|
+
* Should be called inside SuspenseAPI consumer (ie fiber).
|
|
1559
|
+
*/
|
|
1427
1560
|
sync() {
|
|
1428
1561
|
if (!$mol_wire_fiber.warm) {
|
|
1429
1562
|
return this.result();
|
|
@@ -1438,6 +1571,10 @@ var $;
|
|
|
1438
1571
|
}
|
|
1439
1572
|
return this.cache;
|
|
1440
1573
|
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Asynchronous execution.
|
|
1576
|
+
* It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
|
|
1577
|
+
*/
|
|
1441
1578
|
async async_raw() {
|
|
1442
1579
|
while (true) {
|
|
1443
1580
|
this.fresh();
|
|
@@ -1450,6 +1587,7 @@ var $;
|
|
|
1450
1587
|
if (!$mol_promise_like(this.cache))
|
|
1451
1588
|
return this.cache;
|
|
1452
1589
|
if (this.cursor === $mol_wire_cursor.final) {
|
|
1590
|
+
// never ends on destructed fiber
|
|
1453
1591
|
await new Promise(() => { });
|
|
1454
1592
|
}
|
|
1455
1593
|
}
|
|
@@ -1497,6 +1635,7 @@ var $;
|
|
|
1497
1635
|
var $;
|
|
1498
1636
|
(function ($) {
|
|
1499
1637
|
const TypedArray = Object.getPrototypeOf(Uint8Array);
|
|
1638
|
+
/** Returns string key for any value. */
|
|
1500
1639
|
function $mol_key(value) {
|
|
1501
1640
|
primitives: {
|
|
1502
1641
|
if (typeof value === 'bigint')
|
|
@@ -1504,9 +1643,9 @@ var $;
|
|
|
1504
1643
|
if (typeof value === 'symbol')
|
|
1505
1644
|
return `Symbol(${value.description})`;
|
|
1506
1645
|
if (!value)
|
|
1507
|
-
return JSON.stringify(value);
|
|
1646
|
+
return JSON.stringify(value); // 0, null, ""
|
|
1508
1647
|
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1509
|
-
return JSON.stringify(value);
|
|
1648
|
+
return JSON.stringify(value); // boolean, number, string
|
|
1510
1649
|
}
|
|
1511
1650
|
caching: {
|
|
1512
1651
|
let key = $mol_key_store.get(value);
|
|
@@ -1590,6 +1729,10 @@ var $;
|
|
|
1590
1729
|
var $;
|
|
1591
1730
|
(function ($) {
|
|
1592
1731
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
1732
|
+
/**
|
|
1733
|
+
* Deeply compares two values. Returns true if equal.
|
|
1734
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
1735
|
+
*/
|
|
1593
1736
|
function $mol_compare_deep(left, right) {
|
|
1594
1737
|
if (Object.is(left, right))
|
|
1595
1738
|
return true;
|
|
@@ -1729,6 +1872,7 @@ var $;
|
|
|
1729
1872
|
"use strict";
|
|
1730
1873
|
var $;
|
|
1731
1874
|
(function ($) {
|
|
1875
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
1732
1876
|
function $mol_log3_area_lazy(event) {
|
|
1733
1877
|
const self = this.$;
|
|
1734
1878
|
const stack = self.$mol_log3_stack;
|
|
@@ -1785,6 +1929,7 @@ var $;
|
|
|
1785
1929
|
"use strict";
|
|
1786
1930
|
var $;
|
|
1787
1931
|
(function ($) {
|
|
1932
|
+
/** One-shot fiber */
|
|
1788
1933
|
class $mol_wire_task extends $mol_wire_fiber {
|
|
1789
1934
|
static getter(task) {
|
|
1790
1935
|
return function $mol_wire_task_get(host, args) {
|
|
@@ -1810,6 +1955,7 @@ var $;
|
|
|
1810
1955
|
}
|
|
1811
1956
|
const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
|
|
1812
1957
|
const next = new $mol_wire_task(key, task, host, args);
|
|
1958
|
+
// Disabled because non-idempotency is required for try-catch
|
|
1813
1959
|
if (existen?.temp) {
|
|
1814
1960
|
$$.$mol_log3_warn({
|
|
1815
1961
|
place: '$mol_wire_task',
|
|
@@ -1842,7 +1988,7 @@ var $;
|
|
|
1842
1988
|
try {
|
|
1843
1989
|
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
1844
1990
|
}
|
|
1845
|
-
catch {
|
|
1991
|
+
catch { // Promises throw in strict mode
|
|
1846
1992
|
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
1847
1993
|
}
|
|
1848
1994
|
}
|
|
@@ -1867,6 +2013,9 @@ var $;
|
|
|
1867
2013
|
"use strict";
|
|
1868
2014
|
var $;
|
|
1869
2015
|
(function ($) {
|
|
2016
|
+
/**
|
|
2017
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber.
|
|
2018
|
+
*/
|
|
1870
2019
|
function $mol_wire_method(host, field, descr) {
|
|
1871
2020
|
if (!descr)
|
|
1872
2021
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -1936,6 +2085,7 @@ var $;
|
|
|
1936
2085
|
let error;
|
|
1937
2086
|
let result;
|
|
1938
2087
|
let handler;
|
|
2088
|
+
/// Debugger will stop at exceptions but exception will be returned normally
|
|
1939
2089
|
function $mol_try_web(handler2) {
|
|
1940
2090
|
handler = handler2;
|
|
1941
2091
|
error = undefined;
|
|
@@ -1976,6 +2126,7 @@ var $;
|
|
|
1976
2126
|
"use strict";
|
|
1977
2127
|
var $;
|
|
1978
2128
|
(function ($) {
|
|
2129
|
+
/** Long-living fiber. */
|
|
1979
2130
|
class $mol_wire_atom extends $mol_wire_fiber {
|
|
1980
2131
|
static solo(host, task) {
|
|
1981
2132
|
const field = task.name + '()';
|
|
@@ -2026,7 +2177,11 @@ var $;
|
|
|
2026
2177
|
}
|
|
2027
2178
|
$mol_wire_atom.watching.add(this);
|
|
2028
2179
|
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Update atom value through another temp fiber.
|
|
2182
|
+
*/
|
|
2029
2183
|
resync(args) {
|
|
2184
|
+
// enforce pulling tasks abort
|
|
2030
2185
|
for (let cursor = this.pub_from; cursor < this.sub_from; cursor += 2) {
|
|
2031
2186
|
const pub = this.data[cursor];
|
|
2032
2187
|
if (pub && pub instanceof $mol_wire_task) {
|
|
@@ -2087,7 +2242,7 @@ var $;
|
|
|
2087
2242
|
try {
|
|
2088
2243
|
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
2089
2244
|
}
|
|
2090
|
-
catch {
|
|
2245
|
+
catch { // Promises throw in strict mode
|
|
2091
2246
|
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
2092
2247
|
}
|
|
2093
2248
|
}
|
|
@@ -2115,6 +2270,7 @@ var $;
|
|
|
2115
2270
|
"use strict";
|
|
2116
2271
|
var $;
|
|
2117
2272
|
(function ($) {
|
|
2273
|
+
/** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */
|
|
2118
2274
|
function $mol_wire_solo(host, field, descr) {
|
|
2119
2275
|
if (!descr)
|
|
2120
2276
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -2153,6 +2309,7 @@ var $;
|
|
|
2153
2309
|
"use strict";
|
|
2154
2310
|
var $;
|
|
2155
2311
|
(function ($) {
|
|
2312
|
+
/** Reactive memoizing multiplexed property decorator. */
|
|
2156
2313
|
function $mol_wire_plex(host, field, descr) {
|
|
2157
2314
|
if (!descr)
|
|
2158
2315
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -2191,7 +2348,25 @@ var $;
|
|
|
2191
2348
|
"use strict";
|
|
2192
2349
|
var $;
|
|
2193
2350
|
(function ($) {
|
|
2351
|
+
/**
|
|
2352
|
+
* Reactive memoizing solo property decorator from [mol_wire](../wire/README.md)
|
|
2353
|
+
* @example
|
|
2354
|
+
* '@' $mol_mem
|
|
2355
|
+
* name(next?: string) {
|
|
2356
|
+
* return next ?? 'default'
|
|
2357
|
+
* }
|
|
2358
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
2359
|
+
*/
|
|
2194
2360
|
$.$mol_mem = $mol_wire_solo;
|
|
2361
|
+
/**
|
|
2362
|
+
* Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md)
|
|
2363
|
+
* @example
|
|
2364
|
+
* '@' $mol_mem_key
|
|
2365
|
+
* name(id: number, next?: string) {
|
|
2366
|
+
* return next ?? 'default'
|
|
2367
|
+
* }
|
|
2368
|
+
* @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb
|
|
2369
|
+
*/
|
|
2195
2370
|
$.$mol_mem_key = $mol_wire_plex;
|
|
2196
2371
|
})($ || ($ = {}));
|
|
2197
2372
|
|
|
@@ -2280,6 +2455,10 @@ var $;
|
|
|
2280
2455
|
"use strict";
|
|
2281
2456
|
var $;
|
|
2282
2457
|
(function ($) {
|
|
2458
|
+
/**
|
|
2459
|
+
* Key names code for hotkey
|
|
2460
|
+
* @see [mol_hotkey](../../hotkey/hotkey.view.ts)
|
|
2461
|
+
*/
|
|
2283
2462
|
let $mol_keyboard_code;
|
|
2284
2463
|
(function ($mol_keyboard_code) {
|
|
2285
2464
|
$mol_keyboard_code[$mol_keyboard_code["backspace"] = 8] = "backspace";
|
|
@@ -2528,6 +2707,7 @@ var $;
|
|
|
2528
2707
|
"use strict";
|
|
2529
2708
|
var $;
|
|
2530
2709
|
(function ($) {
|
|
2710
|
+
/** Run code without state changes */
|
|
2531
2711
|
function $mol_wire_probe(task, def) {
|
|
2532
2712
|
const warm = $mol_wire_fiber.warm;
|
|
2533
2713
|
try {
|
|
@@ -2548,6 +2728,10 @@ var $;
|
|
|
2548
2728
|
"use strict";
|
|
2549
2729
|
var $;
|
|
2550
2730
|
(function ($) {
|
|
2731
|
+
/**
|
|
2732
|
+
* Real-time refresh current atom.
|
|
2733
|
+
* Don't use if possible. May reduce performance.
|
|
2734
|
+
*/
|
|
2551
2735
|
function $mol_wire_watch() {
|
|
2552
2736
|
const atom = $mol_wire_auto();
|
|
2553
2737
|
if (atom instanceof $mol_wire_atom) {
|
|
@@ -2564,6 +2748,11 @@ var $;
|
|
|
2564
2748
|
"use strict";
|
|
2565
2749
|
var $;
|
|
2566
2750
|
(function ($) {
|
|
2751
|
+
/**
|
|
2752
|
+
* Returns closure that returns constant value.
|
|
2753
|
+
* @example
|
|
2754
|
+
* const rnd = $mol_const( Math.random() )
|
|
2755
|
+
*/
|
|
2567
2756
|
function $mol_const(value) {
|
|
2568
2757
|
const getter = (() => value);
|
|
2569
2758
|
getter['()'] = value;
|
|
@@ -2578,6 +2767,9 @@ var $;
|
|
|
2578
2767
|
"use strict";
|
|
2579
2768
|
var $;
|
|
2580
2769
|
(function ($) {
|
|
2770
|
+
/**
|
|
2771
|
+
* Disable reaping of current subscriber
|
|
2772
|
+
*/
|
|
2581
2773
|
function $mol_wire_solid() {
|
|
2582
2774
|
let current = $mol_wire_auto();
|
|
2583
2775
|
if (current.temp)
|
|
@@ -2681,6 +2873,7 @@ var $;
|
|
|
2681
2873
|
"use strict";
|
|
2682
2874
|
var $;
|
|
2683
2875
|
(function ($) {
|
|
2876
|
+
/** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
|
|
2684
2877
|
function $mol_wire_async(obj) {
|
|
2685
2878
|
let fiber;
|
|
2686
2879
|
const temp = $mol_wire_task.getter(obj);
|
|
@@ -2740,6 +2933,7 @@ var $;
|
|
|
2740
2933
|
|
|
2741
2934
|
;
|
|
2742
2935
|
"use strict";
|
|
2936
|
+
/** @jsx $mol_jsx */
|
|
2743
2937
|
var $;
|
|
2744
2938
|
(function ($) {
|
|
2745
2939
|
function $mol_view_visible_width() {
|
|
@@ -2754,6 +2948,11 @@ var $;
|
|
|
2754
2948
|
return suffix;
|
|
2755
2949
|
}
|
|
2756
2950
|
$.$mol_view_state_key = $mol_view_state_key;
|
|
2951
|
+
/**
|
|
2952
|
+
* The base class for all visual components. It provides the infrastructure for reactive lazy rendering, handling exceptions.
|
|
2953
|
+
* @see https://mol.hyoo.ru/#!section=docs/=vv2nig_s5zr0f
|
|
2954
|
+
*/
|
|
2955
|
+
/// Reactive statefull lazy ViewModel
|
|
2757
2956
|
class $mol_view extends $mol_object {
|
|
2758
2957
|
static Root(id) {
|
|
2759
2958
|
return new this;
|
|
@@ -2818,16 +3017,22 @@ var $;
|
|
|
2818
3017
|
state_key(suffix = '') {
|
|
2819
3018
|
return this.$.$mol_view_state_key(suffix);
|
|
2820
3019
|
}
|
|
3020
|
+
/// Name of element that created when element not found in DOM
|
|
2821
3021
|
dom_name() {
|
|
2822
3022
|
return $mol_dom_qname(this.constructor.toString()) || 'div';
|
|
2823
3023
|
}
|
|
3024
|
+
/// NameSpace of element that created when element not found in DOM
|
|
2824
3025
|
dom_name_space() { return 'http://www.w3.org/1999/xhtml'; }
|
|
3026
|
+
/// Raw child views
|
|
2825
3027
|
sub() {
|
|
2826
3028
|
return [];
|
|
2827
3029
|
}
|
|
3030
|
+
/// Visible sub views with defined ambient context
|
|
3031
|
+
/// Render all by default
|
|
2828
3032
|
sub_visible() {
|
|
2829
3033
|
return this.sub();
|
|
2830
3034
|
}
|
|
3035
|
+
/// Minimal width that used for lazy rendering
|
|
2831
3036
|
minimal_width() {
|
|
2832
3037
|
let min = 0;
|
|
2833
3038
|
try {
|
|
@@ -2849,6 +3054,7 @@ var $;
|
|
|
2849
3054
|
maximal_width() {
|
|
2850
3055
|
return this.minimal_width();
|
|
2851
3056
|
}
|
|
3057
|
+
/// Minimal height that used for lazy rendering
|
|
2852
3058
|
minimal_height() {
|
|
2853
3059
|
let min = 0;
|
|
2854
3060
|
try {
|
|
@@ -2868,11 +3074,11 @@ var $;
|
|
|
2868
3074
|
view_rect() {
|
|
2869
3075
|
if ($mol_wire_probe(() => this.view_rect()) === undefined) {
|
|
2870
3076
|
$mol_wire_watch();
|
|
2871
|
-
return null;
|
|
3077
|
+
return null; // don't touch DOM to prevent instant reflow
|
|
2872
3078
|
}
|
|
2873
3079
|
else {
|
|
2874
3080
|
const { width, height, left, right, top, bottom } = this.dom_node().getBoundingClientRect();
|
|
2875
|
-
return { width, height, left, right, top, bottom };
|
|
3081
|
+
return { width, height, left, right, top, bottom }; // pick to optimize compare
|
|
2876
3082
|
}
|
|
2877
3083
|
}
|
|
2878
3084
|
dom_id() {
|
|
@@ -3062,6 +3268,7 @@ var $;
|
|
|
3062
3268
|
[$mol_dev_format_head]() {
|
|
3063
3269
|
return $mol_dev_format_span({}, $mol_dev_format_native(this));
|
|
3064
3270
|
}
|
|
3271
|
+
/** Deep search view by predicate. */
|
|
3065
3272
|
*view_find(check, path = []) {
|
|
3066
3273
|
if (path.length === 0 && check(this))
|
|
3067
3274
|
return yield [this];
|
|
@@ -3090,6 +3297,7 @@ var $;
|
|
|
3090
3297
|
$mol_fail_log(error);
|
|
3091
3298
|
}
|
|
3092
3299
|
}
|
|
3300
|
+
/** Renders path of views to DOM. */
|
|
3093
3301
|
force_render(path) {
|
|
3094
3302
|
const kids = this.sub();
|
|
3095
3303
|
const index = kids.findIndex(item => {
|
|
@@ -3104,6 +3312,7 @@ var $;
|
|
|
3104
3312
|
kids[index].force_render(path);
|
|
3105
3313
|
}
|
|
3106
3314
|
}
|
|
3315
|
+
/** Renders view to DOM and scroll to it. */
|
|
3107
3316
|
ensure_visible(view, align = "start") {
|
|
3108
3317
|
const path = this.view_find(v => v === view).next().value;
|
|
3109
3318
|
this.force_render(new Set(path));
|
|
@@ -3118,6 +3327,9 @@ var $;
|
|
|
3118
3327
|
const win = this.$.$mol_dom_context;
|
|
3119
3328
|
if (win.parent !== win.self && !win.document.hasFocus())
|
|
3120
3329
|
return;
|
|
3330
|
+
// new this.$.$mol_after_frame( ()=> {
|
|
3331
|
+
// this.dom_node().scrollIntoView({ block: 'start', inline: 'nearest' })
|
|
3332
|
+
// } )
|
|
3121
3333
|
new this.$.$mol_after_timeout(0, () => {
|
|
3122
3334
|
this.focused(true);
|
|
3123
3335
|
});
|
|
@@ -3205,6 +3417,7 @@ var $;
|
|
|
3205
3417
|
"use strict";
|
|
3206
3418
|
var $;
|
|
3207
3419
|
(function ($) {
|
|
3420
|
+
/** Plugin is component without its own DOM element, but instead uses the owner DOM element */
|
|
3208
3421
|
class $mol_plugin extends $mol_view {
|
|
3209
3422
|
dom_node_external(next) {
|
|
3210
3423
|
return next ?? $mol_owning_get(this).host.dom_node();
|
|
@@ -3221,6 +3434,7 @@ var $;
|
|
|
3221
3434
|
var $;
|
|
3222
3435
|
(function ($) {
|
|
3223
3436
|
function $mol_view_component(View) {
|
|
3437
|
+
// service worker
|
|
3224
3438
|
if (typeof HTMLElement !== 'function')
|
|
3225
3439
|
return;
|
|
3226
3440
|
class Component extends HTMLElement {
|
|
@@ -3232,6 +3446,7 @@ var $;
|
|
|
3232
3446
|
if (!this.shadowRoot) {
|
|
3233
3447
|
this.attachShadow({ mode: 'open' });
|
|
3234
3448
|
const node = this.view.dom_node();
|
|
3449
|
+
// node.setAttribute( 'mol_view_root', '' )
|
|
3235
3450
|
for (const style of $mol_dom_context.document.getElementsByTagName('style')) {
|
|
3236
3451
|
this.shadowRoot.append(style.cloneNode(true));
|
|
3237
3452
|
}
|
|
@@ -3273,6 +3488,7 @@ var $;
|
|
|
3273
3488
|
const descr = Reflect.getOwnPropertyDescriptor(proto, field);
|
|
3274
3489
|
if (typeof descr.value !== 'function')
|
|
3275
3490
|
continue;
|
|
3491
|
+
// if( descr.value.length === 0 ) continue
|
|
3276
3492
|
Component.observedAttributes.add(field);
|
|
3277
3493
|
Component.observedAttributes.add('#' + field);
|
|
3278
3494
|
}
|
|
@@ -3299,6 +3515,7 @@ var $;
|
|
|
3299
3515
|
;
|
|
3300
3516
|
"use strict";
|
|
3301
3517
|
|
|
3518
|
+
|
|
3302
3519
|
;
|
|
3303
3520
|
($.$mol_paragraph) = class $mol_paragraph extends ($.$mol_view) {
|
|
3304
3521
|
line_height(){
|
|
@@ -3322,6 +3539,7 @@ var $;
|
|
|
3322
3539
|
;
|
|
3323
3540
|
"use strict";
|
|
3324
3541
|
|
|
3542
|
+
|
|
3325
3543
|
;
|
|
3326
3544
|
"use strict";
|
|
3327
3545
|
var $;
|
|
@@ -3426,8 +3644,10 @@ var $;
|
|
|
3426
3644
|
var $;
|
|
3427
3645
|
(function ($) {
|
|
3428
3646
|
let x = /x/[Symbol.matchAll];
|
|
3647
|
+
/** Type safe reguar expression builder */
|
|
3429
3648
|
class $mol_regexp extends RegExp {
|
|
3430
3649
|
groups;
|
|
3650
|
+
/** Prefer to use $mol_regexp.from */
|
|
3431
3651
|
constructor(source, flags = 'gsu', groups = []) {
|
|
3432
3652
|
super(source, flags);
|
|
3433
3653
|
this.groups = groups;
|
|
@@ -3447,12 +3667,14 @@ var $;
|
|
|
3447
3667
|
this.lastIndex = index;
|
|
3448
3668
|
}
|
|
3449
3669
|
}
|
|
3670
|
+
/** Parses input and returns found capture groups or null */
|
|
3450
3671
|
[Symbol.match](str) {
|
|
3451
3672
|
const res = [...this[Symbol.matchAll](str)].filter(r => r.groups).map(r => r[0]);
|
|
3452
3673
|
if (!res.length)
|
|
3453
3674
|
return null;
|
|
3454
3675
|
return res;
|
|
3455
3676
|
}
|
|
3677
|
+
/** Splits string by regexp edges */
|
|
3456
3678
|
[Symbol.split](str) {
|
|
3457
3679
|
const res = [];
|
|
3458
3680
|
let token_last = null;
|
|
@@ -3507,12 +3729,14 @@ var $;
|
|
|
3507
3729
|
get native() {
|
|
3508
3730
|
return new RegExp(this.source, this.flags);
|
|
3509
3731
|
}
|
|
3732
|
+
/** Makes regexp that greedy repeats this pattern with delimiter */
|
|
3510
3733
|
static separated(chunk, sep) {
|
|
3511
3734
|
return $mol_regexp.from([
|
|
3512
3735
|
$mol_regexp.repeat_greedy([[chunk], sep], 0),
|
|
3513
3736
|
chunk,
|
|
3514
3737
|
]);
|
|
3515
3738
|
}
|
|
3739
|
+
/** Makes regexp that non-greedy repeats this pattern from min to max count */
|
|
3516
3740
|
static repeat(source, min = 0, max = Number.POSITIVE_INFINITY) {
|
|
3517
3741
|
const regexp = $mol_regexp.from(source);
|
|
3518
3742
|
const upper = Number.isFinite(max) ? max : '';
|
|
@@ -3528,6 +3752,7 @@ var $;
|
|
|
3528
3752
|
};
|
|
3529
3753
|
return regexp2;
|
|
3530
3754
|
}
|
|
3755
|
+
/** Makes regexp that greedy repeats this pattern from min to max count */
|
|
3531
3756
|
static repeat_greedy(source, min = 0, max = Number.POSITIVE_INFINITY) {
|
|
3532
3757
|
const regexp = $mol_regexp.from(source);
|
|
3533
3758
|
const upper = Number.isFinite(max) ? max : '';
|
|
@@ -3543,6 +3768,7 @@ var $;
|
|
|
3543
3768
|
};
|
|
3544
3769
|
return regexp2;
|
|
3545
3770
|
}
|
|
3771
|
+
/** Makes regexp that match any of options */
|
|
3546
3772
|
static vary(sources, flags = 'gsu') {
|
|
3547
3773
|
const groups = [];
|
|
3548
3774
|
const chunks = sources.map(source => {
|
|
@@ -3552,17 +3778,21 @@ var $;
|
|
|
3552
3778
|
});
|
|
3553
3779
|
return new $mol_regexp(`(?:${chunks.join('|')})`, flags, groups);
|
|
3554
3780
|
}
|
|
3781
|
+
/** Makes regexp that allow absent of this pattern */
|
|
3555
3782
|
static optional(source) {
|
|
3556
3783
|
return $mol_regexp.repeat_greedy(source, 0, 1);
|
|
3557
3784
|
}
|
|
3785
|
+
/** Makes regexp that look ahead for pattern */
|
|
3558
3786
|
static force_after(source) {
|
|
3559
3787
|
const regexp = $mol_regexp.from(source);
|
|
3560
3788
|
return new $mol_regexp(`(?=${regexp.source})`, regexp.flags, regexp.groups);
|
|
3561
3789
|
}
|
|
3790
|
+
/** Makes regexp that look ahead for pattern */
|
|
3562
3791
|
static forbid_after(source) {
|
|
3563
3792
|
const regexp = $mol_regexp.from(source);
|
|
3564
3793
|
return new $mol_regexp(`(?!${regexp.source})`, regexp.flags, regexp.groups);
|
|
3565
3794
|
}
|
|
3795
|
+
/** Converts some js values to regexp */
|
|
3566
3796
|
static from(source, { ignoreCase, multiline } = {
|
|
3567
3797
|
ignoreCase: false,
|
|
3568
3798
|
multiline: false,
|
|
@@ -3663,9 +3893,11 @@ var $;
|
|
|
3663
3893
|
return regexp;
|
|
3664
3894
|
}
|
|
3665
3895
|
}
|
|
3896
|
+
/** Makes regexp which includes only unicode category */
|
|
3666
3897
|
static unicode_only(...category) {
|
|
3667
3898
|
return new $mol_regexp(`\\p{${category.join('=')}}`);
|
|
3668
3899
|
}
|
|
3900
|
+
/** Makes regexp which excludes unicode category */
|
|
3669
3901
|
static unicode_except(...category) {
|
|
3670
3902
|
return new $mol_regexp(`\\P{${category.join('=')}}`);
|
|
3671
3903
|
}
|
|
@@ -3709,12 +3941,17 @@ var $;
|
|
|
3709
3941
|
;
|
|
3710
3942
|
"use strict";
|
|
3711
3943
|
|
|
3944
|
+
|
|
3712
3945
|
;
|
|
3713
3946
|
"use strict";
|
|
3714
3947
|
var $;
|
|
3715
3948
|
(function ($) {
|
|
3716
3949
|
var $$;
|
|
3717
3950
|
(function ($$) {
|
|
3951
|
+
/**
|
|
3952
|
+
* Output text with dimmed mismatched substrings.
|
|
3953
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_dimmer_demo
|
|
3954
|
+
*/
|
|
3718
3955
|
class $mol_dimmer extends $.$mol_dimmer {
|
|
3719
3956
|
parts() {
|
|
3720
3957
|
const needle = this.needle();
|
|
@@ -3909,6 +4146,11 @@ var $;
|
|
|
3909
4146
|
"use strict";
|
|
3910
4147
|
var $;
|
|
3911
4148
|
(function ($) {
|
|
4149
|
+
/**
|
|
4150
|
+
* CSS in TS.
|
|
4151
|
+
* Statically typed CSS style sheets. Following samples show which CSS code are generated from TS code.
|
|
4152
|
+
* @see https://mol.hyoo.ru/#!section=docs/=xwq9q5_f966fg
|
|
4153
|
+
*/
|
|
3912
4154
|
function $mol_style_define(Component, config) {
|
|
3913
4155
|
return $mol_style_attach(Component.name, $mol_style_sheet(Component, config));
|
|
3914
4156
|
}
|
|
@@ -3918,6 +4160,7 @@ var $;
|
|
|
3918
4160
|
;
|
|
3919
4161
|
"use strict";
|
|
3920
4162
|
|
|
4163
|
+
|
|
3921
4164
|
;
|
|
3922
4165
|
"use strict";
|
|
3923
4166
|
var $;
|
|
@@ -4039,6 +4282,7 @@ var $;
|
|
|
4039
4282
|
"use strict";
|
|
4040
4283
|
var $;
|
|
4041
4284
|
(function ($) {
|
|
4285
|
+
/** Creates lexer by dictionary of lexems. Lexem that started first wins. Then lexem that declared earlier wins. Use regexp capture to take parts of token. */
|
|
4042
4286
|
class $mol_syntax2 {
|
|
4043
4287
|
lexems;
|
|
4044
4288
|
constructor(lexems) {
|
|
@@ -4110,6 +4354,8 @@ var $;
|
|
|
4110
4354
|
'code': /```(.+?)```|;;(.+?);;|`(.+?)`/,
|
|
4111
4355
|
'insert': /\+\+(.+?)\+\+/,
|
|
4112
4356
|
'delete': /~~(.+?)~~|--(.+?)--/,
|
|
4357
|
+
// 'remark' : /(\()(.+?)(\))/ ,
|
|
4358
|
+
// 'quote' : /(")(.+?)(")/ ,
|
|
4113
4359
|
'embed': /""(?:(.*?)\\)?(.*?)""/,
|
|
4114
4360
|
'link': /\\\\(?:(.*?)\\)?(.*?)\\\\/,
|
|
4115
4361
|
'image-link': /!\[([^\[\]]*?)\]\((.*?)\)/,
|
|
@@ -4139,6 +4385,7 @@ var $;
|
|
|
4139
4385
|
;
|
|
4140
4386
|
"use strict";
|
|
4141
4387
|
|
|
4388
|
+
|
|
4142
4389
|
;
|
|
4143
4390
|
"use strict";
|
|
4144
4391
|
var $;
|
|
@@ -4155,6 +4402,7 @@ var $;
|
|
|
4155
4402
|
tokens(path) {
|
|
4156
4403
|
const tokens = [];
|
|
4157
4404
|
const text = (path.length > 0)
|
|
4405
|
+
// @FIXME: this logic compatible only with `string`
|
|
4158
4406
|
? this.tokens(path.slice(0, path.length - 1))[path[path.length - 1]].found.slice(1, -1)
|
|
4159
4407
|
: this.text();
|
|
4160
4408
|
this.syntax().tokenize(text, (name, found, chunks) => {
|
|
@@ -4420,12 +4668,18 @@ var $;
|
|
|
4420
4668
|
;
|
|
4421
4669
|
"use strict";
|
|
4422
4670
|
|
|
4671
|
+
|
|
4423
4672
|
;
|
|
4424
4673
|
"use strict";
|
|
4425
4674
|
var $;
|
|
4426
4675
|
(function ($) {
|
|
4427
4676
|
var $$;
|
|
4428
4677
|
(function ($$) {
|
|
4678
|
+
/**
|
|
4679
|
+
* The list of rows with lazy/virtual rendering support based on `minimal_height` of rows.
|
|
4680
|
+
* `mol_list` should contain only components that inherits `mol_view`. You should not place raw strings or numbers in list.
|
|
4681
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_list_demo
|
|
4682
|
+
*/
|
|
4429
4683
|
class $mol_list extends $.$mol_list {
|
|
4430
4684
|
sub() {
|
|
4431
4685
|
const rows = this.rows();
|
|
@@ -4467,9 +4721,11 @@ var $;
|
|
|
4467
4721
|
const gap_after = $mol_mem_cached(() => this.gap_after()) ?? 0;
|
|
4468
4722
|
let top = Math.ceil(rect?.top ?? 0) + gap_before;
|
|
4469
4723
|
let bottom = Math.ceil(rect?.bottom ?? 0) - gap_after;
|
|
4724
|
+
// change nothing when already covers all limits
|
|
4470
4725
|
if (top <= limit_top && bottom >= limit_bottom) {
|
|
4471
4726
|
return [min2, max2];
|
|
4472
4727
|
}
|
|
4728
|
+
// jumps when fully over limits
|
|
4473
4729
|
if (anchoring && ((bottom < limit_top) || (top > limit_bottom))) {
|
|
4474
4730
|
min = 0;
|
|
4475
4731
|
top = Math.ceil(rect?.top ?? 0);
|
|
@@ -4486,18 +4742,22 @@ var $;
|
|
|
4486
4742
|
}
|
|
4487
4743
|
let top2 = top;
|
|
4488
4744
|
let bottom2 = bottom;
|
|
4745
|
+
// force recalc min when overlapse top limit
|
|
4489
4746
|
if (anchoring && (top < limit_top) && (bottom < limit_bottom) && (max < kids.length)) {
|
|
4490
4747
|
min2 = max;
|
|
4491
4748
|
top2 = bottom;
|
|
4492
4749
|
}
|
|
4750
|
+
// force recalc max when overlapse bottom limit
|
|
4493
4751
|
if ((bottom > limit_bottom) && (top > limit_top) && (min > 0)) {
|
|
4494
4752
|
max2 = min;
|
|
4495
4753
|
bottom2 = top;
|
|
4496
4754
|
}
|
|
4755
|
+
// extend min to cover top limit
|
|
4497
4756
|
while (anchoring && ((top2 > limit_top) && (min2 > 0))) {
|
|
4498
4757
|
--min2;
|
|
4499
4758
|
top2 -= this.item_height_min(min2);
|
|
4500
4759
|
}
|
|
4760
|
+
// extend max to cover bottom limit
|
|
4501
4761
|
while (bottom2 < limit_bottom && max2 < kids.length) {
|
|
4502
4762
|
bottom2 += this.item_height_min(max2);
|
|
4503
4763
|
++max2;
|
|
@@ -4620,6 +4880,10 @@ var $;
|
|
|
4620
4880
|
"use strict";
|
|
4621
4881
|
var $;
|
|
4622
4882
|
(function ($) {
|
|
4883
|
+
/**
|
|
4884
|
+
* Z-index values for layers
|
|
4885
|
+
* https://page.hyoo.ru/#!=xthcpx_wqmiba
|
|
4886
|
+
*/
|
|
4623
4887
|
$.$mol_layer = $mol_style_prop('mol_layer', [
|
|
4624
4888
|
'hover',
|
|
4625
4889
|
'focus',
|
|
@@ -4646,6 +4910,7 @@ var $;
|
|
|
4646
4910
|
;
|
|
4647
4911
|
"use strict";
|
|
4648
4912
|
|
|
4913
|
+
|
|
4649
4914
|
;
|
|
4650
4915
|
($.$mol_button) = class $mol_button extends ($.$mol_view) {
|
|
4651
4916
|
event_activate(next){
|
|
@@ -4734,12 +4999,17 @@ var $;
|
|
|
4734
4999
|
;
|
|
4735
5000
|
"use strict";
|
|
4736
5001
|
|
|
5002
|
+
|
|
4737
5003
|
;
|
|
4738
5004
|
"use strict";
|
|
4739
5005
|
var $;
|
|
4740
5006
|
(function ($) {
|
|
4741
5007
|
var $$;
|
|
4742
5008
|
(function ($$) {
|
|
5009
|
+
/**
|
|
5010
|
+
* Simple button.
|
|
5011
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_button_demo
|
|
5012
|
+
*/
|
|
4743
5013
|
class $mol_button extends $.$mol_button {
|
|
4744
5014
|
disabled() {
|
|
4745
5015
|
return !this.enabled();
|
|
@@ -4755,6 +5025,7 @@ var $;
|
|
|
4755
5025
|
this.status([null]);
|
|
4756
5026
|
}
|
|
4757
5027
|
catch (error) {
|
|
5028
|
+
// Calling actions from catch section, if throwing promise breaks idempotency
|
|
4758
5029
|
Promise.resolve().then(() => this.status([error]));
|
|
4759
5030
|
$mol_fail_hidden(error);
|
|
4760
5031
|
}
|
|
@@ -4824,6 +5095,7 @@ var $;
|
|
|
4824
5095
|
;
|
|
4825
5096
|
"use strict";
|
|
4826
5097
|
|
|
5098
|
+
|
|
4827
5099
|
;
|
|
4828
5100
|
($.$mol_button_minor) = class $mol_button_minor extends ($.$mol_button_typed) {};
|
|
4829
5101
|
|
|
@@ -4838,11 +5110,13 @@ var $;
|
|
|
4838
5110
|
;
|
|
4839
5111
|
"use strict";
|
|
4840
5112
|
|
|
5113
|
+
|
|
4841
5114
|
;
|
|
4842
5115
|
"use strict";
|
|
4843
5116
|
|
|
4844
5117
|
;
|
|
4845
5118
|
"use strict";
|
|
5119
|
+
// @ts-ignore
|
|
4846
5120
|
var $node = $node || {};
|
|
4847
5121
|
|
|
4848
5122
|
;
|
|
@@ -4876,6 +5150,7 @@ var $;
|
|
|
4876
5150
|
"use strict";
|
|
4877
5151
|
var $;
|
|
4878
5152
|
(function ($) {
|
|
5153
|
+
/** State of time moment */
|
|
4879
5154
|
class $mol_state_time extends $mol_object {
|
|
4880
5155
|
static task(precision, reset) {
|
|
4881
5156
|
if (precision) {
|
|
@@ -4902,12 +5177,14 @@ var $;
|
|
|
4902
5177
|
;
|
|
4903
5178
|
"use strict";
|
|
4904
5179
|
|
|
5180
|
+
|
|
4905
5181
|
;
|
|
4906
5182
|
"use strict";
|
|
4907
5183
|
var $;
|
|
4908
5184
|
(function ($) {
|
|
4909
5185
|
var $$;
|
|
4910
5186
|
(function ($$) {
|
|
5187
|
+
/** Base SVG component to display SVG images or icons. */
|
|
4911
5188
|
class $mol_svg extends $.$mol_svg {
|
|
4912
5189
|
computed_style() {
|
|
4913
5190
|
const win = this.$.$mol_dom_context;
|
|
@@ -4967,6 +5244,7 @@ var $;
|
|
|
4967
5244
|
;
|
|
4968
5245
|
"use strict";
|
|
4969
5246
|
|
|
5247
|
+
|
|
4970
5248
|
;
|
|
4971
5249
|
($.$mol_svg_path) = class $mol_svg_path extends ($.$mol_svg) {
|
|
4972
5250
|
geometry(){
|
|
@@ -4984,6 +5262,7 @@ var $;
|
|
|
4984
5262
|
;
|
|
4985
5263
|
"use strict";
|
|
4986
5264
|
|
|
5265
|
+
|
|
4987
5266
|
;
|
|
4988
5267
|
($.$mol_icon) = class $mol_icon extends ($.$mol_svg_root) {
|
|
4989
5268
|
path(){
|
|
@@ -5020,6 +5299,7 @@ var $;
|
|
|
5020
5299
|
;
|
|
5021
5300
|
"use strict";
|
|
5022
5301
|
|
|
5302
|
+
|
|
5023
5303
|
;
|
|
5024
5304
|
($.$mol_icon_clipboard) = class $mol_icon_clipboard extends ($.$mol_icon) {
|
|
5025
5305
|
path(){
|
|
@@ -5031,6 +5311,7 @@ var $;
|
|
|
5031
5311
|
;
|
|
5032
5312
|
"use strict";
|
|
5033
5313
|
|
|
5314
|
+
|
|
5034
5315
|
;
|
|
5035
5316
|
($.$mol_icon_clipboard_outline) = class $mol_icon_clipboard_outline extends ($.$mol_icon) {
|
|
5036
5317
|
path(){
|
|
@@ -5042,6 +5323,7 @@ var $;
|
|
|
5042
5323
|
;
|
|
5043
5324
|
"use strict";
|
|
5044
5325
|
|
|
5326
|
+
|
|
5045
5327
|
;
|
|
5046
5328
|
($.$mol_button_copy) = class $mol_button_copy extends ($.$mol_button_minor) {
|
|
5047
5329
|
text(){
|
|
@@ -5130,6 +5412,10 @@ var $;
|
|
|
5130
5412
|
props[field] = get_val;
|
|
5131
5413
|
return get_val;
|
|
5132
5414
|
}
|
|
5415
|
+
/**
|
|
5416
|
+
* Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
|
|
5417
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
5418
|
+
*/
|
|
5133
5419
|
function $mol_wire_sync(obj) {
|
|
5134
5420
|
return new Proxy(obj, {
|
|
5135
5421
|
get(obj, field) {
|
|
@@ -5163,12 +5449,17 @@ var $;
|
|
|
5163
5449
|
;
|
|
5164
5450
|
"use strict";
|
|
5165
5451
|
|
|
5452
|
+
|
|
5166
5453
|
;
|
|
5167
5454
|
"use strict";
|
|
5168
5455
|
var $;
|
|
5169
5456
|
(function ($) {
|
|
5170
5457
|
var $$;
|
|
5171
5458
|
(function ($$) {
|
|
5459
|
+
/**
|
|
5460
|
+
* Button copy text() value to clipboard
|
|
5461
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_button_demo
|
|
5462
|
+
*/
|
|
5172
5463
|
class $mol_button_copy extends $.$mol_button_copy {
|
|
5173
5464
|
data() {
|
|
5174
5465
|
return Object.fromEntries(this.blobs().map(blob => [blob.type, blob]));
|
|
@@ -5340,6 +5631,10 @@ var $;
|
|
|
5340
5631
|
"use strict";
|
|
5341
5632
|
var $;
|
|
5342
5633
|
(function ($) {
|
|
5634
|
+
/**
|
|
5635
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber from [mol_wire](../wire/README.md)
|
|
5636
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
5637
|
+
*/
|
|
5343
5638
|
$.$mol_action = $mol_wire_method;
|
|
5344
5639
|
})($ || ($ = {}));
|
|
5345
5640
|
|
|
@@ -5416,7 +5711,8 @@ var $;
|
|
|
5416
5711
|
"use strict";
|
|
5417
5712
|
var $;
|
|
5418
5713
|
(function ($) {
|
|
5419
|
-
let buf = new Uint8Array(2 ** 12);
|
|
5714
|
+
let buf = new Uint8Array(2 ** 12); // 4KB Mem Page
|
|
5715
|
+
/** Temporary buffer. Recursive usage isn't supported. */
|
|
5420
5716
|
function $mol_charset_buffer(size) {
|
|
5421
5717
|
if (buf.byteLength < size)
|
|
5422
5718
|
buf = new Uint8Array(size);
|
|
@@ -5438,19 +5734,19 @@ var $;
|
|
|
5438
5734
|
let pos = from;
|
|
5439
5735
|
for (let i = 0; i < str.length; i++) {
|
|
5440
5736
|
let code = str.charCodeAt(i);
|
|
5441
|
-
if (code < 0x80) {
|
|
5737
|
+
if (code < 0x80) { // ASCII - 1 octet
|
|
5442
5738
|
buf[pos++] = code;
|
|
5443
5739
|
}
|
|
5444
|
-
else if (code < 0x800) {
|
|
5740
|
+
else if (code < 0x800) { // 2 octet
|
|
5445
5741
|
buf[pos++] = 0xc0 | (code >> 6);
|
|
5446
5742
|
buf[pos++] = 0x80 | (code & 0x3f);
|
|
5447
5743
|
}
|
|
5448
|
-
else if (code < 0xd800 || code >= 0xe000) {
|
|
5744
|
+
else if (code < 0xd800 || code >= 0xe000) { // 3 octet
|
|
5449
5745
|
buf[pos++] = 0xe0 | (code >> 12);
|
|
5450
5746
|
buf[pos++] = 0x80 | ((code >> 6) & 0x3f);
|
|
5451
5747
|
buf[pos++] = 0x80 | (code & 0x3f);
|
|
5452
5748
|
}
|
|
5453
|
-
else {
|
|
5749
|
+
else { // surrogate pair
|
|
5454
5750
|
const point = ((code - 0xd800) << 10) + str.charCodeAt(++i) + 0x2400;
|
|
5455
5751
|
buf[pos++] = 0xf0 | (point >> 18);
|
|
5456
5752
|
buf[pos++] = 0x80 | ((point >> 12) & 0x3f);
|
|
@@ -5532,12 +5828,24 @@ var $;
|
|
|
5532
5828
|
root() {
|
|
5533
5829
|
const path = this.path();
|
|
5534
5830
|
const base = this.constructor.base;
|
|
5831
|
+
// Если путь выше или равен base или если parent такойже как и this - считаем это корнем
|
|
5535
5832
|
return base.startsWith(path) || this == this.parent();
|
|
5536
5833
|
}
|
|
5537
5834
|
stat(next, virt) {
|
|
5538
5835
|
const path = this.path();
|
|
5539
5836
|
const parent = this.parent();
|
|
5837
|
+
// Отслеживать проверку наличия родительской папки не стоит до корня диска
|
|
5838
|
+
// Лучше ограничить mam-ом
|
|
5540
5839
|
if (!this.root()) {
|
|
5840
|
+
/*
|
|
5841
|
+
Если parent папка удалилась, надо ресетнуть все объекты в ней на любой глубине.
|
|
5842
|
+
Например, rm -rf с последующим git pull: parent папка может удалиться, потом создасться,
|
|
5843
|
+
а текущая папка успеет только удалиться до момента выполнения stat.
|
|
5844
|
+
Поэтому parent.exists() не запустит перевычисления, нужна именно parent.version()
|
|
5845
|
+
|
|
5846
|
+
Однако, parent.version() меняется не только при удалении, будет ложное срабатывание
|
|
5847
|
+
С этим придется мириться, красивого решения пока нет.
|
|
5848
|
+
*/
|
|
5541
5849
|
parent.version();
|
|
5542
5850
|
}
|
|
5543
5851
|
parent.watcher();
|
|
@@ -5551,9 +5859,19 @@ var $;
|
|
|
5551
5859
|
if (/([\/\\]\.|___$)/.test(path))
|
|
5552
5860
|
return;
|
|
5553
5861
|
const file = this.relative(path.at(-1) === '/' ? path.slice(0, -1) : path);
|
|
5862
|
+
// console.log(type, path)
|
|
5863
|
+
// add (change): добавился файл - у parent надо обновить список sub, если он был заюзан
|
|
5864
|
+
// change, unlink (rename): обновился или удалился файл - ресетим
|
|
5865
|
+
// addDir (change), добавилась папка, у parent обновляем список директорий в sub
|
|
5866
|
+
// дочерние ресетим
|
|
5867
|
+
// unlinkDir (rename), удалилась папка, ресетим ее
|
|
5868
|
+
// stat у всех дочерних обновится сам, т.к. связан с parent.version()
|
|
5554
5869
|
this.changed.add(file);
|
|
5555
5870
|
if (!this.watching)
|
|
5556
5871
|
return;
|
|
5872
|
+
// throttle, пока события поступают не сбрасываем.
|
|
5873
|
+
// аналог awaitWriteFinish из chokidar
|
|
5874
|
+
// интервалы между change-сообщениями модифицируемого файла должны быть меньше watch_debounce
|
|
5557
5875
|
this.frame?.destructor();
|
|
5558
5876
|
this.frame = new this.$.$mol_after_timeout(this.watch_debounce(), () => {
|
|
5559
5877
|
if (!this.watching)
|
|
@@ -5562,8 +5880,16 @@ var $;
|
|
|
5562
5880
|
$mol_wire_async(this).flush();
|
|
5563
5881
|
});
|
|
5564
5882
|
}
|
|
5883
|
+
/**
|
|
5884
|
+
* Должно быть больше, чем время между событиями от вотчера при записи внешним процессом.
|
|
5885
|
+
* Иначе запуск ресетов паралельно с изменением может привести к неконсистентности.
|
|
5886
|
+
*/
|
|
5565
5887
|
static watch_debounce() { return 500; }
|
|
5566
5888
|
static flush() {
|
|
5889
|
+
// Пока flush работает, вотчер сюда не заходит, но может добавлять новые изменения
|
|
5890
|
+
// на каждом перезапуске они применятся
|
|
5891
|
+
// Пока run выполняется, изменения накапливаются, в конце run вызывается flush
|
|
5892
|
+
// Пока применяются изменения, run должен ожидать конца flush
|
|
5567
5893
|
for (const file of this.changed) {
|
|
5568
5894
|
const parent = file.parent();
|
|
5569
5895
|
try {
|
|
@@ -5578,16 +5904,32 @@ var $;
|
|
|
5578
5904
|
}
|
|
5579
5905
|
this.changed.clear();
|
|
5580
5906
|
this.watching = true;
|
|
5907
|
+
// this.watch_wd?.destructor()
|
|
5908
|
+
// this.watch_wd = null
|
|
5581
5909
|
}
|
|
5582
5910
|
static watching = true;
|
|
5583
5911
|
static lock = new $mol_lock;
|
|
5584
5912
|
static watch_off(path) {
|
|
5585
5913
|
this.watching = false;
|
|
5914
|
+
// run должен ожидать конца flush
|
|
5586
5915
|
this.flush();
|
|
5587
5916
|
this.watching = false;
|
|
5917
|
+
/*
|
|
5918
|
+
watch запаздывает и событие может прилететь через 3 сек после окончания сайд эффекта
|
|
5919
|
+
поэтому добавляем папку, которую меняет side_effect
|
|
5920
|
+
Когда дойдет до выполнения flush, он ресетнет ее
|
|
5921
|
+
|
|
5922
|
+
Иначе будут лишние срабатывания
|
|
5923
|
+
Например, удалили hyoo/board, watch ресетит и exists начинает отдавать false, срабатывает git clone
|
|
5924
|
+
Сразу после него событие addDir еще не успело прийти,
|
|
5925
|
+
на следующем перезапуске вызывается git pull, т.к.
|
|
5926
|
+
с точки зрения реактивной системы hyoo/board еще не существует.
|
|
5927
|
+
*/
|
|
5588
5928
|
this.changed.add(this.absolute(path));
|
|
5589
5929
|
}
|
|
5930
|
+
// protected static watch_wd = null as null | $mol_after_timeout
|
|
5590
5931
|
static unwatched(side_effect, affected_dir) {
|
|
5932
|
+
// ждем, пока выполнится предыдущий unwatched
|
|
5591
5933
|
const unlock = this.lock.grab();
|
|
5592
5934
|
this.watch_off(affected_dir);
|
|
5593
5935
|
try {
|
|
@@ -5610,6 +5952,7 @@ var $;
|
|
|
5610
5952
|
modified() { return this.stat()?.mtime ?? null; }
|
|
5611
5953
|
version() {
|
|
5612
5954
|
const next = this.stat()?.mtime.getTime().toString(36).toUpperCase() ?? '';
|
|
5955
|
+
// console.log('version', next, this.path())
|
|
5613
5956
|
return next;
|
|
5614
5957
|
}
|
|
5615
5958
|
info(path) { return null; }
|
|
@@ -5627,15 +5970,19 @@ var $;
|
|
|
5627
5970
|
writable(opts) {
|
|
5628
5971
|
return new WritableStream;
|
|
5629
5972
|
}
|
|
5973
|
+
// open( ... modes: readonly $mol_file_mode[] ) { return 0 }
|
|
5630
5974
|
buffer(next) {
|
|
5975
|
+
// Если версия пустая - возвращаем пустой буфер
|
|
5631
5976
|
let readed = new Uint8Array();
|
|
5632
5977
|
if (next === undefined) {
|
|
5978
|
+
// Если меняется версия файла, буфер надо перечитать
|
|
5633
5979
|
if (this.version())
|
|
5634
5980
|
readed = this.read();
|
|
5635
5981
|
}
|
|
5636
5982
|
const prev = $mol_mem_cached(() => this.buffer());
|
|
5637
5983
|
const changed = prev === undefined || !$mol_compare_array(prev, next ?? readed);
|
|
5638
5984
|
if (prev !== undefined && changed) {
|
|
5985
|
+
// Логируем, если повторно читаем/пишем и буфер поменялся
|
|
5639
5986
|
this.$.$mol_log3_rise({
|
|
5640
5987
|
place: `$mol_file_node.buffer()`,
|
|
5641
5988
|
message: 'Changed',
|
|
@@ -5644,6 +5991,11 @@ var $;
|
|
|
5644
5991
|
}
|
|
5645
5992
|
if (next === undefined)
|
|
5646
5993
|
return changed ? readed : prev;
|
|
5994
|
+
// Если буфер при записи не поменялся и файл не удаляли перед этим - не записываем новую версию.
|
|
5995
|
+
// Если записывать, это приведет к смене mtime и вотчер снова триггернется, даже если содержимое файла не поменялось.
|
|
5996
|
+
// В этом алгоритме есть изъян.
|
|
5997
|
+
// Если файл записали, потом отключили вотчер, кто-то из вне его поменял, потом включили вотчер, снова записали тот же буфер,
|
|
5998
|
+
// то буфер не запишется на диск, т.к. кэш не консистентен с диском.
|
|
5647
5999
|
if (!changed && this.exists())
|
|
5648
6000
|
return prev;
|
|
5649
6001
|
this.parent().exists(true);
|
|
@@ -5679,13 +6031,21 @@ var $;
|
|
|
5679
6031
|
}
|
|
5680
6032
|
return null;
|
|
5681
6033
|
}
|
|
6034
|
+
// static watch_root = ''
|
|
6035
|
+
// static watcher_warned = false
|
|
5682
6036
|
watcher() {
|
|
6037
|
+
// const constructor = this.constructor as typeof $mol_file_base
|
|
6038
|
+
// if (! constructor.watcher_warned) {
|
|
6039
|
+
// console.warn(`${constructor}.watcher() not implemented`)
|
|
6040
|
+
// constructor.watcher_warned = true
|
|
6041
|
+
// }
|
|
5683
6042
|
return {
|
|
5684
6043
|
destructor() { }
|
|
5685
6044
|
};
|
|
5686
6045
|
}
|
|
5687
6046
|
exists(next) {
|
|
5688
6047
|
const exists = Boolean(this.stat());
|
|
6048
|
+
// console.log('exists current', exists, 'next', next, this.path())
|
|
5689
6049
|
if (next === undefined)
|
|
5690
6050
|
return exists;
|
|
5691
6051
|
if (next === exists)
|
|
@@ -5711,6 +6071,10 @@ var $;
|
|
|
5711
6071
|
return match ? match[1].substring(1) : '';
|
|
5712
6072
|
}
|
|
5713
6073
|
text(next, virt) {
|
|
6074
|
+
// Если записываем text, и вотчер ресетнул записанный файл,
|
|
6075
|
+
// то надо снова его обновить, вызвать логику, которая делала пуш в text.
|
|
6076
|
+
// Например файл удалили, потом снова создали, версия поменялась - перезаписываем
|
|
6077
|
+
// Если использовать version, то вновь созданный файл, через вотчер запустит свое пересоздание
|
|
5714
6078
|
if (next !== undefined)
|
|
5715
6079
|
this.exists();
|
|
5716
6080
|
return this.text_int(next, virt);
|
|
@@ -5735,6 +6099,7 @@ var $;
|
|
|
5735
6099
|
if (this.type() !== 'dir')
|
|
5736
6100
|
return [];
|
|
5737
6101
|
this.version();
|
|
6102
|
+
// Если дочерний file удалился, список надо обновить
|
|
5738
6103
|
return this.kids().filter(file => file.exists());
|
|
5739
6104
|
}
|
|
5740
6105
|
resolve(path) {
|
|
@@ -5944,6 +6309,7 @@ var $;
|
|
|
5944
6309
|
])
|
|
5945
6310
|
].map(frame_normalize).join('\n')
|
|
5946
6311
|
});
|
|
6312
|
+
// в nodejs, что б не дублировалось cause в консоли
|
|
5947
6313
|
Object.defineProperty(this, 'cause', {
|
|
5948
6314
|
get: () => cause
|
|
5949
6315
|
});
|
|
@@ -6096,6 +6462,7 @@ var $;
|
|
|
6096
6462
|
});
|
|
6097
6463
|
return Object.assign(promise, {
|
|
6098
6464
|
destructor: () => {
|
|
6465
|
+
// Abort of done request breaks response parsing
|
|
6099
6466
|
if (!done && !controller.signal.aborted)
|
|
6100
6467
|
controller.abort();
|
|
6101
6468
|
},
|
|
@@ -6173,10 +6540,12 @@ var $;
|
|
|
6173
6540
|
let res = this.path() + '/' + path;
|
|
6174
6541
|
while (true) {
|
|
6175
6542
|
let prev = res;
|
|
6543
|
+
// foo/../ -> /
|
|
6176
6544
|
res = res.replace(/\/[^\/.]+\/\.\.\//, '/');
|
|
6177
6545
|
if (prev === res)
|
|
6178
6546
|
break;
|
|
6179
6547
|
}
|
|
6548
|
+
// http://localhost/.. -> http://localhost
|
|
6180
6549
|
res = res.replace(/\/\.\.\/?$/, '');
|
|
6181
6550
|
if (res === this.path())
|
|
6182
6551
|
return this;
|
|
@@ -6292,8 +6661,13 @@ var $;
|
|
|
6292
6661
|
(function ($) {
|
|
6293
6662
|
class $mol_file_web extends $mol_file_webdav {
|
|
6294
6663
|
static base = new URL('.', $mol_dom_context.document?.currentScript?.['src'] ?? globalThis.location.href).toString();
|
|
6664
|
+
// Вотчер выключен, версия всегда будет одна
|
|
6665
|
+
// Если пустая строка - будет считаться, что файла нет
|
|
6295
6666
|
version() { return '1'; }
|
|
6667
|
+
// Ворнинги подавляем, иначе в каждом приложении, загружающим локали, будет ворнинг
|
|
6668
|
+
// override watcher() { return { destructor() {} }}
|
|
6296
6669
|
info() {
|
|
6670
|
+
// Директории не поддерживаются
|
|
6297
6671
|
try {
|
|
6298
6672
|
const response = this.fetch({ method: 'HEAD' });
|
|
6299
6673
|
const headers = response.headers();
|
|
@@ -6327,6 +6701,10 @@ var $;
|
|
|
6327
6701
|
"use strict";
|
|
6328
6702
|
var $;
|
|
6329
6703
|
(function ($) {
|
|
6704
|
+
/**
|
|
6705
|
+
* Localisation in $mol framework
|
|
6706
|
+
* @see https://mol.hyoo.ru/#!section=docs/=s5aqnb_odub8l
|
|
6707
|
+
*/
|
|
6330
6708
|
class $mol_locale extends $mol_object {
|
|
6331
6709
|
static lang_default() {
|
|
6332
6710
|
return 'en';
|
|
@@ -6474,12 +6852,17 @@ var $;
|
|
|
6474
6852
|
;
|
|
6475
6853
|
"use strict";
|
|
6476
6854
|
|
|
6855
|
+
|
|
6477
6856
|
;
|
|
6478
6857
|
"use strict";
|
|
6479
6858
|
var $;
|
|
6480
6859
|
(function ($) {
|
|
6481
6860
|
var $$;
|
|
6482
6861
|
(function ($$) {
|
|
6862
|
+
/**
|
|
6863
|
+
* Code visualizer.
|
|
6864
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_text_code_demo
|
|
6865
|
+
*/
|
|
6483
6866
|
class $mol_text_code extends $.$mol_text_code {
|
|
6484
6867
|
render_visible_only() {
|
|
6485
6868
|
return this.$.$mol_support_css_overflow_anchor();
|
|
@@ -6680,12 +7063,17 @@ var $;
|
|
|
6680
7063
|
;
|
|
6681
7064
|
"use strict";
|
|
6682
7065
|
|
|
7066
|
+
|
|
6683
7067
|
;
|
|
6684
7068
|
"use strict";
|
|
6685
7069
|
var $;
|
|
6686
7070
|
(function ($) {
|
|
6687
7071
|
var $$;
|
|
6688
7072
|
(function ($$) {
|
|
7073
|
+
/**
|
|
7074
|
+
* Checkbox UI component. See Variants for more concrete implementations.
|
|
7075
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_check_box_demo
|
|
7076
|
+
*/
|
|
6689
7077
|
class $mol_check extends $.$mol_check {
|
|
6690
7078
|
click(next) {
|
|
6691
7079
|
const event = next ? $mol_dom_event.wrap(next) : null;
|
|
@@ -6722,6 +7110,7 @@ var $;
|
|
|
6722
7110
|
;
|
|
6723
7111
|
"use strict";
|
|
6724
7112
|
|
|
7113
|
+
|
|
6725
7114
|
;
|
|
6726
7115
|
($.$mol_check_expand) = class $mol_check_expand extends ($.$mol_check) {
|
|
6727
7116
|
level_style(){
|
|
@@ -6758,12 +7147,17 @@ var $;
|
|
|
6758
7147
|
;
|
|
6759
7148
|
"use strict";
|
|
6760
7149
|
|
|
7150
|
+
|
|
6761
7151
|
;
|
|
6762
7152
|
"use strict";
|
|
6763
7153
|
var $;
|
|
6764
7154
|
(function ($) {
|
|
6765
7155
|
var $$;
|
|
6766
7156
|
(function ($$) {
|
|
7157
|
+
/**
|
|
7158
|
+
* Expander for trees, lists, etc
|
|
7159
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_check_expand_demo
|
|
7160
|
+
*/
|
|
6767
7161
|
class $mol_check_expand extends $.$mol_check_expand {
|
|
6768
7162
|
level_style() {
|
|
6769
7163
|
return `${this.level() * 1 - 1}rem`;
|
|
@@ -6820,12 +7214,17 @@ var $;
|
|
|
6820
7214
|
;
|
|
6821
7215
|
"use strict";
|
|
6822
7216
|
|
|
7217
|
+
|
|
6823
7218
|
;
|
|
6824
7219
|
"use strict";
|
|
6825
7220
|
var $;
|
|
6826
7221
|
(function ($) {
|
|
6827
7222
|
var $$;
|
|
6828
7223
|
(function ($$) {
|
|
7224
|
+
/**
|
|
7225
|
+
* Dumps any JS values.
|
|
7226
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_dump_demo
|
|
7227
|
+
*/
|
|
6829
7228
|
class $mol_dump_list extends $.$mol_dump_list {
|
|
6830
7229
|
sub() {
|
|
6831
7230
|
return this.values().map((_, index) => this.Dump(index));
|
|
@@ -6899,12 +7298,17 @@ var $;
|
|
|
6899
7298
|
;
|
|
6900
7299
|
"use strict";
|
|
6901
7300
|
|
|
7301
|
+
|
|
6902
7302
|
;
|
|
6903
7303
|
"use strict";
|
|
6904
7304
|
var $;
|
|
6905
7305
|
(function ($) {
|
|
6906
7306
|
var $$;
|
|
6907
7307
|
(function ($$) {
|
|
7308
|
+
/**
|
|
7309
|
+
* Component which expands any content on title click.
|
|
7310
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_expander_demo
|
|
7311
|
+
*/
|
|
6908
7312
|
class $mol_expander extends $.$mol_expander {
|
|
6909
7313
|
rows() {
|
|
6910
7314
|
return [
|
|
@@ -7037,12 +7441,17 @@ var $;
|
|
|
7037
7441
|
;
|
|
7038
7442
|
"use strict";
|
|
7039
7443
|
|
|
7444
|
+
|
|
7040
7445
|
;
|
|
7041
7446
|
"use strict";
|
|
7042
7447
|
var $;
|
|
7043
7448
|
(function ($) {
|
|
7044
7449
|
var $$;
|
|
7045
7450
|
(function ($$) {
|
|
7451
|
+
/**
|
|
7452
|
+
* Dumps any JS values.
|
|
7453
|
+
* @see https://mol.hyoo.ru/#!section=demos/demo=mol_dump_demo
|
|
7454
|
+
*/
|
|
7046
7455
|
class $mol_dump_value extends $.$mol_dump_value {
|
|
7047
7456
|
sub() {
|
|
7048
7457
|
const value = this.value();
|
|
@@ -7131,6 +7540,11 @@ var $;
|
|
|
7131
7540
|
const descr = Reflect.getOwnPropertyDescriptor(value, key);
|
|
7132
7541
|
if ('value' in descr) {
|
|
7133
7542
|
const line = [prefix, descr.value];
|
|
7543
|
+
// let proto = descr.value
|
|
7544
|
+
// while( proto && typeof proto === 'object' ) {
|
|
7545
|
+
// proto = Reflect.getPrototypeOf( proto )
|
|
7546
|
+
// if( proto ) line.push( ' - ', proto )
|
|
7547
|
+
// }
|
|
7134
7548
|
res.push(line);
|
|
7135
7549
|
}
|
|
7136
7550
|
else {
|