@mokup/server 1.2.0 → 1.2.1

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.
@@ -5,20 +5,19 @@ const node_fs = require('node:fs');
5
5
  const node_module = require('node:module');
6
6
  const playgroundGrouping = require('@mokup/shared/playground-grouping');
7
7
  const runtime = require('@mokup/runtime');
8
+ const routeUtils$1 = require('@mokup/shared/route-utils');
9
+ const configUtils = require('@mokup/shared/config-utils');
10
+ const moduleLoader = require('@mokup/shared/module-loader');
11
+ const routeConstants = require('@mokup/shared/route-constants');
12
+ const mockFiles = require('@mokup/shared/mock-files');
13
+ const loadRules$1 = require('@mokup/shared/load-rules');
14
+ const scanUtils = require('@mokup/shared/scan-utils');
8
15
  const pathUtils = require('@mokup/shared/path-utils');
9
16
  const timing = require('@mokup/shared/timing');
10
- const node_buffer = require('node:buffer');
11
- const node_url = require('node:url');
12
- const esbuild = require('@mokup/shared/esbuild');
13
- const process = require('node:process');
14
- const jsoncParser = require('@mokup/shared/jsonc-parser');
15
17
  const hono = require('@mokup/shared/hono');
18
+ const node_process = require('node:process');
16
19
 
17
20
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
18
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
19
-
20
- const process__default = /*#__PURE__*/_interopDefaultCompat(process);
21
-
22
21
  const silentLogger$1 = {
23
22
  info: () => {
24
23
  },
@@ -274,583 +273,98 @@ function registerPlaygroundRoutes(params) {
274
273
  });
275
274
  }
276
275
 
277
- const methodSet = /* @__PURE__ */ new Set([
278
- "GET",
279
- "POST",
280
- "PUT",
281
- "PATCH",
282
- "DELETE",
283
- "OPTIONS",
284
- "HEAD"
285
- ]);
286
- const methodSuffixSet = new Set(
287
- Array.from(methodSet, (method) => method.toLowerCase())
288
- );
289
- const supportedExtensions = /* @__PURE__ */ new Set([
290
- ".json",
291
- ".jsonc",
292
- ".ts",
293
- ".js",
294
- ".mjs",
295
- ".cjs"
296
- ]);
297
- const configExtensions = [".ts", ".js", ".mjs", ".cjs"];
298
-
299
- function normalizePrefix(prefix) {
300
- if (!prefix) {
301
- return "";
302
- }
303
- const normalized = prefix.startsWith("/") ? prefix : `/${prefix}`;
304
- return normalized.endsWith("/") ? normalized.slice(0, -1) : normalized;
305
- }
306
- function resolveDirs(dir, root) {
307
- const raw = typeof dir === "function" ? dir(root) : dir;
308
- const resolved = Array.isArray(raw) ? raw : raw ? [raw] : ["mock"];
309
- const normalized = resolved.map(
310
- (entry) => pathe.isAbsolute(entry) ? entry : pathe.resolve(root, entry)
311
- );
312
- return Array.from(new Set(normalized));
313
- }
314
- function normalizeIgnorePrefix(value, fallback = ["."]) {
315
- const list = typeof value === "undefined" ? fallback : Array.isArray(value) ? value : [value];
316
- return list.filter((entry) => typeof entry === "string" && entry.length > 0);
317
- }
318
-
319
- const jsonExtensions = /* @__PURE__ */ new Set([".json", ".jsonc"]);
320
- function resolveTemplate(template, prefix) {
321
- const normalized = template.startsWith("/") ? template : `/${template}`;
322
- if (!prefix) {
323
- return normalized;
324
- }
325
- const normalizedPrefix = normalizePrefix(prefix);
326
- if (!normalizedPrefix) {
327
- return normalized;
328
- }
329
- if (normalized === normalizedPrefix || normalized.startsWith(`${normalizedPrefix}/`)) {
330
- return normalized;
331
- }
332
- if (normalized === "/") {
333
- return `${normalizedPrefix}/`;
334
- }
335
- return `${normalizedPrefix}${normalized}`;
336
- }
337
- function stripMethodSuffix(base) {
338
- const segments = base.split(".");
339
- const last = segments.at(-1);
340
- if (last && methodSuffixSet.has(last.toLowerCase())) {
341
- segments.pop();
342
- return {
343
- name: segments.join("."),
344
- method: last.toUpperCase()
345
- };
346
- }
347
- return {
348
- name: base,
349
- method: void 0
350
- };
351
- }
276
+ const routeUtils = routeUtils$1.createRouteUtils({
277
+ parseRouteTemplate: runtime.parseRouteTemplate,
278
+ compareRouteScore: runtime.compareRouteScore
279
+ });
352
280
  function deriveRouteFromFile(file, rootDir, logger) {
353
- const rel = pathUtils.toPosix(pathe.relative(rootDir, file));
354
- const ext = pathe.extname(rel);
355
- const withoutExt = rel.slice(0, rel.length - ext.length);
356
- const dir = pathe.dirname(withoutExt);
357
- const base = pathe.basename(withoutExt);
358
- const { name, method } = stripMethodSuffix(base);
359
- const resolvedMethod = method ?? (jsonExtensions.has(ext) ? "GET" : void 0);
360
- if (!resolvedMethod) {
361
- logger.warn(`Skip mock without method suffix: ${file}`);
362
- return null;
363
- }
364
- if (!name) {
365
- logger.warn(`Skip mock with empty route name: ${file}`);
366
- return null;
367
- }
368
- const joined = dir === "." ? name : pathe.join(dir, name);
369
- const segments = pathUtils.toPosix(joined).split("/");
370
- if (segments.at(-1) === "index") {
371
- segments.pop();
372
- }
373
- const template = segments.length === 0 ? "/" : `/${segments.join("/")}`;
374
- const parsed = runtime.parseRouteTemplate(template);
375
- if (parsed.errors.length > 0) {
376
- for (const error of parsed.errors) {
377
- logger.warn(`${error} in ${file}`);
378
- }
379
- return null;
380
- }
381
- for (const warning of parsed.warnings) {
382
- logger.warn(`${warning} in ${file}`);
383
- }
384
- return {
385
- template: parsed.template,
386
- method: resolvedMethod,
387
- tokens: parsed.tokens,
388
- score: parsed.score
389
- };
281
+ return routeUtils.deriveRouteFromFile(file, rootDir, (message) => logger.warn(message));
390
282
  }
391
283
  function resolveRule(params) {
392
- const method = params.derivedMethod;
393
- if (!method) {
394
- params.logger.warn(`Skip mock without method suffix: ${params.file}`);
395
- return null;
396
- }
397
- const template = resolveTemplate(params.derivedTemplate, params.prefix);
398
- const parsed = runtime.parseRouteTemplate(template);
399
- if (parsed.errors.length > 0) {
400
- for (const error of parsed.errors) {
401
- params.logger.warn(`${error} in ${params.file}`);
402
- }
403
- return null;
404
- }
405
- for (const warning of parsed.warnings) {
406
- params.logger.warn(`${warning} in ${params.file}`);
407
- }
408
- const route = {
284
+ return routeUtils.resolveRule({
285
+ rule: params.rule,
286
+ derivedTemplate: params.derivedTemplate,
287
+ derivedMethod: params.derivedMethod,
288
+ prefix: params.prefix,
409
289
  file: params.file,
410
- template: parsed.template,
411
- method,
412
- tokens: parsed.tokens,
413
- score: parsed.score,
414
- handler: params.rule.handler
415
- };
416
- if (typeof params.rule.status === "number") {
417
- route.status = params.rule.status;
418
- }
419
- if (params.rule.headers) {
420
- route.headers = params.rule.headers;
421
- }
422
- if (typeof params.rule.delay === "number") {
423
- route.delay = params.rule.delay;
424
- }
425
- return route;
426
- }
427
- function sortRoutes(routes) {
428
- return routes.sort((a, b) => {
429
- if (a.method !== b.method) {
430
- return a.method.localeCompare(b.method);
431
- }
432
- const scoreCompare = runtime.compareRouteScore(a.score, b.score);
433
- if (scoreCompare !== 0) {
434
- return scoreCompare;
435
- }
436
- return a.template.localeCompare(b.template);
437
- });
438
- }
439
-
440
- let registerPromise = null;
441
- let hasLoggedFailure = false;
442
- async function ensureTsxRegister(logger) {
443
- if (registerPromise) {
444
- return registerPromise;
445
- }
446
- registerPromise = (async () => {
447
- try {
448
- const mod = await import('tsx/esm/api');
449
- const setSourceMapsEnabled = process__default.setSourceMapsEnabled;
450
- if (typeof setSourceMapsEnabled === "function") {
451
- setSourceMapsEnabled(true);
452
- }
453
- if (typeof mod.register === "function") {
454
- mod.register();
290
+ warn: (message) => params.logger.warn(message),
291
+ build: (base, rule) => {
292
+ const route = {
293
+ file: params.file,
294
+ template: base.template,
295
+ method: base.method,
296
+ tokens: base.tokens,
297
+ score: base.score,
298
+ handler: rule.handler
299
+ };
300
+ if (typeof rule.status === "number") {
301
+ route.status = rule.status;
455
302
  }
456
- return true;
457
- } catch (error) {
458
- if (!hasLoggedFailure && logger) {
459
- logger.warn(
460
- "Failed to register tsx loader; falling back to bundled TS loader.",
461
- error
462
- );
463
- hasLoggedFailure = true;
303
+ if (rule.headers) {
304
+ route.headers = rule.headers;
464
305
  }
465
- return false;
466
- }
467
- })();
468
- return registerPromise;
469
- }
470
-
471
- const middlewareSymbol = Symbol.for("mokup.config.middlewares");
472
- function isUnknownFileExtensionError$1(error) {
473
- if (!error || typeof error !== "object") {
474
- return false;
475
- }
476
- const code = error.code;
477
- if (code === "ERR_UNKNOWN_FILE_EXTENSION") {
478
- return true;
479
- }
480
- const message = error.message;
481
- return typeof message === "string" && message.includes("Unknown file extension");
482
- }
483
- async function loadTsModule$1(file, logger) {
484
- const cacheBust = Date.now();
485
- const fileUrl = `${node_url.pathToFileURL(file).href}?t=${cacheBust}`;
486
- const registered = await ensureTsxRegister(logger);
487
- if (registered) {
488
- try {
489
- return await import(fileUrl);
490
- } catch (error) {
491
- if (!isUnknownFileExtensionError$1(error)) {
492
- throw error;
306
+ if (typeof rule.delay === "number") {
307
+ route.delay = rule.delay;
493
308
  }
309
+ return route;
494
310
  }
495
- }
496
- const result = await esbuild.build({
497
- entryPoints: [file],
498
- bundle: true,
499
- format: "esm",
500
- platform: "node",
501
- sourcemap: "inline",
502
- target: "es2020",
503
- write: false
504
311
  });
505
- const output = result.outputFiles[0];
506
- const code = output?.text ?? "";
507
- const dataUrl = `data:text/javascript;base64,${node_buffer.Buffer.from(code).toString(
508
- "base64"
509
- )}`;
510
- return import(`${dataUrl}#${cacheBust}`);
511
312
  }
512
- async function loadModule$1(file, logger) {
513
- const ext = configExtensions.find((extension) => file.endsWith(extension));
514
- if (ext === ".cjs") {
515
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('fetch-server.cjs', document.baseURI).href)));
516
- delete require$1.cache[file];
517
- return require$1(file);
518
- }
519
- if (ext === ".js" || ext === ".mjs") {
520
- return import(`${node_url.pathToFileURL(file).href}?t=${Date.now()}`);
521
- }
522
- if (ext === ".ts") {
523
- return loadTsModule$1(file, logger);
524
- }
525
- return null;
526
- }
527
- function getConfigFileCandidates(dir) {
528
- return configExtensions.map((extension) => pathe.join(dir, `index.config${extension}`));
529
- }
530
- async function findConfigFile(dir, cache) {
531
- const cached = cache.get(dir);
532
- if (cached !== void 0) {
533
- return cached;
534
- }
535
- for (const candidate of getConfigFileCandidates(dir)) {
536
- try {
537
- await node_fs.promises.stat(candidate);
538
- cache.set(dir, candidate);
539
- return candidate;
540
- } catch {
541
- continue;
542
- }
543
- }
544
- cache.set(dir, null);
545
- return null;
313
+ function sortRoutes(routes) {
314
+ return routeUtils.sortRoutes(routes);
546
315
  }
547
- async function loadConfig(file, logger) {
548
- const mod = await loadModule$1(file, logger);
316
+
317
+ const configExtensions = routeConstants.configExtensions;
318
+
319
+ async function loadConfig(file) {
320
+ const mod = await moduleLoader.loadModule(file);
549
321
  if (!mod) {
550
322
  return null;
551
323
  }
552
324
  const raw = mod?.default ?? mod;
553
- const value = isPromise(raw) ? await raw : raw;
325
+ const value = configUtils.isPromise(raw) ? await raw : raw;
554
326
  if (!value || typeof value !== "object") {
555
327
  return null;
556
328
  }
557
329
  return value;
558
330
  }
559
- function isPromise(value) {
560
- return !!value && typeof value.then === "function";
561
- }
562
- function normalizeMiddlewares(value, source, logger, position) {
563
- if (!value) {
564
- return [];
565
- }
566
- const list = Array.isArray(value) ? value : [value];
567
- const middlewares = [];
568
- for (const [index, entry] of list.entries()) {
569
- if (typeof entry !== "function") {
570
- logger.warn(`Invalid middleware in ${source}`);
571
- continue;
572
- }
573
- middlewares.push({
574
- handle: entry,
331
+ async function resolveDirectoryConfig(params) {
332
+ const { file, rootDir, logger, configCache, fileCache } = params;
333
+ const resolved = await configUtils.resolveDirectoryConfig({
334
+ file,
335
+ rootDir,
336
+ configExtensions,
337
+ configCache,
338
+ fileCache,
339
+ loadConfig,
340
+ warn: (message) => logger.warn(message),
341
+ mapMiddleware: (handler, index, position, source) => ({
342
+ handle: handler,
575
343
  source,
576
344
  index,
577
345
  position
578
- });
579
- }
580
- return middlewares;
581
- }
582
- function readMiddlewareMeta(config) {
583
- const value = config[middlewareSymbol];
584
- if (!value || typeof value !== "object") {
585
- return null;
586
- }
587
- const meta = value;
588
- return {
589
- pre: Array.isArray(meta.pre) ? meta.pre : [],
590
- normal: Array.isArray(meta.normal) ? meta.normal : [],
591
- post: Array.isArray(meta.post) ? meta.post : []
592
- };
593
- }
594
- async function resolveDirectoryConfig(params) {
595
- const { file, rootDir, logger, configCache, fileCache } = params;
596
- const resolvedRoot = pathe.normalize(rootDir);
597
- const resolvedFileDir = pathe.normalize(pathe.dirname(file));
598
- const chain = [];
599
- let current = resolvedFileDir;
600
- while (true) {
601
- chain.push(current);
602
- if (current === resolvedRoot) {
603
- break;
604
- }
605
- const parent = pathe.dirname(current);
606
- if (parent === current) {
607
- break;
608
- }
609
- current = parent;
610
- }
611
- chain.reverse();
612
- const merged = {};
613
- const preMiddlewares = [];
614
- const normalMiddlewares = [];
615
- const postMiddlewares = [];
616
- for (const dir of chain) {
617
- const configPath = await findConfigFile(dir, fileCache);
618
- if (!configPath) {
619
- continue;
620
- }
621
- let config = configCache.get(configPath);
622
- if (config === void 0) {
623
- config = await loadConfig(configPath, logger);
624
- configCache.set(configPath, config);
625
- }
626
- if (!config) {
627
- logger.warn(`Invalid config in ${configPath}`);
628
- continue;
629
- }
630
- if (config.headers) {
631
- merged.headers = { ...merged.headers ?? {}, ...config.headers };
632
- }
633
- if (typeof config.status === "number") {
634
- merged.status = config.status;
635
- }
636
- if (typeof config.delay === "number") {
637
- merged.delay = config.delay;
638
- }
639
- if (typeof config.enabled === "boolean") {
640
- merged.enabled = config.enabled;
641
- }
642
- if (typeof config.ignorePrefix !== "undefined") {
643
- merged.ignorePrefix = config.ignorePrefix;
644
- }
645
- if (typeof config.include !== "undefined") {
646
- merged.include = config.include;
647
- }
648
- if (typeof config.exclude !== "undefined") {
649
- merged.exclude = config.exclude;
650
- }
651
- const meta = readMiddlewareMeta(config);
652
- const normalizedPre = normalizeMiddlewares(
653
- meta?.pre,
654
- configPath,
655
- logger,
656
- "pre"
657
- );
658
- const normalizedNormal = normalizeMiddlewares(
659
- meta?.normal,
660
- configPath,
661
- logger,
662
- "normal"
663
- );
664
- const normalizedLegacy = normalizeMiddlewares(
665
- config.middleware,
666
- configPath,
667
- logger,
668
- "normal"
669
- );
670
- const normalizedPost = normalizeMiddlewares(
671
- meta?.post,
672
- configPath,
673
- logger,
674
- "post"
675
- );
676
- if (normalizedPre.length > 0) {
677
- preMiddlewares.push(...normalizedPre);
678
- }
679
- if (normalizedNormal.length > 0) {
680
- normalMiddlewares.push(...normalizedNormal);
681
- }
682
- if (normalizedLegacy.length > 0) {
683
- normalMiddlewares.push(...normalizedLegacy);
684
- }
685
- if (normalizedPost.length > 0) {
686
- postMiddlewares.push(...normalizedPost);
687
- }
688
- }
346
+ })
347
+ });
689
348
  return {
690
- ...merged,
691
- middlewares: [...preMiddlewares, ...normalMiddlewares, ...postMiddlewares]
349
+ headers: resolved.headers,
350
+ status: resolved.status,
351
+ delay: resolved.delay,
352
+ enabled: resolved.enabled,
353
+ ignorePrefix: resolved.ignorePrefix,
354
+ include: resolved.include,
355
+ exclude: resolved.exclude,
356
+ middlewares: resolved.middlewares
692
357
  };
693
358
  }
694
359
 
695
- async function walkDir(dir, rootDir, files) {
696
- const entries = await node_fs.promises.readdir(dir, { withFileTypes: true });
697
- for (const entry of entries) {
698
- if (entry.name === "node_modules" || entry.name === ".git") {
699
- continue;
700
- }
701
- const fullPath = pathe.join(dir, entry.name);
702
- if (entry.isDirectory()) {
703
- await walkDir(fullPath, rootDir, files);
704
- continue;
705
- }
706
- if (entry.isFile()) {
707
- files.push({ file: fullPath, rootDir });
708
- }
709
- }
710
- }
711
- async function exists(path) {
712
- try {
713
- await node_fs.promises.stat(path);
714
- return true;
715
- } catch {
716
- return false;
717
- }
718
- }
719
- async function collectFiles(dirs) {
720
- const files = [];
721
- for (const dir of dirs) {
722
- if (!await exists(dir)) {
723
- continue;
724
- }
725
- await walkDir(dir, dir, files);
726
- }
727
- return files;
728
- }
729
- function isConfigFile(file) {
730
- if (file.endsWith(".d.ts")) {
731
- return false;
732
- }
733
- const base = pathe.basename(file);
734
- if (!base.startsWith("index.config.")) {
735
- return false;
736
- }
737
- const ext = pathe.extname(file).toLowerCase();
738
- return configExtensions.includes(ext);
739
- }
740
- function isSupportedFile(file) {
741
- if (file.endsWith(".d.ts")) {
742
- return false;
743
- }
744
- if (isConfigFile(file)) {
745
- return false;
746
- }
747
- const ext = pathe.extname(file).toLowerCase();
748
- return supportedExtensions.has(ext);
360
+ async function loadRules(file, logger) {
361
+ return loadRules$1.loadRules(file, { loadModule: moduleLoader.loadModule, logger });
749
362
  }
750
363
 
751
- function isUnknownFileExtensionError(error) {
752
- if (!error || typeof error !== "object") {
753
- return false;
754
- }
755
- const code = error.code;
756
- if (code === "ERR_UNKNOWN_FILE_EXTENSION") {
757
- return true;
758
- }
759
- const message = error.message;
760
- return typeof message === "string" && message.includes("Unknown file extension");
761
- }
762
- async function loadTsModule(file, logger) {
763
- const cacheBust = Date.now();
764
- const fileUrl = `${node_url.pathToFileURL(file).href}?t=${cacheBust}`;
765
- const registered = await ensureTsxRegister(logger);
766
- if (registered) {
767
- try {
768
- return await import(fileUrl);
769
- } catch (error) {
770
- if (!isUnknownFileExtensionError(error)) {
771
- throw error;
772
- }
773
- }
774
- }
775
- const result = await esbuild.build({
776
- entryPoints: [file],
777
- bundle: true,
778
- format: "esm",
779
- platform: "node",
780
- sourcemap: "inline",
781
- target: "es2020",
782
- write: false
783
- });
784
- const output = result.outputFiles[0];
785
- const code = output?.text ?? "";
786
- const dataUrl = `data:text/javascript;base64,${node_buffer.Buffer.from(code).toString(
787
- "base64"
788
- )}`;
789
- return import(`${dataUrl}#${cacheBust}`);
790
- }
791
- async function loadModule(file, logger) {
792
- const ext = pathe.extname(file).toLowerCase();
793
- if (ext === ".cjs") {
794
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('fetch-server.cjs', document.baseURI).href)));
795
- delete require$1.cache[file];
796
- return require$1(file);
797
- }
798
- if (ext === ".js" || ext === ".mjs") {
799
- return import(`${node_url.pathToFileURL(file).href}?t=${Date.now()}`);
800
- }
801
- if (ext === ".ts") {
802
- return loadTsModule(file, logger);
803
- }
804
- return null;
805
- }
806
- async function readJsonFile(file, logger) {
807
- try {
808
- const content = await node_fs.promises.readFile(file, "utf8");
809
- const errors = [];
810
- const data = jsoncParser.parse(content, errors, {
811
- allowTrailingComma: true,
812
- disallowComments: false
813
- });
814
- if (errors.length > 0) {
815
- logger.warn(`Invalid JSONC in ${file}`);
816
- return void 0;
817
- }
818
- return data;
819
- } catch (error) {
820
- logger.warn(`Failed to read ${file}: ${String(error)}`);
821
- return void 0;
822
- }
823
- }
824
- async function loadRules(file, logger) {
825
- const ext = pathe.extname(file).toLowerCase();
826
- if (ext === ".json" || ext === ".jsonc") {
827
- const json = await readJsonFile(file, logger);
828
- if (typeof json === "undefined") {
829
- return [];
830
- }
831
- return [
832
- {
833
- handler: json
834
- }
835
- ];
836
- }
837
- const mod = await loadModule(file, logger);
838
- const value = mod?.default ?? mod;
839
- if (!value) {
840
- return [];
841
- }
842
- if (Array.isArray(value)) {
843
- return value;
844
- }
845
- if (typeof value === "function") {
846
- return [
847
- {
848
- handler: value
849
- }
850
- ];
851
- }
852
- return [value];
364
+ function resolveDirs(dir, root) {
365
+ return scanUtils.resolveDirs(dir, root);
853
366
  }
367
+ const normalizeIgnorePrefix = scanUtils.normalizeIgnorePrefix;
854
368
 
855
369
  const silentLogger = {
856
370
  info: () => {
@@ -894,7 +408,7 @@ function buildSkipInfo(file, reason, resolved) {
894
408
  async function scanRoutes(params) {
895
409
  const routes = [];
896
410
  const seen = /* @__PURE__ */ new Set();
897
- const files = await collectFiles(params.dirs);
411
+ const files = await mockFiles.collectFiles(params.dirs);
898
412
  const globalIgnorePrefix = normalizeIgnorePrefix(params.ignorePrefix);
899
413
  const configCache = /* @__PURE__ */ new Map();
900
414
  const fileCache = /* @__PURE__ */ new Map();
@@ -902,7 +416,7 @@ async function scanRoutes(params) {
902
416
  const shouldCollectIgnore = typeof params.onIgnore === "function";
903
417
  const shouldCollectConfig = typeof params.onConfig === "function";
904
418
  for (const fileInfo of files) {
905
- if (isConfigFile(fileInfo.file)) {
419
+ if (mockFiles.isConfigFile(fileInfo.file)) {
906
420
  if (shouldCollectConfig) {
907
421
  const config2 = await resolveDirectoryConfig({
908
422
  file: fileInfo.file,
@@ -923,7 +437,7 @@ async function scanRoutes(params) {
923
437
  fileCache
924
438
  });
925
439
  if (config.enabled === false) {
926
- if (shouldCollectSkip && isSupportedFile(fileInfo.file)) {
440
+ if (shouldCollectSkip && mockFiles.isSupportedFile(fileInfo.file)) {
927
441
  const resolved = resolveSkipRoute({
928
442
  file: fileInfo.file,
929
443
  rootDir: fileInfo.rootDir,
@@ -935,7 +449,7 @@ async function scanRoutes(params) {
935
449
  }
936
450
  const effectiveIgnorePrefix = typeof config.ignorePrefix !== "undefined" ? normalizeIgnorePrefix(config.ignorePrefix, []) : globalIgnorePrefix;
937
451
  if (pathUtils.hasIgnoredPrefix(fileInfo.file, fileInfo.rootDir, effectiveIgnorePrefix)) {
938
- if (shouldCollectSkip && isSupportedFile(fileInfo.file)) {
452
+ if (shouldCollectSkip && mockFiles.isSupportedFile(fileInfo.file)) {
939
453
  const resolved = resolveSkipRoute({
940
454
  file: fileInfo.file,
941
455
  rootDir: fileInfo.rootDir,
@@ -945,7 +459,7 @@ async function scanRoutes(params) {
945
459
  }
946
460
  continue;
947
461
  }
948
- if (!isSupportedFile(fileInfo.file)) {
462
+ if (!mockFiles.isSupportedFile(fileInfo.file)) {
949
463
  if (shouldCollectIgnore) {
950
464
  params.onIgnore?.({ file: fileInfo.file, reason: "unsupported" });
951
465
  }
@@ -1239,7 +753,7 @@ function resolveRoot(list) {
1239
753
  if (deno?.cwd) {
1240
754
  return deno.cwd();
1241
755
  }
1242
- return process.cwd();
756
+ return node_process.cwd();
1243
757
  }
1244
758
  function resolveAllDirs(list, root) {
1245
759
  const dirs = [];