mol_jsx_lib 0.0.1047 → 0.0.1049

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
@@ -159,6 +159,68 @@ require = (req => Object.assign(function require(name) {
159
159
  return $node[name];
160
160
  }, req))(require);
161
161
 
162
+ ;
163
+ "use strict";
164
+ var $;
165
+ (function ($) {
166
+ const named = new WeakSet();
167
+ function $mol_func_name(func) {
168
+ let name = func.name;
169
+ if (name?.length > 1)
170
+ return name;
171
+ if (named.has(func))
172
+ return name;
173
+ for (let key in this) {
174
+ try {
175
+ if (this[key] !== func)
176
+ continue;
177
+ name = key;
178
+ Object.defineProperty(func, 'name', { value: name });
179
+ break;
180
+ }
181
+ catch { }
182
+ }
183
+ named.add(func);
184
+ return name;
185
+ }
186
+ $.$mol_func_name = $mol_func_name;
187
+ function $mol_func_name_from(target, source) {
188
+ Object.defineProperty(target, 'name', { value: source.name });
189
+ return target;
190
+ }
191
+ $.$mol_func_name_from = $mol_func_name_from;
192
+ })($ || ($ = {}));
193
+
194
+ ;
195
+ "use strict";
196
+ var $;
197
+ (function ($) {
198
+ class $mol_error_mix extends AggregateError {
199
+ cause;
200
+ name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
201
+ constructor(message, cause = {}, ...errors) {
202
+ super(errors, message, { cause });
203
+ this.cause = cause;
204
+ const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
205
+ Object.defineProperty(this, 'stack', {
206
+ get: () => (stack_get.call(this) ?? this.message) + '\n' + [JSON.stringify(this.cause, null, ' ') ?? 'no cause', ...this.errors.map(e => e.stack)].map(e => e.trim()
207
+ .replace(/at /gm, ' at ')
208
+ .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
209
+ });
210
+ }
211
+ static [Symbol.toPrimitive]() {
212
+ return this.toString();
213
+ }
214
+ static toString() {
215
+ return $$.$mol_func_name(this);
216
+ }
217
+ static make(...params) {
218
+ return new this(...params);
219
+ }
220
+ }
221
+ $.$mol_error_mix = $mol_error_mix;
222
+ })($ || ($ = {}));
223
+
162
224
  ;
163
225
  "use strict";
164
226
  var $;
@@ -290,38 +352,6 @@ var $;
290
352
  ;
291
353
  "use strict";
292
354
 
293
- ;
294
- "use strict";
295
- var $;
296
- (function ($) {
297
- const named = new WeakSet();
298
- function $mol_func_name(func) {
299
- let name = func.name;
300
- if (name?.length > 1)
301
- return name;
302
- if (named.has(func))
303
- return name;
304
- for (let key in this) {
305
- try {
306
- if (this[key] !== func)
307
- continue;
308
- name = key;
309
- Object.defineProperty(func, 'name', { value: name });
310
- break;
311
- }
312
- catch { }
313
- }
314
- named.add(func);
315
- return name;
316
- }
317
- $.$mol_func_name = $mol_func_name;
318
- function $mol_func_name_from(target, source) {
319
- Object.defineProperty(target, 'name', { value: source.name });
320
- return target;
321
- }
322
- $.$mol_func_name_from = $mol_func_name_from;
323
- })($ || ($ = {}));
324
-
325
355
  ;
326
356
  "use strict";
327
357
  var $;
@@ -881,90 +911,80 @@ var $;
881
911
  "use strict";
882
912
  var $;
883
913
  (function ($) {
884
- function $mol_exec(dir, command, ...args) {
885
- let [app, ...args0] = command.split(' ');
886
- args = [...args0, ...args];
887
- this.$mol_log3_come({
888
- place: '$mol_exec',
889
- dir: $node.path.relative('', dir),
890
- message: 'Run',
891
- command: `${app} ${args.join(' ')}`,
892
- });
893
- var res = $node['child_process'].spawnSync(app, args, {
894
- cwd: $node.path.resolve(dir),
895
- shell: true,
896
- env: this.$mol_env(),
897
- });
898
- if (res.status || res.error) {
899
- return $mol_fail(res.error || new Error(res.stderr.toString(), { cause: res.stdout }));
900
- }
901
- if (!res.stdout)
902
- res.stdout = Buffer.from([]);
903
- return res;
904
- }
905
- $.$mol_exec = $mol_exec;
906
- })($ || ($ = {}));
907
-
908
- ;
909
- "use strict";
910
- var $;
911
- (function ($) {
912
- $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
914
+ let $mol_wire_cursor;
915
+ (function ($mol_wire_cursor) {
916
+ $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
917
+ $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
918
+ $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
919
+ $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
920
+ })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
913
921
  })($ || ($ = {}));
914
922
 
915
923
  ;
916
924
  "use strict";
917
925
  var $;
918
926
  (function ($) {
919
- function $mol_dom_render_children(el, childNodes) {
920
- const node_set = new Set(childNodes);
921
- let nextNode = el.firstChild;
922
- for (let view of childNodes) {
923
- if (view == null)
924
- continue;
925
- if (view instanceof $mol_dom_context.Node) {
926
- while (true) {
927
- if (!nextNode) {
928
- el.appendChild(view);
929
- break;
930
- }
931
- if (nextNode == view) {
932
- nextNode = nextNode.nextSibling;
933
- break;
934
- }
935
- else {
936
- if (node_set.has(nextNode)) {
937
- el.insertBefore(view, nextNode);
938
- break;
939
- }
940
- else {
941
- const nn = nextNode.nextSibling;
942
- el.removeChild(nextNode);
943
- nextNode = nn;
944
- }
945
- }
946
- }
927
+ class $mol_wire_pub extends Object {
928
+ data = [];
929
+ static get [Symbol.species]() {
930
+ return Array;
931
+ }
932
+ sub_from = 0;
933
+ get sub_list() {
934
+ const res = [];
935
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
936
+ res.push(this.data[i]);
947
937
  }
948
- else {
949
- if (nextNode && nextNode.nodeName === '#text') {
950
- const str = String(view);
951
- if (nextNode.nodeValue !== str)
952
- nextNode.nodeValue = str;
953
- nextNode = nextNode.nextSibling;
954
- }
955
- else {
956
- const textNode = $mol_dom_context.document.createTextNode(String(view));
957
- el.insertBefore(textNode, nextNode);
958
- }
938
+ return res;
939
+ }
940
+ get sub_empty() {
941
+ return this.sub_from === this.data.length;
942
+ }
943
+ sub_on(sub, pub_pos) {
944
+ const pos = this.data.length;
945
+ this.data.push(sub, pub_pos);
946
+ return pos;
947
+ }
948
+ sub_off(sub_pos) {
949
+ if (!(sub_pos < this.data.length)) {
950
+ $mol_fail(new Error(`Wrong pos ${sub_pos}`));
951
+ }
952
+ const end = this.data.length - 2;
953
+ if (sub_pos !== end) {
954
+ this.peer_move(end, sub_pos);
959
955
  }
956
+ this.data.pop();
957
+ this.data.pop();
958
+ if (this.data.length === this.sub_from)
959
+ this.reap();
960
960
  }
961
- while (nextNode) {
962
- const currNode = nextNode;
963
- nextNode = currNode.nextSibling;
964
- el.removeChild(currNode);
961
+ reap() { }
962
+ promote() {
963
+ $mol_wire_auto()?.track_next(this);
964
+ }
965
+ fresh() { }
966
+ complete() { }
967
+ get incompleted() {
968
+ return false;
969
+ }
970
+ emit(quant = $mol_wire_cursor.stale) {
971
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
972
+ ;
973
+ this.data[i].absorb(quant);
974
+ }
975
+ }
976
+ peer_move(from_pos, to_pos) {
977
+ const peer = this.data[from_pos];
978
+ const self_pos = this.data[from_pos + 1];
979
+ this.data[to_pos] = peer;
980
+ this.data[to_pos + 1] = self_pos;
981
+ peer.peer_repos(self_pos, to_pos);
982
+ }
983
+ peer_repos(peer_pos, self_pos) {
984
+ this.data[peer_pos + 1] = self_pos;
965
985
  }
966
986
  }
967
- $.$mol_dom_render_children = $mol_dom_render_children;
987
+ $.$mol_wire_pub = $mol_wire_pub;
968
988
  })($ || ($ = {}));
969
989
 
970
990
  ;
@@ -974,262 +994,41 @@ var $;
974
994
  "use strict";
975
995
  var $;
976
996
  (function ($) {
977
- $.$mol_jsx_prefix = '';
978
- $.$mol_jsx_crumbs = '';
979
- $.$mol_jsx_booked = null;
980
- $.$mol_jsx_document = {
981
- getElementById: () => null,
982
- createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
983
- createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
984
- };
985
- $.$mol_jsx_frag = '';
986
- function $mol_jsx(Elem, props, ...childNodes) {
987
- const id = props && props.id || '';
988
- const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
989
- const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
990
- if (Elem && $.$mol_jsx_booked) {
991
- if ($.$mol_jsx_booked.has(id)) {
992
- $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
997
+ $.$mol_wire_auto_sub = null;
998
+ function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
999
+ return $.$mol_wire_auto_sub = next;
1000
+ }
1001
+ $.$mol_wire_auto = $mol_wire_auto;
1002
+ $.$mol_wire_affected = [];
1003
+ })($ || ($ = {}));
1004
+
1005
+ ;
1006
+ "use strict";
1007
+ var $;
1008
+ (function ($) {
1009
+ $['devtoolsFormatters'] ||= [];
1010
+ function $mol_dev_format_register(config) {
1011
+ $['devtoolsFormatters'].push(config);
1012
+ }
1013
+ $.$mol_dev_format_register = $mol_dev_format_register;
1014
+ $.$mol_dev_format_head = Symbol('$mol_dev_format_head');
1015
+ $.$mol_dev_format_body = Symbol('$mol_dev_format_body');
1016
+ $mol_dev_format_register({
1017
+ header: (val, config = false) => {
1018
+ if (config)
1019
+ return null;
1020
+ if (!val)
1021
+ return null;
1022
+ if ($.$mol_dev_format_head in val) {
1023
+ try {
1024
+ return val[$.$mol_dev_format_head]();
1025
+ }
1026
+ catch (error) {
1027
+ return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
1028
+ }
993
1029
  }
994
- else {
995
- $.$mol_jsx_booked.add(id);
996
- }
997
- }
998
- let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
999
- if ($.$mol_jsx_prefix) {
1000
- const prefix_ext = $.$mol_jsx_prefix;
1001
- const booked_ext = $.$mol_jsx_booked;
1002
- const crumbs_ext = $.$mol_jsx_crumbs;
1003
- for (const field in props) {
1004
- const func = props[field];
1005
- if (typeof func !== 'function')
1006
- continue;
1007
- const wrapper = function (...args) {
1008
- const prefix = $.$mol_jsx_prefix;
1009
- const booked = $.$mol_jsx_booked;
1010
- const crumbs = $.$mol_jsx_crumbs;
1011
- try {
1012
- $.$mol_jsx_prefix = prefix_ext;
1013
- $.$mol_jsx_booked = booked_ext;
1014
- $.$mol_jsx_crumbs = crumbs_ext;
1015
- return func.call(this, ...args);
1016
- }
1017
- finally {
1018
- $.$mol_jsx_prefix = prefix;
1019
- $.$mol_jsx_booked = booked;
1020
- $.$mol_jsx_crumbs = crumbs;
1021
- }
1022
- };
1023
- $mol_func_name_from(wrapper, func);
1024
- props[field] = wrapper;
1025
- }
1026
- }
1027
- if (typeof Elem !== 'string') {
1028
- if ('prototype' in Elem) {
1029
- const view = node && node[String(Elem)] || new Elem;
1030
- Object.assign(view, props);
1031
- view[Symbol.toStringTag] = guid;
1032
- view.childNodes = childNodes;
1033
- if (!view.ownerDocument)
1034
- view.ownerDocument = $.$mol_jsx_document;
1035
- view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
1036
- node = view.valueOf();
1037
- node[String(Elem)] = view;
1038
- return node;
1039
- }
1040
- else {
1041
- const prefix = $.$mol_jsx_prefix;
1042
- const booked = $.$mol_jsx_booked;
1043
- const crumbs = $.$mol_jsx_crumbs;
1044
- try {
1045
- $.$mol_jsx_prefix = guid;
1046
- $.$mol_jsx_booked = new Set;
1047
- $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
1048
- return Elem(props, ...childNodes);
1049
- }
1050
- finally {
1051
- $.$mol_jsx_prefix = prefix;
1052
- $.$mol_jsx_booked = booked;
1053
- $.$mol_jsx_crumbs = crumbs;
1054
- }
1055
- }
1056
- }
1057
- if (!node) {
1058
- node = Elem
1059
- ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
1060
- : $.$mol_jsx_document.createDocumentFragment();
1061
- }
1062
- $mol_dom_render_children(node, [].concat(...childNodes));
1063
- if (!Elem)
1064
- return node;
1065
- if (guid)
1066
- node.id = guid;
1067
- for (const key in props) {
1068
- if (key === 'id')
1069
- continue;
1070
- if (typeof props[key] === 'string') {
1071
- if (typeof node[key] === 'string')
1072
- node[key] = props[key];
1073
- node.setAttribute(key, props[key]);
1074
- }
1075
- else if (props[key] &&
1076
- typeof props[key] === 'object' &&
1077
- Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
1078
- if (typeof node[key] === 'object') {
1079
- Object.assign(node[key], props[key]);
1080
- continue;
1081
- }
1082
- }
1083
- else {
1084
- node[key] = props[key];
1085
- }
1086
- }
1087
- if ($.$mol_jsx_crumbs)
1088
- node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
1089
- return node;
1090
- }
1091
- $.$mol_jsx = $mol_jsx;
1092
- })($ || ($ = {}));
1093
-
1094
- ;
1095
- "use strict";
1096
- var $;
1097
- (function ($) {
1098
- function $mol_jsx_attach(next, action) {
1099
- const prev = $mol_jsx_document;
1100
- try {
1101
- $mol_jsx_document = next;
1102
- return action();
1103
- }
1104
- finally {
1105
- $mol_jsx_document = prev;
1106
- }
1107
- }
1108
- $.$mol_jsx_attach = $mol_jsx_attach;
1109
- })($ || ($ = {}));
1110
-
1111
- ;
1112
- "use strict";
1113
- var $;
1114
- (function ($) {
1115
- let $mol_wire_cursor;
1116
- (function ($mol_wire_cursor) {
1117
- $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
1118
- $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
1119
- $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
1120
- $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
1121
- })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
1122
- })($ || ($ = {}));
1123
-
1124
- ;
1125
- "use strict";
1126
- var $;
1127
- (function ($) {
1128
- class $mol_wire_pub extends Object {
1129
- data = [];
1130
- static get [Symbol.species]() {
1131
- return Array;
1132
- }
1133
- sub_from = 0;
1134
- get sub_list() {
1135
- const res = [];
1136
- for (let i = this.sub_from; i < this.data.length; i += 2) {
1137
- res.push(this.data[i]);
1138
- }
1139
- return res;
1140
- }
1141
- get sub_empty() {
1142
- return this.sub_from === this.data.length;
1143
- }
1144
- sub_on(sub, pub_pos) {
1145
- const pos = this.data.length;
1146
- this.data.push(sub, pub_pos);
1147
- return pos;
1148
- }
1149
- sub_off(sub_pos) {
1150
- if (!(sub_pos < this.data.length)) {
1151
- $mol_fail(new Error(`Wrong pos ${sub_pos}`));
1152
- }
1153
- const end = this.data.length - 2;
1154
- if (sub_pos !== end) {
1155
- this.peer_move(end, sub_pos);
1156
- }
1157
- this.data.pop();
1158
- this.data.pop();
1159
- if (this.data.length === this.sub_from)
1160
- this.reap();
1161
- }
1162
- reap() { }
1163
- promote() {
1164
- $mol_wire_auto()?.track_next(this);
1165
- }
1166
- fresh() { }
1167
- complete() { }
1168
- get incompleted() {
1169
- return false;
1170
- }
1171
- emit(quant = $mol_wire_cursor.stale) {
1172
- for (let i = this.sub_from; i < this.data.length; i += 2) {
1173
- ;
1174
- this.data[i].absorb(quant);
1175
- }
1176
- }
1177
- peer_move(from_pos, to_pos) {
1178
- const peer = this.data[from_pos];
1179
- const self_pos = this.data[from_pos + 1];
1180
- this.data[to_pos] = peer;
1181
- this.data[to_pos + 1] = self_pos;
1182
- peer.peer_repos(self_pos, to_pos);
1183
- }
1184
- peer_repos(peer_pos, self_pos) {
1185
- this.data[peer_pos + 1] = self_pos;
1186
- }
1187
- }
1188
- $.$mol_wire_pub = $mol_wire_pub;
1189
- })($ || ($ = {}));
1190
-
1191
- ;
1192
- "use strict";
1193
-
1194
- ;
1195
- "use strict";
1196
- var $;
1197
- (function ($) {
1198
- $.$mol_wire_auto_sub = null;
1199
- function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
1200
- return $.$mol_wire_auto_sub = next;
1201
- }
1202
- $.$mol_wire_auto = $mol_wire_auto;
1203
- $.$mol_wire_affected = [];
1204
- })($ || ($ = {}));
1205
-
1206
- ;
1207
- "use strict";
1208
- var $;
1209
- (function ($) {
1210
- $['devtoolsFormatters'] ||= [];
1211
- function $mol_dev_format_register(config) {
1212
- $['devtoolsFormatters'].push(config);
1213
- }
1214
- $.$mol_dev_format_register = $mol_dev_format_register;
1215
- $.$mol_dev_format_head = Symbol('$mol_dev_format_head');
1216
- $.$mol_dev_format_body = Symbol('$mol_dev_format_body');
1217
- $mol_dev_format_register({
1218
- header: (val, config = false) => {
1219
- if (config)
1220
- return null;
1221
- if (!val)
1222
- return null;
1223
- if ($.$mol_dev_format_head in val) {
1224
- try {
1225
- return val[$.$mol_dev_format_head]();
1226
- }
1227
- catch (error) {
1228
- return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
1229
- }
1230
- }
1231
- if (typeof val === 'function') {
1232
- return $mol_dev_format_native(val);
1030
+ if (typeof val === 'function') {
1031
+ return $mol_dev_format_native(val);
1233
1032
  }
1234
1033
  if (Symbol.toStringTag in val) {
1235
1034
  return $mol_dev_format_native(val);
@@ -1305,20 +1104,6 @@ var $;
1305
1104
  });
1306
1105
  })($ || ($ = {}));
1307
1106
 
1308
- ;
1309
- "use strict";
1310
- var $;
1311
- (function ($) {
1312
- function $mol_const(value) {
1313
- const getter = (() => value);
1314
- getter['()'] = value;
1315
- getter[Symbol.toStringTag] = value;
1316
- getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
1317
- return getter;
1318
- }
1319
- $.$mol_const = $mol_const;
1320
- })($ || ($ = {}));
1321
-
1322
1107
  ;
1323
1108
  "use strict";
1324
1109
  var $;
@@ -1718,103 +1503,6 @@ var $;
1718
1503
  $.$mol_wire_fiber = $mol_wire_fiber;
1719
1504
  })($ || ($ = {}));
1720
1505
 
1721
- ;
1722
- "use strict";
1723
- var $;
1724
- (function ($) {
1725
- function $mol_guid(length = 8, exists = () => false) {
1726
- for (;;) {
1727
- let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
1728
- if (exists(id))
1729
- continue;
1730
- return id;
1731
- }
1732
- }
1733
- $.$mol_guid = $mol_guid;
1734
- })($ || ($ = {}));
1735
-
1736
- ;
1737
- "use strict";
1738
- var $;
1739
- (function ($) {
1740
- $.$mol_key_store = new WeakMap();
1741
- function $mol_key(value) {
1742
- if (typeof value === 'bigint')
1743
- return value.toString() + 'n';
1744
- if (typeof value === 'symbol')
1745
- return value.description;
1746
- if (!value)
1747
- return JSON.stringify(value);
1748
- if (typeof value !== 'object' && typeof value !== 'function')
1749
- return JSON.stringify(value);
1750
- return JSON.stringify(value, (field, value) => {
1751
- if (typeof value === 'bigint')
1752
- return value.toString() + 'n';
1753
- if (typeof value === 'symbol')
1754
- return value.description;
1755
- if (!value)
1756
- return value;
1757
- if (typeof value !== 'object' && typeof value !== 'function')
1758
- return value;
1759
- if (Array.isArray(value))
1760
- return value;
1761
- const proto = Reflect.getPrototypeOf(value);
1762
- if (!proto)
1763
- return value;
1764
- if (Reflect.getPrototypeOf(proto) === null)
1765
- return value;
1766
- if ('toJSON' in value)
1767
- return value;
1768
- if (value instanceof RegExp)
1769
- return value.toString();
1770
- if (value instanceof Uint8Array)
1771
- return [...value];
1772
- let key = $.$mol_key_store.get(value);
1773
- if (key)
1774
- return key;
1775
- key = $mol_guid();
1776
- $.$mol_key_store.set(value, key);
1777
- return key;
1778
- });
1779
- }
1780
- $.$mol_key = $mol_key;
1781
- })($ || ($ = {}));
1782
-
1783
- ;
1784
- "use strict";
1785
- var $;
1786
- (function ($) {
1787
- class $mol_after_timeout extends $mol_object2 {
1788
- delay;
1789
- task;
1790
- id;
1791
- constructor(delay, task) {
1792
- super();
1793
- this.delay = delay;
1794
- this.task = task;
1795
- this.id = setTimeout(task, delay);
1796
- }
1797
- destructor() {
1798
- clearTimeout(this.id);
1799
- }
1800
- }
1801
- $.$mol_after_timeout = $mol_after_timeout;
1802
- })($ || ($ = {}));
1803
-
1804
- ;
1805
- "use strict";
1806
- var $;
1807
- (function ($) {
1808
- class $mol_after_frame extends $mol_after_timeout {
1809
- task;
1810
- constructor(task) {
1811
- super(16, task);
1812
- this.task = task;
1813
- }
1814
- }
1815
- $.$mol_after_frame = $mol_after_frame;
1816
- })($ || ($ = {}));
1817
-
1818
1506
  ;
1819
1507
  "use strict";
1820
1508
  var $;
@@ -2017,6 +1705,445 @@ var $;
2017
1705
  $.$mol_wire_task = $mol_wire_task;
2018
1706
  })($ || ($ = {}));
2019
1707
 
1708
+ ;
1709
+ "use strict";
1710
+ var $;
1711
+ (function ($) {
1712
+ function $mol_wire_sync(obj) {
1713
+ return new Proxy(obj, {
1714
+ get(obj, field) {
1715
+ const val = obj[field];
1716
+ if (typeof val !== 'function')
1717
+ return val;
1718
+ const temp = $mol_wire_task.getter(val);
1719
+ return function $mol_wire_sync(...args) {
1720
+ const fiber = temp(obj, args);
1721
+ return fiber.sync();
1722
+ };
1723
+ },
1724
+ apply(obj, self, args) {
1725
+ const temp = $mol_wire_task.getter(obj);
1726
+ const fiber = temp(self, args);
1727
+ return fiber.sync();
1728
+ },
1729
+ });
1730
+ }
1731
+ $.$mol_wire_sync = $mol_wire_sync;
1732
+ })($ || ($ = {}));
1733
+
1734
+ ;
1735
+ "use strict";
1736
+ var $;
1737
+ (function ($) {
1738
+ class $mol_run_error extends $mol_error_mix {
1739
+ }
1740
+ $.$mol_run_error = $mol_run_error;
1741
+ const child_process = $node['child_process'];
1742
+ $.$mol_run_spawn = child_process.spawn.bind(child_process);
1743
+ function $mol_run_async({ dir, timeout, command, env }) {
1744
+ const args_raw = typeof command === 'string' ? command.split(' ') : command;
1745
+ const [app, ...args] = args_raw;
1746
+ const sub = this.$mol_run_spawn(app, args, {
1747
+ shell: true,
1748
+ cwd: dir,
1749
+ env
1750
+ });
1751
+ this.$mol_log3_come({
1752
+ place: '$mol_run_async',
1753
+ pid: sub.pid,
1754
+ message: 'Run',
1755
+ command: args_raw.join(' '),
1756
+ dir: $node.path.relative('', dir),
1757
+ });
1758
+ let killed = false;
1759
+ let timer;
1760
+ const std_data = [];
1761
+ const error_data = [];
1762
+ const add = (std_chunk, error_chunk) => {
1763
+ if (std_chunk)
1764
+ std_data.push(std_chunk);
1765
+ if (error_chunk)
1766
+ error_data.push(error_chunk);
1767
+ if (!timeout)
1768
+ return;
1769
+ clearTimeout(timer);
1770
+ timer = setTimeout(() => {
1771
+ const signal = killed ? 'SIGKILL' : 'SIGTERM';
1772
+ killed = true;
1773
+ add();
1774
+ sub.kill(signal);
1775
+ }, timeout);
1776
+ };
1777
+ add();
1778
+ sub.stdout?.on('data', data => add(data));
1779
+ sub.stderr?.on('data', data => add(undefined, data));
1780
+ const promise = new Promise((done, fail) => {
1781
+ const close = (error, status = null, signal = null) => {
1782
+ if (!timer && timeout)
1783
+ return;
1784
+ clearTimeout(timer);
1785
+ timer = undefined;
1786
+ const res = {
1787
+ pid: sub.pid,
1788
+ status,
1789
+ signal,
1790
+ get stdout() { return Buffer.concat(std_data); },
1791
+ get stderr() { return Buffer.concat(error_data); }
1792
+ };
1793
+ this.$mol_log3_done({
1794
+ place: '$mol_run_async',
1795
+ pid: sub.pid,
1796
+ message: 'Run',
1797
+ status,
1798
+ command: args_raw.join(' '),
1799
+ dir: $node.path.relative('', dir),
1800
+ });
1801
+ if (error || status || killed)
1802
+ return fail(new $mol_run_error((res.stderr.toString() || res.stdout.toString() || 'Run error') + (killed ? ', timeout' : ''), { signal, timeout: killed }, ...error ? [error] : []));
1803
+ done(res);
1804
+ };
1805
+ sub.on('disconnect', () => close(new Error('Disconnected')));
1806
+ sub.on('error', err => close(err));
1807
+ sub.on('exit', (status, signal) => close(null, status, signal));
1808
+ });
1809
+ return Object.assign(promise, { destructor: () => {
1810
+ clearTimeout(timer);
1811
+ sub.kill('SIGKILL');
1812
+ } });
1813
+ }
1814
+ $.$mol_run_async = $mol_run_async;
1815
+ function $mol_run(options) {
1816
+ if (!options.env)
1817
+ options = { ...options, env: this.$mol_env() };
1818
+ return $mol_wire_sync(this).$mol_run_async(options);
1819
+ }
1820
+ $.$mol_run = $mol_run;
1821
+ })($ || ($ = {}));
1822
+
1823
+ ;
1824
+ "use strict";
1825
+ var $;
1826
+ (function ($) {
1827
+ function $mol_exec(dir, command, ...args) {
1828
+ return this.$mol_run({ command: [command, ...args], dir });
1829
+ }
1830
+ $.$mol_exec = $mol_exec;
1831
+ })($ || ($ = {}));
1832
+
1833
+ ;
1834
+ "use strict";
1835
+ var $;
1836
+ (function ($) {
1837
+ $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
1838
+ })($ || ($ = {}));
1839
+
1840
+ ;
1841
+ "use strict";
1842
+ var $;
1843
+ (function ($) {
1844
+ function $mol_dom_render_children(el, childNodes) {
1845
+ const node_set = new Set(childNodes);
1846
+ let nextNode = el.firstChild;
1847
+ for (let view of childNodes) {
1848
+ if (view == null)
1849
+ continue;
1850
+ if (view instanceof $mol_dom_context.Node) {
1851
+ while (true) {
1852
+ if (!nextNode) {
1853
+ el.appendChild(view);
1854
+ break;
1855
+ }
1856
+ if (nextNode == view) {
1857
+ nextNode = nextNode.nextSibling;
1858
+ break;
1859
+ }
1860
+ else {
1861
+ if (node_set.has(nextNode)) {
1862
+ el.insertBefore(view, nextNode);
1863
+ break;
1864
+ }
1865
+ else {
1866
+ const nn = nextNode.nextSibling;
1867
+ el.removeChild(nextNode);
1868
+ nextNode = nn;
1869
+ }
1870
+ }
1871
+ }
1872
+ }
1873
+ else {
1874
+ if (nextNode && nextNode.nodeName === '#text') {
1875
+ const str = String(view);
1876
+ if (nextNode.nodeValue !== str)
1877
+ nextNode.nodeValue = str;
1878
+ nextNode = nextNode.nextSibling;
1879
+ }
1880
+ else {
1881
+ const textNode = $mol_dom_context.document.createTextNode(String(view));
1882
+ el.insertBefore(textNode, nextNode);
1883
+ }
1884
+ }
1885
+ }
1886
+ while (nextNode) {
1887
+ const currNode = nextNode;
1888
+ nextNode = currNode.nextSibling;
1889
+ el.removeChild(currNode);
1890
+ }
1891
+ }
1892
+ $.$mol_dom_render_children = $mol_dom_render_children;
1893
+ })($ || ($ = {}));
1894
+
1895
+ ;
1896
+ "use strict";
1897
+
1898
+ ;
1899
+ "use strict";
1900
+ var $;
1901
+ (function ($) {
1902
+ $.$mol_jsx_prefix = '';
1903
+ $.$mol_jsx_crumbs = '';
1904
+ $.$mol_jsx_booked = null;
1905
+ $.$mol_jsx_document = {
1906
+ getElementById: () => null,
1907
+ createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
1908
+ createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
1909
+ };
1910
+ $.$mol_jsx_frag = '';
1911
+ function $mol_jsx(Elem, props, ...childNodes) {
1912
+ const id = props && props.id || '';
1913
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
1914
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
1915
+ if (Elem && $.$mol_jsx_booked) {
1916
+ if ($.$mol_jsx_booked.has(id)) {
1917
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
1918
+ }
1919
+ else {
1920
+ $.$mol_jsx_booked.add(id);
1921
+ }
1922
+ }
1923
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
1924
+ if ($.$mol_jsx_prefix) {
1925
+ const prefix_ext = $.$mol_jsx_prefix;
1926
+ const booked_ext = $.$mol_jsx_booked;
1927
+ const crumbs_ext = $.$mol_jsx_crumbs;
1928
+ for (const field in props) {
1929
+ const func = props[field];
1930
+ if (typeof func !== 'function')
1931
+ continue;
1932
+ const wrapper = function (...args) {
1933
+ const prefix = $.$mol_jsx_prefix;
1934
+ const booked = $.$mol_jsx_booked;
1935
+ const crumbs = $.$mol_jsx_crumbs;
1936
+ try {
1937
+ $.$mol_jsx_prefix = prefix_ext;
1938
+ $.$mol_jsx_booked = booked_ext;
1939
+ $.$mol_jsx_crumbs = crumbs_ext;
1940
+ return func.call(this, ...args);
1941
+ }
1942
+ finally {
1943
+ $.$mol_jsx_prefix = prefix;
1944
+ $.$mol_jsx_booked = booked;
1945
+ $.$mol_jsx_crumbs = crumbs;
1946
+ }
1947
+ };
1948
+ $mol_func_name_from(wrapper, func);
1949
+ props[field] = wrapper;
1950
+ }
1951
+ }
1952
+ if (typeof Elem !== 'string') {
1953
+ if ('prototype' in Elem) {
1954
+ const view = node && node[String(Elem)] || new Elem;
1955
+ Object.assign(view, props);
1956
+ view[Symbol.toStringTag] = guid;
1957
+ view.childNodes = childNodes;
1958
+ if (!view.ownerDocument)
1959
+ view.ownerDocument = $.$mol_jsx_document;
1960
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
1961
+ node = view.valueOf();
1962
+ node[String(Elem)] = view;
1963
+ return node;
1964
+ }
1965
+ else {
1966
+ const prefix = $.$mol_jsx_prefix;
1967
+ const booked = $.$mol_jsx_booked;
1968
+ const crumbs = $.$mol_jsx_crumbs;
1969
+ try {
1970
+ $.$mol_jsx_prefix = guid;
1971
+ $.$mol_jsx_booked = new Set;
1972
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
1973
+ return Elem(props, ...childNodes);
1974
+ }
1975
+ finally {
1976
+ $.$mol_jsx_prefix = prefix;
1977
+ $.$mol_jsx_booked = booked;
1978
+ $.$mol_jsx_crumbs = crumbs;
1979
+ }
1980
+ }
1981
+ }
1982
+ if (!node) {
1983
+ node = Elem
1984
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
1985
+ : $.$mol_jsx_document.createDocumentFragment();
1986
+ }
1987
+ $mol_dom_render_children(node, [].concat(...childNodes));
1988
+ if (!Elem)
1989
+ return node;
1990
+ if (guid)
1991
+ node.id = guid;
1992
+ for (const key in props) {
1993
+ if (key === 'id')
1994
+ continue;
1995
+ if (typeof props[key] === 'string') {
1996
+ if (typeof node[key] === 'string')
1997
+ node[key] = props[key];
1998
+ node.setAttribute(key, props[key]);
1999
+ }
2000
+ else if (props[key] &&
2001
+ typeof props[key] === 'object' &&
2002
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
2003
+ if (typeof node[key] === 'object') {
2004
+ Object.assign(node[key], props[key]);
2005
+ continue;
2006
+ }
2007
+ }
2008
+ else {
2009
+ node[key] = props[key];
2010
+ }
2011
+ }
2012
+ if ($.$mol_jsx_crumbs)
2013
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
2014
+ return node;
2015
+ }
2016
+ $.$mol_jsx = $mol_jsx;
2017
+ })($ || ($ = {}));
2018
+
2019
+ ;
2020
+ "use strict";
2021
+ var $;
2022
+ (function ($) {
2023
+ function $mol_jsx_attach(next, action) {
2024
+ const prev = $mol_jsx_document;
2025
+ try {
2026
+ $mol_jsx_document = next;
2027
+ return action();
2028
+ }
2029
+ finally {
2030
+ $mol_jsx_document = prev;
2031
+ }
2032
+ }
2033
+ $.$mol_jsx_attach = $mol_jsx_attach;
2034
+ })($ || ($ = {}));
2035
+
2036
+ ;
2037
+ "use strict";
2038
+ var $;
2039
+ (function ($) {
2040
+ function $mol_const(value) {
2041
+ const getter = (() => value);
2042
+ getter['()'] = value;
2043
+ getter[Symbol.toStringTag] = value;
2044
+ getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
2045
+ return getter;
2046
+ }
2047
+ $.$mol_const = $mol_const;
2048
+ })($ || ($ = {}));
2049
+
2050
+ ;
2051
+ "use strict";
2052
+ var $;
2053
+ (function ($) {
2054
+ function $mol_guid(length = 8, exists = () => false) {
2055
+ for (;;) {
2056
+ let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
2057
+ if (exists(id))
2058
+ continue;
2059
+ return id;
2060
+ }
2061
+ }
2062
+ $.$mol_guid = $mol_guid;
2063
+ })($ || ($ = {}));
2064
+
2065
+ ;
2066
+ "use strict";
2067
+ var $;
2068
+ (function ($) {
2069
+ $.$mol_key_store = new WeakMap();
2070
+ function $mol_key(value) {
2071
+ if (typeof value === 'bigint')
2072
+ return value.toString() + 'n';
2073
+ if (typeof value === 'symbol')
2074
+ return value.description;
2075
+ if (!value)
2076
+ return JSON.stringify(value);
2077
+ if (typeof value !== 'object' && typeof value !== 'function')
2078
+ return JSON.stringify(value);
2079
+ return JSON.stringify(value, (field, value) => {
2080
+ if (typeof value === 'bigint')
2081
+ return value.toString() + 'n';
2082
+ if (typeof value === 'symbol')
2083
+ return value.description;
2084
+ if (!value)
2085
+ return value;
2086
+ if (typeof value !== 'object' && typeof value !== 'function')
2087
+ return value;
2088
+ if (Array.isArray(value))
2089
+ return value;
2090
+ const proto = Reflect.getPrototypeOf(value);
2091
+ if (!proto)
2092
+ return value;
2093
+ if (Reflect.getPrototypeOf(proto) === null)
2094
+ return value;
2095
+ if ('toJSON' in value)
2096
+ return value;
2097
+ if (value instanceof RegExp)
2098
+ return value.toString();
2099
+ if (value instanceof Uint8Array)
2100
+ return [...value];
2101
+ let key = $.$mol_key_store.get(value);
2102
+ if (key)
2103
+ return key;
2104
+ key = $mol_guid();
2105
+ $.$mol_key_store.set(value, key);
2106
+ return key;
2107
+ });
2108
+ }
2109
+ $.$mol_key = $mol_key;
2110
+ })($ || ($ = {}));
2111
+
2112
+ ;
2113
+ "use strict";
2114
+ var $;
2115
+ (function ($) {
2116
+ class $mol_after_timeout extends $mol_object2 {
2117
+ delay;
2118
+ task;
2119
+ id;
2120
+ constructor(delay, task) {
2121
+ super();
2122
+ this.delay = delay;
2123
+ this.task = task;
2124
+ this.id = setTimeout(task, delay);
2125
+ }
2126
+ destructor() {
2127
+ clearTimeout(this.id);
2128
+ }
2129
+ }
2130
+ $.$mol_after_timeout = $mol_after_timeout;
2131
+ })($ || ($ = {}));
2132
+
2133
+ ;
2134
+ "use strict";
2135
+ var $;
2136
+ (function ($) {
2137
+ class $mol_after_frame extends $mol_after_timeout {
2138
+ task;
2139
+ constructor(task) {
2140
+ super(16, task);
2141
+ this.task = task;
2142
+ }
2143
+ }
2144
+ $.$mol_after_frame = $mol_after_frame;
2145
+ })($ || ($ = {}));
2146
+
2020
2147
  ;
2021
2148
  "use strict";
2022
2149
  var $;
@@ -2393,32 +2520,6 @@ var $;
2393
2520
  $.$mol_wire_watch = $mol_wire_watch;
2394
2521
  })($ || ($ = {}));
2395
2522
 
2396
- ;
2397
- "use strict";
2398
- var $;
2399
- (function ($) {
2400
- function $mol_wire_sync(obj) {
2401
- return new Proxy(obj, {
2402
- get(obj, field) {
2403
- const val = obj[field];
2404
- if (typeof val !== 'function')
2405
- return val;
2406
- const temp = $mol_wire_task.getter(val);
2407
- return function $mol_wire_sync(...args) {
2408
- const fiber = temp(obj, args);
2409
- return fiber.sync();
2410
- };
2411
- },
2412
- apply(obj, self, args) {
2413
- const temp = $mol_wire_task.getter(obj);
2414
- const fiber = temp(self, args);
2415
- return fiber.sync();
2416
- },
2417
- });
2418
- }
2419
- $.$mol_wire_sync = $mol_wire_sync;
2420
- })($ || ($ = {}));
2421
-
2422
2523
  ;
2423
2524
  "use strict";
2424
2525
  var $;