@mokup/shared 1.1.0 → 1.1.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.
Files changed (71) hide show
  1. package/dist/config-core.cjs +9 -0
  2. package/dist/config-core.d.cts +4 -0
  3. package/dist/config-core.d.mts +4 -0
  4. package/dist/config-core.d.ts +4 -0
  5. package/dist/config-core.mjs +6 -0
  6. package/dist/config-utils.cjs +179 -0
  7. package/dist/config-utils.d.cts +62 -0
  8. package/dist/config-utils.d.mts +62 -0
  9. package/dist/config-utils.d.ts +62 -0
  10. package/dist/config-utils.mjs +171 -0
  11. package/dist/define-config.cjs +168 -0
  12. package/dist/define-config.d.cts +20 -0
  13. package/dist/define-config.d.mts +20 -0
  14. package/dist/define-config.d.ts +20 -0
  15. package/dist/define-config.mjs +166 -0
  16. package/dist/index.cjs +48 -0
  17. package/dist/index.d.cts +10 -98
  18. package/dist/index.d.mts +10 -98
  19. package/dist/index.d.ts +10 -98
  20. package/dist/index.mjs +18 -1
  21. package/dist/jsonc-utils.cjs +25 -0
  22. package/dist/jsonc-utils.d.cts +7 -0
  23. package/dist/jsonc-utils.d.mts +7 -0
  24. package/dist/jsonc-utils.d.ts +7 -0
  25. package/dist/jsonc-utils.mjs +23 -0
  26. package/dist/load-rules.cjs +39 -0
  27. package/dist/load-rules.d.cts +14 -0
  28. package/dist/load-rules.d.mts +14 -0
  29. package/dist/load-rules.d.ts +14 -0
  30. package/dist/load-rules.mjs +37 -0
  31. package/dist/mock-files.cjs +65 -0
  32. package/dist/mock-files.d.cts +10 -0
  33. package/dist/mock-files.d.mts +10 -0
  34. package/dist/mock-files.d.ts +10 -0
  35. package/dist/mock-files.mjs +61 -0
  36. package/dist/module-loader.cjs +93 -0
  37. package/dist/module-loader.d.cts +13 -0
  38. package/dist/module-loader.d.mts +13 -0
  39. package/dist/module-loader.d.ts +13 -0
  40. package/dist/module-loader.mjs +83 -0
  41. package/dist/path-utils.cjs +57 -0
  42. package/dist/path-utils.d.cts +7 -0
  43. package/dist/path-utils.d.mts +7 -0
  44. package/dist/path-utils.d.ts +7 -0
  45. package/dist/path-utils.mjs +51 -0
  46. package/dist/playground-grouping.cjs +95 -0
  47. package/dist/playground-grouping.d.cts +12 -0
  48. package/dist/playground-grouping.d.mts +12 -0
  49. package/dist/playground-grouping.d.ts +12 -0
  50. package/dist/playground-grouping.mjs +90 -0
  51. package/dist/route-constants.cjs +30 -0
  52. package/dist/route-constants.d.cts +7 -0
  53. package/dist/route-constants.d.mts +7 -0
  54. package/dist/route-constants.d.ts +7 -0
  55. package/dist/route-constants.mjs +24 -0
  56. package/dist/route-utils.cjs +126 -0
  57. package/dist/route-utils.d.cts +42 -0
  58. package/dist/route-utils.d.mts +42 -0
  59. package/dist/route-utils.d.ts +42 -0
  60. package/dist/route-utils.mjs +124 -0
  61. package/dist/scan-utils.cjs +39 -0
  62. package/dist/scan-utils.d.cts +114 -0
  63. package/dist/scan-utils.d.mts +114 -0
  64. package/dist/scan-utils.d.ts +114 -0
  65. package/dist/scan-utils.mjs +34 -0
  66. package/dist/timing.cjs +20 -0
  67. package/dist/timing.d.cts +4 -0
  68. package/dist/timing.d.mts +4 -0
  69. package/dist/timing.d.ts +4 -0
  70. package/dist/timing.mjs +17 -0
  71. package/package.json +81 -18
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ const middlewareSymbol = Symbol.for("mokup.config.middlewares");
4
+ function isPromise(value) {
5
+ return !!value && typeof value.then === "function";
6
+ }
7
+
8
+ exports.isPromise = isPromise;
9
+ exports.middlewareSymbol = middlewareSymbol;
@@ -0,0 +1,4 @@
1
+ declare const middlewareSymbol: unique symbol;
2
+ declare function isPromise<T = unknown>(value: T | Promise<T>): value is Promise<T>;
3
+
4
+ export { isPromise, middlewareSymbol };
@@ -0,0 +1,4 @@
1
+ declare const middlewareSymbol: unique symbol;
2
+ declare function isPromise<T = unknown>(value: T | Promise<T>): value is Promise<T>;
3
+
4
+ export { isPromise, middlewareSymbol };
@@ -0,0 +1,4 @@
1
+ declare const middlewareSymbol: unique symbol;
2
+ declare function isPromise<T = unknown>(value: T | Promise<T>): value is Promise<T>;
3
+
4
+ export { isPromise, middlewareSymbol };
@@ -0,0 +1,6 @@
1
+ const middlewareSymbol = Symbol.for("mokup.config.middlewares");
2
+ function isPromise(value) {
3
+ return !!value && typeof value.then === "function";
4
+ }
5
+
6
+ export { isPromise, middlewareSymbol };
@@ -0,0 +1,179 @@
1
+ 'use strict';
2
+
3
+ const node_fs = require('node:fs');
4
+ const configCore = require('./config-core.cjs');
5
+ const pathe = require('pathe');
6
+
7
+ function readMiddlewareMeta(config) {
8
+ const value = config[configCore.middlewareSymbol];
9
+ if (!value || typeof value !== "object") {
10
+ return null;
11
+ }
12
+ const meta = value;
13
+ return {
14
+ pre: Array.isArray(meta.pre) ? meta.pre : [],
15
+ normal: Array.isArray(meta.normal) ? meta.normal : [],
16
+ post: Array.isArray(meta.post) ? meta.post : []
17
+ };
18
+ }
19
+ function normalizeMiddlewareList(params) {
20
+ const { value, source, position, warn, map } = params;
21
+ if (!value) {
22
+ return [];
23
+ }
24
+ const list = Array.isArray(value) ? value : [value];
25
+ const middlewares = [];
26
+ list.forEach((entry, index) => {
27
+ if (typeof entry !== "function") {
28
+ warn?.(`Invalid middleware in ${source}`);
29
+ return;
30
+ }
31
+ middlewares.push(map(entry, index, position));
32
+ });
33
+ return middlewares;
34
+ }
35
+ function buildConfigChain(file, rootDir) {
36
+ const resolvedRoot = pathe.normalize(rootDir);
37
+ const resolvedFileDir = pathe.normalize(pathe.dirname(file));
38
+ const chain = [];
39
+ let current = resolvedFileDir;
40
+ while (true) {
41
+ chain.push(current);
42
+ if (current === resolvedRoot) {
43
+ break;
44
+ }
45
+ const parent = pathe.dirname(current);
46
+ if (parent === current) {
47
+ break;
48
+ }
49
+ current = parent;
50
+ }
51
+ chain.reverse();
52
+ return chain;
53
+ }
54
+ function getConfigFileCandidates(dir, extensions) {
55
+ return extensions.map((extension) => pathe.join(dir, `index.config${extension}`));
56
+ }
57
+ async function findConfigFile(dir, cache, extensions) {
58
+ const cached = cache.get(dir);
59
+ if (cached !== void 0) {
60
+ return cached;
61
+ }
62
+ for (const candidate of getConfigFileCandidates(dir, extensions)) {
63
+ try {
64
+ await node_fs.promises.stat(candidate);
65
+ cache.set(dir, candidate);
66
+ return candidate;
67
+ } catch {
68
+ continue;
69
+ }
70
+ }
71
+ cache.set(dir, null);
72
+ return null;
73
+ }
74
+ async function resolveDirectoryConfig(params) {
75
+ const { file, rootDir, configExtensions, configCache, fileCache, loadConfig, warn, mapMiddleware } = params;
76
+ const chain = buildConfigChain(file, rootDir);
77
+ const merged = {};
78
+ const preMiddlewares = [];
79
+ const normalMiddlewares = [];
80
+ const postMiddlewares = [];
81
+ const configChain = [];
82
+ const configSources = {};
83
+ for (const dir of chain) {
84
+ const configPath = await findConfigFile(dir, fileCache, configExtensions);
85
+ if (!configPath) {
86
+ continue;
87
+ }
88
+ let config = configCache.get(configPath);
89
+ if (config === void 0) {
90
+ config = await loadConfig(configPath);
91
+ configCache.set(configPath, config);
92
+ }
93
+ if (!config) {
94
+ warn?.(`Invalid config in ${configPath}`);
95
+ continue;
96
+ }
97
+ configChain.push(configPath);
98
+ if (config.headers) {
99
+ merged.headers = { ...merged.headers ?? {}, ...config.headers };
100
+ configSources.headers = configPath;
101
+ }
102
+ if (typeof config.status === "number") {
103
+ merged.status = config.status;
104
+ configSources.status = configPath;
105
+ }
106
+ if (typeof config.delay === "number") {
107
+ merged.delay = config.delay;
108
+ configSources.delay = configPath;
109
+ }
110
+ if (typeof config.enabled === "boolean") {
111
+ merged.enabled = config.enabled;
112
+ configSources.enabled = configPath;
113
+ }
114
+ if (typeof config.ignorePrefix !== "undefined") {
115
+ merged.ignorePrefix = config.ignorePrefix;
116
+ configSources.ignorePrefix = configPath;
117
+ }
118
+ if (typeof config.include !== "undefined") {
119
+ merged.include = config.include;
120
+ configSources.include = configPath;
121
+ }
122
+ if (typeof config.exclude !== "undefined") {
123
+ merged.exclude = config.exclude;
124
+ configSources.exclude = configPath;
125
+ }
126
+ const meta = readMiddlewareMeta(config);
127
+ preMiddlewares.push(
128
+ ...normalizeMiddlewareList({
129
+ value: meta?.pre,
130
+ source: configPath,
131
+ position: "pre",
132
+ warn,
133
+ map: (handler, index, position) => mapMiddleware(handler, index, position, configPath)
134
+ })
135
+ );
136
+ normalMiddlewares.push(
137
+ ...normalizeMiddlewareList({
138
+ value: meta?.normal,
139
+ source: configPath,
140
+ position: "normal",
141
+ warn,
142
+ map: (handler, index, position) => mapMiddleware(handler, index, position, configPath)
143
+ })
144
+ );
145
+ normalMiddlewares.push(
146
+ ...normalizeMiddlewareList({
147
+ value: config.middleware,
148
+ source: configPath,
149
+ position: "normal",
150
+ warn,
151
+ map: (handler, index, position) => mapMiddleware(handler, index, position, configPath)
152
+ })
153
+ );
154
+ postMiddlewares.push(
155
+ ...normalizeMiddlewareList({
156
+ value: meta?.post,
157
+ source: configPath,
158
+ position: "post",
159
+ warn,
160
+ map: (handler, index, position) => mapMiddleware(handler, index, position, configPath)
161
+ })
162
+ );
163
+ }
164
+ return {
165
+ ...merged,
166
+ middlewares: [...preMiddlewares, ...normalMiddlewares, ...postMiddlewares],
167
+ configChain,
168
+ configSources
169
+ };
170
+ }
171
+
172
+ exports.isPromise = configCore.isPromise;
173
+ exports.middlewareSymbol = configCore.middlewareSymbol;
174
+ exports.buildConfigChain = buildConfigChain;
175
+ exports.findConfigFile = findConfigFile;
176
+ exports.getConfigFileCandidates = getConfigFileCandidates;
177
+ exports.normalizeMiddlewareList = normalizeMiddlewareList;
178
+ exports.readMiddlewareMeta = readMiddlewareMeta;
179
+ exports.resolveDirectoryConfig = resolveDirectoryConfig;
@@ -0,0 +1,62 @@
1
+ export { isPromise, middlewareSymbol } from './config-core.cjs';
2
+
3
+ type MiddlewarePosition = 'pre' | 'normal' | 'post';
4
+ interface MiddlewareMeta {
5
+ pre?: unknown[];
6
+ normal?: unknown[];
7
+ post?: unknown[];
8
+ }
9
+ interface ConfigSourceMap {
10
+ headers?: string;
11
+ status?: string;
12
+ delay?: string;
13
+ enabled?: string;
14
+ ignorePrefix?: string;
15
+ include?: string;
16
+ exclude?: string;
17
+ }
18
+ declare function readMiddlewareMeta(config: Record<symbol, unknown>): MiddlewareMeta | null;
19
+
20
+ declare function normalizeMiddlewareList<T>(params: {
21
+ value: unknown;
22
+ source: string;
23
+ position: MiddlewarePosition;
24
+ warn?: (message: string) => void;
25
+ map: (handler: (...args: unknown[]) => unknown, index: number, position: MiddlewarePosition) => T;
26
+ }): T[];
27
+ declare function buildConfigChain(file: string, rootDir: string): string[];
28
+ declare function getConfigFileCandidates(dir: string, extensions: readonly string[]): string[];
29
+ declare function findConfigFile(dir: string, cache: Map<string, string | null>, extensions: readonly string[]): Promise<string | null>;
30
+ declare function resolveDirectoryConfig<TConfig extends {
31
+ headers?: Record<string, string>;
32
+ status?: number;
33
+ delay?: number;
34
+ enabled?: boolean;
35
+ ignorePrefix?: string | string[];
36
+ include?: RegExp | RegExp[];
37
+ exclude?: RegExp | RegExp[];
38
+ middleware?: unknown;
39
+ }, TMiddleware>(params: {
40
+ file: string;
41
+ rootDir: string;
42
+ configExtensions: readonly string[];
43
+ configCache: Map<string, TConfig | null>;
44
+ fileCache: Map<string, string | null>;
45
+ loadConfig: (file: string) => Promise<TConfig | null>;
46
+ warn?: (message: string) => void;
47
+ mapMiddleware: (handler: (...args: unknown[]) => unknown, index: number, position: MiddlewarePosition, source: string) => TMiddleware;
48
+ }): Promise<{
49
+ middlewares: TMiddleware[];
50
+ configChain: string[];
51
+ configSources: ConfigSourceMap;
52
+ headers?: Record<string, string>;
53
+ status?: number;
54
+ delay?: number;
55
+ enabled?: boolean;
56
+ ignorePrefix?: string | string[];
57
+ include?: RegExp | RegExp[];
58
+ exclude?: RegExp | RegExp[];
59
+ }>;
60
+
61
+ export { buildConfigChain, findConfigFile, getConfigFileCandidates, normalizeMiddlewareList, readMiddlewareMeta, resolveDirectoryConfig };
62
+ export type { ConfigSourceMap, MiddlewareMeta, MiddlewarePosition };
@@ -0,0 +1,62 @@
1
+ export { isPromise, middlewareSymbol } from './config-core.mjs';
2
+
3
+ type MiddlewarePosition = 'pre' | 'normal' | 'post';
4
+ interface MiddlewareMeta {
5
+ pre?: unknown[];
6
+ normal?: unknown[];
7
+ post?: unknown[];
8
+ }
9
+ interface ConfigSourceMap {
10
+ headers?: string;
11
+ status?: string;
12
+ delay?: string;
13
+ enabled?: string;
14
+ ignorePrefix?: string;
15
+ include?: string;
16
+ exclude?: string;
17
+ }
18
+ declare function readMiddlewareMeta(config: Record<symbol, unknown>): MiddlewareMeta | null;
19
+
20
+ declare function normalizeMiddlewareList<T>(params: {
21
+ value: unknown;
22
+ source: string;
23
+ position: MiddlewarePosition;
24
+ warn?: (message: string) => void;
25
+ map: (handler: (...args: unknown[]) => unknown, index: number, position: MiddlewarePosition) => T;
26
+ }): T[];
27
+ declare function buildConfigChain(file: string, rootDir: string): string[];
28
+ declare function getConfigFileCandidates(dir: string, extensions: readonly string[]): string[];
29
+ declare function findConfigFile(dir: string, cache: Map<string, string | null>, extensions: readonly string[]): Promise<string | null>;
30
+ declare function resolveDirectoryConfig<TConfig extends {
31
+ headers?: Record<string, string>;
32
+ status?: number;
33
+ delay?: number;
34
+ enabled?: boolean;
35
+ ignorePrefix?: string | string[];
36
+ include?: RegExp | RegExp[];
37
+ exclude?: RegExp | RegExp[];
38
+ middleware?: unknown;
39
+ }, TMiddleware>(params: {
40
+ file: string;
41
+ rootDir: string;
42
+ configExtensions: readonly string[];
43
+ configCache: Map<string, TConfig | null>;
44
+ fileCache: Map<string, string | null>;
45
+ loadConfig: (file: string) => Promise<TConfig | null>;
46
+ warn?: (message: string) => void;
47
+ mapMiddleware: (handler: (...args: unknown[]) => unknown, index: number, position: MiddlewarePosition, source: string) => TMiddleware;
48
+ }): Promise<{
49
+ middlewares: TMiddleware[];
50
+ configChain: string[];
51
+ configSources: ConfigSourceMap;
52
+ headers?: Record<string, string>;
53
+ status?: number;
54
+ delay?: number;
55
+ enabled?: boolean;
56
+ ignorePrefix?: string | string[];
57
+ include?: RegExp | RegExp[];
58
+ exclude?: RegExp | RegExp[];
59
+ }>;
60
+
61
+ export { buildConfigChain, findConfigFile, getConfigFileCandidates, normalizeMiddlewareList, readMiddlewareMeta, resolveDirectoryConfig };
62
+ export type { ConfigSourceMap, MiddlewareMeta, MiddlewarePosition };
@@ -0,0 +1,62 @@
1
+ export { isPromise, middlewareSymbol } from './config-core.js';
2
+
3
+ type MiddlewarePosition = 'pre' | 'normal' | 'post';
4
+ interface MiddlewareMeta {
5
+ pre?: unknown[];
6
+ normal?: unknown[];
7
+ post?: unknown[];
8
+ }
9
+ interface ConfigSourceMap {
10
+ headers?: string;
11
+ status?: string;
12
+ delay?: string;
13
+ enabled?: string;
14
+ ignorePrefix?: string;
15
+ include?: string;
16
+ exclude?: string;
17
+ }
18
+ declare function readMiddlewareMeta(config: Record<symbol, unknown>): MiddlewareMeta | null;
19
+
20
+ declare function normalizeMiddlewareList<T>(params: {
21
+ value: unknown;
22
+ source: string;
23
+ position: MiddlewarePosition;
24
+ warn?: (message: string) => void;
25
+ map: (handler: (...args: unknown[]) => unknown, index: number, position: MiddlewarePosition) => T;
26
+ }): T[];
27
+ declare function buildConfigChain(file: string, rootDir: string): string[];
28
+ declare function getConfigFileCandidates(dir: string, extensions: readonly string[]): string[];
29
+ declare function findConfigFile(dir: string, cache: Map<string, string | null>, extensions: readonly string[]): Promise<string | null>;
30
+ declare function resolveDirectoryConfig<TConfig extends {
31
+ headers?: Record<string, string>;
32
+ status?: number;
33
+ delay?: number;
34
+ enabled?: boolean;
35
+ ignorePrefix?: string | string[];
36
+ include?: RegExp | RegExp[];
37
+ exclude?: RegExp | RegExp[];
38
+ middleware?: unknown;
39
+ }, TMiddleware>(params: {
40
+ file: string;
41
+ rootDir: string;
42
+ configExtensions: readonly string[];
43
+ configCache: Map<string, TConfig | null>;
44
+ fileCache: Map<string, string | null>;
45
+ loadConfig: (file: string) => Promise<TConfig | null>;
46
+ warn?: (message: string) => void;
47
+ mapMiddleware: (handler: (...args: unknown[]) => unknown, index: number, position: MiddlewarePosition, source: string) => TMiddleware;
48
+ }): Promise<{
49
+ middlewares: TMiddleware[];
50
+ configChain: string[];
51
+ configSources: ConfigSourceMap;
52
+ headers?: Record<string, string>;
53
+ status?: number;
54
+ delay?: number;
55
+ enabled?: boolean;
56
+ ignorePrefix?: string | string[];
57
+ include?: RegExp | RegExp[];
58
+ exclude?: RegExp | RegExp[];
59
+ }>;
60
+
61
+ export { buildConfigChain, findConfigFile, getConfigFileCandidates, normalizeMiddlewareList, readMiddlewareMeta, resolveDirectoryConfig };
62
+ export type { ConfigSourceMap, MiddlewareMeta, MiddlewarePosition };
@@ -0,0 +1,171 @@
1
+ import { promises } from 'node:fs';
2
+ import { middlewareSymbol } from './config-core.mjs';
3
+ export { isPromise } from './config-core.mjs';
4
+ import { normalize, dirname, join } from 'pathe';
5
+
6
+ function readMiddlewareMeta(config) {
7
+ const value = config[middlewareSymbol];
8
+ if (!value || typeof value !== "object") {
9
+ return null;
10
+ }
11
+ const meta = value;
12
+ return {
13
+ pre: Array.isArray(meta.pre) ? meta.pre : [],
14
+ normal: Array.isArray(meta.normal) ? meta.normal : [],
15
+ post: Array.isArray(meta.post) ? meta.post : []
16
+ };
17
+ }
18
+ function normalizeMiddlewareList(params) {
19
+ const { value, source, position, warn, map } = params;
20
+ if (!value) {
21
+ return [];
22
+ }
23
+ const list = Array.isArray(value) ? value : [value];
24
+ const middlewares = [];
25
+ list.forEach((entry, index) => {
26
+ if (typeof entry !== "function") {
27
+ warn?.(`Invalid middleware in ${source}`);
28
+ return;
29
+ }
30
+ middlewares.push(map(entry, index, position));
31
+ });
32
+ return middlewares;
33
+ }
34
+ function buildConfigChain(file, rootDir) {
35
+ const resolvedRoot = normalize(rootDir);
36
+ const resolvedFileDir = normalize(dirname(file));
37
+ const chain = [];
38
+ let current = resolvedFileDir;
39
+ while (true) {
40
+ chain.push(current);
41
+ if (current === resolvedRoot) {
42
+ break;
43
+ }
44
+ const parent = dirname(current);
45
+ if (parent === current) {
46
+ break;
47
+ }
48
+ current = parent;
49
+ }
50
+ chain.reverse();
51
+ return chain;
52
+ }
53
+ function getConfigFileCandidates(dir, extensions) {
54
+ return extensions.map((extension) => join(dir, `index.config${extension}`));
55
+ }
56
+ async function findConfigFile(dir, cache, extensions) {
57
+ const cached = cache.get(dir);
58
+ if (cached !== void 0) {
59
+ return cached;
60
+ }
61
+ for (const candidate of getConfigFileCandidates(dir, extensions)) {
62
+ try {
63
+ await promises.stat(candidate);
64
+ cache.set(dir, candidate);
65
+ return candidate;
66
+ } catch {
67
+ continue;
68
+ }
69
+ }
70
+ cache.set(dir, null);
71
+ return null;
72
+ }
73
+ async function resolveDirectoryConfig(params) {
74
+ const { file, rootDir, configExtensions, configCache, fileCache, loadConfig, warn, mapMiddleware } = params;
75
+ const chain = buildConfigChain(file, rootDir);
76
+ const merged = {};
77
+ const preMiddlewares = [];
78
+ const normalMiddlewares = [];
79
+ const postMiddlewares = [];
80
+ const configChain = [];
81
+ const configSources = {};
82
+ for (const dir of chain) {
83
+ const configPath = await findConfigFile(dir, fileCache, configExtensions);
84
+ if (!configPath) {
85
+ continue;
86
+ }
87
+ let config = configCache.get(configPath);
88
+ if (config === void 0) {
89
+ config = await loadConfig(configPath);
90
+ configCache.set(configPath, config);
91
+ }
92
+ if (!config) {
93
+ warn?.(`Invalid config in ${configPath}`);
94
+ continue;
95
+ }
96
+ configChain.push(configPath);
97
+ if (config.headers) {
98
+ merged.headers = { ...merged.headers ?? {}, ...config.headers };
99
+ configSources.headers = configPath;
100
+ }
101
+ if (typeof config.status === "number") {
102
+ merged.status = config.status;
103
+ configSources.status = configPath;
104
+ }
105
+ if (typeof config.delay === "number") {
106
+ merged.delay = config.delay;
107
+ configSources.delay = configPath;
108
+ }
109
+ if (typeof config.enabled === "boolean") {
110
+ merged.enabled = config.enabled;
111
+ configSources.enabled = configPath;
112
+ }
113
+ if (typeof config.ignorePrefix !== "undefined") {
114
+ merged.ignorePrefix = config.ignorePrefix;
115
+ configSources.ignorePrefix = configPath;
116
+ }
117
+ if (typeof config.include !== "undefined") {
118
+ merged.include = config.include;
119
+ configSources.include = configPath;
120
+ }
121
+ if (typeof config.exclude !== "undefined") {
122
+ merged.exclude = config.exclude;
123
+ configSources.exclude = configPath;
124
+ }
125
+ const meta = readMiddlewareMeta(config);
126
+ preMiddlewares.push(
127
+ ...normalizeMiddlewareList({
128
+ value: meta?.pre,
129
+ source: configPath,
130
+ position: "pre",
131
+ warn,
132
+ map: (handler, index, position) => mapMiddleware(handler, index, position, configPath)
133
+ })
134
+ );
135
+ normalMiddlewares.push(
136
+ ...normalizeMiddlewareList({
137
+ value: meta?.normal,
138
+ source: configPath,
139
+ position: "normal",
140
+ warn,
141
+ map: (handler, index, position) => mapMiddleware(handler, index, position, configPath)
142
+ })
143
+ );
144
+ normalMiddlewares.push(
145
+ ...normalizeMiddlewareList({
146
+ value: config.middleware,
147
+ source: configPath,
148
+ position: "normal",
149
+ warn,
150
+ map: (handler, index, position) => mapMiddleware(handler, index, position, configPath)
151
+ })
152
+ );
153
+ postMiddlewares.push(
154
+ ...normalizeMiddlewareList({
155
+ value: meta?.post,
156
+ source: configPath,
157
+ position: "post",
158
+ warn,
159
+ map: (handler, index, position) => mapMiddleware(handler, index, position, configPath)
160
+ })
161
+ );
162
+ }
163
+ return {
164
+ ...merged,
165
+ middlewares: [...preMiddlewares, ...normalMiddlewares, ...postMiddlewares],
166
+ configChain,
167
+ configSources
168
+ };
169
+ }
170
+
171
+ export { buildConfigChain, findConfigFile, getConfigFileCandidates, middlewareSymbol, normalizeMiddlewareList, readMiddlewareMeta, resolveDirectoryConfig };