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.esm.js CHANGED
@@ -729,6 +729,34 @@ var $;
729
729
  ;
730
730
  "use strict";
731
731
  var $;
732
+ (function ($) {
733
+ function $mol_func_name(func) {
734
+ let name = func.name;
735
+ if (name?.length > 1)
736
+ return name;
737
+ for (let key in this) {
738
+ try {
739
+ if (this[key] !== func)
740
+ continue;
741
+ name = key;
742
+ Object.defineProperty(func, 'name', { value: name });
743
+ break;
744
+ }
745
+ catch { }
746
+ }
747
+ return name;
748
+ }
749
+ $.$mol_func_name = $mol_func_name;
750
+ function $mol_func_name_from(target, source) {
751
+ Object.defineProperty(target, 'name', { value: source.name });
752
+ return target;
753
+ }
754
+ $.$mol_func_name_from = $mol_func_name_from;
755
+ })($ || ($ = {}));
756
+ //mol/func/name/name.ts
757
+ ;
758
+ "use strict";
759
+ var $;
732
760
  (function ($) {
733
761
  function $mol_dom_render_children(el, childNodes) {
734
762
  const node_set = new Set(childNodes);
@@ -798,16 +826,40 @@ var $;
798
826
  $.$mol_jsx_frag = '';
799
827
  function $mol_jsx(Elem, props, ...childNodes) {
800
828
  const id = props && props.id || '';
829
+ const guid = $.$mol_jsx_prefix + id;
801
830
  if (Elem && $.$mol_jsx_booked) {
802
831
  if ($.$mol_jsx_booked.has(id)) {
803
- $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
832
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
804
833
  }
805
834
  else {
806
835
  $.$mol_jsx_booked.add(id);
807
836
  }
808
837
  }
809
- const guid = $.$mol_jsx_prefix + id;
810
838
  let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
839
+ if ($.$mol_jsx_prefix) {
840
+ const prefix_ext = $.$mol_jsx_prefix;
841
+ const booked_ext = $.$mol_jsx_booked;
842
+ for (const field in props) {
843
+ const func = props[field];
844
+ if (typeof func !== 'function')
845
+ continue;
846
+ const wrapper = function (...args) {
847
+ const prefix = $.$mol_jsx_prefix;
848
+ const booked = $.$mol_jsx_booked;
849
+ try {
850
+ $.$mol_jsx_prefix = prefix_ext;
851
+ $.$mol_jsx_booked = booked_ext;
852
+ return func.call(this, ...args);
853
+ }
854
+ finally {
855
+ $.$mol_jsx_prefix = prefix;
856
+ $.$mol_jsx_booked = booked;
857
+ }
858
+ };
859
+ $mol_func_name_from(wrapper, func);
860
+ props[field] = wrapper;
861
+ }
862
+ }
811
863
  if (typeof Elem !== 'string') {
812
864
  if ('prototype' in Elem) {
813
865
  const view = node && node[Elem] || new Elem;
@@ -1908,5 +1960,412 @@ var $;
1908
1960
  })($ || ($ = {}));
1909
1961
  //mol/jsx/view/view.tsx
1910
1962
  ;
1963
+ "use strict";
1964
+ var $;
1965
+ (function ($) {
1966
+ function $mol_wire_probe(task, next) {
1967
+ const warm = $mol_wire_fiber.warm;
1968
+ try {
1969
+ $mol_wire_fiber.warm = false;
1970
+ return task();
1971
+ }
1972
+ finally {
1973
+ $mol_wire_fiber.warm = warm;
1974
+ }
1975
+ }
1976
+ $.$mol_wire_probe = $mol_wire_probe;
1977
+ })($ || ($ = {}));
1978
+ //mol/wire/probe/probe.ts
1979
+ ;
1980
+ "use strict";
1981
+ var $;
1982
+ (function ($) {
1983
+ function $mol_wire_solid() {
1984
+ $mol_wire_auto().reap = nothing;
1985
+ }
1986
+ $.$mol_wire_solid = $mol_wire_solid;
1987
+ const nothing = () => { };
1988
+ })($ || ($ = {}));
1989
+ //mol/wire/solid/solid.ts
1990
+ ;
1991
+ "use strict";
1992
+ var $;
1993
+ (function ($) {
1994
+ function $mol_wire_watch() {
1995
+ const atom = $mol_wire_auto();
1996
+ if (atom instanceof $mol_wire_atom) {
1997
+ atom.watch();
1998
+ }
1999
+ else {
2000
+ $mol_fail(new Error('Atom is equired for watching'));
2001
+ }
2002
+ }
2003
+ $.$mol_wire_watch = $mol_wire_watch;
2004
+ })($ || ($ = {}));
2005
+ //mol/wire/watch/watch.ts
2006
+ ;
2007
+ "use strict";
2008
+ var $;
2009
+ (function ($) {
2010
+ function $mol_wire_sync(obj) {
2011
+ return new Proxy(obj, {
2012
+ get(obj, field) {
2013
+ const val = obj[field];
2014
+ if (typeof val !== 'function')
2015
+ return val;
2016
+ const temp = $mol_wire_task.getter(val);
2017
+ return function $mol_wire_sync(...args) {
2018
+ const fiber = temp(obj, args);
2019
+ return fiber.sync();
2020
+ };
2021
+ },
2022
+ apply(obj, self, args) {
2023
+ const temp = $mol_wire_task.getter(obj);
2024
+ const fiber = temp(self, args);
2025
+ return fiber.sync();
2026
+ },
2027
+ });
2028
+ }
2029
+ $.$mol_wire_sync = $mol_wire_sync;
2030
+ })($ || ($ = {}));
2031
+ //mol/wire/sync/sync.ts
2032
+ ;
2033
+ "use strict";
2034
+ var $;
2035
+ (function ($) {
2036
+ function $mol_wire_async(obj) {
2037
+ let fiber;
2038
+ const temp = $mol_wire_task.getter(obj);
2039
+ return new Proxy(obj, {
2040
+ get(obj, field) {
2041
+ const val = obj[field];
2042
+ if (typeof val !== 'function')
2043
+ return val;
2044
+ let fiber;
2045
+ const temp = $mol_wire_task.getter(val);
2046
+ return function $mol_wire_async(...args) {
2047
+ fiber?.destructor();
2048
+ fiber = temp(obj, args);
2049
+ return fiber.async();
2050
+ };
2051
+ },
2052
+ apply(obj, self, args) {
2053
+ fiber?.destructor();
2054
+ fiber = temp(self, args);
2055
+ return fiber.async();
2056
+ },
2057
+ });
2058
+ }
2059
+ $.$mol_wire_async = $mol_wire_async;
2060
+ })($ || ($ = {}));
2061
+ //mol/wire/async/async.ts
2062
+ ;
2063
+ "use strict";
2064
+ var $;
2065
+ (function ($) {
2066
+ function $mol_const(value) {
2067
+ var getter = (() => value);
2068
+ getter['()'] = value;
2069
+ getter[Symbol.toStringTag] = value;
2070
+ return getter;
2071
+ }
2072
+ $.$mol_const = $mol_const;
2073
+ })($ || ($ = {}));
2074
+ //mol/const/const.ts
2075
+ ;
2076
+ "use strict";
2077
+ var $;
2078
+ (function ($) {
2079
+ function $mol_wire_field(host, field, descr) {
2080
+ if (!descr)
2081
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
2082
+ const _get = descr?.get || $mol_const(descr?.value);
2083
+ const persist = $mol_wire_atom.getter(_get, 0);
2084
+ const _set = descr?.set || function (next) {
2085
+ persist(this, []).put(next);
2086
+ };
2087
+ const sup = Reflect.getPrototypeOf(host);
2088
+ const sup_descr = Reflect.getOwnPropertyDescriptor(sup, field);
2089
+ Object.defineProperty(_get, 'name', { value: sup_descr?.get?.name ?? field });
2090
+ Object.defineProperty(_set, 'name', { value: sup_descr?.set?.name ?? field });
2091
+ function get() {
2092
+ return persist(this, []).sync();
2093
+ }
2094
+ const temp = $mol_wire_task.getter(_set);
2095
+ function set(next) {
2096
+ temp(this, [next]).sync();
2097
+ }
2098
+ Object.defineProperty(get, 'name', { value: _get.name + '$' });
2099
+ Object.defineProperty(set, 'name', { value: _set.name + '@' });
2100
+ Object.assign(get, { orig: _get });
2101
+ Object.assign(set, { orig: _set });
2102
+ const { value, writable, ...descr2 } = { ...descr, get, set };
2103
+ Reflect.defineProperty(host, field, descr2);
2104
+ return descr2;
2105
+ }
2106
+ $.$mol_wire_field = $mol_wire_field;
2107
+ })($ || ($ = {}));
2108
+ //mol/wire/field/field.ts
2109
+ ;
2110
+ "use strict";
2111
+ var $;
2112
+ (function ($) {
2113
+ function $mol_wire_patch(obj) {
2114
+ for (const field of Reflect.ownKeys(obj)) {
2115
+ const descr = Reflect.getOwnPropertyDescriptor(obj, field);
2116
+ if (!descr.configurable)
2117
+ continue;
2118
+ if (!descr.get)
2119
+ continue;
2120
+ const get = descr.get ?? (() => descr.value);
2121
+ const set = descr.set ?? (next => descr.value = next);
2122
+ const persist = $mol_wire_atom.getter(get, 0);
2123
+ Reflect.defineProperty(obj, field, {
2124
+ configurable: true,
2125
+ enumerable: descr.enumerable,
2126
+ get() {
2127
+ const atom = persist(obj, []);
2128
+ atom.watch();
2129
+ return atom.sync();
2130
+ },
2131
+ set(next) {
2132
+ const atom = persist(obj, []);
2133
+ set.call(this, next);
2134
+ atom.refresh();
2135
+ },
2136
+ });
2137
+ }
2138
+ }
2139
+ $.$mol_wire_patch = $mol_wire_patch;
2140
+ })($ || ($ = {}));
2141
+ //mol/wire/patch/patch.ts
2142
+ ;
2143
+ "use strict";
2144
+ var $;
2145
+ (function ($) {
2146
+ class $mol_wire_set extends Set {
2147
+ pub = new $mol_wire_pub;
2148
+ has(value) {
2149
+ this.pub.promote();
2150
+ return super.has(value);
2151
+ }
2152
+ entries() {
2153
+ this.pub.promote();
2154
+ return super.entries();
2155
+ }
2156
+ keys() {
2157
+ this.pub.promote();
2158
+ return super.keys();
2159
+ }
2160
+ values() {
2161
+ this.pub.promote();
2162
+ return super.values();
2163
+ }
2164
+ forEach(task, self) {
2165
+ this.pub.promote();
2166
+ super.forEach(task, self);
2167
+ }
2168
+ [Symbol.iterator]() {
2169
+ this.pub.promote();
2170
+ return super[Symbol.iterator]();
2171
+ }
2172
+ get size() {
2173
+ this.pub.promote();
2174
+ return super.size;
2175
+ }
2176
+ add(value) {
2177
+ if (super.has(value))
2178
+ return this;
2179
+ super.add(value);
2180
+ this.pub.emit();
2181
+ return this;
2182
+ }
2183
+ delete(value) {
2184
+ const res = super.delete(value);
2185
+ if (res)
2186
+ this.pub.emit();
2187
+ return res;
2188
+ }
2189
+ clear() {
2190
+ if (!super.size)
2191
+ return;
2192
+ super.clear();
2193
+ this.pub.emit();
2194
+ }
2195
+ item(val, next) {
2196
+ if (next === undefined)
2197
+ return this.has(val);
2198
+ if (next)
2199
+ this.add(val);
2200
+ else
2201
+ this.delete(val);
2202
+ return next;
2203
+ }
2204
+ }
2205
+ $.$mol_wire_set = $mol_wire_set;
2206
+ })($ || ($ = {}));
2207
+ //mol/wire/set/set.ts
2208
+ ;
2209
+ "use strict";
2210
+ var $;
2211
+ (function ($) {
2212
+ class $mol_wire_dict extends Map {
2213
+ pub = new $mol_wire_pub;
2214
+ has(key) {
2215
+ this.pub.promote();
2216
+ return super.has(key);
2217
+ }
2218
+ get(key) {
2219
+ this.pub.promote();
2220
+ return super.get(key);
2221
+ }
2222
+ entries() {
2223
+ this.pub.promote();
2224
+ return super.entries();
2225
+ }
2226
+ keys() {
2227
+ this.pub.promote();
2228
+ return super.keys();
2229
+ }
2230
+ values() {
2231
+ this.pub.promote();
2232
+ return super.values();
2233
+ }
2234
+ forEach(task, self) {
2235
+ this.pub.promote();
2236
+ super.forEach(task, self);
2237
+ }
2238
+ [Symbol.iterator]() {
2239
+ this.pub.promote();
2240
+ return super[Symbol.iterator]();
2241
+ }
2242
+ get size() {
2243
+ this.pub.promote();
2244
+ return super.size;
2245
+ }
2246
+ set(key, value) {
2247
+ if (super.get(key) === value)
2248
+ return this;
2249
+ super.set(key, value);
2250
+ this.pub.emit();
2251
+ return this;
2252
+ }
2253
+ delete(key) {
2254
+ const res = super.delete(key);
2255
+ if (res)
2256
+ this.pub.emit();
2257
+ return res;
2258
+ }
2259
+ clear() {
2260
+ if (!super.size)
2261
+ return;
2262
+ super.clear();
2263
+ this.pub.emit();
2264
+ }
2265
+ item(key, next) {
2266
+ if (next === undefined)
2267
+ return this.get(key) ?? null;
2268
+ if (next === null)
2269
+ this.delete(key);
2270
+ else
2271
+ this.set(key, next);
2272
+ return next;
2273
+ }
2274
+ }
2275
+ $.$mol_wire_dict = $mol_wire_dict;
2276
+ })($ || ($ = {}));
2277
+ //mol/wire/dict/dict.ts
2278
+ ;
2279
+ "use strict";
2280
+ var $;
2281
+ (function ($) {
2282
+ function $mol_promise() {
2283
+ let done;
2284
+ let fail;
2285
+ const promise = new Promise((d, f) => {
2286
+ done = d;
2287
+ fail = f;
2288
+ });
2289
+ return Object.assign(promise, {
2290
+ done,
2291
+ fail,
2292
+ });
2293
+ }
2294
+ $.$mol_promise = $mol_promise;
2295
+ })($ || ($ = {}));
2296
+ //mol/promise/promise.ts
2297
+ ;
2298
+ "use strict";
2299
+ var $;
2300
+ (function ($) {
2301
+ function $mol_wait_timeout_async(timeout) {
2302
+ const promise = $mol_promise();
2303
+ const task = new this.$mol_after_timeout(timeout, () => promise.done());
2304
+ return Object.assign(promise, {
2305
+ destructor: () => task.destructor()
2306
+ });
2307
+ }
2308
+ $.$mol_wait_timeout_async = $mol_wait_timeout_async;
2309
+ function $mol_wait_timeout(timeout) {
2310
+ return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
2311
+ }
2312
+ $.$mol_wait_timeout = $mol_wait_timeout;
2313
+ })($ || ($ = {}));
2314
+ //mol/wait/timeout/timeout.ts
2315
+ ;
2316
+ "use strict";
2317
+ var $;
2318
+ (function ($) {
2319
+ class $mol_wire_log extends $mol_object2 {
2320
+ static watch(task) {
2321
+ return task;
2322
+ }
2323
+ static track(fiber) {
2324
+ const prev = $mol_wire_probe(() => this.track(fiber));
2325
+ let next;
2326
+ try {
2327
+ next = fiber.sync();
2328
+ }
2329
+ finally {
2330
+ for (const pub of fiber.pub_list) {
2331
+ if (pub instanceof $mol_wire_fiber) {
2332
+ this.track(pub);
2333
+ }
2334
+ }
2335
+ }
2336
+ if (prev !== undefined && !$mol_compare_deep(prev, next)) {
2337
+ this.$.$mol_log3_rise({
2338
+ message: 'Changed',
2339
+ place: fiber,
2340
+ });
2341
+ }
2342
+ return next;
2343
+ }
2344
+ static active() {
2345
+ try {
2346
+ this.watch()?.();
2347
+ }
2348
+ finally {
2349
+ for (const pub of $mol_wire_auto().pub_list) {
2350
+ if (pub instanceof $mol_wire_fiber) {
2351
+ this.track(pub);
2352
+ }
2353
+ }
2354
+ }
2355
+ }
2356
+ }
2357
+ __decorate([
2358
+ $mol_mem
2359
+ ], $mol_wire_log, "watch", null);
2360
+ __decorate([
2361
+ $mol_mem_key
2362
+ ], $mol_wire_log, "track", null);
2363
+ __decorate([
2364
+ $mol_mem
2365
+ ], $mol_wire_log, "active", null);
2366
+ $.$mol_wire_log = $mol_wire_log;
2367
+ })($ || ($ = {}));
2368
+ //mol/wire/log/log.ts
2369
+ ;
1911
2370
  export default $
1912
2371
  //# sourceMappingURL=node.esm.js.map