mol_jsx_lib 0.0.54 → 0.0.57

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.test.js CHANGED
@@ -721,6 +721,34 @@ var $;
721
721
  ;
722
722
  "use strict";
723
723
  var $;
724
+ (function ($) {
725
+ function $mol_func_name(func) {
726
+ let name = func.name;
727
+ if (name?.length > 1)
728
+ return name;
729
+ for (let key in this) {
730
+ try {
731
+ if (this[key] !== func)
732
+ continue;
733
+ name = key;
734
+ Object.defineProperty(func, 'name', { value: name });
735
+ break;
736
+ }
737
+ catch { }
738
+ }
739
+ return name;
740
+ }
741
+ $.$mol_func_name = $mol_func_name;
742
+ function $mol_func_name_from(target, source) {
743
+ Object.defineProperty(target, 'name', { value: source.name });
744
+ return target;
745
+ }
746
+ $.$mol_func_name_from = $mol_func_name_from;
747
+ })($ || ($ = {}));
748
+ //mol/func/name/name.ts
749
+ ;
750
+ "use strict";
751
+ var $;
724
752
  (function ($) {
725
753
  function $mol_dom_render_children(el, childNodes) {
726
754
  const node_set = new Set(childNodes);
@@ -790,16 +818,40 @@ var $;
790
818
  $.$mol_jsx_frag = '';
791
819
  function $mol_jsx(Elem, props, ...childNodes) {
792
820
  const id = props && props.id || '';
821
+ const guid = $.$mol_jsx_prefix + id;
793
822
  if (Elem && $.$mol_jsx_booked) {
794
823
  if ($.$mol_jsx_booked.has(id)) {
795
- $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
824
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
796
825
  }
797
826
  else {
798
827
  $.$mol_jsx_booked.add(id);
799
828
  }
800
829
  }
801
- const guid = $.$mol_jsx_prefix + id;
802
830
  let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
831
+ if ($.$mol_jsx_prefix) {
832
+ const prefix_ext = $.$mol_jsx_prefix;
833
+ const booked_ext = $.$mol_jsx_booked;
834
+ for (const field in props) {
835
+ const func = props[field];
836
+ if (typeof func !== 'function')
837
+ continue;
838
+ const wrapper = function (...args) {
839
+ const prefix = $.$mol_jsx_prefix;
840
+ const booked = $.$mol_jsx_booked;
841
+ try {
842
+ $.$mol_jsx_prefix = prefix_ext;
843
+ $.$mol_jsx_booked = booked_ext;
844
+ return func.call(this, ...args);
845
+ }
846
+ finally {
847
+ $.$mol_jsx_prefix = prefix;
848
+ $.$mol_jsx_booked = booked;
849
+ }
850
+ };
851
+ $mol_func_name_from(wrapper, func);
852
+ props[field] = wrapper;
853
+ }
854
+ }
803
855
  if (typeof Elem !== 'string') {
804
856
  if ('prototype' in Elem) {
805
857
  const view = node && node[Elem] || new Elem;
@@ -1903,200 +1955,607 @@ var $;
1903
1955
  "use strict";
1904
1956
  var $;
1905
1957
  (function ($) {
1906
- function $mol_test_complete() {
1907
- process.exit(0);
1958
+ function $mol_wire_probe(task, next) {
1959
+ const warm = $mol_wire_fiber.warm;
1960
+ try {
1961
+ $mol_wire_fiber.warm = false;
1962
+ return task();
1963
+ }
1964
+ finally {
1965
+ $mol_wire_fiber.warm = warm;
1966
+ }
1908
1967
  }
1909
- $.$mol_test_complete = $mol_test_complete;
1968
+ $.$mol_wire_probe = $mol_wire_probe;
1910
1969
  })($ || ($ = {}));
1911
- //mol/test/test.node.test.ts
1970
+ //mol/wire/probe/probe.ts
1912
1971
  ;
1913
1972
  "use strict";
1914
1973
  var $;
1915
- (function ($_1) {
1916
- function $mol_test(set) {
1917
- for (let name in set) {
1918
- const code = set[name];
1919
- const test = (typeof code === 'string') ? new Function('', code) : code;
1920
- $_1.$mol_test_all.push(test);
1921
- }
1922
- $mol_test_schedule();
1974
+ (function ($) {
1975
+ function $mol_wire_solid() {
1976
+ $mol_wire_auto().reap = nothing;
1923
1977
  }
1924
- $_1.$mol_test = $mol_test;
1925
- $_1.$mol_test_mocks = [];
1926
- $_1.$mol_test_all = [];
1927
- async function $mol_test_run() {
1928
- for (var test of $_1.$mol_test_all) {
1929
- let context = Object.create($$);
1930
- for (let mock of $_1.$mol_test_mocks)
1931
- await mock(context);
1932
- const res = test(context);
1933
- if (res instanceof Promise) {
1934
- await new Promise((done, fail) => {
1935
- res.then(done, fail);
1936
- setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
1937
- });
1938
- }
1978
+ $.$mol_wire_solid = $mol_wire_solid;
1979
+ const nothing = () => { };
1980
+ })($ || ($ = {}));
1981
+ //mol/wire/solid/solid.ts
1982
+ ;
1983
+ "use strict";
1984
+ var $;
1985
+ (function ($) {
1986
+ function $mol_wire_watch() {
1987
+ const atom = $mol_wire_auto();
1988
+ if (atom instanceof $mol_wire_atom) {
1989
+ atom.watch();
1939
1990
  }
1940
- $$.$mol_log3_done({
1941
- place: '$mol_test',
1942
- message: 'All tests passed',
1943
- count: $_1.$mol_test_all.length,
1944
- });
1945
- }
1946
- $_1.$mol_test_run = $mol_test_run;
1947
- let scheduled = false;
1948
- function $mol_test_schedule() {
1949
- if (scheduled)
1950
- return;
1951
- scheduled = true;
1952
- setTimeout(async () => {
1953
- scheduled = false;
1954
- try {
1955
- await $mol_test_run();
1956
- }
1957
- finally {
1958
- $$.$mol_test_complete();
1959
- }
1960
- }, 0);
1961
- }
1962
- $_1.$mol_test_schedule = $mol_test_schedule;
1963
- $_1.$mol_test_mocks.push(context => {
1964
- let seed = 0;
1965
- context.Math = Object.create(Math);
1966
- context.Math.random = () => Math.sin(seed++);
1967
- const forbidden = ['XMLHttpRequest', 'fetch'];
1968
- for (let api of forbidden) {
1969
- context[api] = new Proxy(function () { }, {
1970
- get() {
1971
- $mol_fail_hidden(new Error(`${api} is forbidden in tests`));
1972
- },
1973
- apply() {
1974
- $mol_fail_hidden(new Error(`${api} is forbidden in tests`));
1975
- },
1976
- });
1991
+ else {
1992
+ $mol_fail(new Error('Atom is equired for watching'));
1977
1993
  }
1978
- });
1979
- $mol_test({
1980
- 'mocked Math.random'($) {
1981
- console.assert($.Math.random() === 0);
1982
- console.assert($.Math.random() === Math.sin(1));
1983
- },
1984
- 'forbidden XMLHttpRequest'($) {
1985
- try {
1986
- console.assert(void new $.XMLHttpRequest);
1987
- }
1988
- catch (error) {
1989
- console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
1990
- }
1991
- },
1992
- 'forbidden fetch'($) {
1993
- try {
1994
- console.assert(void $.fetch(''));
1995
- }
1996
- catch (error) {
1997
- console.assert(error.message === 'fetch is forbidden in tests');
1998
- }
1999
- },
2000
- });
1994
+ }
1995
+ $.$mol_wire_watch = $mol_wire_watch;
2001
1996
  })($ || ($ = {}));
2002
- //mol/test/test.test.ts
1997
+ //mol/wire/watch/watch.ts
2003
1998
  ;
2004
1999
  "use strict";
2005
2000
  var $;
2006
- (function ($_1) {
2007
- $mol_test_mocks.push($ => {
2008
- $.$mol_log3_come = () => { };
2009
- $.$mol_log3_done = () => { };
2010
- $.$mol_log3_fail = () => { };
2011
- $.$mol_log3_warn = () => { };
2012
- $.$mol_log3_rise = () => { };
2013
- $.$mol_log3_area = () => () => { };
2014
- });
2001
+ (function ($) {
2002
+ function $mol_wire_sync(obj) {
2003
+ return new Proxy(obj, {
2004
+ get(obj, field) {
2005
+ const val = obj[field];
2006
+ if (typeof val !== 'function')
2007
+ return val;
2008
+ const temp = $mol_wire_task.getter(val);
2009
+ return function $mol_wire_sync(...args) {
2010
+ const fiber = temp(obj, args);
2011
+ return fiber.sync();
2012
+ };
2013
+ },
2014
+ apply(obj, self, args) {
2015
+ const temp = $mol_wire_task.getter(obj);
2016
+ const fiber = temp(self, args);
2017
+ return fiber.sync();
2018
+ },
2019
+ });
2020
+ }
2021
+ $.$mol_wire_sync = $mol_wire_sync;
2015
2022
  })($ || ($ = {}));
2016
- //mol/log3/log3.test.ts
2023
+ //mol/wire/sync/sync.ts
2017
2024
  ;
2018
2025
  "use strict";
2019
2026
  var $;
2020
2027
  (function ($) {
2021
- function $mol_dom_serialize(node) {
2022
- const serializer = new $mol_dom_context.XMLSerializer;
2023
- return serializer.serializeToString(node);
2028
+ function $mol_wire_async(obj) {
2029
+ let fiber;
2030
+ const temp = $mol_wire_task.getter(obj);
2031
+ return new Proxy(obj, {
2032
+ get(obj, field) {
2033
+ const val = obj[field];
2034
+ if (typeof val !== 'function')
2035
+ return val;
2036
+ let fiber;
2037
+ const temp = $mol_wire_task.getter(val);
2038
+ return function $mol_wire_async(...args) {
2039
+ fiber?.destructor();
2040
+ fiber = temp(obj, args);
2041
+ return fiber.async();
2042
+ };
2043
+ },
2044
+ apply(obj, self, args) {
2045
+ fiber?.destructor();
2046
+ fiber = temp(self, args);
2047
+ return fiber.async();
2048
+ },
2049
+ });
2024
2050
  }
2025
- $.$mol_dom_serialize = $mol_dom_serialize;
2051
+ $.$mol_wire_async = $mol_wire_async;
2026
2052
  })($ || ($ = {}));
2027
- //mol/dom/serialize/serialize.ts
2053
+ //mol/wire/async/async.ts
2028
2054
  ;
2029
2055
  "use strict";
2030
2056
  var $;
2031
2057
  (function ($) {
2032
- $mol_test({
2033
- 'must be false'() {
2034
- $mol_assert_not(0);
2035
- },
2036
- 'must be true'() {
2037
- $mol_assert_ok(1);
2038
- },
2039
- 'two must be equal'() {
2040
- $mol_assert_equal(2, 2);
2041
- },
2042
- 'three must be equal'() {
2043
- $mol_assert_equal(2, 2, 2);
2044
- },
2045
- 'two must be unique'() {
2046
- $mol_assert_unique([3], [3]);
2047
- },
2048
- 'three must be unique'() {
2049
- $mol_assert_unique([3], [3], [3]);
2050
- },
2051
- 'two must be alike'() {
2052
- $mol_assert_like([3], [3]);
2053
- },
2054
- 'three must be alike'() {
2055
- $mol_assert_like([3], [3], [3]);
2056
- },
2057
- });
2058
+ function $mol_const(value) {
2059
+ var getter = (() => value);
2060
+ getter['()'] = value;
2061
+ getter[Symbol.toStringTag] = value;
2062
+ return getter;
2063
+ }
2064
+ $.$mol_const = $mol_const;
2058
2065
  })($ || ($ = {}));
2059
- //mol/assert/assert.test.ts
2066
+ //mol/const/const.ts
2060
2067
  ;
2061
2068
  "use strict";
2062
2069
  var $;
2063
2070
  (function ($) {
2064
- function $mol_assert_ok(value) {
2065
- if (value)
2066
- return;
2067
- $mol_fail(new Error(`${value} ≠ true`));
2068
- }
2069
- $.$mol_assert_ok = $mol_assert_ok;
2070
- function $mol_assert_not(value) {
2071
- if (!value)
2072
- return;
2073
- $mol_fail(new Error(`${value} ≠ false`));
2074
- }
2075
- $.$mol_assert_not = $mol_assert_not;
2076
- function $mol_assert_fail(handler, ErrorRight) {
2077
- const fail = $.$mol_fail;
2078
- try {
2079
- $.$mol_fail = $.$mol_fail_hidden;
2080
- handler();
2081
- }
2082
- catch (error) {
2083
- if (!ErrorRight)
2084
- return error;
2085
- $.$mol_fail = fail;
2086
- if (typeof ErrorRight === 'string') {
2087
- $mol_assert_equal(error.message, ErrorRight);
2088
- }
2089
- else {
2090
- $mol_assert_ok(error instanceof ErrorRight);
2091
- }
2092
- return error;
2071
+ function $mol_wire_field(host, field, descr) {
2072
+ if (!descr)
2073
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
2074
+ const _get = descr?.get || $mol_const(descr?.value);
2075
+ const persist = $mol_wire_atom.getter(_get, 0);
2076
+ const _set = descr?.set || function (next) {
2077
+ persist(this, []).put(next);
2078
+ };
2079
+ const sup = Reflect.getPrototypeOf(host);
2080
+ const sup_descr = Reflect.getOwnPropertyDescriptor(sup, field);
2081
+ Object.defineProperty(_get, 'name', { value: sup_descr?.get?.name ?? field });
2082
+ Object.defineProperty(_set, 'name', { value: sup_descr?.set?.name ?? field });
2083
+ function get() {
2084
+ return persist(this, []).sync();
2093
2085
  }
2094
- finally {
2095
- $.$mol_fail = fail;
2086
+ const temp = $mol_wire_task.getter(_set);
2087
+ function set(next) {
2088
+ temp(this, [next]).sync();
2096
2089
  }
2097
- $mol_fail(new Error('Not failed'));
2090
+ Object.defineProperty(get, 'name', { value: _get.name + '$' });
2091
+ Object.defineProperty(set, 'name', { value: _set.name + '@' });
2092
+ Object.assign(get, { orig: _get });
2093
+ Object.assign(set, { orig: _set });
2094
+ const { value, writable, ...descr2 } = { ...descr, get, set };
2095
+ Reflect.defineProperty(host, field, descr2);
2096
+ return descr2;
2098
2097
  }
2099
- $.$mol_assert_fail = $mol_assert_fail;
2098
+ $.$mol_wire_field = $mol_wire_field;
2099
+ })($ || ($ = {}));
2100
+ //mol/wire/field/field.ts
2101
+ ;
2102
+ "use strict";
2103
+ var $;
2104
+ (function ($) {
2105
+ function $mol_wire_patch(obj) {
2106
+ for (const field of Reflect.ownKeys(obj)) {
2107
+ const descr = Reflect.getOwnPropertyDescriptor(obj, field);
2108
+ if (!descr.configurable)
2109
+ continue;
2110
+ if (!descr.get)
2111
+ continue;
2112
+ const get = descr.get ?? (() => descr.value);
2113
+ const set = descr.set ?? (next => descr.value = next);
2114
+ const persist = $mol_wire_atom.getter(get, 0);
2115
+ Reflect.defineProperty(obj, field, {
2116
+ configurable: true,
2117
+ enumerable: descr.enumerable,
2118
+ get() {
2119
+ const atom = persist(obj, []);
2120
+ atom.watch();
2121
+ return atom.sync();
2122
+ },
2123
+ set(next) {
2124
+ const atom = persist(obj, []);
2125
+ set.call(this, next);
2126
+ atom.refresh();
2127
+ },
2128
+ });
2129
+ }
2130
+ }
2131
+ $.$mol_wire_patch = $mol_wire_patch;
2132
+ })($ || ($ = {}));
2133
+ //mol/wire/patch/patch.ts
2134
+ ;
2135
+ "use strict";
2136
+ var $;
2137
+ (function ($) {
2138
+ class $mol_wire_set extends Set {
2139
+ pub = new $mol_wire_pub;
2140
+ has(value) {
2141
+ this.pub.promote();
2142
+ return super.has(value);
2143
+ }
2144
+ entries() {
2145
+ this.pub.promote();
2146
+ return super.entries();
2147
+ }
2148
+ keys() {
2149
+ this.pub.promote();
2150
+ return super.keys();
2151
+ }
2152
+ values() {
2153
+ this.pub.promote();
2154
+ return super.values();
2155
+ }
2156
+ forEach(task, self) {
2157
+ this.pub.promote();
2158
+ super.forEach(task, self);
2159
+ }
2160
+ [Symbol.iterator]() {
2161
+ this.pub.promote();
2162
+ return super[Symbol.iterator]();
2163
+ }
2164
+ get size() {
2165
+ this.pub.promote();
2166
+ return super.size;
2167
+ }
2168
+ add(value) {
2169
+ if (super.has(value))
2170
+ return this;
2171
+ super.add(value);
2172
+ this.pub.emit();
2173
+ return this;
2174
+ }
2175
+ delete(value) {
2176
+ const res = super.delete(value);
2177
+ if (res)
2178
+ this.pub.emit();
2179
+ return res;
2180
+ }
2181
+ clear() {
2182
+ if (!super.size)
2183
+ return;
2184
+ super.clear();
2185
+ this.pub.emit();
2186
+ }
2187
+ item(val, next) {
2188
+ if (next === undefined)
2189
+ return this.has(val);
2190
+ if (next)
2191
+ this.add(val);
2192
+ else
2193
+ this.delete(val);
2194
+ return next;
2195
+ }
2196
+ }
2197
+ $.$mol_wire_set = $mol_wire_set;
2198
+ })($ || ($ = {}));
2199
+ //mol/wire/set/set.ts
2200
+ ;
2201
+ "use strict";
2202
+ var $;
2203
+ (function ($) {
2204
+ class $mol_wire_dict extends Map {
2205
+ pub = new $mol_wire_pub;
2206
+ has(key) {
2207
+ this.pub.promote();
2208
+ return super.has(key);
2209
+ }
2210
+ get(key) {
2211
+ this.pub.promote();
2212
+ return super.get(key);
2213
+ }
2214
+ entries() {
2215
+ this.pub.promote();
2216
+ return super.entries();
2217
+ }
2218
+ keys() {
2219
+ this.pub.promote();
2220
+ return super.keys();
2221
+ }
2222
+ values() {
2223
+ this.pub.promote();
2224
+ return super.values();
2225
+ }
2226
+ forEach(task, self) {
2227
+ this.pub.promote();
2228
+ super.forEach(task, self);
2229
+ }
2230
+ [Symbol.iterator]() {
2231
+ this.pub.promote();
2232
+ return super[Symbol.iterator]();
2233
+ }
2234
+ get size() {
2235
+ this.pub.promote();
2236
+ return super.size;
2237
+ }
2238
+ set(key, value) {
2239
+ if (super.get(key) === value)
2240
+ return this;
2241
+ super.set(key, value);
2242
+ this.pub.emit();
2243
+ return this;
2244
+ }
2245
+ delete(key) {
2246
+ const res = super.delete(key);
2247
+ if (res)
2248
+ this.pub.emit();
2249
+ return res;
2250
+ }
2251
+ clear() {
2252
+ if (!super.size)
2253
+ return;
2254
+ super.clear();
2255
+ this.pub.emit();
2256
+ }
2257
+ item(key, next) {
2258
+ if (next === undefined)
2259
+ return this.get(key) ?? null;
2260
+ if (next === null)
2261
+ this.delete(key);
2262
+ else
2263
+ this.set(key, next);
2264
+ return next;
2265
+ }
2266
+ }
2267
+ $.$mol_wire_dict = $mol_wire_dict;
2268
+ })($ || ($ = {}));
2269
+ //mol/wire/dict/dict.ts
2270
+ ;
2271
+ "use strict";
2272
+ var $;
2273
+ (function ($) {
2274
+ function $mol_promise() {
2275
+ let done;
2276
+ let fail;
2277
+ const promise = new Promise((d, f) => {
2278
+ done = d;
2279
+ fail = f;
2280
+ });
2281
+ return Object.assign(promise, {
2282
+ done,
2283
+ fail,
2284
+ });
2285
+ }
2286
+ $.$mol_promise = $mol_promise;
2287
+ })($ || ($ = {}));
2288
+ //mol/promise/promise.ts
2289
+ ;
2290
+ "use strict";
2291
+ var $;
2292
+ (function ($) {
2293
+ function $mol_wait_timeout_async(timeout) {
2294
+ const promise = $mol_promise();
2295
+ const task = new this.$mol_after_timeout(timeout, () => promise.done());
2296
+ return Object.assign(promise, {
2297
+ destructor: () => task.destructor()
2298
+ });
2299
+ }
2300
+ $.$mol_wait_timeout_async = $mol_wait_timeout_async;
2301
+ function $mol_wait_timeout(timeout) {
2302
+ return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
2303
+ }
2304
+ $.$mol_wait_timeout = $mol_wait_timeout;
2305
+ })($ || ($ = {}));
2306
+ //mol/wait/timeout/timeout.ts
2307
+ ;
2308
+ "use strict";
2309
+ var $;
2310
+ (function ($) {
2311
+ class $mol_wire_log extends $mol_object2 {
2312
+ static watch(task) {
2313
+ return task;
2314
+ }
2315
+ static track(fiber) {
2316
+ const prev = $mol_wire_probe(() => this.track(fiber));
2317
+ let next;
2318
+ try {
2319
+ next = fiber.sync();
2320
+ }
2321
+ finally {
2322
+ for (const pub of fiber.pub_list) {
2323
+ if (pub instanceof $mol_wire_fiber) {
2324
+ this.track(pub);
2325
+ }
2326
+ }
2327
+ }
2328
+ if (prev !== undefined && !$mol_compare_deep(prev, next)) {
2329
+ this.$.$mol_log3_rise({
2330
+ message: 'Changed',
2331
+ place: fiber,
2332
+ });
2333
+ }
2334
+ return next;
2335
+ }
2336
+ static active() {
2337
+ try {
2338
+ this.watch()?.();
2339
+ }
2340
+ finally {
2341
+ for (const pub of $mol_wire_auto().pub_list) {
2342
+ if (pub instanceof $mol_wire_fiber) {
2343
+ this.track(pub);
2344
+ }
2345
+ }
2346
+ }
2347
+ }
2348
+ }
2349
+ __decorate([
2350
+ $mol_mem
2351
+ ], $mol_wire_log, "watch", null);
2352
+ __decorate([
2353
+ $mol_mem_key
2354
+ ], $mol_wire_log, "track", null);
2355
+ __decorate([
2356
+ $mol_mem
2357
+ ], $mol_wire_log, "active", null);
2358
+ $.$mol_wire_log = $mol_wire_log;
2359
+ })($ || ($ = {}));
2360
+ //mol/wire/log/log.ts
2361
+ ;
2362
+ "use strict";
2363
+ var $;
2364
+ (function ($) {
2365
+ function $mol_test_complete() {
2366
+ process.exit(0);
2367
+ }
2368
+ $.$mol_test_complete = $mol_test_complete;
2369
+ })($ || ($ = {}));
2370
+ //mol/test/test.node.test.ts
2371
+ ;
2372
+ "use strict";
2373
+ var $;
2374
+ (function ($_1) {
2375
+ function $mol_test(set) {
2376
+ for (let name in set) {
2377
+ const code = set[name];
2378
+ const test = (typeof code === 'string') ? new Function('', code) : code;
2379
+ $_1.$mol_test_all.push(test);
2380
+ }
2381
+ $mol_test_schedule();
2382
+ }
2383
+ $_1.$mol_test = $mol_test;
2384
+ $_1.$mol_test_mocks = [];
2385
+ $_1.$mol_test_all = [];
2386
+ async function $mol_test_run() {
2387
+ for (var test of $_1.$mol_test_all) {
2388
+ let context = Object.create($$);
2389
+ for (let mock of $_1.$mol_test_mocks)
2390
+ await mock(context);
2391
+ const res = test(context);
2392
+ if (res instanceof Promise) {
2393
+ await new Promise((done, fail) => {
2394
+ res.then(done, fail);
2395
+ setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
2396
+ });
2397
+ }
2398
+ }
2399
+ $$.$mol_log3_done({
2400
+ place: '$mol_test',
2401
+ message: 'All tests passed',
2402
+ count: $_1.$mol_test_all.length,
2403
+ });
2404
+ }
2405
+ $_1.$mol_test_run = $mol_test_run;
2406
+ let scheduled = false;
2407
+ function $mol_test_schedule() {
2408
+ if (scheduled)
2409
+ return;
2410
+ scheduled = true;
2411
+ setTimeout(async () => {
2412
+ scheduled = false;
2413
+ try {
2414
+ await $mol_test_run();
2415
+ }
2416
+ finally {
2417
+ $$.$mol_test_complete();
2418
+ }
2419
+ }, 0);
2420
+ }
2421
+ $_1.$mol_test_schedule = $mol_test_schedule;
2422
+ $_1.$mol_test_mocks.push(context => {
2423
+ let seed = 0;
2424
+ context.Math = Object.create(Math);
2425
+ context.Math.random = () => Math.sin(seed++);
2426
+ const forbidden = ['XMLHttpRequest', 'fetch'];
2427
+ for (let api of forbidden) {
2428
+ context[api] = new Proxy(function () { }, {
2429
+ get() {
2430
+ $mol_fail_hidden(new Error(`${api} is forbidden in tests`));
2431
+ },
2432
+ apply() {
2433
+ $mol_fail_hidden(new Error(`${api} is forbidden in tests`));
2434
+ },
2435
+ });
2436
+ }
2437
+ });
2438
+ $mol_test({
2439
+ 'mocked Math.random'($) {
2440
+ console.assert($.Math.random() === 0);
2441
+ console.assert($.Math.random() === Math.sin(1));
2442
+ },
2443
+ 'forbidden XMLHttpRequest'($) {
2444
+ try {
2445
+ console.assert(void new $.XMLHttpRequest);
2446
+ }
2447
+ catch (error) {
2448
+ console.assert(error.message === 'XMLHttpRequest is forbidden in tests');
2449
+ }
2450
+ },
2451
+ 'forbidden fetch'($) {
2452
+ try {
2453
+ console.assert(void $.fetch(''));
2454
+ }
2455
+ catch (error) {
2456
+ console.assert(error.message === 'fetch is forbidden in tests');
2457
+ }
2458
+ },
2459
+ });
2460
+ })($ || ($ = {}));
2461
+ //mol/test/test.test.ts
2462
+ ;
2463
+ "use strict";
2464
+ var $;
2465
+ (function ($_1) {
2466
+ $mol_test_mocks.push($ => {
2467
+ $.$mol_log3_come = () => { };
2468
+ $.$mol_log3_done = () => { };
2469
+ $.$mol_log3_fail = () => { };
2470
+ $.$mol_log3_warn = () => { };
2471
+ $.$mol_log3_rise = () => { };
2472
+ $.$mol_log3_area = () => () => { };
2473
+ });
2474
+ })($ || ($ = {}));
2475
+ //mol/log3/log3.test.ts
2476
+ ;
2477
+ "use strict";
2478
+ var $;
2479
+ (function ($) {
2480
+ function $mol_dom_serialize(node) {
2481
+ const serializer = new $mol_dom_context.XMLSerializer;
2482
+ return serializer.serializeToString(node);
2483
+ }
2484
+ $.$mol_dom_serialize = $mol_dom_serialize;
2485
+ })($ || ($ = {}));
2486
+ //mol/dom/serialize/serialize.ts
2487
+ ;
2488
+ "use strict";
2489
+ var $;
2490
+ (function ($) {
2491
+ $mol_test({
2492
+ 'must be false'() {
2493
+ $mol_assert_not(0);
2494
+ },
2495
+ 'must be true'() {
2496
+ $mol_assert_ok(1);
2497
+ },
2498
+ 'two must be equal'() {
2499
+ $mol_assert_equal(2, 2);
2500
+ },
2501
+ 'three must be equal'() {
2502
+ $mol_assert_equal(2, 2, 2);
2503
+ },
2504
+ 'two must be unique'() {
2505
+ $mol_assert_unique([3], [3]);
2506
+ },
2507
+ 'three must be unique'() {
2508
+ $mol_assert_unique([3], [3], [3]);
2509
+ },
2510
+ 'two must be alike'() {
2511
+ $mol_assert_like([3], [3]);
2512
+ },
2513
+ 'three must be alike'() {
2514
+ $mol_assert_like([3], [3], [3]);
2515
+ },
2516
+ });
2517
+ })($ || ($ = {}));
2518
+ //mol/assert/assert.test.ts
2519
+ ;
2520
+ "use strict";
2521
+ var $;
2522
+ (function ($) {
2523
+ function $mol_assert_ok(value) {
2524
+ if (value)
2525
+ return;
2526
+ $mol_fail(new Error(`${value} ≠ true`));
2527
+ }
2528
+ $.$mol_assert_ok = $mol_assert_ok;
2529
+ function $mol_assert_not(value) {
2530
+ if (!value)
2531
+ return;
2532
+ $mol_fail(new Error(`${value} ≠ false`));
2533
+ }
2534
+ $.$mol_assert_not = $mol_assert_not;
2535
+ function $mol_assert_fail(handler, ErrorRight) {
2536
+ const fail = $.$mol_fail;
2537
+ try {
2538
+ $.$mol_fail = $.$mol_fail_hidden;
2539
+ handler();
2540
+ }
2541
+ catch (error) {
2542
+ if (!ErrorRight)
2543
+ return error;
2544
+ $.$mol_fail = fail;
2545
+ if (typeof ErrorRight === 'string') {
2546
+ $mol_assert_equal(error.message, ErrorRight);
2547
+ }
2548
+ else {
2549
+ $mol_assert_ok(error instanceof ErrorRight);
2550
+ }
2551
+ return error;
2552
+ }
2553
+ finally {
2554
+ $.$mol_fail = fail;
2555
+ }
2556
+ $mol_fail(new Error('Not failed'));
2557
+ }
2558
+ $.$mol_assert_fail = $mol_assert_fail;
2100
2559
  function $mol_assert_equal(...args) {
2101
2560
  for (let i = 0; i < args.length; ++i) {
2102
2561
  for (let j = 0; j < args.length; ++j) {
@@ -2153,6 +2612,20 @@ var $;
2153
2612
  //mol/assert/assert.ts
2154
2613
  ;
2155
2614
  "use strict";
2615
+ var $;
2616
+ (function ($_1) {
2617
+ $mol_test({
2618
+ 'FQN of anon function'($) {
2619
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
2620
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
2621
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
2622
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
2623
+ },
2624
+ });
2625
+ })($ || ($ = {}));
2626
+ //mol/func/name/name.test.ts
2627
+ ;
2628
+ "use strict";
2156
2629
  //mol/type/error/error.ts
2157
2630
  ;
2158
2631
  "use strict";
@@ -2356,7 +2829,29 @@ var $;
2356
2829
  $mol_jsx("span", { id: "/bar" }),
2357
2830
  $mol_jsx("span", { id: "/bar" }));
2358
2831
  };
2359
- $mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
2832
+ $mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/foo/bar"');
2833
+ },
2834
+ 'Owner based guid generationn'() {
2835
+ const Foo = () => {
2836
+ return $mol_jsx("div", null,
2837
+ $mol_jsx(Bar, { id: "/bar", icon: () => $mol_jsx("img", { id: "/icon" }) }));
2838
+ };
2839
+ const Bar = (props) => {
2840
+ return $mol_jsx("span", null, props.icon());
2841
+ };
2842
+ const dom = $mol_jsx(Foo, { id: "/foo" });
2843
+ $mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
2844
+ },
2845
+ 'Fail on same ids from different caller'() {
2846
+ const Foo = () => {
2847
+ return $mol_jsx("div", null,
2848
+ $mol_jsx("img", { id: "/icon" }),
2849
+ $mol_jsx(Bar, { id: "/bar", icon: () => $mol_jsx("img", { id: "/icon" }) }));
2850
+ };
2851
+ const Bar = (props) => {
2852
+ return $mol_jsx("span", null, props.icon());
2853
+ };
2854
+ $mol_assert_fail(() => $mol_jsx(Foo, { id: "/foo" }), 'JSX already has tag with id "/foo/icon"');
2360
2855
  },
2361
2856
  });
2362
2857
  })($ || ($ = {}));
@@ -2641,108 +3136,45 @@ var $;
2641
3136
  $mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
2642
3137
  },
2643
3138
  'Error'() {
2644
- $mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
2645
- const fail = (message) => new Error(message);
2646
- $mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
2647
- $mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
2648
- },
2649
- 'Map'() {
2650
- $mol_assert_ok($mol_compare_deep(new Map, new Map));
2651
- $mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
2652
- $mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
2653
- $mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
2654
- },
2655
- 'Set'() {
2656
- $mol_assert_ok($mol_compare_deep(new Set, new Set));
2657
- $mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
2658
- $mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
2659
- },
2660
- 'Uint8Array'() {
2661
- $mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
2662
- $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
2663
- $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
2664
- },
2665
- 'Custom comparator'() {
2666
- class User {
2667
- name;
2668
- rand;
2669
- constructor(name, rand = Math.random()) {
2670
- this.name = name;
2671
- this.rand = rand;
2672
- }
2673
- [Symbol.toPrimitive](mode) {
2674
- return this.name;
2675
- }
2676
- }
2677
- $mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
2678
- $mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
2679
- },
2680
- });
2681
- })($ || ($ = {}));
2682
- //mol/compare/deep/deep.test.tsx
2683
- ;
2684
- "use strict";
2685
- var $;
2686
- (function ($) {
2687
- function $mol_wire_sync(obj) {
2688
- return new Proxy(obj, {
2689
- get(obj, field) {
2690
- const val = obj[field];
2691
- if (typeof val !== 'function')
2692
- return val;
2693
- const temp = $mol_wire_task.getter(val);
2694
- return function $mol_wire_sync(...args) {
2695
- const fiber = temp(obj, args);
2696
- return fiber.sync();
2697
- };
2698
- },
2699
- apply(obj, self, args) {
2700
- const temp = $mol_wire_task.getter(obj);
2701
- const fiber = temp(self, args);
2702
- return fiber.sync();
2703
- },
2704
- });
2705
- }
2706
- $.$mol_wire_sync = $mol_wire_sync;
2707
- })($ || ($ = {}));
2708
- //mol/wire/sync/sync.ts
2709
- ;
2710
- "use strict";
2711
- var $;
2712
- (function ($) {
2713
- function $mol_promise() {
2714
- let done;
2715
- let fail;
2716
- const promise = new Promise((d, f) => {
2717
- done = d;
2718
- fail = f;
2719
- });
2720
- return Object.assign(promise, {
2721
- done,
2722
- fail,
2723
- });
2724
- }
2725
- $.$mol_promise = $mol_promise;
2726
- })($ || ($ = {}));
2727
- //mol/promise/promise.ts
2728
- ;
2729
- "use strict";
2730
- var $;
2731
- (function ($) {
2732
- function $mol_wait_timeout_async(timeout) {
2733
- const promise = $mol_promise();
2734
- const task = new this.$mol_after_timeout(timeout, () => promise.done());
2735
- return Object.assign(promise, {
2736
- destructor: () => task.destructor()
2737
- });
2738
- }
2739
- $.$mol_wait_timeout_async = $mol_wait_timeout_async;
2740
- function $mol_wait_timeout(timeout) {
2741
- return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
2742
- }
2743
- $.$mol_wait_timeout = $mol_wait_timeout;
3139
+ $mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
3140
+ const fail = (message) => new Error(message);
3141
+ $mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
3142
+ $mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
3143
+ },
3144
+ 'Map'() {
3145
+ $mol_assert_ok($mol_compare_deep(new Map, new Map));
3146
+ $mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
3147
+ $mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
3148
+ $mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
3149
+ },
3150
+ 'Set'() {
3151
+ $mol_assert_ok($mol_compare_deep(new Set, new Set));
3152
+ $mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
3153
+ $mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
3154
+ },
3155
+ 'Uint8Array'() {
3156
+ $mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
3157
+ $mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
3158
+ $mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
3159
+ },
3160
+ 'Custom comparator'() {
3161
+ class User {
3162
+ name;
3163
+ rand;
3164
+ constructor(name, rand = Math.random()) {
3165
+ this.name = name;
3166
+ this.rand = rand;
3167
+ }
3168
+ [Symbol.toPrimitive](mode) {
3169
+ return this.name;
3170
+ }
3171
+ }
3172
+ $mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
3173
+ $mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
3174
+ },
3175
+ });
2744
3176
  })($ || ($ = {}));
2745
- //mol/wait/timeout/timeout.ts
3177
+ //mol/compare/deep/deep.test.tsx
2746
3178
  ;
2747
3179
  "use strict";
2748
3180
  var $;
@@ -2789,36 +3221,6 @@ var $;
2789
3221
  ;
2790
3222
  "use strict";
2791
3223
  var $;
2792
- (function ($) {
2793
- function $mol_wire_async(obj) {
2794
- let fiber;
2795
- const temp = $mol_wire_task.getter(obj);
2796
- return new Proxy(obj, {
2797
- get(obj, field) {
2798
- const val = obj[field];
2799
- if (typeof val !== 'function')
2800
- return val;
2801
- let fiber;
2802
- const temp = $mol_wire_task.getter(val);
2803
- return function $mol_wire_async(...args) {
2804
- fiber?.destructor();
2805
- fiber = temp(obj, args);
2806
- return fiber.async();
2807
- };
2808
- },
2809
- apply(obj, self, args) {
2810
- fiber?.destructor();
2811
- fiber = temp(self, args);
2812
- return fiber.async();
2813
- },
2814
- });
2815
- }
2816
- $.$mol_wire_async = $mol_wire_async;
2817
- })($ || ($ = {}));
2818
- //mol/wire/async/async.ts
2819
- ;
2820
- "use strict";
2821
- var $;
2822
3224
  (function ($_1) {
2823
3225
  $mol_test({
2824
3226
  'Cached channel'($) {
@@ -3389,77 +3791,6 @@ var $;
3389
3791
  ;
3390
3792
  "use strict";
3391
3793
  var $;
3392
- (function ($) {
3393
- function $mol_wire_probe(task, next) {
3394
- const warm = $mol_wire_fiber.warm;
3395
- try {
3396
- $mol_wire_fiber.warm = false;
3397
- return task();
3398
- }
3399
- finally {
3400
- $mol_wire_fiber.warm = warm;
3401
- }
3402
- }
3403
- $.$mol_wire_probe = $mol_wire_probe;
3404
- })($ || ($ = {}));
3405
- //mol/wire/probe/probe.ts
3406
- ;
3407
- "use strict";
3408
- var $;
3409
- (function ($) {
3410
- class $mol_wire_log extends $mol_object2 {
3411
- static watch(task) {
3412
- return task;
3413
- }
3414
- static track(fiber) {
3415
- const prev = $mol_wire_probe(() => this.track(fiber));
3416
- let next;
3417
- try {
3418
- next = fiber.sync();
3419
- }
3420
- finally {
3421
- for (const pub of fiber.pub_list) {
3422
- if (pub instanceof $mol_wire_fiber) {
3423
- this.track(pub);
3424
- }
3425
- }
3426
- }
3427
- if (prev !== undefined && !$mol_compare_deep(prev, next)) {
3428
- this.$.$mol_log3_rise({
3429
- message: 'Changed',
3430
- place: fiber,
3431
- });
3432
- }
3433
- return next;
3434
- }
3435
- static active() {
3436
- try {
3437
- this.watch()?.();
3438
- }
3439
- finally {
3440
- for (const pub of $mol_wire_auto().pub_list) {
3441
- if (pub instanceof $mol_wire_fiber) {
3442
- this.track(pub);
3443
- }
3444
- }
3445
- }
3446
- }
3447
- }
3448
- __decorate([
3449
- $mol_mem
3450
- ], $mol_wire_log, "watch", null);
3451
- __decorate([
3452
- $mol_mem_key
3453
- ], $mol_wire_log, "track", null);
3454
- __decorate([
3455
- $mol_mem
3456
- ], $mol_wire_log, "active", null);
3457
- $.$mol_wire_log = $mol_wire_log;
3458
- })($ || ($ = {}));
3459
- //mol/wire/log/log.ts
3460
- ;
3461
- "use strict";
3462
- var $;
3463
3794
  (function ($) {
3464
3795
  $mol_test({
3465
3796
  'Primitives'() {
@@ -3615,5 +3946,277 @@ var $;
3615
3946
  });
3616
3947
  })($ || ($ = {}));
3617
3948
  //mol/jsx/view/view.test.tsx
3949
+ ;
3950
+ "use strict";
3951
+ var $;
3952
+ (function ($) {
3953
+ $mol_test({
3954
+ 'const returns stored value'() {
3955
+ const foo = { bar: $mol_const(Math.random()) };
3956
+ $mol_assert_equal(foo.bar(), foo.bar());
3957
+ $mol_assert_equal(foo.bar(), foo.bar['()']);
3958
+ },
3959
+ });
3960
+ })($ || ($ = {}));
3961
+ //mol/const/const.test.ts
3962
+ ;
3963
+ "use strict";
3964
+ var $;
3965
+ (function ($_1) {
3966
+ $mol_test({
3967
+ 'Cached field'($) {
3968
+ class App extends $mol_object2 {
3969
+ static $ = $;
3970
+ static low = 1;
3971
+ static get high() {
3972
+ return this.low + 1;
3973
+ }
3974
+ static set high(next) {
3975
+ this.low = next - 1;
3976
+ }
3977
+ static test() {
3978
+ $mol_assert_equal(App.high, 2);
3979
+ App.high = 3;
3980
+ $mol_assert_equal(App.high, 3);
3981
+ }
3982
+ }
3983
+ __decorate([
3984
+ $mol_wire_field
3985
+ ], App, "low", void 0);
3986
+ __decorate([
3987
+ $mol_wire_field
3988
+ ], App, "high", null);
3989
+ __decorate([
3990
+ $mol_wire_method
3991
+ ], App, "test", null);
3992
+ App.test();
3993
+ },
3994
+ });
3995
+ })($ || ($ = {}));
3996
+ //mol/wire/field/field.test.ts
3997
+ ;
3998
+ "use strict";
3999
+ var $;
4000
+ (function ($_1) {
4001
+ $mol_test({
4002
+ 'Watch one value'($) {
4003
+ class App extends $mol_object2 {
4004
+ static $ = $;
4005
+ static set = new $mol_wire_set();
4006
+ static lucky() {
4007
+ return this.set.has(777);
4008
+ }
4009
+ }
4010
+ __decorate([
4011
+ $mol_wire_mem(0)
4012
+ ], App, "lucky", null);
4013
+ $mol_assert_equal(App.lucky(), false);
4014
+ App.set.add(666);
4015
+ $mol_assert_equal(App.lucky(), false);
4016
+ App.set.add(777);
4017
+ $mol_assert_equal(App.lucky(), true);
4018
+ App.set.delete(777);
4019
+ $mol_assert_equal(App.lucky(), false);
4020
+ },
4021
+ 'Watch item channel'($) {
4022
+ class App extends $mol_object2 {
4023
+ static $ = $;
4024
+ static set = new $mol_wire_set();
4025
+ static lucky() {
4026
+ return this.set.item(777);
4027
+ }
4028
+ }
4029
+ __decorate([
4030
+ $mol_wire_mem(0)
4031
+ ], App, "lucky", null);
4032
+ $mol_assert_equal(App.lucky(), false);
4033
+ App.set.item(666, true);
4034
+ $mol_assert_equal(App.lucky(), false);
4035
+ App.set.item(777, true);
4036
+ $mol_assert_equal(App.lucky(), true);
4037
+ App.set.item(777, false);
4038
+ $mol_assert_equal(App.lucky(), false);
4039
+ },
4040
+ 'Watch size'($) {
4041
+ class App extends $mol_object2 {
4042
+ static $ = $;
4043
+ static set = new $mol_wire_set();
4044
+ static size() {
4045
+ return this.set.size;
4046
+ }
4047
+ }
4048
+ __decorate([
4049
+ $mol_wire_mem(0)
4050
+ ], App, "size", null);
4051
+ $mol_assert_equal(App.size(), 0);
4052
+ App.set.add(666);
4053
+ $mol_assert_equal(App.size(), 1);
4054
+ App.set.add(777);
4055
+ $mol_assert_equal(App.size(), 2);
4056
+ App.set.delete(777);
4057
+ $mol_assert_equal(App.size(), 1);
4058
+ },
4059
+ 'Watch for-of'($) {
4060
+ class App extends $mol_object2 {
4061
+ static $ = $;
4062
+ static set = new $mol_wire_set();
4063
+ static sum() {
4064
+ let res = 0;
4065
+ for (const val of this.set) {
4066
+ res += val;
4067
+ }
4068
+ return res;
4069
+ }
4070
+ }
4071
+ __decorate([
4072
+ $mol_wire_mem(0)
4073
+ ], App, "sum", null);
4074
+ $mol_assert_equal(App.sum(), 0);
4075
+ App.set.add(111);
4076
+ $mol_assert_equal(App.sum(), 111);
4077
+ App.set.add(222);
4078
+ $mol_assert_equal(App.sum(), 333);
4079
+ App.set.delete(111);
4080
+ $mol_assert_equal(App.sum(), 222);
4081
+ },
4082
+ 'Watch forEach'($) {
4083
+ class App extends $mol_object2 {
4084
+ static $ = $;
4085
+ static set = new $mol_wire_set();
4086
+ static sum() {
4087
+ let res = 0;
4088
+ this.set.forEach(val => res += val);
4089
+ return res;
4090
+ }
4091
+ }
4092
+ __decorate([
4093
+ $mol_wire_mem(0)
4094
+ ], App, "sum", null);
4095
+ $mol_assert_equal(App.sum(), 0);
4096
+ App.set.add(111);
4097
+ $mol_assert_equal(App.sum(), 111);
4098
+ App.set.add(222);
4099
+ $mol_assert_equal(App.sum(), 333);
4100
+ App.set.delete(111);
4101
+ $mol_assert_equal(App.sum(), 222);
4102
+ },
4103
+ });
4104
+ })($ || ($ = {}));
4105
+ //mol/wire/set/set.test.ts
4106
+ ;
4107
+ "use strict";
4108
+ var $;
4109
+ (function ($_1) {
4110
+ $mol_test({
4111
+ 'Watch one value'($) {
4112
+ class App extends $mol_object2 {
4113
+ static $ = $;
4114
+ static dict = new $mol_wire_dict();
4115
+ static lucky() {
4116
+ return this.dict.get(777);
4117
+ }
4118
+ }
4119
+ __decorate([
4120
+ $mol_wire_mem(0)
4121
+ ], App, "lucky", null);
4122
+ $mol_assert_equal(App.lucky(), undefined);
4123
+ App.dict.set(666, 6666);
4124
+ $mol_assert_equal(App.lucky(), undefined);
4125
+ App.dict.set(777, 7777);
4126
+ $mol_assert_equal(App.lucky(), 7777);
4127
+ App.dict.delete(777);
4128
+ $mol_assert_equal(App.lucky(), undefined);
4129
+ },
4130
+ 'Watch item channel'($) {
4131
+ class App extends $mol_object2 {
4132
+ static $ = $;
4133
+ static dict = new $mol_wire_dict();
4134
+ static lucky() {
4135
+ return this.dict.item(777);
4136
+ }
4137
+ }
4138
+ __decorate([
4139
+ $mol_wire_mem(0)
4140
+ ], App, "lucky", null);
4141
+ $mol_assert_equal(App.lucky(), null);
4142
+ App.dict.item(666, 6666);
4143
+ $mol_assert_equal(App.lucky(), null);
4144
+ App.dict.item(777, 7777);
4145
+ $mol_assert_equal(App.lucky(), 7777);
4146
+ App.dict.item(777, null);
4147
+ $mol_assert_equal(App.lucky(), null);
4148
+ },
4149
+ 'Watch size'($) {
4150
+ class App extends $mol_object2 {
4151
+ static $ = $;
4152
+ static dict = new $mol_wire_dict();
4153
+ static size() {
4154
+ return this.dict.size;
4155
+ }
4156
+ }
4157
+ __decorate([
4158
+ $mol_wire_mem(0)
4159
+ ], App, "size", null);
4160
+ $mol_assert_equal(App.size(), 0);
4161
+ App.dict.set(666, 6666);
4162
+ $mol_assert_equal(App.size(), 1);
4163
+ App.dict.set(777, 7777);
4164
+ $mol_assert_equal(App.size(), 2);
4165
+ App.dict.delete(777);
4166
+ $mol_assert_equal(App.size(), 1);
4167
+ },
4168
+ 'Watch for-of'($) {
4169
+ class App extends $mol_object2 {
4170
+ static $ = $;
4171
+ static dict = new $mol_wire_dict();
4172
+ static sum() {
4173
+ let keys = 0;
4174
+ let vals = 0;
4175
+ for (const [key, val] of this.dict) {
4176
+ keys += key;
4177
+ vals += val;
4178
+ }
4179
+ return [keys, vals];
4180
+ }
4181
+ }
4182
+ __decorate([
4183
+ $mol_wire_mem(0)
4184
+ ], App, "sum", null);
4185
+ $mol_assert_like(App.sum(), [0, 0]);
4186
+ App.dict.set(111, 1111);
4187
+ $mol_assert_like(App.sum(), [111, 1111]);
4188
+ App.dict.set(222, 2222);
4189
+ $mol_assert_like(App.sum(), [333, 3333]);
4190
+ App.dict.delete(111);
4191
+ $mol_assert_like(App.sum(), [222, 2222]);
4192
+ },
4193
+ 'Watch forEach'($) {
4194
+ class App extends $mol_object2 {
4195
+ static $ = $;
4196
+ static dict = new $mol_wire_dict();
4197
+ static sum() {
4198
+ let keys = 0;
4199
+ let vals = 0;
4200
+ this.dict.forEach((val, key) => {
4201
+ keys += key;
4202
+ vals += val;
4203
+ });
4204
+ return [keys, vals];
4205
+ }
4206
+ }
4207
+ __decorate([
4208
+ $mol_wire_mem(0)
4209
+ ], App, "sum", null);
4210
+ $mol_assert_like(App.sum(), [0, 0]);
4211
+ App.dict.set(111, 1111);
4212
+ $mol_assert_like(App.sum(), [111, 1111]);
4213
+ App.dict.set(222, 2222);
4214
+ $mol_assert_like(App.sum(), [333, 3333]);
4215
+ App.dict.delete(111);
4216
+ $mol_assert_like(App.sum(), [222, 2222]);
4217
+ },
4218
+ });
4219
+ })($ || ($ = {}));
4220
+ //mol/wire/dict/dict.test.ts
3618
4221
 
3619
4222
  //# sourceMappingURL=node.test.js.map