mol_wire_lib 1.0.97 → 1.0.100
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 +188 -198
- package/node.esm.js.map +1 -1
- package/node.js +188 -198
- package/node.js.map +1 -1
- package/node.test.js +277 -303
- 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 +188 -198
- package/web.esm.js.map +1 -1
- package/web.js +188 -198
- package/web.js.map +1 -1
- package/web.test.js +89 -105
- 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,36 @@ 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
|
+
if (this.sub_empty)
|
|
949
|
+
this.destructor();
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
$.$mol_wire_fiber_temp = $mol_wire_fiber_temp;
|
|
953
|
+
})($ || ($ = {}));
|
|
954
|
+
//mol/wire/fiber/temp/temp.ts
|
|
955
|
+
;
|
|
956
|
+
"use strict";
|
|
957
|
+
var $;
|
|
1092
958
|
(function ($) {
|
|
1093
959
|
function $mol_wire_sync(obj) {
|
|
1094
960
|
return new Proxy(obj, {
|
|
@@ -1134,33 +1000,157 @@ var $;
|
|
|
1134
1000
|
"use strict";
|
|
1135
1001
|
var $;
|
|
1136
1002
|
(function ($) {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
return
|
|
1143
|
-
|
|
1144
|
-
return true;
|
|
1003
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
1004
|
+
for (;;) {
|
|
1005
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1006
|
+
if (exists(id))
|
|
1007
|
+
continue;
|
|
1008
|
+
return id;
|
|
1009
|
+
}
|
|
1145
1010
|
}
|
|
1146
|
-
$.$
|
|
1011
|
+
$.$mol_guid = $mol_guid;
|
|
1147
1012
|
})($ || ($ = {}));
|
|
1148
|
-
//mol/
|
|
1013
|
+
//mol/guid/guid.ts
|
|
1149
1014
|
;
|
|
1150
1015
|
"use strict";
|
|
1151
1016
|
var $;
|
|
1152
1017
|
(function ($) {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
return
|
|
1018
|
+
$.$mol_key_store = new WeakMap();
|
|
1019
|
+
function $mol_key(value) {
|
|
1020
|
+
if (!value)
|
|
1021
|
+
return JSON.stringify(value);
|
|
1022
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1023
|
+
return JSON.stringify(value);
|
|
1024
|
+
return JSON.stringify(value, (field, value) => {
|
|
1025
|
+
if (!value)
|
|
1026
|
+
return value;
|
|
1027
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1028
|
+
return value;
|
|
1029
|
+
if (Array.isArray(value))
|
|
1030
|
+
return value;
|
|
1031
|
+
const proto = Reflect.getPrototypeOf(value);
|
|
1032
|
+
if (!proto)
|
|
1033
|
+
return value;
|
|
1034
|
+
if (Reflect.getPrototypeOf(proto) === null)
|
|
1035
|
+
return value;
|
|
1036
|
+
if ('toJSON' in value)
|
|
1037
|
+
return value;
|
|
1038
|
+
if (value instanceof RegExp)
|
|
1039
|
+
return value.toString();
|
|
1040
|
+
let key = $.$mol_key_store.get(value);
|
|
1041
|
+
if (key)
|
|
1042
|
+
return key;
|
|
1043
|
+
key = $mol_guid();
|
|
1044
|
+
$.$mol_key_store.set(value, key);
|
|
1045
|
+
return key;
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
$.$mol_key = $mol_key;
|
|
1049
|
+
})($ || ($ = {}));
|
|
1050
|
+
//mol/key/key.ts
|
|
1051
|
+
;
|
|
1052
|
+
"use strict";
|
|
1053
|
+
var $;
|
|
1054
|
+
(function ($) {
|
|
1055
|
+
function $mol_wire_method(host, field, descr) {
|
|
1056
|
+
if (!descr)
|
|
1057
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1058
|
+
const orig = descr?.value ?? host[field];
|
|
1059
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1060
|
+
if (typeof sup[field] === 'function') {
|
|
1061
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1062
|
+
}
|
|
1063
|
+
const temp = $mol_wire_fiber_temp.getter(orig);
|
|
1064
|
+
const value = function (...args) {
|
|
1065
|
+
const fiber = temp(this ?? null, args);
|
|
1066
|
+
return fiber.sync();
|
|
1067
|
+
};
|
|
1068
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1069
|
+
Object.assign(value, { orig });
|
|
1070
|
+
const descr2 = { ...descr, value };
|
|
1071
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1072
|
+
return descr2;
|
|
1073
|
+
}
|
|
1074
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
1075
|
+
})($ || ($ = {}));
|
|
1076
|
+
//mol/wire/method/method.ts
|
|
1077
|
+
;
|
|
1078
|
+
"use strict";
|
|
1079
|
+
var $;
|
|
1080
|
+
(function ($) {
|
|
1081
|
+
class $mol_wire_fiber_persist extends $mol_wire_fiber {
|
|
1082
|
+
static getter(task, keys) {
|
|
1083
|
+
const field = task.name + '()';
|
|
1084
|
+
if (keys) {
|
|
1085
|
+
return function $mol_wire_fiber_persist_get(host, args) {
|
|
1086
|
+
let dict, key, fiber;
|
|
1087
|
+
key = `${host?.[Symbol.toStringTag] ?? host}.${task.name}(${args.map(v => $mol_key(v)).join(',')})`;
|
|
1088
|
+
dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1089
|
+
if (dict) {
|
|
1090
|
+
const existen = dict.get(key);
|
|
1091
|
+
if (existen)
|
|
1092
|
+
return existen;
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
dict = (host ?? task)[field] = new Map();
|
|
1096
|
+
}
|
|
1097
|
+
fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
|
|
1098
|
+
dict.set(key, fiber);
|
|
1099
|
+
return fiber;
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
else {
|
|
1103
|
+
return function $mol_wire_fiber_persist_get(host, args) {
|
|
1104
|
+
const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
|
|
1105
|
+
if (existen)
|
|
1106
|
+
return existen;
|
|
1107
|
+
const key = `${host?.[Symbol.toStringTag] ?? host}.${field}`;
|
|
1108
|
+
const fiber = new $mol_wire_fiber_persist(key, task, host, ...args);
|
|
1109
|
+
(host ?? task)[field] = fiber;
|
|
1110
|
+
return fiber;
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
recall(...args) {
|
|
1115
|
+
if (this.cursor > $mol_wire_cursor.fresh) {
|
|
1116
|
+
try {
|
|
1117
|
+
this.once();
|
|
1118
|
+
}
|
|
1119
|
+
catch (error) {
|
|
1120
|
+
if (error instanceof Promise)
|
|
1121
|
+
$mol_fail_hidden(error);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return this.put(this.task.call(this.host, ...args));
|
|
1125
|
+
}
|
|
1126
|
+
once() {
|
|
1127
|
+
return this.sync();
|
|
1128
|
+
}
|
|
1129
|
+
destructor() {
|
|
1130
|
+
super.destructor();
|
|
1131
|
+
const prev = this.cache;
|
|
1132
|
+
if ($mol_owning_check(this, prev)) {
|
|
1133
|
+
prev.destructor();
|
|
1134
|
+
}
|
|
1135
|
+
if (this.pub_from === 0) {
|
|
1136
|
+
;
|
|
1137
|
+
(this.host ?? this.task)[this.field()] = null;
|
|
1138
|
+
}
|
|
1139
|
+
else {
|
|
1140
|
+
;
|
|
1141
|
+
(this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1160
1144
|
}
|
|
1161
|
-
|
|
1145
|
+
__decorate([
|
|
1146
|
+
$mol_wire_method
|
|
1147
|
+
], $mol_wire_fiber_persist.prototype, "recall", null);
|
|
1148
|
+
__decorate([
|
|
1149
|
+
$mol_wire_method
|
|
1150
|
+
], $mol_wire_fiber_persist.prototype, "once", null);
|
|
1151
|
+
$.$mol_wire_fiber_persist = $mol_wire_fiber_persist;
|
|
1162
1152
|
})($ || ($ = {}));
|
|
1163
|
-
//mol/
|
|
1153
|
+
//mol/wire/fiber/persist/persist.ts
|
|
1164
1154
|
;
|
|
1165
1155
|
"use strict";
|
|
1166
1156
|
var $;
|
|
@@ -1189,13 +1179,13 @@ var $;
|
|
|
1189
1179
|
const persist = $mol_wire_fiber_persist.getter(func, keys);
|
|
1190
1180
|
const wrapper = function (...args) {
|
|
1191
1181
|
let atom = persist(this, args.slice(0, keys));
|
|
1192
|
-
if (args.length <= keys || args[keys] === undefined)
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1182
|
+
if (args.length <= keys || args[keys] === undefined) {
|
|
1183
|
+
if ($mol_wire_auto() instanceof $mol_wire_fiber_temp) {
|
|
1184
|
+
return atom.once();
|
|
1185
|
+
}
|
|
1186
|
+
else {
|
|
1187
|
+
return atom.sync();
|
|
1188
|
+
}
|
|
1199
1189
|
}
|
|
1200
1190
|
return atom.recall(...args);
|
|
1201
1191
|
};
|
|
@@ -2361,61 +2351,6 @@ var $;
|
|
|
2361
2351
|
;
|
|
2362
2352
|
"use strict";
|
|
2363
2353
|
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
2354
|
(function ($) {
|
|
2420
2355
|
$mol_test({
|
|
2421
2356
|
'Sync execution'() {
|
|
@@ -2498,6 +2433,61 @@ var $;
|
|
|
2498
2433
|
;
|
|
2499
2434
|
"use strict";
|
|
2500
2435
|
var $;
|
|
2436
|
+
(function ($) {
|
|
2437
|
+
$mol_test({
|
|
2438
|
+
'Primitives'() {
|
|
2439
|
+
$mol_assert_equal($mol_key(null), 'null');
|
|
2440
|
+
$mol_assert_equal($mol_key(false), 'false');
|
|
2441
|
+
$mol_assert_equal($mol_key(true), 'true');
|
|
2442
|
+
$mol_assert_equal($mol_key(0), '0');
|
|
2443
|
+
$mol_assert_equal($mol_key(''), '""');
|
|
2444
|
+
},
|
|
2445
|
+
'Array & POJO'() {
|
|
2446
|
+
$mol_assert_equal($mol_key([null]), '[null]');
|
|
2447
|
+
$mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
|
|
2448
|
+
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
2449
|
+
},
|
|
2450
|
+
'Function'() {
|
|
2451
|
+
const func = () => { };
|
|
2452
|
+
$mol_assert_equal($mol_key(func), $mol_key(func));
|
|
2453
|
+
$mol_assert_unique($mol_key(func), $mol_key(() => { }));
|
|
2454
|
+
},
|
|
2455
|
+
'Objects'() {
|
|
2456
|
+
class User {
|
|
2457
|
+
}
|
|
2458
|
+
const jin = new User();
|
|
2459
|
+
$mol_assert_equal($mol_key(jin), $mol_key(jin));
|
|
2460
|
+
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
2461
|
+
},
|
|
2462
|
+
'Elements'() {
|
|
2463
|
+
const foo = $mol_jsx("div", null, "bar");
|
|
2464
|
+
$mol_assert_equal($mol_key(foo), $mol_key(foo));
|
|
2465
|
+
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
2466
|
+
},
|
|
2467
|
+
'Custom JSON representation'() {
|
|
2468
|
+
class User {
|
|
2469
|
+
name;
|
|
2470
|
+
age;
|
|
2471
|
+
constructor(name, age) {
|
|
2472
|
+
this.name = name;
|
|
2473
|
+
this.age = age;
|
|
2474
|
+
}
|
|
2475
|
+
toJSON() { return { name: this.name }; }
|
|
2476
|
+
}
|
|
2477
|
+
$mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
2478
|
+
},
|
|
2479
|
+
'Special native classes'() {
|
|
2480
|
+
$mol_assert_equal($mol_key(new Date('xyz')), 'null');
|
|
2481
|
+
$mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
2482
|
+
$mol_assert_equal($mol_key(/./), '"/./"');
|
|
2483
|
+
$mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
2484
|
+
},
|
|
2485
|
+
});
|
|
2486
|
+
})($ || ($ = {}));
|
|
2487
|
+
//mol/key/key.test.tsx
|
|
2488
|
+
;
|
|
2489
|
+
"use strict";
|
|
2490
|
+
var $;
|
|
2501
2491
|
(function ($_1) {
|
|
2502
2492
|
$mol_test({
|
|
2503
2493
|
'Cached channel'($) {
|
|
@@ -2741,6 +2731,40 @@ var $;
|
|
|
2741
2731
|
App.count(5);
|
|
2742
2732
|
$mol_assert_like(App.res(), 6);
|
|
2743
2733
|
},
|
|
2734
|
+
async 'Toggle with async'($) {
|
|
2735
|
+
class App extends $mol_object2 {
|
|
2736
|
+
static $ = $;
|
|
2737
|
+
static checked(next = false) {
|
|
2738
|
+
$$.$mol_wait_timeout(0);
|
|
2739
|
+
return next;
|
|
2740
|
+
}
|
|
2741
|
+
static toggle() {
|
|
2742
|
+
const prev = this.checked();
|
|
2743
|
+
$mol_assert_unique(this.checked(!prev), prev);
|
|
2744
|
+
}
|
|
2745
|
+
static res() {
|
|
2746
|
+
return this.checked();
|
|
2747
|
+
}
|
|
2748
|
+
static test() {
|
|
2749
|
+
$mol_assert_equal(App.res(), false);
|
|
2750
|
+
App.toggle();
|
|
2751
|
+
$mol_assert_equal(App.res(), true);
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
__decorate([
|
|
2755
|
+
$mol_wire_mem(0)
|
|
2756
|
+
], App, "checked", null);
|
|
2757
|
+
__decorate([
|
|
2758
|
+
$mol_wire_method
|
|
2759
|
+
], App, "toggle", null);
|
|
2760
|
+
__decorate([
|
|
2761
|
+
$mol_wire_mem(0)
|
|
2762
|
+
], App, "res", null);
|
|
2763
|
+
__decorate([
|
|
2764
|
+
$mol_wire_method
|
|
2765
|
+
], App, "test", null);
|
|
2766
|
+
await $mol_wire_async(App).test();
|
|
2767
|
+
},
|
|
2744
2768
|
'Restore after error'($) {
|
|
2745
2769
|
class App extends $mol_object2 {
|
|
2746
2770
|
static get $() { return $; }
|
|
@@ -2874,29 +2898,6 @@ var $;
|
|
|
2874
2898
|
$mol_wire_fiber.sync();
|
|
2875
2899
|
$mol_assert_equal(await $mol_wire_async(App).result(), 1);
|
|
2876
2900
|
},
|
|
2877
|
-
'Forget sub fibers on complete'($) {
|
|
2878
|
-
class App extends $mol_object2 {
|
|
2879
|
-
static get $() { return $; }
|
|
2880
|
-
static counter = 0;
|
|
2881
|
-
static count() { return this.counter++; }
|
|
2882
|
-
static data(next = 1) { return next; }
|
|
2883
|
-
static result() {
|
|
2884
|
-
return this.count() + this.data();
|
|
2885
|
-
}
|
|
2886
|
-
}
|
|
2887
|
-
__decorate([
|
|
2888
|
-
$mol_wire_method
|
|
2889
|
-
], App, "count", null);
|
|
2890
|
-
__decorate([
|
|
2891
|
-
$mol_wire_mem(0)
|
|
2892
|
-
], App, "data", null);
|
|
2893
|
-
__decorate([
|
|
2894
|
-
$mol_wire_mem(0)
|
|
2895
|
-
], App, "result", null);
|
|
2896
|
-
$mol_assert_equal(App.result(), 1);
|
|
2897
|
-
App.data(2);
|
|
2898
|
-
$mol_assert_equal(App.result(), 3);
|
|
2899
|
-
},
|
|
2900
2901
|
'Memoize by single simple key'($) {
|
|
2901
2902
|
class Team extends $mol_object2 {
|
|
2902
2903
|
static $ = $;
|
|
@@ -3010,33 +3011,6 @@ var $;
|
|
|
3010
3011
|
$mol_assert_equal(Fib.value(4), 8);
|
|
3011
3012
|
$mol_assert_equal(Fib.sums, 6);
|
|
3012
3013
|
},
|
|
3013
|
-
'Unsubscribe from temp pubs on complete'($) {
|
|
3014
|
-
class Random extends $mol_object2 {
|
|
3015
|
-
static $ = $;
|
|
3016
|
-
static seed() {
|
|
3017
|
-
return Math.random();
|
|
3018
|
-
}
|
|
3019
|
-
static resets(next) {
|
|
3020
|
-
return Math.random();
|
|
3021
|
-
}
|
|
3022
|
-
static value() {
|
|
3023
|
-
this.resets();
|
|
3024
|
-
return this.seed();
|
|
3025
|
-
}
|
|
3026
|
-
}
|
|
3027
|
-
__decorate([
|
|
3028
|
-
$mol_wire_method
|
|
3029
|
-
], Random, "seed", null);
|
|
3030
|
-
__decorate([
|
|
3031
|
-
$mol_wire_mem(0)
|
|
3032
|
-
], Random, "resets", null);
|
|
3033
|
-
__decorate([
|
|
3034
|
-
$mol_wire_mem(0)
|
|
3035
|
-
], Random, "value", null);
|
|
3036
|
-
const first = Random.value();
|
|
3037
|
-
Random.resets(null);
|
|
3038
|
-
$mol_assert_unique(Random.value(), first);
|
|
3039
|
-
},
|
|
3040
3014
|
});
|
|
3041
3015
|
})($ || ($ = {}));
|
|
3042
3016
|
//mol/wire/mem/mem.test.ts
|