mol_jsx_lib 0.0.1048 → 0.0.1050

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.js CHANGED
@@ -128,7 +128,11 @@ var $node = new Proxy({ require }, {
128
128
  try {
129
129
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
130
130
  }
131
- catch { }
131
+ catch (e) {
132
+ if ($$.$mol_fail_catch(e)) {
133
+ $$.$mol_fail_log(e);
134
+ }
135
+ }
132
136
  break;
133
137
  }
134
138
  else {
@@ -139,7 +143,7 @@ var $node = new Proxy({ require }, {
139
143
  return target.require(name);
140
144
  }
141
145
  catch (error) {
142
- if (error.code === 'ERR_REQUIRE_ESM') {
146
+ if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
143
147
  const module = cache.get(name);
144
148
  if (module)
145
149
  return module;
@@ -159,6 +163,68 @@ require = (req => Object.assign(function require(name) {
159
163
  return $node[name];
160
164
  }, req))(require);
161
165
 
166
+ ;
167
+ "use strict";
168
+ var $;
169
+ (function ($) {
170
+ const named = new WeakSet();
171
+ function $mol_func_name(func) {
172
+ let name = func.name;
173
+ if (name?.length > 1)
174
+ return name;
175
+ if (named.has(func))
176
+ return name;
177
+ for (let key in this) {
178
+ try {
179
+ if (this[key] !== func)
180
+ continue;
181
+ name = key;
182
+ Object.defineProperty(func, 'name', { value: name });
183
+ break;
184
+ }
185
+ catch { }
186
+ }
187
+ named.add(func);
188
+ return name;
189
+ }
190
+ $.$mol_func_name = $mol_func_name;
191
+ function $mol_func_name_from(target, source) {
192
+ Object.defineProperty(target, 'name', { value: source.name });
193
+ return target;
194
+ }
195
+ $.$mol_func_name_from = $mol_func_name_from;
196
+ })($ || ($ = {}));
197
+
198
+ ;
199
+ "use strict";
200
+ var $;
201
+ (function ($) {
202
+ class $mol_error_mix extends AggregateError {
203
+ cause;
204
+ name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
205
+ constructor(message, cause = {}, ...errors) {
206
+ super(errors, message, { cause });
207
+ this.cause = cause;
208
+ const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
209
+ Object.defineProperty(this, 'stack', {
210
+ 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()
211
+ .replace(/at /gm, ' at ')
212
+ .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
213
+ });
214
+ }
215
+ static [Symbol.toPrimitive]() {
216
+ return this.toString();
217
+ }
218
+ static toString() {
219
+ return $$.$mol_func_name(this);
220
+ }
221
+ static make(...params) {
222
+ return new this(...params);
223
+ }
224
+ }
225
+ $.$mol_error_mix = $mol_error_mix;
226
+ })($ || ($ = {}));
227
+
162
228
  ;
163
229
  "use strict";
164
230
  var $;
@@ -290,38 +356,6 @@ var $;
290
356
  ;
291
357
  "use strict";
292
358
 
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
359
  ;
326
360
  "use strict";
327
361
  var $;
@@ -881,90 +915,80 @@ var $;
881
915
  "use strict";
882
916
  var $;
883
917
  (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;
918
+ let $mol_wire_cursor;
919
+ (function ($mol_wire_cursor) {
920
+ $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
921
+ $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
922
+ $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
923
+ $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
924
+ })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
913
925
  })($ || ($ = {}));
914
926
 
915
927
  ;
916
928
  "use strict";
917
929
  var $;
918
930
  (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
- }
931
+ class $mol_wire_pub extends Object {
932
+ data = [];
933
+ static get [Symbol.species]() {
934
+ return Array;
935
+ }
936
+ sub_from = 0;
937
+ get sub_list() {
938
+ const res = [];
939
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
940
+ res.push(this.data[i]);
947
941
  }
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
- }
942
+ return res;
943
+ }
944
+ get sub_empty() {
945
+ return this.sub_from === this.data.length;
946
+ }
947
+ sub_on(sub, pub_pos) {
948
+ const pos = this.data.length;
949
+ this.data.push(sub, pub_pos);
950
+ return pos;
951
+ }
952
+ sub_off(sub_pos) {
953
+ if (!(sub_pos < this.data.length)) {
954
+ $mol_fail(new Error(`Wrong pos ${sub_pos}`));
955
+ }
956
+ const end = this.data.length - 2;
957
+ if (sub_pos !== end) {
958
+ this.peer_move(end, sub_pos);
959
959
  }
960
+ this.data.pop();
961
+ this.data.pop();
962
+ if (this.data.length === this.sub_from)
963
+ this.reap();
960
964
  }
961
- while (nextNode) {
962
- const currNode = nextNode;
963
- nextNode = currNode.nextSibling;
964
- el.removeChild(currNode);
965
+ reap() { }
966
+ promote() {
967
+ $mol_wire_auto()?.track_next(this);
968
+ }
969
+ fresh() { }
970
+ complete() { }
971
+ get incompleted() {
972
+ return false;
973
+ }
974
+ emit(quant = $mol_wire_cursor.stale) {
975
+ for (let i = this.sub_from; i < this.data.length; i += 2) {
976
+ ;
977
+ this.data[i].absorb(quant);
978
+ }
979
+ }
980
+ peer_move(from_pos, to_pos) {
981
+ const peer = this.data[from_pos];
982
+ const self_pos = this.data[from_pos + 1];
983
+ this.data[to_pos] = peer;
984
+ this.data[to_pos + 1] = self_pos;
985
+ peer.peer_repos(self_pos, to_pos);
986
+ }
987
+ peer_repos(peer_pos, self_pos) {
988
+ this.data[peer_pos + 1] = self_pos;
965
989
  }
966
990
  }
967
- $.$mol_dom_render_children = $mol_dom_render_children;
991
+ $.$mol_wire_pub = $mol_wire_pub;
968
992
  })($ || ($ = {}));
969
993
 
970
994
  ;
@@ -974,259 +998,38 @@ var $;
974
998
  "use strict";
975
999
  var $;
976
1000
  (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)}`));
993
- }
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
- }
1001
+ $.$mol_wire_auto_sub = null;
1002
+ function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
1003
+ return $.$mol_wire_auto_sub = next;
1004
+ }
1005
+ $.$mol_wire_auto = $mol_wire_auto;
1006
+ $.$mol_wire_affected = [];
1007
+ })($ || ($ = {}));
1008
+
1009
+ ;
1010
+ "use strict";
1011
+ var $;
1012
+ (function ($) {
1013
+ $['devtoolsFormatters'] ||= [];
1014
+ function $mol_dev_format_register(config) {
1015
+ $['devtoolsFormatters'].push(config);
1016
+ }
1017
+ $.$mol_dev_format_register = $mol_dev_format_register;
1018
+ $.$mol_dev_format_head = Symbol('$mol_dev_format_head');
1019
+ $.$mol_dev_format_body = Symbol('$mol_dev_format_body');
1020
+ $mol_dev_format_register({
1021
+ header: (val, config = false) => {
1022
+ if (config)
1023
+ return null;
1024
+ if (!val)
1025
+ return null;
1026
+ if ($.$mol_dev_format_head in val) {
1027
+ try {
1028
+ return val[$.$mol_dev_format_head]();
1029
+ }
1030
+ catch (error) {
1031
+ return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
1032
+ }
1230
1033
  }
1231
1034
  if (typeof val === 'function') {
1232
1035
  return $mol_dev_format_native(val);
@@ -1305,20 +1108,6 @@ var $;
1305
1108
  });
1306
1109
  })($ || ($ = {}));
1307
1110
 
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
1111
  ;
1323
1112
  "use strict";
1324
1113
  var $;
@@ -1718,103 +1507,6 @@ var $;
1718
1507
  $.$mol_wire_fiber = $mol_wire_fiber;
1719
1508
  })($ || ($ = {}));
1720
1509
 
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
1510
  ;
1819
1511
  "use strict";
1820
1512
  var $;
@@ -2017,6 +1709,467 @@ var $;
2017
1709
  $.$mol_wire_task = $mol_wire_task;
2018
1710
  })($ || ($ = {}));
2019
1711
 
1712
+ ;
1713
+ "use strict";
1714
+ var $;
1715
+ (function ($) {
1716
+ const factories = new WeakMap();
1717
+ function factory(val) {
1718
+ let make = factories.get(val);
1719
+ if (make)
1720
+ return make;
1721
+ make = $mol_func_name_from((...args) => new val(...args), val);
1722
+ factories.set(val, make);
1723
+ return make;
1724
+ }
1725
+ function $mol_wire_sync(obj) {
1726
+ return new Proxy(obj, {
1727
+ get(obj, field) {
1728
+ let val = obj[field];
1729
+ if (typeof val !== 'function')
1730
+ return val;
1731
+ const temp = $mol_wire_task.getter(val);
1732
+ return function $mol_wire_sync(...args) {
1733
+ const fiber = temp(obj, args);
1734
+ return fiber.sync();
1735
+ };
1736
+ },
1737
+ construct(obj, args) {
1738
+ const temp = $mol_wire_task.getter(factory(obj));
1739
+ return temp(obj, args).sync();
1740
+ },
1741
+ apply(obj, self, args) {
1742
+ const temp = $mol_wire_task.getter(obj);
1743
+ return temp(self, args).sync();
1744
+ },
1745
+ });
1746
+ }
1747
+ $.$mol_wire_sync = $mol_wire_sync;
1748
+ })($ || ($ = {}));
1749
+
1750
+ ;
1751
+ "use strict";
1752
+ var $;
1753
+ (function ($) {
1754
+ class $mol_run_error extends $mol_error_mix {
1755
+ }
1756
+ $.$mol_run_error = $mol_run_error;
1757
+ const child_process = $node['child_process'];
1758
+ $.$mol_run_spawn = child_process.spawn.bind(child_process);
1759
+ $.$mol_run_spawn_sync = child_process.spawnSync.bind(child_process);
1760
+ function $mol_run_async({ dir, timeout, command, env }) {
1761
+ const args_raw = typeof command === 'string' ? command.split(' ') : command;
1762
+ const [app, ...args] = args_raw;
1763
+ if (!env?.MOL_RUN_ASYNC) {
1764
+ this.$mol_log3_come({
1765
+ place: '$mol_run_sync',
1766
+ message: 'Run',
1767
+ command: args_raw.join(' '),
1768
+ dir: $node.path.relative('', dir),
1769
+ });
1770
+ return this.$mol_run_spawn_sync(app, args, { shell: true, cwd: dir, env });
1771
+ }
1772
+ const sub = this.$mol_run_spawn(app, args, {
1773
+ shell: true,
1774
+ cwd: dir,
1775
+ env
1776
+ });
1777
+ this.$mol_log3_come({
1778
+ place: '$mol_run_async',
1779
+ pid: sub.pid,
1780
+ message: 'Run',
1781
+ command: args_raw.join(' '),
1782
+ dir: $node.path.relative('', dir),
1783
+ });
1784
+ let killed = false;
1785
+ let timer;
1786
+ const std_data = [];
1787
+ const error_data = [];
1788
+ const add = (std_chunk, error_chunk) => {
1789
+ if (std_chunk)
1790
+ std_data.push(std_chunk);
1791
+ if (error_chunk)
1792
+ error_data.push(error_chunk);
1793
+ if (!timeout)
1794
+ return;
1795
+ clearTimeout(timer);
1796
+ timer = setTimeout(() => {
1797
+ const signal = killed ? 'SIGKILL' : 'SIGTERM';
1798
+ killed = true;
1799
+ add();
1800
+ sub.kill(signal);
1801
+ }, timeout);
1802
+ };
1803
+ add();
1804
+ sub.stdout?.on('data', data => add(data));
1805
+ sub.stderr?.on('data', data => add(undefined, data));
1806
+ const promise = new Promise((done, fail) => {
1807
+ const close = (error, status = null, signal = null) => {
1808
+ if (!timer && timeout)
1809
+ return;
1810
+ clearTimeout(timer);
1811
+ timer = undefined;
1812
+ const res = {
1813
+ pid: sub.pid,
1814
+ status,
1815
+ signal,
1816
+ get stdout() { return Buffer.concat(std_data); },
1817
+ get stderr() { return Buffer.concat(error_data); }
1818
+ };
1819
+ this.$mol_log3_done({
1820
+ place: '$mol_run_async',
1821
+ pid: sub.pid,
1822
+ message: 'Run',
1823
+ status,
1824
+ command: args_raw.join(' '),
1825
+ dir: $node.path.relative('', dir),
1826
+ });
1827
+ if (error || status || killed)
1828
+ return fail(new $mol_run_error((res.stderr.toString() || res.stdout.toString() || 'Run error') + (killed ? ', timeout' : ''), { signal, timeout: killed }, ...error ? [error] : []));
1829
+ done(res);
1830
+ };
1831
+ sub.on('disconnect', () => close(new Error('Disconnected')));
1832
+ sub.on('error', err => close(err));
1833
+ sub.on('exit', (status, signal) => close(null, status, signal));
1834
+ });
1835
+ return Object.assign(promise, { destructor: () => {
1836
+ clearTimeout(timer);
1837
+ sub.kill('SIGKILL');
1838
+ } });
1839
+ }
1840
+ $.$mol_run_async = $mol_run_async;
1841
+ function $mol_run(options) {
1842
+ if (!options.env)
1843
+ options = { ...options, env: this.$mol_env() };
1844
+ return $mol_wire_sync(this).$mol_run_async(options);
1845
+ }
1846
+ $.$mol_run = $mol_run;
1847
+ })($ || ($ = {}));
1848
+
1849
+ ;
1850
+ "use strict";
1851
+ var $;
1852
+ (function ($) {
1853
+ function $mol_exec(dir, command, ...args) {
1854
+ return this.$mol_run({ command: [command, ...args], dir });
1855
+ }
1856
+ $.$mol_exec = $mol_exec;
1857
+ })($ || ($ = {}));
1858
+
1859
+ ;
1860
+ "use strict";
1861
+ var $;
1862
+ (function ($) {
1863
+ $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
1864
+ })($ || ($ = {}));
1865
+
1866
+ ;
1867
+ "use strict";
1868
+ var $;
1869
+ (function ($) {
1870
+ function $mol_dom_render_children(el, childNodes) {
1871
+ const node_set = new Set(childNodes);
1872
+ let nextNode = el.firstChild;
1873
+ for (let view of childNodes) {
1874
+ if (view == null)
1875
+ continue;
1876
+ if (view instanceof $mol_dom_context.Node) {
1877
+ while (true) {
1878
+ if (!nextNode) {
1879
+ el.appendChild(view);
1880
+ break;
1881
+ }
1882
+ if (nextNode == view) {
1883
+ nextNode = nextNode.nextSibling;
1884
+ break;
1885
+ }
1886
+ else {
1887
+ if (node_set.has(nextNode)) {
1888
+ el.insertBefore(view, nextNode);
1889
+ break;
1890
+ }
1891
+ else {
1892
+ const nn = nextNode.nextSibling;
1893
+ el.removeChild(nextNode);
1894
+ nextNode = nn;
1895
+ }
1896
+ }
1897
+ }
1898
+ }
1899
+ else {
1900
+ if (nextNode && nextNode.nodeName === '#text') {
1901
+ const str = String(view);
1902
+ if (nextNode.nodeValue !== str)
1903
+ nextNode.nodeValue = str;
1904
+ nextNode = nextNode.nextSibling;
1905
+ }
1906
+ else {
1907
+ const textNode = $mol_dom_context.document.createTextNode(String(view));
1908
+ el.insertBefore(textNode, nextNode);
1909
+ }
1910
+ }
1911
+ }
1912
+ while (nextNode) {
1913
+ const currNode = nextNode;
1914
+ nextNode = currNode.nextSibling;
1915
+ el.removeChild(currNode);
1916
+ }
1917
+ }
1918
+ $.$mol_dom_render_children = $mol_dom_render_children;
1919
+ })($ || ($ = {}));
1920
+
1921
+ ;
1922
+ "use strict";
1923
+
1924
+ ;
1925
+ "use strict";
1926
+ var $;
1927
+ (function ($) {
1928
+ $.$mol_jsx_prefix = '';
1929
+ $.$mol_jsx_crumbs = '';
1930
+ $.$mol_jsx_booked = null;
1931
+ $.$mol_jsx_document = {
1932
+ getElementById: () => null,
1933
+ createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
1934
+ createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
1935
+ };
1936
+ $.$mol_jsx_frag = '';
1937
+ function $mol_jsx(Elem, props, ...childNodes) {
1938
+ const id = props && props.id || '';
1939
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
1940
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
1941
+ if (Elem && $.$mol_jsx_booked) {
1942
+ if ($.$mol_jsx_booked.has(id)) {
1943
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
1944
+ }
1945
+ else {
1946
+ $.$mol_jsx_booked.add(id);
1947
+ }
1948
+ }
1949
+ let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
1950
+ if ($.$mol_jsx_prefix) {
1951
+ const prefix_ext = $.$mol_jsx_prefix;
1952
+ const booked_ext = $.$mol_jsx_booked;
1953
+ const crumbs_ext = $.$mol_jsx_crumbs;
1954
+ for (const field in props) {
1955
+ const func = props[field];
1956
+ if (typeof func !== 'function')
1957
+ continue;
1958
+ const wrapper = function (...args) {
1959
+ const prefix = $.$mol_jsx_prefix;
1960
+ const booked = $.$mol_jsx_booked;
1961
+ const crumbs = $.$mol_jsx_crumbs;
1962
+ try {
1963
+ $.$mol_jsx_prefix = prefix_ext;
1964
+ $.$mol_jsx_booked = booked_ext;
1965
+ $.$mol_jsx_crumbs = crumbs_ext;
1966
+ return func.call(this, ...args);
1967
+ }
1968
+ finally {
1969
+ $.$mol_jsx_prefix = prefix;
1970
+ $.$mol_jsx_booked = booked;
1971
+ $.$mol_jsx_crumbs = crumbs;
1972
+ }
1973
+ };
1974
+ $mol_func_name_from(wrapper, func);
1975
+ props[field] = wrapper;
1976
+ }
1977
+ }
1978
+ if (typeof Elem !== 'string') {
1979
+ if ('prototype' in Elem) {
1980
+ const view = node && node[String(Elem)] || new Elem;
1981
+ Object.assign(view, props);
1982
+ view[Symbol.toStringTag] = guid;
1983
+ view.childNodes = childNodes;
1984
+ if (!view.ownerDocument)
1985
+ view.ownerDocument = $.$mol_jsx_document;
1986
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
1987
+ node = view.valueOf();
1988
+ node[String(Elem)] = view;
1989
+ return node;
1990
+ }
1991
+ else {
1992
+ const prefix = $.$mol_jsx_prefix;
1993
+ const booked = $.$mol_jsx_booked;
1994
+ const crumbs = $.$mol_jsx_crumbs;
1995
+ try {
1996
+ $.$mol_jsx_prefix = guid;
1997
+ $.$mol_jsx_booked = new Set;
1998
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
1999
+ return Elem(props, ...childNodes);
2000
+ }
2001
+ finally {
2002
+ $.$mol_jsx_prefix = prefix;
2003
+ $.$mol_jsx_booked = booked;
2004
+ $.$mol_jsx_crumbs = crumbs;
2005
+ }
2006
+ }
2007
+ }
2008
+ if (!node) {
2009
+ node = Elem
2010
+ ? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
2011
+ : $.$mol_jsx_document.createDocumentFragment();
2012
+ }
2013
+ $mol_dom_render_children(node, [].concat(...childNodes));
2014
+ if (!Elem)
2015
+ return node;
2016
+ if (guid)
2017
+ node.id = guid;
2018
+ for (const key in props) {
2019
+ if (key === 'id')
2020
+ continue;
2021
+ if (typeof props[key] === 'string') {
2022
+ if (typeof node[key] === 'string')
2023
+ node[key] = props[key];
2024
+ node.setAttribute(key, props[key]);
2025
+ }
2026
+ else if (props[key] &&
2027
+ typeof props[key] === 'object' &&
2028
+ Reflect.getPrototypeOf(props[key]) === Reflect.getPrototypeOf({})) {
2029
+ if (typeof node[key] === 'object') {
2030
+ Object.assign(node[key], props[key]);
2031
+ continue;
2032
+ }
2033
+ }
2034
+ else {
2035
+ node[key] = props[key];
2036
+ }
2037
+ }
2038
+ if ($.$mol_jsx_crumbs)
2039
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
2040
+ return node;
2041
+ }
2042
+ $.$mol_jsx = $mol_jsx;
2043
+ })($ || ($ = {}));
2044
+
2045
+ ;
2046
+ "use strict";
2047
+ var $;
2048
+ (function ($) {
2049
+ function $mol_jsx_attach(next, action) {
2050
+ const prev = $mol_jsx_document;
2051
+ try {
2052
+ $mol_jsx_document = next;
2053
+ return action();
2054
+ }
2055
+ finally {
2056
+ $mol_jsx_document = prev;
2057
+ }
2058
+ }
2059
+ $.$mol_jsx_attach = $mol_jsx_attach;
2060
+ })($ || ($ = {}));
2061
+
2062
+ ;
2063
+ "use strict";
2064
+ var $;
2065
+ (function ($) {
2066
+ function $mol_const(value) {
2067
+ const getter = (() => value);
2068
+ getter['()'] = value;
2069
+ getter[Symbol.toStringTag] = value;
2070
+ getter[$mol_dev_format_head] = () => $mol_dev_format_span({}, '()=> ', $mol_dev_format_auto(value));
2071
+ return getter;
2072
+ }
2073
+ $.$mol_const = $mol_const;
2074
+ })($ || ($ = {}));
2075
+
2076
+ ;
2077
+ "use strict";
2078
+ var $;
2079
+ (function ($) {
2080
+ function $mol_guid(length = 8, exists = () => false) {
2081
+ for (;;) {
2082
+ let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
2083
+ if (exists(id))
2084
+ continue;
2085
+ return id;
2086
+ }
2087
+ }
2088
+ $.$mol_guid = $mol_guid;
2089
+ })($ || ($ = {}));
2090
+
2091
+ ;
2092
+ "use strict";
2093
+ var $;
2094
+ (function ($) {
2095
+ $.$mol_key_store = new WeakMap();
2096
+ function $mol_key(value) {
2097
+ if (typeof value === 'bigint')
2098
+ return value.toString() + 'n';
2099
+ if (typeof value === 'symbol')
2100
+ return value.description;
2101
+ if (!value)
2102
+ return JSON.stringify(value);
2103
+ if (typeof value !== 'object' && typeof value !== 'function')
2104
+ return JSON.stringify(value);
2105
+ return JSON.stringify(value, (field, value) => {
2106
+ if (typeof value === 'bigint')
2107
+ return value.toString() + 'n';
2108
+ if (typeof value === 'symbol')
2109
+ return value.description;
2110
+ if (!value)
2111
+ return value;
2112
+ if (typeof value !== 'object' && typeof value !== 'function')
2113
+ return value;
2114
+ if (Array.isArray(value))
2115
+ return value;
2116
+ const proto = Reflect.getPrototypeOf(value);
2117
+ if (!proto)
2118
+ return value;
2119
+ if (Reflect.getPrototypeOf(proto) === null)
2120
+ return value;
2121
+ if ('toJSON' in value)
2122
+ return value;
2123
+ if (value instanceof RegExp)
2124
+ return value.toString();
2125
+ if (value instanceof Uint8Array)
2126
+ return [...value];
2127
+ let key = $.$mol_key_store.get(value);
2128
+ if (key)
2129
+ return key;
2130
+ key = $mol_guid();
2131
+ $.$mol_key_store.set(value, key);
2132
+ return key;
2133
+ });
2134
+ }
2135
+ $.$mol_key = $mol_key;
2136
+ })($ || ($ = {}));
2137
+
2138
+ ;
2139
+ "use strict";
2140
+ var $;
2141
+ (function ($) {
2142
+ class $mol_after_timeout extends $mol_object2 {
2143
+ delay;
2144
+ task;
2145
+ id;
2146
+ constructor(delay, task) {
2147
+ super();
2148
+ this.delay = delay;
2149
+ this.task = task;
2150
+ this.id = setTimeout(task, delay);
2151
+ }
2152
+ destructor() {
2153
+ clearTimeout(this.id);
2154
+ }
2155
+ }
2156
+ $.$mol_after_timeout = $mol_after_timeout;
2157
+ })($ || ($ = {}));
2158
+
2159
+ ;
2160
+ "use strict";
2161
+ var $;
2162
+ (function ($) {
2163
+ class $mol_after_frame extends $mol_after_timeout {
2164
+ task;
2165
+ constructor(task) {
2166
+ super(16, task);
2167
+ this.task = task;
2168
+ }
2169
+ }
2170
+ $.$mol_after_frame = $mol_after_frame;
2171
+ })($ || ($ = {}));
2172
+
2020
2173
  ;
2021
2174
  "use strict";
2022
2175
  var $;
@@ -2393,32 +2546,6 @@ var $;
2393
2546
  $.$mol_wire_watch = $mol_wire_watch;
2394
2547
  })($ || ($ = {}));
2395
2548
 
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
2549
  ;
2423
2550
  "use strict";
2424
2551
  var $;