mol_dump_lib 0.0.804 → 0.0.806

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.mjs CHANGED
@@ -28,6 +28,231 @@ 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
+ })($ || ($ = {}));
36
+
37
+ ;
38
+ "use strict";
39
+
40
+ ;
41
+ "use strict";
42
+ var $;
43
+ (function ($) {
44
+ function $mol_fail(error) {
45
+ throw error;
46
+ }
47
+ $.$mol_fail = $mol_fail;
48
+ })($ || ($ = {}));
49
+
50
+ ;
51
+ "use strict";
52
+ var $;
53
+ (function ($) {
54
+ function $mol_promise_like(val) {
55
+ try {
56
+ return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
57
+ }
58
+ catch {
59
+ return false;
60
+ }
61
+ }
62
+ $.$mol_promise_like = $mol_promise_like;
63
+ })($ || ($ = {}));
64
+
65
+ ;
66
+ "use strict";
67
+ var $;
68
+ (function ($) {
69
+ function $mol_fail_hidden(error) {
70
+ throw error;
71
+ }
72
+ $.$mol_fail_hidden = $mol_fail_hidden;
73
+ })($ || ($ = {}));
74
+
75
+ ;
76
+ "use strict";
77
+ var $;
78
+ (function ($) {
79
+ const catched = new WeakMap();
80
+ function $mol_fail_catch(error) {
81
+ if (typeof error !== 'object')
82
+ return false;
83
+ if ($mol_promise_like(error))
84
+ $mol_fail_hidden(error);
85
+ if (catched.get(error))
86
+ return false;
87
+ catched.set(error, true);
88
+ return true;
89
+ }
90
+ $.$mol_fail_catch = $mol_fail_catch;
91
+ })($ || ($ = {}));
92
+
93
+ ;
94
+ "use strict";
95
+ var $;
96
+ (function ($) {
97
+ function $mol_try(handler) {
98
+ try {
99
+ return handler();
100
+ }
101
+ catch (error) {
102
+ return error;
103
+ }
104
+ }
105
+ $.$mol_try = $mol_try;
106
+ })($ || ($ = {}));
107
+
108
+ ;
109
+ "use strict";
110
+ var $;
111
+ (function ($) {
112
+ function $mol_fail_log(error) {
113
+ if ($mol_promise_like(error))
114
+ return false;
115
+ if (!$mol_fail_catch(error))
116
+ return false;
117
+ $mol_try(() => { $mol_fail_hidden(error); });
118
+ return true;
119
+ }
120
+ $.$mol_fail_log = $mol_fail_log;
121
+ })($ || ($ = {}));
122
+
123
+ ;
124
+ "use strict";
125
+ var $node = new Proxy({ require }, {
126
+ get(target, name, wrapper) {
127
+ if (target[name])
128
+ return target[name];
129
+ if (name.startsWith('node:'))
130
+ return target.require(name);
131
+ if (name[0] === '.')
132
+ return target.require(name);
133
+ const mod = target.require('module');
134
+ if (mod.builtinModules.indexOf(name) >= 0)
135
+ return target.require(name);
136
+ try {
137
+ target.require.resolve(name);
138
+ }
139
+ catch {
140
+ const $$ = $;
141
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
142
+ try {
143
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
144
+ }
145
+ catch (e) {
146
+ if ($$.$mol_fail_catch(e)) {
147
+ $$.$mol_fail_log(e);
148
+ }
149
+ }
150
+ }
151
+ try {
152
+ return target.require(name);
153
+ }
154
+ catch (error) {
155
+ if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
156
+ const module = cache.get(name);
157
+ if (module)
158
+ return module;
159
+ throw import(name).then(module => cache.set(name, module));
160
+ }
161
+ $.$mol_fail_log(error);
162
+ return null;
163
+ }
164
+ },
165
+ set(target, name, value) {
166
+ target[name] = value;
167
+ return true;
168
+ },
169
+ });
170
+ const cache = new Map();
171
+ require = (req => Object.assign(function require(name) {
172
+ return $node[name];
173
+ }, req))(require);
174
+
175
+ ;
176
+ "use strict";
177
+ var $;
178
+ (function ($) {
179
+ const named = new WeakSet();
180
+ function $mol_func_name(func) {
181
+ let name = func.name;
182
+ if (name?.length > 1)
183
+ return name;
184
+ if (named.has(func))
185
+ return name;
186
+ for (let key in this) {
187
+ try {
188
+ if (this[key] !== func)
189
+ continue;
190
+ name = key;
191
+ Object.defineProperty(func, 'name', { value: name });
192
+ break;
193
+ }
194
+ catch { }
195
+ }
196
+ named.add(func);
197
+ return name;
198
+ }
199
+ $.$mol_func_name = $mol_func_name;
200
+ function $mol_func_name_from(target, source) {
201
+ Object.defineProperty(target, 'name', { value: source.name });
202
+ return target;
203
+ }
204
+ $.$mol_func_name_from = $mol_func_name_from;
205
+ })($ || ($ = {}));
206
+
207
+ ;
208
+ "use strict";
209
+ var $;
210
+ (function ($) {
211
+ function cause_serialize(cause) {
212
+ return JSON.stringify(cause, null, ' ')
213
+ .replace(/\(/, '<')
214
+ .replace(/\)/, ' >');
215
+ }
216
+ function frame_normalize(frame) {
217
+ return (typeof frame === 'string' ? frame : cause_serialize(frame))
218
+ .trim()
219
+ .replace(/at /gm, ' at ')
220
+ .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
221
+ }
222
+ class $mol_error_mix extends AggregateError {
223
+ cause;
224
+ name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
225
+ constructor(message, cause = {}, ...errors) {
226
+ super(errors, message, { cause });
227
+ this.cause = cause;
228
+ const desc = Object.getOwnPropertyDescriptor(this, 'stack');
229
+ const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
230
+ Object.defineProperty(this, 'stack', {
231
+ get: () => stack_get() + '\n' + [
232
+ this.cause ?? 'no cause',
233
+ ...this.errors.flatMap(e => [
234
+ String(e.stack),
235
+ ...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
236
+ ])
237
+ ].map(frame_normalize).join('\n')
238
+ });
239
+ Object.defineProperty(this, 'cause', {
240
+ get: () => cause
241
+ });
242
+ }
243
+ static [Symbol.toPrimitive]() {
244
+ return this.toString();
245
+ }
246
+ static toString() {
247
+ return $$.$mol_func_name(this);
248
+ }
249
+ static make(...params) {
250
+ return new this(...params);
251
+ }
252
+ }
253
+ $.$mol_error_mix = $mol_error_mix;
254
+ })($ || ($ = {}));
255
+
31
256
  ;
32
257
  "use strict";
33
258
  var $;
@@ -132,61 +357,9 @@ var $;
132
357
  $.$mol_owning_catch = $mol_owning_catch;
133
358
  })($ || ($ = {}));
134
359
 
135
- ;
136
- "use strict";
137
- var $;
138
- (function ($) {
139
- function $mol_fail(error) {
140
- throw error;
141
- }
142
- $.$mol_fail = $mol_fail;
143
- })($ || ($ = {}));
144
-
145
- ;
146
- "use strict";
147
- var $;
148
- (function ($) {
149
- function $mol_fail_hidden(error) {
150
- throw error;
151
- }
152
- $.$mol_fail_hidden = $mol_fail_hidden;
153
- })($ || ($ = {}));
154
-
155
360
  ;
156
361
  "use strict";
157
362
 
158
- ;
159
- "use strict";
160
- var $;
161
- (function ($) {
162
- const named = new WeakSet();
163
- function $mol_func_name(func) {
164
- let name = func.name;
165
- if (name?.length > 1)
166
- return name;
167
- if (named.has(func))
168
- return name;
169
- for (let key in this) {
170
- try {
171
- if (this[key] !== func)
172
- continue;
173
- name = key;
174
- Object.defineProperty(func, 'name', { value: name });
175
- break;
176
- }
177
- catch { }
178
- }
179
- named.add(func);
180
- return name;
181
- }
182
- $.$mol_func_name = $mol_func_name;
183
- function $mol_func_name_from(target, source) {
184
- Object.defineProperty(target, 'name', { value: source.name });
185
- return target;
186
- }
187
- $.$mol_func_name_from = $mol_func_name_from;
188
- })($ || ($ = {}));
189
-
190
363
  ;
191
364
  "use strict";
192
365
  var $;
@@ -254,15 +427,19 @@ var $;
254
427
  "use strict";
255
428
  var $;
256
429
  (function ($) {
257
- class $mol_window extends $mol_object {
258
- static size() {
259
- return {
260
- width: 1024,
261
- height: 768,
262
- };
263
- }
430
+ function $mol_env() {
431
+ return {};
264
432
  }
265
- $.$mol_window = $mol_window;
433
+ $.$mol_env = $mol_env;
434
+ })($ || ($ = {}));
435
+
436
+ ;
437
+ "use strict";
438
+ var $;
439
+ (function ($) {
440
+ $.$mol_env = function $mol_env() {
441
+ return this.process.env;
442
+ };
266
443
  })($ || ($ = {}));
267
444
 
268
445
  ;
@@ -741,21 +918,6 @@ var $;
741
918
  $.$mol_after_tick = $mol_after_tick;
742
919
  })($ || ($ = {}));
743
920
 
744
- ;
745
- "use strict";
746
- var $;
747
- (function ($) {
748
- function $mol_promise_like(val) {
749
- try {
750
- return val && typeof val === 'object' && 'then' in val && typeof val.then === 'function';
751
- }
752
- catch {
753
- return false;
754
- }
755
- }
756
- $.$mol_promise_like = $mol_promise_like;
757
- })($ || ($ = {}));
758
-
759
921
  ;
760
922
  "use strict";
761
923
  var $;
@@ -1009,89 +1171,6 @@ var $;
1009
1171
  $.$mol_wire_fiber = $mol_wire_fiber;
1010
1172
  })($ || ($ = {}));
1011
1173
 
1012
- ;
1013
- "use strict";
1014
- var $;
1015
- (function ($) {
1016
- $.$mol_key_store = new WeakMap();
1017
- const TypedArray = Object.getPrototypeOf(Uint8Array);
1018
- function $mol_key(value) {
1019
- if (typeof value === 'bigint')
1020
- return value.toString() + 'n';
1021
- if (typeof value === 'symbol')
1022
- return value.description;
1023
- if (!value)
1024
- return JSON.stringify(value);
1025
- if (typeof value !== 'object' && typeof value !== 'function')
1026
- return JSON.stringify(value);
1027
- return JSON.stringify(value, (field, value) => {
1028
- if (typeof value === 'bigint')
1029
- return value.toString() + 'n';
1030
- if (typeof value === 'symbol')
1031
- return value.description;
1032
- if (!value)
1033
- return value;
1034
- if (typeof value !== 'object' && typeof value !== 'function')
1035
- return value;
1036
- if (Array.isArray(value))
1037
- return value;
1038
- const proto = Reflect.getPrototypeOf(value);
1039
- if (!proto)
1040
- return value;
1041
- if (Reflect.getPrototypeOf(proto) === null)
1042
- return value;
1043
- if ('toJSON' in value)
1044
- return value;
1045
- if (value instanceof RegExp)
1046
- return value.toString();
1047
- if (value instanceof TypedArray)
1048
- return [...value];
1049
- let key = $.$mol_key_store.get(value);
1050
- if (key)
1051
- return key;
1052
- key = $mol_guid();
1053
- $.$mol_key_store.set(value, key);
1054
- return key;
1055
- });
1056
- }
1057
- $.$mol_key = $mol_key;
1058
- })($ || ($ = {}));
1059
-
1060
- ;
1061
- "use strict";
1062
- var $;
1063
- (function ($) {
1064
- class $mol_after_timeout extends $mol_object2 {
1065
- delay;
1066
- task;
1067
- id;
1068
- constructor(delay, task) {
1069
- super();
1070
- this.delay = delay;
1071
- this.task = task;
1072
- this.id = setTimeout(task, delay);
1073
- }
1074
- destructor() {
1075
- clearTimeout(this.id);
1076
- }
1077
- }
1078
- $.$mol_after_timeout = $mol_after_timeout;
1079
- })($ || ($ = {}));
1080
-
1081
- ;
1082
- "use strict";
1083
- var $;
1084
- (function ($) {
1085
- class $mol_after_frame extends $mol_after_timeout {
1086
- task;
1087
- constructor(task) {
1088
- super(16, task);
1089
- this.task = task;
1090
- }
1091
- }
1092
- $.$mol_after_frame = $mol_after_frame;
1093
- })($ || ($ = {}));
1094
-
1095
1174
  ;
1096
1175
  "use strict";
1097
1176
  var $;
@@ -1846,500 +1925,81 @@ var $;
1846
1925
  "use strict";
1847
1926
  var $;
1848
1927
  (function ($) {
1849
- function $mol_wire_method(host, field, descr) {
1850
- if (!descr)
1851
- descr = Reflect.getOwnPropertyDescriptor(host, field);
1852
- const orig = descr?.value ?? host[field];
1853
- const sup = Reflect.getPrototypeOf(host);
1854
- if (typeof sup[field] === 'function') {
1855
- Object.defineProperty(orig, 'name', { value: sup[field].name });
1856
- }
1857
- const temp = $mol_wire_task.getter(orig);
1858
- const value = function (...args) {
1859
- const fiber = temp(this ?? null, args);
1860
- return fiber.sync();
1928
+ const factories = new WeakMap();
1929
+ function factory(val) {
1930
+ let make = factories.get(val);
1931
+ if (make)
1932
+ return make;
1933
+ make = $mol_func_name_from((...args) => new val(...args), val);
1934
+ factories.set(val, make);
1935
+ return make;
1936
+ }
1937
+ const getters = new WeakMap();
1938
+ function get_prop(host, field) {
1939
+ let props = getters.get(host);
1940
+ let get_val = props?.[field];
1941
+ if (get_val)
1942
+ return get_val;
1943
+ get_val = (next) => {
1944
+ if (next !== undefined)
1945
+ host[field] = next;
1946
+ return host[field];
1861
1947
  };
1862
- Object.defineProperty(value, 'name', { value: orig.name + ' ' });
1863
- Object.assign(value, { orig });
1864
- const descr2 = { ...descr, value };
1865
- Reflect.defineProperty(host, field, descr2);
1866
- return descr2;
1948
+ Object.defineProperty(get_val, 'name', { value: field });
1949
+ if (!props) {
1950
+ props = {};
1951
+ getters.set(host, props);
1952
+ }
1953
+ props[field] = get_val;
1954
+ return get_val;
1867
1955
  }
1868
- $.$mol_wire_method = $mol_wire_method;
1869
- })($ || ($ = {}));
1870
-
1871
- ;
1872
- "use strict";
1873
-
1874
- ;
1875
- "use strict";
1876
-
1877
- ;
1878
- "use strict";
1879
- var $;
1880
- (function ($) {
1881
- const catched = new WeakMap();
1882
- function $mol_fail_catch(error) {
1883
- if (typeof error !== 'object')
1884
- return false;
1885
- if ($mol_promise_like(error))
1886
- $mol_fail_hidden(error);
1887
- if (catched.get(error))
1888
- return false;
1889
- catched.set(error, true);
1890
- return true;
1956
+ function $mol_wire_sync(obj) {
1957
+ return new Proxy(obj, {
1958
+ get(obj, field) {
1959
+ let val = obj[field];
1960
+ const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
1961
+ if (typeof val !== 'function')
1962
+ return temp(obj, []).sync();
1963
+ return function $mol_wire_sync(...args) {
1964
+ const fiber = temp(obj, args);
1965
+ return fiber.sync();
1966
+ };
1967
+ },
1968
+ set(obj, field, next) {
1969
+ const temp = $mol_wire_task.getter(get_prop(obj, field));
1970
+ temp(obj, [next]).sync();
1971
+ return true;
1972
+ },
1973
+ construct(obj, args) {
1974
+ const temp = $mol_wire_task.getter(factory(obj));
1975
+ return temp(obj, args).sync();
1976
+ },
1977
+ apply(obj, self, args) {
1978
+ const temp = $mol_wire_task.getter(obj);
1979
+ return temp(self, args).sync();
1980
+ },
1981
+ });
1891
1982
  }
1892
- $.$mol_fail_catch = $mol_fail_catch;
1983
+ $.$mol_wire_sync = $mol_wire_sync;
1893
1984
  })($ || ($ = {}));
1894
1985
 
1895
1986
  ;
1896
1987
  "use strict";
1897
1988
  var $;
1898
1989
  (function ($) {
1899
- function $mol_try(handler) {
1900
- try {
1901
- return handler();
1990
+ class $mol_run_error extends $mol_error_mix {
1991
+ }
1992
+ $.$mol_run_error = $mol_run_error;
1993
+ $.$mol_run_spawn = (...args) => $node['child_process'].spawn(...args);
1994
+ $.$mol_run_spawn_sync = (...args) => $node['child_process'].spawnSync(...args);
1995
+ class $mol_run extends $mol_object {
1996
+ static async_enabled() {
1997
+ return Boolean(this.$.$mol_env()['MOL_RUN_ASYNC']);
1902
1998
  }
1903
- catch (error) {
1904
- return error;
1905
- }
1906
- }
1907
- $.$mol_try = $mol_try;
1908
- })($ || ($ = {}));
1909
-
1910
- ;
1911
- "use strict";
1912
- var $;
1913
- (function ($) {
1914
- function $mol_fail_log(error) {
1915
- if ($mol_promise_like(error))
1916
- return false;
1917
- if (!$mol_fail_catch(error))
1918
- return false;
1919
- $mol_try(() => { $mol_fail_hidden(error); });
1920
- return true;
1921
- }
1922
- $.$mol_fail_log = $mol_fail_log;
1923
- })($ || ($ = {}));
1924
-
1925
- ;
1926
- "use strict";
1927
- var $;
1928
- (function ($) {
1929
- class $mol_wire_atom extends $mol_wire_fiber {
1930
- static solo(host, task) {
1931
- const field = task.name + '()';
1932
- const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1933
- if (existen)
1934
- return existen;
1935
- const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1936
- const key = prefix + ('.' + task.name + '<>');
1937
- const fiber = new $mol_wire_atom(key, task, host, []);
1938
- (host ?? task)[field] = fiber;
1939
- return fiber;
1940
- }
1941
- static plex(host, task, key) {
1942
- const field = task.name + '()';
1943
- let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1944
- const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1945
- const key_str = $mol_key(key);
1946
- if (dict) {
1947
- const existen = dict.get(key_str);
1948
- if (existen)
1949
- return existen;
1950
- }
1951
- else {
1952
- dict = (host ?? task)[field] = new Map();
1953
- }
1954
- const id = prefix + ('.' + task.name) + ('<' + key_str.replace(/^"|"$/g, "'") + '>');
1955
- const fiber = new $mol_wire_atom(id, task, host, [key]);
1956
- dict.set(key_str, fiber);
1957
- return fiber;
1958
- }
1959
- static watching = new Set();
1960
- static watcher = null;
1961
- static watch() {
1962
- $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1963
- for (const atom of $mol_wire_atom.watching) {
1964
- if (atom.cursor === $mol_wire_cursor.final) {
1965
- $mol_wire_atom.watching.delete(atom);
1966
- }
1967
- else {
1968
- atom.cursor = $mol_wire_cursor.stale;
1969
- atom.fresh();
1970
- }
1971
- }
1972
- }
1973
- watch() {
1974
- if (!$mol_wire_atom.watcher) {
1975
- $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1976
- }
1977
- $mol_wire_atom.watching.add(this);
1978
- }
1979
- resync(args) {
1980
- return this.put(this.task.call(this.host, ...args));
1981
- }
1982
- once() {
1983
- return this.sync();
1984
- }
1985
- channel() {
1986
- return Object.assign((next) => {
1987
- if (next !== undefined)
1988
- return this.resync([...this.args, next]);
1989
- if (!$mol_wire_fiber.warm)
1990
- return this.result();
1991
- if ($mol_wire_auto()?.temp) {
1992
- return this.once();
1993
- }
1994
- else {
1995
- return this.sync();
1996
- }
1997
- }, { atom: this });
1998
- }
1999
- destructor() {
2000
- super.destructor();
2001
- if (this.pub_from === 0) {
2002
- ;
2003
- (this.host ?? this.task)[this.field()] = null;
2004
- }
2005
- else {
2006
- ;
2007
- (this.host ?? this.task)[this.field()].delete($mol_key(this.args[0]));
2008
- }
2009
- }
2010
- put(next) {
2011
- const prev = this.cache;
2012
- update: if (next !== prev) {
2013
- try {
2014
- if ($mol_compare_deep(prev, next))
2015
- break update;
2016
- }
2017
- catch (error) {
2018
- $mol_fail_log(error);
2019
- }
2020
- if ($mol_owning_check(this, prev)) {
2021
- prev.destructor();
2022
- }
2023
- if ($mol_owning_catch(this, next)) {
2024
- try {
2025
- next[Symbol.toStringTag] = this[Symbol.toStringTag];
2026
- }
2027
- catch {
2028
- Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
2029
- }
2030
- }
2031
- if (!this.sub_empty)
2032
- this.emit();
2033
- }
2034
- this.cache = next;
2035
- this.cursor = $mol_wire_cursor.fresh;
2036
- if ($mol_promise_like(next))
2037
- return next;
2038
- this.complete_pubs();
2039
- return next;
2040
- }
2041
- }
2042
- __decorate([
2043
- $mol_wire_method
2044
- ], $mol_wire_atom.prototype, "resync", null);
2045
- __decorate([
2046
- $mol_wire_method
2047
- ], $mol_wire_atom.prototype, "once", null);
2048
- $.$mol_wire_atom = $mol_wire_atom;
2049
- })($ || ($ = {}));
2050
-
2051
- ;
2052
- "use strict";
2053
- var $;
2054
- (function ($) {
2055
- function $mol_wire_solo(host, field, descr) {
2056
- if (!descr)
2057
- descr = Reflect.getOwnPropertyDescriptor(host, field);
2058
- const orig = descr?.value ?? host[field];
2059
- const sup = Reflect.getPrototypeOf(host);
2060
- if (typeof sup[field] === 'function') {
2061
- Object.defineProperty(orig, 'name', { value: sup[field].name });
2062
- }
2063
- const descr2 = {
2064
- ...descr,
2065
- value: function (...args) {
2066
- let atom = $mol_wire_atom.solo(this, orig);
2067
- if ((args.length === 0) || (args[0] === undefined)) {
2068
- if (!$mol_wire_fiber.warm)
2069
- return atom.result();
2070
- if ($mol_wire_auto()?.temp) {
2071
- return atom.once();
2072
- }
2073
- else {
2074
- return atom.sync();
2075
- }
2076
- }
2077
- return atom.resync(args);
2078
- }
2079
- };
2080
- Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
2081
- Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
2082
- Object.assign(descr2.value, { orig });
2083
- Reflect.defineProperty(host, field, descr2);
2084
- return descr2;
2085
- }
2086
- $.$mol_wire_solo = $mol_wire_solo;
2087
- })($ || ($ = {}));
2088
-
2089
- ;
2090
- "use strict";
2091
- var $;
2092
- (function ($) {
2093
- function $mol_wire_plex(host, field, descr) {
2094
- if (!descr)
2095
- descr = Reflect.getOwnPropertyDescriptor(host, field);
2096
- const orig = descr?.value ?? host[field];
2097
- const sup = Reflect.getPrototypeOf(host);
2098
- if (typeof sup[field] === 'function') {
2099
- Object.defineProperty(orig, 'name', { value: sup[field].name });
2100
- }
2101
- const descr2 = {
2102
- ...descr,
2103
- value: function (...args) {
2104
- let atom = $mol_wire_atom.plex(this, orig, args[0]);
2105
- if ((args.length === 1) || (args[1] === undefined)) {
2106
- if (!$mol_wire_fiber.warm)
2107
- return atom.result();
2108
- if ($mol_wire_auto()?.temp) {
2109
- return atom.once();
2110
- }
2111
- else {
2112
- return atom.sync();
2113
- }
2114
- }
2115
- return atom.resync(args);
2116
- }
2117
- };
2118
- Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
2119
- Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
2120
- Object.assign(descr2.value, { orig });
2121
- Reflect.defineProperty(host, field, descr2);
2122
- return descr2;
2123
- }
2124
- $.$mol_wire_plex = $mol_wire_plex;
2125
- })($ || ($ = {}));
2126
-
2127
- ;
2128
- "use strict";
2129
- var $;
2130
- (function ($) {
2131
- $.$mol_mem = $mol_wire_solo;
2132
- $.$mol_mem_key = $mol_wire_plex;
2133
- })($ || ($ = {}));
2134
-
2135
- ;
2136
- "use strict";
2137
- var $;
2138
- (function ($) {
2139
- })($ || ($ = {}));
2140
-
2141
- ;
2142
- "use strict";
2143
-
2144
- ;
2145
- "use strict";
2146
- var $node = new Proxy({ require }, {
2147
- get(target, name, wrapper) {
2148
- if (target[name])
2149
- return target[name];
2150
- if (name.startsWith('node:'))
2151
- return target.require(name);
2152
- if (name[0] === '.')
2153
- return target.require(name);
2154
- const mod = target.require('module');
2155
- if (mod.builtinModules.indexOf(name) >= 0)
2156
- return target.require(name);
2157
- try {
2158
- target.require.resolve(name);
2159
- }
2160
- catch {
2161
- const $$ = $;
2162
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2163
- try {
2164
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
2165
- }
2166
- catch (e) {
2167
- if ($$.$mol_fail_catch(e)) {
2168
- $$.$mol_fail_log(e);
2169
- }
2170
- }
2171
- }
2172
- try {
2173
- return target.require(name);
2174
- }
2175
- catch (error) {
2176
- if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
2177
- const module = cache.get(name);
2178
- if (module)
2179
- return module;
2180
- throw import(name).then(module => cache.set(name, module));
2181
- }
2182
- $.$mol_fail_log(error);
2183
- return null;
2184
- }
2185
- },
2186
- set(target, name, value) {
2187
- target[name] = value;
2188
- return true;
2189
- },
2190
- });
2191
- const cache = new Map();
2192
- require = (req => Object.assign(function require(name) {
2193
- return $node[name];
2194
- }, req))(require);
2195
-
2196
- ;
2197
- "use strict";
2198
- var $;
2199
- (function ($) {
2200
- function cause_serialize(cause) {
2201
- return JSON.stringify(cause, null, ' ')
2202
- .replace(/\(/, '<')
2203
- .replace(/\)/, ' >');
2204
- }
2205
- function frame_normalize(frame) {
2206
- return (typeof frame === 'string' ? frame : cause_serialize(frame))
2207
- .trim()
2208
- .replace(/at /gm, ' at ')
2209
- .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
2210
- }
2211
- class $mol_error_mix extends AggregateError {
2212
- cause;
2213
- name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
2214
- constructor(message, cause = {}, ...errors) {
2215
- super(errors, message, { cause });
2216
- this.cause = cause;
2217
- const desc = Object.getOwnPropertyDescriptor(this, 'stack');
2218
- const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
2219
- Object.defineProperty(this, 'stack', {
2220
- get: () => stack_get() + '\n' + [
2221
- this.cause ?? 'no cause',
2222
- ...this.errors.flatMap(e => [
2223
- String(e.stack),
2224
- ...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
2225
- ])
2226
- ].map(frame_normalize).join('\n')
2227
- });
2228
- Object.defineProperty(this, 'cause', {
2229
- get: () => cause
2230
- });
2231
- }
2232
- static [Symbol.toPrimitive]() {
2233
- return this.toString();
2234
- }
2235
- static toString() {
2236
- return $$.$mol_func_name(this);
2237
- }
2238
- static make(...params) {
2239
- return new this(...params);
2240
- }
2241
- }
2242
- $.$mol_error_mix = $mol_error_mix;
2243
- })($ || ($ = {}));
2244
-
2245
- ;
2246
- "use strict";
2247
- var $;
2248
- (function ($) {
2249
- function $mol_env() {
2250
- return {};
2251
- }
2252
- $.$mol_env = $mol_env;
2253
- })($ || ($ = {}));
2254
-
2255
- ;
2256
- "use strict";
2257
- var $;
2258
- (function ($) {
2259
- $.$mol_env = function $mol_env() {
2260
- return this.process.env;
2261
- };
2262
- })($ || ($ = {}));
2263
-
2264
- ;
2265
- "use strict";
2266
- var $;
2267
- (function ($) {
2268
- const factories = new WeakMap();
2269
- function factory(val) {
2270
- let make = factories.get(val);
2271
- if (make)
2272
- return make;
2273
- make = $mol_func_name_from((...args) => new val(...args), val);
2274
- factories.set(val, make);
2275
- return make;
2276
- }
2277
- const getters = new WeakMap();
2278
- function get_prop(host, field) {
2279
- let props = getters.get(host);
2280
- let get_val = props?.[field];
2281
- if (get_val)
2282
- return get_val;
2283
- get_val = (next) => {
2284
- if (next !== undefined)
2285
- host[field] = next;
2286
- return host[field];
2287
- };
2288
- Object.defineProperty(get_val, 'name', { value: field });
2289
- if (!props) {
2290
- props = {};
2291
- getters.set(host, props);
2292
- }
2293
- props[field] = get_val;
2294
- return get_val;
2295
- }
2296
- function $mol_wire_sync(obj) {
2297
- return new Proxy(obj, {
2298
- get(obj, field) {
2299
- let val = obj[field];
2300
- const temp = $mol_wire_task.getter(typeof val === 'function' ? val : get_prop(obj, field));
2301
- if (typeof val !== 'function')
2302
- return temp(obj, []).sync();
2303
- return function $mol_wire_sync(...args) {
2304
- const fiber = temp(obj, args);
2305
- return fiber.sync();
2306
- };
2307
- },
2308
- set(obj, field, next) {
2309
- const temp = $mol_wire_task.getter(get_prop(obj, field));
2310
- temp(obj, [next]).sync();
2311
- return true;
2312
- },
2313
- construct(obj, args) {
2314
- const temp = $mol_wire_task.getter(factory(obj));
2315
- return temp(obj, args).sync();
2316
- },
2317
- apply(obj, self, args) {
2318
- const temp = $mol_wire_task.getter(obj);
2319
- return temp(self, args).sync();
2320
- },
2321
- });
2322
- }
2323
- $.$mol_wire_sync = $mol_wire_sync;
2324
- })($ || ($ = {}));
2325
-
2326
- ;
2327
- "use strict";
2328
- var $;
2329
- (function ($) {
2330
- class $mol_run_error extends $mol_error_mix {
2331
- }
2332
- $.$mol_run_error = $mol_run_error;
2333
- $.$mol_run_spawn = (...args) => $node['child_process'].spawn(...args);
2334
- $.$mol_run_spawn_sync = (...args) => $node['child_process'].spawnSync(...args);
2335
- class $mol_run extends $mol_object {
2336
- static async_enabled() {
2337
- return Boolean(this.$.$mol_env()['MOL_RUN_ASYNC']);
2338
- }
2339
- static spawn(options) {
2340
- const sync = !this.async_enabled() || !Boolean($mol_wire_auto());
2341
- const env = options.env ?? this.$.$mol_env();
2342
- return $mol_wire_sync(this).spawn_async({ ...options, sync, env });
1999
+ static spawn(options) {
2000
+ const sync = !this.async_enabled() || !Boolean($mol_wire_auto());
2001
+ const env = options.env ?? this.$.$mol_env();
2002
+ return $mol_wire_sync(this).spawn_async({ ...options, sync, env });
2343
2003
  }
2344
2004
  static spawn_async({ dir, sync, timeout, command, env }) {
2345
2005
  const args_raw = typeof command === 'string' ? command.split(' ') : command;
@@ -2464,622 +2124,1103 @@ var $;
2464
2124
  "use strict";
2465
2125
  var $;
2466
2126
  (function ($) {
2467
- class $mol_view_selection extends $mol_object {
2468
- static focused(next, notify) {
2469
- const parents = [];
2470
- let element = next?.[0] ?? $mol_dom_context.document.activeElement;
2471
- while (element?.shadowRoot) {
2472
- element = element.shadowRoot.activeElement;
2473
- }
2474
- while (element) {
2475
- parents.push(element);
2476
- const parent = element.parentNode;
2477
- if (parent instanceof ShadowRoot)
2478
- element = parent.host;
2479
- else
2480
- element = parent;
2481
- }
2482
- if (!next || notify)
2483
- return parents;
2484
- new $mol_after_tick(() => {
2485
- const element = this.focused()[0];
2486
- if (element)
2487
- element.focus();
2488
- else
2489
- $mol_dom_context.blur();
2127
+ $.$mol_dom = $mol_dom_context;
2128
+ })($ || ($ = {}));
2129
+
2130
+ ;
2131
+ "use strict";
2132
+ var $;
2133
+ (function ($) {
2134
+ function $mol_style_attach(id, text) {
2135
+ const doc = $mol_dom_context.document;
2136
+ if (!doc)
2137
+ return null;
2138
+ const elid = `$mol_style_attach:${id}`;
2139
+ let el = doc.getElementById(elid);
2140
+ if (!el) {
2141
+ el = doc.createElement('style');
2142
+ el.id = elid;
2143
+ doc.head.appendChild(el);
2144
+ }
2145
+ if (el.innerHTML != text)
2146
+ el.innerHTML = text;
2147
+ return el;
2148
+ }
2149
+ $.$mol_style_attach = $mol_style_attach;
2150
+ })($ || ($ = {}));
2151
+
2152
+ ;
2153
+ "use strict";
2154
+ var $;
2155
+ (function ($) {
2156
+ class $mol_promise extends Promise {
2157
+ done;
2158
+ fail;
2159
+ constructor(executor) {
2160
+ let done;
2161
+ let fail;
2162
+ super((d, f) => {
2163
+ done = d;
2164
+ fail = f;
2165
+ executor?.(d, f);
2490
2166
  });
2491
- return parents;
2167
+ this.done = done;
2168
+ this.fail = fail;
2492
2169
  }
2493
2170
  }
2494
- __decorate([
2495
- $mol_mem
2496
- ], $mol_view_selection, "focused", null);
2497
- $.$mol_view_selection = $mol_view_selection;
2171
+ $.$mol_promise = $mol_promise;
2498
2172
  })($ || ($ = {}));
2499
2173
 
2500
2174
  ;
2501
2175
  "use strict";
2502
2176
  var $;
2503
2177
  (function ($) {
2504
- class $mol_wrapper extends $mol_object2 {
2505
- static wrap;
2506
- static run(task) {
2507
- return this.func(task)();
2178
+ class $mol_promise_blocker extends $mol_promise {
2179
+ static [Symbol.toStringTag] = '$mol_promise_blocker';
2180
+ }
2181
+ $.$mol_promise_blocker = $mol_promise_blocker;
2182
+ })($ || ($ = {}));
2183
+
2184
+ ;
2185
+ "use strict";
2186
+ var $;
2187
+ (function ($) {
2188
+ class $mol_decor {
2189
+ value;
2190
+ constructor(value) {
2191
+ this.value = value;
2508
2192
  }
2509
- static func(func) {
2510
- return this.wrap(func);
2193
+ prefix() { return ''; }
2194
+ valueOf() { return this.value; }
2195
+ postfix() { return ''; }
2196
+ toString() {
2197
+ return `${this.prefix()}${this.valueOf()}${this.postfix()}`;
2511
2198
  }
2512
- static get class() {
2513
- return (Class) => {
2514
- const construct = (target, args) => new Class(...args);
2515
- const handler = {
2516
- construct: this.func(construct)
2517
- };
2518
- handler[Symbol.toStringTag] = Class.name + '#';
2519
- return new Proxy(Class, handler);
2520
- };
2199
+ }
2200
+ $.$mol_decor = $mol_decor;
2201
+ })($ || ($ = {}));
2202
+
2203
+ ;
2204
+ "use strict";
2205
+ var $;
2206
+ (function ($) {
2207
+ class $mol_style_unit extends $mol_decor {
2208
+ literal;
2209
+ constructor(value, literal) {
2210
+ super(value);
2211
+ this.literal = literal;
2212
+ }
2213
+ postfix() {
2214
+ return this.literal;
2215
+ }
2216
+ static per(value) { return `${value}%`; }
2217
+ static px(value) { return `${value}px`; }
2218
+ static mm(value) { return `${value}mm`; }
2219
+ static cm(value) { return `${value}cm`; }
2220
+ static Q(value) { return `${value}Q`; }
2221
+ static in(value) { return `${value}in`; }
2222
+ static pc(value) { return `${value}pc`; }
2223
+ static pt(value) { return `${value}pt`; }
2224
+ static cap(value) { return `${value}cap`; }
2225
+ static ch(value) { return `${value}ch`; }
2226
+ static em(value) { return `${value}em`; }
2227
+ static rem(value) { return `${value}rem`; }
2228
+ static ex(value) { return `${value}ex`; }
2229
+ static ic(value) { return `${value}ic`; }
2230
+ static lh(value) { return `${value}lh`; }
2231
+ static rlh(value) { return `${value}rlh`; }
2232
+ static vh(value) { return `${value}vh`; }
2233
+ static vw(value) { return `${value}vw`; }
2234
+ static vi(value) { return `${value}vi`; }
2235
+ static vb(value) { return `${value}vb`; }
2236
+ static vmin(value) { return `${value}vmin`; }
2237
+ static vmax(value) { return `${value}vmax`; }
2238
+ static deg(value) { return `${value}deg`; }
2239
+ static rad(value) { return `${value}rad`; }
2240
+ static grad(value) { return `${value}grad`; }
2241
+ static turn(value) { return `${value}turn`; }
2242
+ static s(value) { return `${value}s`; }
2243
+ static ms(value) { return `${value}ms`; }
2244
+ }
2245
+ $.$mol_style_unit = $mol_style_unit;
2246
+ })($ || ($ = {}));
2247
+
2248
+ ;
2249
+ "use strict";
2250
+ var $;
2251
+ (function ($) {
2252
+ const { per } = $mol_style_unit;
2253
+ class $mol_style_func extends $mol_decor {
2254
+ name;
2255
+ constructor(name, value) {
2256
+ super(value);
2257
+ this.name = name;
2258
+ }
2259
+ prefix() { return this.name + '('; }
2260
+ postfix() { return ')'; }
2261
+ static linear_gradient(value) {
2262
+ return new $mol_style_func('linear-gradient', value);
2263
+ }
2264
+ static radial_gradient(value) {
2265
+ return new $mol_style_func('radial-gradient', value);
2266
+ }
2267
+ static calc(value) {
2268
+ return new $mol_style_func('calc', value);
2269
+ }
2270
+ static vary(name, defaultValue) {
2271
+ return new $mol_style_func('var', defaultValue ? [name, defaultValue] : name);
2272
+ }
2273
+ static url(href) {
2274
+ return new $mol_style_func('url', JSON.stringify(href));
2275
+ }
2276
+ static hsla(hue, saturation, lightness, alpha) {
2277
+ return new $mol_style_func('hsla', [hue, per(saturation), per(lightness), alpha]);
2278
+ }
2279
+ static clamp(min, mid, max) {
2280
+ return new $mol_style_func('clamp', [min, mid, max]);
2281
+ }
2282
+ static rgba(red, green, blue, alpha) {
2283
+ return new $mol_style_func('rgba', [red, green, blue, alpha]);
2284
+ }
2285
+ static scale(zoom) {
2286
+ return new $mol_style_func('scale', [zoom]);
2287
+ }
2288
+ static linear(...breakpoints) {
2289
+ return new $mol_style_func("linear", breakpoints.map((e) => Array.isArray(e)
2290
+ ? String(e[0]) +
2291
+ " " +
2292
+ (typeof e[1] === "number" ? e[1] + "%" : e[1].toString())
2293
+ : String(e)));
2294
+ }
2295
+ static cubic_bezier(x1, y1, x2, y2) {
2296
+ return new $mol_style_func('cubic-bezier', [x1, y1, x2, y2]);
2297
+ }
2298
+ static steps(value, step_position) {
2299
+ return new $mol_style_func('steps', [value, step_position]);
2300
+ }
2301
+ static blur(value) {
2302
+ return new $mol_style_func('blur', value ?? "");
2303
+ }
2304
+ static brightness(value) {
2305
+ return new $mol_style_func('brightness', value ?? "");
2306
+ }
2307
+ static contrast(value) {
2308
+ return new $mol_style_func('contrast', value ?? "");
2309
+ }
2310
+ static drop_shadow(color, x_offset, y_offset, blur_radius) {
2311
+ return new $mol_style_func("drop-shadow", blur_radius
2312
+ ? [color, x_offset, y_offset, blur_radius]
2313
+ : [color, x_offset, y_offset]);
2314
+ }
2315
+ static grayscale(value) {
2316
+ return new $mol_style_func('grayscale', value ?? "");
2317
+ }
2318
+ static hue_rotate(value) {
2319
+ return new $mol_style_func('hue-rotate', value ?? "");
2320
+ }
2321
+ static invert(value) {
2322
+ return new $mol_style_func('invert', value ?? "");
2521
2323
  }
2522
- static get method() {
2523
- return (obj, name, descr) => {
2524
- descr.value = this.func(descr.value);
2525
- return descr;
2526
- };
2324
+ static opacity(value) {
2325
+ return new $mol_style_func('opacity', value ?? "");
2527
2326
  }
2528
- static get field() {
2529
- return (obj, name, descr) => {
2530
- descr.get = descr.set = this.func(descr.get);
2531
- return descr;
2532
- };
2327
+ static sepia(value) {
2328
+ return new $mol_style_func('sepia', value ?? "");
2329
+ }
2330
+ static saturate(value) {
2331
+ return new $mol_style_func('saturate', value ?? "");
2533
2332
  }
2534
2333
  }
2535
- $.$mol_wrapper = $mol_wrapper;
2334
+ $.$mol_style_func = $mol_style_func;
2536
2335
  })($ || ($ = {}));
2537
2336
 
2538
2337
  ;
2539
2338
  "use strict";
2540
- var $;
2541
- (function ($) {
2542
- class $mol_memo extends $mol_wrapper {
2543
- static wrap(task) {
2544
- const store = new WeakMap();
2545
- const fun = function (next) {
2546
- if (next === undefined && store.has(this))
2547
- return store.get(this);
2548
- const val = task.call(this, next) ?? next;
2549
- store.set(this, val);
2550
- return val;
2551
- };
2552
- Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
2553
- return fun;
2554
- }
2555
- }
2556
- $.$mol_memo = $mol_memo;
2557
- })($ || ($ = {}));
2339
+
2340
+ ;
2341
+ "use strict";
2558
2342
 
2559
2343
  ;
2560
2344
  "use strict";
2561
2345
  var $;
2562
2346
  (function ($) {
2563
- $.$mol_dom = $mol_dom_context;
2347
+ function $mol_style_prop(prefix, keys) {
2348
+ const record = keys.reduce((rec, key) => {
2349
+ rec[key] = $mol_style_func.vary(`--${prefix}_${key}`);
2350
+ return rec;
2351
+ }, {});
2352
+ return record;
2353
+ }
2354
+ $.$mol_style_prop = $mol_style_prop;
2564
2355
  })($ || ($ = {}));
2565
2356
 
2566
2357
  ;
2567
2358
  "use strict";
2568
2359
  var $;
2569
2360
  (function ($) {
2570
- function $mol_dom_qname(name) {
2571
- return name.replace(/\W/g, '').replace(/^(?=\d+)/, '_');
2572
- }
2573
- $.$mol_dom_qname = $mol_dom_qname;
2361
+ $.$mol_theme = $mol_style_prop('mol_theme', [
2362
+ 'back',
2363
+ 'hover',
2364
+ 'card',
2365
+ 'current',
2366
+ 'special',
2367
+ 'text',
2368
+ 'control',
2369
+ 'shade',
2370
+ 'line',
2371
+ 'focus',
2372
+ 'field',
2373
+ 'image',
2374
+ 'spirit',
2375
+ ]);
2574
2376
  })($ || ($ = {}));
2575
2377
 
2576
2378
  ;
2577
2379
  "use strict";
2578
2380
  var $;
2579
2381
  (function ($) {
2580
- function $mol_wire_probe(task, def) {
2581
- const warm = $mol_wire_fiber.warm;
2582
- try {
2583
- $mol_wire_fiber.warm = false;
2584
- const res = task();
2585
- if (res === undefined)
2586
- return def;
2587
- return res;
2588
- }
2589
- finally {
2590
- $mol_wire_fiber.warm = warm;
2591
- }
2592
- }
2593
- $.$mol_wire_probe = $mol_wire_probe;
2382
+ $mol_style_attach("mol/theme/theme.css", ":root {\n\t--mol_theme_hue: 240deg;\n\t--mol_theme_hue_spread: 90deg;\n\tcolor-scheme: dark light;\n}\n\n:where([mol_theme]) {\n\tcolor: var(--mol_theme_text);\n\tfill: var(--mol_theme_text);\n\tbackground-color: var(--mol_theme_back);\n}\n\t\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\n\t--mol_theme_luma: -1;\n\t--mol_theme_image: invert(1) hue-rotate( 180deg );\n\t--mol_theme_spirit: hsl( 0deg, 0%, 0%, .75 );\n\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 10% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 20%, .25 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 8%, .25 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 80% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 60%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 65% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 60%, 65% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 60%, 65% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 60%, 65% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\t\n\t--mol_theme_back: oklch( 20% .03 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 30% .05 var(--mol_theme_hue) / .25 );\n\t--mol_theme_field: oklch( 15% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 80% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 60% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 80% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 70% .1 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 70% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 70% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t\n\t--mol_theme_luma: 1;\n\t--mol_theme_image: none;\n\t--mol_theme_spirit: hsl( 0deg, 0%, 100%, .75 );\n\t\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 92% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 100%, .5 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 100%, .75 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 0% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 40%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 40% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 80%, 30% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 80%, 30% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 80%, 30% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t--mol_theme_back: oklch( 92% .01 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 99% .01 var(--mol_theme_hue) / .5 );\n\t--mol_theme_field: oklch( 100% 0 var(--mol_theme_hue) / .5 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 20% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 50% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 60% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 40% .15 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 50% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 50% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 25% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 35% .1 var(--mol_theme_hue) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 85% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 98% .03 var(--mol_theme_hue) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 35% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 45% .15 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 83% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n\n");
2594
2383
  })($ || ($ = {}));
2595
2384
 
2596
2385
  ;
2597
2386
  "use strict";
2598
2387
  var $;
2599
2388
  (function ($) {
2600
- function $mol_wire_watch() {
2601
- const atom = $mol_wire_auto();
2602
- if (atom instanceof $mol_wire_atom) {
2603
- atom.watch();
2604
- }
2605
- else {
2606
- $mol_fail(new Error('Atom is required for watching'));
2607
- }
2608
- }
2609
- $.$mol_wire_watch = $mol_wire_watch;
2389
+ $.$mol_gap = $mol_style_prop('mol_gap', [
2390
+ 'block',
2391
+ 'text',
2392
+ 'round',
2393
+ 'space',
2394
+ 'blur',
2395
+ ]);
2610
2396
  })($ || ($ = {}));
2611
2397
 
2612
2398
  ;
2613
2399
  "use strict";
2614
2400
  var $;
2615
2401
  (function ($) {
2616
- function $mol_const(value) {
2617
- const getter = (() => value);
2618
- getter['()'] = value;
2619
- getter[Symbol.toStringTag] = value;
2620
- getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
2621
- return getter;
2622
- }
2623
- $.$mol_const = $mol_const;
2402
+ $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
2624
2403
  })($ || ($ = {}));
2625
2404
 
2626
2405
  ;
2627
2406
  "use strict";
2628
2407
  var $;
2629
2408
  (function ($) {
2630
- function $mol_wire_solid() {
2631
- let current = $mol_wire_auto();
2632
- if (current.temp)
2633
- current = current.host;
2634
- if (current.reap !== nothing) {
2635
- current?.sub_on(sub, sub.data.length);
2409
+ function $mol_dom_render_children(el, childNodes) {
2410
+ const node_set = new Set(childNodes);
2411
+ let nextNode = el.firstChild;
2412
+ for (let view of childNodes) {
2413
+ if (view == null)
2414
+ continue;
2415
+ if (view instanceof $mol_dom_context.Node) {
2416
+ while (true) {
2417
+ if (!nextNode) {
2418
+ el.appendChild(view);
2419
+ break;
2420
+ }
2421
+ if (nextNode == view) {
2422
+ nextNode = nextNode.nextSibling;
2423
+ break;
2424
+ }
2425
+ else {
2426
+ if (node_set.has(nextNode)) {
2427
+ el.insertBefore(view, nextNode);
2428
+ break;
2429
+ }
2430
+ else {
2431
+ const nn = nextNode.nextSibling;
2432
+ el.removeChild(nextNode);
2433
+ nextNode = nn;
2434
+ }
2435
+ }
2436
+ }
2437
+ }
2438
+ else {
2439
+ if (nextNode && nextNode.nodeName === '#text') {
2440
+ const str = String(view);
2441
+ if (nextNode.nodeValue !== str)
2442
+ nextNode.nodeValue = str;
2443
+ nextNode = nextNode.nextSibling;
2444
+ }
2445
+ else {
2446
+ const textNode = $mol_dom_context.document.createTextNode(String(view));
2447
+ el.insertBefore(textNode, nextNode);
2448
+ }
2449
+ }
2450
+ }
2451
+ while (nextNode) {
2452
+ const currNode = nextNode;
2453
+ nextNode = currNode.nextSibling;
2454
+ el.removeChild(currNode);
2636
2455
  }
2637
- current.reap = nothing;
2638
2456
  }
2639
- $.$mol_wire_solid = $mol_wire_solid;
2640
- const nothing = () => { };
2641
- const sub = new $mol_wire_pub_sub;
2457
+ $.$mol_dom_render_children = $mol_dom_render_children;
2642
2458
  })($ || ($ = {}));
2643
2459
 
2460
+ ;
2461
+ "use strict";
2462
+
2644
2463
  ;
2645
2464
  "use strict";
2646
2465
  var $;
2647
2466
  (function ($) {
2648
- function $mol_dom_render_attributes(el, attrs) {
2649
- for (let name in attrs) {
2650
- let val = attrs[name];
2651
- if (val === undefined) {
2652
- continue;
2467
+ $.$mol_jsx_prefix = '';
2468
+ $.$mol_jsx_crumbs = '';
2469
+ $.$mol_jsx_booked = null;
2470
+ $.$mol_jsx_document = {
2471
+ getElementById: () => null,
2472
+ createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
2473
+ createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
2474
+ };
2475
+ $.$mol_jsx_frag = '';
2476
+ function $mol_jsx(Elem, props, ...childNodes) {
2477
+ const id = props && props.id || '';
2478
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
2479
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
2480
+ if (Elem && $.$mol_jsx_booked) {
2481
+ if ($.$mol_jsx_booked.has(id)) {
2482
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
2653
2483
  }
2654
- else if (val === null || val === false) {
2655
- if (!el.hasAttribute(name))
2484
+ else {
2485
+ $.$mol_jsx_booked.add(id);
2486
+ }
2487
+ }
2488
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
2489
+ if ($.$mol_jsx_prefix) {
2490
+ const prefix_ext = $.$mol_jsx_prefix;
2491
+ const booked_ext = $.$mol_jsx_booked;
2492
+ const crumbs_ext = $.$mol_jsx_crumbs;
2493
+ for (const field in props) {
2494
+ const func = props[field];
2495
+ if (typeof func !== 'function')
2656
2496
  continue;
2657
- el.removeAttribute(name);
2497
+ const wrapper = function (...args) {
2498
+ const prefix = $.$mol_jsx_prefix;
2499
+ const booked = $.$mol_jsx_booked;
2500
+ const crumbs = $.$mol_jsx_crumbs;
2501
+ try {
2502
+ $.$mol_jsx_prefix = prefix_ext;
2503
+ $.$mol_jsx_booked = booked_ext;
2504
+ $.$mol_jsx_crumbs = crumbs_ext;
2505
+ return func.call(this, ...args);
2506
+ }
2507
+ finally {
2508
+ $.$mol_jsx_prefix = prefix;
2509
+ $.$mol_jsx_booked = booked;
2510
+ $.$mol_jsx_crumbs = crumbs;
2511
+ }
2512
+ };
2513
+ $mol_func_name_from(wrapper, func);
2514
+ props[field] = wrapper;
2515
+ }
2516
+ }
2517
+ if (typeof Elem !== 'string') {
2518
+ if ('prototype' in Elem) {
2519
+ const view = node && node[String(Elem)] || new Elem;
2520
+ Object.assign(view, props);
2521
+ view[Symbol.toStringTag] = guid;
2522
+ view.childNodes = childNodes;
2523
+ if (!view.ownerDocument)
2524
+ view.ownerDocument = $.$mol_jsx_document;
2525
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
2526
+ node = view.valueOf();
2527
+ node[String(Elem)] = view;
2528
+ return node;
2658
2529
  }
2659
2530
  else {
2660
- const str = String(val);
2661
- if (el.getAttribute(name) === str)
2531
+ const prefix = $.$mol_jsx_prefix;
2532
+ const booked = $.$mol_jsx_booked;
2533
+ const crumbs = $.$mol_jsx_crumbs;
2534
+ try {
2535
+ $.$mol_jsx_prefix = guid;
2536
+ $.$mol_jsx_booked = new Set;
2537
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
2538
+ return Elem(props, ...childNodes);
2539
+ }
2540
+ finally {
2541
+ $.$mol_jsx_prefix = prefix;
2542
+ $.$mol_jsx_booked = booked;
2543
+ $.$mol_jsx_crumbs = crumbs;
2544
+ }
2545
+ }
2546
+ }
2547
+ if (!node) {
2548
+ node = Elem
2549
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
2550
+ : $.$mol_jsx_document.createDocumentFragment();
2551
+ }
2552
+ $mol_dom_render_children(node, [].concat(...childNodes));
2553
+ if (!Elem)
2554
+ return node;
2555
+ if (guid)
2556
+ node.id = guid;
2557
+ for (const key in props) {
2558
+ if (key === 'id')
2559
+ continue;
2560
+ if (typeof props[key] === 'string') {
2561
+ if (typeof node[key] === 'string')
2562
+ node[key] = props[key];
2563
+ node.setAttribute(key, props[key]);
2564
+ }
2565
+ else if (props[key] &&
2566
+ typeof props[key] === 'object' &&
2567
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
2568
+ if (typeof node[key] === 'object') {
2569
+ Object.assign(node[key], props[key]);
2662
2570
  continue;
2663
- el.setAttribute(name, str);
2571
+ }
2572
+ }
2573
+ else {
2574
+ node[key] = props[key];
2664
2575
  }
2665
2576
  }
2577
+ if ($.$mol_jsx_crumbs)
2578
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
2579
+ return node;
2666
2580
  }
2667
- $.$mol_dom_render_attributes = $mol_dom_render_attributes;
2581
+ $.$mol_jsx = $mol_jsx;
2668
2582
  })($ || ($ = {}));
2669
2583
 
2670
2584
  ;
2671
2585
  "use strict";
2672
2586
  var $;
2673
2587
  (function ($) {
2674
- function $mol_dom_render_events(el, events, passive = false) {
2675
- for (let name in events) {
2676
- el.addEventListener(name, events[name], { passive });
2588
+ class $mol_window extends $mol_object {
2589
+ static size() {
2590
+ return {
2591
+ width: 1024,
2592
+ height: 768,
2593
+ };
2677
2594
  }
2678
2595
  }
2679
- $.$mol_dom_render_events = $mol_dom_render_events;
2596
+ $.$mol_window = $mol_window;
2597
+ })($ || ($ = {}));
2598
+
2599
+ ;
2600
+ "use strict";
2601
+ var $;
2602
+ (function ($) {
2603
+ $.$mol_key_store = new WeakMap();
2604
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
2605
+ function $mol_key(value) {
2606
+ if (typeof value === 'bigint')
2607
+ return value.toString() + 'n';
2608
+ if (typeof value === 'symbol')
2609
+ return value.description;
2610
+ if (!value)
2611
+ return JSON.stringify(value);
2612
+ if (typeof value !== 'object' && typeof value !== 'function')
2613
+ return JSON.stringify(value);
2614
+ return JSON.stringify(value, (field, value) => {
2615
+ if (typeof value === 'bigint')
2616
+ return value.toString() + 'n';
2617
+ if (typeof value === 'symbol')
2618
+ return value.description;
2619
+ if (!value)
2620
+ return value;
2621
+ if (typeof value !== 'object' && typeof value !== 'function')
2622
+ return value;
2623
+ if (Array.isArray(value))
2624
+ return value;
2625
+ const proto = Reflect.getPrototypeOf(value);
2626
+ if (!proto)
2627
+ return value;
2628
+ if (Reflect.getPrototypeOf(proto) === null)
2629
+ return value;
2630
+ if ('toJSON' in value)
2631
+ return value;
2632
+ if (value instanceof RegExp)
2633
+ return value.toString();
2634
+ if (value instanceof TypedArray)
2635
+ return [...value];
2636
+ let key = $.$mol_key_store.get(value);
2637
+ if (key)
2638
+ return key;
2639
+ key = $mol_guid();
2640
+ $.$mol_key_store.set(value, key);
2641
+ return key;
2642
+ });
2643
+ }
2644
+ $.$mol_key = $mol_key;
2680
2645
  })($ || ($ = {}));
2681
2646
 
2682
2647
  ;
2683
2648
  "use strict";
2684
2649
  var $;
2685
2650
  (function ($) {
2686
- function $mol_dom_render_styles(el, styles) {
2687
- for (let name in styles) {
2688
- let val = styles[name];
2689
- const style = el.style;
2690
- const kebab = (name) => name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase());
2691
- if (typeof val === 'number') {
2692
- style.setProperty(kebab(name), `${val}px`);
2693
- }
2694
- else {
2695
- style.setProperty(kebab(name), val);
2696
- }
2651
+ class $mol_after_timeout extends $mol_object2 {
2652
+ delay;
2653
+ task;
2654
+ id;
2655
+ constructor(delay, task) {
2656
+ super();
2657
+ this.delay = delay;
2658
+ this.task = task;
2659
+ this.id = setTimeout(task, delay);
2660
+ }
2661
+ destructor() {
2662
+ clearTimeout(this.id);
2697
2663
  }
2698
2664
  }
2699
- $.$mol_dom_render_styles = $mol_dom_render_styles;
2665
+ $.$mol_after_timeout = $mol_after_timeout;
2700
2666
  })($ || ($ = {}));
2701
2667
 
2702
2668
  ;
2703
2669
  "use strict";
2704
2670
  var $;
2705
2671
  (function ($) {
2706
- function $mol_dom_render_children(el, childNodes) {
2707
- const node_set = new Set(childNodes);
2708
- let nextNode = el.firstChild;
2709
- for (let view of childNodes) {
2710
- if (view == null)
2711
- continue;
2712
- if (view instanceof $mol_dom_context.Node) {
2713
- while (true) {
2714
- if (!nextNode) {
2715
- el.appendChild(view);
2716
- break;
2717
- }
2718
- if (nextNode == view) {
2719
- nextNode = nextNode.nextSibling;
2720
- break;
2721
- }
2722
- else {
2723
- if (node_set.has(nextNode)) {
2724
- el.insertBefore(view, nextNode);
2725
- break;
2726
- }
2727
- else {
2728
- const nn = nextNode.nextSibling;
2729
- el.removeChild(nextNode);
2730
- nextNode = nn;
2731
- }
2732
- }
2733
- }
2734
- }
2735
- else {
2736
- if (nextNode && nextNode.nodeName === '#text') {
2737
- const str = String(view);
2738
- if (nextNode.nodeValue !== str)
2739
- nextNode.nodeValue = str;
2740
- nextNode = nextNode.nextSibling;
2741
- }
2742
- else {
2743
- const textNode = $mol_dom_context.document.createTextNode(String(view));
2744
- el.insertBefore(textNode, nextNode);
2745
- }
2746
- }
2747
- }
2748
- while (nextNode) {
2749
- const currNode = nextNode;
2750
- nextNode = currNode.nextSibling;
2751
- el.removeChild(currNode);
2672
+ class $mol_after_frame extends $mol_after_timeout {
2673
+ task;
2674
+ constructor(task) {
2675
+ super(16, task);
2676
+ this.task = task;
2752
2677
  }
2753
2678
  }
2754
- $.$mol_dom_render_children = $mol_dom_render_children;
2679
+ $.$mol_after_frame = $mol_after_frame;
2755
2680
  })($ || ($ = {}));
2756
2681
 
2757
2682
  ;
2758
2683
  "use strict";
2759
2684
  var $;
2760
2685
  (function ($) {
2761
- function $mol_dom_render_fields(el, fields) {
2762
- for (let key in fields) {
2763
- const val = fields[key];
2764
- if (val === undefined)
2765
- continue;
2766
- if (val === el[key])
2767
- continue;
2768
- el[key] = val;
2686
+ function $mol_wire_method(host, field, descr) {
2687
+ if (!descr)
2688
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
2689
+ const orig = descr?.value ?? host[field];
2690
+ const sup = Reflect.getPrototypeOf(host);
2691
+ if (typeof sup[field] === 'function') {
2692
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
2769
2693
  }
2694
+ const temp = $mol_wire_task.getter(orig);
2695
+ const value = function (...args) {
2696
+ const fiber = temp(this ?? null, args);
2697
+ return fiber.sync();
2698
+ };
2699
+ Object.defineProperty(value, 'name', { value: orig.name + ' ' });
2700
+ Object.assign(value, { orig });
2701
+ const descr2 = { ...descr, value };
2702
+ Reflect.defineProperty(host, field, descr2);
2703
+ return descr2;
2770
2704
  }
2771
- $.$mol_dom_render_fields = $mol_dom_render_fields;
2705
+ $.$mol_wire_method = $mol_wire_method;
2772
2706
  })($ || ($ = {}));
2773
2707
 
2774
2708
  ;
2775
2709
  "use strict";
2776
- var $;
2777
- (function ($) {
2778
- function $mol_wire_async(obj) {
2779
- let fiber;
2780
- const temp = $mol_wire_task.getter(obj);
2781
- return new Proxy(obj, {
2782
- get(obj, field) {
2783
- const val = obj[field];
2784
- if (typeof val !== 'function')
2785
- return val;
2786
- let fiber;
2787
- const temp = $mol_wire_task.getter(val);
2788
- return function $mol_wire_async(...args) {
2789
- fiber?.destructor();
2790
- fiber = temp(obj, args);
2791
- return fiber.async();
2792
- };
2793
- },
2794
- apply(obj, self, args) {
2795
- fiber?.destructor();
2796
- fiber = temp(self, args);
2797
- return fiber.async();
2798
- },
2799
- });
2800
- }
2801
- $.$mol_wire_async = $mol_wire_async;
2802
- })($ || ($ = {}));
2803
2710
 
2804
2711
  ;
2805
2712
  "use strict";
2806
2713
 
2807
2714
  ;
2808
2715
  "use strict";
2716
+ var $;
2717
+ (function ($) {
2718
+ class $mol_wire_atom extends $mol_wire_fiber {
2719
+ static solo(host, task) {
2720
+ const field = task.name + '()';
2721
+ const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
2722
+ if (existen)
2723
+ return existen;
2724
+ const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
2725
+ const key = prefix + ('.' + task.name + '<>');
2726
+ const fiber = new $mol_wire_atom(key, task, host, []);
2727
+ (host ?? task)[field] = fiber;
2728
+ return fiber;
2729
+ }
2730
+ static plex(host, task, key) {
2731
+ const field = task.name + '()';
2732
+ let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
2733
+ const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
2734
+ const key_str = $mol_key(key);
2735
+ if (dict) {
2736
+ const existen = dict.get(key_str);
2737
+ if (existen)
2738
+ return existen;
2739
+ }
2740
+ else {
2741
+ dict = (host ?? task)[field] = new Map();
2742
+ }
2743
+ const id = prefix + ('.' + task.name) + ('<' + key_str.replace(/^"|"$/g, "'") + '>');
2744
+ const fiber = new $mol_wire_atom(id, task, host, [key]);
2745
+ dict.set(key_str, fiber);
2746
+ return fiber;
2747
+ }
2748
+ static watching = new Set();
2749
+ static watcher = null;
2750
+ static watch() {
2751
+ $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
2752
+ for (const atom of $mol_wire_atom.watching) {
2753
+ if (atom.cursor === $mol_wire_cursor.final) {
2754
+ $mol_wire_atom.watching.delete(atom);
2755
+ }
2756
+ else {
2757
+ atom.cursor = $mol_wire_cursor.stale;
2758
+ atom.fresh();
2759
+ }
2760
+ }
2761
+ }
2762
+ watch() {
2763
+ if (!$mol_wire_atom.watcher) {
2764
+ $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
2765
+ }
2766
+ $mol_wire_atom.watching.add(this);
2767
+ }
2768
+ resync(args) {
2769
+ return this.put(this.task.call(this.host, ...args));
2770
+ }
2771
+ once() {
2772
+ return this.sync();
2773
+ }
2774
+ channel() {
2775
+ return Object.assign((next) => {
2776
+ if (next !== undefined)
2777
+ return this.resync([...this.args, next]);
2778
+ if (!$mol_wire_fiber.warm)
2779
+ return this.result();
2780
+ if ($mol_wire_auto()?.temp) {
2781
+ return this.once();
2782
+ }
2783
+ else {
2784
+ return this.sync();
2785
+ }
2786
+ }, { atom: this });
2787
+ }
2788
+ destructor() {
2789
+ super.destructor();
2790
+ if (this.pub_from === 0) {
2791
+ ;
2792
+ (this.host ?? this.task)[this.field()] = null;
2793
+ }
2794
+ else {
2795
+ ;
2796
+ (this.host ?? this.task)[this.field()].delete($mol_key(this.args[0]));
2797
+ }
2798
+ }
2799
+ put(next) {
2800
+ const prev = this.cache;
2801
+ update: if (next !== prev) {
2802
+ try {
2803
+ if ($mol_compare_deep(prev, next))
2804
+ break update;
2805
+ }
2806
+ catch (error) {
2807
+ $mol_fail_log(error);
2808
+ }
2809
+ if ($mol_owning_check(this, prev)) {
2810
+ prev.destructor();
2811
+ }
2812
+ if ($mol_owning_catch(this, next)) {
2813
+ try {
2814
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
2815
+ }
2816
+ catch {
2817
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
2818
+ }
2819
+ }
2820
+ if (!this.sub_empty)
2821
+ this.emit();
2822
+ }
2823
+ this.cache = next;
2824
+ this.cursor = $mol_wire_cursor.fresh;
2825
+ if ($mol_promise_like(next))
2826
+ return next;
2827
+ this.complete_pubs();
2828
+ return next;
2829
+ }
2830
+ }
2831
+ __decorate([
2832
+ $mol_wire_method
2833
+ ], $mol_wire_atom.prototype, "resync", null);
2834
+ __decorate([
2835
+ $mol_wire_method
2836
+ ], $mol_wire_atom.prototype, "once", null);
2837
+ $.$mol_wire_atom = $mol_wire_atom;
2838
+ })($ || ($ = {}));
2809
2839
 
2810
2840
  ;
2811
2841
  "use strict";
2812
2842
  var $;
2813
2843
  (function ($) {
2814
- function $mol_style_attach(id, text) {
2815
- const doc = $mol_dom_context.document;
2816
- if (!doc)
2817
- return null;
2818
- const elid = `$mol_style_attach:${id}`;
2819
- let el = doc.getElementById(elid);
2820
- if (!el) {
2821
- el = doc.createElement('style');
2822
- el.id = elid;
2823
- doc.head.appendChild(el);
2844
+ function $mol_wire_solo(host, field, descr) {
2845
+ if (!descr)
2846
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
2847
+ const orig = descr?.value ?? host[field];
2848
+ const sup = Reflect.getPrototypeOf(host);
2849
+ if (typeof sup[field] === 'function') {
2850
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
2824
2851
  }
2825
- if (el.innerHTML != text)
2826
- el.innerHTML = text;
2827
- return el;
2852
+ const descr2 = {
2853
+ ...descr,
2854
+ value: function (...args) {
2855
+ let atom = $mol_wire_atom.solo(this, orig);
2856
+ if ((args.length === 0) || (args[0] === undefined)) {
2857
+ if (!$mol_wire_fiber.warm)
2858
+ return atom.result();
2859
+ if ($mol_wire_auto()?.temp) {
2860
+ return atom.once();
2861
+ }
2862
+ else {
2863
+ return atom.sync();
2864
+ }
2865
+ }
2866
+ return atom.resync(args);
2867
+ }
2868
+ };
2869
+ Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
2870
+ Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
2871
+ Object.assign(descr2.value, { orig });
2872
+ Reflect.defineProperty(host, field, descr2);
2873
+ return descr2;
2828
2874
  }
2829
- $.$mol_style_attach = $mol_style_attach;
2875
+ $.$mol_wire_solo = $mol_wire_solo;
2830
2876
  })($ || ($ = {}));
2831
2877
 
2832
2878
  ;
2833
2879
  "use strict";
2834
2880
  var $;
2835
2881
  (function ($) {
2836
- class $mol_promise extends Promise {
2837
- done;
2838
- fail;
2839
- constructor(executor) {
2840
- let done;
2841
- let fail;
2842
- super((d, f) => {
2843
- done = d;
2844
- fail = f;
2845
- executor?.(d, f);
2846
- });
2847
- this.done = done;
2848
- this.fail = fail;
2882
+ function $mol_wire_plex(host, field, descr) {
2883
+ if (!descr)
2884
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
2885
+ const orig = descr?.value ?? host[field];
2886
+ const sup = Reflect.getPrototypeOf(host);
2887
+ if (typeof sup[field] === 'function') {
2888
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
2849
2889
  }
2890
+ const descr2 = {
2891
+ ...descr,
2892
+ value: function (...args) {
2893
+ let atom = $mol_wire_atom.plex(this, orig, args[0]);
2894
+ if ((args.length === 1) || (args[1] === undefined)) {
2895
+ if (!$mol_wire_fiber.warm)
2896
+ return atom.result();
2897
+ if ($mol_wire_auto()?.temp) {
2898
+ return atom.once();
2899
+ }
2900
+ else {
2901
+ return atom.sync();
2902
+ }
2903
+ }
2904
+ return atom.resync(args);
2905
+ }
2906
+ };
2907
+ Reflect.defineProperty(descr2.value, 'name', { value: orig.name + ' ' });
2908
+ Reflect.defineProperty(descr2.value, 'length', { value: orig.length });
2909
+ Object.assign(descr2.value, { orig });
2910
+ Reflect.defineProperty(host, field, descr2);
2911
+ return descr2;
2850
2912
  }
2851
- $.$mol_promise = $mol_promise;
2913
+ $.$mol_wire_plex = $mol_wire_plex;
2852
2914
  })($ || ($ = {}));
2853
2915
 
2854
2916
  ;
2855
2917
  "use strict";
2856
2918
  var $;
2857
2919
  (function ($) {
2858
- class $mol_promise_blocker extends $mol_promise {
2859
- static [Symbol.toStringTag] = '$mol_promise_blocker';
2860
- }
2861
- $.$mol_promise_blocker = $mol_promise_blocker;
2920
+ $.$mol_mem = $mol_wire_solo;
2921
+ $.$mol_mem_key = $mol_wire_plex;
2862
2922
  })($ || ($ = {}));
2863
2923
 
2864
2924
  ;
2865
2925
  "use strict";
2866
2926
  var $;
2867
2927
  (function ($) {
2868
- class $mol_decor {
2869
- value;
2870
- constructor(value) {
2871
- this.value = value;
2872
- }
2873
- prefix() { return ''; }
2874
- valueOf() { return this.value; }
2875
- postfix() { return ''; }
2876
- toString() {
2877
- return `${this.prefix()}${this.valueOf()}${this.postfix()}`;
2878
- }
2928
+ function $mol_guard_defined(value) {
2929
+ return value !== null && value !== undefined;
2879
2930
  }
2880
- $.$mol_decor = $mol_decor;
2931
+ $.$mol_guard_defined = $mol_guard_defined;
2881
2932
  })($ || ($ = {}));
2882
2933
 
2883
2934
  ;
2884
2935
  "use strict";
2885
2936
  var $;
2886
2937
  (function ($) {
2887
- class $mol_style_unit extends $mol_decor {
2888
- literal;
2889
- constructor(value, literal) {
2890
- super(value);
2891
- this.literal = literal;
2892
- }
2893
- postfix() {
2894
- return this.literal;
2938
+ class $mol_view_selection extends $mol_object {
2939
+ static focused(next, notify) {
2940
+ const parents = [];
2941
+ let element = next?.[0] ?? $mol_dom_context.document.activeElement;
2942
+ while (element?.shadowRoot) {
2943
+ element = element.shadowRoot.activeElement;
2944
+ }
2945
+ while (element) {
2946
+ parents.push(element);
2947
+ const parent = element.parentNode;
2948
+ if (parent instanceof ShadowRoot)
2949
+ element = parent.host;
2950
+ else
2951
+ element = parent;
2952
+ }
2953
+ if (!next || notify)
2954
+ return parents;
2955
+ new $mol_after_tick(() => {
2956
+ const element = this.focused()[0];
2957
+ if (element)
2958
+ element.focus();
2959
+ else
2960
+ $mol_dom_context.blur();
2961
+ });
2962
+ return parents;
2895
2963
  }
2896
- static per(value) { return `${value}%`; }
2897
- static px(value) { return `${value}px`; }
2898
- static mm(value) { return `${value}mm`; }
2899
- static cm(value) { return `${value}cm`; }
2900
- static Q(value) { return `${value}Q`; }
2901
- static in(value) { return `${value}in`; }
2902
- static pc(value) { return `${value}pc`; }
2903
- static pt(value) { return `${value}pt`; }
2904
- static cap(value) { return `${value}cap`; }
2905
- static ch(value) { return `${value}ch`; }
2906
- static em(value) { return `${value}em`; }
2907
- static rem(value) { return `${value}rem`; }
2908
- static ex(value) { return `${value}ex`; }
2909
- static ic(value) { return `${value}ic`; }
2910
- static lh(value) { return `${value}lh`; }
2911
- static rlh(value) { return `${value}rlh`; }
2912
- static vh(value) { return `${value}vh`; }
2913
- static vw(value) { return `${value}vw`; }
2914
- static vi(value) { return `${value}vi`; }
2915
- static vb(value) { return `${value}vb`; }
2916
- static vmin(value) { return `${value}vmin`; }
2917
- static vmax(value) { return `${value}vmax`; }
2918
- static deg(value) { return `${value}deg`; }
2919
- static rad(value) { return `${value}rad`; }
2920
- static grad(value) { return `${value}grad`; }
2921
- static turn(value) { return `${value}turn`; }
2922
- static s(value) { return `${value}s`; }
2923
- static ms(value) { return `${value}ms`; }
2924
2964
  }
2925
- $.$mol_style_unit = $mol_style_unit;
2965
+ __decorate([
2966
+ $mol_mem
2967
+ ], $mol_view_selection, "focused", null);
2968
+ $.$mol_view_selection = $mol_view_selection;
2926
2969
  })($ || ($ = {}));
2927
2970
 
2928
2971
  ;
2929
2972
  "use strict";
2930
2973
  var $;
2931
2974
  (function ($) {
2932
- const { per } = $mol_style_unit;
2933
- class $mol_style_func extends $mol_decor {
2934
- name;
2935
- constructor(name, value) {
2936
- super(value);
2937
- this.name = name;
2938
- }
2939
- prefix() { return this.name + '('; }
2940
- postfix() { return ')'; }
2941
- static linear_gradient(value) {
2942
- return new $mol_style_func('linear-gradient', value);
2943
- }
2944
- static radial_gradient(value) {
2945
- return new $mol_style_func('radial-gradient', value);
2946
- }
2947
- static calc(value) {
2948
- return new $mol_style_func('calc', value);
2949
- }
2950
- static vary(name, defaultValue) {
2951
- return new $mol_style_func('var', defaultValue ? [name, defaultValue] : name);
2952
- }
2953
- static url(href) {
2954
- return new $mol_style_func('url', JSON.stringify(href));
2955
- }
2956
- static hsla(hue, saturation, lightness, alpha) {
2957
- return new $mol_style_func('hsla', [hue, per(saturation), per(lightness), alpha]);
2958
- }
2959
- static clamp(min, mid, max) {
2960
- return new $mol_style_func('clamp', [min, mid, max]);
2961
- }
2962
- static rgba(red, green, blue, alpha) {
2963
- return new $mol_style_func('rgba', [red, green, blue, alpha]);
2964
- }
2965
- static scale(zoom) {
2966
- return new $mol_style_func('scale', [zoom]);
2967
- }
2968
- static linear(...breakpoints) {
2969
- return new $mol_style_func("linear", breakpoints.map((e) => Array.isArray(e)
2970
- ? String(e[0]) +
2971
- " " +
2972
- (typeof e[1] === "number" ? e[1] + "%" : e[1].toString())
2973
- : String(e)));
2974
- }
2975
- static cubic_bezier(x1, y1, x2, y2) {
2976
- return new $mol_style_func('cubic-bezier', [x1, y1, x2, y2]);
2977
- }
2978
- static steps(value, step_position) {
2979
- return new $mol_style_func('steps', [value, step_position]);
2980
- }
2981
- static blur(value) {
2982
- return new $mol_style_func('blur', value ?? "");
2975
+ class $mol_wrapper extends $mol_object2 {
2976
+ static wrap;
2977
+ static run(task) {
2978
+ return this.func(task)();
2983
2979
  }
2984
- static brightness(value) {
2985
- return new $mol_style_func('brightness', value ?? "");
2980
+ static func(func) {
2981
+ return this.wrap(func);
2986
2982
  }
2987
- static contrast(value) {
2988
- return new $mol_style_func('contrast', value ?? "");
2983
+ static get class() {
2984
+ return (Class) => {
2985
+ const construct = (target, args) => new Class(...args);
2986
+ const handler = {
2987
+ construct: this.func(construct)
2988
+ };
2989
+ handler[Symbol.toStringTag] = Class.name + '#';
2990
+ return new Proxy(Class, handler);
2991
+ };
2989
2992
  }
2990
- static drop_shadow(color, x_offset, y_offset, blur_radius) {
2991
- return new $mol_style_func("drop-shadow", blur_radius
2992
- ? [color, x_offset, y_offset, blur_radius]
2993
- : [color, x_offset, y_offset]);
2993
+ static get method() {
2994
+ return (obj, name, descr) => {
2995
+ descr.value = this.func(descr.value);
2996
+ return descr;
2997
+ };
2994
2998
  }
2995
- static grayscale(value) {
2996
- return new $mol_style_func('grayscale', value ?? "");
2999
+ static get field() {
3000
+ return (obj, name, descr) => {
3001
+ descr.get = descr.set = this.func(descr.get);
3002
+ return descr;
3003
+ };
2997
3004
  }
2998
- static hue_rotate(value) {
2999
- return new $mol_style_func('hue-rotate', value ?? "");
3005
+ }
3006
+ $.$mol_wrapper = $mol_wrapper;
3007
+ })($ || ($ = {}));
3008
+
3009
+ ;
3010
+ "use strict";
3011
+ var $;
3012
+ (function ($) {
3013
+ class $mol_memo extends $mol_wrapper {
3014
+ static wrap(task) {
3015
+ const store = new WeakMap();
3016
+ const fun = function (next) {
3017
+ if (next === undefined && store.has(this))
3018
+ return store.get(this);
3019
+ const val = task.call(this, next) ?? next;
3020
+ store.set(this, val);
3021
+ return val;
3022
+ };
3023
+ Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
3024
+ return fun;
3000
3025
  }
3001
- static invert(value) {
3002
- return new $mol_style_func('invert', value ?? "");
3026
+ }
3027
+ $.$mol_memo = $mol_memo;
3028
+ })($ || ($ = {}));
3029
+
3030
+ ;
3031
+ "use strict";
3032
+ var $;
3033
+ (function ($) {
3034
+ function $mol_dom_qname(name) {
3035
+ return name.replace(/\W/g, '').replace(/^(?=\d+)/, '_');
3036
+ }
3037
+ $.$mol_dom_qname = $mol_dom_qname;
3038
+ })($ || ($ = {}));
3039
+
3040
+ ;
3041
+ "use strict";
3042
+ var $;
3043
+ (function ($) {
3044
+ function $mol_wire_probe(task, def) {
3045
+ const warm = $mol_wire_fiber.warm;
3046
+ try {
3047
+ $mol_wire_fiber.warm = false;
3048
+ const res = task();
3049
+ if (res === undefined)
3050
+ return def;
3051
+ return res;
3003
3052
  }
3004
- static opacity(value) {
3005
- return new $mol_style_func('opacity', value ?? "");
3053
+ finally {
3054
+ $mol_wire_fiber.warm = warm;
3006
3055
  }
3007
- static sepia(value) {
3008
- return new $mol_style_func('sepia', value ?? "");
3056
+ }
3057
+ $.$mol_wire_probe = $mol_wire_probe;
3058
+ })($ || ($ = {}));
3059
+
3060
+ ;
3061
+ "use strict";
3062
+ var $;
3063
+ (function ($) {
3064
+ function $mol_wire_watch() {
3065
+ const atom = $mol_wire_auto();
3066
+ if (atom instanceof $mol_wire_atom) {
3067
+ atom.watch();
3009
3068
  }
3010
- static saturate(value) {
3011
- return new $mol_style_func('saturate', value ?? "");
3069
+ else {
3070
+ $mol_fail(new Error('Atom is required for watching'));
3012
3071
  }
3013
3072
  }
3014
- $.$mol_style_func = $mol_style_func;
3073
+ $.$mol_wire_watch = $mol_wire_watch;
3015
3074
  })($ || ($ = {}));
3016
3075
 
3017
3076
  ;
3018
3077
  "use strict";
3078
+ var $;
3079
+ (function ($) {
3080
+ function $mol_const(value) {
3081
+ const getter = (() => value);
3082
+ getter['()'] = value;
3083
+ getter[Symbol.toStringTag] = value;
3084
+ getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
3085
+ return getter;
3086
+ }
3087
+ $.$mol_const = $mol_const;
3088
+ })($ || ($ = {}));
3019
3089
 
3020
3090
  ;
3021
3091
  "use strict";
3092
+ var $;
3093
+ (function ($) {
3094
+ function $mol_wire_solid() {
3095
+ let current = $mol_wire_auto();
3096
+ if (current.temp)
3097
+ current = current.host;
3098
+ if (current.reap !== nothing) {
3099
+ current?.sub_on(sub, sub.data.length);
3100
+ }
3101
+ current.reap = nothing;
3102
+ }
3103
+ $.$mol_wire_solid = $mol_wire_solid;
3104
+ const nothing = () => { };
3105
+ const sub = new $mol_wire_pub_sub;
3106
+ })($ || ($ = {}));
3022
3107
 
3023
3108
  ;
3024
3109
  "use strict";
3025
3110
  var $;
3026
3111
  (function ($) {
3027
- function $mol_style_prop(prefix, keys) {
3028
- const record = keys.reduce((rec, key) => {
3029
- rec[key] = $mol_style_func.vary(`--${prefix}_${key}`);
3030
- return rec;
3031
- }, {});
3032
- return record;
3112
+ function $mol_dom_render_attributes(el, attrs) {
3113
+ for (let name in attrs) {
3114
+ let val = attrs[name];
3115
+ if (val === undefined) {
3116
+ continue;
3117
+ }
3118
+ else if (val === null || val === false) {
3119
+ if (!el.hasAttribute(name))
3120
+ continue;
3121
+ el.removeAttribute(name);
3122
+ }
3123
+ else {
3124
+ const str = String(val);
3125
+ if (el.getAttribute(name) === str)
3126
+ continue;
3127
+ el.setAttribute(name, str);
3128
+ }
3129
+ }
3033
3130
  }
3034
- $.$mol_style_prop = $mol_style_prop;
3131
+ $.$mol_dom_render_attributes = $mol_dom_render_attributes;
3035
3132
  })($ || ($ = {}));
3036
3133
 
3037
3134
  ;
3038
3135
  "use strict";
3039
3136
  var $;
3040
3137
  (function ($) {
3041
- $.$mol_theme = $mol_style_prop('mol_theme', [
3042
- 'back',
3043
- 'hover',
3044
- 'card',
3045
- 'current',
3046
- 'special',
3047
- 'text',
3048
- 'control',
3049
- 'shade',
3050
- 'line',
3051
- 'focus',
3052
- 'field',
3053
- 'image',
3054
- 'spirit',
3055
- ]);
3138
+ function $mol_dom_render_events(el, events, passive = false) {
3139
+ for (let name in events) {
3140
+ el.addEventListener(name, events[name], { passive });
3141
+ }
3142
+ }
3143
+ $.$mol_dom_render_events = $mol_dom_render_events;
3056
3144
  })($ || ($ = {}));
3057
3145
 
3058
3146
  ;
3059
3147
  "use strict";
3060
3148
  var $;
3061
3149
  (function ($) {
3062
- $mol_style_attach("mol/theme/theme.css", ":root {\n\t--mol_theme_hue: 240deg;\n\t--mol_theme_hue_spread: 90deg;\n\tcolor-scheme: dark light;\n}\n\n:where([mol_theme]) {\n\tcolor: var(--mol_theme_text);\n\tfill: var(--mol_theme_text);\n\tbackground-color: var(--mol_theme_back);\n}\n\t\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\n\t--mol_theme_luma: -1;\n\t--mol_theme_image: invert(1) hue-rotate( 180deg );\n\t--mol_theme_spirit: hsl( 0deg, 0%, 0%, .75 );\n\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 10% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 20%, .25 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 8%, .25 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 80% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 60%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 65% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 60%, 65% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 60%, 65% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 60%, 65% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\t\n\t--mol_theme_back: oklch( 20% .03 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 30% .05 var(--mol_theme_hue) / .25 );\n\t--mol_theme_field: oklch( 15% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 80% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 60% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 80% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 70% .1 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 70% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 70% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t\n\t--mol_theme_luma: 1;\n\t--mol_theme_image: none;\n\t--mol_theme_spirit: hsl( 0deg, 0%, 100%, .75 );\n\t\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 92% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 100%, .5 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 100%, .75 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 0% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 40%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 40% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 80%, 30% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 80%, 30% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 80%, 30% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t--mol_theme_back: oklch( 92% .01 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 99% .01 var(--mol_theme_hue) / .5 );\n\t--mol_theme_field: oklch( 100% 0 var(--mol_theme_hue) / .5 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 20% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 50% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 60% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 40% .15 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 50% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 50% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 25% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 35% .1 var(--mol_theme_hue) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 85% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 98% .03 var(--mol_theme_hue) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 35% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 45% .15 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 83% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n\n");
3150
+ function $mol_dom_render_styles(el, styles) {
3151
+ for (let name in styles) {
3152
+ let val = styles[name];
3153
+ const style = el.style;
3154
+ const kebab = (name) => name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase());
3155
+ if (typeof val === 'number') {
3156
+ style.setProperty(kebab(name), `${val}px`);
3157
+ }
3158
+ else {
3159
+ style.setProperty(kebab(name), val);
3160
+ }
3161
+ }
3162
+ }
3163
+ $.$mol_dom_render_styles = $mol_dom_render_styles;
3063
3164
  })($ || ($ = {}));
3064
3165
 
3065
3166
  ;
3066
3167
  "use strict";
3067
3168
  var $;
3068
3169
  (function ($) {
3069
- $.$mol_gap = $mol_style_prop('mol_gap', [
3070
- 'block',
3071
- 'text',
3072
- 'round',
3073
- 'space',
3074
- 'blur',
3075
- ]);
3170
+ function $mol_dom_render_fields(el, fields) {
3171
+ for (let key in fields) {
3172
+ const val = fields[key];
3173
+ if (val === undefined)
3174
+ continue;
3175
+ if (val === el[key])
3176
+ continue;
3177
+ el[key] = val;
3178
+ }
3179
+ }
3180
+ $.$mol_dom_render_fields = $mol_dom_render_fields;
3076
3181
  })($ || ($ = {}));
3077
3182
 
3078
3183
  ;
3079
3184
  "use strict";
3080
3185
  var $;
3081
3186
  (function ($) {
3082
- $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
3187
+ function $mol_wire_async(obj) {
3188
+ let fiber;
3189
+ const temp = $mol_wire_task.getter(obj);
3190
+ return new Proxy(obj, {
3191
+ get(obj, field) {
3192
+ const val = obj[field];
3193
+ if (typeof val !== 'function')
3194
+ return val;
3195
+ let fiber;
3196
+ const temp = $mol_wire_task.getter(val);
3197
+ return function $mol_wire_async(...args) {
3198
+ fiber?.destructor();
3199
+ fiber = temp(obj, args);
3200
+ return fiber.async();
3201
+ };
3202
+ },
3203
+ apply(obj, self, args) {
3204
+ fiber?.destructor();
3205
+ fiber = temp(self, args);
3206
+ return fiber.async();
3207
+ },
3208
+ });
3209
+ }
3210
+ $.$mol_wire_async = $mol_wire_async;
3211
+ })($ || ($ = {}));
3212
+
3213
+ ;
3214
+ "use strict";
3215
+
3216
+ ;
3217
+ "use strict";
3218
+
3219
+ ;
3220
+ "use strict";
3221
+ var $;
3222
+ (function ($) {
3223
+ $mol_style_attach("mol/view/view/view.css", "[mol_view] {\n\ttransition-property: height, width, min-height, min-width, max-width, max-height, transform;\n\ttransition-duration: .2s;\n\ttransition-timing-function: ease-out;\n\t-webkit-appearance: none;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\tflex-shrink: 0;\n\tcontain: style;\n\tscrollbar-color: var(--mol_theme_line) transparent;\n\tscrollbar-width: thin;\n}\t\n\n[mol_view]::selection {\n\tbackground: var(--mol_theme_line);\n}\t\n\n[mol_view]::-webkit-scrollbar {\n\twidth: .25rem;\n\theight: .25rem;\n}\n\n[mol_view]::-webkit-scrollbar-corner {\n\tbackground-color: var(--mol_theme_line);\n}\n\n[mol_view]::-webkit-scrollbar-track {\n\tbackground-color: transparent;\n}\n\n[mol_view]::-webkit-scrollbar-thumb {\n\tbackground-color: var(--mol_theme_line);\n\tborder-radius: var(--mol_gap_round);\n}\n\n[mol_view] > * {\n\tword-break: inherit;\n}\n\n[mol_view_root] {\n\tmargin: 0;\n\tpadding: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbox-sizing: border-box;\n\tfont-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n\tfont-size: 1rem;\n\tline-height: 1.5rem;\n\tbackground: var(--mol_theme_back);\n\tcolor: var(--mol_theme_text);\n\tcontain: unset; /** Fixes bg ignoring when applied to body on Chrome */\n\ttab-size: 4;\n\toverscroll-behavior: contain; /** Disable navigation gestures **/\n}\n\n@media print {\n\t[mol_view_root] {\n\t\theight: auto;\n\t}\n}\n[mol_view][mol_view_error]:not([mol_view_error=\"Promise\"], [mol_view_error=\"$mol_promise_blocker\"]) {\n\tbackground-image: repeating-linear-gradient(\n\t\t-45deg,\n\t\t#f92323,\n\t\t#f92323 .5rem,\n\t\t#ff3d3d .5rem,\n\t\t#ff3d3d 1.5rem\n\t);\n\tcolor: black;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n@keyframes mol_view_wait {\n\tfrom {\n\t\topacity: .25;\n\t}\n\t20% {\n\t\topacity: .75;\n\t}\n\tto {\n\t\topacity: .25;\n\t}\n}\n\n:where([mol_view][mol_view_error=\"$mol_promise_blocker\"]),\n:where([mol_view][mol_view_error=\"Promise\"]) {\n\tbackground: var(--mol_theme_hover);\n}\n\n[mol_view][mol_view_error=\"Promise\"] {\n\tanimation: mol_view_wait 1s steps(20,end) infinite;\n}\n");
3083
3224
  })($ || ($ = {}));
3084
3225
 
3085
3226
  ;
@@ -3102,32 +3243,58 @@ var $;
3102
3243
  static Root(id) {
3103
3244
  return new this;
3104
3245
  }
3105
- autorun() {
3246
+ static roots() {
3247
+ return [...$mol_dom.document.querySelectorAll('[mol_view_root]:not([mol_view_root=""])')].map((node, index) => {
3248
+ const name = node.getAttribute('mol_view_root');
3249
+ const View = this.$[name];
3250
+ if (!View) {
3251
+ $mol_fail_log(new Error(`Autobind unknown view class`, { cause: { name } }));
3252
+ return null;
3253
+ }
3254
+ const view = View.Root(index);
3255
+ view.dom_node(node);
3256
+ return view;
3257
+ }).filter($mol_guard_defined);
3258
+ }
3259
+ static auto() {
3260
+ const roots = this.roots();
3261
+ if (!roots.length)
3262
+ return;
3263
+ for (const root of roots) {
3264
+ try {
3265
+ root.dom_tree();
3266
+ }
3267
+ catch (error) {
3268
+ $mol_fail_log(error);
3269
+ }
3270
+ }
3106
3271
  try {
3107
- this.dom_tree();
3108
- document.title = this.title();
3272
+ document.title = roots[0].title();
3109
3273
  }
3110
3274
  catch (error) {
3111
3275
  $mol_fail_log(error);
3112
3276
  }
3113
- }
3114
- static autobind() {
3115
- const nodes = $mol_dom_context.document.querySelectorAll('[mol_view_root]:not([mol_view_root=""])');
3116
- for (let i = nodes.length - 1; i >= 0; --i) {
3117
- const name = nodes.item(i).getAttribute('mol_view_root');
3118
- const View = $[name];
3119
- if (!View) {
3120
- console.error(`Can not attach view. Class not found: ${name}`);
3121
- continue;
3122
- }
3123
- const view = View.Root(i);
3124
- view.dom_node(nodes.item(i));
3125
- view.autorun();
3277
+ descr: try {
3278
+ const descr = roots[0].hint();
3279
+ if (!descr)
3280
+ break descr;
3281
+ const head = $mol_dom.document.head;
3282
+ let node = head.querySelector('meta[name="description"]');
3283
+ if (node)
3284
+ node.content = descr;
3285
+ else
3286
+ head.append($mol_jsx("meta", { name: "description", content: descr }));
3287
+ }
3288
+ catch (error) {
3289
+ $mol_fail_log(error);
3126
3290
  }
3127
3291
  }
3128
3292
  title() {
3129
3293
  return this.toString().match(/.*\.(\w+)/)?.[1] ?? this.toString();
3130
3294
  }
3295
+ hint() {
3296
+ return '';
3297
+ }
3131
3298
  focused(next) {
3132
3299
  let node = this.dom_node();
3133
3300
  const value = $mol_view_selection.focused(next === undefined ? undefined : (next ? [node] : []));
@@ -3459,9 +3626,6 @@ var $;
3459
3626
  }
3460
3627
  }
3461
3628
  }
3462
- __decorate([
3463
- $mol_mem
3464
- ], $mol_view.prototype, "autorun", null);
3465
3629
  __decorate([
3466
3630
  $mol_mem
3467
3631
  ], $mol_view.prototype, "title", null);
@@ -3515,20 +3679,16 @@ var $;
3515
3679
  ], $mol_view, "Root", null);
3516
3680
  __decorate([
3517
3681
  $mol_mem
3518
- ], $mol_view, "autobind", null);
3682
+ ], $mol_view, "roots", null);
3683
+ __decorate([
3684
+ $mol_mem
3685
+ ], $mol_view, "auto", null);
3519
3686
  __decorate([
3520
3687
  $mol_memo.method
3521
3688
  ], $mol_view, "view_classes", null);
3522
3689
  $.$mol_view = $mol_view;
3523
3690
  })($ || ($ = {}));
3524
3691
 
3525
- ;
3526
- "use strict";
3527
- var $;
3528
- (function ($) {
3529
- $mol_style_attach("mol/view/view/view.css", "[mol_view] {\n\ttransition-property: height, width, min-height, min-width, max-width, max-height, transform;\n\ttransition-duration: .2s;\n\ttransition-timing-function: ease-out;\n\t-webkit-appearance: none;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\tflex-shrink: 0;\n\tcontain: style;\n\tscrollbar-color: var(--mol_theme_line) transparent;\n\tscrollbar-width: thin;\n}\t\n\n[mol_view]::selection {\n\tbackground: var(--mol_theme_line);\n}\t\n\n[mol_view]::-webkit-scrollbar {\n\twidth: .25rem;\n\theight: .25rem;\n}\n\n[mol_view]::-webkit-scrollbar-corner {\n\tbackground-color: var(--mol_theme_line);\n}\n\n[mol_view]::-webkit-scrollbar-track {\n\tbackground-color: transparent;\n}\n\n[mol_view]::-webkit-scrollbar-thumb {\n\tbackground-color: var(--mol_theme_line);\n\tborder-radius: var(--mol_gap_round);\n}\n\n[mol_view] > * {\n\tword-break: inherit;\n}\n\n[mol_view_root] {\n\tmargin: 0;\n\tpadding: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbox-sizing: border-box;\n\tfont-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n\tfont-size: 1rem;\n\tline-height: 1.5rem;\n\tbackground: var(--mol_theme_back);\n\tcolor: var(--mol_theme_text);\n\tcontain: unset; /** Fixes bg ignoring when applied to body on Chrome */\n\ttab-size: 4;\n\toverscroll-behavior: contain; /** Disable navigation gestures **/\n}\n\n@media print {\n\t[mol_view_root] {\n\t\theight: auto;\n\t}\n}\n[mol_view][mol_view_error]:not([mol_view_error=\"Promise\"], [mol_view_error=\"$mol_promise_blocker\"]) {\n\tbackground-image: repeating-linear-gradient(\n\t\t-45deg,\n\t\t#f92323,\n\t\t#f92323 .5rem,\n\t\t#ff3d3d .5rem,\n\t\t#ff3d3d 1.5rem\n\t);\n\tcolor: black;\n\talign-items: center;\n\tjustify-content: center;\n}\n\n@keyframes mol_view_wait {\n\tfrom {\n\t\topacity: .25;\n\t}\n\t20% {\n\t\topacity: .75;\n\t}\n\tto {\n\t\topacity: .25;\n\t}\n}\n\n:where([mol_view][mol_view_error=\"$mol_promise_blocker\"]),\n:where([mol_view][mol_view_error=\"Promise\"]) {\n\tbackground: var(--mol_theme_hover);\n}\n\n[mol_view][mol_view_error=\"Promise\"] {\n\tanimation: mol_view_wait 1s steps(20,end) infinite;\n}\n");
3530
- })($ || ($ = {}));
3531
-
3532
3692
  ;
3533
3693
  "use strict";
3534
3694
  var $;