mokup 2.0.0 → 2.0.2

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.
@@ -2,4 +2,6 @@
2
2
  import '@mokup/cli';
3
3
  import '@mokup/runtime';
4
4
  import '@mokup/server';
5
+ import '@mokup/server/fetch';
6
+ import '@mokup/server/node';
5
7
  import '@mokup/server/worker';
@@ -2,4 +2,6 @@
2
2
  import '@mokup/cli';
3
3
  import '@mokup/runtime';
4
4
  import '@mokup/server';
5
+ import '@mokup/server/fetch';
6
+ import '@mokup/server/node';
5
7
  import '@mokup/server/worker';
package/dist/cli-bin.d.ts CHANGED
@@ -2,4 +2,6 @@
2
2
  import '@mokup/cli';
3
3
  import '@mokup/runtime';
4
4
  import '@mokup/server';
5
+ import '@mokup/server/fetch';
6
+ import '@mokup/server/node';
5
7
  import '@mokup/server/worker';
package/dist/index.d.cts CHANGED
@@ -1,9 +1,13 @@
1
+ import { MockEntryOptions, PlaygroundOptionsInput } from '@mokup/shared';
2
+ export { PlaygroundOptionsInput } from '@mokup/shared';
1
3
  import { Context, MiddlewareHandler } from '@mokup/shared/hono';
2
4
  export { Context, MiddlewareHandler } from '@mokup/shared/hono';
3
5
 
4
6
  type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
5
- type RequestHandler = (context: Context) => Response | Promise<Response> | unknown;
6
- type RouteResponse = unknown | RequestHandler;
7
+ type RouteStaticResponse = string | number | boolean | bigint | symbol | null | undefined | object;
8
+ type RouteHandlerResult = RouteStaticResponse | Response;
9
+ type RequestHandler = (context: Context) => RouteHandlerResult | Promise<RouteHandlerResult>;
10
+ type RouteResponse = RouteStaticResponse | RequestHandler;
7
11
  interface RouteRule {
8
12
  handler: RouteResponse;
9
13
  enabled?: boolean;
@@ -20,10 +24,7 @@ interface ServiceWorkerOptions {
20
24
  fallback?: boolean;
21
25
  basePath?: string | string[];
22
26
  }
23
- type PlaygroundOptionsInput = boolean | {
24
- path?: string;
25
- enabled?: boolean;
26
- } | undefined;
27
+
27
28
  interface RouteDirectoryConfig {
28
29
  headers?: Record<string, string>;
29
30
  status?: number;
@@ -34,14 +35,7 @@ interface RouteDirectoryConfig {
34
35
  exclude?: RegExp | RegExp[];
35
36
  middleware?: MiddlewareHandler | MiddlewareHandler[];
36
37
  }
37
- interface VitePluginOptions {
38
- dir?: string | string[] | ((root: string) => string | string[]);
39
- prefix?: string;
40
- include?: RegExp | RegExp[];
41
- exclude?: RegExp | RegExp[];
42
- ignorePrefix?: string | string[];
43
- watch?: boolean;
44
- log?: boolean;
38
+ interface VitePluginOptions extends MockEntryOptions {
45
39
  mode?: RuntimeMode;
46
40
  sw?: ServiceWorkerOptions;
47
41
  }
@@ -51,4 +45,4 @@ interface MokupPluginOptions {
51
45
  }
52
46
  type VitePluginOptionsInput = MokupPluginOptions;
53
47
 
54
- export type { HttpMethod, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput };
48
+ export type { HttpMethod, MokupPluginOptions, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput };
package/dist/index.d.mts CHANGED
@@ -1,9 +1,13 @@
1
+ import { MockEntryOptions, PlaygroundOptionsInput } from '@mokup/shared';
2
+ export { PlaygroundOptionsInput } from '@mokup/shared';
1
3
  import { Context, MiddlewareHandler } from '@mokup/shared/hono';
2
4
  export { Context, MiddlewareHandler } from '@mokup/shared/hono';
3
5
 
4
6
  type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
5
- type RequestHandler = (context: Context) => Response | Promise<Response> | unknown;
6
- type RouteResponse = unknown | RequestHandler;
7
+ type RouteStaticResponse = string | number | boolean | bigint | symbol | null | undefined | object;
8
+ type RouteHandlerResult = RouteStaticResponse | Response;
9
+ type RequestHandler = (context: Context) => RouteHandlerResult | Promise<RouteHandlerResult>;
10
+ type RouteResponse = RouteStaticResponse | RequestHandler;
7
11
  interface RouteRule {
8
12
  handler: RouteResponse;
9
13
  enabled?: boolean;
@@ -20,10 +24,7 @@ interface ServiceWorkerOptions {
20
24
  fallback?: boolean;
21
25
  basePath?: string | string[];
22
26
  }
23
- type PlaygroundOptionsInput = boolean | {
24
- path?: string;
25
- enabled?: boolean;
26
- } | undefined;
27
+
27
28
  interface RouteDirectoryConfig {
28
29
  headers?: Record<string, string>;
29
30
  status?: number;
@@ -34,14 +35,7 @@ interface RouteDirectoryConfig {
34
35
  exclude?: RegExp | RegExp[];
35
36
  middleware?: MiddlewareHandler | MiddlewareHandler[];
36
37
  }
37
- interface VitePluginOptions {
38
- dir?: string | string[] | ((root: string) => string | string[]);
39
- prefix?: string;
40
- include?: RegExp | RegExp[];
41
- exclude?: RegExp | RegExp[];
42
- ignorePrefix?: string | string[];
43
- watch?: boolean;
44
- log?: boolean;
38
+ interface VitePluginOptions extends MockEntryOptions {
45
39
  mode?: RuntimeMode;
46
40
  sw?: ServiceWorkerOptions;
47
41
  }
@@ -51,4 +45,4 @@ interface MokupPluginOptions {
51
45
  }
52
46
  type VitePluginOptionsInput = MokupPluginOptions;
53
47
 
54
- export type { HttpMethod, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput };
48
+ export type { HttpMethod, MokupPluginOptions, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,13 @@
1
+ import { MockEntryOptions, PlaygroundOptionsInput } from '@mokup/shared';
2
+ export { PlaygroundOptionsInput } from '@mokup/shared';
1
3
  import { Context, MiddlewareHandler } from '@mokup/shared/hono';
2
4
  export { Context, MiddlewareHandler } from '@mokup/shared/hono';
3
5
 
4
6
  type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
5
- type RequestHandler = (context: Context) => Response | Promise<Response> | unknown;
6
- type RouteResponse = unknown | RequestHandler;
7
+ type RouteStaticResponse = string | number | boolean | bigint | symbol | null | undefined | object;
8
+ type RouteHandlerResult = RouteStaticResponse | Response;
9
+ type RequestHandler = (context: Context) => RouteHandlerResult | Promise<RouteHandlerResult>;
10
+ type RouteResponse = RouteStaticResponse | RequestHandler;
7
11
  interface RouteRule {
8
12
  handler: RouteResponse;
9
13
  enabled?: boolean;
@@ -20,10 +24,7 @@ interface ServiceWorkerOptions {
20
24
  fallback?: boolean;
21
25
  basePath?: string | string[];
22
26
  }
23
- type PlaygroundOptionsInput = boolean | {
24
- path?: string;
25
- enabled?: boolean;
26
- } | undefined;
27
+
27
28
  interface RouteDirectoryConfig {
28
29
  headers?: Record<string, string>;
29
30
  status?: number;
@@ -34,14 +35,7 @@ interface RouteDirectoryConfig {
34
35
  exclude?: RegExp | RegExp[];
35
36
  middleware?: MiddlewareHandler | MiddlewareHandler[];
36
37
  }
37
- interface VitePluginOptions {
38
- dir?: string | string[] | ((root: string) => string | string[]);
39
- prefix?: string;
40
- include?: RegExp | RegExp[];
41
- exclude?: RegExp | RegExp[];
42
- ignorePrefix?: string | string[];
43
- watch?: boolean;
44
- log?: boolean;
38
+ interface VitePluginOptions extends MockEntryOptions {
45
39
  mode?: RuntimeMode;
46
40
  sw?: ServiceWorkerOptions;
47
41
  }
@@ -51,4 +45,4 @@ interface MokupPluginOptions {
51
45
  }
52
46
  type VitePluginOptionsInput = MokupPluginOptions;
53
47
 
54
- export type { HttpMethod, MokupPluginOptions, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput };
48
+ export type { HttpMethod, MokupPluginOptions, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const fetch = require('@mokup/server/fetch');
4
+
5
+
6
+
7
+ exports.createFetchHandler = fetch.createFetchHandler;
@@ -0,0 +1,2 @@
1
+ export { FetchHandler, Manifest, ManifestRoute, ModuleMap, RuntimeOptions, ServerOptions, WorkerBundle, WorkerInput } from '@mokup/server';
2
+ export { createFetchHandler } from '@mokup/server/fetch';
@@ -0,0 +1,2 @@
1
+ export { FetchHandler, Manifest, ManifestRoute, ModuleMap, RuntimeOptions, ServerOptions, WorkerBundle, WorkerInput } from '@mokup/server';
2
+ export { createFetchHandler } from '@mokup/server/fetch';
@@ -0,0 +1,2 @@
1
+ export { FetchHandler, Manifest, ManifestRoute, ModuleMap, RuntimeOptions, ServerOptions, WorkerBundle, WorkerInput } from '@mokup/server';
2
+ export { createFetchHandler } from '@mokup/server/fetch';
@@ -0,0 +1 @@
1
+ export { createFetchHandler } from '@mokup/server/fetch';
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const node = require('@mokup/server/node');
4
+
5
+
6
+
7
+ Object.prototype.hasOwnProperty.call(node, '__proto__') &&
8
+ !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
9
+ Object.defineProperty(exports, '__proto__', {
10
+ enumerable: true,
11
+ value: node['__proto__']
12
+ });
13
+
14
+ Object.keys(node).forEach(function (k) {
15
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = node[k];
16
+ });
@@ -0,0 +1 @@
1
+ export * from '@mokup/server/node';
@@ -0,0 +1 @@
1
+ export * from '@mokup/server/node';
@@ -0,0 +1 @@
1
+ export * from '@mokup/server/node';
@@ -0,0 +1 @@
1
+ export * from '@mokup/server/node';
package/dist/server.cjs CHANGED
@@ -1,16 +1,18 @@
1
1
  'use strict';
2
2
 
3
- const server = require('@mokup/server');
3
+ const fetch = require('@mokup/server/fetch');
4
+ const node = require('@mokup/server/node');
4
5
 
5
6
 
6
7
 
7
- Object.prototype.hasOwnProperty.call(server, '__proto__') &&
8
- !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
9
- Object.defineProperty(exports, '__proto__', {
10
- enumerable: true,
11
- value: server['__proto__']
12
- });
8
+ exports.createFetchHandler = fetch.createFetchHandler;
9
+ Object.prototype.hasOwnProperty.call(node, '__proto__') &&
10
+ !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
11
+ Object.defineProperty(exports, '__proto__', {
12
+ enumerable: true,
13
+ value: node['__proto__']
14
+ });
13
15
 
14
- Object.keys(server).forEach(function (k) {
15
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = server[k];
16
+ Object.keys(node).forEach(function (k) {
17
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = node[k];
16
18
  });
package/dist/server.d.cts CHANGED
@@ -1 +1,3 @@
1
- export * from '@mokup/server';
1
+ export { FetchHandler, Manifest, ManifestRoute, ModuleMap, RuntimeOptions, ServerOptions, WorkerBundle, WorkerInput } from '@mokup/server';
2
+ export { createFetchHandler } from '@mokup/server/fetch';
3
+ export * from '@mokup/server/node';
package/dist/server.d.mts CHANGED
@@ -1 +1,3 @@
1
- export * from '@mokup/server';
1
+ export { FetchHandler, Manifest, ManifestRoute, ModuleMap, RuntimeOptions, ServerOptions, WorkerBundle, WorkerInput } from '@mokup/server';
2
+ export { createFetchHandler } from '@mokup/server/fetch';
3
+ export * from '@mokup/server/node';
package/dist/server.d.ts CHANGED
@@ -1 +1,3 @@
1
- export * from '@mokup/server';
1
+ export { FetchHandler, Manifest, ManifestRoute, ModuleMap, RuntimeOptions, ServerOptions, WorkerBundle, WorkerInput } from '@mokup/server';
2
+ export { createFetchHandler } from '@mokup/server/fetch';
3
+ export * from '@mokup/server/node';
package/dist/server.mjs CHANGED
@@ -1 +1,2 @@
1
- export * from '@mokup/server';
1
+ export { createFetchHandler } from '@mokup/server/fetch';
2
+ export * from '@mokup/server/node';
@@ -52,6 +52,7 @@ const supportedExtensions = /* @__PURE__ */ new Set([
52
52
  ".mjs",
53
53
  ".cjs"
54
54
  ]);
55
+ const configExtensions = [".ts", ".js", ".mjs", ".cjs"];
55
56
 
56
57
  function normalizeMethod(method) {
57
58
  if (!method) {
@@ -350,7 +351,7 @@ function createMiddleware(getApp, logger) {
350
351
  };
351
352
  }
352
353
 
353
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/mokup.CvPjMpMJ.cjs', document.baseURI).href)));
354
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/mokup.B-yfMz5B.cjs', document.baseURI).href)));
354
355
  const mimeTypes = {
355
356
  ".html": "text/html; charset=utf-8",
356
357
  ".css": "text/css; charset=utf-8",
@@ -516,12 +517,23 @@ const disabledReasonSet = /* @__PURE__ */ new Set([
516
517
  "include",
517
518
  "unknown"
518
519
  ]);
520
+ const ignoredReasonSet = /* @__PURE__ */ new Set([
521
+ "unsupported",
522
+ "invalid-route",
523
+ "unknown"
524
+ ]);
519
525
  function normalizeDisabledReason(reason) {
520
526
  if (reason && disabledReasonSet.has(reason)) {
521
527
  return reason;
522
528
  }
523
529
  return "unknown";
524
530
  }
531
+ function normalizeIgnoredReason(reason) {
532
+ if (reason && ignoredReasonSet.has(reason)) {
533
+ return reason;
534
+ }
535
+ return "unknown";
536
+ }
525
537
  function formatRouteFile(file, root) {
526
538
  if (!root) {
527
539
  return toPosixPath(file);
@@ -600,6 +612,29 @@ function toPlaygroundDisabledRoute(route, root, groups) {
600
612
  }
601
613
  return disabled;
602
614
  }
615
+ function toPlaygroundIgnoredRoute(route, root, groups) {
616
+ const matchedGroup = resolveRouteGroup(route.file, groups);
617
+ const ignored = {
618
+ file: formatRouteFile(route.file, root),
619
+ reason: normalizeIgnoredReason(route.reason)
620
+ };
621
+ if (matchedGroup) {
622
+ ignored.groupKey = matchedGroup.key;
623
+ ignored.group = matchedGroup.label;
624
+ }
625
+ return ignored;
626
+ }
627
+ function toPlaygroundConfigFile(entry, root, groups) {
628
+ const matchedGroup = resolveRouteGroup(entry.file, groups);
629
+ const configFile = {
630
+ file: formatRouteFile(entry.file, root)
631
+ };
632
+ if (matchedGroup) {
633
+ configFile.groupKey = matchedGroup.key;
634
+ configFile.group = matchedGroup.label;
635
+ }
636
+ return configFile;
637
+ }
603
638
  function createPlaygroundMiddleware(params) {
604
639
  const distDir = resolvePlaygroundDist();
605
640
  const playgroundPath = params.config.path;
@@ -648,13 +683,19 @@ function createPlaygroundMiddleware(params) {
648
683
  const groups = resolveGroups(dirs, baseRoot);
649
684
  const routes = params.getRoutes();
650
685
  const disabledRoutes = params.getDisabledRoutes?.() ?? [];
686
+ const ignoredRoutes = params.getIgnoredRoutes?.() ?? [];
687
+ const configFiles = params.getConfigFiles?.() ?? [];
688
+ const disabledConfigFiles = params.getDisabledConfigFiles?.() ?? [];
651
689
  sendJson(res, {
652
690
  basePath: matchedPath,
653
691
  root: baseRoot,
654
692
  count: routes.length,
655
693
  groups: groups.map((group) => ({ key: group.key, label: group.label })),
656
694
  routes: routes.map((route) => toPlaygroundRoute(route, baseRoot, groups)),
657
- disabled: disabledRoutes.map((route) => toPlaygroundDisabledRoute(route, baseRoot, groups))
695
+ disabled: disabledRoutes.map((route) => toPlaygroundDisabledRoute(route, baseRoot, groups)),
696
+ ignored: ignoredRoutes.map((route) => toPlaygroundIgnoredRoute(route, baseRoot, groups)),
697
+ configs: configFiles.map((entry) => toPlaygroundConfigFile(entry, baseRoot, groups)),
698
+ disabledConfigs: disabledConfigFiles.map((entry) => toPlaygroundConfigFile(entry, baseRoot, groups))
658
699
  });
659
700
  return;
660
701
  }
@@ -798,11 +839,10 @@ function sortRoutes(routes) {
798
839
  });
799
840
  }
800
841
 
801
- const configExtensions = [".ts", ".js", ".mjs", ".cjs"];
802
842
  async function loadModule$1(file) {
803
843
  const ext = configExtensions.find((extension) => file.endsWith(extension));
804
844
  if (ext === ".cjs") {
805
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/mokup.CvPjMpMJ.cjs', document.baseURI).href)));
845
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/mokup.B-yfMz5B.cjs', document.baseURI).href)));
806
846
  delete require$1.cache[file];
807
847
  return require$1(file);
808
848
  }
@@ -985,17 +1025,28 @@ function isSupportedFile(file) {
985
1025
  if (file.endsWith(".d.ts")) {
986
1026
  return false;
987
1027
  }
988
- if (pathe.basename(file).startsWith("index.config.")) {
1028
+ if (isConfigFile(file)) {
989
1029
  return false;
990
1030
  }
991
1031
  const ext = pathe.extname(file).toLowerCase();
992
1032
  return supportedExtensions.has(ext);
993
1033
  }
1034
+ function isConfigFile(file) {
1035
+ if (file.endsWith(".d.ts")) {
1036
+ return false;
1037
+ }
1038
+ const base = pathe.basename(file);
1039
+ if (!base.startsWith("index.config.")) {
1040
+ return false;
1041
+ }
1042
+ const ext = pathe.extname(file).toLowerCase();
1043
+ return configExtensions.includes(ext);
1044
+ }
994
1045
 
995
1046
  async function loadModule(file) {
996
1047
  const ext = pathe.extname(file).toLowerCase();
997
1048
  if (ext === ".cjs") {
998
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/mokup.CvPjMpMJ.cjs', document.baseURI).href)));
1049
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/mokup.B-yfMz5B.cjs', document.baseURI).href)));
999
1050
  delete require$1.cache[file];
1000
1051
  return require$1(file);
1001
1052
  }
@@ -1126,7 +1177,23 @@ async function scanRoutes(params) {
1126
1177
  const configCache = /* @__PURE__ */ new Map();
1127
1178
  const fileCache = /* @__PURE__ */ new Map();
1128
1179
  const shouldCollectSkip = typeof params.onSkip === "function";
1180
+ const shouldCollectIgnore = typeof params.onIgnore === "function";
1181
+ const shouldCollectConfig = typeof params.onConfig === "function";
1129
1182
  for (const fileInfo of files) {
1183
+ if (isConfigFile(fileInfo.file)) {
1184
+ if (shouldCollectConfig) {
1185
+ const config2 = await resolveDirectoryConfig({
1186
+ file: fileInfo.file,
1187
+ rootDir: fileInfo.rootDir,
1188
+ server: params.server,
1189
+ logger: params.logger,
1190
+ configCache,
1191
+ fileCache
1192
+ });
1193
+ params.onConfig?.({ file: fileInfo.file, enabled: config2.enabled !== false });
1194
+ }
1195
+ continue;
1196
+ }
1130
1197
  const configParams = {
1131
1198
  file: fileInfo.file,
1132
1199
  rootDir: fileInfo.rootDir,
@@ -1162,6 +1229,9 @@ async function scanRoutes(params) {
1162
1229
  continue;
1163
1230
  }
1164
1231
  if (!isSupportedFile(fileInfo.file)) {
1232
+ if (shouldCollectIgnore) {
1233
+ params.onIgnore?.({ file: fileInfo.file, reason: "unsupported" });
1234
+ }
1165
1235
  continue;
1166
1236
  }
1167
1237
  const effectiveInclude = typeof config.include !== "undefined" ? config.include : params.include;
@@ -1180,6 +1250,9 @@ async function scanRoutes(params) {
1180
1250
  }
1181
1251
  const derived = deriveRouteFromFile(fileInfo.file, fileInfo.rootDir, params.logger);
1182
1252
  if (!derived) {
1253
+ if (shouldCollectIgnore) {
1254
+ params.onIgnore?.({ file: fileInfo.file, reason: "invalid-route" });
1255
+ }
1183
1256
  continue;
1184
1257
  }
1185
1258
  const rules = await loadRules(fileInfo.file, params.server, params.logger);
@@ -49,6 +49,7 @@ const supportedExtensions = /* @__PURE__ */ new Set([
49
49
  ".mjs",
50
50
  ".cjs"
51
51
  ]);
52
+ const configExtensions = [".ts", ".js", ".mjs", ".cjs"];
52
53
 
53
54
  function normalizeMethod(method) {
54
55
  if (!method) {
@@ -513,12 +514,23 @@ const disabledReasonSet = /* @__PURE__ */ new Set([
513
514
  "include",
514
515
  "unknown"
515
516
  ]);
517
+ const ignoredReasonSet = /* @__PURE__ */ new Set([
518
+ "unsupported",
519
+ "invalid-route",
520
+ "unknown"
521
+ ]);
516
522
  function normalizeDisabledReason(reason) {
517
523
  if (reason && disabledReasonSet.has(reason)) {
518
524
  return reason;
519
525
  }
520
526
  return "unknown";
521
527
  }
528
+ function normalizeIgnoredReason(reason) {
529
+ if (reason && ignoredReasonSet.has(reason)) {
530
+ return reason;
531
+ }
532
+ return "unknown";
533
+ }
522
534
  function formatRouteFile(file, root) {
523
535
  if (!root) {
524
536
  return toPosixPath(file);
@@ -597,6 +609,29 @@ function toPlaygroundDisabledRoute(route, root, groups) {
597
609
  }
598
610
  return disabled;
599
611
  }
612
+ function toPlaygroundIgnoredRoute(route, root, groups) {
613
+ const matchedGroup = resolveRouteGroup(route.file, groups);
614
+ const ignored = {
615
+ file: formatRouteFile(route.file, root),
616
+ reason: normalizeIgnoredReason(route.reason)
617
+ };
618
+ if (matchedGroup) {
619
+ ignored.groupKey = matchedGroup.key;
620
+ ignored.group = matchedGroup.label;
621
+ }
622
+ return ignored;
623
+ }
624
+ function toPlaygroundConfigFile(entry, root, groups) {
625
+ const matchedGroup = resolveRouteGroup(entry.file, groups);
626
+ const configFile = {
627
+ file: formatRouteFile(entry.file, root)
628
+ };
629
+ if (matchedGroup) {
630
+ configFile.groupKey = matchedGroup.key;
631
+ configFile.group = matchedGroup.label;
632
+ }
633
+ return configFile;
634
+ }
600
635
  function createPlaygroundMiddleware(params) {
601
636
  const distDir = resolvePlaygroundDist();
602
637
  const playgroundPath = params.config.path;
@@ -645,13 +680,19 @@ function createPlaygroundMiddleware(params) {
645
680
  const groups = resolveGroups(dirs, baseRoot);
646
681
  const routes = params.getRoutes();
647
682
  const disabledRoutes = params.getDisabledRoutes?.() ?? [];
683
+ const ignoredRoutes = params.getIgnoredRoutes?.() ?? [];
684
+ const configFiles = params.getConfigFiles?.() ?? [];
685
+ const disabledConfigFiles = params.getDisabledConfigFiles?.() ?? [];
648
686
  sendJson(res, {
649
687
  basePath: matchedPath,
650
688
  root: baseRoot,
651
689
  count: routes.length,
652
690
  groups: groups.map((group) => ({ key: group.key, label: group.label })),
653
691
  routes: routes.map((route) => toPlaygroundRoute(route, baseRoot, groups)),
654
- disabled: disabledRoutes.map((route) => toPlaygroundDisabledRoute(route, baseRoot, groups))
692
+ disabled: disabledRoutes.map((route) => toPlaygroundDisabledRoute(route, baseRoot, groups)),
693
+ ignored: ignoredRoutes.map((route) => toPlaygroundIgnoredRoute(route, baseRoot, groups)),
694
+ configs: configFiles.map((entry) => toPlaygroundConfigFile(entry, baseRoot, groups)),
695
+ disabledConfigs: disabledConfigFiles.map((entry) => toPlaygroundConfigFile(entry, baseRoot, groups))
655
696
  });
656
697
  return;
657
698
  }
@@ -795,7 +836,6 @@ function sortRoutes(routes) {
795
836
  });
796
837
  }
797
838
 
798
- const configExtensions = [".ts", ".js", ".mjs", ".cjs"];
799
839
  async function loadModule$1(file) {
800
840
  const ext = configExtensions.find((extension) => file.endsWith(extension));
801
841
  if (ext === ".cjs") {
@@ -982,12 +1022,23 @@ function isSupportedFile(file) {
982
1022
  if (file.endsWith(".d.ts")) {
983
1023
  return false;
984
1024
  }
985
- if (basename(file).startsWith("index.config.")) {
1025
+ if (isConfigFile(file)) {
986
1026
  return false;
987
1027
  }
988
1028
  const ext = extname(file).toLowerCase();
989
1029
  return supportedExtensions.has(ext);
990
1030
  }
1031
+ function isConfigFile(file) {
1032
+ if (file.endsWith(".d.ts")) {
1033
+ return false;
1034
+ }
1035
+ const base = basename(file);
1036
+ if (!base.startsWith("index.config.")) {
1037
+ return false;
1038
+ }
1039
+ const ext = extname(file).toLowerCase();
1040
+ return configExtensions.includes(ext);
1041
+ }
991
1042
 
992
1043
  async function loadModule(file) {
993
1044
  const ext = extname(file).toLowerCase();
@@ -1123,7 +1174,23 @@ async function scanRoutes(params) {
1123
1174
  const configCache = /* @__PURE__ */ new Map();
1124
1175
  const fileCache = /* @__PURE__ */ new Map();
1125
1176
  const shouldCollectSkip = typeof params.onSkip === "function";
1177
+ const shouldCollectIgnore = typeof params.onIgnore === "function";
1178
+ const shouldCollectConfig = typeof params.onConfig === "function";
1126
1179
  for (const fileInfo of files) {
1180
+ if (isConfigFile(fileInfo.file)) {
1181
+ if (shouldCollectConfig) {
1182
+ const config2 = await resolveDirectoryConfig({
1183
+ file: fileInfo.file,
1184
+ rootDir: fileInfo.rootDir,
1185
+ server: params.server,
1186
+ logger: params.logger,
1187
+ configCache,
1188
+ fileCache
1189
+ });
1190
+ params.onConfig?.({ file: fileInfo.file, enabled: config2.enabled !== false });
1191
+ }
1192
+ continue;
1193
+ }
1127
1194
  const configParams = {
1128
1195
  file: fileInfo.file,
1129
1196
  rootDir: fileInfo.rootDir,
@@ -1159,6 +1226,9 @@ async function scanRoutes(params) {
1159
1226
  continue;
1160
1227
  }
1161
1228
  if (!isSupportedFile(fileInfo.file)) {
1229
+ if (shouldCollectIgnore) {
1230
+ params.onIgnore?.({ file: fileInfo.file, reason: "unsupported" });
1231
+ }
1162
1232
  continue;
1163
1233
  }
1164
1234
  const effectiveInclude = typeof config.include !== "undefined" ? config.include : params.include;
@@ -1177,6 +1247,9 @@ async function scanRoutes(params) {
1177
1247
  }
1178
1248
  const derived = deriveRouteFromFile(fileInfo.file, fileInfo.rootDir, params.logger);
1179
1249
  if (!derived) {
1250
+ if (shouldCollectIgnore) {
1251
+ params.onIgnore?.({ file: fileInfo.file, reason: "invalid-route" });
1252
+ }
1180
1253
  continue;
1181
1254
  }
1182
1255
  const rules = await loadRules(fileInfo.file, params.server, params.logger);
package/dist/vite.cjs CHANGED
@@ -5,7 +5,7 @@ const node_path = require('node:path');
5
5
  const process = require('node:process');
6
6
  const node_url = require('node:url');
7
7
  const chokidar = require('@mokup/shared/chokidar');
8
- const sw = require('./shared/mokup.CvPjMpMJ.cjs');
8
+ const sw = require('./shared/mokup.B-yfMz5B.cjs');
9
9
  require('node:buffer');
10
10
  require('@mokup/shared/hono');
11
11
  require('node:module');
@@ -19,7 +19,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
19
19
 
20
20
  const chokidar__default = /*#__PURE__*/_interopDefaultCompat(chokidar);
21
21
 
22
- function buildRouteSignature(routes, disabledRoutes) {
22
+ function buildRouteSignature(routes, disabledRoutes, ignoredRoutes, configFiles, disabledConfigFiles) {
23
23
  return routes.map(
24
24
  (route) => [
25
25
  route.method,
@@ -38,6 +38,17 @@ function buildRouteSignature(routes, disabledRoutes) {
38
38
  route.url ?? ""
39
39
  ].join("|")
40
40
  )
41
+ ).concat(
42
+ ignoredRoutes.map(
43
+ (route) => [
44
+ route.reason,
45
+ route.file
46
+ ].join("|")
47
+ )
48
+ ).concat(
49
+ configFiles.map((route) => route.file)
50
+ ).concat(
51
+ disabledConfigFiles.map((route) => route.file)
41
52
  ).join("\n");
42
53
  }
43
54
  function isViteDevServer(server) {
@@ -167,6 +178,9 @@ function createMokupPlugin(options = {}) {
167
178
  let serverRoutes = [];
168
179
  let swRoutes = [];
169
180
  let disabledRoutes = [];
181
+ let ignoredRoutes = [];
182
+ let configFiles = [];
183
+ let disabledConfigFiles = [];
170
184
  let app = null;
171
185
  let previewWatcher = null;
172
186
  let currentServer = null;
@@ -264,6 +278,9 @@ function createMokupPlugin(options = {}) {
264
278
  const playgroundMiddleware = sw.createPlaygroundMiddleware({
265
279
  getRoutes: () => routes,
266
280
  getDisabledRoutes: () => disabledRoutes,
281
+ getIgnoredRoutes: () => ignoredRoutes,
282
+ getConfigFiles: () => configFiles,
283
+ getDisabledConfigFiles: () => disabledConfigFiles,
267
284
  config: playgroundConfig,
268
285
  logger,
269
286
  getServer: () => currentServer,
@@ -275,13 +292,17 @@ function createMokupPlugin(options = {}) {
275
292
  const collectedServer = [];
276
293
  const collectedSw = [];
277
294
  const collectedDisabled = [];
295
+ const collectedIgnored = [];
296
+ const collectedConfigs = [];
278
297
  for (const entry of optionList) {
279
298
  const dirs = sw.resolveDirs(entry.dir, root);
280
299
  const scanParams = {
281
300
  dirs,
282
301
  prefix: entry.prefix ?? "",
283
302
  logger,
284
- onSkip: (info) => collectedDisabled.push(info)
303
+ onSkip: (info) => collectedDisabled.push(info),
304
+ onIgnore: (info) => collectedIgnored.push(info),
305
+ onConfig: (info) => collectedConfigs.push(info)
285
306
  };
286
307
  if (entry.include) {
287
308
  scanParams.include = entry.include;
@@ -310,8 +331,19 @@ function createMokupPlugin(options = {}) {
310
331
  serverRoutes = sw.sortRoutes(collectedServer);
311
332
  swRoutes = sw.sortRoutes(collectedSw);
312
333
  disabledRoutes = collectedDisabled;
334
+ ignoredRoutes = collectedIgnored;
335
+ const configMap = new Map(collectedConfigs.map((entry) => [entry.file, entry]));
336
+ const resolvedConfigs = Array.from(configMap.values());
337
+ configFiles = resolvedConfigs.filter((entry) => entry.enabled);
338
+ disabledConfigFiles = resolvedConfigs.filter((entry) => !entry.enabled);
313
339
  app = serverRoutes.length > 0 ? sw.createHonoApp(serverRoutes) : null;
314
- const signature = buildRouteSignature(routes, disabledRoutes);
340
+ const signature = buildRouteSignature(
341
+ routes,
342
+ disabledRoutes,
343
+ ignoredRoutes,
344
+ configFiles,
345
+ disabledConfigFiles
346
+ );
315
347
  if (isViteDevServer(server) && server.ws) {
316
348
  if (lastSignature && signature !== lastSignature) {
317
349
  server.ws.send({
package/dist/vite.d.cts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Plugin } from 'vite';
2
2
  import { MokupPluginOptions } from './index.cjs';
3
- export { HttpMethod, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.cjs';
3
+ export { HttpMethod, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.cjs';
4
4
  export { Context, MiddlewareHandler } from '@mokup/shared/hono';
5
+ export { PlaygroundOptionsInput } from '@mokup/shared';
5
6
 
6
7
  declare function createMokupPlugin(options?: MokupPluginOptions): Plugin;
7
8
 
package/dist/vite.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Plugin } from 'vite';
2
2
  import { MokupPluginOptions } from './index.mjs';
3
- export { HttpMethod, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.mjs';
3
+ export { HttpMethod, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.mjs';
4
4
  export { Context, MiddlewareHandler } from '@mokup/shared/hono';
5
+ export { PlaygroundOptionsInput } from '@mokup/shared';
5
6
 
6
7
  declare function createMokupPlugin(options?: MokupPluginOptions): Plugin;
7
8
 
package/dist/vite.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Plugin } from 'vite';
2
2
  import { MokupPluginOptions } from './index.js';
3
- export { HttpMethod, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.js';
3
+ export { HttpMethod, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.js';
4
4
  export { Context, MiddlewareHandler } from '@mokup/shared/hono';
5
+ export { PlaygroundOptionsInput } from '@mokup/shared';
5
6
 
6
7
  declare function createMokupPlugin(options?: MokupPluginOptions): Plugin;
7
8
 
package/dist/vite.mjs CHANGED
@@ -3,7 +3,7 @@ import { isAbsolute, resolve } from 'node:path';
3
3
  import { cwd } from 'node:process';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import chokidar from '@mokup/shared/chokidar';
6
- import { r as resolvePlaygroundOptions, a as resolveSwConfig, b as resolveSwUnregisterConfig, c as createPlaygroundMiddleware, d as buildSwScript, e as createLogger, f as createMiddleware, i as isInDirs, g as createDebouncer, h as resolveDirs, s as scanRoutes, j as sortRoutes, k as createHonoApp } from './shared/mokup.U2S5CHgY.mjs';
6
+ import { r as resolvePlaygroundOptions, a as resolveSwConfig, b as resolveSwUnregisterConfig, c as createPlaygroundMiddleware, d as buildSwScript, e as createLogger, f as createMiddleware, i as isInDirs, g as createDebouncer, h as resolveDirs, s as scanRoutes, j as sortRoutes, k as createHonoApp } from './shared/mokup.jeVwRMia.mjs';
7
7
  import 'node:buffer';
8
8
  import '@mokup/shared/hono';
9
9
  import 'node:module';
@@ -12,7 +12,7 @@ import '@mokup/shared/esbuild';
12
12
  import '@mokup/shared/jsonc-parser';
13
13
  import '@mokup/runtime';
14
14
 
15
- function buildRouteSignature(routes, disabledRoutes) {
15
+ function buildRouteSignature(routes, disabledRoutes, ignoredRoutes, configFiles, disabledConfigFiles) {
16
16
  return routes.map(
17
17
  (route) => [
18
18
  route.method,
@@ -31,6 +31,17 @@ function buildRouteSignature(routes, disabledRoutes) {
31
31
  route.url ?? ""
32
32
  ].join("|")
33
33
  )
34
+ ).concat(
35
+ ignoredRoutes.map(
36
+ (route) => [
37
+ route.reason,
38
+ route.file
39
+ ].join("|")
40
+ )
41
+ ).concat(
42
+ configFiles.map((route) => route.file)
43
+ ).concat(
44
+ disabledConfigFiles.map((route) => route.file)
34
45
  ).join("\n");
35
46
  }
36
47
  function isViteDevServer(server) {
@@ -160,6 +171,9 @@ function createMokupPlugin(options = {}) {
160
171
  let serverRoutes = [];
161
172
  let swRoutes = [];
162
173
  let disabledRoutes = [];
174
+ let ignoredRoutes = [];
175
+ let configFiles = [];
176
+ let disabledConfigFiles = [];
163
177
  let app = null;
164
178
  let previewWatcher = null;
165
179
  let currentServer = null;
@@ -257,6 +271,9 @@ function createMokupPlugin(options = {}) {
257
271
  const playgroundMiddleware = createPlaygroundMiddleware({
258
272
  getRoutes: () => routes,
259
273
  getDisabledRoutes: () => disabledRoutes,
274
+ getIgnoredRoutes: () => ignoredRoutes,
275
+ getConfigFiles: () => configFiles,
276
+ getDisabledConfigFiles: () => disabledConfigFiles,
260
277
  config: playgroundConfig,
261
278
  logger,
262
279
  getServer: () => currentServer,
@@ -268,13 +285,17 @@ function createMokupPlugin(options = {}) {
268
285
  const collectedServer = [];
269
286
  const collectedSw = [];
270
287
  const collectedDisabled = [];
288
+ const collectedIgnored = [];
289
+ const collectedConfigs = [];
271
290
  for (const entry of optionList) {
272
291
  const dirs = resolveDirs(entry.dir, root);
273
292
  const scanParams = {
274
293
  dirs,
275
294
  prefix: entry.prefix ?? "",
276
295
  logger,
277
- onSkip: (info) => collectedDisabled.push(info)
296
+ onSkip: (info) => collectedDisabled.push(info),
297
+ onIgnore: (info) => collectedIgnored.push(info),
298
+ onConfig: (info) => collectedConfigs.push(info)
278
299
  };
279
300
  if (entry.include) {
280
301
  scanParams.include = entry.include;
@@ -303,8 +324,19 @@ function createMokupPlugin(options = {}) {
303
324
  serverRoutes = sortRoutes(collectedServer);
304
325
  swRoutes = sortRoutes(collectedSw);
305
326
  disabledRoutes = collectedDisabled;
327
+ ignoredRoutes = collectedIgnored;
328
+ const configMap = new Map(collectedConfigs.map((entry) => [entry.file, entry]));
329
+ const resolvedConfigs = Array.from(configMap.values());
330
+ configFiles = resolvedConfigs.filter((entry) => entry.enabled);
331
+ disabledConfigFiles = resolvedConfigs.filter((entry) => !entry.enabled);
306
332
  app = serverRoutes.length > 0 ? createHonoApp(serverRoutes) : null;
307
- const signature = buildRouteSignature(routes, disabledRoutes);
333
+ const signature = buildRouteSignature(
334
+ routes,
335
+ disabledRoutes,
336
+ ignoredRoutes,
337
+ configFiles,
338
+ disabledConfigFiles
339
+ );
308
340
  if (isViteDevServer(server) && server.ws) {
309
341
  if (lastSignature && signature !== lastSignature) {
310
342
  server.ws.send({
package/dist/webpack.cjs CHANGED
@@ -7,7 +7,7 @@ const process = require('node:process');
7
7
  const chokidar = require('@mokup/shared/chokidar');
8
8
  const esbuild = require('@mokup/shared/esbuild');
9
9
  const pathe = require('@mokup/shared/pathe');
10
- const sw = require('./shared/mokup.CvPjMpMJ.cjs');
10
+ const sw = require('./shared/mokup.B-yfMz5B.cjs');
11
11
  require('node:buffer');
12
12
  require('@mokup/shared/hono');
13
13
  require('node:fs');
@@ -205,6 +205,9 @@ function createMokupWebpackPlugin(options = {}) {
205
205
  let serverRoutes = [];
206
206
  let swRoutes = [];
207
207
  let disabledRoutes = [];
208
+ let ignoredRoutes = [];
209
+ let configFiles = [];
210
+ let disabledConfigFiles = [];
208
211
  let app = null;
209
212
  let watcher = null;
210
213
  let watchingCompiler = null;
@@ -233,13 +236,17 @@ function createMokupWebpackPlugin(options = {}) {
233
236
  const collectedServer = [];
234
237
  const collectedSw = [];
235
238
  const collectedDisabled = [];
239
+ const collectedIgnored = [];
240
+ const collectedConfigs = [];
236
241
  for (const entry of optionList) {
237
242
  const dirs = sw.resolveDirs(entry.dir, root);
238
243
  const scanParams = {
239
244
  dirs,
240
245
  prefix: entry.prefix ?? "",
241
246
  logger,
242
- onSkip: (info) => collectedDisabled.push(info)
247
+ onSkip: (info) => collectedDisabled.push(info),
248
+ onIgnore: (info) => collectedIgnored.push(info),
249
+ onConfig: (info) => collectedConfigs.push(info)
243
250
  };
244
251
  if (entry.include) {
245
252
  scanParams.include = entry.include;
@@ -265,6 +272,11 @@ function createMokupWebpackPlugin(options = {}) {
265
272
  serverRoutes = sw.sortRoutes(collectedServer);
266
273
  swRoutes = sw.sortRoutes(collectedSw);
267
274
  disabledRoutes = collectedDisabled;
275
+ ignoredRoutes = collectedIgnored;
276
+ const configMap = new Map(collectedConfigs.map((entry) => [entry.file, entry]));
277
+ const resolvedConfigs = Array.from(configMap.values());
278
+ configFiles = resolvedConfigs.filter((entry) => entry.enabled);
279
+ disabledConfigFiles = resolvedConfigs.filter((entry) => !entry.enabled);
268
280
  app = serverRoutes.length > 0 ? sw.createHonoApp(serverRoutes) : null;
269
281
  };
270
282
  const rebuildBundles = async () => {
@@ -314,6 +326,9 @@ function createMokupWebpackPlugin(options = {}) {
314
326
  const playgroundMiddleware = sw.createPlaygroundMiddleware({
315
327
  getRoutes: () => routes,
316
328
  getDisabledRoutes: () => disabledRoutes,
329
+ getIgnoredRoutes: () => ignoredRoutes,
330
+ getConfigFiles: () => configFiles,
331
+ getDisabledConfigFiles: () => disabledConfigFiles,
317
332
  config: playgroundConfig,
318
333
  logger,
319
334
  getDirs: () => resolveAllDirs(),
@@ -1,7 +1,8 @@
1
1
  import { MokupPluginOptions } from './index.cjs';
2
- export { HttpMethod, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.cjs';
2
+ export { HttpMethod, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.cjs';
3
3
  import { IncomingMessage, ServerResponse } from 'node:http';
4
4
  export { Context, MiddlewareHandler } from '@mokup/shared/hono';
5
+ export { PlaygroundOptionsInput } from '@mokup/shared';
5
6
 
6
7
  interface WebpackPluginInstance {
7
8
  apply: (compiler: WebpackCompiler) => void;
@@ -1,7 +1,8 @@
1
1
  import { MokupPluginOptions } from './index.mjs';
2
- export { HttpMethod, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.mjs';
2
+ export { HttpMethod, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.mjs';
3
3
  import { IncomingMessage, ServerResponse } from 'node:http';
4
4
  export { Context, MiddlewareHandler } from '@mokup/shared/hono';
5
+ export { PlaygroundOptionsInput } from '@mokup/shared';
5
6
 
6
7
  interface WebpackPluginInstance {
7
8
  apply: (compiler: WebpackCompiler) => void;
package/dist/webpack.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { MokupPluginOptions } from './index.js';
2
- export { HttpMethod, PlaygroundOptionsInput, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.js';
2
+ export { HttpMethod, RequestHandler, RouteDirectoryConfig, RouteResponse, RouteRule, RuntimeMode, ServiceWorkerOptions, VitePluginOptions, VitePluginOptionsInput } from './index.js';
3
3
  import { IncomingMessage, ServerResponse } from 'node:http';
4
4
  export { Context, MiddlewareHandler } from '@mokup/shared/hono';
5
+ export { PlaygroundOptionsInput } from '@mokup/shared';
5
6
 
6
7
  interface WebpackPluginInstance {
7
8
  apply: (compiler: WebpackCompiler) => void;
package/dist/webpack.mjs CHANGED
@@ -3,7 +3,7 @@ import { cwd } from 'node:process';
3
3
  import chokidar from '@mokup/shared/chokidar';
4
4
  import { build } from '@mokup/shared/esbuild';
5
5
  import { isAbsolute, resolve } from '@mokup/shared/pathe';
6
- import { r as resolvePlaygroundOptions, a as resolveSwConfig, b as resolveSwUnregisterConfig, c as createPlaygroundMiddleware, e as createLogger, f as createMiddleware, i as isInDirs, g as createDebouncer, h as resolveDirs, s as scanRoutes, j as sortRoutes, k as createHonoApp, d as buildSwScript, t as toPosix } from './shared/mokup.U2S5CHgY.mjs';
6
+ import { r as resolvePlaygroundOptions, a as resolveSwConfig, b as resolveSwUnregisterConfig, c as createPlaygroundMiddleware, e as createLogger, f as createMiddleware, i as isInDirs, g as createDebouncer, h as resolveDirs, s as scanRoutes, j as sortRoutes, k as createHonoApp, d as buildSwScript, t as toPosix } from './shared/mokup.jeVwRMia.mjs';
7
7
  import 'node:buffer';
8
8
  import '@mokup/shared/hono';
9
9
  import 'node:fs';
@@ -196,6 +196,9 @@ function createMokupWebpackPlugin(options = {}) {
196
196
  let serverRoutes = [];
197
197
  let swRoutes = [];
198
198
  let disabledRoutes = [];
199
+ let ignoredRoutes = [];
200
+ let configFiles = [];
201
+ let disabledConfigFiles = [];
199
202
  let app = null;
200
203
  let watcher = null;
201
204
  let watchingCompiler = null;
@@ -224,13 +227,17 @@ function createMokupWebpackPlugin(options = {}) {
224
227
  const collectedServer = [];
225
228
  const collectedSw = [];
226
229
  const collectedDisabled = [];
230
+ const collectedIgnored = [];
231
+ const collectedConfigs = [];
227
232
  for (const entry of optionList) {
228
233
  const dirs = resolveDirs(entry.dir, root);
229
234
  const scanParams = {
230
235
  dirs,
231
236
  prefix: entry.prefix ?? "",
232
237
  logger,
233
- onSkip: (info) => collectedDisabled.push(info)
238
+ onSkip: (info) => collectedDisabled.push(info),
239
+ onIgnore: (info) => collectedIgnored.push(info),
240
+ onConfig: (info) => collectedConfigs.push(info)
234
241
  };
235
242
  if (entry.include) {
236
243
  scanParams.include = entry.include;
@@ -256,6 +263,11 @@ function createMokupWebpackPlugin(options = {}) {
256
263
  serverRoutes = sortRoutes(collectedServer);
257
264
  swRoutes = sortRoutes(collectedSw);
258
265
  disabledRoutes = collectedDisabled;
266
+ ignoredRoutes = collectedIgnored;
267
+ const configMap = new Map(collectedConfigs.map((entry) => [entry.file, entry]));
268
+ const resolvedConfigs = Array.from(configMap.values());
269
+ configFiles = resolvedConfigs.filter((entry) => entry.enabled);
270
+ disabledConfigFiles = resolvedConfigs.filter((entry) => !entry.enabled);
259
271
  app = serverRoutes.length > 0 ? createHonoApp(serverRoutes) : null;
260
272
  };
261
273
  const rebuildBundles = async () => {
@@ -305,6 +317,9 @@ function createMokupWebpackPlugin(options = {}) {
305
317
  const playgroundMiddleware = createPlaygroundMiddleware({
306
318
  getRoutes: () => routes,
307
319
  getDisabledRoutes: () => disabledRoutes,
320
+ getIgnoredRoutes: () => ignoredRoutes,
321
+ getConfigFiles: () => configFiles,
322
+ getDisabledConfigFiles: () => disabledConfigFiles,
308
323
  config: playgroundConfig,
309
324
  logger,
310
325
  getDirs: () => resolveAllDirs(),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mokup",
3
3
  "type": "module",
4
- "version": "2.0.0",
4
+ "version": "2.0.2",
5
5
  "description": "Mock utilities and Vite plugin for mokup.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://mokup.icebreaker.top",
@@ -26,6 +26,16 @@
26
26
  "import": "./dist/server.mjs",
27
27
  "require": "./dist/server.cjs"
28
28
  },
29
+ "./server/fetch": {
30
+ "types": "./dist/server/fetch.d.ts",
31
+ "import": "./dist/server/fetch.mjs",
32
+ "require": "./dist/server/fetch.cjs"
33
+ },
34
+ "./server/node": {
35
+ "types": "./dist/server/node.d.ts",
36
+ "import": "./dist/server/node.mjs",
37
+ "require": "./dist/server/node.cjs"
38
+ },
29
39
  "./server/worker": {
30
40
  "types": "./dist/server/worker.d.ts",
31
41
  "import": "./dist/server/worker.mjs",
@@ -81,14 +91,15 @@
81
91
  }
82
92
  },
83
93
  "dependencies": {
84
- "@mokup/cli": "1.0.3",
85
- "@mokup/playground": "0.0.9",
86
- "@mokup/runtime": "1.0.0",
87
- "@mokup/server": "1.1.0",
88
- "@mokup/shared": "1.0.0"
94
+ "@mokup/cli": "1.0.5",
95
+ "@mokup/playground": "0.0.10",
96
+ "@mokup/runtime": "1.0.2",
97
+ "@mokup/server": "1.1.2",
98
+ "@mokup/shared": "1.0.1"
89
99
  },
90
100
  "devDependencies": {
91
101
  "@types/node": "^25.0.10",
102
+ "tsd": "^0.33.0",
92
103
  "typescript": "^5.9.3",
93
104
  "unbuild": "^3.6.1",
94
105
  "vite": "^7.3.1"
@@ -97,6 +108,7 @@
97
108
  "build": "unbuild",
98
109
  "dev": "unbuild --stub",
99
110
  "lint": "eslint .",
111
+ "test:types": "tsd",
100
112
  "typecheck": "tsc -p tsconfig.json --noEmit"
101
113
  }
102
114
  }