mam 1.11.795 → 1.11.797

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
@@ -2419,45 +2419,64 @@ var $;
2419
2419
  ;
2420
2420
  "use strict";
2421
2421
 
2422
+ ;
2423
+ "use strict";
2424
+ var $;
2425
+ (function ($) {
2426
+ const mod = require('module');
2427
+ const internals = mod.builtinModules;
2428
+ function $node_internal_check(name) {
2429
+ if (name.startsWith('node:'))
2430
+ return true;
2431
+ return internals.includes(name);
2432
+ }
2433
+ $.$node_internal_check = $node_internal_check;
2434
+ })($ || ($ = {}));
2435
+
2422
2436
  ;
2423
2437
  "use strict";
2424
2438
  var $node = new Proxy({ require }, {
2425
2439
  get(target, name, wrapper) {
2426
2440
  if (target[name])
2427
2441
  return target[name];
2428
- if (name.startsWith('node:'))
2442
+ const $$ = $;
2443
+ if ($$.$node_internal_check(name, target))
2429
2444
  return target.require(name);
2430
2445
  if (name[0] === '.')
2431
2446
  return target.require(name);
2432
- const mod = target.require('module');
2433
- if (mod.builtinModules.indexOf(name) >= 0)
2434
- return target.require(name);
2435
2447
  try {
2436
2448
  target.require.resolve(name);
2437
2449
  }
2438
2450
  catch {
2439
- const $$ = $;
2440
- $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2451
+ try {
2452
+ $$.$mol_exec('.', 'npm', 'install', '--omit=dev', name);
2453
+ }
2454
+ catch (e) {
2455
+ if ($$.$mol_promise_like(e))
2456
+ $$.$mol_fail_hidden(e);
2457
+ }
2441
2458
  try {
2442
2459
  $$.$mol_exec('.', 'npm', 'install', '--omit=dev', '@types/' + name);
2443
2460
  }
2444
2461
  catch (e) {
2445
- if ($$.$mol_fail_catch(e)) {
2446
- $$.$mol_fail_log(e);
2447
- }
2462
+ if ($$.$mol_promise_like(e))
2463
+ $$.$mol_fail_hidden(e);
2464
+ $$.$mol_fail_log(e);
2448
2465
  }
2449
2466
  }
2450
2467
  try {
2451
2468
  return target.require(name);
2452
2469
  }
2453
2470
  catch (error) {
2454
- if ($.$mol_fail_catch(error) && error.code === 'ERR_REQUIRE_ESM') {
2471
+ if ($$.$mol_promise_like(error))
2472
+ $$.$mol_fail_hidden(error);
2473
+ if (error && typeof error === 'object' && error.code === 'ERR_REQUIRE_ESM') {
2455
2474
  const module = cache.get(name);
2456
2475
  if (module)
2457
2476
  return module;
2458
2477
  throw Object.assign(import(name).then(module => cache.set(name, module)), { cause: error });
2459
2478
  }
2460
- $.$mol_fail_log(error);
2479
+ $$.$mol_fail_log(error);
2461
2480
  return null;
2462
2481
  }
2463
2482
  },
@@ -6225,7 +6244,7 @@ var $;
6225
6244
  types.push('\t' + JSON.stringify(dep) + ' : typeof import\( ' + JSON.stringify(dep) + ' ) // ' + src);
6226
6245
  }
6227
6246
  const node_types = $mol_file.absolute(path).resolve(`-node/deps.d.ts`);
6228
- node_types.text('interface $node {\n ' + types.join('\n') + '\n}');
6247
+ node_types.text('// @ts-nocheck\ninterface $node {\n ' + types.join('\n') + '\n}');
6229
6248
  sources.push(node_types);
6230
6249
  }
6231
6250
  return sources.map(src => src.path());
@@ -6875,7 +6894,7 @@ var $;
6875
6894
  ++version[2];
6876
6895
  json.version = version.join('.');
6877
6896
  for (let dep of this.nodeDeps([path, exclude]).keys()) {
6878
- if (require('module').builtinModules.includes(dep) || dep.startsWith('node:'))
6897
+ if ($node_internal_check(dep))
6879
6898
  continue;
6880
6899
  json.dependencies[dep] ??= `*`;
6881
6900
  }
@@ -7258,6 +7277,8 @@ var $;
7258
7277
  var indent = /^([\s\t]*)/.exec(line);
7259
7278
  var priority = -indent[0].replace(/\t/g, ' ').length / 4;
7260
7279
  line.replace(/\b(?:require|import)\(\s*['"]([^"'()]*?)['"]\s*\)/ig, (str, path) => {
7280
+ if ($node_internal_check(path))
7281
+ return str;
7261
7282
  path = path.replace(/(\/[^\/.]+)$/, '$1.js').replace(/\/$/, '/index.js');
7262
7283
  if (path[0] === '.')
7263
7284
  path = '../' + path;
@@ -7286,7 +7307,7 @@ var $;
7286
7307
  return str;
7287
7308
  });
7288
7309
  line.replace(/\b(?:require|import)\(\s*['"]([^"'()]*?)['"]\s*\)/ig, (str, path) => {
7289
- if (path.startsWith('node:'))
7310
+ if ($node_internal_check(path))
7290
7311
  return str;
7291
7312
  $mol_build_depsMerge(depends, { [path]: priority });
7292
7313
  return str;