@mokup/shared 1.1.4 → 2.0.0

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 (142) hide show
  1. package/README.md +58 -0
  2. package/dist/chokidar.d.mts +3 -8
  3. package/dist/chokidar.d.ts +3 -9
  4. package/dist/chokidar.mjs +2 -1
  5. package/dist/chunk-_iGcCiPk.mjs +28 -0
  6. package/dist/{config-core.d.cts → config-core-dqVMz7on.d.mts} +3 -2
  7. package/dist/config-core-dqVMz7on.d.ts +5 -0
  8. package/dist/config-core.d.mts +2 -4
  9. package/dist/config-core.d.ts +2 -4
  10. package/dist/config-core.mjs +3 -2
  11. package/dist/config-utils-DFu0_9tl.d.mts +59 -0
  12. package/dist/config-utils-DFu0_9tl.d.ts +59 -0
  13. package/dist/config-utils.d.mts +3 -62
  14. package/dist/config-utils.d.ts +3 -62
  15. package/dist/config-utils.mjs +143 -159
  16. package/dist/define-config-CzB1-X1m.d.mts +20 -0
  17. package/dist/define-config-CzB1-X1m.d.ts +20 -0
  18. package/dist/define-config.d.mts +2 -20
  19. package/dist/define-config.d.ts +2 -20
  20. package/dist/define-config.mjs +146 -162
  21. package/dist/diagnostic-types-DqAzUbgn.d.mts +39 -0
  22. package/dist/diagnostic-types-DqAzUbgn.d.ts +39 -0
  23. package/dist/diagnostic-types.d.mts +2 -0
  24. package/dist/diagnostic-types.d.ts +2 -0
  25. package/dist/diagnostic-types.mjs +29 -0
  26. package/dist/diagnostics-C3QaEtqE.d.mts +101 -0
  27. package/dist/diagnostics-C3QaEtqE.d.ts +101 -0
  28. package/dist/diagnostics.d.mts +2 -0
  29. package/dist/diagnostics.d.ts +2 -0
  30. package/dist/diagnostics.mjs +129 -0
  31. package/dist/hono.d.mts +4 -3
  32. package/dist/hono.d.ts +4 -3
  33. package/dist/hono.mjs +4 -3
  34. package/dist/index-5prVUGOX.d.mts +113 -0
  35. package/dist/index-5prVUGOX.d.ts +113 -0
  36. package/dist/index.d.mts +13 -10
  37. package/dist/index.d.ts +13 -10
  38. package/dist/index.mjs +13 -18
  39. package/dist/jsonc-parser.d.mts +1 -1
  40. package/dist/jsonc-parser.d.ts +1 -1
  41. package/dist/jsonc-parser.mjs +8 -1
  42. package/dist/jsonc-utils-_Hs6a39T.d.mts +7 -0
  43. package/dist/jsonc-utils-_Hs6a39T.d.ts +7 -0
  44. package/dist/jsonc-utils.d.mts +2 -7
  45. package/dist/jsonc-utils.d.ts +2 -7
  46. package/dist/jsonc-utils.mjs +20 -20
  47. package/dist/load-rules-D_kCpu9I.d.mts +14 -0
  48. package/dist/load-rules-D_kCpu9I.d.ts +14 -0
  49. package/dist/load-rules.d.mts +2 -14
  50. package/dist/load-rules.d.ts +2 -14
  51. package/dist/load-rules.mjs +16 -34
  52. package/dist/logger-types-BbqYCr6j.d.mts +50 -0
  53. package/dist/logger-types-BbqYCr6j.d.ts +50 -0
  54. package/dist/logger.browser.d.mts +4 -3
  55. package/dist/logger.browser.d.ts +4 -3
  56. package/dist/logger.browser.mjs +49 -48
  57. package/dist/logger.d.mts +4 -3
  58. package/dist/logger.d.ts +4 -3
  59. package/dist/logger.mjs +49 -48
  60. package/dist/{mock-files.d.cts → mock-files-DfGigWmY.d.mts} +5 -5
  61. package/dist/mock-files-DfGigWmY.d.ts +10 -0
  62. package/dist/mock-files.d.mts +2 -10
  63. package/dist/mock-files.d.ts +2 -10
  64. package/dist/mock-files.mjs +38 -50
  65. package/dist/{module-loader.d.cts → module-loader-nAQlwo3D.d.mts} +7 -6
  66. package/dist/module-loader-nAQlwo3D.d.ts +14 -0
  67. package/dist/module-loader.d.mts +2 -13
  68. package/dist/module-loader.d.ts +2 -13
  69. package/dist/module-loader.mjs +60 -69
  70. package/dist/path-utils.d.mts +3 -2
  71. package/dist/path-utils.d.ts +3 -2
  72. package/dist/path-utils.mjs +25 -35
  73. package/dist/pathe.d.mts +1 -1
  74. package/dist/pathe.d.ts +1 -1
  75. package/dist/pathe.mjs +8 -1
  76. package/dist/playground-grouping.d.mts +6 -6
  77. package/dist/playground-grouping.d.ts +6 -6
  78. package/dist/playground-grouping.mjs +57 -77
  79. package/dist/rolldown.d.mts +37 -0
  80. package/dist/rolldown.d.ts +37 -0
  81. package/dist/rolldown.mjs +81 -0
  82. package/dist/{route-constants.d.cts → route-constants-BUi36iYR.d.mts} +3 -2
  83. package/dist/route-constants-BUi36iYR.d.ts +8 -0
  84. package/dist/route-constants.d.mts +2 -7
  85. package/dist/route-constants.d.ts +2 -7
  86. package/dist/route-constants.mjs +25 -21
  87. package/dist/route-utils-BiWFUqo-.d.mts +42 -0
  88. package/dist/route-utils-BiWFUqo-.d.ts +42 -0
  89. package/dist/route-utils.d.mts +2 -42
  90. package/dist/route-utils.d.ts +2 -42
  91. package/dist/route-utils.mjs +94 -121
  92. package/dist/scan-utils.d.mts +2 -114
  93. package/dist/scan-utils.d.ts +2 -114
  94. package/dist/scan-utils.mjs +14 -25
  95. package/dist/timing.d.mts +3 -2
  96. package/dist/timing.d.ts +3 -2
  97. package/dist/timing.mjs +11 -12
  98. package/package.json +88 -128
  99. package/dist/chokidar.cjs +0 -11
  100. package/dist/chokidar.d.cts +0 -9
  101. package/dist/config-core.cjs +0 -9
  102. package/dist/config-utils.cjs +0 -179
  103. package/dist/config-utils.d.cts +0 -62
  104. package/dist/define-config.cjs +0 -169
  105. package/dist/define-config.d.cts +0 -20
  106. package/dist/esbuild.cjs +0 -16
  107. package/dist/esbuild.d.cts +0 -1
  108. package/dist/esbuild.d.mts +0 -1
  109. package/dist/esbuild.d.ts +0 -1
  110. package/dist/esbuild.mjs +0 -1
  111. package/dist/hono.cjs +0 -20
  112. package/dist/hono.d.cts +0 -3
  113. package/dist/index.cjs +0 -50
  114. package/dist/index.d.cts +0 -10
  115. package/dist/jsonc-parser.cjs +0 -16
  116. package/dist/jsonc-parser.d.cts +0 -1
  117. package/dist/jsonc-utils.cjs +0 -25
  118. package/dist/jsonc-utils.d.cts +0 -7
  119. package/dist/load-rules.cjs +0 -39
  120. package/dist/load-rules.d.cts +0 -14
  121. package/dist/logger.browser.cjs +0 -55
  122. package/dist/logger.browser.d.cts +0 -21
  123. package/dist/logger.cjs +0 -55
  124. package/dist/logger.d.cts +0 -21
  125. package/dist/mock-files.cjs +0 -65
  126. package/dist/module-loader.cjs +0 -93
  127. package/dist/path-utils.cjs +0 -57
  128. package/dist/path-utils.d.cts +0 -7
  129. package/dist/pathe.cjs +0 -16
  130. package/dist/pathe.d.cts +0 -1
  131. package/dist/playground-grouping.cjs +0 -95
  132. package/dist/playground-grouping.d.cts +0 -12
  133. package/dist/route-constants.cjs +0 -30
  134. package/dist/route-utils.cjs +0 -126
  135. package/dist/route-utils.d.cts +0 -42
  136. package/dist/scan-utils.cjs +0 -39
  137. package/dist/scan-utils.d.cts +0 -114
  138. package/dist/shared/shared.DazgCdsk.d.cts +0 -49
  139. package/dist/shared/shared.DazgCdsk.d.mts +0 -49
  140. package/dist/shared/shared.DazgCdsk.d.ts +0 -49
  141. package/dist/timing.cjs +0 -20
  142. package/dist/timing.d.cts +0 -4
@@ -1,179 +0,0 @@
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;
@@ -1,62 +0,0 @@
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) | undefined;
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 };
@@ -1,169 +0,0 @@
1
- 'use strict';
2
-
3
- const configCore = require('./config-core.cjs');
4
-
5
- function normalizeHookError(policy) {
6
- if (policy === "throw" || policy === "silent") {
7
- return policy;
8
- }
9
- return "warn";
10
- }
11
- function createDefineConfig(options) {
12
- const contextStack = [];
13
- function getActiveContext() {
14
- const context = contextStack[contextStack.length - 1];
15
- if (!context) {
16
- throw new Error("onBeforeAll/onAfterAll must be called inside defineConfig()");
17
- }
18
- return context;
19
- }
20
- function runWithContext(context, fn) {
21
- contextStack.push(context);
22
- try {
23
- const result = fn();
24
- if (configCore.isPromise(result)) {
25
- return result.finally(() => {
26
- contextStack.pop();
27
- });
28
- }
29
- contextStack.pop();
30
- return result;
31
- } catch (error) {
32
- contextStack.pop();
33
- throw error;
34
- }
35
- }
36
- function reportHookError(error, policy) {
37
- if (policy === "silent") {
38
- return;
39
- }
40
- if (policy === "warn") {
41
- console.warn(`${options.logPrefix} defineConfig hook failed:`, error);
42
- }
43
- }
44
- function runHookSequence(stage, hooks, policy, setStage) {
45
- if (hooks.length === 0) {
46
- return;
47
- }
48
- setStage(stage);
49
- let chain = null;
50
- const runHook = (hook) => {
51
- try {
52
- const result = hook();
53
- if (configCore.isPromise(result)) {
54
- return result.catch((error) => {
55
- if (policy === "throw") {
56
- throw error;
57
- }
58
- reportHookError(error, policy);
59
- });
60
- }
61
- return void 0;
62
- } catch (error) {
63
- if (policy === "throw") {
64
- throw error;
65
- }
66
- reportHookError(error, policy);
67
- return void 0;
68
- }
69
- };
70
- for (const hook of hooks) {
71
- if (chain) {
72
- chain = chain.then(() => runHook(hook));
73
- continue;
74
- }
75
- const result = runHook(hook);
76
- if (configCore.isPromise(result)) {
77
- chain = result;
78
- }
79
- }
80
- if (!chain) {
81
- setStage("normal");
82
- return;
83
- }
84
- return chain.finally(() => {
85
- setStage("normal");
86
- });
87
- }
88
- function attachMetadata(config, meta) {
89
- Object.defineProperty(config, configCore.middlewareSymbol, {
90
- value: meta,
91
- enumerable: false
92
- });
93
- return config;
94
- }
95
- function normalizeConfig(value) {
96
- return value && typeof value === "object" ? value : {};
97
- }
98
- function onBeforeAll(handler) {
99
- if (typeof handler !== "function") {
100
- throw new TypeError("onBeforeAll expects a function");
101
- }
102
- const context = getActiveContext();
103
- context.hooks.pre.push(handler);
104
- }
105
- function onAfterAll(handler) {
106
- if (typeof handler !== "function") {
107
- throw new TypeError("onAfterAll expects a function");
108
- }
109
- const context = getActiveContext();
110
- context.hooks.post.push(handler);
111
- }
112
- function defineConfig(input) {
113
- if (typeof input === "function") {
114
- const pre = [];
115
- const normal = [];
116
- const post = [];
117
- let stage = "normal";
118
- const app = {
119
- use: (...handlers) => {
120
- if (stage === "pre") {
121
- pre.push(...handlers);
122
- return;
123
- }
124
- if (stage === "post") {
125
- post.push(...handlers);
126
- return;
127
- }
128
- normal.push(...handlers);
129
- }
130
- };
131
- const context = {
132
- app,
133
- hooks: { pre: [], post: [] },
134
- setStage: (next) => {
135
- stage = next;
136
- }
137
- };
138
- const result = runWithContext(context, () => input({ app }));
139
- const finalize = (value) => {
140
- const config2 = normalizeConfig(value);
141
- const policy = normalizeHookError(config2.hookError);
142
- const preResult = runHookSequence("pre", context.hooks.pre, policy, context.setStage);
143
- const runPost = () => runHookSequence("post", context.hooks.post, policy, context.setStage);
144
- if (configCore.isPromise(preResult)) {
145
- return preResult.then(runPost).then(() => attachMetadata(config2, { pre, normal, post }));
146
- }
147
- const postResult = runPost();
148
- if (configCore.isPromise(postResult)) {
149
- return postResult.then(() => attachMetadata(config2, { pre, normal, post }));
150
- }
151
- return attachMetadata(config2, { pre, normal, post });
152
- };
153
- const isConfigPromise = (value) => configCore.isPromise(value);
154
- if (isConfigPromise(result)) {
155
- return result.then(finalize);
156
- }
157
- return finalize(result);
158
- }
159
- const config = normalizeConfig(input);
160
- return attachMetadata(config, { pre: [], normal: [], post: [] });
161
- }
162
- return {
163
- defineConfig,
164
- onBeforeAll,
165
- onAfterAll
166
- };
167
- }
168
-
169
- exports.createDefineConfig = createDefineConfig;
@@ -1,20 +0,0 @@
1
- type HookErrorPolicy = 'warn' | 'silent' | 'throw';
2
- type HookHandler = () => void | Promise<void>;
3
- interface ConfigApp<TMiddleware> {
4
- use: (...handlers: TMiddleware[]) => void;
5
- }
6
- type DefineConfigFactory<TConfig, TMiddleware> = (context: {
7
- app: ConfigApp<TMiddleware>;
8
- }) => TConfig | void | Promise<TConfig | void>;
9
- declare function createDefineConfig<TConfig extends {
10
- hookError?: HookErrorPolicy;
11
- }, TMiddleware>(options: {
12
- logPrefix: string;
13
- }): {
14
- defineConfig: (input: TConfig | DefineConfigFactory<TConfig, TMiddleware>) => TConfig | Promise<TConfig>;
15
- onBeforeAll: (handler: HookHandler) => void;
16
- onAfterAll: (handler: HookHandler) => void;
17
- };
18
-
19
- export { createDefineConfig };
20
- export type { ConfigApp, DefineConfigFactory, HookErrorPolicy, HookHandler };
package/dist/esbuild.cjs DELETED
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- const esbuild = require('esbuild');
4
-
5
-
6
-
7
- Object.prototype.hasOwnProperty.call(esbuild, '__proto__') &&
8
- !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
9
- Object.defineProperty(exports, '__proto__', {
10
- enumerable: true,
11
- value: esbuild['__proto__']
12
- });
13
-
14
- Object.keys(esbuild).forEach(function (k) {
15
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = esbuild[k];
16
- });
@@ -1 +0,0 @@
1
- export * from 'esbuild';
@@ -1 +0,0 @@
1
- export * from 'esbuild';
package/dist/esbuild.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from 'esbuild';
package/dist/esbuild.mjs DELETED
@@ -1 +0,0 @@
1
- export * from 'esbuild';
package/dist/hono.cjs DELETED
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- const hono = require('hono');
4
- const patternRouter = require('hono/router/pattern-router');
5
- const serviceWorker = require('hono/service-worker');
6
-
7
-
8
-
9
- exports.PatternRouter = patternRouter.PatternRouter;
10
- exports.handle = serviceWorker.handle;
11
- Object.prototype.hasOwnProperty.call(hono, '__proto__') &&
12
- !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
13
- Object.defineProperty(exports, '__proto__', {
14
- enumerable: true,
15
- value: hono['__proto__']
16
- });
17
-
18
- Object.keys(hono).forEach(function (k) {
19
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = hono[k];
20
- });
package/dist/hono.d.cts DELETED
@@ -1,3 +0,0 @@
1
- export * from 'hono';
2
- export { PatternRouter } from 'hono/router/pattern-router';
3
- export { handle } from 'hono/service-worker';
package/dist/index.cjs DELETED
@@ -1,50 +0,0 @@
1
- 'use strict';
2
-
3
- const configCore = require('./config-core.cjs');
4
- const configUtils = require('./config-utils.cjs');
5
- const defineConfig = require('./define-config.cjs');
6
- const jsoncUtils = require('./jsonc-utils.cjs');
7
- const loadRules = require('./load-rules.cjs');
8
- const mockFiles = require('./mock-files.cjs');
9
- const moduleLoader = require('./module-loader.cjs');
10
- const routeConstants = require('./route-constants.cjs');
11
- const routeUtils = require('./route-utils.cjs');
12
- const scanUtils = require('./scan-utils.cjs');
13
- require('node:fs');
14
- require('pathe');
15
- require('jsonc-parser');
16
- require('node:module');
17
- require('node:os');
18
- require('node:process');
19
- require('node:url');
20
- require('./path-utils.cjs');
21
-
22
-
23
-
24
- exports.isPromise = configCore.isPromise;
25
- exports.middlewareSymbol = configCore.middlewareSymbol;
26
- exports.buildConfigChain = configUtils.buildConfigChain;
27
- exports.findConfigFile = configUtils.findConfigFile;
28
- exports.getConfigFileCandidates = configUtils.getConfigFileCandidates;
29
- exports.normalizeMiddlewareList = configUtils.normalizeMiddlewareList;
30
- exports.readMiddlewareMeta = configUtils.readMiddlewareMeta;
31
- exports.resolveDirectoryConfig = configUtils.resolveDirectoryConfig;
32
- exports.createDefineConfig = defineConfig.createDefineConfig;
33
- exports.readJsoncFile = jsoncUtils.readJsoncFile;
34
- exports.loadRules = loadRules.loadRules;
35
- exports.collectFiles = mockFiles.collectFiles;
36
- exports.isConfigFile = mockFiles.isConfigFile;
37
- exports.isSupportedFile = mockFiles.isSupportedFile;
38
- exports.createTsxConfigFile = moduleLoader.createTsxConfigFile;
39
- exports.ensureTsxRegister = moduleLoader.ensureTsxRegister;
40
- exports.loadModule = moduleLoader.loadModule;
41
- exports.configExtensions = routeConstants.configExtensions;
42
- exports.jsonExtensions = routeConstants.jsonExtensions;
43
- exports.methodSet = routeConstants.methodSet;
44
- exports.methodSuffixSet = routeConstants.methodSuffixSet;
45
- exports.supportedExtensions = routeConstants.supportedExtensions;
46
- exports.createRouteUtils = routeUtils.createRouteUtils;
47
- exports.normalizeIgnorePrefix = scanUtils.normalizeIgnorePrefix;
48
- exports.normalizeMethod = scanUtils.normalizeMethod;
49
- exports.normalizePrefix = scanUtils.normalizePrefix;
50
- exports.resolveDirs = scanUtils.resolveDirs;
package/dist/index.d.cts DELETED
@@ -1,10 +0,0 @@
1
- export { isPromise, middlewareSymbol } from './config-core.cjs';
2
- export { ConfigSourceMap, MiddlewareMeta, MiddlewarePosition, buildConfigChain, findConfigFile, getConfigFileCandidates, normalizeMiddlewareList, readMiddlewareMeta, resolveDirectoryConfig } from './config-utils.cjs';
3
- export { ConfigApp, DefineConfigFactory, HookErrorPolicy, HookHandler, createDefineConfig } from './define-config.cjs';
4
- export { readJsoncFile } from './jsonc-utils.cjs';
5
- export { loadRules } from './load-rules.cjs';
6
- export { collectFiles, isConfigFile, isSupportedFile } from './mock-files.cjs';
7
- export { createTsxConfigFile, ensureTsxRegister, loadModule } from './module-loader.cjs';
8
- export { configExtensions, jsonExtensions, methodSet, methodSuffixSet, supportedExtensions } from './route-constants.cjs';
9
- export { DerivedRoute, RouteParser, RouteParserResult, RouteScoreComparator, createRouteUtils } from './route-utils.cjs';
10
- export { D as DirInput, M as MockEntryOptions, P as PlaygroundOptionsInput, normalizeIgnorePrefix, normalizeMethod, normalizePrefix, resolveDirs } from './scan-utils.cjs';
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- const jsoncParser = require('jsonc-parser');
4
-
5
-
6
-
7
- Object.prototype.hasOwnProperty.call(jsoncParser, '__proto__') &&
8
- !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
9
- Object.defineProperty(exports, '__proto__', {
10
- enumerable: true,
11
- value: jsoncParser['__proto__']
12
- });
13
-
14
- Object.keys(jsoncParser).forEach(function (k) {
15
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = jsoncParser[k];
16
- });
@@ -1 +0,0 @@
1
- export * from 'jsonc-parser';
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- const node_fs = require('node:fs');
4
- const jsoncParser = require('jsonc-parser');
5
-
6
- async function readJsoncFile(file, logger) {
7
- try {
8
- const content = await node_fs.promises.readFile(file, "utf8");
9
- const errors = [];
10
- const data = jsoncParser.parse(content, errors, {
11
- allowTrailingComma: true,
12
- disallowComments: false
13
- });
14
- if (errors.length > 0) {
15
- logger?.warn?.(`Invalid JSONC in ${file}`);
16
- return void 0;
17
- }
18
- return data;
19
- } catch (error) {
20
- logger?.warn?.(`Failed to read ${file}: ${String(error)}`);
21
- return void 0;
22
- }
23
- }
24
-
25
- exports.readJsoncFile = readJsoncFile;
@@ -1,7 +0,0 @@
1
- interface JsoncLogger {
2
- warn?: (message: string) => void;
3
- }
4
- declare function readJsoncFile(file: string, logger?: JsoncLogger): Promise<any>;
5
-
6
- export { readJsoncFile };
7
- export type { JsoncLogger };
@@ -1,39 +0,0 @@
1
- 'use strict';
2
-
3
- const jsoncUtils = require('./jsonc-utils.cjs');
4
- const pathe = require('pathe');
5
- require('node:fs');
6
- require('jsonc-parser');
7
-
8
- async function loadRules(file, options) {
9
- const ext = pathe.extname(file).toLowerCase();
10
- if (ext === ".json" || ext === ".jsonc") {
11
- const json = await jsoncUtils.readJsoncFile(file, options.logger);
12
- if (typeof json === "undefined") {
13
- return [];
14
- }
15
- return [
16
- {
17
- handler: json
18
- }
19
- ];
20
- }
21
- const mod = await options.loadModule(file);
22
- const value = mod?.default ?? mod;
23
- if (!value) {
24
- return [];
25
- }
26
- if (Array.isArray(value)) {
27
- return value;
28
- }
29
- if (typeof value === "function") {
30
- return [
31
- {
32
- handler: value
33
- }
34
- ];
35
- }
36
- return [value];
37
- }
38
-
39
- exports.loadRules = loadRules;
@@ -1,14 +0,0 @@
1
- interface LoadRulesOptions {
2
- loadModule: (file: string) => Promise<unknown | null>;
3
- logger?: {
4
- warn?: (message: string) => void;
5
- };
6
- }
7
- declare function loadRules<T extends {
8
- handler: unknown;
9
- } = {
10
- handler: unknown;
11
- }>(file: string, options: LoadRulesOptions): Promise<T[]>;
12
-
13
- export { loadRules };
14
- export type { LoadRulesOptions };