mol_jsx_lib 0.0.52 → 0.0.55

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.esm.js CHANGED
@@ -1908,5 +1908,412 @@ var $;
1908
1908
  })($ || ($ = {}));
1909
1909
  //mol/jsx/view/view.tsx
1910
1910
  ;
1911
+ "use strict";
1912
+ var $;
1913
+ (function ($) {
1914
+ function $mol_wire_probe(task, next) {
1915
+ const warm = $mol_wire_fiber.warm;
1916
+ try {
1917
+ $mol_wire_fiber.warm = false;
1918
+ return task();
1919
+ }
1920
+ finally {
1921
+ $mol_wire_fiber.warm = warm;
1922
+ }
1923
+ }
1924
+ $.$mol_wire_probe = $mol_wire_probe;
1925
+ })($ || ($ = {}));
1926
+ //mol/wire/probe/probe.ts
1927
+ ;
1928
+ "use strict";
1929
+ var $;
1930
+ (function ($) {
1931
+ function $mol_wire_solid() {
1932
+ $mol_wire_auto().reap = nothing;
1933
+ }
1934
+ $.$mol_wire_solid = $mol_wire_solid;
1935
+ const nothing = () => { };
1936
+ })($ || ($ = {}));
1937
+ //mol/wire/solid/solid.ts
1938
+ ;
1939
+ "use strict";
1940
+ var $;
1941
+ (function ($) {
1942
+ function $mol_wire_watch() {
1943
+ const atom = $mol_wire_auto();
1944
+ if (atom instanceof $mol_wire_atom) {
1945
+ atom.watch();
1946
+ }
1947
+ else {
1948
+ $mol_fail(new Error('Atom is equired for watching'));
1949
+ }
1950
+ }
1951
+ $.$mol_wire_watch = $mol_wire_watch;
1952
+ })($ || ($ = {}));
1953
+ //mol/wire/watch/watch.ts
1954
+ ;
1955
+ "use strict";
1956
+ var $;
1957
+ (function ($) {
1958
+ function $mol_wire_sync(obj) {
1959
+ return new Proxy(obj, {
1960
+ get(obj, field) {
1961
+ const val = obj[field];
1962
+ if (typeof val !== 'function')
1963
+ return val;
1964
+ const temp = $mol_wire_task.getter(val);
1965
+ return function $mol_wire_sync(...args) {
1966
+ const fiber = temp(obj, args);
1967
+ return fiber.sync();
1968
+ };
1969
+ },
1970
+ apply(obj, self, args) {
1971
+ const temp = $mol_wire_task.getter(obj);
1972
+ const fiber = temp(self, args);
1973
+ return fiber.sync();
1974
+ },
1975
+ });
1976
+ }
1977
+ $.$mol_wire_sync = $mol_wire_sync;
1978
+ })($ || ($ = {}));
1979
+ //mol/wire/sync/sync.ts
1980
+ ;
1981
+ "use strict";
1982
+ var $;
1983
+ (function ($) {
1984
+ function $mol_wire_async(obj) {
1985
+ let fiber;
1986
+ const temp = $mol_wire_task.getter(obj);
1987
+ return new Proxy(obj, {
1988
+ get(obj, field) {
1989
+ const val = obj[field];
1990
+ if (typeof val !== 'function')
1991
+ return val;
1992
+ let fiber;
1993
+ const temp = $mol_wire_task.getter(val);
1994
+ return function $mol_wire_async(...args) {
1995
+ fiber?.destructor();
1996
+ fiber = temp(obj, args);
1997
+ return fiber.async();
1998
+ };
1999
+ },
2000
+ apply(obj, self, args) {
2001
+ fiber?.destructor();
2002
+ fiber = temp(self, args);
2003
+ return fiber.async();
2004
+ },
2005
+ });
2006
+ }
2007
+ $.$mol_wire_async = $mol_wire_async;
2008
+ })($ || ($ = {}));
2009
+ //mol/wire/async/async.ts
2010
+ ;
2011
+ "use strict";
2012
+ var $;
2013
+ (function ($) {
2014
+ function $mol_const(value) {
2015
+ var getter = (() => value);
2016
+ getter['()'] = value;
2017
+ getter[Symbol.toStringTag] = value;
2018
+ return getter;
2019
+ }
2020
+ $.$mol_const = $mol_const;
2021
+ })($ || ($ = {}));
2022
+ //mol/const/const.ts
2023
+ ;
2024
+ "use strict";
2025
+ var $;
2026
+ (function ($) {
2027
+ function $mol_wire_field(host, field, descr) {
2028
+ if (!descr)
2029
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
2030
+ const _get = descr?.get || $mol_const(descr?.value);
2031
+ const persist = $mol_wire_atom.getter(_get, 0);
2032
+ const _set = descr?.set || function (next) {
2033
+ persist(this, []).put(next);
2034
+ };
2035
+ const sup = Reflect.getPrototypeOf(host);
2036
+ const sup_descr = Reflect.getOwnPropertyDescriptor(sup, field);
2037
+ Object.defineProperty(_get, 'name', { value: sup_descr?.get?.name ?? field });
2038
+ Object.defineProperty(_set, 'name', { value: sup_descr?.set?.name ?? field });
2039
+ function get() {
2040
+ return persist(this, []).sync();
2041
+ }
2042
+ const temp = $mol_wire_task.getter(_set);
2043
+ function set(next) {
2044
+ temp(this, [next]).sync();
2045
+ }
2046
+ Object.defineProperty(get, 'name', { value: _get.name + '$' });
2047
+ Object.defineProperty(set, 'name', { value: _set.name + '@' });
2048
+ Object.assign(get, { orig: _get });
2049
+ Object.assign(set, { orig: _set });
2050
+ const { value, writable, ...descr2 } = { ...descr, get, set };
2051
+ Reflect.defineProperty(host, field, descr2);
2052
+ return descr2;
2053
+ }
2054
+ $.$mol_wire_field = $mol_wire_field;
2055
+ })($ || ($ = {}));
2056
+ //mol/wire/field/field.ts
2057
+ ;
2058
+ "use strict";
2059
+ var $;
2060
+ (function ($) {
2061
+ function $mol_wire_patch(obj) {
2062
+ for (const field of Reflect.ownKeys(obj)) {
2063
+ const descr = Reflect.getOwnPropertyDescriptor(obj, field);
2064
+ if (!descr.configurable)
2065
+ continue;
2066
+ if (!descr.get)
2067
+ continue;
2068
+ const get = descr.get ?? (() => descr.value);
2069
+ const set = descr.set ?? (next => descr.value = next);
2070
+ const persist = $mol_wire_atom.getter(get, 0);
2071
+ Reflect.defineProperty(obj, field, {
2072
+ configurable: true,
2073
+ enumerable: descr.enumerable,
2074
+ get() {
2075
+ const atom = persist(obj, []);
2076
+ atom.watch();
2077
+ return atom.sync();
2078
+ },
2079
+ set(next) {
2080
+ const atom = persist(obj, []);
2081
+ set.call(this, next);
2082
+ atom.refresh();
2083
+ },
2084
+ });
2085
+ }
2086
+ }
2087
+ $.$mol_wire_patch = $mol_wire_patch;
2088
+ })($ || ($ = {}));
2089
+ //mol/wire/patch/patch.ts
2090
+ ;
2091
+ "use strict";
2092
+ var $;
2093
+ (function ($) {
2094
+ class $mol_wire_set extends Set {
2095
+ pub = new $mol_wire_pub;
2096
+ has(value) {
2097
+ this.pub.promote();
2098
+ return super.has(value);
2099
+ }
2100
+ entries() {
2101
+ this.pub.promote();
2102
+ return super.entries();
2103
+ }
2104
+ keys() {
2105
+ this.pub.promote();
2106
+ return super.keys();
2107
+ }
2108
+ values() {
2109
+ this.pub.promote();
2110
+ return super.values();
2111
+ }
2112
+ forEach(task, self) {
2113
+ this.pub.promote();
2114
+ super.forEach(task, self);
2115
+ }
2116
+ [Symbol.iterator]() {
2117
+ this.pub.promote();
2118
+ return super[Symbol.iterator]();
2119
+ }
2120
+ get size() {
2121
+ this.pub.promote();
2122
+ return super.size;
2123
+ }
2124
+ add(value) {
2125
+ if (super.has(value))
2126
+ return this;
2127
+ super.add(value);
2128
+ this.pub.emit();
2129
+ return this;
2130
+ }
2131
+ delete(value) {
2132
+ const res = super.delete(value);
2133
+ if (res)
2134
+ this.pub.emit();
2135
+ return res;
2136
+ }
2137
+ clear() {
2138
+ if (!super.size)
2139
+ return;
2140
+ super.clear();
2141
+ this.pub.emit();
2142
+ }
2143
+ item(val, next) {
2144
+ if (next === undefined)
2145
+ return this.has(val);
2146
+ if (next)
2147
+ this.add(val);
2148
+ else
2149
+ this.delete(val);
2150
+ return next;
2151
+ }
2152
+ }
2153
+ $.$mol_wire_set = $mol_wire_set;
2154
+ })($ || ($ = {}));
2155
+ //mol/wire/set/set.ts
2156
+ ;
2157
+ "use strict";
2158
+ var $;
2159
+ (function ($) {
2160
+ class $mol_wire_dict extends Map {
2161
+ pub = new $mol_wire_pub;
2162
+ has(key) {
2163
+ this.pub.promote();
2164
+ return super.has(key);
2165
+ }
2166
+ get(key) {
2167
+ this.pub.promote();
2168
+ return super.get(key);
2169
+ }
2170
+ entries() {
2171
+ this.pub.promote();
2172
+ return super.entries();
2173
+ }
2174
+ keys() {
2175
+ this.pub.promote();
2176
+ return super.keys();
2177
+ }
2178
+ values() {
2179
+ this.pub.promote();
2180
+ return super.values();
2181
+ }
2182
+ forEach(task, self) {
2183
+ this.pub.promote();
2184
+ super.forEach(task, self);
2185
+ }
2186
+ [Symbol.iterator]() {
2187
+ this.pub.promote();
2188
+ return super[Symbol.iterator]();
2189
+ }
2190
+ get size() {
2191
+ this.pub.promote();
2192
+ return super.size;
2193
+ }
2194
+ set(key, value) {
2195
+ if (super.get(key) === value)
2196
+ return this;
2197
+ super.set(key, value);
2198
+ this.pub.emit();
2199
+ return this;
2200
+ }
2201
+ delete(key) {
2202
+ const res = super.delete(key);
2203
+ if (res)
2204
+ this.pub.emit();
2205
+ return res;
2206
+ }
2207
+ clear() {
2208
+ if (!super.size)
2209
+ return;
2210
+ super.clear();
2211
+ this.pub.emit();
2212
+ }
2213
+ item(key, next) {
2214
+ if (next === undefined)
2215
+ return this.get(key) ?? null;
2216
+ if (next === null)
2217
+ this.delete(key);
2218
+ else
2219
+ this.set(key, next);
2220
+ return next;
2221
+ }
2222
+ }
2223
+ $.$mol_wire_dict = $mol_wire_dict;
2224
+ })($ || ($ = {}));
2225
+ //mol/wire/dict/dict.ts
2226
+ ;
2227
+ "use strict";
2228
+ var $;
2229
+ (function ($) {
2230
+ function $mol_promise() {
2231
+ let done;
2232
+ let fail;
2233
+ const promise = new Promise((d, f) => {
2234
+ done = d;
2235
+ fail = f;
2236
+ });
2237
+ return Object.assign(promise, {
2238
+ done,
2239
+ fail,
2240
+ });
2241
+ }
2242
+ $.$mol_promise = $mol_promise;
2243
+ })($ || ($ = {}));
2244
+ //mol/promise/promise.ts
2245
+ ;
2246
+ "use strict";
2247
+ var $;
2248
+ (function ($) {
2249
+ function $mol_wait_timeout_async(timeout) {
2250
+ const promise = $mol_promise();
2251
+ const task = new this.$mol_after_timeout(timeout, () => promise.done());
2252
+ return Object.assign(promise, {
2253
+ destructor: () => task.destructor()
2254
+ });
2255
+ }
2256
+ $.$mol_wait_timeout_async = $mol_wait_timeout_async;
2257
+ function $mol_wait_timeout(timeout) {
2258
+ return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
2259
+ }
2260
+ $.$mol_wait_timeout = $mol_wait_timeout;
2261
+ })($ || ($ = {}));
2262
+ //mol/wait/timeout/timeout.ts
2263
+ ;
2264
+ "use strict";
2265
+ var $;
2266
+ (function ($) {
2267
+ class $mol_wire_log extends $mol_object2 {
2268
+ static watch(task) {
2269
+ return task;
2270
+ }
2271
+ static track(fiber) {
2272
+ const prev = $mol_wire_probe(() => this.track(fiber));
2273
+ let next;
2274
+ try {
2275
+ next = fiber.sync();
2276
+ }
2277
+ finally {
2278
+ for (const pub of fiber.pub_list) {
2279
+ if (pub instanceof $mol_wire_fiber) {
2280
+ this.track(pub);
2281
+ }
2282
+ }
2283
+ }
2284
+ if (prev !== undefined && !$mol_compare_deep(prev, next)) {
2285
+ this.$.$mol_log3_rise({
2286
+ message: 'Changed',
2287
+ place: fiber,
2288
+ });
2289
+ }
2290
+ return next;
2291
+ }
2292
+ static active() {
2293
+ try {
2294
+ this.watch()?.();
2295
+ }
2296
+ finally {
2297
+ for (const pub of $mol_wire_auto().pub_list) {
2298
+ if (pub instanceof $mol_wire_fiber) {
2299
+ this.track(pub);
2300
+ }
2301
+ }
2302
+ }
2303
+ }
2304
+ }
2305
+ __decorate([
2306
+ $mol_mem
2307
+ ], $mol_wire_log, "watch", null);
2308
+ __decorate([
2309
+ $mol_mem_key
2310
+ ], $mol_wire_log, "track", null);
2311
+ __decorate([
2312
+ $mol_mem
2313
+ ], $mol_wire_log, "active", null);
2314
+ $.$mol_wire_log = $mol_wire_log;
2315
+ })($ || ($ = {}));
2316
+ //mol/wire/log/log.ts
2317
+ ;
1911
2318
  export default $
1912
2319
  //# sourceMappingURL=node.esm.js.map