mol_wire_lib 1.0.1469 → 1.0.1471
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 +11 -5
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +96 -18
- package/node.js.map +1 -1
- package/node.meta.tree +1 -0
- package/node.mjs +96 -18
- package/node.test.js +163 -18
- package/node.test.js.map +1 -1
- package/package.json +3 -2
- package/web.d.ts +11 -5
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +96 -18
- package/web.js.map +1 -1
- package/web.meta.tree +1 -0
- package/web.mjs +96 -18
- package/web.test.js +67 -0
- package/web.test.js.map +1 -1
package/web.meta.tree
CHANGED
package/web.mjs
CHANGED
|
@@ -28,6 +28,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
28
28
|
var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
|
|
29
29
|
$.$$ = $
|
|
30
30
|
|
|
31
|
+
;
|
|
32
|
+
"use strict";
|
|
33
|
+
var $;
|
|
34
|
+
(function ($) {
|
|
35
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
36
|
+
for (;;) {
|
|
37
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
38
|
+
if (exists(id))
|
|
39
|
+
continue;
|
|
40
|
+
return id;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
$.$mol_guid = $mol_guid;
|
|
44
|
+
})($ || ($ = {}));
|
|
45
|
+
|
|
31
46
|
;
|
|
32
47
|
"use strict";
|
|
33
48
|
var $;
|
|
@@ -56,6 +71,11 @@ var $;
|
|
|
56
71
|
var $;
|
|
57
72
|
(function ($) {
|
|
58
73
|
class $mol_wire_pub extends Object {
|
|
74
|
+
constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
|
|
75
|
+
super();
|
|
76
|
+
this[Symbol.toStringTag] = id;
|
|
77
|
+
}
|
|
78
|
+
[Symbol.toStringTag];
|
|
59
79
|
data = [];
|
|
60
80
|
static get [Symbol.species]() {
|
|
61
81
|
return Array;
|
|
@@ -649,7 +669,6 @@ var $;
|
|
|
649
669
|
}
|
|
650
670
|
}
|
|
651
671
|
}
|
|
652
|
-
[Symbol.toStringTag];
|
|
653
672
|
cache = undefined;
|
|
654
673
|
get args() {
|
|
655
674
|
return this.data.slice(0, this.pub_from);
|
|
@@ -668,13 +687,12 @@ var $;
|
|
|
668
687
|
return this.task.name + '()';
|
|
669
688
|
}
|
|
670
689
|
constructor(id, task, host, args) {
|
|
671
|
-
super();
|
|
690
|
+
super(id);
|
|
672
691
|
this.task = task;
|
|
673
692
|
this.host = host;
|
|
674
693
|
if (args)
|
|
675
694
|
this.data.push(...args);
|
|
676
695
|
this.pub_from = this.sub_from = args?.length ?? 0;
|
|
677
|
-
this[Symbol.toStringTag] = id;
|
|
678
696
|
}
|
|
679
697
|
plan() {
|
|
680
698
|
$mol_wire_fiber.planning.add(this);
|
|
@@ -1126,21 +1144,6 @@ var $;
|
|
|
1126
1144
|
$.$mol_wire_task = $mol_wire_task;
|
|
1127
1145
|
})($ || ($ = {}));
|
|
1128
1146
|
|
|
1129
|
-
;
|
|
1130
|
-
"use strict";
|
|
1131
|
-
var $;
|
|
1132
|
-
(function ($) {
|
|
1133
|
-
function $mol_guid(length = 8, exists = () => false) {
|
|
1134
|
-
for (;;) {
|
|
1135
|
-
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1136
|
-
if (exists(id))
|
|
1137
|
-
continue;
|
|
1138
|
-
return id;
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
$.$mol_guid = $mol_guid;
|
|
1142
|
-
})($ || ($ = {}));
|
|
1143
|
-
|
|
1144
1147
|
;
|
|
1145
1148
|
"use strict";
|
|
1146
1149
|
var $;
|
|
@@ -1925,6 +1928,81 @@ var $;
|
|
|
1925
1928
|
$.$mol_wire_set = $mol_wire_set;
|
|
1926
1929
|
})($ || ($ = {}));
|
|
1927
1930
|
|
|
1931
|
+
;
|
|
1932
|
+
"use strict";
|
|
1933
|
+
var $;
|
|
1934
|
+
(function ($) {
|
|
1935
|
+
const pubs = new WeakMap();
|
|
1936
|
+
function $mol_wire_proxy_pub(id, target) {
|
|
1937
|
+
let pub = pubs.get(target);
|
|
1938
|
+
if (!pub)
|
|
1939
|
+
pubs.set(target, pub = new $mol_wire_pub(id));
|
|
1940
|
+
return pub;
|
|
1941
|
+
}
|
|
1942
|
+
$.$mol_wire_proxy_pub = $mol_wire_proxy_pub;
|
|
1943
|
+
function $mol_wire_proxy(id, target) {
|
|
1944
|
+
if (!target)
|
|
1945
|
+
return target;
|
|
1946
|
+
const type = typeof target;
|
|
1947
|
+
if (type !== 'object' && type !== 'function')
|
|
1948
|
+
return target;
|
|
1949
|
+
return new Proxy(target, {
|
|
1950
|
+
get(target, property) {
|
|
1951
|
+
$mol_wire_proxy_pub(id, target).promote();
|
|
1952
|
+
const suffix = '.' + (typeof property === 'symbol' ? property.description : property);
|
|
1953
|
+
return $mol_wire_proxy(id + suffix, Reflect.get(target, property));
|
|
1954
|
+
},
|
|
1955
|
+
getOwnPropertyDescriptor(target, property) {
|
|
1956
|
+
$mol_wire_proxy_pub(id, target).promote();
|
|
1957
|
+
return Reflect.getOwnPropertyDescriptor(target, property);
|
|
1958
|
+
},
|
|
1959
|
+
ownKeys(target) {
|
|
1960
|
+
$mol_wire_proxy_pub(id, target).promote();
|
|
1961
|
+
return Reflect.ownKeys(target);
|
|
1962
|
+
},
|
|
1963
|
+
has(target, property) {
|
|
1964
|
+
$mol_wire_proxy_pub(id, target).promote();
|
|
1965
|
+
return Reflect.has(target, property);
|
|
1966
|
+
},
|
|
1967
|
+
getPrototypeOf(target) {
|
|
1968
|
+
$mol_wire_proxy_pub(id, target).promote();
|
|
1969
|
+
return $mol_wire_proxy(id, Reflect.getPrototypeOf(target));
|
|
1970
|
+
},
|
|
1971
|
+
isExtensible(target) {
|
|
1972
|
+
$mol_wire_proxy_pub(id, target).promote();
|
|
1973
|
+
return Reflect.isExtensible(target);
|
|
1974
|
+
},
|
|
1975
|
+
set(target, property, next) {
|
|
1976
|
+
const pub = pubs.get(target);
|
|
1977
|
+
if (pub) {
|
|
1978
|
+
const prev = Reflect.get(target, property);
|
|
1979
|
+
if ($mol_compare_deep(prev, next))
|
|
1980
|
+
return true;
|
|
1981
|
+
pub.emit();
|
|
1982
|
+
}
|
|
1983
|
+
return Reflect.set(target, property, next);
|
|
1984
|
+
},
|
|
1985
|
+
defineProperty(target, property, attributes) {
|
|
1986
|
+
pubs.get(target)?.emit();
|
|
1987
|
+
return Reflect.defineProperty(target, property, attributes);
|
|
1988
|
+
},
|
|
1989
|
+
deleteProperty(target, property) {
|
|
1990
|
+
pubs.get(target)?.emit();
|
|
1991
|
+
return Reflect.deleteProperty(target, property);
|
|
1992
|
+
},
|
|
1993
|
+
setPrototypeOf(target, proto) {
|
|
1994
|
+
pubs.get(target)?.emit();
|
|
1995
|
+
return Reflect.setPrototypeOf(target, proto);
|
|
1996
|
+
},
|
|
1997
|
+
preventExtensions(target) {
|
|
1998
|
+
pubs.get(target)?.emit();
|
|
1999
|
+
return Reflect.preventExtensions(target);
|
|
2000
|
+
},
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
$.$mol_wire_proxy = $mol_wire_proxy;
|
|
2004
|
+
})($ || ($ = {}));
|
|
2005
|
+
|
|
1928
2006
|
;
|
|
1929
2007
|
"use strict";
|
|
1930
2008
|
var $;
|
package/web.test.js
CHANGED
|
@@ -2348,6 +2348,73 @@ var $;
|
|
|
2348
2348
|
});
|
|
2349
2349
|
})($ || ($ = {}));
|
|
2350
2350
|
|
|
2351
|
+
;
|
|
2352
|
+
"use strict";
|
|
2353
|
+
var $;
|
|
2354
|
+
(function ($_1) {
|
|
2355
|
+
var $$;
|
|
2356
|
+
(function ($$) {
|
|
2357
|
+
$mol_test({
|
|
2358
|
+
"Deep property change"($) {
|
|
2359
|
+
const source = $mol_wire_proxy('source', {
|
|
2360
|
+
foo: {
|
|
2361
|
+
bar: 123,
|
|
2362
|
+
}
|
|
2363
|
+
});
|
|
2364
|
+
const { res } = $mol_wire_let({
|
|
2365
|
+
res() { return source.foo.bar; }
|
|
2366
|
+
});
|
|
2367
|
+
$mol_assert_equal(res(), 123);
|
|
2368
|
+
source.foo.bar = 321;
|
|
2369
|
+
$mol_assert_equal(res(), 321);
|
|
2370
|
+
},
|
|
2371
|
+
"Deep property add/remove"($) {
|
|
2372
|
+
const source = $mol_wire_proxy('source', {
|
|
2373
|
+
foo: {
|
|
2374
|
+
bar: 123,
|
|
2375
|
+
}
|
|
2376
|
+
});
|
|
2377
|
+
const { exists, props } = $mol_wire_let({
|
|
2378
|
+
exists() { return 'bar' in source.foo; },
|
|
2379
|
+
props() { return Object.keys(source.foo); },
|
|
2380
|
+
});
|
|
2381
|
+
$mol_assert_equal(exists(), true);
|
|
2382
|
+
$mol_assert_equal(props(), ['bar']);
|
|
2383
|
+
delete source.foo.bar;
|
|
2384
|
+
$mol_assert_equal(exists(), false);
|
|
2385
|
+
$mol_assert_equal(props(), []);
|
|
2386
|
+
Object.defineProperty(source.foo, 'bar', { value: 'xxx', enumerable: true });
|
|
2387
|
+
$mol_assert_equal(exists(), true);
|
|
2388
|
+
$mol_assert_equal(props(), ['bar']);
|
|
2389
|
+
},
|
|
2390
|
+
"Deep property change to equal"($) {
|
|
2391
|
+
const source = $mol_wire_proxy('source', {
|
|
2392
|
+
foo: {
|
|
2393
|
+
bar: 123,
|
|
2394
|
+
}
|
|
2395
|
+
});
|
|
2396
|
+
let count = 0;
|
|
2397
|
+
const { res } = $mol_wire_let({
|
|
2398
|
+
res() {
|
|
2399
|
+
++count;
|
|
2400
|
+
return source.foo.bar;
|
|
2401
|
+
}
|
|
2402
|
+
});
|
|
2403
|
+
res();
|
|
2404
|
+
$mol_assert_equal(count, 1);
|
|
2405
|
+
res();
|
|
2406
|
+
$mol_assert_equal(count, 1);
|
|
2407
|
+
source.foo = { bar: 123 };
|
|
2408
|
+
res();
|
|
2409
|
+
$mol_assert_equal(count, 1);
|
|
2410
|
+
source.foo = { bar: 321 };
|
|
2411
|
+
res();
|
|
2412
|
+
$mol_assert_equal(count, 2);
|
|
2413
|
+
},
|
|
2414
|
+
});
|
|
2415
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
2416
|
+
})($ || ($ = {}));
|
|
2417
|
+
|
|
2351
2418
|
;
|
|
2352
2419
|
"use strict";
|
|
2353
2420
|
var $;
|