mol_tree2 1.0.238 → 1.0.240

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
@@ -1161,6 +1161,204 @@ var $;
1161
1161
  ;
1162
1162
  "use strict";
1163
1163
  var $;
1164
+ (function ($) {
1165
+ })($ || ($ = {}));
1166
+ //mol/dom/context/context.ts
1167
+ ;
1168
+ "use strict";
1169
+ //node/node.ts
1170
+ ;
1171
+ "use strict";
1172
+ var $node = new Proxy({ require }, {
1173
+ get(target, name, wrapper) {
1174
+ if (target[name])
1175
+ return target[name];
1176
+ const mod = target.require('module');
1177
+ if (mod.builtinModules.indexOf(name) >= 0)
1178
+ return target.require(name);
1179
+ if (name[0] === '.')
1180
+ return target.require(name);
1181
+ const path = target.require('path');
1182
+ const fs = target.require('fs');
1183
+ let dir = path.resolve('.');
1184
+ const suffix = `./node_modules/${name}`;
1185
+ const $$ = $;
1186
+ while (!fs.existsSync(path.join(dir, suffix))) {
1187
+ const parent = path.resolve(dir, '..');
1188
+ if (parent === dir) {
1189
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
1190
+ try {
1191
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
1192
+ }
1193
+ catch { }
1194
+ break;
1195
+ }
1196
+ else {
1197
+ dir = parent;
1198
+ }
1199
+ }
1200
+ return target.require(name);
1201
+ },
1202
+ set(target, name, value) {
1203
+ target[name] = value;
1204
+ return true;
1205
+ },
1206
+ });
1207
+ require = (req => Object.assign(function require(name) {
1208
+ return $node[name];
1209
+ }, req))(require);
1210
+ //node/node.node.ts
1211
+ ;
1212
+ "use strict";
1213
+ var $;
1214
+ (function ($) {
1215
+ function $mol_log3_area_lazy(event) {
1216
+ const self = this;
1217
+ const stack = self.$mol_log3_stack;
1218
+ const deep = stack.length;
1219
+ let logged = false;
1220
+ stack.push(() => {
1221
+ logged = true;
1222
+ self.$mol_log3_area.call(self, event);
1223
+ });
1224
+ return () => {
1225
+ if (logged)
1226
+ self.console.groupEnd();
1227
+ if (stack.length > deep)
1228
+ stack.length = deep;
1229
+ };
1230
+ }
1231
+ $.$mol_log3_area_lazy = $mol_log3_area_lazy;
1232
+ $.$mol_log3_stack = [];
1233
+ })($ || ($ = {}));
1234
+ //mol/log3/log3.ts
1235
+ ;
1236
+ "use strict";
1237
+ var $;
1238
+ (function ($) {
1239
+ class $mol_term_color {
1240
+ static reset = this.ansi(0, 0);
1241
+ static bold = this.ansi(1, 22);
1242
+ static italic = this.ansi(3, 23);
1243
+ static underline = this.ansi(4, 24);
1244
+ static inverse = this.ansi(7, 27);
1245
+ static hidden = this.ansi(8, 28);
1246
+ static strike = this.ansi(9, 29);
1247
+ static gray = this.ansi(90, 39);
1248
+ static red = this.ansi(91, 39);
1249
+ static green = this.ansi(92, 39);
1250
+ static yellow = this.ansi(93, 39);
1251
+ static blue = this.ansi(94, 39);
1252
+ static magenta = this.ansi(95, 39);
1253
+ static cyan = this.ansi(96, 39);
1254
+ static Gray = (str) => this.inverse(this.gray(str));
1255
+ static Red = (str) => this.inverse(this.red(str));
1256
+ static Green = (str) => this.inverse(this.green(str));
1257
+ static Yellow = (str) => this.inverse(this.yellow(str));
1258
+ static Blue = (str) => this.inverse(this.blue(str));
1259
+ static Magenta = (str) => this.inverse(this.magenta(str));
1260
+ static Cyan = (str) => this.inverse(this.cyan(str));
1261
+ static ansi(open, close) {
1262
+ if (typeof process === 'undefined')
1263
+ return String;
1264
+ if (!process.stdout.isTTY)
1265
+ return String;
1266
+ const prefix = `\x1b[${open}m`;
1267
+ const postfix = `\x1b[${close}m`;
1268
+ const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
1269
+ return function colorer(str) {
1270
+ str = String(str);
1271
+ if (str === '')
1272
+ return str;
1273
+ const suffix = str.replace(suffix_regexp, prefix);
1274
+ return prefix + suffix + postfix;
1275
+ };
1276
+ }
1277
+ }
1278
+ $.$mol_term_color = $mol_term_color;
1279
+ })($ || ($ = {}));
1280
+ //mol/term/color/color.ts
1281
+ ;
1282
+ "use strict";
1283
+ var $;
1284
+ (function ($) {
1285
+ function $mol_log3_node_make(level, output, type, color) {
1286
+ return function $mol_log3_logger(event) {
1287
+ if (!event.time)
1288
+ event = { time: new Date().toISOString(), ...event };
1289
+ let tree = this.$mol_tree2_from_json(event);
1290
+ tree = tree.struct(type, tree.kids);
1291
+ let str = color(tree.toString());
1292
+ this.console[level](str);
1293
+ const self = this;
1294
+ return () => self.console.groupEnd();
1295
+ };
1296
+ }
1297
+ $.$mol_log3_node_make = $mol_log3_node_make;
1298
+ $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
1299
+ $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
1300
+ $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
1301
+ $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
1302
+ $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
1303
+ $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
1304
+ })($ || ($ = {}));
1305
+ //mol/log3/log3.node.ts
1306
+ ;
1307
+ "use strict";
1308
+ var $;
1309
+ (function ($) {
1310
+ function $mol_env() {
1311
+ return {};
1312
+ }
1313
+ $.$mol_env = $mol_env;
1314
+ })($ || ($ = {}));
1315
+ //mol/env/env.ts
1316
+ ;
1317
+ "use strict";
1318
+ var $;
1319
+ (function ($) {
1320
+ $.$mol_env = function $mol_env() {
1321
+ return this.process.env;
1322
+ };
1323
+ })($ || ($ = {}));
1324
+ //mol/env/env.node.ts
1325
+ ;
1326
+ "use strict";
1327
+ var $;
1328
+ (function ($) {
1329
+ function $mol_exec(dir, command, ...args) {
1330
+ let [app, ...args0] = command.split(' ');
1331
+ args = [...args0, ...args];
1332
+ this.$mol_log3_come({
1333
+ place: '$mol_exec',
1334
+ dir: $node.path.relative('', dir),
1335
+ message: 'Run',
1336
+ command: `${app} ${args.join(' ')}`,
1337
+ });
1338
+ var res = $node['child_process'].spawnSync(app, args, {
1339
+ cwd: $node.path.resolve(dir),
1340
+ shell: true,
1341
+ env: this.$mol_env(),
1342
+ });
1343
+ if (res.status || res.error)
1344
+ return $mol_fail(res.error || new Error(res.stderr.toString()));
1345
+ if (!res.stdout)
1346
+ res.stdout = Buffer.from([]);
1347
+ return res;
1348
+ }
1349
+ $.$mol_exec = $mol_exec;
1350
+ })($ || ($ = {}));
1351
+ //mol/exec/exec.node.ts
1352
+ ;
1353
+ "use strict";
1354
+ var $;
1355
+ (function ($) {
1356
+ $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
1357
+ })($ || ($ = {}));
1358
+ //mol/dom/context/context.node.ts
1359
+ ;
1360
+ "use strict";
1361
+ var $;
1164
1362
  (function ($) {
1165
1363
  function $mol_tree2_xml_from_dom(dom) {
1166
1364
  switch (dom.nodeType) {