mol_wire_dom 0.0.821 → 0.0.823

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.test.js CHANGED
@@ -1032,301 +1032,6 @@ var $;
1032
1032
  ;
1033
1033
  "use strict";
1034
1034
  var $;
1035
- (function ($) {
1036
- class $mol_wire_task extends $mol_wire_fiber {
1037
- static getter(task) {
1038
- return function $mol_wire_task_get(host, args) {
1039
- const sub = $mol_wire_auto();
1040
- const existen = sub?.track_next();
1041
- reuse: if (existen) {
1042
- if (!existen.temp)
1043
- break reuse;
1044
- if (existen.host !== host)
1045
- break reuse;
1046
- if (existen.task !== task)
1047
- break reuse;
1048
- if (!$mol_compare_deep(existen.args, args))
1049
- break reuse;
1050
- return existen;
1051
- }
1052
- return new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
1053
- };
1054
- }
1055
- get temp() {
1056
- return true;
1057
- }
1058
- complete() {
1059
- if ($mol_promise_like(this.cache))
1060
- return;
1061
- this.destructor();
1062
- }
1063
- put(next) {
1064
- const prev = this.cache;
1065
- this.cache = next;
1066
- if ($mol_promise_like(next)) {
1067
- this.cursor = $mol_wire_cursor.fresh;
1068
- if (next !== prev)
1069
- this.emit();
1070
- return next;
1071
- }
1072
- this.cursor = $mol_wire_cursor.final;
1073
- if (this.sub_empty)
1074
- this.destructor();
1075
- else if (next !== prev)
1076
- this.emit();
1077
- return next;
1078
- }
1079
- }
1080
- $.$mol_wire_task = $mol_wire_task;
1081
- })($ || ($ = {}));
1082
- //mol/wire/task/task.ts
1083
- ;
1084
- "use strict";
1085
- var $;
1086
- (function ($) {
1087
- function $mol_wire_method(host, field, descr) {
1088
- if (!descr)
1089
- descr = Reflect.getOwnPropertyDescriptor(host, field);
1090
- const orig = descr?.value ?? host[field];
1091
- const sup = Reflect.getPrototypeOf(host);
1092
- if (typeof sup[field] === 'function') {
1093
- Object.defineProperty(orig, 'name', { value: sup[field].name });
1094
- }
1095
- const temp = $mol_wire_task.getter(orig);
1096
- const value = function (...args) {
1097
- const fiber = temp(this ?? null, args);
1098
- return fiber.sync();
1099
- };
1100
- Object.defineProperty(value, 'name', { value: orig.name + ' ' });
1101
- Object.assign(value, { orig });
1102
- const descr2 = { ...descr, value };
1103
- Reflect.defineProperty(host, field, descr2);
1104
- return descr2;
1105
- }
1106
- $.$mol_wire_method = $mol_wire_method;
1107
- })($ || ($ = {}));
1108
- //mol/wire/method/method.ts
1109
- ;
1110
- "use strict";
1111
- //mol/type/tail/tail.ts
1112
- ;
1113
- "use strict";
1114
- //mol/type/foot/foot.ts
1115
- ;
1116
- "use strict";
1117
- var $;
1118
- (function ($) {
1119
- const catched = new WeakMap();
1120
- function $mol_fail_catch(error) {
1121
- if (typeof error !== 'object')
1122
- return false;
1123
- if ($mol_promise_like(error))
1124
- $mol_fail_hidden(error);
1125
- if (catched.get(error))
1126
- return false;
1127
- catched.set(error, true);
1128
- return true;
1129
- }
1130
- $.$mol_fail_catch = $mol_fail_catch;
1131
- })($ || ($ = {}));
1132
- //mol/fail/catch/catch.ts
1133
- ;
1134
- "use strict";
1135
- var $;
1136
- (function ($) {
1137
- function $mol_fail_log(error) {
1138
- if ($mol_promise_like(error))
1139
- return false;
1140
- if (!$mol_fail_catch(error))
1141
- return false;
1142
- console.error(error);
1143
- return true;
1144
- }
1145
- $.$mol_fail_log = $mol_fail_log;
1146
- })($ || ($ = {}));
1147
- //mol/fail/log/log.ts
1148
- ;
1149
- "use strict";
1150
- var $;
1151
- (function ($) {
1152
- class $mol_wire_atom extends $mol_wire_fiber {
1153
- static solo(host, task) {
1154
- const field = task.name + '()';
1155
- const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1156
- if (existen)
1157
- return existen;
1158
- const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1159
- const key = `${prefix}.${field}`;
1160
- const fiber = new $mol_wire_atom(key, task, host, []);
1161
- (host ?? task)[field] = fiber;
1162
- return fiber;
1163
- }
1164
- static plex(host, task, key) {
1165
- const field = task.name + '()';
1166
- let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1167
- const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1168
- const id = `${prefix}.${task.name}(${$mol_key(key).replace(/^"|"$/g, "'")})`;
1169
- if (dict) {
1170
- const existen = dict.get(id);
1171
- if (existen)
1172
- return existen;
1173
- }
1174
- else {
1175
- dict = (host ?? task)[field] = new Map();
1176
- }
1177
- const fiber = new $mol_wire_atom(id, task, host, [key]);
1178
- dict.set(id, fiber);
1179
- return fiber;
1180
- }
1181
- static watching = new Set();
1182
- static watcher = null;
1183
- static watch() {
1184
- $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1185
- for (const atom of $mol_wire_atom.watching) {
1186
- if (atom.cursor === $mol_wire_cursor.final) {
1187
- $mol_wire_atom.watching.delete(atom);
1188
- }
1189
- else {
1190
- atom.cursor = $mol_wire_cursor.stale;
1191
- atom.fresh();
1192
- }
1193
- }
1194
- }
1195
- watch() {
1196
- if (!$mol_wire_atom.watcher) {
1197
- $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1198
- }
1199
- $mol_wire_atom.watching.add(this);
1200
- }
1201
- resync(args) {
1202
- return this.put(this.task.call(this.host, ...args));
1203
- }
1204
- once() {
1205
- return this.sync();
1206
- }
1207
- channel() {
1208
- return Object.assign((next) => {
1209
- if (next !== undefined)
1210
- return this.resync([...this.args, next]);
1211
- if (!$mol_wire_fiber.warm)
1212
- return this.result();
1213
- if ($mol_wire_auto()?.temp) {
1214
- return this.once();
1215
- }
1216
- else {
1217
- return this.sync();
1218
- }
1219
- }, { atom: this });
1220
- }
1221
- destructor() {
1222
- super.destructor();
1223
- const prev = this.cache;
1224
- if ($mol_owning_check(this, prev)) {
1225
- prev.destructor();
1226
- }
1227
- if (this.pub_from === 0) {
1228
- ;
1229
- (this.host ?? this.task)[this.field()] = null;
1230
- }
1231
- else {
1232
- ;
1233
- (this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
1234
- }
1235
- }
1236
- put(next) {
1237
- const prev = this.cache;
1238
- update: if (next !== prev) {
1239
- try {
1240
- if ($mol_compare_deep(prev, next))
1241
- break update;
1242
- }
1243
- catch (error) {
1244
- $mol_fail_log(error);
1245
- }
1246
- if ($mol_owning_check(this, prev)) {
1247
- prev.destructor();
1248
- }
1249
- if ($mol_owning_catch(this, next)) {
1250
- try {
1251
- next[Symbol.toStringTag] = this[Symbol.toStringTag];
1252
- }
1253
- catch {
1254
- Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1255
- }
1256
- }
1257
- if (!this.sub_empty)
1258
- this.emit();
1259
- }
1260
- this.cache = next;
1261
- this.cursor = $mol_wire_cursor.fresh;
1262
- if ($mol_promise_like(next))
1263
- return next;
1264
- this.complete_pubs();
1265
- return next;
1266
- }
1267
- }
1268
- __decorate([
1269
- $mol_wire_method
1270
- ], $mol_wire_atom.prototype, "resync", null);
1271
- __decorate([
1272
- $mol_wire_method
1273
- ], $mol_wire_atom.prototype, "once", null);
1274
- $.$mol_wire_atom = $mol_wire_atom;
1275
- })($ || ($ = {}));
1276
- //mol/wire/atom/atom.ts
1277
- ;
1278
- "use strict";
1279
- var $;
1280
- (function ($) {
1281
- })($ || ($ = {}));
1282
- //mol/dom/context/context.ts
1283
- ;
1284
- "use strict";
1285
- //node/node.ts
1286
- ;
1287
- "use strict";
1288
- var $node = new Proxy({ require }, {
1289
- get(target, name, wrapper) {
1290
- if (target[name])
1291
- return target[name];
1292
- const mod = target.require('module');
1293
- if (mod.builtinModules.indexOf(name) >= 0)
1294
- return target.require(name);
1295
- if (name[0] === '.')
1296
- return target.require(name);
1297
- const path = target.require('path');
1298
- const fs = target.require('fs');
1299
- let dir = path.resolve('.');
1300
- const suffix = `./node_modules/${name}`;
1301
- const $$ = $;
1302
- while (!fs.existsSync(path.join(dir, suffix))) {
1303
- const parent = path.resolve(dir, '..');
1304
- if (parent === dir) {
1305
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
1306
- try {
1307
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
1308
- }
1309
- catch { }
1310
- break;
1311
- }
1312
- else {
1313
- dir = parent;
1314
- }
1315
- }
1316
- return target.require(name);
1317
- },
1318
- set(target, name, value) {
1319
- target[name] = value;
1320
- return true;
1321
- },
1322
- });
1323
- require = (req => Object.assign(function require(name) {
1324
- return $node[name];
1325
- }, req))(require);
1326
- //node/node.node.ts
1327
- ;
1328
- "use strict";
1329
- var $;
1330
1035
  (function ($) {
1331
1036
  function $mol_log3_area_lazy(event) {
1332
1037
  const self = this;
@@ -1716,127 +1421,432 @@ var $;
1716
1421
  }
1717
1422
  return root;
1718
1423
  }
1719
- $.$mol_tree2_from_string = $mol_tree2_from_string;
1424
+ $.$mol_tree2_from_string = $mol_tree2_from_string;
1425
+ })($ || ($ = {}));
1426
+ //mol/tree2/from/string/string.ts
1427
+ ;
1428
+ "use strict";
1429
+ var $;
1430
+ (function ($) {
1431
+ function $mol_tree2_from_json(json, span = $mol_span.unknown) {
1432
+ if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
1433
+ return new $mol_tree2(String(json), '', [], span);
1434
+ }
1435
+ if (typeof json === 'string') {
1436
+ return $mol_tree2.data(json, [], span);
1437
+ }
1438
+ if (Array.isArray(json)) {
1439
+ const sub = json.map(json => $mol_tree2_from_json(json, span));
1440
+ return new $mol_tree2('/', '', sub, span);
1441
+ }
1442
+ if (ArrayBuffer.isView(json)) {
1443
+ const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1444
+ return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1445
+ }
1446
+ if (json instanceof Date) {
1447
+ return new $mol_tree2('', json.toISOString(), [], span);
1448
+ }
1449
+ if (typeof json.toJSON === 'function') {
1450
+ return $mol_tree2_from_json(json.toJSON());
1451
+ }
1452
+ if (json instanceof Error) {
1453
+ const { name, message, stack } = json;
1454
+ json = { ...json, name, message, stack };
1455
+ }
1456
+ const sub = [];
1457
+ for (var key in json) {
1458
+ const val = json[key];
1459
+ if (val === undefined)
1460
+ continue;
1461
+ const subsub = $mol_tree2_from_json(val, span);
1462
+ if (/^[^\n\t\\ ]+$/.test(key)) {
1463
+ sub.push(new $mol_tree2(key, '', [subsub], span));
1464
+ }
1465
+ else {
1466
+ sub.push($mol_tree2.data(key, [subsub], span));
1467
+ }
1468
+ }
1469
+ return new $mol_tree2('*', '', sub, span);
1470
+ }
1471
+ $.$mol_tree2_from_json = $mol_tree2_from_json;
1472
+ })($ || ($ = {}));
1473
+ //mol/tree2/from/json/json.ts
1474
+ ;
1475
+ "use strict";
1476
+ var $;
1477
+ (function ($) {
1478
+ class $mol_term_color {
1479
+ static reset = this.ansi(0, 0);
1480
+ static bold = this.ansi(1, 22);
1481
+ static italic = this.ansi(3, 23);
1482
+ static underline = this.ansi(4, 24);
1483
+ static inverse = this.ansi(7, 27);
1484
+ static hidden = this.ansi(8, 28);
1485
+ static strike = this.ansi(9, 29);
1486
+ static gray = this.ansi(90, 39);
1487
+ static red = this.ansi(91, 39);
1488
+ static green = this.ansi(92, 39);
1489
+ static yellow = this.ansi(93, 39);
1490
+ static blue = this.ansi(94, 39);
1491
+ static magenta = this.ansi(95, 39);
1492
+ static cyan = this.ansi(96, 39);
1493
+ static Gray = (str) => this.inverse(this.gray(str));
1494
+ static Red = (str) => this.inverse(this.red(str));
1495
+ static Green = (str) => this.inverse(this.green(str));
1496
+ static Yellow = (str) => this.inverse(this.yellow(str));
1497
+ static Blue = (str) => this.inverse(this.blue(str));
1498
+ static Magenta = (str) => this.inverse(this.magenta(str));
1499
+ static Cyan = (str) => this.inverse(this.cyan(str));
1500
+ static ansi(open, close) {
1501
+ if (typeof process === 'undefined')
1502
+ return String;
1503
+ if (!process.stdout.isTTY)
1504
+ return String;
1505
+ const prefix = `\x1b[${open}m`;
1506
+ const postfix = `\x1b[${close}m`;
1507
+ const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
1508
+ return function colorer(str) {
1509
+ str = String(str);
1510
+ if (str === '')
1511
+ return str;
1512
+ const suffix = str.replace(suffix_regexp, prefix);
1513
+ return prefix + suffix + postfix;
1514
+ };
1515
+ }
1516
+ }
1517
+ $.$mol_term_color = $mol_term_color;
1518
+ })($ || ($ = {}));
1519
+ //mol/term/color/color.ts
1520
+ ;
1521
+ "use strict";
1522
+ var $;
1523
+ (function ($) {
1524
+ function $mol_log3_node_make(level, output, type, color) {
1525
+ return function $mol_log3_logger(event) {
1526
+ if (!event.time)
1527
+ event = { time: new Date().toISOString(), ...event };
1528
+ let tree = this.$mol_tree2_from_json(event);
1529
+ tree = tree.struct(type, tree.kids);
1530
+ let str = color(tree.toString());
1531
+ this.console[level](str);
1532
+ const self = this;
1533
+ return () => self.console.groupEnd();
1534
+ };
1535
+ }
1536
+ $.$mol_log3_node_make = $mol_log3_node_make;
1537
+ $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
1538
+ $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
1539
+ $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
1540
+ $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
1541
+ $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
1542
+ $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
1543
+ })($ || ($ = {}));
1544
+ //mol/log3/log3.node.ts
1545
+ ;
1546
+ "use strict";
1547
+ var $;
1548
+ (function ($) {
1549
+ class $mol_wire_task extends $mol_wire_fiber {
1550
+ static getter(task) {
1551
+ return function $mol_wire_task_get(host, args) {
1552
+ const sub = $mol_wire_auto();
1553
+ const existen = sub?.track_next();
1554
+ reuse: if (existen) {
1555
+ if (!existen.temp)
1556
+ break reuse;
1557
+ if (existen.host !== host)
1558
+ break reuse;
1559
+ if (existen.task !== task)
1560
+ break reuse;
1561
+ if (!$mol_compare_deep(existen.args, args))
1562
+ break reuse;
1563
+ return existen;
1564
+ }
1565
+ const next = new $mol_wire_task(`${host?.[Symbol.toStringTag] ?? host}.${task.name}(#)`, task, host, args);
1566
+ if (existen?.temp) {
1567
+ $$.$mol_log3_warn({
1568
+ place: '$mol_wire_task',
1569
+ message: `Non idempotency`,
1570
+ existen,
1571
+ next,
1572
+ hint: 'Ignore it',
1573
+ });
1574
+ }
1575
+ return next;
1576
+ };
1577
+ }
1578
+ get temp() {
1579
+ return true;
1580
+ }
1581
+ complete() {
1582
+ if ($mol_promise_like(this.cache))
1583
+ return;
1584
+ this.destructor();
1585
+ }
1586
+ put(next) {
1587
+ const prev = this.cache;
1588
+ this.cache = next;
1589
+ if ($mol_promise_like(next)) {
1590
+ this.cursor = $mol_wire_cursor.fresh;
1591
+ if (next !== prev)
1592
+ this.emit();
1593
+ return next;
1594
+ }
1595
+ this.cursor = $mol_wire_cursor.final;
1596
+ if (this.sub_empty)
1597
+ this.destructor();
1598
+ else if (next !== prev)
1599
+ this.emit();
1600
+ return next;
1601
+ }
1602
+ }
1603
+ $.$mol_wire_task = $mol_wire_task;
1604
+ })($ || ($ = {}));
1605
+ //mol/wire/task/task.ts
1606
+ ;
1607
+ "use strict";
1608
+ var $;
1609
+ (function ($) {
1610
+ function $mol_wire_method(host, field, descr) {
1611
+ if (!descr)
1612
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
1613
+ const orig = descr?.value ?? host[field];
1614
+ const sup = Reflect.getPrototypeOf(host);
1615
+ if (typeof sup[field] === 'function') {
1616
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
1617
+ }
1618
+ const temp = $mol_wire_task.getter(orig);
1619
+ const value = function (...args) {
1620
+ const fiber = temp(this ?? null, args);
1621
+ return fiber.sync();
1622
+ };
1623
+ Object.defineProperty(value, 'name', { value: orig.name + ' ' });
1624
+ Object.assign(value, { orig });
1625
+ const descr2 = { ...descr, value };
1626
+ Reflect.defineProperty(host, field, descr2);
1627
+ return descr2;
1628
+ }
1629
+ $.$mol_wire_method = $mol_wire_method;
1630
+ })($ || ($ = {}));
1631
+ //mol/wire/method/method.ts
1632
+ ;
1633
+ "use strict";
1634
+ //mol/type/tail/tail.ts
1635
+ ;
1636
+ "use strict";
1637
+ //mol/type/foot/foot.ts
1638
+ ;
1639
+ "use strict";
1640
+ var $;
1641
+ (function ($) {
1642
+ const catched = new WeakMap();
1643
+ function $mol_fail_catch(error) {
1644
+ if (typeof error !== 'object')
1645
+ return false;
1646
+ if ($mol_promise_like(error))
1647
+ $mol_fail_hidden(error);
1648
+ if (catched.get(error))
1649
+ return false;
1650
+ catched.set(error, true);
1651
+ return true;
1652
+ }
1653
+ $.$mol_fail_catch = $mol_fail_catch;
1654
+ })($ || ($ = {}));
1655
+ //mol/fail/catch/catch.ts
1656
+ ;
1657
+ "use strict";
1658
+ var $;
1659
+ (function ($) {
1660
+ function $mol_fail_log(error) {
1661
+ if ($mol_promise_like(error))
1662
+ return false;
1663
+ if (!$mol_fail_catch(error))
1664
+ return false;
1665
+ console.error(error);
1666
+ return true;
1667
+ }
1668
+ $.$mol_fail_log = $mol_fail_log;
1720
1669
  })($ || ($ = {}));
1721
- //mol/tree2/from/string/string.ts
1670
+ //mol/fail/log/log.ts
1722
1671
  ;
1723
1672
  "use strict";
1724
1673
  var $;
1725
1674
  (function ($) {
1726
- function $mol_tree2_from_json(json, span = $mol_span.unknown) {
1727
- if (typeof json === 'boolean' || typeof json === 'number' || json === null) {
1728
- return new $mol_tree2(String(json), '', [], span);
1675
+ class $mol_wire_atom extends $mol_wire_fiber {
1676
+ static solo(host, task) {
1677
+ const field = task.name + '()';
1678
+ const existen = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1679
+ if (existen)
1680
+ return existen;
1681
+ const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1682
+ const key = `${prefix}.${field}`;
1683
+ const fiber = new $mol_wire_atom(key, task, host, []);
1684
+ (host ?? task)[field] = fiber;
1685
+ return fiber;
1729
1686
  }
1730
- if (typeof json === 'string') {
1731
- return $mol_tree2.data(json, [], span);
1687
+ static plex(host, task, key) {
1688
+ const field = task.name + '()';
1689
+ let dict = Object.getOwnPropertyDescriptor(host ?? task, field)?.value;
1690
+ const prefix = host?.[Symbol.toStringTag] ?? (host instanceof Function ? $$.$mol_func_name(host) : host);
1691
+ const id = `${prefix}.${task.name}(${$mol_key(key).replace(/^"|"$/g, "'")})`;
1692
+ if (dict) {
1693
+ const existen = dict.get(id);
1694
+ if (existen)
1695
+ return existen;
1696
+ }
1697
+ else {
1698
+ dict = (host ?? task)[field] = new Map();
1699
+ }
1700
+ const fiber = new $mol_wire_atom(id, task, host, [key]);
1701
+ dict.set(id, fiber);
1702
+ return fiber;
1732
1703
  }
1733
- if (Array.isArray(json)) {
1734
- const sub = json.map(json => $mol_tree2_from_json(json, span));
1735
- return new $mol_tree2('/', '', sub, span);
1704
+ static watching = new Set();
1705
+ static watcher = null;
1706
+ static watch() {
1707
+ $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1708
+ for (const atom of $mol_wire_atom.watching) {
1709
+ if (atom.cursor === $mol_wire_cursor.final) {
1710
+ $mol_wire_atom.watching.delete(atom);
1711
+ }
1712
+ else {
1713
+ atom.cursor = $mol_wire_cursor.stale;
1714
+ atom.fresh();
1715
+ }
1716
+ }
1736
1717
  }
1737
- if (ArrayBuffer.isView(json)) {
1738
- const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
1739
- return $mol_tree2.data(String.fromCharCode(...buf), [], span);
1718
+ watch() {
1719
+ if (!$mol_wire_atom.watcher) {
1720
+ $mol_wire_atom.watcher = new $mol_after_frame($mol_wire_atom.watch);
1721
+ }
1722
+ $mol_wire_atom.watching.add(this);
1740
1723
  }
1741
- if (json instanceof Date) {
1742
- return new $mol_tree2('', json.toISOString(), [], span);
1724
+ resync(args) {
1725
+ return this.put(this.task.call(this.host, ...args));
1743
1726
  }
1744
- if (typeof json.toJSON === 'function') {
1745
- return $mol_tree2_from_json(json.toJSON());
1727
+ once() {
1728
+ return this.sync();
1746
1729
  }
1747
- if (json instanceof Error) {
1748
- const { name, message, stack } = json;
1749
- json = { ...json, name, message, stack };
1730
+ channel() {
1731
+ return Object.assign((next) => {
1732
+ if (next !== undefined)
1733
+ return this.resync([...this.args, next]);
1734
+ if (!$mol_wire_fiber.warm)
1735
+ return this.result();
1736
+ if ($mol_wire_auto()?.temp) {
1737
+ return this.once();
1738
+ }
1739
+ else {
1740
+ return this.sync();
1741
+ }
1742
+ }, { atom: this });
1750
1743
  }
1751
- const sub = [];
1752
- for (var key in json) {
1753
- const val = json[key];
1754
- if (val === undefined)
1755
- continue;
1756
- const subsub = $mol_tree2_from_json(val, span);
1757
- if (/^[^\n\t\\ ]+$/.test(key)) {
1758
- sub.push(new $mol_tree2(key, '', [subsub], span));
1744
+ destructor() {
1745
+ super.destructor();
1746
+ const prev = this.cache;
1747
+ if ($mol_owning_check(this, prev)) {
1748
+ prev.destructor();
1749
+ }
1750
+ if (this.pub_from === 0) {
1751
+ ;
1752
+ (this.host ?? this.task)[this.field()] = null;
1759
1753
  }
1760
1754
  else {
1761
- sub.push($mol_tree2.data(key, [subsub], span));
1755
+ ;
1756
+ (this.host ?? this.task)[this.field()].delete(this[Symbol.toStringTag]);
1762
1757
  }
1763
1758
  }
1764
- return new $mol_tree2('*', '', sub, span);
1759
+ put(next) {
1760
+ const prev = this.cache;
1761
+ update: if (next !== prev) {
1762
+ try {
1763
+ if ($mol_compare_deep(prev, next))
1764
+ break update;
1765
+ }
1766
+ catch (error) {
1767
+ $mol_fail_log(error);
1768
+ }
1769
+ if ($mol_owning_check(this, prev)) {
1770
+ prev.destructor();
1771
+ }
1772
+ if ($mol_owning_catch(this, next)) {
1773
+ try {
1774
+ next[Symbol.toStringTag] = this[Symbol.toStringTag];
1775
+ }
1776
+ catch {
1777
+ Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
1778
+ }
1779
+ }
1780
+ if (!this.sub_empty)
1781
+ this.emit();
1782
+ }
1783
+ this.cache = next;
1784
+ this.cursor = $mol_wire_cursor.fresh;
1785
+ if ($mol_promise_like(next))
1786
+ return next;
1787
+ this.complete_pubs();
1788
+ return next;
1789
+ }
1765
1790
  }
1766
- $.$mol_tree2_from_json = $mol_tree2_from_json;
1791
+ __decorate([
1792
+ $mol_wire_method
1793
+ ], $mol_wire_atom.prototype, "resync", null);
1794
+ __decorate([
1795
+ $mol_wire_method
1796
+ ], $mol_wire_atom.prototype, "once", null);
1797
+ $.$mol_wire_atom = $mol_wire_atom;
1767
1798
  })($ || ($ = {}));
1768
- //mol/tree2/from/json/json.ts
1799
+ //mol/wire/atom/atom.ts
1769
1800
  ;
1770
1801
  "use strict";
1771
1802
  var $;
1772
1803
  (function ($) {
1773
- class $mol_term_color {
1774
- static reset = this.ansi(0, 0);
1775
- static bold = this.ansi(1, 22);
1776
- static italic = this.ansi(3, 23);
1777
- static underline = this.ansi(4, 24);
1778
- static inverse = this.ansi(7, 27);
1779
- static hidden = this.ansi(8, 28);
1780
- static strike = this.ansi(9, 29);
1781
- static gray = this.ansi(90, 39);
1782
- static red = this.ansi(91, 39);
1783
- static green = this.ansi(92, 39);
1784
- static yellow = this.ansi(93, 39);
1785
- static blue = this.ansi(94, 39);
1786
- static magenta = this.ansi(95, 39);
1787
- static cyan = this.ansi(96, 39);
1788
- static Gray = (str) => this.inverse(this.gray(str));
1789
- static Red = (str) => this.inverse(this.red(str));
1790
- static Green = (str) => this.inverse(this.green(str));
1791
- static Yellow = (str) => this.inverse(this.yellow(str));
1792
- static Blue = (str) => this.inverse(this.blue(str));
1793
- static Magenta = (str) => this.inverse(this.magenta(str));
1794
- static Cyan = (str) => this.inverse(this.cyan(str));
1795
- static ansi(open, close) {
1796
- if (typeof process === 'undefined')
1797
- return String;
1798
- if (!process.stdout.isTTY)
1799
- return String;
1800
- const prefix = `\x1b[${open}m`;
1801
- const postfix = `\x1b[${close}m`;
1802
- const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
1803
- return function colorer(str) {
1804
- str = String(str);
1805
- if (str === '')
1806
- return str;
1807
- const suffix = str.replace(suffix_regexp, prefix);
1808
- return prefix + suffix + postfix;
1809
- };
1810
- }
1811
- }
1812
- $.$mol_term_color = $mol_term_color;
1813
1804
  })($ || ($ = {}));
1814
- //mol/term/color/color.ts
1805
+ //mol/dom/context/context.ts
1815
1806
  ;
1816
1807
  "use strict";
1817
- var $;
1818
- (function ($) {
1819
- function $mol_log3_node_make(level, output, type, color) {
1820
- return function $mol_log3_logger(event) {
1821
- if (!event.time)
1822
- event = { time: new Date().toISOString(), ...event };
1823
- let tree = this.$mol_tree2_from_json(event);
1824
- tree = tree.struct(type, tree.kids);
1825
- let str = color(tree.toString());
1826
- this.console[level](str);
1827
- const self = this;
1828
- return () => self.console.groupEnd();
1829
- };
1830
- }
1831
- $.$mol_log3_node_make = $mol_log3_node_make;
1832
- $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
1833
- $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
1834
- $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
1835
- $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
1836
- $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
1837
- $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
1838
- })($ || ($ = {}));
1839
- //mol/log3/log3.node.ts
1808
+ //node/node.ts
1809
+ ;
1810
+ "use strict";
1811
+ var $node = new Proxy({ require }, {
1812
+ get(target, name, wrapper) {
1813
+ if (target[name])
1814
+ return target[name];
1815
+ const mod = target.require('module');
1816
+ if (mod.builtinModules.indexOf(name) >= 0)
1817
+ return target.require(name);
1818
+ if (name[0] === '.')
1819
+ return target.require(name);
1820
+ const path = target.require('path');
1821
+ const fs = target.require('fs');
1822
+ let dir = path.resolve('.');
1823
+ const suffix = `./node_modules/${name}`;
1824
+ const $$ = $;
1825
+ while (!fs.existsSync(path.join(dir, suffix))) {
1826
+ const parent = path.resolve(dir, '..');
1827
+ if (parent === dir) {
1828
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
1829
+ try {
1830
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
1831
+ }
1832
+ catch { }
1833
+ break;
1834
+ }
1835
+ else {
1836
+ dir = parent;
1837
+ }
1838
+ }
1839
+ return target.require(name);
1840
+ },
1841
+ set(target, name, value) {
1842
+ target[name] = value;
1843
+ return true;
1844
+ },
1845
+ });
1846
+ require = (req => Object.assign(function require(name) {
1847
+ return $node[name];
1848
+ }, req))(require);
1849
+ //node/node.node.ts
1840
1850
  ;
1841
1851
  "use strict";
1842
1852
  var $;