mol_jsx_lib 0.0.1667 → 0.0.1669

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/web.mjs CHANGED
@@ -503,12 +503,10 @@ var $;
503
503
  $mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
504
504
  /** Some of (transitive) pub update required. */
505
505
  $mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
506
- /** Doubt check in progress, so any incoming quant is noticeable. */
507
- $mol_wire_cursor[$mol_wire_cursor["check"] = -3] = "check";
508
506
  /** Actual state but may be dropped. */
509
- $mol_wire_cursor[$mol_wire_cursor["fresh"] = -4] = "fresh";
507
+ $mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
510
508
  /** State will never be changed. */
511
- $mol_wire_cursor[$mol_wire_cursor["final"] = -5] = "final";
509
+ $mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
512
510
  })($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
513
511
  })($ || ($ = {}));
514
512
 
@@ -587,12 +585,6 @@ var $;
587
585
  * Enforce actualization. Should not throw errors.
588
586
  */
589
587
  fresh() { }
590
- /**
591
- * Lives inside single calculation of subscriber or not.
592
- */
593
- get temp() {
594
- return false;
595
- }
596
588
  /**
597
589
  * Allow to put data to caches in the subtree.
598
590
  */
@@ -898,6 +890,9 @@ var $;
898
890
  class $mol_wire_pub_sub extends $mol_wire_pub {
899
891
  pub_from = 0; // 4B
900
892
  cursor = $mol_wire_cursor.stale; // 4B
893
+ get temp() {
894
+ return false;
895
+ }
901
896
  get pub_list() {
902
897
  const res = [];
903
898
  const max = this.cursor >= 0 ? this.cursor : this.sub_from;
@@ -917,9 +912,6 @@ var $;
917
912
  if (this.cursor >= this.pub_from) {
918
913
  $mol_fail(new Error('Circular subscription'));
919
914
  }
920
- if (this.cursor === $mol_wire_cursor.check) {
921
- $mol_fail(new Error('Circular checking'));
922
- }
923
915
  super.promote();
924
916
  }
925
917
  track_next(pub) {
@@ -961,8 +953,7 @@ var $;
961
953
  }
962
954
  for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
963
955
  const pub = this.data[cursor];
964
- // Slot may be cleared by pub_off when a temp was destroyed mid-calc.
965
- pub?.fresh();
956
+ pub.fresh();
966
957
  }
967
958
  this.cursor = $mol_wire_cursor.fresh;
968
959
  }
@@ -971,10 +962,6 @@ var $;
971
962
  this.data[sub_pos + 1] = undefined;
972
963
  }
973
964
  destructor() {
974
- // Mid-calc destroy (absorb restarts a temp): stop promoting into this
975
- // fiber so track_next does not throw 'Promo to non begun sub'.
976
- if ($mol_wire_auto() === this)
977
- $mol_wire_auto(null);
978
965
  for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
979
966
  const sub = this.data[cursor];
980
967
  const pos = this.data[cursor + 1];
@@ -1020,21 +1007,20 @@ var $;
1020
1007
  return;
1021
1008
  this.cursor = quant;
1022
1009
  this.emit($mol_wire_cursor.doubt);
1023
- if (quant !== $mol_wire_cursor.stale)
1024
- return;
1025
- if (!this.incompleted)
1026
- return;
1027
- // Notice from own task resumes the same calculation, but from a regular
1028
- // pub it makes awaited tasks based on outdated data, so restart them.
1029
- const pub = this.data[pos];
1030
- if (pub?.temp)
1031
- return;
1032
- for (let cursor = this.pub_from; cursor < this.sub_from; cursor += 2) {
1033
- const pub = this.data[cursor];
1034
- if (pub?.temp) {
1035
- pub.destructor();
1036
- }
1037
- }
1010
+ // if( pos >= 0 && pos < this.sub_from - 2 ) {
1011
+ // const pub = this.data[ pos ] as $mol_wire_pub
1012
+ // if( pub instanceof $mol_wire_task ) return
1013
+ // for(
1014
+ // let cursor = this.pub_from;
1015
+ // cursor < this.sub_from;
1016
+ // cursor += 2
1017
+ // ) {
1018
+ // const pub = this.data[ cursor ] as $mol_wire_pub
1019
+ // if( pub instanceof $mol_wire_task ) {
1020
+ // pub.destructor()
1021
+ // }
1022
+ // }
1023
+ // }
1038
1024
  }
1039
1025
  [$mol_dev_format_head]() {
1040
1026
  return $mol_dev_format_native(this);
@@ -1189,8 +1175,7 @@ var $;
1189
1175
  [$mol_dev_format_head]() {
1190
1176
  const cursor = {
1191
1177
  [$mol_wire_cursor.stale]: '🔴',
1192
- [$mol_wire_cursor.doubt]: '🟠',
1193
- [$mol_wire_cursor.check]: '🟡',
1178
+ [$mol_wire_cursor.doubt]: '🟡',
1194
1179
  [$mol_wire_cursor.fresh]: '🟢',
1195
1180
  [$mol_wire_cursor.final]: '🔵',
1196
1181
  }[this.cursor] ?? this.cursor.toString();
@@ -1214,11 +1199,10 @@ var $;
1214
1199
  if (this.cursor === $mol_wire_cursor.final)
1215
1200
  return;
1216
1201
  check: if (this.cursor === $mol_wire_cursor.doubt) {
1217
- this.cursor = $mol_wire_cursor.check;
1218
1202
  for (let i = this.pub_from; i < this.sub_from; i += 2) {
1219
1203
  ;
1220
1204
  this.data[i]?.fresh();
1221
- if (this.cursor !== $mol_wire_cursor.check)
1205
+ if (this.cursor !== $mol_wire_cursor.doubt)
1222
1206
  break check;
1223
1207
  }
1224
1208
  this.cursor = $mol_wire_cursor.fresh;
@@ -1227,74 +1211,62 @@ var $;
1227
1211
  const bu = this.track_on();
1228
1212
  let result;
1229
1213
  try {
1230
- try {
1231
- switch (this.pub_from) {
1232
- case 0:
1233
- result = this.task.call(this.host);
1234
- break;
1235
- case 1:
1236
- result = this.task.call(this.host, this.data[0]);
1237
- break;
1238
- default:
1239
- result = this.task.call(this.host, ...this.args);
1240
- break;
1214
+ switch (this.pub_from) {
1215
+ case 0:
1216
+ result = this.task.call(this.host);
1217
+ break;
1218
+ case 1:
1219
+ result = this.task.call(this.host, this.data[0]);
1220
+ break;
1221
+ default:
1222
+ result = this.task.call(this.host, ...this.args);
1223
+ break;
1224
+ }
1225
+ if ($mol_promise_like(result)) {
1226
+ if (wrappers.has(result)) {
1227
+ result = wrappers.get(result).then(a => a);
1241
1228
  }
1242
- if ($mol_promise_like(result)) {
1243
- if (wrappers.has(result)) {
1244
- result = wrappers.get(result).then(a => a);
1245
- }
1246
- else {
1247
- const put = (res) => {
1248
- if (this.cache === result)
1249
- this.put(res);
1250
- return res;
1251
- };
1252
- wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1253
- wrappers.set(result, result);
1254
- const error = new Error(`Promise in ${this}`);
1255
- Object.defineProperty(result, 'stack', { get: () => error.stack });
1256
- }
1229
+ else {
1230
+ const put = (res) => {
1231
+ if (this.cache === result)
1232
+ this.put(res);
1233
+ return res;
1234
+ };
1235
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1236
+ wrappers.set(result, result);
1237
+ const error = new Error(`Promise in ${this}`);
1238
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1257
1239
  }
1258
1240
  }
1259
- catch (error) {
1260
- if (error instanceof Error || $mol_promise_like(error)) {
1261
- result = error;
1241
+ }
1242
+ catch (error) {
1243
+ if (error instanceof Error || $mol_promise_like(error)) {
1244
+ result = error;
1245
+ }
1246
+ else {
1247
+ result = new Error(String(error), { cause: error });
1248
+ }
1249
+ if ($mol_promise_like(result)) {
1250
+ if (wrappers.has(result)) {
1251
+ result = wrappers.get(result);
1262
1252
  }
1263
1253
  else {
1264
- result = new Error(String(error), { cause: error });
1254
+ const put = (v) => {
1255
+ if (this.cache === result)
1256
+ this.absorb();
1257
+ return v;
1258
+ };
1259
+ wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1260
+ const error = new Error(`Promise in ${this}`);
1261
+ Object.defineProperty(result, 'stack', { get: () => error.stack });
1265
1262
  }
1266
- if ($mol_promise_like(result)) {
1267
- if (wrappers.has(result)) {
1268
- result = wrappers.get(result);
1269
- }
1270
- else {
1271
- const put = (v) => {
1272
- if (this.cache === result)
1273
- this.absorb();
1274
- return v;
1275
- };
1276
- wrappers.set(result, result = Object.assign(result.then(put, put), { destructor: result.destructor || (() => { }) }));
1277
- const error = new Error(`Promise in ${this}`);
1278
- Object.defineProperty(result, 'stack', { get: () => error.stack });
1279
- }
1280
- }
1281
- }
1282
- // Temp destroyed mid-calc (absorb restart): cut/off would throw.
1283
- if (this.cursor < this.pub_from)
1284
- return this;
1285
- if (!$mol_promise_like(result)) {
1286
- this.track_cut();
1287
1263
  }
1288
- this.track_off(bu);
1289
- this.put(result);
1290
1264
  }
1291
- finally {
1292
- // If cut threw or destructor nulled auto — put outer back
1293
- // (else once()/onclose → Promo to non begun sub).
1294
- if ($mol_wire_auto() === this || !$mol_wire_auto()) {
1295
- $mol_wire_auto(bu);
1296
- }
1265
+ if (!$mol_promise_like(result)) {
1266
+ this.track_cut();
1297
1267
  }
1268
+ this.track_off(bu);
1269
+ this.put(result);
1298
1270
  return this;
1299
1271
  }
1300
1272
  refresh() {