mol_jsx_lib 0.0.1047 → 0.0.1049
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 +129 -92
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +598 -497
- package/node.js.map +1 -1
- package/node.mjs +598 -497
- package/node.test.js +1927 -1765
- package/node.test.js.map +1 -1
- package/package.json +21 -19
- package/web.deps.json +1 -1
package/node.test.js
CHANGED
|
@@ -150,6 +150,68 @@ require = (req => Object.assign(function require(name) {
|
|
|
150
150
|
return $node[name];
|
|
151
151
|
}, req))(require);
|
|
152
152
|
|
|
153
|
+
;
|
|
154
|
+
"use strict";
|
|
155
|
+
var $;
|
|
156
|
+
(function ($) {
|
|
157
|
+
const named = new WeakSet();
|
|
158
|
+
function $mol_func_name(func) {
|
|
159
|
+
let name = func.name;
|
|
160
|
+
if (name?.length > 1)
|
|
161
|
+
return name;
|
|
162
|
+
if (named.has(func))
|
|
163
|
+
return name;
|
|
164
|
+
for (let key in this) {
|
|
165
|
+
try {
|
|
166
|
+
if (this[key] !== func)
|
|
167
|
+
continue;
|
|
168
|
+
name = key;
|
|
169
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
catch { }
|
|
173
|
+
}
|
|
174
|
+
named.add(func);
|
|
175
|
+
return name;
|
|
176
|
+
}
|
|
177
|
+
$.$mol_func_name = $mol_func_name;
|
|
178
|
+
function $mol_func_name_from(target, source) {
|
|
179
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
180
|
+
return target;
|
|
181
|
+
}
|
|
182
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
183
|
+
})($ || ($ = {}));
|
|
184
|
+
|
|
185
|
+
;
|
|
186
|
+
"use strict";
|
|
187
|
+
var $;
|
|
188
|
+
(function ($) {
|
|
189
|
+
class $mol_error_mix extends AggregateError {
|
|
190
|
+
cause;
|
|
191
|
+
name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
|
|
192
|
+
constructor(message, cause = {}, ...errors) {
|
|
193
|
+
super(errors, message, { cause });
|
|
194
|
+
this.cause = cause;
|
|
195
|
+
const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
|
|
196
|
+
Object.defineProperty(this, 'stack', {
|
|
197
|
+
get: () => (stack_get.call(this) ?? this.message) + '\n' + [JSON.stringify(this.cause, null, ' ') ?? 'no cause', ...this.errors.map(e => e.stack)].map(e => e.trim()
|
|
198
|
+
.replace(/at /gm, ' at ')
|
|
199
|
+
.replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
static [Symbol.toPrimitive]() {
|
|
203
|
+
return this.toString();
|
|
204
|
+
}
|
|
205
|
+
static toString() {
|
|
206
|
+
return $$.$mol_func_name(this);
|
|
207
|
+
}
|
|
208
|
+
static make(...params) {
|
|
209
|
+
return new this(...params);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
$.$mol_error_mix = $mol_error_mix;
|
|
213
|
+
})($ || ($ = {}));
|
|
214
|
+
|
|
153
215
|
;
|
|
154
216
|
"use strict";
|
|
155
217
|
var $;
|
|
@@ -281,38 +343,6 @@ var $;
|
|
|
281
343
|
;
|
|
282
344
|
"use strict";
|
|
283
345
|
|
|
284
|
-
;
|
|
285
|
-
"use strict";
|
|
286
|
-
var $;
|
|
287
|
-
(function ($) {
|
|
288
|
-
const named = new WeakSet();
|
|
289
|
-
function $mol_func_name(func) {
|
|
290
|
-
let name = func.name;
|
|
291
|
-
if (name?.length > 1)
|
|
292
|
-
return name;
|
|
293
|
-
if (named.has(func))
|
|
294
|
-
return name;
|
|
295
|
-
for (let key in this) {
|
|
296
|
-
try {
|
|
297
|
-
if (this[key] !== func)
|
|
298
|
-
continue;
|
|
299
|
-
name = key;
|
|
300
|
-
Object.defineProperty(func, 'name', { value: name });
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
catch { }
|
|
304
|
-
}
|
|
305
|
-
named.add(func);
|
|
306
|
-
return name;
|
|
307
|
-
}
|
|
308
|
-
$.$mol_func_name = $mol_func_name;
|
|
309
|
-
function $mol_func_name_from(target, source) {
|
|
310
|
-
Object.defineProperty(target, 'name', { value: source.name });
|
|
311
|
-
return target;
|
|
312
|
-
}
|
|
313
|
-
$.$mol_func_name_from = $mol_func_name_from;
|
|
314
|
-
})($ || ($ = {}));
|
|
315
|
-
|
|
316
346
|
;
|
|
317
347
|
"use strict";
|
|
318
348
|
var $;
|
|
@@ -872,90 +902,80 @@ var $;
|
|
|
872
902
|
"use strict";
|
|
873
903
|
var $;
|
|
874
904
|
(function ($) {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
command: `${app} ${args.join(' ')}`,
|
|
883
|
-
});
|
|
884
|
-
var res = $node['child_process'].spawnSync(app, args, {
|
|
885
|
-
cwd: $node.path.resolve(dir),
|
|
886
|
-
shell: true,
|
|
887
|
-
env: this.$mol_env(),
|
|
888
|
-
});
|
|
889
|
-
if (res.status || res.error) {
|
|
890
|
-
return $mol_fail(res.error || new Error(res.stderr.toString(), { cause: res.stdout }));
|
|
891
|
-
}
|
|
892
|
-
if (!res.stdout)
|
|
893
|
-
res.stdout = Buffer.from([]);
|
|
894
|
-
return res;
|
|
895
|
-
}
|
|
896
|
-
$.$mol_exec = $mol_exec;
|
|
897
|
-
})($ || ($ = {}));
|
|
898
|
-
|
|
899
|
-
;
|
|
900
|
-
"use strict";
|
|
901
|
-
var $;
|
|
902
|
-
(function ($) {
|
|
903
|
-
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
905
|
+
let $mol_wire_cursor;
|
|
906
|
+
(function ($mol_wire_cursor) {
|
|
907
|
+
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
908
|
+
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
909
|
+
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
910
|
+
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
911
|
+
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
904
912
|
})($ || ($ = {}));
|
|
905
913
|
|
|
906
914
|
;
|
|
907
915
|
"use strict";
|
|
908
916
|
var $;
|
|
909
917
|
(function ($) {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
break;
|
|
921
|
-
}
|
|
922
|
-
if (nextNode == view) {
|
|
923
|
-
nextNode = nextNode.nextSibling;
|
|
924
|
-
break;
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
if (node_set.has(nextNode)) {
|
|
928
|
-
el.insertBefore(view, nextNode);
|
|
929
|
-
break;
|
|
930
|
-
}
|
|
931
|
-
else {
|
|
932
|
-
const nn = nextNode.nextSibling;
|
|
933
|
-
el.removeChild(nextNode);
|
|
934
|
-
nextNode = nn;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
}
|
|
918
|
+
class $mol_wire_pub extends Object {
|
|
919
|
+
data = [];
|
|
920
|
+
static get [Symbol.species]() {
|
|
921
|
+
return Array;
|
|
922
|
+
}
|
|
923
|
+
sub_from = 0;
|
|
924
|
+
get sub_list() {
|
|
925
|
+
const res = [];
|
|
926
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
927
|
+
res.push(this.data[i]);
|
|
938
928
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
929
|
+
return res;
|
|
930
|
+
}
|
|
931
|
+
get sub_empty() {
|
|
932
|
+
return this.sub_from === this.data.length;
|
|
933
|
+
}
|
|
934
|
+
sub_on(sub, pub_pos) {
|
|
935
|
+
const pos = this.data.length;
|
|
936
|
+
this.data.push(sub, pub_pos);
|
|
937
|
+
return pos;
|
|
938
|
+
}
|
|
939
|
+
sub_off(sub_pos) {
|
|
940
|
+
if (!(sub_pos < this.data.length)) {
|
|
941
|
+
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
942
|
+
}
|
|
943
|
+
const end = this.data.length - 2;
|
|
944
|
+
if (sub_pos !== end) {
|
|
945
|
+
this.peer_move(end, sub_pos);
|
|
950
946
|
}
|
|
947
|
+
this.data.pop();
|
|
948
|
+
this.data.pop();
|
|
949
|
+
if (this.data.length === this.sub_from)
|
|
950
|
+
this.reap();
|
|
951
951
|
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
952
|
+
reap() { }
|
|
953
|
+
promote() {
|
|
954
|
+
$mol_wire_auto()?.track_next(this);
|
|
955
|
+
}
|
|
956
|
+
fresh() { }
|
|
957
|
+
complete() { }
|
|
958
|
+
get incompleted() {
|
|
959
|
+
return false;
|
|
960
|
+
}
|
|
961
|
+
emit(quant = $mol_wire_cursor.stale) {
|
|
962
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
963
|
+
;
|
|
964
|
+
this.data[i].absorb(quant);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
peer_move(from_pos, to_pos) {
|
|
968
|
+
const peer = this.data[from_pos];
|
|
969
|
+
const self_pos = this.data[from_pos + 1];
|
|
970
|
+
this.data[to_pos] = peer;
|
|
971
|
+
this.data[to_pos + 1] = self_pos;
|
|
972
|
+
peer.peer_repos(self_pos, to_pos);
|
|
973
|
+
}
|
|
974
|
+
peer_repos(peer_pos, self_pos) {
|
|
975
|
+
this.data[peer_pos + 1] = self_pos;
|
|
956
976
|
}
|
|
957
977
|
}
|
|
958
|
-
$.$
|
|
978
|
+
$.$mol_wire_pub = $mol_wire_pub;
|
|
959
979
|
})($ || ($ = {}));
|
|
960
980
|
|
|
961
981
|
;
|
|
@@ -965,262 +985,41 @@ var $;
|
|
|
965
985
|
"use strict";
|
|
966
986
|
var $;
|
|
967
987
|
(function ($) {
|
|
968
|
-
$.$
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
988
|
+
$.$mol_wire_auto_sub = null;
|
|
989
|
+
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
990
|
+
return $.$mol_wire_auto_sub = next;
|
|
991
|
+
}
|
|
992
|
+
$.$mol_wire_auto = $mol_wire_auto;
|
|
993
|
+
$.$mol_wire_affected = [];
|
|
994
|
+
})($ || ($ = {}));
|
|
995
|
+
|
|
996
|
+
;
|
|
997
|
+
"use strict";
|
|
998
|
+
var $;
|
|
999
|
+
(function ($) {
|
|
1000
|
+
$['devtoolsFormatters'] ||= [];
|
|
1001
|
+
function $mol_dev_format_register(config) {
|
|
1002
|
+
$['devtoolsFormatters'].push(config);
|
|
1003
|
+
}
|
|
1004
|
+
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
1005
|
+
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
1006
|
+
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
1007
|
+
$mol_dev_format_register({
|
|
1008
|
+
header: (val, config = false) => {
|
|
1009
|
+
if (config)
|
|
1010
|
+
return null;
|
|
1011
|
+
if (!val)
|
|
1012
|
+
return null;
|
|
1013
|
+
if ($.$mol_dev_format_head in val) {
|
|
1014
|
+
try {
|
|
1015
|
+
return val[$.$mol_dev_format_head]();
|
|
1016
|
+
}
|
|
1017
|
+
catch (error) {
|
|
1018
|
+
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
1019
|
+
}
|
|
984
1020
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
990
|
-
if ($.$mol_jsx_prefix) {
|
|
991
|
-
const prefix_ext = $.$mol_jsx_prefix;
|
|
992
|
-
const booked_ext = $.$mol_jsx_booked;
|
|
993
|
-
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
994
|
-
for (const field in props) {
|
|
995
|
-
const func = props[field];
|
|
996
|
-
if (typeof func !== 'function')
|
|
997
|
-
continue;
|
|
998
|
-
const wrapper = function (...args) {
|
|
999
|
-
const prefix = $.$mol_jsx_prefix;
|
|
1000
|
-
const booked = $.$mol_jsx_booked;
|
|
1001
|
-
const crumbs = $.$mol_jsx_crumbs;
|
|
1002
|
-
try {
|
|
1003
|
-
$.$mol_jsx_prefix = prefix_ext;
|
|
1004
|
-
$.$mol_jsx_booked = booked_ext;
|
|
1005
|
-
$.$mol_jsx_crumbs = crumbs_ext;
|
|
1006
|
-
return func.call(this, ...args);
|
|
1007
|
-
}
|
|
1008
|
-
finally {
|
|
1009
|
-
$.$mol_jsx_prefix = prefix;
|
|
1010
|
-
$.$mol_jsx_booked = booked;
|
|
1011
|
-
$.$mol_jsx_crumbs = crumbs;
|
|
1012
|
-
}
|
|
1013
|
-
};
|
|
1014
|
-
$mol_func_name_from(wrapper, func);
|
|
1015
|
-
props[field] = wrapper;
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
if (typeof Elem !== 'string') {
|
|
1019
|
-
if ('prototype' in Elem) {
|
|
1020
|
-
const view = node && node[String(Elem)] || new Elem;
|
|
1021
|
-
Object.assign(view, props);
|
|
1022
|
-
view[Symbol.toStringTag] = guid;
|
|
1023
|
-
view.childNodes = childNodes;
|
|
1024
|
-
if (!view.ownerDocument)
|
|
1025
|
-
view.ownerDocument = $.$mol_jsx_document;
|
|
1026
|
-
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
1027
|
-
node = view.valueOf();
|
|
1028
|
-
node[String(Elem)] = view;
|
|
1029
|
-
return node;
|
|
1030
|
-
}
|
|
1031
|
-
else {
|
|
1032
|
-
const prefix = $.$mol_jsx_prefix;
|
|
1033
|
-
const booked = $.$mol_jsx_booked;
|
|
1034
|
-
const crumbs = $.$mol_jsx_crumbs;
|
|
1035
|
-
try {
|
|
1036
|
-
$.$mol_jsx_prefix = guid;
|
|
1037
|
-
$.$mol_jsx_booked = new Set;
|
|
1038
|
-
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
1039
|
-
return Elem(props, ...childNodes);
|
|
1040
|
-
}
|
|
1041
|
-
finally {
|
|
1042
|
-
$.$mol_jsx_prefix = prefix;
|
|
1043
|
-
$.$mol_jsx_booked = booked;
|
|
1044
|
-
$.$mol_jsx_crumbs = crumbs;
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
if (!node) {
|
|
1049
|
-
node = Elem
|
|
1050
|
-
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
1051
|
-
: $.$mol_jsx_document.createDocumentFragment();
|
|
1052
|
-
}
|
|
1053
|
-
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
1054
|
-
if (!Elem)
|
|
1055
|
-
return node;
|
|
1056
|
-
if (guid)
|
|
1057
|
-
node.id = guid;
|
|
1058
|
-
for (const key in props) {
|
|
1059
|
-
if (key === 'id')
|
|
1060
|
-
continue;
|
|
1061
|
-
if (typeof props[key] === 'string') {
|
|
1062
|
-
if (typeof node[key] === 'string')
|
|
1063
|
-
node[key] = props[key];
|
|
1064
|
-
node.setAttribute(key, props[key]);
|
|
1065
|
-
}
|
|
1066
|
-
else if (props[key] &&
|
|
1067
|
-
typeof props[key] === 'object' &&
|
|
1068
|
-
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
1069
|
-
if (typeof node[key] === 'object') {
|
|
1070
|
-
Object.assign(node[key], props[key]);
|
|
1071
|
-
continue;
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
else {
|
|
1075
|
-
node[key] = props[key];
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
if ($.$mol_jsx_crumbs)
|
|
1079
|
-
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
1080
|
-
return node;
|
|
1081
|
-
}
|
|
1082
|
-
$.$mol_jsx = $mol_jsx;
|
|
1083
|
-
})($ || ($ = {}));
|
|
1084
|
-
|
|
1085
|
-
;
|
|
1086
|
-
"use strict";
|
|
1087
|
-
var $;
|
|
1088
|
-
(function ($) {
|
|
1089
|
-
function $mol_jsx_attach(next, action) {
|
|
1090
|
-
const prev = $mol_jsx_document;
|
|
1091
|
-
try {
|
|
1092
|
-
$mol_jsx_document = next;
|
|
1093
|
-
return action();
|
|
1094
|
-
}
|
|
1095
|
-
finally {
|
|
1096
|
-
$mol_jsx_document = prev;
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
$.$mol_jsx_attach = $mol_jsx_attach;
|
|
1100
|
-
})($ || ($ = {}));
|
|
1101
|
-
|
|
1102
|
-
;
|
|
1103
|
-
"use strict";
|
|
1104
|
-
var $;
|
|
1105
|
-
(function ($) {
|
|
1106
|
-
let $mol_wire_cursor;
|
|
1107
|
-
(function ($mol_wire_cursor) {
|
|
1108
|
-
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
1109
|
-
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
1110
|
-
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
1111
|
-
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
1112
|
-
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
1113
|
-
})($ || ($ = {}));
|
|
1114
|
-
|
|
1115
|
-
;
|
|
1116
|
-
"use strict";
|
|
1117
|
-
var $;
|
|
1118
|
-
(function ($) {
|
|
1119
|
-
class $mol_wire_pub extends Object {
|
|
1120
|
-
data = [];
|
|
1121
|
-
static get [Symbol.species]() {
|
|
1122
|
-
return Array;
|
|
1123
|
-
}
|
|
1124
|
-
sub_from = 0;
|
|
1125
|
-
get sub_list() {
|
|
1126
|
-
const res = [];
|
|
1127
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
1128
|
-
res.push(this.data[i]);
|
|
1129
|
-
}
|
|
1130
|
-
return res;
|
|
1131
|
-
}
|
|
1132
|
-
get sub_empty() {
|
|
1133
|
-
return this.sub_from === this.data.length;
|
|
1134
|
-
}
|
|
1135
|
-
sub_on(sub, pub_pos) {
|
|
1136
|
-
const pos = this.data.length;
|
|
1137
|
-
this.data.push(sub, pub_pos);
|
|
1138
|
-
return pos;
|
|
1139
|
-
}
|
|
1140
|
-
sub_off(sub_pos) {
|
|
1141
|
-
if (!(sub_pos < this.data.length)) {
|
|
1142
|
-
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
1143
|
-
}
|
|
1144
|
-
const end = this.data.length - 2;
|
|
1145
|
-
if (sub_pos !== end) {
|
|
1146
|
-
this.peer_move(end, sub_pos);
|
|
1147
|
-
}
|
|
1148
|
-
this.data.pop();
|
|
1149
|
-
this.data.pop();
|
|
1150
|
-
if (this.data.length === this.sub_from)
|
|
1151
|
-
this.reap();
|
|
1152
|
-
}
|
|
1153
|
-
reap() { }
|
|
1154
|
-
promote() {
|
|
1155
|
-
$mol_wire_auto()?.track_next(this);
|
|
1156
|
-
}
|
|
1157
|
-
fresh() { }
|
|
1158
|
-
complete() { }
|
|
1159
|
-
get incompleted() {
|
|
1160
|
-
return false;
|
|
1161
|
-
}
|
|
1162
|
-
emit(quant = $mol_wire_cursor.stale) {
|
|
1163
|
-
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
1164
|
-
;
|
|
1165
|
-
this.data[i].absorb(quant);
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
peer_move(from_pos, to_pos) {
|
|
1169
|
-
const peer = this.data[from_pos];
|
|
1170
|
-
const self_pos = this.data[from_pos + 1];
|
|
1171
|
-
this.data[to_pos] = peer;
|
|
1172
|
-
this.data[to_pos + 1] = self_pos;
|
|
1173
|
-
peer.peer_repos(self_pos, to_pos);
|
|
1174
|
-
}
|
|
1175
|
-
peer_repos(peer_pos, self_pos) {
|
|
1176
|
-
this.data[peer_pos + 1] = self_pos;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
$.$mol_wire_pub = $mol_wire_pub;
|
|
1180
|
-
})($ || ($ = {}));
|
|
1181
|
-
|
|
1182
|
-
;
|
|
1183
|
-
"use strict";
|
|
1184
|
-
|
|
1185
|
-
;
|
|
1186
|
-
"use strict";
|
|
1187
|
-
var $;
|
|
1188
|
-
(function ($) {
|
|
1189
|
-
$.$mol_wire_auto_sub = null;
|
|
1190
|
-
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
1191
|
-
return $.$mol_wire_auto_sub = next;
|
|
1192
|
-
}
|
|
1193
|
-
$.$mol_wire_auto = $mol_wire_auto;
|
|
1194
|
-
$.$mol_wire_affected = [];
|
|
1195
|
-
})($ || ($ = {}));
|
|
1196
|
-
|
|
1197
|
-
;
|
|
1198
|
-
"use strict";
|
|
1199
|
-
var $;
|
|
1200
|
-
(function ($) {
|
|
1201
|
-
$['devtoolsFormatters'] ||= [];
|
|
1202
|
-
function $mol_dev_format_register(config) {
|
|
1203
|
-
$['devtoolsFormatters'].push(config);
|
|
1204
|
-
}
|
|
1205
|
-
$.$mol_dev_format_register = $mol_dev_format_register;
|
|
1206
|
-
$.$mol_dev_format_head = Symbol('$mol_dev_format_head');
|
|
1207
|
-
$.$mol_dev_format_body = Symbol('$mol_dev_format_body');
|
|
1208
|
-
$mol_dev_format_register({
|
|
1209
|
-
header: (val, config = false) => {
|
|
1210
|
-
if (config)
|
|
1211
|
-
return null;
|
|
1212
|
-
if (!val)
|
|
1213
|
-
return null;
|
|
1214
|
-
if ($.$mol_dev_format_head in val) {
|
|
1215
|
-
try {
|
|
1216
|
-
return val[$.$mol_dev_format_head]();
|
|
1217
|
-
}
|
|
1218
|
-
catch (error) {
|
|
1219
|
-
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
if (typeof val === 'function') {
|
|
1223
|
-
return $mol_dev_format_native(val);
|
|
1021
|
+
if (typeof val === 'function') {
|
|
1022
|
+
return $mol_dev_format_native(val);
|
|
1224
1023
|
}
|
|
1225
1024
|
if (Symbol.toStringTag in val) {
|
|
1226
1025
|
return $mol_dev_format_native(val);
|
|
@@ -1296,20 +1095,6 @@ var $;
|
|
|
1296
1095
|
});
|
|
1297
1096
|
})($ || ($ = {}));
|
|
1298
1097
|
|
|
1299
|
-
;
|
|
1300
|
-
"use strict";
|
|
1301
|
-
var $;
|
|
1302
|
-
(function ($) {
|
|
1303
|
-
function $mol_const(value) {
|
|
1304
|
-
const getter = (() => value);
|
|
1305
|
-
getter['()'] = value;
|
|
1306
|
-
getter[Symbol.toStringTag] = value;
|
|
1307
|
-
getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
|
|
1308
|
-
return getter;
|
|
1309
|
-
}
|
|
1310
|
-
$.$mol_const = $mol_const;
|
|
1311
|
-
})($ || ($ = {}));
|
|
1312
|
-
|
|
1313
1098
|
;
|
|
1314
1099
|
"use strict";
|
|
1315
1100
|
var $;
|
|
@@ -1709,103 +1494,6 @@ var $;
|
|
|
1709
1494
|
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
1710
1495
|
})($ || ($ = {}));
|
|
1711
1496
|
|
|
1712
|
-
;
|
|
1713
|
-
"use strict";
|
|
1714
|
-
var $;
|
|
1715
|
-
(function ($) {
|
|
1716
|
-
function $mol_guid(length = 8, exists = () => false) {
|
|
1717
|
-
for (;;) {
|
|
1718
|
-
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1719
|
-
if (exists(id))
|
|
1720
|
-
continue;
|
|
1721
|
-
return id;
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
$.$mol_guid = $mol_guid;
|
|
1725
|
-
})($ || ($ = {}));
|
|
1726
|
-
|
|
1727
|
-
;
|
|
1728
|
-
"use strict";
|
|
1729
|
-
var $;
|
|
1730
|
-
(function ($) {
|
|
1731
|
-
$.$mol_key_store = new WeakMap();
|
|
1732
|
-
function $mol_key(value) {
|
|
1733
|
-
if (typeof value === 'bigint')
|
|
1734
|
-
return value.toString() + 'n';
|
|
1735
|
-
if (typeof value === 'symbol')
|
|
1736
|
-
return value.description;
|
|
1737
|
-
if (!value)
|
|
1738
|
-
return JSON.stringify(value);
|
|
1739
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1740
|
-
return JSON.stringify(value);
|
|
1741
|
-
return JSON.stringify(value, (field, value) => {
|
|
1742
|
-
if (typeof value === 'bigint')
|
|
1743
|
-
return value.toString() + 'n';
|
|
1744
|
-
if (typeof value === 'symbol')
|
|
1745
|
-
return value.description;
|
|
1746
|
-
if (!value)
|
|
1747
|
-
return value;
|
|
1748
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1749
|
-
return value;
|
|
1750
|
-
if (Array.isArray(value))
|
|
1751
|
-
return value;
|
|
1752
|
-
const proto = Reflect.getPrototypeOf(value);
|
|
1753
|
-
if (!proto)
|
|
1754
|
-
return value;
|
|
1755
|
-
if (Reflect.getPrototypeOf(proto) === null)
|
|
1756
|
-
return value;
|
|
1757
|
-
if ('toJSON' in value)
|
|
1758
|
-
return value;
|
|
1759
|
-
if (value instanceof RegExp)
|
|
1760
|
-
return value.toString();
|
|
1761
|
-
if (value instanceof Uint8Array)
|
|
1762
|
-
return [...value];
|
|
1763
|
-
let key = $.$mol_key_store.get(value);
|
|
1764
|
-
if (key)
|
|
1765
|
-
return key;
|
|
1766
|
-
key = $mol_guid();
|
|
1767
|
-
$.$mol_key_store.set(value, key);
|
|
1768
|
-
return key;
|
|
1769
|
-
});
|
|
1770
|
-
}
|
|
1771
|
-
$.$mol_key = $mol_key;
|
|
1772
|
-
})($ || ($ = {}));
|
|
1773
|
-
|
|
1774
|
-
;
|
|
1775
|
-
"use strict";
|
|
1776
|
-
var $;
|
|
1777
|
-
(function ($) {
|
|
1778
|
-
class $mol_after_timeout extends $mol_object2 {
|
|
1779
|
-
delay;
|
|
1780
|
-
task;
|
|
1781
|
-
id;
|
|
1782
|
-
constructor(delay, task) {
|
|
1783
|
-
super();
|
|
1784
|
-
this.delay = delay;
|
|
1785
|
-
this.task = task;
|
|
1786
|
-
this.id = setTimeout(task, delay);
|
|
1787
|
-
}
|
|
1788
|
-
destructor() {
|
|
1789
|
-
clearTimeout(this.id);
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
$.$mol_after_timeout = $mol_after_timeout;
|
|
1793
|
-
})($ || ($ = {}));
|
|
1794
|
-
|
|
1795
|
-
;
|
|
1796
|
-
"use strict";
|
|
1797
|
-
var $;
|
|
1798
|
-
(function ($) {
|
|
1799
|
-
class $mol_after_frame extends $mol_after_timeout {
|
|
1800
|
-
task;
|
|
1801
|
-
constructor(task) {
|
|
1802
|
-
super(16, task);
|
|
1803
|
-
this.task = task;
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
$.$mol_after_frame = $mol_after_frame;
|
|
1807
|
-
})($ || ($ = {}));
|
|
1808
|
-
|
|
1809
1497
|
;
|
|
1810
1498
|
"use strict";
|
|
1811
1499
|
var $;
|
|
@@ -2012,962 +1700,1375 @@ var $;
|
|
|
2012
1700
|
"use strict";
|
|
2013
1701
|
var $;
|
|
2014
1702
|
(function ($) {
|
|
2015
|
-
function $
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
1703
|
+
function $mol_wire_sync(obj) {
|
|
1704
|
+
return new Proxy(obj, {
|
|
1705
|
+
get(obj, field) {
|
|
1706
|
+
const val = obj[field];
|
|
1707
|
+
if (typeof val !== 'function')
|
|
1708
|
+
return val;
|
|
1709
|
+
const temp = $mol_wire_task.getter(val);
|
|
1710
|
+
return function $mol_wire_sync(...args) {
|
|
1711
|
+
const fiber = temp(obj, args);
|
|
1712
|
+
return fiber.sync();
|
|
1713
|
+
};
|
|
1714
|
+
},
|
|
1715
|
+
apply(obj, self, args) {
|
|
1716
|
+
const temp = $mol_wire_task.getter(obj);
|
|
1717
|
+
const fiber = temp(self, args);
|
|
1718
|
+
return fiber.sync();
|
|
1719
|
+
},
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
|
1723
|
+
})($ || ($ = {}));
|
|
1724
|
+
|
|
1725
|
+
;
|
|
1726
|
+
"use strict";
|
|
1727
|
+
var $;
|
|
1728
|
+
(function ($) {
|
|
1729
|
+
class $mol_run_error extends $mol_error_mix {
|
|
1730
|
+
}
|
|
1731
|
+
$.$mol_run_error = $mol_run_error;
|
|
1732
|
+
const child_process = $node['child_process'];
|
|
1733
|
+
$.$mol_run_spawn = child_process.spawn.bind(child_process);
|
|
1734
|
+
function $mol_run_async({ dir, timeout, command, env }) {
|
|
1735
|
+
const args_raw = typeof command === 'string' ? command.split(' ') : command;
|
|
1736
|
+
const [app, ...args] = args_raw;
|
|
1737
|
+
const sub = this.$mol_run_spawn(app, args, {
|
|
1738
|
+
shell: true,
|
|
1739
|
+
cwd: dir,
|
|
1740
|
+
env
|
|
1741
|
+
});
|
|
1742
|
+
this.$mol_log3_come({
|
|
1743
|
+
place: '$mol_run_async',
|
|
1744
|
+
pid: sub.pid,
|
|
1745
|
+
message: 'Run',
|
|
1746
|
+
command: args_raw.join(' '),
|
|
1747
|
+
dir: $node.path.relative('', dir),
|
|
1748
|
+
});
|
|
1749
|
+
let killed = false;
|
|
1750
|
+
let timer;
|
|
1751
|
+
const std_data = [];
|
|
1752
|
+
const error_data = [];
|
|
1753
|
+
const add = (std_chunk, error_chunk) => {
|
|
1754
|
+
if (std_chunk)
|
|
1755
|
+
std_data.push(std_chunk);
|
|
1756
|
+
if (error_chunk)
|
|
1757
|
+
error_data.push(error_chunk);
|
|
1758
|
+
if (!timeout)
|
|
1759
|
+
return;
|
|
1760
|
+
clearTimeout(timer);
|
|
1761
|
+
timer = setTimeout(() => {
|
|
1762
|
+
const signal = killed ? 'SIGKILL' : 'SIGTERM';
|
|
1763
|
+
killed = true;
|
|
1764
|
+
add();
|
|
1765
|
+
sub.kill(signal);
|
|
1766
|
+
}, timeout);
|
|
2027
1767
|
};
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
1768
|
+
add();
|
|
1769
|
+
sub.stdout?.on('data', data => add(data));
|
|
1770
|
+
sub.stderr?.on('data', data => add(undefined, data));
|
|
1771
|
+
const promise = new Promise((done, fail) => {
|
|
1772
|
+
const close = (error, status = null, signal = null) => {
|
|
1773
|
+
if (!timer && timeout)
|
|
1774
|
+
return;
|
|
1775
|
+
clearTimeout(timer);
|
|
1776
|
+
timer = undefined;
|
|
1777
|
+
const res = {
|
|
1778
|
+
pid: sub.pid,
|
|
1779
|
+
status,
|
|
1780
|
+
signal,
|
|
1781
|
+
get stdout() { return Buffer.concat(std_data); },
|
|
1782
|
+
get stderr() { return Buffer.concat(error_data); }
|
|
1783
|
+
};
|
|
1784
|
+
this.$mol_log3_done({
|
|
1785
|
+
place: '$mol_run_async',
|
|
1786
|
+
pid: sub.pid,
|
|
1787
|
+
message: 'Run',
|
|
1788
|
+
status,
|
|
1789
|
+
command: args_raw.join(' '),
|
|
1790
|
+
dir: $node.path.relative('', dir),
|
|
1791
|
+
});
|
|
1792
|
+
if (error || status || killed)
|
|
1793
|
+
return fail(new $mol_run_error((res.stderr.toString() || res.stdout.toString() || 'Run error') + (killed ? ', timeout' : ''), { signal, timeout: killed }, ...error ? [error] : []));
|
|
1794
|
+
done(res);
|
|
1795
|
+
};
|
|
1796
|
+
sub.on('disconnect', () => close(new Error('Disconnected')));
|
|
1797
|
+
sub.on('error', err => close(err));
|
|
1798
|
+
sub.on('exit', (status, signal) => close(null, status, signal));
|
|
1799
|
+
});
|
|
1800
|
+
return Object.assign(promise, { destructor: () => {
|
|
1801
|
+
clearTimeout(timer);
|
|
1802
|
+
sub.kill('SIGKILL');
|
|
1803
|
+
} });
|
|
2033
1804
|
}
|
|
2034
|
-
$.$
|
|
1805
|
+
$.$mol_run_async = $mol_run_async;
|
|
1806
|
+
function $mol_run(options) {
|
|
1807
|
+
if (!options.env)
|
|
1808
|
+
options = { ...options, env: this.$mol_env() };
|
|
1809
|
+
return $mol_wire_sync(this).$mol_run_async(options);
|
|
1810
|
+
}
|
|
1811
|
+
$.$mol_run = $mol_run;
|
|
2035
1812
|
})($ || ($ = {}));
|
|
2036
1813
|
|
|
2037
1814
|
;
|
|
2038
1815
|
"use strict";
|
|
1816
|
+
var $;
|
|
1817
|
+
(function ($) {
|
|
1818
|
+
function $mol_exec(dir, command, ...args) {
|
|
1819
|
+
return this.$mol_run({ command: [command, ...args], dir });
|
|
1820
|
+
}
|
|
1821
|
+
$.$mol_exec = $mol_exec;
|
|
1822
|
+
})($ || ($ = {}));
|
|
2039
1823
|
|
|
2040
1824
|
;
|
|
2041
1825
|
"use strict";
|
|
1826
|
+
var $;
|
|
1827
|
+
(function ($) {
|
|
1828
|
+
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
1829
|
+
})($ || ($ = {}));
|
|
2042
1830
|
|
|
2043
1831
|
;
|
|
2044
1832
|
"use strict";
|
|
2045
1833
|
var $;
|
|
2046
1834
|
(function ($) {
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
if (
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
1835
|
+
function $mol_dom_render_children(el, childNodes) {
|
|
1836
|
+
const node_set = new Set(childNodes);
|
|
1837
|
+
let nextNode = el.firstChild;
|
|
1838
|
+
for (let view of childNodes) {
|
|
1839
|
+
if (view == null)
|
|
1840
|
+
continue;
|
|
1841
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
1842
|
+
while (true) {
|
|
1843
|
+
if (!nextNode) {
|
|
1844
|
+
el.appendChild(view);
|
|
1845
|
+
break;
|
|
1846
|
+
}
|
|
1847
|
+
if (nextNode == view) {
|
|
1848
|
+
nextNode = nextNode.nextSibling;
|
|
1849
|
+
break;
|
|
1850
|
+
}
|
|
1851
|
+
else {
|
|
1852
|
+
if (node_set.has(nextNode)) {
|
|
1853
|
+
el.insertBefore(view, nextNode);
|
|
1854
|
+
break;
|
|
1855
|
+
}
|
|
1856
|
+
else {
|
|
1857
|
+
const nn = nextNode.nextSibling;
|
|
1858
|
+
el.removeChild(nextNode);
|
|
1859
|
+
nextNode = nn;
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
2068
1863
|
}
|
|
2069
1864
|
else {
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
return fiber;
|
|
2076
|
-
}
|
|
2077
|
-
static watching = new Set();
|
|
2078
|
-
static watcher = null;
|
|
2079
|
-
static watch() {
|
|
2080
|
-
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
2081
|
-
for (const atom of $mol_wire_atom.watching) {
|
|
2082
|
-
if (atom.cursor === $mol_wire_cursor.final) {
|
|
2083
|
-
$mol_wire_atom.watching.delete(atom);
|
|
1865
|
+
if (nextNode && nextNode.nodeName === '#text') {
|
|
1866
|
+
const str = String(view);
|
|
1867
|
+
if (nextNode.nodeValue !== str)
|
|
1868
|
+
nextNode.nodeValue = str;
|
|
1869
|
+
nextNode = nextNode.nextSibling;
|
|
2084
1870
|
}
|
|
2085
1871
|
else {
|
|
2086
|
-
|
|
2087
|
-
|
|
1872
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
1873
|
+
el.insertBefore(textNode, nextNode);
|
|
2088
1874
|
}
|
|
2089
1875
|
}
|
|
2090
1876
|
}
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
$mol_wire_atom.watching.add(this);
|
|
2096
|
-
}
|
|
2097
|
-
resync(args) {
|
|
2098
|
-
return this.put(this.task.call(this.host, ...args));
|
|
2099
|
-
}
|
|
2100
|
-
once() {
|
|
2101
|
-
return this.sync();
|
|
1877
|
+
while (nextNode) {
|
|
1878
|
+
const currNode = nextNode;
|
|
1879
|
+
nextNode = currNode.nextSibling;
|
|
1880
|
+
el.removeChild(currNode);
|
|
2102
1881
|
}
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
1882
|
+
}
|
|
1883
|
+
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
1884
|
+
})($ || ($ = {}));
|
|
1885
|
+
|
|
1886
|
+
;
|
|
1887
|
+
"use strict";
|
|
1888
|
+
|
|
1889
|
+
;
|
|
1890
|
+
"use strict";
|
|
1891
|
+
var $;
|
|
1892
|
+
(function ($) {
|
|
1893
|
+
$.$mol_jsx_prefix = '';
|
|
1894
|
+
$.$mol_jsx_crumbs = '';
|
|
1895
|
+
$.$mol_jsx_booked = null;
|
|
1896
|
+
$.$mol_jsx_document = {
|
|
1897
|
+
getElementById: () => null,
|
|
1898
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
1899
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
1900
|
+
};
|
|
1901
|
+
$.$mol_jsx_frag = '';
|
|
1902
|
+
function $mol_jsx(Elem, props, ...childNodes) {
|
|
1903
|
+
const id = props && props.id || '';
|
|
1904
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
1905
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
|
1906
|
+
if (Elem && $.$mol_jsx_booked) {
|
|
1907
|
+
if ($.$mol_jsx_booked.has(id)) {
|
|
1908
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
2126
1909
|
}
|
|
2127
1910
|
else {
|
|
2128
|
-
;
|
|
2129
|
-
(this.host ?? this.task)[this.field()].delete($mol_key(this.args[0]));
|
|
1911
|
+
$.$mol_jsx_booked.add(id);
|
|
2130
1912
|
}
|
|
2131
1913
|
}
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
if ($mol_owning_catch(this, next)) {
|
|
1914
|
+
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
1915
|
+
if ($.$mol_jsx_prefix) {
|
|
1916
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
|
1917
|
+
const booked_ext = $.$mol_jsx_booked;
|
|
1918
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
1919
|
+
for (const field in props) {
|
|
1920
|
+
const func = props[field];
|
|
1921
|
+
if (typeof func !== 'function')
|
|
1922
|
+
continue;
|
|
1923
|
+
const wrapper = function (...args) {
|
|
1924
|
+
const prefix = $.$mol_jsx_prefix;
|
|
1925
|
+
const booked = $.$mol_jsx_booked;
|
|
1926
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
2146
1927
|
try {
|
|
2147
|
-
|
|
1928
|
+
$.$mol_jsx_prefix = prefix_ext;
|
|
1929
|
+
$.$mol_jsx_booked = booked_ext;
|
|
1930
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
|
1931
|
+
return func.call(this, ...args);
|
|
2148
1932
|
}
|
|
2149
|
-
|
|
2150
|
-
|
|
1933
|
+
finally {
|
|
1934
|
+
$.$mol_jsx_prefix = prefix;
|
|
1935
|
+
$.$mol_jsx_booked = booked;
|
|
1936
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
2151
1937
|
}
|
|
1938
|
+
};
|
|
1939
|
+
$mol_func_name_from(wrapper, func);
|
|
1940
|
+
props[field] = wrapper;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
if (typeof Elem !== 'string') {
|
|
1944
|
+
if ('prototype' in Elem) {
|
|
1945
|
+
const view = node && node[String(Elem)] || new Elem;
|
|
1946
|
+
Object.assign(view, props);
|
|
1947
|
+
view[Symbol.toStringTag] = guid;
|
|
1948
|
+
view.childNodes = childNodes;
|
|
1949
|
+
if (!view.ownerDocument)
|
|
1950
|
+
view.ownerDocument = $.$mol_jsx_document;
|
|
1951
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
1952
|
+
node = view.valueOf();
|
|
1953
|
+
node[String(Elem)] = view;
|
|
1954
|
+
return node;
|
|
1955
|
+
}
|
|
1956
|
+
else {
|
|
1957
|
+
const prefix = $.$mol_jsx_prefix;
|
|
1958
|
+
const booked = $.$mol_jsx_booked;
|
|
1959
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
1960
|
+
try {
|
|
1961
|
+
$.$mol_jsx_prefix = guid;
|
|
1962
|
+
$.$mol_jsx_booked = new Set;
|
|
1963
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
1964
|
+
return Elem(props, ...childNodes);
|
|
1965
|
+
}
|
|
1966
|
+
finally {
|
|
1967
|
+
$.$mol_jsx_prefix = prefix;
|
|
1968
|
+
$.$mol_jsx_booked = booked;
|
|
1969
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
2152
1970
|
}
|
|
2153
|
-
if (!this.sub_empty)
|
|
2154
|
-
this.emit();
|
|
2155
1971
|
}
|
|
2156
|
-
this.cache = next;
|
|
2157
|
-
this.cursor = $mol_wire_cursor.fresh;
|
|
2158
|
-
if ($mol_promise_like(next))
|
|
2159
|
-
return next;
|
|
2160
|
-
this.complete_pubs();
|
|
2161
|
-
return next;
|
|
2162
1972
|
}
|
|
1973
|
+
if (!node) {
|
|
1974
|
+
node = Elem
|
|
1975
|
+
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
1976
|
+
: $.$mol_jsx_document.createDocumentFragment();
|
|
1977
|
+
}
|
|
1978
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
1979
|
+
if (!Elem)
|
|
1980
|
+
return node;
|
|
1981
|
+
if (guid)
|
|
1982
|
+
node.id = guid;
|
|
1983
|
+
for (const key in props) {
|
|
1984
|
+
if (key === 'id')
|
|
1985
|
+
continue;
|
|
1986
|
+
if (typeof props[key] === 'string') {
|
|
1987
|
+
if (typeof node[key] === 'string')
|
|
1988
|
+
node[key] = props[key];
|
|
1989
|
+
node.setAttribute(key, props[key]);
|
|
1990
|
+
}
|
|
1991
|
+
else if (props[key] &&
|
|
1992
|
+
typeof props[key] === 'object' &&
|
|
1993
|
+
Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
|
|
1994
|
+
if (typeof node[key] === 'object') {
|
|
1995
|
+
Object.assign(node[key], props[key]);
|
|
1996
|
+
continue;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
else {
|
|
2000
|
+
node[key] = props[key];
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
if ($.$mol_jsx_crumbs)
|
|
2004
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
2005
|
+
return node;
|
|
2163
2006
|
}
|
|
2164
|
-
|
|
2165
|
-
$mol_wire_method
|
|
2166
|
-
], $mol_wire_atom.prototype, "resync", null);
|
|
2167
|
-
__decorate([
|
|
2168
|
-
$mol_wire_method
|
|
2169
|
-
], $mol_wire_atom.prototype, "once", null);
|
|
2170
|
-
$.$mol_wire_atom = $mol_wire_atom;
|
|
2007
|
+
$.$mol_jsx = $mol_jsx;
|
|
2171
2008
|
})($ || ($ = {}));
|
|
2172
2009
|
|
|
2173
2010
|
;
|
|
2174
2011
|
"use strict";
|
|
2175
2012
|
var $;
|
|
2176
2013
|
(function ($) {
|
|
2177
|
-
function $
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
$mol_wire_atom.solo(this, _get).put(next);
|
|
2183
|
-
};
|
|
2184
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
2185
|
-
const sup_descr = Reflect.getOwnPropertyDescriptor(sup, field);
|
|
2186
|
-
Object.defineProperty(_get, 'name', { value: sup_descr?.get?.name ?? field });
|
|
2187
|
-
Object.defineProperty(_set, 'name', { value: sup_descr?.set?.name ?? field });
|
|
2188
|
-
function get() {
|
|
2189
|
-
return $mol_wire_atom.solo(this, _get).sync();
|
|
2014
|
+
function $mol_jsx_attach(next, action) {
|
|
2015
|
+
const prev = $mol_jsx_document;
|
|
2016
|
+
try {
|
|
2017
|
+
$mol_jsx_document = next;
|
|
2018
|
+
return action();
|
|
2190
2019
|
}
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
temp(this, [next]).sync();
|
|
2020
|
+
finally {
|
|
2021
|
+
$mol_jsx_document = prev;
|
|
2194
2022
|
}
|
|
2195
|
-
Object.defineProperty(get, 'name', { value: _get.name + '$' });
|
|
2196
|
-
Object.defineProperty(set, 'name', { value: _set.name + '@' });
|
|
2197
|
-
Object.assign(get, { orig: _get });
|
|
2198
|
-
Object.assign(set, { orig: _set });
|
|
2199
|
-
const { value, writable, ...descr2 } = { ...descr, get, set };
|
|
2200
|
-
Reflect.defineProperty(host, field, descr2);
|
|
2201
|
-
return descr2;
|
|
2202
2023
|
}
|
|
2203
|
-
$.$
|
|
2024
|
+
$.$mol_jsx_attach = $mol_jsx_attach;
|
|
2204
2025
|
})($ || ($ = {}));
|
|
2205
2026
|
|
|
2206
2027
|
;
|
|
2207
2028
|
"use strict";
|
|
2208
2029
|
var $;
|
|
2209
2030
|
(function ($) {
|
|
2210
|
-
function $
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
2217
|
-
}
|
|
2218
|
-
const descr2 = {
|
|
2219
|
-
...descr,
|
|
2220
|
-
value: function (...args) {
|
|
2221
|
-
let atom = $mol_wire_atom.solo(this, orig);
|
|
2222
|
-
if ((args.length === 0) || (args[0] === undefined)) {
|
|
2223
|
-
if (!$mol_wire_fiber.warm)
|
|
2224
|
-
return atom.result();
|
|
2225
|
-
if ($mol_wire_auto()?.temp) {
|
|
2226
|
-
return atom.once();
|
|
2227
|
-
}
|
|
2228
|
-
else {
|
|
2229
|
-
return atom.sync();
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
return atom.resync(args);
|
|
2233
|
-
}
|
|
2234
|
-
};
|
|
2235
|
-
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
2236
|
-
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
2237
|
-
Object.assign(descr2.value, { orig });
|
|
2238
|
-
Reflect.defineProperty(host, field, descr2);
|
|
2239
|
-
return descr2;
|
|
2031
|
+
function $mol_const(value) {
|
|
2032
|
+
const getter = (() => value);
|
|
2033
|
+
getter['()'] = value;
|
|
2034
|
+
getter[Symbol.toStringTag] = value;
|
|
2035
|
+
getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
|
|
2036
|
+
return getter;
|
|
2240
2037
|
}
|
|
2241
|
-
$.$
|
|
2038
|
+
$.$mol_const = $mol_const;
|
|
2242
2039
|
})($ || ($ = {}));
|
|
2243
2040
|
|
|
2244
2041
|
;
|
|
2245
2042
|
"use strict";
|
|
2246
2043
|
var $;
|
|
2247
2044
|
(function ($) {
|
|
2248
|
-
function $
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
2045
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
2046
|
+
for (;;) {
|
|
2047
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
2048
|
+
if (exists(id))
|
|
2049
|
+
continue;
|
|
2050
|
+
return id;
|
|
2255
2051
|
}
|
|
2256
|
-
const descr2 = {
|
|
2257
|
-
...descr,
|
|
2258
|
-
value: function (...args) {
|
|
2259
|
-
let atom = $mol_wire_atom.plex(this, orig, args[0]);
|
|
2260
|
-
if ((args.length === 1) || (args[1] === undefined)) {
|
|
2261
|
-
if (!$mol_wire_fiber.warm)
|
|
2262
|
-
return atom.result();
|
|
2263
|
-
if ($mol_wire_auto()?.temp) {
|
|
2264
|
-
return atom.once();
|
|
2265
|
-
}
|
|
2266
|
-
else {
|
|
2267
|
-
return atom.sync();
|
|
2268
|
-
}
|
|
2269
|
-
}
|
|
2270
|
-
return atom.resync(args);
|
|
2271
|
-
}
|
|
2272
|
-
};
|
|
2273
|
-
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
2274
|
-
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
2275
|
-
Object.assign(descr2.value, { orig });
|
|
2276
|
-
Reflect.defineProperty(host, field, descr2);
|
|
2277
|
-
return descr2;
|
|
2278
2052
|
}
|
|
2279
|
-
$.$
|
|
2280
|
-
})($ || ($ = {}));
|
|
2281
|
-
|
|
2282
|
-
;
|
|
2283
|
-
"use strict";
|
|
2284
|
-
var $;
|
|
2285
|
-
(function ($) {
|
|
2286
|
-
$.$mol_mem = $mol_wire_solo;
|
|
2287
|
-
$.$mol_mem_key = $mol_wire_plex;
|
|
2053
|
+
$.$mol_guid = $mol_guid;
|
|
2288
2054
|
})($ || ($ = {}));
|
|
2289
2055
|
|
|
2290
2056
|
;
|
|
2291
2057
|
"use strict";
|
|
2292
2058
|
var $;
|
|
2293
2059
|
(function ($) {
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
return
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2060
|
+
$.$mol_key_store = new WeakMap();
|
|
2061
|
+
function $mol_key(value) {
|
|
2062
|
+
if (typeof value === 'bigint')
|
|
2063
|
+
return value.toString() + 'n';
|
|
2064
|
+
if (typeof value === 'symbol')
|
|
2065
|
+
return value.description;
|
|
2066
|
+
if (!value)
|
|
2067
|
+
return JSON.stringify(value);
|
|
2068
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
2069
|
+
return JSON.stringify(value);
|
|
2070
|
+
return JSON.stringify(value, (field, value) => {
|
|
2071
|
+
if (typeof value === 'bigint')
|
|
2072
|
+
return value.toString() + 'n';
|
|
2073
|
+
if (typeof value === 'symbol')
|
|
2074
|
+
return value.description;
|
|
2075
|
+
if (!value)
|
|
2076
|
+
return value;
|
|
2077
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
2078
|
+
return value;
|
|
2079
|
+
if (Array.isArray(value))
|
|
2080
|
+
return value;
|
|
2081
|
+
const proto = Reflect.getPrototypeOf(value);
|
|
2082
|
+
if (!proto)
|
|
2083
|
+
return value;
|
|
2084
|
+
if (Reflect.getPrototypeOf(proto) === null)
|
|
2085
|
+
return value;
|
|
2086
|
+
if ('toJSON' in value)
|
|
2087
|
+
return value;
|
|
2088
|
+
if (value instanceof RegExp)
|
|
2089
|
+
return value.toString();
|
|
2090
|
+
if (value instanceof Uint8Array)
|
|
2091
|
+
return [...value];
|
|
2092
|
+
let key = $.$mol_key_store.get(value);
|
|
2093
|
+
if (key)
|
|
2094
|
+
return key;
|
|
2095
|
+
key = $mol_guid();
|
|
2096
|
+
$.$mol_key_store.set(value, key);
|
|
2097
|
+
return key;
|
|
2098
|
+
});
|
|
2323
2099
|
}
|
|
2324
|
-
|
|
2325
|
-
$mol_wire_field
|
|
2326
|
-
], $mol_jsx_view.prototype, "childNodes", null);
|
|
2327
|
-
__decorate([
|
|
2328
|
-
$mol_mem
|
|
2329
|
-
], $mol_jsx_view.prototype, "valueOf", null);
|
|
2330
|
-
$.$mol_jsx_view = $mol_jsx_view;
|
|
2100
|
+
$.$mol_key = $mol_key;
|
|
2331
2101
|
})($ || ($ = {}));
|
|
2332
2102
|
|
|
2333
2103
|
;
|
|
2334
2104
|
"use strict";
|
|
2335
2105
|
var $;
|
|
2336
2106
|
(function ($) {
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2107
|
+
class $mol_after_timeout extends $mol_object2 {
|
|
2108
|
+
delay;
|
|
2109
|
+
task;
|
|
2110
|
+
id;
|
|
2111
|
+
constructor(delay, task) {
|
|
2112
|
+
super();
|
|
2113
|
+
this.delay = delay;
|
|
2114
|
+
this.task = task;
|
|
2115
|
+
this.id = setTimeout(task, delay);
|
|
2345
2116
|
}
|
|
2346
|
-
|
|
2347
|
-
|
|
2117
|
+
destructor() {
|
|
2118
|
+
clearTimeout(this.id);
|
|
2348
2119
|
}
|
|
2349
2120
|
}
|
|
2350
|
-
$.$
|
|
2121
|
+
$.$mol_after_timeout = $mol_after_timeout;
|
|
2351
2122
|
})($ || ($ = {}));
|
|
2352
2123
|
|
|
2353
2124
|
;
|
|
2354
2125
|
"use strict";
|
|
2355
2126
|
var $;
|
|
2356
2127
|
(function ($) {
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
current?.sub_on(sub, sub.data.length);
|
|
2128
|
+
class $mol_after_frame extends $mol_after_timeout {
|
|
2129
|
+
task;
|
|
2130
|
+
constructor(task) {
|
|
2131
|
+
super(16, task);
|
|
2132
|
+
this.task = task;
|
|
2363
2133
|
}
|
|
2364
|
-
current.reap = nothing;
|
|
2365
2134
|
}
|
|
2366
|
-
$.$
|
|
2367
|
-
const nothing = () => { };
|
|
2368
|
-
const sub = new $mol_wire_pub_sub;
|
|
2135
|
+
$.$mol_after_frame = $mol_after_frame;
|
|
2369
2136
|
})($ || ($ = {}));
|
|
2370
2137
|
|
|
2371
2138
|
;
|
|
2372
2139
|
"use strict";
|
|
2373
2140
|
var $;
|
|
2374
2141
|
(function ($) {
|
|
2375
|
-
function $
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2142
|
+
function $mol_wire_method(host, field, descr) {
|
|
2143
|
+
if (!descr)
|
|
2144
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
2145
|
+
const orig = descr?.value ?? host[field];
|
|
2146
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
2147
|
+
if (typeof sup[field] === 'function') {
|
|
2148
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
2382
2149
|
}
|
|
2150
|
+
const temp = $mol_wire_task.getter(orig);
|
|
2151
|
+
const value = function (...args) {
|
|
2152
|
+
const fiber = temp(this ?? null, args);
|
|
2153
|
+
return fiber.sync();
|
|
2154
|
+
};
|
|
2155
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
2156
|
+
Object.assign(value, { orig });
|
|
2157
|
+
const descr2 = { ...descr, value };
|
|
2158
|
+
Reflect.defineProperty(host, field, descr2);
|
|
2159
|
+
return descr2;
|
|
2383
2160
|
}
|
|
2384
|
-
$.$
|
|
2161
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
2385
2162
|
})($ || ($ = {}));
|
|
2386
2163
|
|
|
2387
2164
|
;
|
|
2388
2165
|
"use strict";
|
|
2389
|
-
var $;
|
|
2390
|
-
(function ($) {
|
|
2391
|
-
function $mol_wire_sync(obj) {
|
|
2392
|
-
return new Proxy(obj, {
|
|
2393
|
-
get(obj, field) {
|
|
2394
|
-
const val = obj[field];
|
|
2395
|
-
if (typeof val !== 'function')
|
|
2396
|
-
return val;
|
|
2397
|
-
const temp = $mol_wire_task.getter(val);
|
|
2398
|
-
return function $mol_wire_sync(...args) {
|
|
2399
|
-
const fiber = temp(obj, args);
|
|
2400
|
-
return fiber.sync();
|
|
2401
|
-
};
|
|
2402
|
-
},
|
|
2403
|
-
apply(obj, self, args) {
|
|
2404
|
-
const temp = $mol_wire_task.getter(obj);
|
|
2405
|
-
const fiber = temp(self, args);
|
|
2406
|
-
return fiber.sync();
|
|
2407
|
-
},
|
|
2408
|
-
});
|
|
2409
|
-
}
|
|
2410
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
|
2411
|
-
})($ || ($ = {}));
|
|
2412
2166
|
|
|
2413
2167
|
;
|
|
2414
2168
|
"use strict";
|
|
2415
|
-
var $;
|
|
2416
|
-
(function ($) {
|
|
2417
|
-
function $mol_wire_async(obj) {
|
|
2418
|
-
let fiber;
|
|
2419
|
-
const temp = $mol_wire_task.getter(obj);
|
|
2420
|
-
return new Proxy(obj, {
|
|
2421
|
-
get(obj, field) {
|
|
2422
|
-
const val = obj[field];
|
|
2423
|
-
if (typeof val !== 'function')
|
|
2424
|
-
return val;
|
|
2425
|
-
let fiber;
|
|
2426
|
-
const temp = $mol_wire_task.getter(val);
|
|
2427
|
-
return function $mol_wire_async(...args) {
|
|
2428
|
-
fiber?.destructor();
|
|
2429
|
-
fiber = temp(obj, args);
|
|
2430
|
-
return fiber.async();
|
|
2431
|
-
};
|
|
2432
|
-
},
|
|
2433
|
-
apply(obj, self, args) {
|
|
2434
|
-
fiber?.destructor();
|
|
2435
|
-
fiber = temp(self, args);
|
|
2436
|
-
return fiber.async();
|
|
2437
|
-
},
|
|
2438
|
-
});
|
|
2439
|
-
}
|
|
2440
|
-
$.$mol_wire_async = $mol_wire_async;
|
|
2441
|
-
})($ || ($ = {}));
|
|
2442
2169
|
|
|
2443
2170
|
;
|
|
2444
2171
|
"use strict";
|
|
2445
2172
|
var $;
|
|
2446
2173
|
(function ($) {
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2174
|
+
class $mol_wire_atom extends $mol_wire_fiber {
|
|
2175
|
+
static solo(host, task) {
|
|
2176
|
+
const field = task.name + '<>';
|
|
2177
|
+
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
2178
|
+
if (existen)
|
|
2179
|
+
return existen;
|
|
2180
|
+
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
2181
|
+
const key = prefix + ('.' + field);
|
|
2182
|
+
const fiber = new $mol_wire_atom(key, task, host, []);
|
|
2183
|
+
(host ?? task)[field] = fiber;
|
|
2184
|
+
return fiber;
|
|
2185
|
+
}
|
|
2186
|
+
static plex(host, task, key) {
|
|
2187
|
+
const field = task.name + '<>';
|
|
2188
|
+
let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
2189
|
+
const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
|
|
2190
|
+
const key_str = $mol_key(key);
|
|
2191
|
+
if (dict) {
|
|
2192
|
+
const existen = dict.get(key_str);
|
|
2193
|
+
if (existen)
|
|
2194
|
+
return existen;
|
|
2451
2195
|
}
|
|
2452
|
-
|
|
2453
|
-
|
|
2196
|
+
else {
|
|
2197
|
+
dict = (host ?? task)[field] = new Map();
|
|
2454
2198
|
}
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
const error = results.find(res => res instanceof Error);
|
|
2460
|
-
if (error)
|
|
2461
|
-
$mol_fail(error);
|
|
2462
|
-
return results;
|
|
2463
|
-
}
|
|
2464
|
-
$.$mol_wire_race = $mol_wire_race;
|
|
2465
|
-
})($ || ($ = {}));
|
|
2466
|
-
|
|
2467
|
-
;
|
|
2468
|
-
"use strict";
|
|
2469
|
-
var $;
|
|
2470
|
-
(function ($_1) {
|
|
2471
|
-
let $$;
|
|
2472
|
-
(function ($$) {
|
|
2473
|
-
let $;
|
|
2474
|
-
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
2475
|
-
$_1.$mol_object_field = Symbol('$mol_object_field');
|
|
2476
|
-
class $mol_object extends $mol_object2 {
|
|
2477
|
-
static make(config) {
|
|
2478
|
-
return super.create(obj => {
|
|
2479
|
-
for (let key in config)
|
|
2480
|
-
obj[key] = config[key];
|
|
2481
|
-
});
|
|
2199
|
+
const id = prefix + ('.' + task.name) + ('<' + key_str.replace(/^"|"$/g, "'") + '>');
|
|
2200
|
+
const fiber = new $mol_wire_atom(id, task, host, [key]);
|
|
2201
|
+
dict.set(key_str, fiber);
|
|
2202
|
+
return fiber;
|
|
2482
2203
|
}
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2204
|
+
static watching = new Set();
|
|
2205
|
+
static watcher = null;
|
|
2206
|
+
static watch() {
|
|
2207
|
+
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
2208
|
+
for (const atom of $mol_wire_atom.watching) {
|
|
2209
|
+
if (atom.cursor === $mol_wire_cursor.final) {
|
|
2210
|
+
$mol_wire_atom.watching.delete(atom);
|
|
2211
|
+
}
|
|
2212
|
+
else {
|
|
2213
|
+
atom.cursor = $mol_wire_cursor.stale;
|
|
2214
|
+
atom.fresh();
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
watch() {
|
|
2219
|
+
if (!$mol_wire_atom.watcher) {
|
|
2220
|
+
$mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
|
|
2221
|
+
}
|
|
2222
|
+
$mol_wire_atom.watching.add(this);
|
|
2223
|
+
}
|
|
2224
|
+
resync(args) {
|
|
2225
|
+
return this.put(this.task.call(this.host, ...args));
|
|
2226
|
+
}
|
|
2227
|
+
once() {
|
|
2228
|
+
return this.sync();
|
|
2229
|
+
}
|
|
2230
|
+
channel() {
|
|
2231
|
+
return Object.assign((next) => {
|
|
2232
|
+
if (next !== undefined)
|
|
2233
|
+
return this.resync([...this.args, next]);
|
|
2234
|
+
if (!$mol_wire_fiber.warm)
|
|
2235
|
+
return this.result();
|
|
2236
|
+
if ($mol_wire_auto()?.temp) {
|
|
2237
|
+
return this.once();
|
|
2238
|
+
}
|
|
2239
|
+
else {
|
|
2240
|
+
return this.sync();
|
|
2241
|
+
}
|
|
2242
|
+
}, { atom: this });
|
|
2243
|
+
}
|
|
2244
|
+
destructor() {
|
|
2245
|
+
super.destructor();
|
|
2246
|
+
const prev = this.cache;
|
|
2247
|
+
if ($mol_owning_check(this, prev)) {
|
|
2248
|
+
prev.destructor();
|
|
2249
|
+
}
|
|
2250
|
+
if (this.pub_from === 0) {
|
|
2251
|
+
;
|
|
2252
|
+
(this.host ?? this.task)[this.field()] = null;
|
|
2495
2253
|
}
|
|
2496
2254
|
else {
|
|
2497
|
-
|
|
2255
|
+
;
|
|
2256
|
+
(this.host ?? this.task)[this.field()].delete($mol_key(this.args[0]));
|
|
2498
2257
|
}
|
|
2499
2258
|
}
|
|
2500
|
-
|
|
2501
|
-
this.
|
|
2502
|
-
|
|
2259
|
+
put(next) {
|
|
2260
|
+
const prev = this.cache;
|
|
2261
|
+
update: if (next !== prev) {
|
|
2262
|
+
try {
|
|
2263
|
+
if ($mol_compare_deep(prev, next))
|
|
2264
|
+
break update;
|
|
2265
|
+
}
|
|
2266
|
+
catch (error) {
|
|
2267
|
+
$mol_fail_log(error);
|
|
2268
|
+
}
|
|
2269
|
+
if ($mol_owning_check(this, prev)) {
|
|
2270
|
+
prev.destructor();
|
|
2271
|
+
}
|
|
2272
|
+
if ($mol_owning_catch(this, next)) {
|
|
2273
|
+
try {
|
|
2274
|
+
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
2275
|
+
}
|
|
2276
|
+
catch {
|
|
2277
|
+
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
if (!this.sub_empty)
|
|
2281
|
+
this.emit();
|
|
2282
|
+
}
|
|
2283
|
+
this.cache = next;
|
|
2284
|
+
this.cursor = $mol_wire_cursor.fresh;
|
|
2285
|
+
if ($mol_promise_like(next))
|
|
2286
|
+
return next;
|
|
2287
|
+
this.complete_pubs();
|
|
2288
|
+
return next;
|
|
2503
2289
|
}
|
|
2504
2290
|
}
|
|
2505
2291
|
__decorate([
|
|
2506
|
-
$
|
|
2507
|
-
], $
|
|
2292
|
+
$mol_wire_method
|
|
2293
|
+
], $mol_wire_atom.prototype, "resync", null);
|
|
2508
2294
|
__decorate([
|
|
2509
|
-
$
|
|
2510
|
-
], $
|
|
2511
|
-
$.$
|
|
2295
|
+
$mol_wire_method
|
|
2296
|
+
], $mol_wire_atom.prototype, "once", null);
|
|
2297
|
+
$.$mol_wire_atom = $mol_wire_atom;
|
|
2512
2298
|
})($ || ($ = {}));
|
|
2513
2299
|
|
|
2514
2300
|
;
|
|
2515
2301
|
"use strict";
|
|
2516
2302
|
var $;
|
|
2517
2303
|
(function ($) {
|
|
2518
|
-
function $
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
const
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
const
|
|
2526
|
-
const
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2304
|
+
function $mol_wire_field(host, field, descr) {
|
|
2305
|
+
if (!descr)
|
|
2306
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
2307
|
+
const _get = descr?.get || $mol_const(descr?.value);
|
|
2308
|
+
const _set = descr?.set || function (next) {
|
|
2309
|
+
$mol_wire_atom.solo(this, _get).put(next);
|
|
2310
|
+
};
|
|
2311
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
2312
|
+
const sup_descr = Reflect.getOwnPropertyDescriptor(sup, field);
|
|
2313
|
+
Object.defineProperty(_get, 'name', { value: sup_descr?.get?.name ?? field });
|
|
2314
|
+
Object.defineProperty(_set, 'name', { value: sup_descr?.set?.name ?? field });
|
|
2315
|
+
function get() {
|
|
2316
|
+
return $mol_wire_atom.solo(this, _get).sync();
|
|
2317
|
+
}
|
|
2318
|
+
const temp = $mol_wire_task.getter(_set);
|
|
2319
|
+
function set(next) {
|
|
2320
|
+
temp(this, [next]).sync();
|
|
2321
|
+
}
|
|
2322
|
+
Object.defineProperty(get, 'name', { value: _get.name + '$' });
|
|
2323
|
+
Object.defineProperty(set, 'name', { value: _set.name + '@' });
|
|
2324
|
+
Object.assign(get, { orig: _get });
|
|
2325
|
+
Object.assign(set, { orig: _set });
|
|
2326
|
+
const { value, writable, ...descr2 } = { ...descr, get, set };
|
|
2327
|
+
Reflect.defineProperty(host, field, descr2);
|
|
2328
|
+
return descr2;
|
|
2531
2329
|
}
|
|
2532
|
-
$.$
|
|
2330
|
+
$.$mol_wire_field = $mol_wire_field;
|
|
2533
2331
|
})($ || ($ = {}));
|
|
2534
2332
|
|
|
2535
2333
|
;
|
|
2536
2334
|
"use strict";
|
|
2537
2335
|
var $;
|
|
2538
2336
|
(function ($) {
|
|
2539
|
-
function $
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
const get = descr.get ?? (() => descr.value);
|
|
2547
|
-
const set = descr.set ?? (next => descr.value = next);
|
|
2548
|
-
Reflect.defineProperty(obj, field, {
|
|
2549
|
-
configurable: true,
|
|
2550
|
-
enumerable: descr.enumerable,
|
|
2551
|
-
get() {
|
|
2552
|
-
const atom = $mol_wire_atom.solo(obj, get);
|
|
2553
|
-
atom.watch();
|
|
2554
|
-
return atom.sync();
|
|
2555
|
-
},
|
|
2556
|
-
set(next) {
|
|
2557
|
-
const atom = $mol_wire_atom.solo(obj, get);
|
|
2558
|
-
set.call(this, next);
|
|
2559
|
-
atom.refresh();
|
|
2560
|
-
},
|
|
2561
|
-
});
|
|
2337
|
+
function $mol_wire_solo(host, field, descr) {
|
|
2338
|
+
if (!descr)
|
|
2339
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
2340
|
+
const orig = descr?.value ?? host[field];
|
|
2341
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
2342
|
+
if (typeof sup[field] === 'function') {
|
|
2343
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
2562
2344
|
}
|
|
2345
|
+
const descr2 = {
|
|
2346
|
+
...descr,
|
|
2347
|
+
value: function (...args) {
|
|
2348
|
+
let atom = $mol_wire_atom.solo(this, orig);
|
|
2349
|
+
if ((args.length === 0) || (args[0] === undefined)) {
|
|
2350
|
+
if (!$mol_wire_fiber.warm)
|
|
2351
|
+
return atom.result();
|
|
2352
|
+
if ($mol_wire_auto()?.temp) {
|
|
2353
|
+
return atom.once();
|
|
2354
|
+
}
|
|
2355
|
+
else {
|
|
2356
|
+
return atom.sync();
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
return atom.resync(args);
|
|
2360
|
+
}
|
|
2361
|
+
};
|
|
2362
|
+
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
2363
|
+
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
2364
|
+
Object.assign(descr2.value, { orig });
|
|
2365
|
+
Reflect.defineProperty(host, field, descr2);
|
|
2366
|
+
return descr2;
|
|
2563
2367
|
}
|
|
2564
|
-
$.$
|
|
2368
|
+
$.$mol_wire_solo = $mol_wire_solo;
|
|
2565
2369
|
})($ || ($ = {}));
|
|
2566
2370
|
|
|
2567
|
-
;
|
|
2568
|
-
"use strict";
|
|
2569
|
-
|
|
2570
2371
|
;
|
|
2571
2372
|
"use strict";
|
|
2572
2373
|
var $;
|
|
2573
2374
|
(function ($) {
|
|
2574
|
-
function $
|
|
2575
|
-
|
|
2576
|
-
|
|
2375
|
+
function $mol_wire_plex(host, field, descr) {
|
|
2376
|
+
if (!descr)
|
|
2377
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
2378
|
+
const orig = descr?.value ?? host[field];
|
|
2379
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
2380
|
+
if (typeof sup[field] === 'function') {
|
|
2381
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
2577
2382
|
}
|
|
2578
|
-
|
|
2383
|
+
const descr2 = {
|
|
2384
|
+
...descr,
|
|
2385
|
+
value: function (...args) {
|
|
2386
|
+
let atom = $mol_wire_atom.plex(this, orig, args[0]);
|
|
2387
|
+
if ((args.length === 1) || (args[1] === undefined)) {
|
|
2388
|
+
if (!$mol_wire_fiber.warm)
|
|
2389
|
+
return atom.result();
|
|
2390
|
+
if ($mol_wire_auto()?.temp) {
|
|
2391
|
+
return atom.once();
|
|
2392
|
+
}
|
|
2393
|
+
else {
|
|
2394
|
+
return atom.sync();
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
return atom.resync(args);
|
|
2398
|
+
}
|
|
2399
|
+
};
|
|
2400
|
+
Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
|
|
2401
|
+
Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
|
|
2402
|
+
Object.assign(descr2.value, { orig });
|
|
2403
|
+
Reflect.defineProperty(host, field, descr2);
|
|
2404
|
+
return descr2;
|
|
2579
2405
|
}
|
|
2580
|
-
$.$
|
|
2406
|
+
$.$mol_wire_plex = $mol_wire_plex;
|
|
2581
2407
|
})($ || ($ = {}));
|
|
2582
2408
|
|
|
2583
2409
|
;
|
|
2584
2410
|
"use strict";
|
|
2585
2411
|
var $;
|
|
2586
2412
|
(function ($) {
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
this.pub.promote();
|
|
2599
|
-
return super.keys();
|
|
2600
|
-
}
|
|
2601
|
-
values() {
|
|
2602
|
-
this.pub.promote();
|
|
2603
|
-
return super.values();
|
|
2604
|
-
}
|
|
2605
|
-
forEach(task, self) {
|
|
2606
|
-
this.pub.promote();
|
|
2607
|
-
super.forEach(task, self);
|
|
2608
|
-
}
|
|
2609
|
-
[Symbol.iterator]() {
|
|
2610
|
-
this.pub.promote();
|
|
2611
|
-
return super[Symbol.iterator]();
|
|
2612
|
-
}
|
|
2613
|
-
get size() {
|
|
2614
|
-
this.pub.promote();
|
|
2615
|
-
return super.size;
|
|
2616
|
-
}
|
|
2617
|
-
add(value) {
|
|
2618
|
-
if (super.has(value))
|
|
2619
|
-
return this;
|
|
2620
|
-
super.add(value);
|
|
2621
|
-
this.pub.emit();
|
|
2622
|
-
return this;
|
|
2623
|
-
}
|
|
2624
|
-
delete(value) {
|
|
2625
|
-
const res = super.delete(value);
|
|
2626
|
-
if (res)
|
|
2627
|
-
this.pub.emit();
|
|
2628
|
-
return res;
|
|
2413
|
+
$.$mol_mem = $mol_wire_solo;
|
|
2414
|
+
$.$mol_mem_key = $mol_wire_plex;
|
|
2415
|
+
})($ || ($ = {}));
|
|
2416
|
+
|
|
2417
|
+
;
|
|
2418
|
+
"use strict";
|
|
2419
|
+
var $;
|
|
2420
|
+
(function ($) {
|
|
2421
|
+
class $mol_jsx_view extends $mol_object2 {
|
|
2422
|
+
static of(node) {
|
|
2423
|
+
return node[this];
|
|
2629
2424
|
}
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2425
|
+
attributes;
|
|
2426
|
+
ownerDocument;
|
|
2427
|
+
className = '';
|
|
2428
|
+
get childNodes() {
|
|
2429
|
+
return [];
|
|
2635
2430
|
}
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
this.
|
|
2643
|
-
|
|
2431
|
+
valueOf() {
|
|
2432
|
+
const prefix = $mol_jsx_prefix;
|
|
2433
|
+
const booked = $mol_jsx_booked;
|
|
2434
|
+
const crumbs = $mol_jsx_crumbs;
|
|
2435
|
+
const document = $mol_jsx_document;
|
|
2436
|
+
try {
|
|
2437
|
+
$mol_jsx_prefix = this[Symbol.toStringTag];
|
|
2438
|
+
$mol_jsx_booked = new Set;
|
|
2439
|
+
$mol_jsx_crumbs = this.className;
|
|
2440
|
+
$mol_jsx_document = this.ownerDocument;
|
|
2441
|
+
return this.render();
|
|
2442
|
+
}
|
|
2443
|
+
finally {
|
|
2444
|
+
$mol_jsx_prefix = prefix;
|
|
2445
|
+
$mol_jsx_booked = booked;
|
|
2446
|
+
$mol_jsx_crumbs = crumbs;
|
|
2447
|
+
$mol_jsx_document = document;
|
|
2448
|
+
}
|
|
2644
2449
|
}
|
|
2645
2450
|
}
|
|
2646
|
-
|
|
2451
|
+
__decorate([
|
|
2452
|
+
$mol_wire_field
|
|
2453
|
+
], $mol_jsx_view.prototype, "childNodes", null);
|
|
2454
|
+
__decorate([
|
|
2455
|
+
$mol_mem
|
|
2456
|
+
], $mol_jsx_view.prototype, "valueOf", null);
|
|
2457
|
+
$.$mol_jsx_view = $mol_jsx_view;
|
|
2647
2458
|
})($ || ($ = {}));
|
|
2648
2459
|
|
|
2649
2460
|
;
|
|
2650
2461
|
"use strict";
|
|
2651
2462
|
var $;
|
|
2652
2463
|
(function ($) {
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
this.pub.promote();
|
|
2661
|
-
return super.get(key);
|
|
2662
|
-
}
|
|
2663
|
-
entries() {
|
|
2664
|
-
this.pub.promote();
|
|
2665
|
-
return super.entries();
|
|
2666
|
-
}
|
|
2667
|
-
keys() {
|
|
2668
|
-
this.pub.promote();
|
|
2669
|
-
return super.keys();
|
|
2670
|
-
}
|
|
2671
|
-
values() {
|
|
2672
|
-
this.pub.promote();
|
|
2673
|
-
return super.values();
|
|
2674
|
-
}
|
|
2675
|
-
forEach(task, self) {
|
|
2676
|
-
this.pub.promote();
|
|
2677
|
-
super.forEach(task, self);
|
|
2678
|
-
}
|
|
2679
|
-
[Symbol.iterator]() {
|
|
2680
|
-
this.pub.promote();
|
|
2681
|
-
return super[Symbol.iterator]();
|
|
2682
|
-
}
|
|
2683
|
-
get size() {
|
|
2684
|
-
this.pub.promote();
|
|
2685
|
-
return super.size;
|
|
2686
|
-
}
|
|
2687
|
-
set(key, value) {
|
|
2688
|
-
if (super.get(key) === value)
|
|
2689
|
-
return this;
|
|
2690
|
-
super.set(key, value);
|
|
2691
|
-
this.pub?.emit();
|
|
2692
|
-
return this;
|
|
2693
|
-
}
|
|
2694
|
-
delete(key) {
|
|
2695
|
-
const res = super.delete(key);
|
|
2696
|
-
if (res)
|
|
2697
|
-
this.pub.emit();
|
|
2464
|
+
function $mol_wire_probe(task, def) {
|
|
2465
|
+
const warm = $mol_wire_fiber.warm;
|
|
2466
|
+
try {
|
|
2467
|
+
$mol_wire_fiber.warm = false;
|
|
2468
|
+
const res = task();
|
|
2469
|
+
if (res === undefined)
|
|
2470
|
+
return def;
|
|
2698
2471
|
return res;
|
|
2699
2472
|
}
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
return;
|
|
2703
|
-
super.clear();
|
|
2704
|
-
this.pub.emit();
|
|
2473
|
+
finally {
|
|
2474
|
+
$mol_wire_fiber.warm = warm;
|
|
2705
2475
|
}
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2476
|
+
}
|
|
2477
|
+
$.$mol_wire_probe = $mol_wire_probe;
|
|
2478
|
+
})($ || ($ = {}));
|
|
2479
|
+
|
|
2480
|
+
;
|
|
2481
|
+
"use strict";
|
|
2482
|
+
var $;
|
|
2483
|
+
(function ($) {
|
|
2484
|
+
function $mol_wire_solid() {
|
|
2485
|
+
let current = $mol_wire_auto();
|
|
2486
|
+
if (current.temp)
|
|
2487
|
+
current = current.host;
|
|
2488
|
+
if (current.reap !== nothing) {
|
|
2489
|
+
current?.sub_on(sub, sub.data.length);
|
|
2714
2490
|
}
|
|
2491
|
+
current.reap = nothing;
|
|
2715
2492
|
}
|
|
2716
|
-
$.$
|
|
2493
|
+
$.$mol_wire_solid = $mol_wire_solid;
|
|
2494
|
+
const nothing = () => { };
|
|
2495
|
+
const sub = new $mol_wire_pub_sub;
|
|
2717
2496
|
})($ || ($ = {}));
|
|
2718
2497
|
|
|
2719
2498
|
;
|
|
2720
2499
|
"use strict";
|
|
2721
2500
|
var $;
|
|
2722
2501
|
(function ($) {
|
|
2723
|
-
function $
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
done,
|
|
2732
|
-
fail,
|
|
2733
|
-
});
|
|
2502
|
+
function $mol_wire_watch() {
|
|
2503
|
+
const atom = $mol_wire_auto();
|
|
2504
|
+
if (atom instanceof $mol_wire_atom) {
|
|
2505
|
+
atom.watch();
|
|
2506
|
+
}
|
|
2507
|
+
else {
|
|
2508
|
+
$mol_fail(new Error('Atom is required for watching'));
|
|
2509
|
+
}
|
|
2734
2510
|
}
|
|
2735
|
-
$.$
|
|
2511
|
+
$.$mol_wire_watch = $mol_wire_watch;
|
|
2736
2512
|
})($ || ($ = {}));
|
|
2737
2513
|
|
|
2738
2514
|
;
|
|
2739
2515
|
"use strict";
|
|
2740
2516
|
var $;
|
|
2741
2517
|
(function ($) {
|
|
2742
|
-
function $
|
|
2743
|
-
|
|
2744
|
-
const
|
|
2745
|
-
return
|
|
2746
|
-
|
|
2518
|
+
function $mol_wire_async(obj) {
|
|
2519
|
+
let fiber;
|
|
2520
|
+
const temp = $mol_wire_task.getter(obj);
|
|
2521
|
+
return new Proxy(obj, {
|
|
2522
|
+
get(obj, field) {
|
|
2523
|
+
const val = obj[field];
|
|
2524
|
+
if (typeof val !== 'function')
|
|
2525
|
+
return val;
|
|
2526
|
+
let fiber;
|
|
2527
|
+
const temp = $mol_wire_task.getter(val);
|
|
2528
|
+
return function $mol_wire_async(...args) {
|
|
2529
|
+
fiber?.destructor();
|
|
2530
|
+
fiber = temp(obj, args);
|
|
2531
|
+
return fiber.async();
|
|
2532
|
+
};
|
|
2533
|
+
},
|
|
2534
|
+
apply(obj, self, args) {
|
|
2535
|
+
fiber?.destructor();
|
|
2536
|
+
fiber = temp(self, args);
|
|
2537
|
+
return fiber.async();
|
|
2538
|
+
},
|
|
2747
2539
|
});
|
|
2748
2540
|
}
|
|
2749
|
-
$.$
|
|
2750
|
-
function $mol_wait_timeout(timeout) {
|
|
2751
|
-
return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
|
|
2752
|
-
}
|
|
2753
|
-
$.$mol_wait_timeout = $mol_wait_timeout;
|
|
2541
|
+
$.$mol_wire_async = $mol_wire_async;
|
|
2754
2542
|
})($ || ($ = {}));
|
|
2755
2543
|
|
|
2756
2544
|
;
|
|
2757
2545
|
"use strict";
|
|
2758
2546
|
var $;
|
|
2759
2547
|
(function ($) {
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
return task;
|
|
2763
|
-
}
|
|
2764
|
-
static track(fiber) {
|
|
2765
|
-
const prev = $mol_wire_probe(() => this.track(fiber));
|
|
2766
|
-
let next;
|
|
2548
|
+
function $mol_wire_race(...tasks) {
|
|
2549
|
+
const results = tasks.map(task => {
|
|
2767
2550
|
try {
|
|
2768
|
-
|
|
2551
|
+
return task();
|
|
2769
2552
|
}
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
if (pub instanceof $mol_wire_fiber) {
|
|
2773
|
-
this.track(pub);
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2553
|
+
catch (error) {
|
|
2554
|
+
return error;
|
|
2776
2555
|
}
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
else if (prev !== undefined) {
|
|
2786
|
-
this.$.$mol_log3_rise({
|
|
2787
|
-
message: '🔥 Next',
|
|
2788
|
-
place: fiber,
|
|
2789
|
-
prev,
|
|
2790
|
-
});
|
|
2791
|
-
}
|
|
2792
|
-
return next;
|
|
2793
|
-
}
|
|
2794
|
-
static active() {
|
|
2795
|
-
try {
|
|
2796
|
-
this.watch()?.();
|
|
2797
|
-
}
|
|
2798
|
-
catch (error) {
|
|
2799
|
-
$mol_fail_log(error);
|
|
2800
|
-
}
|
|
2801
|
-
finally {
|
|
2802
|
-
for (const pub of $mol_wire_auto().pub_list) {
|
|
2803
|
-
if (pub instanceof $mol_wire_fiber) {
|
|
2804
|
-
this.track(pub);
|
|
2805
|
-
}
|
|
2806
|
-
}
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2556
|
+
});
|
|
2557
|
+
const promises = results.filter(res => $mol_promise_like(res));
|
|
2558
|
+
if (promises.length)
|
|
2559
|
+
$mol_fail(Promise.race(promises));
|
|
2560
|
+
const error = results.find(res => res instanceof Error);
|
|
2561
|
+
if (error)
|
|
2562
|
+
$mol_fail(error);
|
|
2563
|
+
return results;
|
|
2809
2564
|
}
|
|
2810
|
-
|
|
2811
|
-
$mol_mem
|
|
2812
|
-
], $mol_wire_log, "watch", null);
|
|
2813
|
-
__decorate([
|
|
2814
|
-
$mol_mem_key
|
|
2815
|
-
], $mol_wire_log, "track", null);
|
|
2816
|
-
__decorate([
|
|
2817
|
-
$mol_mem
|
|
2818
|
-
], $mol_wire_log, "active", null);
|
|
2819
|
-
$.$mol_wire_log = $mol_wire_log;
|
|
2565
|
+
$.$mol_wire_race = $mol_wire_race;
|
|
2820
2566
|
})($ || ($ = {}));
|
|
2821
2567
|
|
|
2822
2568
|
;
|
|
2823
2569
|
"use strict";
|
|
2824
2570
|
var $;
|
|
2825
2571
|
(function ($_1) {
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
$_1.$mol_test_all = [];
|
|
2837
|
-
async function $mol_test_run() {
|
|
2838
|
-
for (var test of $_1.$mol_test_all) {
|
|
2839
|
-
let context = Object.create($$);
|
|
2840
|
-
for (let mock of $_1.$mol_test_mocks)
|
|
2841
|
-
await mock(context);
|
|
2842
|
-
const res = test(context);
|
|
2843
|
-
if ($mol_promise_like(res)) {
|
|
2844
|
-
await new Promise((done, fail) => {
|
|
2845
|
-
res.then(done, fail);
|
|
2846
|
-
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
2847
|
-
});
|
|
2848
|
-
}
|
|
2849
|
-
}
|
|
2850
|
-
$$.$mol_log3_done({
|
|
2851
|
-
place: '$mol_test',
|
|
2852
|
-
message: 'All tests passed',
|
|
2853
|
-
count: $_1.$mol_test_all.length,
|
|
2854
|
-
});
|
|
2855
|
-
}
|
|
2856
|
-
$_1.$mol_test_run = $mol_test_run;
|
|
2857
|
-
let scheduled = false;
|
|
2858
|
-
function $mol_test_schedule() {
|
|
2859
|
-
if (scheduled)
|
|
2860
|
-
return;
|
|
2861
|
-
scheduled = true;
|
|
2862
|
-
setTimeout(async () => {
|
|
2863
|
-
scheduled = false;
|
|
2864
|
-
await $mol_test_run();
|
|
2865
|
-
$$.$mol_test_complete();
|
|
2866
|
-
}, 1000);
|
|
2867
|
-
}
|
|
2868
|
-
$_1.$mol_test_schedule = $mol_test_schedule;
|
|
2869
|
-
$_1.$mol_test_mocks.push(context => {
|
|
2870
|
-
let seed = 0;
|
|
2871
|
-
context.Math = Object.create(Math);
|
|
2872
|
-
context.Math.random = () => Math.sin(seed++);
|
|
2873
|
-
const forbidden = ['XMLHttpRequest', 'fetch'];
|
|
2874
|
-
for (let api of forbidden) {
|
|
2875
|
-
context[api] = new Proxy(function () { }, {
|
|
2876
|
-
get() {
|
|
2877
|
-
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
2878
|
-
},
|
|
2879
|
-
apply() {
|
|
2880
|
-
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
2881
|
-
},
|
|
2572
|
+
let $$;
|
|
2573
|
+
(function ($$) {
|
|
2574
|
+
let $;
|
|
2575
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
2576
|
+
$_1.$mol_object_field = Symbol('$mol_object_field');
|
|
2577
|
+
class $mol_object extends $mol_object2 {
|
|
2578
|
+
static make(config) {
|
|
2579
|
+
return super.create(obj => {
|
|
2580
|
+
for (let key in config)
|
|
2581
|
+
obj[key] = config[key];
|
|
2882
2582
|
});
|
|
2883
2583
|
}
|
|
2884
|
-
}
|
|
2885
|
-
$
|
|
2886
|
-
'mocked Math.random'($) {
|
|
2887
|
-
console.assert($.Math.random() === 0);
|
|
2888
|
-
console.assert($.Math.random() === Math.sin(1));
|
|
2889
|
-
},
|
|
2890
|
-
'forbidden XMLHttpRequest'($) {
|
|
2891
|
-
try {
|
|
2892
|
-
console.assert(void new $.XMLHttpRequest);
|
|
2893
|
-
}
|
|
2894
|
-
catch (error) {
|
|
2895
|
-
console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
|
|
2896
|
-
}
|
|
2897
|
-
},
|
|
2898
|
-
'forbidden fetch'($) {
|
|
2899
|
-
try {
|
|
2900
|
-
console.assert(void $.fetch(''));
|
|
2901
|
-
}
|
|
2902
|
-
catch (error) {
|
|
2903
|
-
console.assert(error.message === 'fetch is forbidden in tests');
|
|
2904
|
-
}
|
|
2905
|
-
},
|
|
2906
|
-
});
|
|
2584
|
+
}
|
|
2585
|
+
$_1.$mol_object = $mol_object;
|
|
2907
2586
|
})($ || ($ = {}));
|
|
2908
2587
|
|
|
2909
2588
|
;
|
|
2910
2589
|
"use strict";
|
|
2911
2590
|
var $;
|
|
2912
2591
|
(function ($) {
|
|
2913
|
-
|
|
2914
|
-
|
|
2592
|
+
class $mol_state_time extends $mol_object {
|
|
2593
|
+
static task(precision, reset) {
|
|
2594
|
+
if (precision) {
|
|
2595
|
+
return new $mol_after_timeout(precision, () => this.task(precision, null));
|
|
2596
|
+
}
|
|
2597
|
+
else {
|
|
2598
|
+
return new $mol_after_frame(() => this.task(precision, null));
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
static now(precision) {
|
|
2602
|
+
this.task(precision);
|
|
2603
|
+
return Date.now();
|
|
2604
|
+
}
|
|
2915
2605
|
}
|
|
2916
|
-
|
|
2606
|
+
__decorate([
|
|
2607
|
+
$mol_mem_key
|
|
2608
|
+
], $mol_state_time, "task", null);
|
|
2609
|
+
__decorate([
|
|
2610
|
+
$mol_mem_key
|
|
2611
|
+
], $mol_state_time, "now", null);
|
|
2612
|
+
$.$mol_state_time = $mol_state_time;
|
|
2917
2613
|
})($ || ($ = {}));
|
|
2918
2614
|
|
|
2919
2615
|
;
|
|
2920
2616
|
"use strict";
|
|
2921
2617
|
var $;
|
|
2922
|
-
(function ($
|
|
2923
|
-
$
|
|
2618
|
+
(function ($) {
|
|
2619
|
+
function $mol_wire_easing(next) {
|
|
2620
|
+
const atom = $mol_wire_auto();
|
|
2621
|
+
if (!(atom instanceof $mol_wire_atom))
|
|
2622
|
+
$mol_fail(new Error('Allowed only inside atom'));
|
|
2623
|
+
const prev = atom.result() ?? next;
|
|
2624
|
+
if (typeof prev !== 'number')
|
|
2625
|
+
return next;
|
|
2626
|
+
const current = (prev * 2 + next) / 3;
|
|
2627
|
+
const diff = Math.abs(current - next);
|
|
2628
|
+
if (diff < 1)
|
|
2629
|
+
return next;
|
|
2630
|
+
$mol_state_time.now(0);
|
|
2631
|
+
return current;
|
|
2632
|
+
}
|
|
2633
|
+
$.$mol_wire_easing = $mol_wire_easing;
|
|
2924
2634
|
})($ || ($ = {}));
|
|
2925
2635
|
|
|
2926
2636
|
;
|
|
2927
2637
|
"use strict";
|
|
2638
|
+
var $;
|
|
2639
|
+
(function ($) {
|
|
2640
|
+
function $mol_wire_patch(obj) {
|
|
2641
|
+
for (const field of Reflect.ownKeys(obj)) {
|
|
2642
|
+
const descr = Reflect.getOwnPropertyDescriptor(obj, field);
|
|
2643
|
+
if (!descr.configurable)
|
|
2644
|
+
continue;
|
|
2645
|
+
if (!descr.get)
|
|
2646
|
+
continue;
|
|
2647
|
+
const get = descr.get ?? (() => descr.value);
|
|
2648
|
+
const set = descr.set ?? (next => descr.value = next);
|
|
2649
|
+
Reflect.defineProperty(obj, field, {
|
|
2650
|
+
configurable: true,
|
|
2651
|
+
enumerable: descr.enumerable,
|
|
2652
|
+
get() {
|
|
2653
|
+
const atom = $mol_wire_atom.solo(obj, get);
|
|
2654
|
+
atom.watch();
|
|
2655
|
+
return atom.sync();
|
|
2656
|
+
},
|
|
2657
|
+
set(next) {
|
|
2658
|
+
const atom = $mol_wire_atom.solo(obj, get);
|
|
2659
|
+
set.call(this, next);
|
|
2660
|
+
atom.refresh();
|
|
2661
|
+
},
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
$.$mol_wire_patch = $mol_wire_patch;
|
|
2666
|
+
})($ || ($ = {}));
|
|
2928
2667
|
|
|
2929
2668
|
;
|
|
2930
2669
|
"use strict";
|
|
2931
2670
|
|
|
2932
2671
|
;
|
|
2933
2672
|
"use strict";
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2673
|
+
var $;
|
|
2674
|
+
(function ($) {
|
|
2675
|
+
function $mol_wire_let(host) {
|
|
2676
|
+
for (const field of Object.keys(host)) {
|
|
2677
|
+
host[field] = new $mol_wire_atom(field, host[field], host).channel();
|
|
2678
|
+
}
|
|
2679
|
+
return host;
|
|
2680
|
+
}
|
|
2681
|
+
$.$mol_wire_let = $mol_wire_let;
|
|
2682
|
+
})($ || ($ = {}));
|
|
2937
2683
|
|
|
2938
2684
|
;
|
|
2939
2685
|
"use strict";
|
|
2940
2686
|
var $;
|
|
2941
2687
|
(function ($) {
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
$.$mol_assert_ok = $mol_assert_ok;
|
|
2948
|
-
function $mol_assert_not(value) {
|
|
2949
|
-
if (!value)
|
|
2950
|
-
return;
|
|
2951
|
-
$mol_fail(new Error(`${value} ≠ false`));
|
|
2952
|
-
}
|
|
2953
|
-
$.$mol_assert_not = $mol_assert_not;
|
|
2954
|
-
function $mol_assert_fail(handler, ErrorRight) {
|
|
2955
|
-
const fail = $.$mol_fail;
|
|
2956
|
-
try {
|
|
2957
|
-
$.$mol_fail = $.$mol_fail_hidden;
|
|
2958
|
-
handler();
|
|
2959
|
-
}
|
|
2960
|
-
catch (error) {
|
|
2961
|
-
$.$mol_fail = fail;
|
|
2962
|
-
if (typeof ErrorRight === 'string') {
|
|
2963
|
-
$mol_assert_equal(error.message, ErrorRight);
|
|
2964
|
-
}
|
|
2965
|
-
else {
|
|
2966
|
-
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
2967
|
-
}
|
|
2968
|
-
return error;
|
|
2688
|
+
class $mol_wire_set extends Set {
|
|
2689
|
+
pub = new $mol_wire_pub;
|
|
2690
|
+
has(value) {
|
|
2691
|
+
this.pub.promote();
|
|
2692
|
+
return super.has(value);
|
|
2969
2693
|
}
|
|
2970
|
-
|
|
2694
|
+
entries() {
|
|
2695
|
+
this.pub.promote();
|
|
2696
|
+
return super.entries();
|
|
2697
|
+
}
|
|
2698
|
+
keys() {
|
|
2699
|
+
this.pub.promote();
|
|
2700
|
+
return super.keys();
|
|
2701
|
+
}
|
|
2702
|
+
values() {
|
|
2703
|
+
this.pub.promote();
|
|
2704
|
+
return super.values();
|
|
2705
|
+
}
|
|
2706
|
+
forEach(task, self) {
|
|
2707
|
+
this.pub.promote();
|
|
2708
|
+
super.forEach(task, self);
|
|
2709
|
+
}
|
|
2710
|
+
[Symbol.iterator]() {
|
|
2711
|
+
this.pub.promote();
|
|
2712
|
+
return super[Symbol.iterator]();
|
|
2713
|
+
}
|
|
2714
|
+
get size() {
|
|
2715
|
+
this.pub.promote();
|
|
2716
|
+
return super.size;
|
|
2717
|
+
}
|
|
2718
|
+
add(value) {
|
|
2719
|
+
if (super.has(value))
|
|
2720
|
+
return this;
|
|
2721
|
+
super.add(value);
|
|
2722
|
+
this.pub.emit();
|
|
2723
|
+
return this;
|
|
2724
|
+
}
|
|
2725
|
+
delete(value) {
|
|
2726
|
+
const res = super.delete(value);
|
|
2727
|
+
if (res)
|
|
2728
|
+
this.pub.emit();
|
|
2729
|
+
return res;
|
|
2730
|
+
}
|
|
2731
|
+
clear() {
|
|
2732
|
+
if (!super.size)
|
|
2733
|
+
return;
|
|
2734
|
+
super.clear();
|
|
2735
|
+
this.pub.emit();
|
|
2736
|
+
}
|
|
2737
|
+
item(val, next) {
|
|
2738
|
+
if (next === undefined)
|
|
2739
|
+
return this.has(val);
|
|
2740
|
+
if (next)
|
|
2741
|
+
this.add(val);
|
|
2742
|
+
else
|
|
2743
|
+
this.delete(val);
|
|
2744
|
+
return next;
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
$.$mol_wire_set = $mol_wire_set;
|
|
2748
|
+
})($ || ($ = {}));
|
|
2749
|
+
|
|
2750
|
+
;
|
|
2751
|
+
"use strict";
|
|
2752
|
+
var $;
|
|
2753
|
+
(function ($) {
|
|
2754
|
+
class $mol_wire_dict extends Map {
|
|
2755
|
+
pub = new $mol_wire_pub;
|
|
2756
|
+
has(key) {
|
|
2757
|
+
this.pub.promote();
|
|
2758
|
+
return super.has(key);
|
|
2759
|
+
}
|
|
2760
|
+
get(key) {
|
|
2761
|
+
this.pub.promote();
|
|
2762
|
+
return super.get(key);
|
|
2763
|
+
}
|
|
2764
|
+
entries() {
|
|
2765
|
+
this.pub.promote();
|
|
2766
|
+
return super.entries();
|
|
2767
|
+
}
|
|
2768
|
+
keys() {
|
|
2769
|
+
this.pub.promote();
|
|
2770
|
+
return super.keys();
|
|
2771
|
+
}
|
|
2772
|
+
values() {
|
|
2773
|
+
this.pub.promote();
|
|
2774
|
+
return super.values();
|
|
2775
|
+
}
|
|
2776
|
+
forEach(task, self) {
|
|
2777
|
+
this.pub.promote();
|
|
2778
|
+
super.forEach(task, self);
|
|
2779
|
+
}
|
|
2780
|
+
[Symbol.iterator]() {
|
|
2781
|
+
this.pub.promote();
|
|
2782
|
+
return super[Symbol.iterator]();
|
|
2783
|
+
}
|
|
2784
|
+
get size() {
|
|
2785
|
+
this.pub.promote();
|
|
2786
|
+
return super.size;
|
|
2787
|
+
}
|
|
2788
|
+
set(key, value) {
|
|
2789
|
+
if (super.get(key) === value)
|
|
2790
|
+
return this;
|
|
2791
|
+
super.set(key, value);
|
|
2792
|
+
this.pub?.emit();
|
|
2793
|
+
return this;
|
|
2794
|
+
}
|
|
2795
|
+
delete(key) {
|
|
2796
|
+
const res = super.delete(key);
|
|
2797
|
+
if (res)
|
|
2798
|
+
this.pub.emit();
|
|
2799
|
+
return res;
|
|
2800
|
+
}
|
|
2801
|
+
clear() {
|
|
2802
|
+
if (!super.size)
|
|
2803
|
+
return;
|
|
2804
|
+
super.clear();
|
|
2805
|
+
this.pub.emit();
|
|
2806
|
+
}
|
|
2807
|
+
item(key, next) {
|
|
2808
|
+
if (next === undefined)
|
|
2809
|
+
return this.get(key) ?? null;
|
|
2810
|
+
if (next === null)
|
|
2811
|
+
this.delete(key);
|
|
2812
|
+
else
|
|
2813
|
+
this.set(key, next);
|
|
2814
|
+
return next;
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
$.$mol_wire_dict = $mol_wire_dict;
|
|
2818
|
+
})($ || ($ = {}));
|
|
2819
|
+
|
|
2820
|
+
;
|
|
2821
|
+
"use strict";
|
|
2822
|
+
var $;
|
|
2823
|
+
(function ($) {
|
|
2824
|
+
function $mol_promise() {
|
|
2825
|
+
let done;
|
|
2826
|
+
let fail;
|
|
2827
|
+
const promise = new Promise((d, f) => {
|
|
2828
|
+
done = d;
|
|
2829
|
+
fail = f;
|
|
2830
|
+
});
|
|
2831
|
+
return Object.assign(promise, {
|
|
2832
|
+
done,
|
|
2833
|
+
fail,
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
$.$mol_promise = $mol_promise;
|
|
2837
|
+
})($ || ($ = {}));
|
|
2838
|
+
|
|
2839
|
+
;
|
|
2840
|
+
"use strict";
|
|
2841
|
+
var $;
|
|
2842
|
+
(function ($) {
|
|
2843
|
+
function $mol_wait_timeout_async(timeout) {
|
|
2844
|
+
const promise = $mol_promise();
|
|
2845
|
+
const task = new this.$mol_after_timeout(timeout, () => promise.done());
|
|
2846
|
+
return Object.assign(promise, {
|
|
2847
|
+
destructor: () => task.destructor()
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
$.$mol_wait_timeout_async = $mol_wait_timeout_async;
|
|
2851
|
+
function $mol_wait_timeout(timeout) {
|
|
2852
|
+
return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
|
|
2853
|
+
}
|
|
2854
|
+
$.$mol_wait_timeout = $mol_wait_timeout;
|
|
2855
|
+
})($ || ($ = {}));
|
|
2856
|
+
|
|
2857
|
+
;
|
|
2858
|
+
"use strict";
|
|
2859
|
+
var $;
|
|
2860
|
+
(function ($) {
|
|
2861
|
+
class $mol_wire_log extends $mol_object2 {
|
|
2862
|
+
static watch(task) {
|
|
2863
|
+
return task;
|
|
2864
|
+
}
|
|
2865
|
+
static track(fiber) {
|
|
2866
|
+
const prev = $mol_wire_probe(() => this.track(fiber));
|
|
2867
|
+
let next;
|
|
2868
|
+
try {
|
|
2869
|
+
next = fiber.sync();
|
|
2870
|
+
}
|
|
2871
|
+
finally {
|
|
2872
|
+
for (const pub of fiber.pub_list) {
|
|
2873
|
+
if (pub instanceof $mol_wire_fiber) {
|
|
2874
|
+
this.track(pub);
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
if (fiber.host === this)
|
|
2879
|
+
return next;
|
|
2880
|
+
if ($mol_compare_deep(prev, next)) {
|
|
2881
|
+
this.$.$mol_log3_rise({
|
|
2882
|
+
message: '💧 Same',
|
|
2883
|
+
place: fiber,
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2886
|
+
else if (prev !== undefined) {
|
|
2887
|
+
this.$.$mol_log3_rise({
|
|
2888
|
+
message: '🔥 Next',
|
|
2889
|
+
place: fiber,
|
|
2890
|
+
prev,
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
2893
|
+
return next;
|
|
2894
|
+
}
|
|
2895
|
+
static active() {
|
|
2896
|
+
try {
|
|
2897
|
+
this.watch()?.();
|
|
2898
|
+
}
|
|
2899
|
+
catch (error) {
|
|
2900
|
+
$mol_fail_log(error);
|
|
2901
|
+
}
|
|
2902
|
+
finally {
|
|
2903
|
+
for (const pub of $mol_wire_auto().pub_list) {
|
|
2904
|
+
if (pub instanceof $mol_wire_fiber) {
|
|
2905
|
+
this.track(pub);
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
__decorate([
|
|
2912
|
+
$mol_mem
|
|
2913
|
+
], $mol_wire_log, "watch", null);
|
|
2914
|
+
__decorate([
|
|
2915
|
+
$mol_mem_key
|
|
2916
|
+
], $mol_wire_log, "track", null);
|
|
2917
|
+
__decorate([
|
|
2918
|
+
$mol_mem
|
|
2919
|
+
], $mol_wire_log, "active", null);
|
|
2920
|
+
$.$mol_wire_log = $mol_wire_log;
|
|
2921
|
+
})($ || ($ = {}));
|
|
2922
|
+
|
|
2923
|
+
;
|
|
2924
|
+
"use strict";
|
|
2925
|
+
var $;
|
|
2926
|
+
(function ($_1) {
|
|
2927
|
+
function $mol_test(set) {
|
|
2928
|
+
for (let name in set) {
|
|
2929
|
+
const code = set[name];
|
|
2930
|
+
const test = (typeof code === 'string') ? new Function('', code) : code;
|
|
2931
|
+
$_1.$mol_test_all.push(test);
|
|
2932
|
+
}
|
|
2933
|
+
$mol_test_schedule();
|
|
2934
|
+
}
|
|
2935
|
+
$_1.$mol_test = $mol_test;
|
|
2936
|
+
$_1.$mol_test_mocks = [];
|
|
2937
|
+
$_1.$mol_test_all = [];
|
|
2938
|
+
async function $mol_test_run() {
|
|
2939
|
+
for (var test of $_1.$mol_test_all) {
|
|
2940
|
+
let context = Object.create($$);
|
|
2941
|
+
for (let mock of $_1.$mol_test_mocks)
|
|
2942
|
+
await mock(context);
|
|
2943
|
+
const res = test(context);
|
|
2944
|
+
if ($mol_promise_like(res)) {
|
|
2945
|
+
await new Promise((done, fail) => {
|
|
2946
|
+
res.then(done, fail);
|
|
2947
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
$$.$mol_log3_done({
|
|
2952
|
+
place: '$mol_test',
|
|
2953
|
+
message: 'All tests passed',
|
|
2954
|
+
count: $_1.$mol_test_all.length,
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
$_1.$mol_test_run = $mol_test_run;
|
|
2958
|
+
let scheduled = false;
|
|
2959
|
+
function $mol_test_schedule() {
|
|
2960
|
+
if (scheduled)
|
|
2961
|
+
return;
|
|
2962
|
+
scheduled = true;
|
|
2963
|
+
setTimeout(async () => {
|
|
2964
|
+
scheduled = false;
|
|
2965
|
+
await $mol_test_run();
|
|
2966
|
+
$$.$mol_test_complete();
|
|
2967
|
+
}, 1000);
|
|
2968
|
+
}
|
|
2969
|
+
$_1.$mol_test_schedule = $mol_test_schedule;
|
|
2970
|
+
$_1.$mol_test_mocks.push(context => {
|
|
2971
|
+
let seed = 0;
|
|
2972
|
+
context.Math = Object.create(Math);
|
|
2973
|
+
context.Math.random = () => Math.sin(seed++);
|
|
2974
|
+
const forbidden = ['XMLHttpRequest', 'fetch'];
|
|
2975
|
+
for (let api of forbidden) {
|
|
2976
|
+
context[api] = new Proxy(function () { }, {
|
|
2977
|
+
get() {
|
|
2978
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
2979
|
+
},
|
|
2980
|
+
apply() {
|
|
2981
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
2982
|
+
},
|
|
2983
|
+
});
|
|
2984
|
+
}
|
|
2985
|
+
});
|
|
2986
|
+
$mol_test({
|
|
2987
|
+
'mocked Math.random'($) {
|
|
2988
|
+
console.assert($.Math.random() === 0);
|
|
2989
|
+
console.assert($.Math.random() === Math.sin(1));
|
|
2990
|
+
},
|
|
2991
|
+
'forbidden XMLHttpRequest'($) {
|
|
2992
|
+
try {
|
|
2993
|
+
console.assert(void new $.XMLHttpRequest);
|
|
2994
|
+
}
|
|
2995
|
+
catch (error) {
|
|
2996
|
+
console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
|
|
2997
|
+
}
|
|
2998
|
+
},
|
|
2999
|
+
'forbidden fetch'($) {
|
|
3000
|
+
try {
|
|
3001
|
+
console.assert(void $.fetch(''));
|
|
3002
|
+
}
|
|
3003
|
+
catch (error) {
|
|
3004
|
+
console.assert(error.message === 'fetch is forbidden in tests');
|
|
3005
|
+
}
|
|
3006
|
+
},
|
|
3007
|
+
});
|
|
3008
|
+
})($ || ($ = {}));
|
|
3009
|
+
|
|
3010
|
+
;
|
|
3011
|
+
"use strict";
|
|
3012
|
+
var $;
|
|
3013
|
+
(function ($) {
|
|
3014
|
+
function $mol_test_complete() {
|
|
3015
|
+
process.exit(0);
|
|
3016
|
+
}
|
|
3017
|
+
$.$mol_test_complete = $mol_test_complete;
|
|
3018
|
+
})($ || ($ = {}));
|
|
3019
|
+
|
|
3020
|
+
;
|
|
3021
|
+
"use strict";
|
|
3022
|
+
var $;
|
|
3023
|
+
(function ($_1) {
|
|
3024
|
+
$mol_test_mocks.push($ => $.$mol_fail_log = () => false);
|
|
3025
|
+
})($ || ($ = {}));
|
|
3026
|
+
|
|
3027
|
+
;
|
|
3028
|
+
"use strict";
|
|
3029
|
+
|
|
3030
|
+
;
|
|
3031
|
+
"use strict";
|
|
3032
|
+
|
|
3033
|
+
;
|
|
3034
|
+
"use strict";
|
|
3035
|
+
|
|
3036
|
+
;
|
|
3037
|
+
"use strict";
|
|
3038
|
+
|
|
3039
|
+
;
|
|
3040
|
+
"use strict";
|
|
3041
|
+
var $;
|
|
3042
|
+
(function ($) {
|
|
3043
|
+
function $mol_assert_ok(value) {
|
|
3044
|
+
if (value)
|
|
3045
|
+
return;
|
|
3046
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
3047
|
+
}
|
|
3048
|
+
$.$mol_assert_ok = $mol_assert_ok;
|
|
3049
|
+
function $mol_assert_not(value) {
|
|
3050
|
+
if (!value)
|
|
3051
|
+
return;
|
|
3052
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
3053
|
+
}
|
|
3054
|
+
$.$mol_assert_not = $mol_assert_not;
|
|
3055
|
+
function $mol_assert_fail(handler, ErrorRight) {
|
|
3056
|
+
const fail = $.$mol_fail;
|
|
3057
|
+
try {
|
|
3058
|
+
$.$mol_fail = $.$mol_fail_hidden;
|
|
3059
|
+
handler();
|
|
3060
|
+
}
|
|
3061
|
+
catch (error) {
|
|
3062
|
+
$.$mol_fail = fail;
|
|
3063
|
+
if (typeof ErrorRight === 'string') {
|
|
3064
|
+
$mol_assert_equal(error.message, ErrorRight);
|
|
3065
|
+
}
|
|
3066
|
+
else {
|
|
3067
|
+
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
3068
|
+
}
|
|
3069
|
+
return error;
|
|
3070
|
+
}
|
|
3071
|
+
finally {
|
|
2971
3072
|
$.$mol_fail = fail;
|
|
2972
3073
|
}
|
|
2973
3074
|
$mol_fail(new Error('Not failed'));
|
|
@@ -3017,43 +3118,415 @@ var $;
|
|
|
3017
3118
|
console.error(error);
|
|
3018
3119
|
return val;
|
|
3019
3120
|
}
|
|
3020
|
-
};
|
|
3121
|
+
};
|
|
3122
|
+
})($ || ($ = {}));
|
|
3123
|
+
|
|
3124
|
+
;
|
|
3125
|
+
"use strict";
|
|
3126
|
+
var $;
|
|
3127
|
+
(function ($) {
|
|
3128
|
+
$mol_test({
|
|
3129
|
+
'must be false'() {
|
|
3130
|
+
$mol_assert_not(0);
|
|
3131
|
+
},
|
|
3132
|
+
'must be true'() {
|
|
3133
|
+
$mol_assert_ok(1);
|
|
3134
|
+
},
|
|
3135
|
+
'two must be equal'() {
|
|
3136
|
+
$mol_assert_equal(2, 2);
|
|
3137
|
+
},
|
|
3138
|
+
'three must be equal'() {
|
|
3139
|
+
$mol_assert_equal(2, 2, 2);
|
|
3140
|
+
},
|
|
3141
|
+
'two must be unique'() {
|
|
3142
|
+
$mol_assert_unique([2], [3]);
|
|
3143
|
+
},
|
|
3144
|
+
'three must be unique'() {
|
|
3145
|
+
$mol_assert_unique([1], [2], [3]);
|
|
3146
|
+
},
|
|
3147
|
+
'two must be alike'() {
|
|
3148
|
+
$mol_assert_like([3], [3]);
|
|
3149
|
+
},
|
|
3150
|
+
'three must be alike'() {
|
|
3151
|
+
$mol_assert_like([3], [3], [3]);
|
|
3152
|
+
},
|
|
3153
|
+
'two object must be alike'() {
|
|
3154
|
+
$mol_assert_like({ a: 1 }, { a: 1 });
|
|
3155
|
+
},
|
|
3156
|
+
'three object must be alike'() {
|
|
3157
|
+
$mol_assert_like({ a: 1 }, { a: 1 }, { a: 1 });
|
|
3158
|
+
},
|
|
3159
|
+
});
|
|
3160
|
+
})($ || ($ = {}));
|
|
3161
|
+
|
|
3162
|
+
;
|
|
3163
|
+
"use strict";
|
|
3164
|
+
var $;
|
|
3165
|
+
(function ($_1) {
|
|
3166
|
+
$mol_test_mocks.push($ => {
|
|
3167
|
+
$.$mol_log3_come = () => { };
|
|
3168
|
+
$.$mol_log3_done = () => { };
|
|
3169
|
+
$.$mol_log3_fail = () => { };
|
|
3170
|
+
$.$mol_log3_warn = () => { };
|
|
3171
|
+
$.$mol_log3_rise = () => { };
|
|
3172
|
+
$.$mol_log3_area = () => () => { };
|
|
3173
|
+
});
|
|
3174
|
+
})($ || ($ = {}));
|
|
3175
|
+
|
|
3176
|
+
;
|
|
3177
|
+
"use strict";
|
|
3178
|
+
|
|
3179
|
+
;
|
|
3180
|
+
"use strict";
|
|
3181
|
+
|
|
3182
|
+
;
|
|
3183
|
+
"use strict";
|
|
3184
|
+
|
|
3185
|
+
;
|
|
3186
|
+
"use strict";
|
|
3187
|
+
var $;
|
|
3188
|
+
(function ($) {
|
|
3189
|
+
$mol_test({
|
|
3190
|
+
'get'() {
|
|
3191
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
3192
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
3193
|
+
},
|
|
3194
|
+
'has'() {
|
|
3195
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
3196
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
3197
|
+
},
|
|
3198
|
+
'set'() {
|
|
3199
|
+
const target = { foo: 777 };
|
|
3200
|
+
const proxy = $mol_delegate({}, () => target);
|
|
3201
|
+
proxy.foo = 123;
|
|
3202
|
+
$mol_assert_equal(target.foo, 123);
|
|
3203
|
+
},
|
|
3204
|
+
'getOwnPropertyDescriptor'() {
|
|
3205
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
3206
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
3207
|
+
value: 777,
|
|
3208
|
+
writable: true,
|
|
3209
|
+
enumerable: true,
|
|
3210
|
+
configurable: true,
|
|
3211
|
+
});
|
|
3212
|
+
},
|
|
3213
|
+
'ownKeys'() {
|
|
3214
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
3215
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
3216
|
+
},
|
|
3217
|
+
'getPrototypeOf'() {
|
|
3218
|
+
class Foo {
|
|
3219
|
+
}
|
|
3220
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
3221
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
3222
|
+
},
|
|
3223
|
+
'setPrototypeOf'() {
|
|
3224
|
+
class Foo {
|
|
3225
|
+
}
|
|
3226
|
+
const target = {};
|
|
3227
|
+
const proxy = $mol_delegate({}, () => target);
|
|
3228
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
3229
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
3230
|
+
},
|
|
3231
|
+
'instanceof'() {
|
|
3232
|
+
class Foo {
|
|
3233
|
+
}
|
|
3234
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
3235
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
3236
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
3237
|
+
},
|
|
3238
|
+
'autobind'() {
|
|
3239
|
+
class Foo {
|
|
3240
|
+
}
|
|
3241
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
3242
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
3243
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
3244
|
+
},
|
|
3245
|
+
});
|
|
3246
|
+
})($ || ($ = {}));
|
|
3247
|
+
|
|
3248
|
+
;
|
|
3249
|
+
"use strict";
|
|
3250
|
+
var $;
|
|
3251
|
+
(function ($_1) {
|
|
3252
|
+
$mol_test({
|
|
3253
|
+
'span for same uri'($) {
|
|
3254
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
3255
|
+
const child = span.span(4, 5, 8);
|
|
3256
|
+
$mol_assert_equal(child.uri, 'test.ts');
|
|
3257
|
+
$mol_assert_equal(child.row, 4);
|
|
3258
|
+
$mol_assert_equal(child.col, 5);
|
|
3259
|
+
$mol_assert_equal(child.length, 8);
|
|
3260
|
+
},
|
|
3261
|
+
'span after of given position'($) {
|
|
3262
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
3263
|
+
const child = span.after(11);
|
|
3264
|
+
$mol_assert_equal(child.uri, 'test.ts');
|
|
3265
|
+
$mol_assert_equal(child.row, 1);
|
|
3266
|
+
$mol_assert_equal(child.col, 7);
|
|
3267
|
+
$mol_assert_equal(child.length, 11);
|
|
3268
|
+
},
|
|
3269
|
+
'slice span - regular'($) {
|
|
3270
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
3271
|
+
const child = span.slice(1, 4);
|
|
3272
|
+
$mol_assert_equal(child.row, 1);
|
|
3273
|
+
$mol_assert_equal(child.col, 4);
|
|
3274
|
+
$mol_assert_equal(child.length, 3);
|
|
3275
|
+
const child2 = span.slice(2, 2);
|
|
3276
|
+
$mol_assert_equal(child2.col, 5);
|
|
3277
|
+
$mol_assert_equal(child2.length, 0);
|
|
3278
|
+
},
|
|
3279
|
+
'slice span - negative'($) {
|
|
3280
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
3281
|
+
const child = span.slice(-3, -1);
|
|
3282
|
+
$mol_assert_equal(child.row, 1);
|
|
3283
|
+
$mol_assert_equal(child.col, 5);
|
|
3284
|
+
$mol_assert_equal(child.length, 2);
|
|
3285
|
+
},
|
|
3286
|
+
'slice span - out of range'($) {
|
|
3287
|
+
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
3288
|
+
$mol_assert_fail(() => span.slice(-1, 3), `End value '3' can't be less than begin value (test.ts#1:3/5)`);
|
|
3289
|
+
$mol_assert_fail(() => span.slice(1, 6), `End value '6' out of range (test.ts#1:3/5)`);
|
|
3290
|
+
$mol_assert_fail(() => span.slice(1, 10), `End value '10' out of range (test.ts#1:3/5)`);
|
|
3291
|
+
},
|
|
3292
|
+
'error handling'($) {
|
|
3293
|
+
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
3294
|
+
const error = span.error('Some error');
|
|
3295
|
+
$mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
|
|
3296
|
+
}
|
|
3297
|
+
});
|
|
3021
3298
|
})($ || ($ = {}));
|
|
3022
3299
|
|
|
3023
3300
|
;
|
|
3024
3301
|
"use strict";
|
|
3025
3302
|
var $;
|
|
3026
|
-
(function ($) {
|
|
3303
|
+
(function ($_1) {
|
|
3027
3304
|
$mol_test({
|
|
3028
|
-
'
|
|
3029
|
-
$
|
|
3305
|
+
'inserting'($) {
|
|
3306
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
3307
|
+
.insert($mol_tree2.struct('x'), 'a', 'b', 'c')
|
|
3308
|
+
.toString(), 'a b x\n');
|
|
3309
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
3310
|
+
.insert($mol_tree2.struct('x'), 'a', 'b', 'c', 'd')
|
|
3311
|
+
.toString(), 'a b c x\n');
|
|
3312
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
3313
|
+
.insert($mol_tree2.struct('x'), 0, 0, 0)
|
|
3314
|
+
.toString(), 'a b x\n');
|
|
3315
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
3316
|
+
.insert($mol_tree2.struct('x'), 0, 0, 0, 0)
|
|
3317
|
+
.toString(), 'a b \\\n\tx\n');
|
|
3318
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
3319
|
+
.insert($mol_tree2.struct('x'), null, null, null)
|
|
3320
|
+
.toString(), 'a b x\n');
|
|
3321
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
3322
|
+
.insert($mol_tree2.struct('x'), null, null, null, null)
|
|
3323
|
+
.toString(), 'a b \\\n\tx\n');
|
|
3030
3324
|
},
|
|
3031
|
-
'
|
|
3032
|
-
$
|
|
3325
|
+
'deleting'($) {
|
|
3326
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
3327
|
+
.insert(null, 'a', 'b', 'c')
|
|
3328
|
+
.toString(), 'a b\n');
|
|
3329
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
3330
|
+
.insert(null, 0, 0, 0)
|
|
3331
|
+
.toString(), 'a b\n');
|
|
3033
3332
|
},
|
|
3034
|
-
'
|
|
3035
|
-
|
|
3333
|
+
'hack'($) {
|
|
3334
|
+
const res = $.$mol_tree2_from_string(`foo bar xxx\n`)
|
|
3335
|
+
.hack({
|
|
3336
|
+
'bar': (input, belt) => [input.struct('777', input.hack(belt))],
|
|
3337
|
+
});
|
|
3338
|
+
$mol_assert_equal(res.toString(), 'foo 777 xxx\n');
|
|
3036
3339
|
},
|
|
3037
|
-
|
|
3038
|
-
|
|
3340
|
+
});
|
|
3341
|
+
})($ || ($ = {}));
|
|
3342
|
+
|
|
3343
|
+
;
|
|
3344
|
+
"use strict";
|
|
3345
|
+
var $;
|
|
3346
|
+
(function ($_1) {
|
|
3347
|
+
$mol_test({
|
|
3348
|
+
'tree parsing'($) {
|
|
3349
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
|
|
3350
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
|
|
3351
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
|
|
3352
|
+
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
|
|
3353
|
+
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
|
|
3354
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
|
|
3355
|
+
$mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
|
|
3356
|
+
$mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
3039
3357
|
},
|
|
3040
|
-
'
|
|
3041
|
-
|
|
3358
|
+
'Too many tabs'($) {
|
|
3359
|
+
const tree = `
|
|
3360
|
+
foo
|
|
3361
|
+
bar
|
|
3362
|
+
`;
|
|
3363
|
+
$mol_assert_fail(() => {
|
|
3364
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
3365
|
+
}, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
|
|
3042
3366
|
},
|
|
3043
|
-
'
|
|
3044
|
-
|
|
3367
|
+
'Too few tabs'($) {
|
|
3368
|
+
const tree = `
|
|
3369
|
+
foo
|
|
3370
|
+
bar
|
|
3371
|
+
`;
|
|
3372
|
+
$mol_assert_fail(() => {
|
|
3373
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
3374
|
+
}, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
|
|
3045
3375
|
},
|
|
3046
|
-
'
|
|
3047
|
-
|
|
3376
|
+
'Wrong nodes separator at start'($) {
|
|
3377
|
+
const tree = `foo\n \tbar\n`;
|
|
3378
|
+
$mol_assert_fail(() => {
|
|
3379
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
3380
|
+
}, 'Wrong nodes separator\ntest#2:1/2\n!!\n \tbar');
|
|
3048
3381
|
},
|
|
3049
|
-
'
|
|
3050
|
-
|
|
3382
|
+
'Wrong nodes separator in the middle'($) {
|
|
3383
|
+
const tree = `foo bar\n`;
|
|
3384
|
+
$mol_assert_fail(() => {
|
|
3385
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
3386
|
+
}, 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar');
|
|
3051
3387
|
},
|
|
3052
|
-
'
|
|
3053
|
-
|
|
3388
|
+
'Unexpected EOF, LF required'($) {
|
|
3389
|
+
const tree = ` foo`;
|
|
3390
|
+
$mol_assert_fail(() => {
|
|
3391
|
+
$.$mol_tree2_from_string(tree, 'test');
|
|
3392
|
+
}, 'Unexpected EOF, LF required\ntest#1:5/1\n !\n foo');
|
|
3393
|
+
},
|
|
3394
|
+
'Errors skip and collect'($) {
|
|
3395
|
+
const tree = `foo bar`;
|
|
3396
|
+
const errors = [];
|
|
3397
|
+
const $$ = $.$mol_ambient({
|
|
3398
|
+
$mol_fail: (error) => {
|
|
3399
|
+
errors.push(error.message);
|
|
3400
|
+
return null;
|
|
3401
|
+
}
|
|
3402
|
+
});
|
|
3403
|
+
const res = $$.$mol_tree2_from_string(tree, 'test');
|
|
3404
|
+
$mol_assert_like(errors, [
|
|
3405
|
+
'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar',
|
|
3406
|
+
'Unexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
|
|
3407
|
+
]);
|
|
3408
|
+
$mol_assert_equal(res.toString(), 'foo bar\n');
|
|
3409
|
+
},
|
|
3410
|
+
});
|
|
3411
|
+
})($ || ($ = {}));
|
|
3412
|
+
|
|
3413
|
+
;
|
|
3414
|
+
"use strict";
|
|
3415
|
+
var $;
|
|
3416
|
+
(function ($) {
|
|
3417
|
+
$mol_test({
|
|
3418
|
+
'fromJSON'() {
|
|
3419
|
+
$mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
|
|
3420
|
+
$mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
3421
|
+
$mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
3422
|
+
$mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
|
|
3423
|
+
$mol_assert_equal($mol_tree2_from_json(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
3424
|
+
$mol_assert_equal($mol_tree2_from_json({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
3425
|
+
},
|
|
3426
|
+
});
|
|
3427
|
+
})($ || ($ = {}));
|
|
3428
|
+
|
|
3429
|
+
;
|
|
3430
|
+
"use strict";
|
|
3431
|
+
var $;
|
|
3432
|
+
(function ($_1) {
|
|
3433
|
+
$mol_test({
|
|
3434
|
+
'FQN of anon function'($) {
|
|
3435
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
3436
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
3437
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
3438
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
3439
|
+
},
|
|
3440
|
+
});
|
|
3441
|
+
})($ || ($ = {}));
|
|
3442
|
+
|
|
3443
|
+
;
|
|
3444
|
+
"use strict";
|
|
3445
|
+
var $;
|
|
3446
|
+
(function ($) {
|
|
3447
|
+
$mol_test({
|
|
3448
|
+
'auto name'() {
|
|
3449
|
+
class Invalid extends $mol_error_mix {
|
|
3450
|
+
}
|
|
3451
|
+
const mix = new Invalid('foo');
|
|
3452
|
+
$mol_assert_equal(mix.name, 'Invalid_Error');
|
|
3453
|
+
},
|
|
3454
|
+
'simpe mix'() {
|
|
3455
|
+
const mix = new $mol_error_mix('foo', {}, new Error('bar'), new Error('lol'));
|
|
3456
|
+
$mol_assert_equal(mix.message, 'foo');
|
|
3457
|
+
$mol_assert_equal(mix.errors.map(e => e.message), ['bar', 'lol']);
|
|
3458
|
+
},
|
|
3459
|
+
'provide additional info'() {
|
|
3460
|
+
class Invalid extends $mol_error_mix {
|
|
3461
|
+
}
|
|
3462
|
+
const mix = new $mol_error_mix('Wrong password', {}, new Invalid('Too short', { value: 'p@ssw0rd', hint: '> 8 letters' }), new Invalid('Too simple', { value: 'p@ssw0rd', hint: 'need capital letter' }));
|
|
3463
|
+
const hints = [];
|
|
3464
|
+
if (mix instanceof $mol_error_mix) {
|
|
3465
|
+
for (const er of mix.errors) {
|
|
3466
|
+
if (er instanceof Invalid) {
|
|
3467
|
+
hints.push(er.cause?.hint ?? '');
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
$mol_assert_equal(hints, ['> 8 letters', 'need capital letter']);
|
|
3472
|
+
},
|
|
3473
|
+
});
|
|
3474
|
+
})($ || ($ = {}));
|
|
3475
|
+
|
|
3476
|
+
;
|
|
3477
|
+
"use strict";
|
|
3478
|
+
var $;
|
|
3479
|
+
(function ($_1) {
|
|
3480
|
+
$mol_test({
|
|
3481
|
+
'Collect deps'() {
|
|
3482
|
+
const pub1 = new $mol_wire_pub;
|
|
3483
|
+
const pub2 = new $mol_wire_pub;
|
|
3484
|
+
const sub = new $mol_wire_pub_sub;
|
|
3485
|
+
const bu1 = sub.track_on();
|
|
3486
|
+
try {
|
|
3487
|
+
pub1.promote();
|
|
3488
|
+
pub2.promote();
|
|
3489
|
+
pub2.promote();
|
|
3490
|
+
}
|
|
3491
|
+
finally {
|
|
3492
|
+
sub.track_cut();
|
|
3493
|
+
sub.track_off(bu1);
|
|
3494
|
+
}
|
|
3495
|
+
pub1.emit();
|
|
3496
|
+
pub2.emit();
|
|
3497
|
+
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
3498
|
+
const bu2 = sub.track_on();
|
|
3499
|
+
try {
|
|
3500
|
+
pub1.promote();
|
|
3501
|
+
pub1.promote();
|
|
3502
|
+
pub2.promote();
|
|
3503
|
+
}
|
|
3504
|
+
finally {
|
|
3505
|
+
sub.track_cut();
|
|
3506
|
+
sub.track_off(bu2);
|
|
3507
|
+
}
|
|
3508
|
+
pub1.emit();
|
|
3509
|
+
pub2.emit();
|
|
3510
|
+
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
3054
3511
|
},
|
|
3055
|
-
'
|
|
3056
|
-
|
|
3512
|
+
'cyclic detection'($) {
|
|
3513
|
+
const sub1 = new $mol_wire_pub_sub;
|
|
3514
|
+
const sub2 = new $mol_wire_pub_sub;
|
|
3515
|
+
const bu1 = sub1.track_on();
|
|
3516
|
+
try {
|
|
3517
|
+
const bu2 = sub2.track_on();
|
|
3518
|
+
try {
|
|
3519
|
+
$mol_assert_fail(() => sub1.promote(), 'Circular subscription');
|
|
3520
|
+
}
|
|
3521
|
+
finally {
|
|
3522
|
+
sub2.track_cut();
|
|
3523
|
+
sub2.track_off(bu2);
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
finally {
|
|
3527
|
+
sub1.track_cut();
|
|
3528
|
+
sub1.track_off(bu1);
|
|
3529
|
+
}
|
|
3057
3530
|
},
|
|
3058
3531
|
});
|
|
3059
3532
|
})($ || ($ = {}));
|
|
@@ -3061,37 +3534,47 @@ var $;
|
|
|
3061
3534
|
;
|
|
3062
3535
|
"use strict";
|
|
3063
3536
|
var $;
|
|
3064
|
-
(function ($
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3537
|
+
(function ($) {
|
|
3538
|
+
$.$mol_after_mock_queue = [];
|
|
3539
|
+
function $mol_after_mock_warp() {
|
|
3540
|
+
const queue = $.$mol_after_mock_queue.splice(0);
|
|
3541
|
+
for (const task of queue)
|
|
3542
|
+
task();
|
|
3543
|
+
}
|
|
3544
|
+
$.$mol_after_mock_warp = $mol_after_mock_warp;
|
|
3545
|
+
class $mol_after_mock_commmon extends $mol_object2 {
|
|
3546
|
+
task;
|
|
3547
|
+
promise = Promise.resolve();
|
|
3548
|
+
cancelled = false;
|
|
3549
|
+
id;
|
|
3550
|
+
constructor(task) {
|
|
3551
|
+
super();
|
|
3552
|
+
this.task = task;
|
|
3553
|
+
$.$mol_after_mock_queue.push(task);
|
|
3554
|
+
}
|
|
3555
|
+
destructor() {
|
|
3556
|
+
const index = $.$mol_after_mock_queue.indexOf(this.task);
|
|
3557
|
+
if (index >= 0)
|
|
3558
|
+
$.$mol_after_mock_queue.splice(index, 1);
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
|
3562
|
+
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
|
3563
|
+
delay;
|
|
3564
|
+
constructor(delay, task) {
|
|
3565
|
+
super(task);
|
|
3566
|
+
this.delay = delay;
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
$.$mol_after_mock_timeout = $mol_after_mock_timeout;
|
|
3073
3570
|
})($ || ($ = {}));
|
|
3074
3571
|
|
|
3075
|
-
;
|
|
3076
|
-
"use strict";
|
|
3077
|
-
|
|
3078
|
-
;
|
|
3079
|
-
"use strict";
|
|
3080
|
-
|
|
3081
|
-
;
|
|
3082
|
-
"use strict";
|
|
3083
|
-
|
|
3084
3572
|
;
|
|
3085
3573
|
"use strict";
|
|
3086
3574
|
var $;
|
|
3087
3575
|
(function ($_1) {
|
|
3088
|
-
$
|
|
3089
|
-
|
|
3090
|
-
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
3091
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
3092
|
-
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
3093
|
-
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
3094
|
-
},
|
|
3576
|
+
$mol_test_mocks.push($ => {
|
|
3577
|
+
$.$mol_after_tick = $mol_after_mock_commmon;
|
|
3095
3578
|
});
|
|
3096
3579
|
})($ || ($ = {}));
|
|
3097
3580
|
|
|
@@ -3100,60 +3583,79 @@ var $;
|
|
|
3100
3583
|
var $;
|
|
3101
3584
|
(function ($) {
|
|
3102
3585
|
$mol_test({
|
|
3103
|
-
'
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
3109
|
-
$mol_assert_equal('foo' in proxy, true);
|
|
3110
|
-
},
|
|
3111
|
-
'set'() {
|
|
3112
|
-
const target = { foo: 777 };
|
|
3113
|
-
const proxy = $mol_delegate({}, () => target);
|
|
3114
|
-
proxy.foo = 123;
|
|
3115
|
-
$mol_assert_equal(target.foo, 123);
|
|
3116
|
-
},
|
|
3117
|
-
'getOwnPropertyDescriptor'() {
|
|
3118
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
3119
|
-
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
3120
|
-
value: 777,
|
|
3121
|
-
writable: true,
|
|
3122
|
-
enumerable: true,
|
|
3123
|
-
configurable: true,
|
|
3124
|
-
});
|
|
3125
|
-
},
|
|
3126
|
-
'ownKeys'() {
|
|
3127
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
3128
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
3129
|
-
},
|
|
3130
|
-
'getPrototypeOf'() {
|
|
3131
|
-
class Foo {
|
|
3586
|
+
'Sync execution'() {
|
|
3587
|
+
class Sync extends $mol_object2 {
|
|
3588
|
+
static calc(a, b) {
|
|
3589
|
+
return a + b;
|
|
3590
|
+
}
|
|
3132
3591
|
}
|
|
3133
|
-
|
|
3134
|
-
|
|
3592
|
+
__decorate([
|
|
3593
|
+
$mol_wire_method
|
|
3594
|
+
], Sync, "calc", null);
|
|
3595
|
+
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
3135
3596
|
},
|
|
3136
|
-
'
|
|
3137
|
-
class
|
|
3597
|
+
async 'async <=> sync'() {
|
|
3598
|
+
class SyncAsync extends $mol_object2 {
|
|
3599
|
+
static async val(a) {
|
|
3600
|
+
return a;
|
|
3601
|
+
}
|
|
3602
|
+
static sum(a, b) {
|
|
3603
|
+
const syn = $mol_wire_sync(this);
|
|
3604
|
+
return syn.val(a) + syn.val(b);
|
|
3605
|
+
}
|
|
3606
|
+
static async calc(a, b) {
|
|
3607
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
3608
|
+
}
|
|
3138
3609
|
}
|
|
3139
|
-
|
|
3140
|
-
const proxy = $mol_delegate({}, () => target);
|
|
3141
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
3142
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
3610
|
+
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
3143
3611
|
},
|
|
3144
|
-
'
|
|
3145
|
-
class
|
|
3612
|
+
async 'Idempotence control'() {
|
|
3613
|
+
class Idempotence extends $mol_object2 {
|
|
3614
|
+
static logs_idemp = 0;
|
|
3615
|
+
static logs_unidemp = 0;
|
|
3616
|
+
static log_idemp() {
|
|
3617
|
+
this.logs_idemp += 1;
|
|
3618
|
+
}
|
|
3619
|
+
static log_unidemp() {
|
|
3620
|
+
this.logs_unidemp += 1;
|
|
3621
|
+
}
|
|
3622
|
+
static async val(a) {
|
|
3623
|
+
return a;
|
|
3624
|
+
}
|
|
3625
|
+
static sum(a, b) {
|
|
3626
|
+
this.log_idemp();
|
|
3627
|
+
this.log_unidemp();
|
|
3628
|
+
const syn = $mol_wire_sync(this);
|
|
3629
|
+
return syn.val(a) + syn.val(b);
|
|
3630
|
+
}
|
|
3631
|
+
static async calc(a, b) {
|
|
3632
|
+
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
3633
|
+
}
|
|
3146
3634
|
}
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3635
|
+
__decorate([
|
|
3636
|
+
$mol_wire_method
|
|
3637
|
+
], Idempotence, "log_idemp", null);
|
|
3638
|
+
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
3639
|
+
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
3640
|
+
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
3150
3641
|
},
|
|
3151
|
-
'
|
|
3152
|
-
class
|
|
3642
|
+
async 'Error handling'() {
|
|
3643
|
+
class Handle extends $mol_object2 {
|
|
3644
|
+
static async sum(a, b) {
|
|
3645
|
+
$mol_fail(new Error('test error ' + (a + b)));
|
|
3646
|
+
}
|
|
3647
|
+
static check() {
|
|
3648
|
+
try {
|
|
3649
|
+
return $mol_wire_sync(Handle).sum(1, 2);
|
|
3650
|
+
}
|
|
3651
|
+
catch (error) {
|
|
3652
|
+
if ($mol_promise_like(error))
|
|
3653
|
+
$mol_fail_hidden(error);
|
|
3654
|
+
$mol_assert_equal(error.message, 'test error 3');
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3153
3657
|
}
|
|
3154
|
-
|
|
3155
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
3156
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
3658
|
+
await $mol_wire_async(Handle).check();
|
|
3157
3659
|
},
|
|
3158
3660
|
});
|
|
3159
3661
|
})($ || ($ = {}));
|
|
@@ -3163,50 +3665,51 @@ var $;
|
|
|
3163
3665
|
var $;
|
|
3164
3666
|
(function ($_1) {
|
|
3165
3667
|
$mol_test({
|
|
3166
|
-
'
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
3176
|
-
const child = span.after(11);
|
|
3177
|
-
$mol_assert_equal(child.uri, 'test.ts');
|
|
3178
|
-
$mol_assert_equal(child.row, 1);
|
|
3179
|
-
$mol_assert_equal(child.col, 7);
|
|
3180
|
-
$mol_assert_equal(child.length, 11);
|
|
3181
|
-
},
|
|
3182
|
-
'slice span - regular'($) {
|
|
3183
|
-
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
3184
|
-
const child = span.slice(1, 4);
|
|
3185
|
-
$mol_assert_equal(child.row, 1);
|
|
3186
|
-
$mol_assert_equal(child.col, 4);
|
|
3187
|
-
$mol_assert_equal(child.length, 3);
|
|
3188
|
-
const child2 = span.slice(2, 2);
|
|
3189
|
-
$mol_assert_equal(child2.col, 5);
|
|
3190
|
-
$mol_assert_equal(child2.length, 0);
|
|
3668
|
+
'test types'($) {
|
|
3669
|
+
class A {
|
|
3670
|
+
static a() {
|
|
3671
|
+
return '';
|
|
3672
|
+
}
|
|
3673
|
+
static b() {
|
|
3674
|
+
return $mol_wire_async(this).a();
|
|
3675
|
+
}
|
|
3676
|
+
}
|
|
3191
3677
|
},
|
|
3192
|
-
'
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3678
|
+
async 'Latest method calls wins'($) {
|
|
3679
|
+
class NameLogger extends $mol_object2 {
|
|
3680
|
+
static $ = $;
|
|
3681
|
+
static first = [];
|
|
3682
|
+
static last = [];
|
|
3683
|
+
static send(next) {
|
|
3684
|
+
$mol_wire_sync(this.first).push(next);
|
|
3685
|
+
this.$.$mol_wait_timeout(0);
|
|
3686
|
+
this.last.push(next);
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
const name = $mol_wire_async(NameLogger).send;
|
|
3690
|
+
name('john');
|
|
3691
|
+
const promise = name('jin');
|
|
3692
|
+
$.$mol_after_mock_warp();
|
|
3693
|
+
await promise;
|
|
3694
|
+
$mol_assert_like(NameLogger.first, ['john', 'jin']);
|
|
3695
|
+
$mol_assert_like(NameLogger.last, ['jin']);
|
|
3198
3696
|
},
|
|
3199
|
-
'
|
|
3200
|
-
const
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3697
|
+
async 'Latest function calls wins'($) {
|
|
3698
|
+
const first = [];
|
|
3699
|
+
const last = [];
|
|
3700
|
+
function send_name(next) {
|
|
3701
|
+
$mol_wire_sync(first).push(next);
|
|
3702
|
+
$.$mol_wait_timeout(0);
|
|
3703
|
+
last.push(next);
|
|
3704
|
+
}
|
|
3705
|
+
const name = $mol_wire_async(send_name);
|
|
3706
|
+
name('john');
|
|
3707
|
+
const promise = name('jin');
|
|
3708
|
+
$.$mol_after_mock_warp();
|
|
3709
|
+
await promise;
|
|
3710
|
+
$mol_assert_like(first, ['john', 'jin']);
|
|
3711
|
+
$mol_assert_like(last, ['jin']);
|
|
3204
3712
|
},
|
|
3205
|
-
'error handling'($) {
|
|
3206
|
-
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
3207
|
-
const error = span.error('Some error');
|
|
3208
|
-
$mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
|
|
3209
|
-
}
|
|
3210
3713
|
});
|
|
3211
3714
|
})($ || ($ = {}));
|
|
3212
3715
|
|
|
@@ -3215,40 +3718,15 @@ var $;
|
|
|
3215
3718
|
var $;
|
|
3216
3719
|
(function ($_1) {
|
|
3217
3720
|
$mol_test({
|
|
3218
|
-
'
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
.toString(), 'a b x\n');
|
|
3228
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
3229
|
-
.insert($mol_tree2.struct('x'), 0, 0, 0, 0)
|
|
3230
|
-
.toString(), 'a b \\\n\tx\n');
|
|
3231
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
3232
|
-
.insert($mol_tree2.struct('x'), null, null, null)
|
|
3233
|
-
.toString(), 'a b x\n');
|
|
3234
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
3235
|
-
.insert($mol_tree2.struct('x'), null, null, null, null)
|
|
3236
|
-
.toString(), 'a b \\\n\tx\n');
|
|
3237
|
-
},
|
|
3238
|
-
'deleting'($) {
|
|
3239
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
3240
|
-
.insert(null, 'a', 'b', 'c')
|
|
3241
|
-
.toString(), 'a b\n');
|
|
3242
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
3243
|
-
.insert(null, 0, 0, 0)
|
|
3244
|
-
.toString(), 'a b\n');
|
|
3245
|
-
},
|
|
3246
|
-
'hack'($) {
|
|
3247
|
-
const res = $.$mol_tree2_from_string(`foo bar xxx\n`)
|
|
3248
|
-
.hack({
|
|
3249
|
-
'bar': (input, belt) => [input.struct('777', input.hack(belt))],
|
|
3250
|
-
});
|
|
3251
|
-
$mol_assert_equal(res.toString(), 'foo 777 xxx\n');
|
|
3721
|
+
'test types'($) {
|
|
3722
|
+
class A {
|
|
3723
|
+
static a() {
|
|
3724
|
+
return Promise.resolve('');
|
|
3725
|
+
}
|
|
3726
|
+
static b() {
|
|
3727
|
+
return $mol_wire_sync(this).a();
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3252
3730
|
},
|
|
3253
3731
|
});
|
|
3254
3732
|
})($ || ($ = {}));
|
|
@@ -3257,85 +3735,36 @@ var $;
|
|
|
3257
3735
|
"use strict";
|
|
3258
3736
|
var $;
|
|
3259
3737
|
(function ($_1) {
|
|
3260
|
-
$
|
|
3261
|
-
|
|
3262
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids.length, 2);
|
|
3263
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo\nbar\n").kids[1].type, "bar");
|
|
3264
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo\n\n\n").kids.length, 1);
|
|
3265
|
-
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids.length, 2);
|
|
3266
|
-
$mol_assert_equal($.$mol_tree2_from_string("=foo\n\\bar\n").kids[1].value, "bar");
|
|
3267
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo bar \\pol\n").kids[0].kids[0].kids[0].value, "pol");
|
|
3268
|
-
$mol_assert_equal($.$mol_tree2_from_string("foo bar\n\t\\pol\n\t\\men\n").kids[0].kids[0].kids[1].value, "men");
|
|
3269
|
-
$mol_assert_equal($.$mol_tree2_from_string('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
3270
|
-
},
|
|
3271
|
-
'Too many tabs'($) {
|
|
3272
|
-
const tree = `
|
|
3273
|
-
foo
|
|
3274
|
-
bar
|
|
3275
|
-
`;
|
|
3276
|
-
$mol_assert_fail(() => {
|
|
3277
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
3278
|
-
}, 'Too many tabs\ntest#3:1/6\n!!!!!!\n\t\t\t\t\t\tbar');
|
|
3279
|
-
},
|
|
3280
|
-
'Too few tabs'($) {
|
|
3281
|
-
const tree = `
|
|
3282
|
-
foo
|
|
3283
|
-
bar
|
|
3284
|
-
`;
|
|
3285
|
-
$mol_assert_fail(() => {
|
|
3286
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
3287
|
-
}, 'Too few tabs\ntest#3:1/4\n!!!!\n\t\t\t\tbar');
|
|
3288
|
-
},
|
|
3289
|
-
'Wrong nodes separator at start'($) {
|
|
3290
|
-
const tree = `foo\n \tbar\n`;
|
|
3291
|
-
$mol_assert_fail(() => {
|
|
3292
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
3293
|
-
}, 'Wrong nodes separator\ntest#2:1/2\n!!\n \tbar');
|
|
3294
|
-
},
|
|
3295
|
-
'Wrong nodes separator in the middle'($) {
|
|
3296
|
-
const tree = `foo bar\n`;
|
|
3297
|
-
$mol_assert_fail(() => {
|
|
3298
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
3299
|
-
}, 'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar');
|
|
3300
|
-
},
|
|
3301
|
-
'Unexpected EOF, LF required'($) {
|
|
3302
|
-
const tree = ` foo`;
|
|
3303
|
-
$mol_assert_fail(() => {
|
|
3304
|
-
$.$mol_tree2_from_string(tree, 'test');
|
|
3305
|
-
}, 'Unexpected EOF, LF required\ntest#1:5/1\n !\n foo');
|
|
3306
|
-
},
|
|
3307
|
-
'Errors skip and collect'($) {
|
|
3308
|
-
const tree = `foo bar`;
|
|
3309
|
-
const errors = [];
|
|
3310
|
-
const $$ = $.$mol_ambient({
|
|
3311
|
-
$mol_fail: (error) => {
|
|
3312
|
-
errors.push(error.message);
|
|
3313
|
-
return null;
|
|
3314
|
-
}
|
|
3315
|
-
});
|
|
3316
|
-
const res = $$.$mol_tree2_from_string(tree, 'test');
|
|
3317
|
-
$mol_assert_like(errors, [
|
|
3318
|
-
'Wrong nodes separator\ntest#1:5/1\n !\nfoo bar',
|
|
3319
|
-
'Unexpected EOF, LF required\ntest#1:9/1\n !\nfoo bar',
|
|
3320
|
-
]);
|
|
3321
|
-
$mol_assert_equal(res.toString(), 'foo bar\n');
|
|
3322
|
-
},
|
|
3738
|
+
$mol_test_mocks.push($ => {
|
|
3739
|
+
$.$mol_after_timeout = $mol_after_mock_timeout;
|
|
3323
3740
|
});
|
|
3324
3741
|
})($ || ($ = {}));
|
|
3325
3742
|
|
|
3326
3743
|
;
|
|
3327
3744
|
"use strict";
|
|
3328
3745
|
var $;
|
|
3329
|
-
(function ($) {
|
|
3746
|
+
(function ($_1) {
|
|
3330
3747
|
$mol_test({
|
|
3331
|
-
'
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3748
|
+
async 'exec timeout auto kill child process'($) {
|
|
3749
|
+
let close_mock = () => { };
|
|
3750
|
+
const context_mock = $.$mol_ambient({
|
|
3751
|
+
$mol_run_spawn: () => ({
|
|
3752
|
+
on(name, cb) {
|
|
3753
|
+
if (name === 'exit')
|
|
3754
|
+
close_mock = cb;
|
|
3755
|
+
},
|
|
3756
|
+
kill() { close_mock(); }
|
|
3757
|
+
})
|
|
3758
|
+
});
|
|
3759
|
+
let message = '';
|
|
3760
|
+
try {
|
|
3761
|
+
const res = await $mol_wire_async(context_mock).$mol_run({ command: 'sleep 10', dir: '.', timeout: 10 });
|
|
3762
|
+
}
|
|
3763
|
+
catch (e) {
|
|
3764
|
+
message = e.message;
|
|
3765
|
+
}
|
|
3766
|
+
$mol_assert_equal(message, 'Run error, timeout');
|
|
3767
|
+
}
|
|
3339
3768
|
});
|
|
3340
3769
|
})($ || ($ = {}));
|
|
3341
3770
|
|
|
@@ -3400,130 +3829,31 @@ var $;
|
|
|
3400
3829
|
const App = () => {
|
|
3401
3830
|
return $mol_jsx("div", null,
|
|
3402
3831
|
$mol_jsx("span", { id: "bar" }),
|
|
3403
|
-
$mol_jsx("span", { id: "bar" }));
|
|
3404
|
-
};
|
|
3405
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
3406
|
-
},
|
|
3407
|
-
'Owner based guid generationn'() {
|
|
3408
|
-
const Foo = () => {
|
|
3409
|
-
return $mol_jsx("div", null,
|
|
3410
|
-
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
3411
|
-
};
|
|
3412
|
-
const Bar = (props) => {
|
|
3413
|
-
return $mol_jsx("span", null, props.icon());
|
|
3414
|
-
};
|
|
3415
|
-
const dom = $mol_jsx(Foo, { id: "app" });
|
|
3416
|
-
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
3417
|
-
},
|
|
3418
|
-
'Fail on same ids from different caller'() {
|
|
3419
|
-
const Foo = () => {
|
|
3420
|
-
return $mol_jsx("div", null,
|
|
3421
|
-
$mol_jsx("img", { id: "icon" }),
|
|
3422
|
-
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
3423
|
-
};
|
|
3424
|
-
const Bar = (props) => {
|
|
3425
|
-
return $mol_jsx("span", null, props.icon());
|
|
3426
|
-
};
|
|
3427
|
-
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
3428
|
-
},
|
|
3429
|
-
});
|
|
3430
|
-
})($ || ($ = {}));
|
|
3431
|
-
|
|
3432
|
-
;
|
|
3433
|
-
"use strict";
|
|
3434
|
-
var $;
|
|
3435
|
-
(function ($) {
|
|
3436
|
-
function $mol_dom_parse(text, type = 'application/xhtml+xml') {
|
|
3437
|
-
const parser = new $mol_dom_context.DOMParser();
|
|
3438
|
-
const doc = parser.parseFromString(text, type);
|
|
3439
|
-
const error = doc.getElementsByTagName('parsererror');
|
|
3440
|
-
if (error.length)
|
|
3441
|
-
throw new Error(error[0].textContent);
|
|
3442
|
-
return doc;
|
|
3443
|
-
}
|
|
3444
|
-
$.$mol_dom_parse = $mol_dom_parse;
|
|
3445
|
-
})($ || ($ = {}));
|
|
3446
|
-
|
|
3447
|
-
;
|
|
3448
|
-
"use strict";
|
|
3449
|
-
var $;
|
|
3450
|
-
(function ($) {
|
|
3451
|
-
$mol_test({
|
|
3452
|
-
'Attach to document'() {
|
|
3453
|
-
const doc = $mol_dom_parse('<html><body id="foo"></body></html>');
|
|
3454
|
-
$mol_jsx_attach(doc, () => $mol_jsx("body", { id: "foo" }, "bar"));
|
|
3455
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">bar</body></html>');
|
|
3456
|
-
},
|
|
3457
|
-
});
|
|
3458
|
-
})($ || ($ = {}));
|
|
3459
|
-
|
|
3460
|
-
;
|
|
3461
|
-
"use strict";
|
|
3462
|
-
var $;
|
|
3463
|
-
(function ($) {
|
|
3464
|
-
$mol_test({
|
|
3465
|
-
'const returns stored value'() {
|
|
3466
|
-
const foo = { bar: $mol_const(Math.random()) };
|
|
3467
|
-
$mol_assert_equal(foo.bar(), foo.bar());
|
|
3468
|
-
$mol_assert_equal(foo.bar(), foo.bar['()']);
|
|
3469
|
-
},
|
|
3470
|
-
});
|
|
3471
|
-
})($ || ($ = {}));
|
|
3472
|
-
|
|
3473
|
-
;
|
|
3474
|
-
"use strict";
|
|
3475
|
-
var $;
|
|
3476
|
-
(function ($_1) {
|
|
3477
|
-
$mol_test({
|
|
3478
|
-
'Collect deps'() {
|
|
3479
|
-
const pub1 = new $mol_wire_pub;
|
|
3480
|
-
const pub2 = new $mol_wire_pub;
|
|
3481
|
-
const sub = new $mol_wire_pub_sub;
|
|
3482
|
-
const bu1 = sub.track_on();
|
|
3483
|
-
try {
|
|
3484
|
-
pub1.promote();
|
|
3485
|
-
pub2.promote();
|
|
3486
|
-
pub2.promote();
|
|
3487
|
-
}
|
|
3488
|
-
finally {
|
|
3489
|
-
sub.track_cut();
|
|
3490
|
-
sub.track_off(bu1);
|
|
3491
|
-
}
|
|
3492
|
-
pub1.emit();
|
|
3493
|
-
pub2.emit();
|
|
3494
|
-
$mol_assert_like(sub.pub_list, [pub1, pub2, pub2]);
|
|
3495
|
-
const bu2 = sub.track_on();
|
|
3496
|
-
try {
|
|
3497
|
-
pub1.promote();
|
|
3498
|
-
pub1.promote();
|
|
3499
|
-
pub2.promote();
|
|
3500
|
-
}
|
|
3501
|
-
finally {
|
|
3502
|
-
sub.track_cut();
|
|
3503
|
-
sub.track_off(bu2);
|
|
3504
|
-
}
|
|
3505
|
-
pub1.emit();
|
|
3506
|
-
pub2.emit();
|
|
3507
|
-
$mol_assert_like(sub.pub_list, [pub1, pub1, pub2]);
|
|
3832
|
+
$mol_jsx("span", { id: "bar" }));
|
|
3833
|
+
};
|
|
3834
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
3508
3835
|
},
|
|
3509
|
-
'
|
|
3510
|
-
const
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3836
|
+
'Owner based guid generationn'() {
|
|
3837
|
+
const Foo = () => {
|
|
3838
|
+
return $mol_jsx("div", null,
|
|
3839
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
3840
|
+
};
|
|
3841
|
+
const Bar = (props) => {
|
|
3842
|
+
return $mol_jsx("span", null, props.icon());
|
|
3843
|
+
};
|
|
3844
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
3845
|
+
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
3846
|
+
},
|
|
3847
|
+
'Fail on same ids from different caller'() {
|
|
3848
|
+
const Foo = () => {
|
|
3849
|
+
return $mol_jsx("div", null,
|
|
3850
|
+
$mol_jsx("img", { id: "icon" }),
|
|
3851
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
3852
|
+
};
|
|
3853
|
+
const Bar = (props) => {
|
|
3854
|
+
return $mol_jsx("span", null, props.icon());
|
|
3855
|
+
};
|
|
3856
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
3527
3857
|
},
|
|
3528
3858
|
});
|
|
3529
3859
|
})($ || ($ = {}));
|
|
@@ -3532,46 +3862,27 @@ var $;
|
|
|
3532
3862
|
"use strict";
|
|
3533
3863
|
var $;
|
|
3534
3864
|
(function ($) {
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
const
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
class $mol_after_mock_commmon extends $mol_object2 {
|
|
3543
|
-
task;
|
|
3544
|
-
promise = Promise.resolve();
|
|
3545
|
-
cancelled = false;
|
|
3546
|
-
id;
|
|
3547
|
-
constructor(task) {
|
|
3548
|
-
super();
|
|
3549
|
-
this.task = task;
|
|
3550
|
-
$.$mol_after_mock_queue.push(task);
|
|
3551
|
-
}
|
|
3552
|
-
destructor() {
|
|
3553
|
-
const index = $.$mol_after_mock_queue.indexOf(this.task);
|
|
3554
|
-
if (index >= 0)
|
|
3555
|
-
$.$mol_after_mock_queue.splice(index, 1);
|
|
3556
|
-
}
|
|
3557
|
-
}
|
|
3558
|
-
$.$mol_after_mock_commmon = $mol_after_mock_commmon;
|
|
3559
|
-
class $mol_after_mock_timeout extends $mol_after_mock_commmon {
|
|
3560
|
-
delay;
|
|
3561
|
-
constructor(delay, task) {
|
|
3562
|
-
super(task);
|
|
3563
|
-
this.delay = delay;
|
|
3564
|
-
}
|
|
3865
|
+
function $mol_dom_parse(text, type = 'application/xhtml+xml') {
|
|
3866
|
+
const parser = new $mol_dom_context.DOMParser();
|
|
3867
|
+
const doc = parser.parseFromString(text, type);
|
|
3868
|
+
const error = doc.getElementsByTagName('parsererror');
|
|
3869
|
+
if (error.length)
|
|
3870
|
+
throw new Error(error[0].textContent);
|
|
3871
|
+
return doc;
|
|
3565
3872
|
}
|
|
3566
|
-
$.$
|
|
3873
|
+
$.$mol_dom_parse = $mol_dom_parse;
|
|
3567
3874
|
})($ || ($ = {}));
|
|
3568
3875
|
|
|
3569
3876
|
;
|
|
3570
3877
|
"use strict";
|
|
3571
3878
|
var $;
|
|
3572
|
-
(function ($
|
|
3573
|
-
$
|
|
3574
|
-
|
|
3879
|
+
(function ($) {
|
|
3880
|
+
$mol_test({
|
|
3881
|
+
'Attach to document'() {
|
|
3882
|
+
const doc = $mol_dom_parse('<html><body id="foo"></body></html>');
|
|
3883
|
+
$mol_jsx_attach(doc, () => $mol_jsx("body", { id: "foo" }, "bar"));
|
|
3884
|
+
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">bar</body></html>');
|
|
3885
|
+
},
|
|
3575
3886
|
});
|
|
3576
3887
|
})($ || ($ = {}));
|
|
3577
3888
|
|
|
@@ -3580,79 +3891,10 @@ var $;
|
|
|
3580
3891
|
var $;
|
|
3581
3892
|
(function ($) {
|
|
3582
3893
|
$mol_test({
|
|
3583
|
-
'
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
}
|
|
3588
|
-
}
|
|
3589
|
-
__decorate([
|
|
3590
|
-
$mol_wire_method
|
|
3591
|
-
], Sync, "calc", null);
|
|
3592
|
-
$mol_assert_equal(Sync.calc(1, 2), 3);
|
|
3593
|
-
},
|
|
3594
|
-
async 'async <=> sync'() {
|
|
3595
|
-
class SyncAsync extends $mol_object2 {
|
|
3596
|
-
static async val(a) {
|
|
3597
|
-
return a;
|
|
3598
|
-
}
|
|
3599
|
-
static sum(a, b) {
|
|
3600
|
-
const syn = $mol_wire_sync(this);
|
|
3601
|
-
return syn.val(a) + syn.val(b);
|
|
3602
|
-
}
|
|
3603
|
-
static async calc(a, b) {
|
|
3604
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
3605
|
-
}
|
|
3606
|
-
}
|
|
3607
|
-
$mol_assert_equal(await SyncAsync.calc(1, 2), 8);
|
|
3608
|
-
},
|
|
3609
|
-
async 'Idempotence control'() {
|
|
3610
|
-
class Idempotence extends $mol_object2 {
|
|
3611
|
-
static logs_idemp = 0;
|
|
3612
|
-
static logs_unidemp = 0;
|
|
3613
|
-
static log_idemp() {
|
|
3614
|
-
this.logs_idemp += 1;
|
|
3615
|
-
}
|
|
3616
|
-
static log_unidemp() {
|
|
3617
|
-
this.logs_unidemp += 1;
|
|
3618
|
-
}
|
|
3619
|
-
static async val(a) {
|
|
3620
|
-
return a;
|
|
3621
|
-
}
|
|
3622
|
-
static sum(a, b) {
|
|
3623
|
-
this.log_idemp();
|
|
3624
|
-
this.log_unidemp();
|
|
3625
|
-
const syn = $mol_wire_sync(this);
|
|
3626
|
-
return syn.val(a) + syn.val(b);
|
|
3627
|
-
}
|
|
3628
|
-
static async calc(a, b) {
|
|
3629
|
-
return 5 + await $mol_wire_async(this).sum(a, b);
|
|
3630
|
-
}
|
|
3631
|
-
}
|
|
3632
|
-
__decorate([
|
|
3633
|
-
$mol_wire_method
|
|
3634
|
-
], Idempotence, "log_idemp", null);
|
|
3635
|
-
$mol_assert_equal(await Idempotence.calc(1, 2), 8);
|
|
3636
|
-
$mol_assert_equal(Idempotence.logs_idemp, 1);
|
|
3637
|
-
$mol_assert_equal(Idempotence.logs_unidemp, 3);
|
|
3638
|
-
},
|
|
3639
|
-
async 'Error handling'() {
|
|
3640
|
-
class Handle extends $mol_object2 {
|
|
3641
|
-
static async sum(a, b) {
|
|
3642
|
-
$mol_fail(new Error('test error ' + (a + b)));
|
|
3643
|
-
}
|
|
3644
|
-
static check() {
|
|
3645
|
-
try {
|
|
3646
|
-
return $mol_wire_sync(Handle).sum(1, 2);
|
|
3647
|
-
}
|
|
3648
|
-
catch (error) {
|
|
3649
|
-
if ($mol_promise_like(error))
|
|
3650
|
-
$mol_fail_hidden(error);
|
|
3651
|
-
$mol_assert_equal(error.message, 'test error 3');
|
|
3652
|
-
}
|
|
3653
|
-
}
|
|
3654
|
-
}
|
|
3655
|
-
await $mol_wire_async(Handle).check();
|
|
3894
|
+
'const returns stored value'() {
|
|
3895
|
+
const foo = { bar: $mol_const(Math.random()) };
|
|
3896
|
+
$mol_assert_equal(foo.bar(), foo.bar());
|
|
3897
|
+
$mol_assert_equal(foo.bar(), foo.bar['()']);
|
|
3656
3898
|
},
|
|
3657
3899
|
});
|
|
3658
3900
|
})($ || ($ = {}));
|
|
@@ -3723,18 +3965,15 @@ var $;
|
|
|
3723
3965
|
var $;
|
|
3724
3966
|
(function ($_1) {
|
|
3725
3967
|
$mol_test_mocks.push($ => {
|
|
3726
|
-
$.$
|
|
3968
|
+
$.$mol_after_frame = $mol_after_mock_commmon;
|
|
3727
3969
|
});
|
|
3728
3970
|
})($ || ($ = {}));
|
|
3729
3971
|
|
|
3730
3972
|
;
|
|
3731
3973
|
"use strict";
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
$.$mol_after_frame = $mol_after_mock_commmon;
|
|
3736
|
-
});
|
|
3737
|
-
})($ || ($ = {}));
|
|
3974
|
+
|
|
3975
|
+
;
|
|
3976
|
+
"use strict";
|
|
3738
3977
|
|
|
3739
3978
|
;
|
|
3740
3979
|
"use strict";
|
|
@@ -4149,83 +4388,6 @@ var $;
|
|
|
4149
4388
|
});
|
|
4150
4389
|
})($ || ($ = {}));
|
|
4151
4390
|
|
|
4152
|
-
;
|
|
4153
|
-
"use strict";
|
|
4154
|
-
|
|
4155
|
-
;
|
|
4156
|
-
"use strict";
|
|
4157
|
-
|
|
4158
|
-
;
|
|
4159
|
-
"use strict";
|
|
4160
|
-
var $;
|
|
4161
|
-
(function ($_1) {
|
|
4162
|
-
$mol_test({
|
|
4163
|
-
'test types'($) {
|
|
4164
|
-
class A {
|
|
4165
|
-
static a() {
|
|
4166
|
-
return Promise.resolve('');
|
|
4167
|
-
}
|
|
4168
|
-
static b() {
|
|
4169
|
-
return $mol_wire_sync(this).a();
|
|
4170
|
-
}
|
|
4171
|
-
}
|
|
4172
|
-
},
|
|
4173
|
-
});
|
|
4174
|
-
})($ || ($ = {}));
|
|
4175
|
-
|
|
4176
|
-
;
|
|
4177
|
-
"use strict";
|
|
4178
|
-
var $;
|
|
4179
|
-
(function ($_1) {
|
|
4180
|
-
$mol_test({
|
|
4181
|
-
'test types'($) {
|
|
4182
|
-
class A {
|
|
4183
|
-
static a() {
|
|
4184
|
-
return '';
|
|
4185
|
-
}
|
|
4186
|
-
static b() {
|
|
4187
|
-
return $mol_wire_async(this).a();
|
|
4188
|
-
}
|
|
4189
|
-
}
|
|
4190
|
-
},
|
|
4191
|
-
async 'Latest method calls wins'($) {
|
|
4192
|
-
class NameLogger extends $mol_object2 {
|
|
4193
|
-
static $ = $;
|
|
4194
|
-
static first = [];
|
|
4195
|
-
static last = [];
|
|
4196
|
-
static send(next) {
|
|
4197
|
-
$mol_wire_sync(this.first).push(next);
|
|
4198
|
-
this.$.$mol_wait_timeout(0);
|
|
4199
|
-
this.last.push(next);
|
|
4200
|
-
}
|
|
4201
|
-
}
|
|
4202
|
-
const name = $mol_wire_async(NameLogger).send;
|
|
4203
|
-
name('john');
|
|
4204
|
-
const promise = name('jin');
|
|
4205
|
-
$.$mol_after_mock_warp();
|
|
4206
|
-
await promise;
|
|
4207
|
-
$mol_assert_like(NameLogger.first, ['john', 'jin']);
|
|
4208
|
-
$mol_assert_like(NameLogger.last, ['jin']);
|
|
4209
|
-
},
|
|
4210
|
-
async 'Latest function calls wins'($) {
|
|
4211
|
-
const first = [];
|
|
4212
|
-
const last = [];
|
|
4213
|
-
function send_name(next) {
|
|
4214
|
-
$mol_wire_sync(first).push(next);
|
|
4215
|
-
$.$mol_wait_timeout(0);
|
|
4216
|
-
last.push(next);
|
|
4217
|
-
}
|
|
4218
|
-
const name = $mol_wire_async(send_name);
|
|
4219
|
-
name('john');
|
|
4220
|
-
const promise = name('jin');
|
|
4221
|
-
$.$mol_after_mock_warp();
|
|
4222
|
-
await promise;
|
|
4223
|
-
$mol_assert_like(first, ['john', 'jin']);
|
|
4224
|
-
$mol_assert_like(last, ['jin']);
|
|
4225
|
-
},
|
|
4226
|
-
});
|
|
4227
|
-
})($ || ($ = {}));
|
|
4228
|
-
|
|
4229
4391
|
;
|
|
4230
4392
|
"use strict";
|
|
4231
4393
|
var $;
|