@mokup/shared 1.1.3 → 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 (143) 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-dqVMz7on.d.mts +5 -0
  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 -161
  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-core.d.cts +0 -4
  103. package/dist/config-utils.cjs +0 -179
  104. package/dist/config-utils.d.cts +0 -62
  105. package/dist/define-config.cjs +0 -168
  106. package/dist/define-config.d.cts +0 -20
  107. package/dist/esbuild.cjs +0 -16
  108. package/dist/esbuild.d.cts +0 -1
  109. package/dist/esbuild.d.mts +0 -1
  110. package/dist/esbuild.d.ts +0 -1
  111. package/dist/esbuild.mjs +0 -1
  112. package/dist/hono.cjs +0 -20
  113. package/dist/hono.d.cts +0 -3
  114. package/dist/index.cjs +0 -50
  115. package/dist/index.d.cts +0 -10
  116. package/dist/jsonc-parser.cjs +0 -16
  117. package/dist/jsonc-parser.d.cts +0 -1
  118. package/dist/jsonc-utils.cjs +0 -25
  119. package/dist/jsonc-utils.d.cts +0 -7
  120. package/dist/load-rules.cjs +0 -39
  121. package/dist/load-rules.d.cts +0 -14
  122. package/dist/logger.browser.cjs +0 -55
  123. package/dist/logger.browser.d.cts +0 -21
  124. package/dist/logger.cjs +0 -55
  125. package/dist/logger.d.cts +0 -21
  126. package/dist/mock-files.cjs +0 -65
  127. package/dist/module-loader.cjs +0 -93
  128. package/dist/path-utils.cjs +0 -57
  129. package/dist/path-utils.d.cts +0 -7
  130. package/dist/pathe.cjs +0 -16
  131. package/dist/pathe.d.cts +0 -1
  132. package/dist/playground-grouping.cjs +0 -95
  133. package/dist/playground-grouping.d.cts +0 -12
  134. package/dist/route-constants.cjs +0 -30
  135. package/dist/route-utils.cjs +0 -126
  136. package/dist/route-utils.d.cts +0 -42
  137. package/dist/scan-utils.cjs +0 -39
  138. package/dist/scan-utils.d.cts +0 -114
  139. package/dist/shared/shared.DazgCdsk.d.cts +0 -49
  140. package/dist/shared/shared.DazgCdsk.d.mts +0 -49
  141. package/dist/shared/shared.DazgCdsk.d.ts +0 -49
  142. package/dist/timing.cjs +0 -20
  143. package/dist/timing.d.cts +0 -4
@@ -1,166 +1,151 @@
1
- import { isPromise, middlewareSymbol } from './config-core.mjs';
2
-
1
+ import { isPromise, middlewareSymbol } from "./config-core.mjs";
2
+ //#region src/define-config.ts
3
3
  function normalizeHookError(policy) {
4
- if (policy === "throw" || policy === "silent") {
5
- return policy;
6
- }
7
- return "warn";
4
+ if (policy === "throw" || policy === "silent") return policy;
5
+ return "warn";
8
6
  }
9
7
  function createDefineConfig(options) {
10
- const contextStack = [];
11
- function getActiveContext() {
12
- const context = contextStack[contextStack.length - 1];
13
- if (!context) {
14
- throw new Error("onBeforeAll/onAfterAll must be called inside defineConfig()");
15
- }
16
- return context;
17
- }
18
- function runWithContext(context, fn) {
19
- contextStack.push(context);
20
- try {
21
- const result = fn();
22
- if (isPromise(result)) {
23
- return result.finally(() => {
24
- contextStack.pop();
25
- });
26
- }
27
- contextStack.pop();
28
- return result;
29
- } catch (error) {
30
- contextStack.pop();
31
- throw error;
32
- }
33
- }
34
- function reportHookError(error, policy) {
35
- if (policy === "silent") {
36
- return;
37
- }
38
- if (policy === "warn") {
39
- console.warn(`${options.logPrefix} defineConfig hook failed:`, error);
40
- }
41
- }
42
- function runHookSequence(stage, hooks, policy, setStage) {
43
- if (hooks.length === 0) {
44
- return;
45
- }
46
- setStage(stage);
47
- let chain = null;
48
- const runHook = (hook) => {
49
- try {
50
- const result = hook();
51
- if (isPromise(result)) {
52
- return result.catch((error) => {
53
- if (policy === "throw") {
54
- throw error;
55
- }
56
- reportHookError(error, policy);
57
- });
58
- }
59
- return void 0;
60
- } catch (error) {
61
- if (policy === "throw") {
62
- throw error;
63
- }
64
- reportHookError(error, policy);
65
- return void 0;
66
- }
67
- };
68
- for (const hook of hooks) {
69
- if (chain) {
70
- chain = chain.then(() => runHook(hook));
71
- continue;
72
- }
73
- const result = runHook(hook);
74
- if (isPromise(result)) {
75
- chain = result;
76
- }
77
- }
78
- if (!chain) {
79
- setStage("normal");
80
- return;
81
- }
82
- return chain.finally(() => {
83
- setStage("normal");
84
- });
85
- }
86
- function attachMetadata(config, meta) {
87
- Object.defineProperty(config, middlewareSymbol, {
88
- value: meta,
89
- enumerable: false
90
- });
91
- return config;
92
- }
93
- function normalizeConfig(value) {
94
- return value && typeof value === "object" ? value : {};
95
- }
96
- function onBeforeAll(handler) {
97
- if (typeof handler !== "function") {
98
- throw new TypeError("onBeforeAll expects a function");
99
- }
100
- const context = getActiveContext();
101
- context.hooks.pre.push(handler);
102
- }
103
- function onAfterAll(handler) {
104
- if (typeof handler !== "function") {
105
- throw new TypeError("onAfterAll expects a function");
106
- }
107
- const context = getActiveContext();
108
- context.hooks.post.push(handler);
109
- }
110
- function defineConfig(input) {
111
- if (typeof input === "function") {
112
- const pre = [];
113
- const normal = [];
114
- const post = [];
115
- let stage = "normal";
116
- const app = {
117
- use: (...handlers) => {
118
- if (stage === "pre") {
119
- pre.push(...handlers);
120
- return;
121
- }
122
- if (stage === "post") {
123
- post.push(...handlers);
124
- return;
125
- }
126
- normal.push(...handlers);
127
- }
128
- };
129
- const context = {
130
- app,
131
- hooks: { pre: [], post: [] },
132
- setStage: (next) => {
133
- stage = next;
134
- }
135
- };
136
- const result = runWithContext(context, () => input({ app }));
137
- const finalize = (value) => {
138
- const config2 = normalizeConfig(value);
139
- const policy = normalizeHookError(config2.hookError);
140
- const preResult = runHookSequence("pre", context.hooks.pre, policy, context.setStage);
141
- const runPost = () => runHookSequence("post", context.hooks.post, policy, context.setStage);
142
- if (isPromise(preResult)) {
143
- return preResult.then(runPost).then(() => attachMetadata(config2, { pre, normal, post }));
144
- }
145
- const postResult = runPost();
146
- if (isPromise(postResult)) {
147
- return postResult.then(() => attachMetadata(config2, { pre, normal, post }));
148
- }
149
- return attachMetadata(config2, { pre, normal, post });
150
- };
151
- if (isPromise(result)) {
152
- return result.then(finalize);
153
- }
154
- return finalize(result);
155
- }
156
- const config = normalizeConfig(input);
157
- return attachMetadata(config, { pre: [], normal: [], post: [] });
158
- }
159
- return {
160
- defineConfig,
161
- onBeforeAll,
162
- onAfterAll
163
- };
8
+ const contextStack = [];
9
+ function getActiveContext() {
10
+ const context = contextStack.at(-1);
11
+ if (!context) throw new Error("onBeforeAll/onAfterAll must be called inside defineConfig()");
12
+ return context;
13
+ }
14
+ function runWithContext(context, fn) {
15
+ contextStack.push(context);
16
+ try {
17
+ const result = fn();
18
+ if (isPromise(result)) return result.finally(() => {
19
+ contextStack.pop();
20
+ });
21
+ contextStack.pop();
22
+ return result;
23
+ } catch (error) {
24
+ contextStack.pop();
25
+ throw error;
26
+ }
27
+ }
28
+ function reportHookError(error, policy) {
29
+ if (policy === "silent") return;
30
+ if (policy === "warn") console.warn(`${options.logPrefix} defineConfig hook failed:`, error);
31
+ }
32
+ function runHookSequence(stage, hooks, policy, setStage) {
33
+ if (hooks.length === 0) return;
34
+ setStage(stage);
35
+ let chain = null;
36
+ const runHook = (hook) => {
37
+ try {
38
+ const result = hook();
39
+ if (isPromise(result)) return result.catch((error) => {
40
+ if (policy === "throw") throw error;
41
+ reportHookError(error, policy);
42
+ });
43
+ return;
44
+ } catch (error) {
45
+ if (policy === "throw") throw error;
46
+ reportHookError(error, policy);
47
+ return;
48
+ }
49
+ };
50
+ for (const hook of hooks) {
51
+ if (chain) {
52
+ chain = chain.then(() => runHook(hook));
53
+ continue;
54
+ }
55
+ const result = runHook(hook);
56
+ if (isPromise(result)) chain = result;
57
+ }
58
+ if (!chain) {
59
+ setStage("normal");
60
+ return;
61
+ }
62
+ return chain.finally(() => {
63
+ setStage("normal");
64
+ });
65
+ }
66
+ function attachMetadata(config, meta) {
67
+ Object.defineProperty(config, middlewareSymbol, {
68
+ value: meta,
69
+ enumerable: false
70
+ });
71
+ return config;
72
+ }
73
+ function normalizeConfig(value) {
74
+ return value && typeof value === "object" ? value : {};
75
+ }
76
+ function onBeforeAll(handler) {
77
+ if (typeof handler !== "function") throw new TypeError("onBeforeAll expects a function");
78
+ getActiveContext().hooks.pre.push(handler);
79
+ }
80
+ function onAfterAll(handler) {
81
+ if (typeof handler !== "function") throw new TypeError("onAfterAll expects a function");
82
+ getActiveContext().hooks.post.push(handler);
83
+ }
84
+ function defineConfig(input) {
85
+ if (typeof input === "function") {
86
+ const pre = [];
87
+ const normal = [];
88
+ const post = [];
89
+ let stage = "normal";
90
+ const app = { use: (...handlers) => {
91
+ if (stage === "pre") {
92
+ pre.push(...handlers);
93
+ return;
94
+ }
95
+ if (stage === "post") {
96
+ post.push(...handlers);
97
+ return;
98
+ }
99
+ normal.push(...handlers);
100
+ } };
101
+ const context = {
102
+ app,
103
+ hooks: {
104
+ pre: [],
105
+ post: []
106
+ },
107
+ setStage: (next) => {
108
+ stage = next;
109
+ }
110
+ };
111
+ const result = runWithContext(context, () => input({ app }));
112
+ const finalize = (value) => {
113
+ const config = normalizeConfig(value);
114
+ const policy = normalizeHookError(config.hookError);
115
+ const preResult = runHookSequence("pre", context.hooks.pre, policy, context.setStage);
116
+ const runPost = () => runHookSequence("post", context.hooks.post, policy, context.setStage);
117
+ if (isPromise(preResult)) return preResult.then(runPost).then(() => attachMetadata(config, {
118
+ pre,
119
+ normal,
120
+ post
121
+ }));
122
+ const postResult = runPost();
123
+ if (isPromise(postResult)) return postResult.then(() => attachMetadata(config, {
124
+ pre,
125
+ normal,
126
+ post
127
+ }));
128
+ return attachMetadata(config, {
129
+ pre,
130
+ normal,
131
+ post
132
+ });
133
+ };
134
+ const isConfigPromise = (value) => isPromise(value);
135
+ if (isConfigPromise(result)) return result.then(finalize);
136
+ return finalize(result);
137
+ }
138
+ return attachMetadata(normalizeConfig(input), {
139
+ pre: [],
140
+ normal: [],
141
+ post: []
142
+ });
143
+ }
144
+ return {
145
+ defineConfig,
146
+ onBeforeAll,
147
+ onAfterAll
148
+ };
164
149
  }
165
-
150
+ //#endregion
166
151
  export { createDefineConfig };
@@ -0,0 +1,39 @@
1
+ //#region src/diagnostic-types.d.ts
2
+ /**
3
+ * Shared diagnostic categories emitted during mokup route scanning.
4
+ *
5
+ * @example
6
+ * import type { DiagnosticCategory } from '@mokup/shared'
7
+ *
8
+ * const category: DiagnosticCategory = 'invalid-route'
9
+ */
10
+ type DiagnosticCategory = 'invalid-route' | 'unsupported-fields' | 'missing-handler' | 'duplicate-route' | 'sw-conflict';
11
+ /**
12
+ * Ordered list of all supported diagnostic categories.
13
+ *
14
+ * @example
15
+ * import { diagnosticCategories } from '@mokup/shared'
16
+ *
17
+ * diagnosticCategories.includes('invalid-route')
18
+ */
19
+ declare const diagnosticCategories: readonly ["invalid-route", "unsupported-fields", "missing-handler", "duplicate-route", "sw-conflict"];
20
+ /**
21
+ * Runtime guard for supported diagnostic categories.
22
+ *
23
+ * @example
24
+ * import { isDiagnosticCategory } from '@mokup/shared'
25
+ *
26
+ * isDiagnosticCategory('invalid-route')
27
+ */
28
+ declare function isDiagnosticCategory(value: string): value is DiagnosticCategory;
29
+ /**
30
+ * Controls which diagnostics should fail instead of warn.
31
+ *
32
+ * @example
33
+ * import type { DiagnosticErrorMode } from '@mokup/shared'
34
+ *
35
+ * const errorOn: DiagnosticErrorMode = ['invalid-route']
36
+ */
37
+ type DiagnosticErrorMode = 'all' | DiagnosticCategory[];
38
+ //#endregion
39
+ export { isDiagnosticCategory as i, DiagnosticErrorMode as n, diagnosticCategories as r, DiagnosticCategory as t };
@@ -0,0 +1,39 @@
1
+ //#region src/diagnostic-types.d.ts
2
+ /**
3
+ * Shared diagnostic categories emitted during mokup route scanning.
4
+ *
5
+ * @example
6
+ * import type { DiagnosticCategory } from '@mokup/shared'
7
+ *
8
+ * const category: DiagnosticCategory = 'invalid-route'
9
+ */
10
+ type DiagnosticCategory = 'invalid-route' | 'unsupported-fields' | 'missing-handler' | 'duplicate-route' | 'sw-conflict';
11
+ /**
12
+ * Ordered list of all supported diagnostic categories.
13
+ *
14
+ * @example
15
+ * import { diagnosticCategories } from '@mokup/shared'
16
+ *
17
+ * diagnosticCategories.includes('invalid-route')
18
+ */
19
+ declare const diagnosticCategories: readonly ["invalid-route", "unsupported-fields", "missing-handler", "duplicate-route", "sw-conflict"];
20
+ /**
21
+ * Runtime guard for supported diagnostic categories.
22
+ *
23
+ * @example
24
+ * import { isDiagnosticCategory } from '@mokup/shared'
25
+ *
26
+ * isDiagnosticCategory('invalid-route')
27
+ */
28
+ declare function isDiagnosticCategory(value: string): value is DiagnosticCategory;
29
+ /**
30
+ * Controls which diagnostics should fail instead of warn.
31
+ *
32
+ * @example
33
+ * import type { DiagnosticErrorMode } from '@mokup/shared'
34
+ *
35
+ * const errorOn: DiagnosticErrorMode = ['invalid-route']
36
+ */
37
+ type DiagnosticErrorMode = 'all' | DiagnosticCategory[];
38
+ //#endregion
39
+ export { isDiagnosticCategory as i, DiagnosticErrorMode as n, diagnosticCategories as r, DiagnosticCategory as t };
@@ -0,0 +1,2 @@
1
+ import { i as isDiagnosticCategory, n as DiagnosticErrorMode, r as diagnosticCategories, t as DiagnosticCategory } from "./diagnostic-types-DqAzUbgn.mjs";
2
+ export { DiagnosticCategory, DiagnosticErrorMode, diagnosticCategories, isDiagnosticCategory };
@@ -0,0 +1,2 @@
1
+ import { i as isDiagnosticCategory, n as DiagnosticErrorMode, r as diagnosticCategories, t as DiagnosticCategory } from "./diagnostic-types-DqAzUbgn.mjs";
2
+ export { DiagnosticCategory, DiagnosticErrorMode, diagnosticCategories, isDiagnosticCategory };
@@ -0,0 +1,29 @@
1
+ //#region src/diagnostic-types.ts
2
+ /**
3
+ * Ordered list of all supported diagnostic categories.
4
+ *
5
+ * @example
6
+ * import { diagnosticCategories } from '@mokup/shared'
7
+ *
8
+ * diagnosticCategories.includes('invalid-route')
9
+ */
10
+ const diagnosticCategories = [
11
+ "invalid-route",
12
+ "unsupported-fields",
13
+ "missing-handler",
14
+ "duplicate-route",
15
+ "sw-conflict"
16
+ ];
17
+ /**
18
+ * Runtime guard for supported diagnostic categories.
19
+ *
20
+ * @example
21
+ * import { isDiagnosticCategory } from '@mokup/shared'
22
+ *
23
+ * isDiagnosticCategory('invalid-route')
24
+ */
25
+ function isDiagnosticCategory(value) {
26
+ return diagnosticCategories.includes(value);
27
+ }
28
+ //#endregion
29
+ export { diagnosticCategories, isDiagnosticCategory };
@@ -0,0 +1,101 @@
1
+ //#region src/diagnostics.d.ts
2
+ interface DiagnosticSummarySection<TCategory extends string = string> {
3
+ category?: TCategory;
4
+ label: string;
5
+ items?: string[];
6
+ count?: number;
7
+ advice?: string;
8
+ }
9
+ declare const routeDiagnosticCatalog: {
10
+ readonly invalidRoute: {
11
+ readonly category: "invalid-route";
12
+ readonly label: "invalid route files ignored";
13
+ readonly advice: "Add a method suffix like .get.ts and avoid unsupported route group segments.";
14
+ };
15
+ readonly unsupportedFields: {
16
+ readonly category: "unsupported-fields";
17
+ readonly label: "routes skipped for unsupported rule fields";
18
+ readonly advice: "Use handler, headers, status, and delay in route rules; do not use legacy response, url, or method fields.";
19
+ };
20
+ readonly missingHandler: {
21
+ readonly category: "missing-handler";
22
+ readonly label: "routes skipped without handler";
23
+ readonly advice: "Export a handler value or function for every enabled rule.";
24
+ };
25
+ readonly duplicateRoute: {
26
+ readonly category: "duplicate-route";
27
+ readonly label: "duplicate route definitions";
28
+ readonly advice: "Keep each method + route path unique across scanned files.";
29
+ };
30
+ };
31
+ declare const swConflictDiagnostic: {
32
+ readonly category: "sw-conflict";
33
+ readonly label: "service worker config conflicts";
34
+ readonly advice: "Align sw.path, sw.scope, sw.register, and sw.unregister across entries that use SW mode.";
35
+ };
36
+ declare function collectSwConflictDiagnosticWarning(params: {
37
+ message: string;
38
+ onConflict?: (value: string) => void;
39
+ }): boolean;
40
+ declare function collectRouteDiagnosticWarning(params: {
41
+ message: string;
42
+ onUnsupportedFields?: (value: string) => void;
43
+ onMissingHandler?: (value: string) => void;
44
+ onDuplicateRoute?: (value: string) => void;
45
+ }): void;
46
+ declare function createRouteDiagnosticSections(params: {
47
+ invalidRoutes?: string[];
48
+ unsupportedFields?: string[];
49
+ missingHandlers?: string[];
50
+ duplicateRoutes?: string[];
51
+ }): ({
52
+ items: string[];
53
+ category: "invalid-route";
54
+ label: "invalid route files ignored";
55
+ advice: "Add a method suffix like .get.ts and avoid unsupported route group segments.";
56
+ } | {
57
+ items: string[];
58
+ category: "unsupported-fields";
59
+ label: "routes skipped for unsupported rule fields";
60
+ advice: "Use handler, headers, status, and delay in route rules; do not use legacy response, url, or method fields.";
61
+ } | {
62
+ items: string[];
63
+ category: "missing-handler";
64
+ label: "routes skipped without handler";
65
+ advice: "Export a handler value or function for every enabled rule.";
66
+ } | {
67
+ items: string[];
68
+ category: "duplicate-route";
69
+ label: "duplicate route definitions";
70
+ advice: "Keep each method + route path unique across scanned files.";
71
+ })[];
72
+ declare function createSwConflictDiagnosticSections(messages?: string[]): {
73
+ items: string[];
74
+ category: "sw-conflict";
75
+ label: "service worker config conflicts";
76
+ advice: "Align sw.path, sw.scope, sw.register, and sw.unregister across entries that use SW mode.";
77
+ }[];
78
+ declare function buildDiagnosticSummaryLines<TCategory extends string>(params: {
79
+ title?: string;
80
+ sections: DiagnosticSummarySection<TCategory>[];
81
+ maxItems?: number;
82
+ }): string[];
83
+ declare function createDiagnosticError<TCategory extends string>(params: {
84
+ errorOn?: 'all' | TCategory[];
85
+ sections: DiagnosticSummarySection<TCategory>[];
86
+ title?: string;
87
+ maxItems?: number;
88
+ }): Error | null;
89
+ declare function reportDiagnostics<TCategory extends string>(params: {
90
+ errorOn?: 'all' | TCategory[];
91
+ sections: DiagnosticSummarySection<TCategory>[];
92
+ title?: string;
93
+ errorTitle?: string;
94
+ maxItems?: number;
95
+ warn?: (message: string) => void;
96
+ }): {
97
+ summaryLines: string[];
98
+ error: Error | null;
99
+ };
100
+ //#endregion
101
+ export { createDiagnosticError as a, reportDiagnostics as c, collectSwConflictDiagnosticWarning as i, routeDiagnosticCatalog as l, buildDiagnosticSummaryLines as n, createRouteDiagnosticSections as o, collectRouteDiagnosticWarning as r, createSwConflictDiagnosticSections as s, DiagnosticSummarySection as t, swConflictDiagnostic as u };
@@ -0,0 +1,101 @@
1
+ //#region src/diagnostics.d.ts
2
+ interface DiagnosticSummarySection<TCategory extends string = string> {
3
+ category?: TCategory;
4
+ label: string;
5
+ items?: string[];
6
+ count?: number;
7
+ advice?: string;
8
+ }
9
+ declare const routeDiagnosticCatalog: {
10
+ readonly invalidRoute: {
11
+ readonly category: "invalid-route";
12
+ readonly label: "invalid route files ignored";
13
+ readonly advice: "Add a method suffix like .get.ts and avoid unsupported route group segments.";
14
+ };
15
+ readonly unsupportedFields: {
16
+ readonly category: "unsupported-fields";
17
+ readonly label: "routes skipped for unsupported rule fields";
18
+ readonly advice: "Use handler, headers, status, and delay in route rules; do not use legacy response, url, or method fields.";
19
+ };
20
+ readonly missingHandler: {
21
+ readonly category: "missing-handler";
22
+ readonly label: "routes skipped without handler";
23
+ readonly advice: "Export a handler value or function for every enabled rule.";
24
+ };
25
+ readonly duplicateRoute: {
26
+ readonly category: "duplicate-route";
27
+ readonly label: "duplicate route definitions";
28
+ readonly advice: "Keep each method + route path unique across scanned files.";
29
+ };
30
+ };
31
+ declare const swConflictDiagnostic: {
32
+ readonly category: "sw-conflict";
33
+ readonly label: "service worker config conflicts";
34
+ readonly advice: "Align sw.path, sw.scope, sw.register, and sw.unregister across entries that use SW mode.";
35
+ };
36
+ declare function collectSwConflictDiagnosticWarning(params: {
37
+ message: string;
38
+ onConflict?: (value: string) => void;
39
+ }): boolean;
40
+ declare function collectRouteDiagnosticWarning(params: {
41
+ message: string;
42
+ onUnsupportedFields?: (value: string) => void;
43
+ onMissingHandler?: (value: string) => void;
44
+ onDuplicateRoute?: (value: string) => void;
45
+ }): void;
46
+ declare function createRouteDiagnosticSections(params: {
47
+ invalidRoutes?: string[];
48
+ unsupportedFields?: string[];
49
+ missingHandlers?: string[];
50
+ duplicateRoutes?: string[];
51
+ }): ({
52
+ items: string[];
53
+ category: "invalid-route";
54
+ label: "invalid route files ignored";
55
+ advice: "Add a method suffix like .get.ts and avoid unsupported route group segments.";
56
+ } | {
57
+ items: string[];
58
+ category: "unsupported-fields";
59
+ label: "routes skipped for unsupported rule fields";
60
+ advice: "Use handler, headers, status, and delay in route rules; do not use legacy response, url, or method fields.";
61
+ } | {
62
+ items: string[];
63
+ category: "missing-handler";
64
+ label: "routes skipped without handler";
65
+ advice: "Export a handler value or function for every enabled rule.";
66
+ } | {
67
+ items: string[];
68
+ category: "duplicate-route";
69
+ label: "duplicate route definitions";
70
+ advice: "Keep each method + route path unique across scanned files.";
71
+ })[];
72
+ declare function createSwConflictDiagnosticSections(messages?: string[]): {
73
+ items: string[];
74
+ category: "sw-conflict";
75
+ label: "service worker config conflicts";
76
+ advice: "Align sw.path, sw.scope, sw.register, and sw.unregister across entries that use SW mode.";
77
+ }[];
78
+ declare function buildDiagnosticSummaryLines<TCategory extends string>(params: {
79
+ title?: string;
80
+ sections: DiagnosticSummarySection<TCategory>[];
81
+ maxItems?: number;
82
+ }): string[];
83
+ declare function createDiagnosticError<TCategory extends string>(params: {
84
+ errorOn?: 'all' | TCategory[];
85
+ sections: DiagnosticSummarySection<TCategory>[];
86
+ title?: string;
87
+ maxItems?: number;
88
+ }): Error | null;
89
+ declare function reportDiagnostics<TCategory extends string>(params: {
90
+ errorOn?: 'all' | TCategory[];
91
+ sections: DiagnosticSummarySection<TCategory>[];
92
+ title?: string;
93
+ errorTitle?: string;
94
+ maxItems?: number;
95
+ warn?: (message: string) => void;
96
+ }): {
97
+ summaryLines: string[];
98
+ error: Error | null;
99
+ };
100
+ //#endregion
101
+ export { createDiagnosticError as a, reportDiagnostics as c, collectSwConflictDiagnosticWarning as i, routeDiagnosticCatalog as l, buildDiagnosticSummaryLines as n, createRouteDiagnosticSections as o, collectRouteDiagnosticWarning as r, createSwConflictDiagnosticSections as s, DiagnosticSummarySection as t, swConflictDiagnostic as u };
@@ -0,0 +1,2 @@
1
+ import { a as createDiagnosticError, c as reportDiagnostics, i as collectSwConflictDiagnosticWarning, l as routeDiagnosticCatalog, n as buildDiagnosticSummaryLines, o as createRouteDiagnosticSections, r as collectRouteDiagnosticWarning, s as createSwConflictDiagnosticSections, t as DiagnosticSummarySection, u as swConflictDiagnostic } from "./diagnostics-C3QaEtqE.mjs";
2
+ export { DiagnosticSummarySection, buildDiagnosticSummaryLines, collectRouteDiagnosticWarning, collectSwConflictDiagnosticWarning, createDiagnosticError, createRouteDiagnosticSections, createSwConflictDiagnosticSections, reportDiagnostics, routeDiagnosticCatalog, swConflictDiagnostic };
@@ -0,0 +1,2 @@
1
+ import { a as createDiagnosticError, c as reportDiagnostics, i as collectSwConflictDiagnosticWarning, l as routeDiagnosticCatalog, n as buildDiagnosticSummaryLines, o as createRouteDiagnosticSections, r as collectRouteDiagnosticWarning, s as createSwConflictDiagnosticSections, t as DiagnosticSummarySection, u as swConflictDiagnostic } from "./diagnostics-C3QaEtqE.mjs";
2
+ export { DiagnosticSummarySection, buildDiagnosticSummaryLines, collectRouteDiagnosticWarning, collectSwConflictDiagnosticWarning, createDiagnosticError, createRouteDiagnosticSections, createSwConflictDiagnosticSections, reportDiagnostics, routeDiagnosticCatalog, swConflictDiagnostic };