mol_wire_dom 0.0.1661 → 0.0.1663
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 +6 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +53 -31
- package/node.js.map +1 -1
- package/node.mjs +53 -31
- package/node.test.js +68 -40
- package/node.test.js.map +1 -1
- package/package.json +3 -2
- package/web.d.ts +6 -1
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +53 -31
- package/web.js.map +1 -1
- package/web.mjs +53 -31
- package/web.test.js +15 -9
- package/web.test.js.map +1 -1
package/web.mjs
CHANGED
|
@@ -635,6 +635,14 @@ var $;
|
|
|
635
635
|
$.$mol_func_name_from = $mol_func_name_from;
|
|
636
636
|
})($ || ($ = {}));
|
|
637
637
|
|
|
638
|
+
;
|
|
639
|
+
"use strict";
|
|
640
|
+
var $;
|
|
641
|
+
(function ($) {
|
|
642
|
+
$.$mol_key_handle = Symbol.for('$mol_key_handle');
|
|
643
|
+
$.$mol_key_store = new WeakMap();
|
|
644
|
+
})($ || ($ = {}));
|
|
645
|
+
|
|
638
646
|
;
|
|
639
647
|
"use strict";
|
|
640
648
|
var $;
|
|
@@ -671,6 +679,9 @@ var $;
|
|
|
671
679
|
static toJSON() {
|
|
672
680
|
return this.toString();
|
|
673
681
|
}
|
|
682
|
+
static [$mol_key_handle]() {
|
|
683
|
+
return this.toString();
|
|
684
|
+
}
|
|
674
685
|
destructor() { }
|
|
675
686
|
static destructor() { }
|
|
676
687
|
[Symbol.dispose]() {
|
|
@@ -984,46 +995,50 @@ var $;
|
|
|
984
995
|
"use strict";
|
|
985
996
|
var $;
|
|
986
997
|
(function ($) {
|
|
987
|
-
$.$mol_key_store = new WeakMap();
|
|
988
998
|
const TypedArray = Object.getPrototypeOf(Uint8Array);
|
|
989
999
|
function $mol_key(value) {
|
|
990
|
-
|
|
991
|
-
return value.toString() + 'n';
|
|
992
|
-
if (typeof value === 'symbol')
|
|
993
|
-
return value.description;
|
|
994
|
-
if (!value)
|
|
995
|
-
return JSON.stringify(value);
|
|
996
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
997
|
-
return JSON.stringify(value);
|
|
998
|
-
return JSON.stringify(value, (field, value) => {
|
|
1000
|
+
primitives: {
|
|
999
1001
|
if (typeof value === 'bigint')
|
|
1000
1002
|
return value.toString() + 'n';
|
|
1001
1003
|
if (typeof value === 'symbol')
|
|
1002
|
-
return value.description
|
|
1004
|
+
return `Symbol(${value.description})`;
|
|
1003
1005
|
if (!value)
|
|
1004
|
-
return value;
|
|
1006
|
+
return JSON.stringify(value);
|
|
1005
1007
|
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1006
|
-
return value;
|
|
1008
|
+
return JSON.stringify(value);
|
|
1009
|
+
}
|
|
1010
|
+
caching: {
|
|
1011
|
+
let key = $mol_key_store.get(value);
|
|
1012
|
+
if (key)
|
|
1013
|
+
return key;
|
|
1014
|
+
}
|
|
1015
|
+
objects: {
|
|
1016
|
+
if (value instanceof TypedArray) {
|
|
1017
|
+
return `${value[Symbol.toStringTag]}([${[...value].map(v => $mol_key(v))}])`;
|
|
1018
|
+
}
|
|
1007
1019
|
if (Array.isArray(value))
|
|
1008
|
-
return value
|
|
1009
|
-
const proto = Reflect.getPrototypeOf(value);
|
|
1010
|
-
if (!proto)
|
|
1011
|
-
return value;
|
|
1012
|
-
if (Reflect.getPrototypeOf(proto) === null)
|
|
1013
|
-
return value;
|
|
1014
|
-
if ('toJSON' in value)
|
|
1015
|
-
return value;
|
|
1020
|
+
return `[${value.map(v => $mol_key(v))}]`;
|
|
1016
1021
|
if (value instanceof RegExp)
|
|
1017
1022
|
return value.toString();
|
|
1018
|
-
if (value instanceof
|
|
1019
|
-
return
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1023
|
+
if (value instanceof Date)
|
|
1024
|
+
return `Date(${value.valueOf()})`;
|
|
1025
|
+
}
|
|
1026
|
+
structures: {
|
|
1027
|
+
const proto = Reflect.getPrototypeOf(value);
|
|
1028
|
+
if (!proto || !Reflect.getPrototypeOf(proto)) {
|
|
1029
|
+
return `{${Object.entries(value).map(([k, v]) => JSON.stringify(k) + ':' + $mol_key(v))}}`;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
handlers: {
|
|
1033
|
+
if ($mol_key_handle in value) {
|
|
1034
|
+
return value[$mol_key_handle]();
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
containers: {
|
|
1038
|
+
const key = JSON.stringify('#' + $mol_guid());
|
|
1039
|
+
$mol_key_store.set(value, key);
|
|
1025
1040
|
return key;
|
|
1026
|
-
}
|
|
1041
|
+
}
|
|
1027
1042
|
}
|
|
1028
1043
|
$.$mol_key = $mol_key;
|
|
1029
1044
|
})($ || ($ = {}));
|
|
@@ -1543,8 +1558,15 @@ var $;
|
|
|
1543
1558
|
(this.host ?? this.task)[this.field()] = null;
|
|
1544
1559
|
}
|
|
1545
1560
|
else {
|
|
1546
|
-
;
|
|
1547
|
-
(this.host ?? this.task)[this.field()]
|
|
1561
|
+
const key = $mol_key(this.args[0]);
|
|
1562
|
+
const map = (this.host ?? this.task)[this.field()];
|
|
1563
|
+
if (!map.has(key))
|
|
1564
|
+
this.$.$mol_log3_warn({
|
|
1565
|
+
place: this,
|
|
1566
|
+
message: 'Absent key on destruction',
|
|
1567
|
+
hint: 'Check for $mol_key(key) is not changed',
|
|
1568
|
+
});
|
|
1569
|
+
map.delete(key);
|
|
1548
1570
|
}
|
|
1549
1571
|
}
|
|
1550
1572
|
put(next) {
|
package/web.test.js
CHANGED
|
@@ -1172,9 +1172,9 @@ var $;
|
|
|
1172
1172
|
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
1173
1173
|
},
|
|
1174
1174
|
'Uint8Array'() {
|
|
1175
|
-
$mol_assert_equal($mol_key(new Uint8Array([1, 2])), '[1,2]');
|
|
1176
|
-
$mol_assert_equal($mol_key([new Uint8Array([1, 2])]), '[[1,2]]');
|
|
1177
|
-
$mol_assert_equal($mol_key({ foo: new Uint8Array([1, 2]) }), '{"foo":[1,2]}');
|
|
1175
|
+
$mol_assert_equal($mol_key(new Uint8Array([1, 2])), 'Uint8Array([1,2])');
|
|
1176
|
+
$mol_assert_equal($mol_key([new Uint8Array([1, 2])]), '[Uint8Array([1,2])]');
|
|
1177
|
+
$mol_assert_equal($mol_key({ foo: new Uint8Array([1, 2]) }), '{"foo":Uint8Array([1,2])}');
|
|
1178
1178
|
},
|
|
1179
1179
|
'Function'() {
|
|
1180
1180
|
const func = () => { };
|
|
@@ -1194,6 +1194,12 @@ var $;
|
|
|
1194
1194
|
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
1195
1195
|
},
|
|
1196
1196
|
'Custom JSON representation'() {
|
|
1197
|
+
class User {
|
|
1198
|
+
toJSON() { return 'jin'; }
|
|
1199
|
+
}
|
|
1200
|
+
$mol_assert_unique([$mol_key(new User)], [$mol_key(new User)]);
|
|
1201
|
+
},
|
|
1202
|
+
'Custom key handler'() {
|
|
1197
1203
|
class User {
|
|
1198
1204
|
name;
|
|
1199
1205
|
age;
|
|
@@ -1201,15 +1207,15 @@ var $;
|
|
|
1201
1207
|
this.name = name;
|
|
1202
1208
|
this.age = age;
|
|
1203
1209
|
}
|
|
1204
|
-
|
|
1210
|
+
[$mol_key_handle]() { return `User(${JSON.stringify(this.name)})`; }
|
|
1205
1211
|
}
|
|
1206
|
-
$mol_assert_equal($mol_key(new User('jin', 18)), '
|
|
1212
|
+
$mol_assert_equal($mol_key([new User('jin', 16)]), $mol_key([new User('jin', 18)]), '[User("jin")]');
|
|
1207
1213
|
},
|
|
1208
1214
|
'Special native classes'() {
|
|
1209
|
-
$mol_assert_equal($mol_key(new Date('xyz')), '
|
|
1210
|
-
$mol_assert_equal($mol_key(new Date(
|
|
1211
|
-
$mol_assert_equal($mol_key(/./), '
|
|
1212
|
-
$mol_assert_equal($mol_key(/\./gimsu), '
|
|
1215
|
+
$mol_assert_equal($mol_key(new Date('xyz')), 'Date(NaN)');
|
|
1216
|
+
$mol_assert_equal($mol_key(new Date(12345)), 'Date(12345)');
|
|
1217
|
+
$mol_assert_equal($mol_key(/./), '/./');
|
|
1218
|
+
$mol_assert_equal($mol_key(/\./gimsu), '/\\./gimsu');
|
|
1213
1219
|
},
|
|
1214
1220
|
});
|
|
1215
1221
|
})($ || ($ = {}));
|