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