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