mol_wire_lib 1.0.96 → 1.0.99
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 +33 -35
- package/node.deps.json +1 -1
- package/node.esm.js +187 -198
- package/node.esm.js.map +1 -1
- package/node.js +187 -198
- package/node.js.map +1 -1
- package/node.test.js +276 -253
- package/node.test.js.map +1 -1
- package/package.json +5 -5
- package/web.d.ts +33 -35
- package/web.deps.json +1 -1
- package/web.esm.js +187 -198
- package/web.esm.js.map +1 -1
- package/web.js +187 -198
- package/web.js.map +1 -1
- package/web.test.js +89 -55
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -85,7 +85,7 @@ var $;
|
|
|
85
85
|
$mol_wire_auto()?.track_next(this);
|
|
86
86
|
}
|
|
87
87
|
refresh() { }
|
|
88
|
-
|
|
88
|
+
complete() { }
|
|
89
89
|
emit(quant = $mol_wire_cursor.stale) {
|
|
90
90
|
for (let i = this.sub_from; i < this.length; i += 2) {
|
|
91
91
|
;
|
|
@@ -330,14 +330,12 @@ var $;
|
|
|
330
330
|
}
|
|
331
331
|
this.sub_from = this.cursor;
|
|
332
332
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
commit_pubs() {
|
|
333
|
+
complete() { }
|
|
334
|
+
complete_pubs() {
|
|
337
335
|
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
|
338
336
|
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
339
337
|
const pub = this[cursor];
|
|
340
|
-
pub?.
|
|
338
|
+
pub?.complete();
|
|
341
339
|
}
|
|
342
340
|
}
|
|
343
341
|
absorb(quant = $mol_wire_cursor.stale) {
|
|
@@ -681,84 +679,6 @@ var $;
|
|
|
681
679
|
;
|
|
682
680
|
"use strict";
|
|
683
681
|
var $;
|
|
684
|
-
(function ($) {
|
|
685
|
-
function $mol_guid(length = 8, exists = () => false) {
|
|
686
|
-
for (;;) {
|
|
687
|
-
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
688
|
-
if (exists(id))
|
|
689
|
-
continue;
|
|
690
|
-
return id;
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
$.$mol_guid = $mol_guid;
|
|
694
|
-
})($ || ($ = {}));
|
|
695
|
-
//mol/guid/guid.ts
|
|
696
|
-
;
|
|
697
|
-
"use strict";
|
|
698
|
-
var $;
|
|
699
|
-
(function ($) {
|
|
700
|
-
$.$mol_key_store = new WeakMap();
|
|
701
|
-
function $mol_key(value) {
|
|
702
|
-
if (!value)
|
|
703
|
-
return JSON.stringify(value);
|
|
704
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
705
|
-
return JSON.stringify(value);
|
|
706
|
-
return JSON.stringify(value, (field, value) => {
|
|
707
|
-
if (!value)
|
|
708
|
-
return value;
|
|
709
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
710
|
-
return value;
|
|
711
|
-
if (Array.isArray(value))
|
|
712
|
-
return value;
|
|
713
|
-
const proto = Reflect.getPrototypeOf(value);
|
|
714
|
-
if (!proto)
|
|
715
|
-
return value;
|
|
716
|
-
if (Reflect.getPrototypeOf(proto) === null)
|
|
717
|
-
return value;
|
|
718
|
-
if ('toJSON' in value)
|
|
719
|
-
return value;
|
|
720
|
-
if (value instanceof RegExp)
|
|
721
|
-
return value.toString();
|
|
722
|
-
let key = $.$mol_key_store.get(value);
|
|
723
|
-
if (key)
|
|
724
|
-
return key;
|
|
725
|
-
key = $mol_guid();
|
|
726
|
-
$.$mol_key_store.set(value, key);
|
|
727
|
-
return key;
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
$.$mol_key = $mol_key;
|
|
731
|
-
})($ || ($ = {}));
|
|
732
|
-
//mol/key/key.ts
|
|
733
|
-
;
|
|
734
|
-
"use strict";
|
|
735
|
-
var $;
|
|
736
|
-
(function ($) {
|
|
737
|
-
function $mol_wire_method(host, field, descr) {
|
|
738
|
-
if (!descr)
|
|
739
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
740
|
-
const orig = descr?.value ?? host[field];
|
|
741
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
742
|
-
if (typeof sup[field] === 'function') {
|
|
743
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
744
|
-
}
|
|
745
|
-
const temp = $mol_wire_fiber_temp.getter(orig);
|
|
746
|
-
const value = function (...args) {
|
|
747
|
-
const fiber = temp(this ?? null, args);
|
|
748
|
-
return fiber.sync();
|
|
749
|
-
};
|
|
750
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
751
|
-
Object.assign(value, { orig });
|
|
752
|
-
const descr2 = { ...descr, value };
|
|
753
|
-
Reflect.defineProperty(host, field, descr2);
|
|
754
|
-
return descr2;
|
|
755
|
-
}
|
|
756
|
-
$.$mol_wire_method = $mol_wire_method;
|
|
757
|
-
})($ || ($ = {}));
|
|
758
|
-
//mol/wire/method/method.ts
|
|
759
|
-
;
|
|
760
|
-
"use strict";
|
|
761
|
-
var $;
|
|
762
682
|
(function ($) {
|
|
763
683
|
const handled = new WeakSet();
|
|
764
684
|
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
@@ -933,15 +853,12 @@ var $;
|
|
|
933
853
|
if (next instanceof Promise)
|
|
934
854
|
return next;
|
|
935
855
|
if (this instanceof $mol_wire_fiber_persist) {
|
|
936
|
-
this.
|
|
856
|
+
this.complete_pubs();
|
|
937
857
|
}
|
|
938
858
|
else {
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
else {
|
|
943
|
-
this.commit_pubs();
|
|
944
|
-
}
|
|
859
|
+
this.cursor = $mol_wire_cursor.final;
|
|
860
|
+
if (this.sub_empty)
|
|
861
|
+
this.destructor();
|
|
945
862
|
}
|
|
946
863
|
return next;
|
|
947
864
|
}
|
|
@@ -975,87 +892,6 @@ var $;
|
|
|
975
892
|
}
|
|
976
893
|
}
|
|
977
894
|
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
978
|
-
class $mol_wire_fiber_temp extends $mol_wire_fiber {
|
|
979
|
-
static getter(task) {
|
|
980
|
-
return function $mol_wire_fiber_temp_get(host, args) {
|
|
981
|
-
const existen = $mol_wire_auto()?.track_next();
|
|
982
|
-
reuse: if (existen) {
|
|
983
|
-
if (!(existen instanceof $mol_wire_fiber_temp))
|
|
984
|
-
break reuse;
|
|
985
|
-
if (existen.host !== host)
|
|
986
|
-
break reuse;
|
|
987
|
-
if (existen.task !== task)
|
|
988
|
-
break reuse;
|
|
989
|
-
if (!$mol_compare_deep(existen.args, args))
|
|
990
|
-
break reuse;
|
|
991
|
-
return existen;
|
|
992
|
-
}
|
|
993
|
-
return new $mol_wire_fiber_temp(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
|
|
994
|
-
};
|
|
995
|
-
}
|
|
996
|
-
commit() {
|
|
997
|
-
super.commit();
|
|
998
|
-
this.destructor();
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
$.$mol_wire_fiber_temp = $mol_wire_fiber_temp;
|
|
1002
|
-
class $mol_wire_fiber_persist extends $mol_wire_fiber {
|
|
1003
|
-
static getter(task, keys) {
|
|
1004
|
-
const field = task.name + '()';
|
|
1005
|
-
if (keys) {
|
|
1006
|
-
return function $mol_wire_fiber_persist_get(host, args) {
|
|
1007
|
-
let dict, key, fiber;
|
|
1008
|
-
key = `${host?.[Symbol.toStringTag] ?? host}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
|
|
1009
|
-
dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1010
|
-
if (dict) {
|
|
1011
|
-
const existen = dict.get(key);
|
|
1012
|
-
if (existen)
|
|
1013
|
-
return existen;
|
|
1014
|
-
}
|
|
1015
|
-
else {
|
|
1016
|
-
dict = (host ?? task)[field] = new Map();
|
|
1017
|
-
}
|
|
1018
|
-
fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
|
|
1019
|
-
dict.set(key, fiber);
|
|
1020
|
-
return fiber;
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
else {
|
|
1024
|
-
return function $mol_wire_fiber_persist_get(host, args) {
|
|
1025
|
-
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1026
|
-
if (existen)
|
|
1027
|
-
return existen;
|
|
1028
|
-
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
1029
|
-
const fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
|
|
1030
|
-
(host ?? task)[field] = fiber;
|
|
1031
|
-
return fiber;
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
recall(...args) {
|
|
1036
|
-
return this.put(this.task.call(this.host, ...args));
|
|
1037
|
-
}
|
|
1038
|
-
commit() { }
|
|
1039
|
-
destructor() {
|
|
1040
|
-
super.destructor();
|
|
1041
|
-
const prev = this.cache;
|
|
1042
|
-
if ($mol_owning_check(this, prev)) {
|
|
1043
|
-
prev.destructor();
|
|
1044
|
-
}
|
|
1045
|
-
if (this.pub_from === 0) {
|
|
1046
|
-
;
|
|
1047
|
-
(this.host ?? this.task)[this.field()] = null;
|
|
1048
|
-
}
|
|
1049
|
-
else {
|
|
1050
|
-
;
|
|
1051
|
-
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
__decorate([
|
|
1056
|
-
$mol_wire_method
|
|
1057
|
-
], $mol_wire_fiber_persist.prototype, "recall", null);
|
|
1058
|
-
$.$mol_wire_fiber_persist = $mol_wire_fiber_persist;
|
|
1059
895
|
})($ || ($ = {}));
|
|
1060
896
|
//mol/wire/fiber/fiber.ts
|
|
1061
897
|
;
|
|
@@ -1089,6 +925,35 @@ var $;
|
|
|
1089
925
|
;
|
|
1090
926
|
"use strict";
|
|
1091
927
|
var $;
|
|
928
|
+
(function ($) {
|
|
929
|
+
class $mol_wire_fiber_temp extends $mol_wire_fiber {
|
|
930
|
+
static getter(task) {
|
|
931
|
+
return function $mol_wire_fiber_temp_get(host, args) {
|
|
932
|
+
const existen = $mol_wire_auto()?.track_next();
|
|
933
|
+
reuse: if (existen) {
|
|
934
|
+
if (!(existen instanceof $mol_wire_fiber_temp))
|
|
935
|
+
break reuse;
|
|
936
|
+
if (existen.host !== host)
|
|
937
|
+
break reuse;
|
|
938
|
+
if (existen.task !== task)
|
|
939
|
+
break reuse;
|
|
940
|
+
if (!$mol_compare_deep(existen.args, args))
|
|
941
|
+
break reuse;
|
|
942
|
+
return existen;
|
|
943
|
+
}
|
|
944
|
+
return new $mol_wire_fiber_temp(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, ...args);
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
complete() {
|
|
948
|
+
this.destructor();
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
$.$mol_wire_fiber_temp = $mol_wire_fiber_temp;
|
|
952
|
+
})($ || ($ = {}));
|
|
953
|
+
//mol/wire/fiber/temp/temp.ts
|
|
954
|
+
;
|
|
955
|
+
"use strict";
|
|
956
|
+
var $;
|
|
1092
957
|
(function ($) {
|
|
1093
958
|
function $mol_wire_sync(obj) {
|
|
1094
959
|
return new Proxy(obj, {
|
|
@@ -1134,33 +999,157 @@ var $;
|
|
|
1134
999
|
"use strict";
|
|
1135
1000
|
var $;
|
|
1136
1001
|
(function ($) {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
return
|
|
1143
|
-
|
|
1144
|
-
return true;
|
|
1002
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
1003
|
+
for (;;) {
|
|
1004
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1005
|
+
if (exists(id))
|
|
1006
|
+
continue;
|
|
1007
|
+
return id;
|
|
1008
|
+
}
|
|
1145
1009
|
}
|
|
1146
|
-
$.$
|
|
1010
|
+
$.$mol_guid = $mol_guid;
|
|
1147
1011
|
})($ || ($ = {}));
|
|
1148
|
-
//mol/
|
|
1012
|
+
//mol/guid/guid.ts
|
|
1149
1013
|
;
|
|
1150
1014
|
"use strict";
|
|
1151
1015
|
var $;
|
|
1152
1016
|
(function ($) {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
return
|
|
1017
|
+
$.$mol_key_store = new WeakMap();
|
|
1018
|
+
function $mol_key(value) {
|
|
1019
|
+
if (!value)
|
|
1020
|
+
return JSON.stringify(value);
|
|
1021
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1022
|
+
return JSON.stringify(value);
|
|
1023
|
+
return JSON.stringify(value, (field, value) => {
|
|
1024
|
+
if (!value)
|
|
1025
|
+
return value;
|
|
1026
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1027
|
+
return value;
|
|
1028
|
+
if (Array.isArray(value))
|
|
1029
|
+
return value;
|
|
1030
|
+
const proto = Reflect.getPrototypeOf(value);
|
|
1031
|
+
if (!proto)
|
|
1032
|
+
return value;
|
|
1033
|
+
if (Reflect.getPrototypeOf(proto) === null)
|
|
1034
|
+
return value;
|
|
1035
|
+
if ('toJSON' in value)
|
|
1036
|
+
return value;
|
|
1037
|
+
if (value instanceof RegExp)
|
|
1038
|
+
return value.toString();
|
|
1039
|
+
let key = $.$mol_key_store.get(value);
|
|
1040
|
+
if (key)
|
|
1041
|
+
return key;
|
|
1042
|
+
key = $mol_guid();
|
|
1043
|
+
$.$mol_key_store.set(value, key);
|
|
1044
|
+
return key;
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
$.$mol_key = $mol_key;
|
|
1048
|
+
})($ || ($ = {}));
|
|
1049
|
+
//mol/key/key.ts
|
|
1050
|
+
;
|
|
1051
|
+
"use strict";
|
|
1052
|
+
var $;
|
|
1053
|
+
(function ($) {
|
|
1054
|
+
function $mol_wire_method(host, field, descr) {
|
|
1055
|
+
if (!descr)
|
|
1056
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1057
|
+
const orig = descr?.value ?? host[field];
|
|
1058
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1059
|
+
if (typeof sup[field] === 'function') {
|
|
1060
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1061
|
+
}
|
|
1062
|
+
const temp = $mol_wire_fiber_temp.getter(orig);
|
|
1063
|
+
const value = function (...args) {
|
|
1064
|
+
const fiber = temp(this ?? null, args);
|
|
1065
|
+
return fiber.sync();
|
|
1066
|
+
};
|
|
1067
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1068
|
+
Object.assign(value, { orig });
|
|
1069
|
+
const descr2 = { ...descr, value };
|
|
1070
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1071
|
+
return descr2;
|
|
1160
1072
|
}
|
|
1161
|
-
$.$
|
|
1073
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
1162
1074
|
})($ || ($ = {}));
|
|
1163
|
-
//mol/
|
|
1075
|
+
//mol/wire/method/method.ts
|
|
1076
|
+
;
|
|
1077
|
+
"use strict";
|
|
1078
|
+
var $;
|
|
1079
|
+
(function ($) {
|
|
1080
|
+
class $mol_wire_fiber_persist extends $mol_wire_fiber {
|
|
1081
|
+
static getter(task, keys) {
|
|
1082
|
+
const field = task.name + '()';
|
|
1083
|
+
if (keys) {
|
|
1084
|
+
return function $mol_wire_fiber_persist_get(host, args) {
|
|
1085
|
+
let dict, key, fiber;
|
|
1086
|
+
key = `${host?.[Symbol.toStringTag] ?? host}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
|
|
1087
|
+
dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1088
|
+
if (dict) {
|
|
1089
|
+
const existen = dict.get(key);
|
|
1090
|
+
if (existen)
|
|
1091
|
+
return existen;
|
|
1092
|
+
}
|
|
1093
|
+
else {
|
|
1094
|
+
dict = (host ?? task)[field] = new Map();
|
|
1095
|
+
}
|
|
1096
|
+
fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
|
|
1097
|
+
dict.set(key, fiber);
|
|
1098
|
+
return fiber;
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
else {
|
|
1102
|
+
return function $mol_wire_fiber_persist_get(host, args) {
|
|
1103
|
+
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1104
|
+
if (existen)
|
|
1105
|
+
return existen;
|
|
1106
|
+
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
1107
|
+
const fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
|
|
1108
|
+
(host ?? task)[field] = fiber;
|
|
1109
|
+
return fiber;
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
recall(...args) {
|
|
1114
|
+
if (this.cursor > $mol_wire_cursor.fresh) {
|
|
1115
|
+
try {
|
|
1116
|
+
this.once();
|
|
1117
|
+
}
|
|
1118
|
+
catch (error) {
|
|
1119
|
+
if (error instanceof Promise)
|
|
1120
|
+
$mol_fail_hidden(error);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
return this.put(this.task.call(this.host, ...args));
|
|
1124
|
+
}
|
|
1125
|
+
once() {
|
|
1126
|
+
return this.sync();
|
|
1127
|
+
}
|
|
1128
|
+
destructor() {
|
|
1129
|
+
super.destructor();
|
|
1130
|
+
const prev = this.cache;
|
|
1131
|
+
if ($mol_owning_check(this, prev)) {
|
|
1132
|
+
prev.destructor();
|
|
1133
|
+
}
|
|
1134
|
+
if (this.pub_from === 0) {
|
|
1135
|
+
;
|
|
1136
|
+
(this.host ?? this.task)[this.field()] = null;
|
|
1137
|
+
}
|
|
1138
|
+
else {
|
|
1139
|
+
;
|
|
1140
|
+
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
__decorate([
|
|
1145
|
+
$mol_wire_method
|
|
1146
|
+
], $mol_wire_fiber_persist.prototype, "recall", null);
|
|
1147
|
+
__decorate([
|
|
1148
|
+
$mol_wire_method
|
|
1149
|
+
], $mol_wire_fiber_persist.prototype, "once", null);
|
|
1150
|
+
$.$mol_wire_fiber_persist = $mol_wire_fiber_persist;
|
|
1151
|
+
})($ || ($ = {}));
|
|
1152
|
+
//mol/wire/fiber/persist/persist.ts
|
|
1164
1153
|
;
|
|
1165
1154
|
"use strict";
|
|
1166
1155
|
var $;
|
|
@@ -1189,13 +1178,13 @@ var $;
|
|
|
1189
1178
|
const persist = $mol_wire_fiber_persist.getter(func, keys);
|
|
1190
1179
|
const wrapper = function (...args) {
|
|
1191
1180
|
let atom = persist(this, args.slice(0, keys));
|
|
1192
|
-
if (args.length <= keys || args[keys] === undefined)
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1181
|
+
if (args.length <= keys || args[keys] === undefined) {
|
|
1182
|
+
if ($mol_wire_auto() instanceof $mol_wire_fiber_temp) {
|
|
1183
|
+
return atom.once();
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
return atom.sync();
|
|
1187
|
+
}
|
|
1199
1188
|
}
|
|
1200
1189
|
return atom.recall(...args);
|
|
1201
1190
|
};
|
|
@@ -2361,61 +2350,6 @@ var $;
|
|
|
2361
2350
|
;
|
|
2362
2351
|
"use strict";
|
|
2363
2352
|
var $;
|
|
2364
|
-
(function ($) {
|
|
2365
|
-
$mol_test({
|
|
2366
|
-
'Primitives'() {
|
|
2367
|
-
$mol_assert_equal($mol_key(null), 'null');
|
|
2368
|
-
$mol_assert_equal($mol_key(false), 'false');
|
|
2369
|
-
$mol_assert_equal($mol_key(true), 'true');
|
|
2370
|
-
$mol_assert_equal($mol_key(0), '0');
|
|
2371
|
-
$mol_assert_equal($mol_key(''), '""');
|
|
2372
|
-
},
|
|
2373
|
-
'Array & POJO'() {
|
|
2374
|
-
$mol_assert_equal($mol_key([null]), '[null]');
|
|
2375
|
-
$mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
|
|
2376
|
-
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
2377
|
-
},
|
|
2378
|
-
'Function'() {
|
|
2379
|
-
const func = () => { };
|
|
2380
|
-
$mol_assert_equal($mol_key(func), $mol_key(func));
|
|
2381
|
-
$mol_assert_unique($mol_key(func), $mol_key(() => { }));
|
|
2382
|
-
},
|
|
2383
|
-
'Objects'() {
|
|
2384
|
-
class User {
|
|
2385
|
-
}
|
|
2386
|
-
const jin = new User();
|
|
2387
|
-
$mol_assert_equal($mol_key(jin), $mol_key(jin));
|
|
2388
|
-
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
2389
|
-
},
|
|
2390
|
-
'Elements'() {
|
|
2391
|
-
const foo = $mol_jsx("div", null, "bar");
|
|
2392
|
-
$mol_assert_equal($mol_key(foo), $mol_key(foo));
|
|
2393
|
-
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
2394
|
-
},
|
|
2395
|
-
'Custom JSON representation'() {
|
|
2396
|
-
class User {
|
|
2397
|
-
name;
|
|
2398
|
-
age;
|
|
2399
|
-
constructor(name, age) {
|
|
2400
|
-
this.name = name;
|
|
2401
|
-
this.age = age;
|
|
2402
|
-
}
|
|
2403
|
-
toJSON() { return { name: this.name }; }
|
|
2404
|
-
}
|
|
2405
|
-
$mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
2406
|
-
},
|
|
2407
|
-
'Special native classes'() {
|
|
2408
|
-
$mol_assert_equal($mol_key(new Date('xyz')), 'null');
|
|
2409
|
-
$mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
2410
|
-
$mol_assert_equal($mol_key(/./), '"/./"');
|
|
2411
|
-
$mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
2412
|
-
},
|
|
2413
|
-
});
|
|
2414
|
-
})($ || ($ = {}));
|
|
2415
|
-
//mol/key/key.test.tsx
|
|
2416
|
-
;
|
|
2417
|
-
"use strict";
|
|
2418
|
-
var $;
|
|
2419
2353
|
(function ($) {
|
|
2420
2354
|
$mol_test({
|
|
2421
2355
|
'Sync execution'() {
|
|
@@ -2498,6 +2432,61 @@ var $;
|
|
|
2498
2432
|
;
|
|
2499
2433
|
"use strict";
|
|
2500
2434
|
var $;
|
|
2435
|
+
(function ($) {
|
|
2436
|
+
$mol_test({
|
|
2437
|
+
'Primitives'() {
|
|
2438
|
+
$mol_assert_equal($mol_key(null), 'null');
|
|
2439
|
+
$mol_assert_equal($mol_key(false), 'false');
|
|
2440
|
+
$mol_assert_equal($mol_key(true), 'true');
|
|
2441
|
+
$mol_assert_equal($mol_key(0), '0');
|
|
2442
|
+
$mol_assert_equal($mol_key(''), '""');
|
|
2443
|
+
},
|
|
2444
|
+
'Array & POJO'() {
|
|
2445
|
+
$mol_assert_equal($mol_key([null]), '[null]');
|
|
2446
|
+
$mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
|
|
2447
|
+
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
2448
|
+
},
|
|
2449
|
+
'Function'() {
|
|
2450
|
+
const func = () => { };
|
|
2451
|
+
$mol_assert_equal($mol_key(func), $mol_key(func));
|
|
2452
|
+
$mol_assert_unique($mol_key(func), $mol_key(() => { }));
|
|
2453
|
+
},
|
|
2454
|
+
'Objects'() {
|
|
2455
|
+
class User {
|
|
2456
|
+
}
|
|
2457
|
+
const jin = new User();
|
|
2458
|
+
$mol_assert_equal($mol_key(jin), $mol_key(jin));
|
|
2459
|
+
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
2460
|
+
},
|
|
2461
|
+
'Elements'() {
|
|
2462
|
+
const foo = $mol_jsx("div", null, "bar");
|
|
2463
|
+
$mol_assert_equal($mol_key(foo), $mol_key(foo));
|
|
2464
|
+
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
2465
|
+
},
|
|
2466
|
+
'Custom JSON representation'() {
|
|
2467
|
+
class User {
|
|
2468
|
+
name;
|
|
2469
|
+
age;
|
|
2470
|
+
constructor(name, age) {
|
|
2471
|
+
this.name = name;
|
|
2472
|
+
this.age = age;
|
|
2473
|
+
}
|
|
2474
|
+
toJSON() { return { name: this.name }; }
|
|
2475
|
+
}
|
|
2476
|
+
$mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
2477
|
+
},
|
|
2478
|
+
'Special native classes'() {
|
|
2479
|
+
$mol_assert_equal($mol_key(new Date('xyz')), 'null');
|
|
2480
|
+
$mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
2481
|
+
$mol_assert_equal($mol_key(/./), '"/./"');
|
|
2482
|
+
$mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
2483
|
+
},
|
|
2484
|
+
});
|
|
2485
|
+
})($ || ($ = {}));
|
|
2486
|
+
//mol/key/key.test.tsx
|
|
2487
|
+
;
|
|
2488
|
+
"use strict";
|
|
2489
|
+
var $;
|
|
2501
2490
|
(function ($_1) {
|
|
2502
2491
|
$mol_test({
|
|
2503
2492
|
'Cached channel'($) {
|
|
@@ -2741,6 +2730,40 @@ var $;
|
|
|
2741
2730
|
App.count(5);
|
|
2742
2731
|
$mol_assert_like(App.res(), 6);
|
|
2743
2732
|
},
|
|
2733
|
+
async 'Toggle with async'($) {
|
|
2734
|
+
class App extends $mol_object2 {
|
|
2735
|
+
static $ = $;
|
|
2736
|
+
static checked(next = false) {
|
|
2737
|
+
$$.$mol_wait_timeout(0);
|
|
2738
|
+
return next;
|
|
2739
|
+
}
|
|
2740
|
+
static toggle() {
|
|
2741
|
+
const prev = this.checked();
|
|
2742
|
+
$mol_assert_unique(this.checked(!prev), prev);
|
|
2743
|
+
}
|
|
2744
|
+
static res() {
|
|
2745
|
+
return this.checked();
|
|
2746
|
+
}
|
|
2747
|
+
static test() {
|
|
2748
|
+
$mol_assert_equal(App.res(), false);
|
|
2749
|
+
App.toggle();
|
|
2750
|
+
$mol_assert_equal(App.res(), true);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
__decorate([
|
|
2754
|
+
$mol_wire_mem(0)
|
|
2755
|
+
], App, "checked", null);
|
|
2756
|
+
__decorate([
|
|
2757
|
+
$mol_wire_method
|
|
2758
|
+
], App, "toggle", null);
|
|
2759
|
+
__decorate([
|
|
2760
|
+
$mol_wire_mem(0)
|
|
2761
|
+
], App, "res", null);
|
|
2762
|
+
__decorate([
|
|
2763
|
+
$mol_wire_method
|
|
2764
|
+
], App, "test", null);
|
|
2765
|
+
await $mol_wire_async(App).test();
|
|
2766
|
+
},
|
|
2744
2767
|
'Restore after error'($) {
|
|
2745
2768
|
class App extends $mol_object2 {
|
|
2746
2769
|
static get $() { return $; }
|