@wolfstar/http-framework 4.0.2 → 5.0.0-next-20260919094537

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.
@@ -23,31 +23,247 @@ declare function discoverConfigFile(cwd: string): string | null;
23
23
  declare function loadConfigFile(options: LoadConfigFileOptions): Promise<LoadedConfigFile>;
24
24
  //#endregion
25
25
  //#region src/lib/config/errors.d.ts
26
- interface ConfigErrorOptions {
27
- /** A stable, machine readable code, e.g. `INVALID_TYPE`. */
28
- code: string;
29
- /** A short, actionable suggestion. */
30
- hint?: string;
31
- /** The dotted path of the offending option, e.g. `dev.debounce`. */
32
- path?: string;
33
- /** The configuration file the error originates from. */
34
- file?: string | null;
35
- cause?: unknown;
36
- }
37
26
  /**
38
- * A `stars.config.*` error: an invalid option, or a file that failed to load or parse.
27
+ * Structured, stable diagnostic codes for every way a `stars.config.*` can fail to load or validate.
28
+ *
29
+ * This is a plain data error (no exit code or terminal formatting), so nothing here reports anywhere on its own —
30
+ * `reporters` stays empty and each call only builds and returns a `Diagnostic`. That keeps it meaningful outside a
31
+ * CLI, e.g. for a dashboard or test that calls {@link loadStarsConfig} directly; `@wolfstar/cli` is what renders it
32
+ * and picks an exit code (`exitCodeOf`).
39
33
  *
40
- * This is a plain data error (no exit code or terminal formatting) so it stays meaningful outside a CLI, e.g. for a
41
- * dashboard or test that calls {@link loadStarsConfig} directly. `@wolfstar/cli` maps it to exit code `2` and renders
42
- * `message`, `path`, `file` and `hint` for the terminal.
34
+ * The `sources` field (populated with the configuration file, when there is one) carries the "which file" grounding
35
+ * `ConfigError` used to expose as `.file`; the "which option" grounding it exposed as `.path` is folded directly into
36
+ * every `why`/`fix` message instead, the way every other diagnostic code already reads.
37
+ *
38
+ * `why` and `fix` are always given the same, fully-typed params object (even when one of them ignores part of it):
39
+ * a bare `() => value` loses nostics' param-type inference (a zero-arg function widens to `unknown` params), so every
40
+ * entry here spells out its shape on both sides instead.
43
41
  */
44
- declare class ConfigError extends Error {
45
- readonly code: string;
46
- readonly hint: string | null;
47
- readonly path: string | null;
48
- readonly file: string | null;
49
- constructor(message: string, options: ConfigErrorOptions);
50
- }
42
+ declare const configDiagnostics: import("nostics").Diagnostics<{
43
+ readonly ROOT_NOT_FOUND: {
44
+ why: (p: {
45
+ root: string;
46
+ }) => string;
47
+ fix: (_p: {
48
+ root: string;
49
+ }) => string;
50
+ };
51
+ readonly PACKAGE_JSON_INVALID: {
52
+ why: (p: {
53
+ file: string;
54
+ message: string;
55
+ }) => string;
56
+ fix: (_p: {
57
+ file: string;
58
+ message: string;
59
+ }) => string;
60
+ };
61
+ readonly ENTRY_NOT_FOUND: {
62
+ why: (p: {
63
+ entry: string;
64
+ }) => string;
65
+ fix: (_p: {
66
+ entry: string;
67
+ }) => string;
68
+ };
69
+ readonly ENTRY_DEFAULT_NOT_FOUND: {
70
+ why: (p: {
71
+ root: string;
72
+ defaults: string;
73
+ }) => string;
74
+ fix: (p: {
75
+ root: string;
76
+ defaults: string;
77
+ }) => string;
78
+ };
79
+ readonly INVALID_BUILD_TOOL: {
80
+ why: (p: {
81
+ tool: string;
82
+ }) => string;
83
+ fix: (_p: {
84
+ tool: string;
85
+ }) => string;
86
+ };
87
+ readonly EXPERIMENTAL_BUILD_TOOL: {
88
+ why: (p: {
89
+ tool: string;
90
+ flag: string;
91
+ }) => string;
92
+ fix: (p: {
93
+ tool: string;
94
+ flag: string;
95
+ }) => string;
96
+ };
97
+ readonly BUILD_TOOL_REQUIRED: {
98
+ why: (p: {
99
+ entry: string;
100
+ }) => string;
101
+ fix: (_p: {
102
+ entry: string;
103
+ }) => string;
104
+ };
105
+ readonly TSCONFIG_EXPLICIT_NOT_FOUND: {
106
+ why: (p: {
107
+ tsconfig: string;
108
+ path: string;
109
+ }) => string;
110
+ fix: (p: {
111
+ tsconfig: string;
112
+ path: string;
113
+ }) => string;
114
+ };
115
+ readonly TSCONFIG_NOT_FOUND: {
116
+ why: (p: {
117
+ root: string;
118
+ suggestion: string;
119
+ }) => string;
120
+ fix: (p: {
121
+ root: string;
122
+ suggestion: string;
123
+ }) => string;
124
+ };
125
+ readonly TSDOWN_OPTIONS_REQUIRE_TSDOWN: {
126
+ why: (_p: {
127
+ tool: string;
128
+ }) => string;
129
+ fix: (p: {
130
+ tool: string;
131
+ }) => string;
132
+ };
133
+ readonly VITE_OPTIONS_REQUIRE_VITE: {
134
+ why: (_p: {
135
+ tool: string;
136
+ }) => string;
137
+ fix: (p: {
138
+ tool: string;
139
+ }) => string;
140
+ };
141
+ readonly TSDOWN_CONFIG_FILE_UNSUPPORTED: {
142
+ why: (p: {
143
+ file: string;
144
+ version: number;
145
+ legacyVersion: number;
146
+ }) => string;
147
+ fix: (p: {
148
+ file: string;
149
+ version: number;
150
+ legacyVersion: number;
151
+ }) => string;
152
+ };
153
+ readonly INVALID_TYPE: {
154
+ why: (p: {
155
+ path: string;
156
+ expected: string;
157
+ value: unknown;
158
+ fix: string;
159
+ }) => string;
160
+ fix: (p: {
161
+ path: string;
162
+ expected: string;
163
+ value: unknown;
164
+ fix: string;
165
+ }) => string;
166
+ };
167
+ readonly INVALID_COMPATIBILITY_VERSION: {
168
+ why: (p: {
169
+ value: unknown;
170
+ legacyVersion: number;
171
+ latestVersion: number;
172
+ }) => string;
173
+ fix: (p: {
174
+ value: unknown;
175
+ legacyVersion: number;
176
+ latestVersion: number;
177
+ }) => string;
178
+ };
179
+ readonly UNKNOWN_OPTION: {
180
+ why: (p: {
181
+ path: string;
182
+ parent: string;
183
+ known: string;
184
+ }) => string;
185
+ fix: (p: {
186
+ path: string;
187
+ parent: string;
188
+ known: string;
189
+ }) => string;
190
+ };
191
+ readonly EXPERIMENT_REQUIRED: {
192
+ why: (p: {
193
+ path: string;
194
+ requires: string;
195
+ drop: string;
196
+ }) => string;
197
+ fix: (p: {
198
+ path: string;
199
+ requires: string;
200
+ drop: string;
201
+ }) => string;
202
+ };
203
+ readonly IMPORTS_REQUIRE_TSDOWN: {
204
+ why: (_p: {}) => string;
205
+ fix: (_p: {}) => string;
206
+ };
207
+ readonly LOCALES_NOT_FOUND: {
208
+ why: (p: {
209
+ locales: string;
210
+ }) => string;
211
+ fix: (_p: {
212
+ locales: string;
213
+ }) => string;
214
+ };
215
+ readonly INVALID_URL: {
216
+ why: (p: {
217
+ url: string;
218
+ fix: string;
219
+ }) => string;
220
+ fix: (p: {
221
+ url: string;
222
+ fix: string;
223
+ }) => string;
224
+ };
225
+ readonly TUNNEL_URL_NOT_HTTPS: {
226
+ why: (p: {
227
+ url: string;
228
+ }) => string;
229
+ fix: (_p: {
230
+ url: string;
231
+ }) => string;
232
+ };
233
+ readonly INVALID_TYPECHECKER: {
234
+ why: (p: {
235
+ checker: string;
236
+ }) => string;
237
+ fix: (_p: {
238
+ checker: string;
239
+ }) => string;
240
+ };
241
+ readonly CONFIG_NOT_FOUND: {
242
+ why: (p: {
243
+ file: string;
244
+ cwd: string;
245
+ names: string;
246
+ }) => string;
247
+ fix: (p: {
248
+ file: string;
249
+ cwd: string;
250
+ names: string;
251
+ }) => string;
252
+ };
253
+ readonly CONFIG_LOAD_FAILED: {
254
+ why: (p: {
255
+ message: string;
256
+ }) => string;
257
+ fix: (_p: {
258
+ message: string;
259
+ }) => string;
260
+ };
261
+ readonly CONFIG_NOT_OBJECT: {
262
+ why: (_p: {}) => string;
263
+ fix: (_p: {}) => string;
264
+ };
265
+ }, readonly []>;
266
+ type ConfigDiagnosticCode = keyof typeof configDiagnostics;
51
267
  //#endregion
52
268
  //#region src/lib/config/index.d.ts
53
269
  interface LoadStarsConfigOptions {
@@ -67,7 +283,7 @@ interface LoadStarsConfigOptions {
67
283
  /**
68
284
  * Loads, validates and resolves a project's `stars.config.*`.
69
285
  *
70
- * @throws {ConfigError} when the configuration file cannot be loaded or contains an invalid option.
286
+ * @throws {Diagnostic} (from `nostics`, via {@link configDiagnostics}) when the configuration file cannot be loaded or contains an invalid option.
71
287
  */
72
288
  declare function loadStarsConfig(options?: LoadStarsConfigOptions): Promise<ResolvedStarsConfig>;
73
289
  //#endregion
@@ -374,7 +590,7 @@ interface StarsNitroConfig {
374
590
  *
375
591
  * `enableExternalVite`, `enableNitro` and `nitro` build on `enableVite` (and `nitro` on `enableNitro` too): the type
376
592
  * only accepts them once their prerequisite is `true`, so turning one on without the other is a type error here
377
- * instead of a `ConfigError` at load time.
593
+ * instead of a diagnostic at load time.
378
594
  */
379
595
  type StarsExperimentalConfig = {
380
596
  enableVite?: false;
@@ -591,7 +807,7 @@ interface ResolveConfigOptions {
591
807
  /**
592
808
  * Applies defaults, validates every option and resolves all paths to absolute ones.
593
809
  *
594
- * @throws {ConfigError} with an actionable `hint` on the first invalid option.
810
+ * @throws {Diagnostic} (from `nostics`, via {@link configDiagnostics}) with an actionable `fix` on the first invalid option.
595
811
  */
596
812
  declare function resolveStarsConfig(options: ResolveConfigOptions): ResolvedStarsConfig;
597
813
  /**
@@ -608,5 +824,5 @@ declare function displayPath(root: string, path: string): string;
608
824
  */
609
825
  declare function readProjectEnvFiles(root: string, environment?: string): Record<string, string>;
610
826
  //#endregion
611
- export { StarsTypecheckConfig as A, LoadConfigFileOptions as B, StarsExperimentalConfig as C, StarsNitroConfig as D, StarsImportsConfig as E, loadStarsConfig as F, discoverConfigFile as H, ConfigError as I, ConfigErrorOptions as L, StarsViteConfig as M, defineConfig as N, StarsTsdownConfig as O, LoadStarsConfigOptions as P, CONFIG_EXTENSIONS as R, StarsDevConfig as S, StarsI18nCodegenConfig as T, loadConfigFile as U, LoadedConfigFile as V, StarsBuildConfig as _, ResolvedDevConfig as a, StarsCompatibilityVersion as b, ResolvedI18nCodegenConfig as c, ResolvedStarsConfig as d, ResolvedTunnelConfig as f, resolveStarsConfig as g, readProjectEnvFiles as h, ResolvedCodegenConfig as i, StarsTypechecker as j, StarsTunnelConfig as k, ResolvedImportsConfig as l, displayPath as m, ResolveConfigOptions as n, ResolvedExperimentalConfig as o, ResolvedTypecheckConfig as p, ResolvedBuildConfig as r, ResolvedFutureConfig as s, PackageJsonLike as t, ResolvedNitroConfig as u, StarsBuildTool as v, StarsFutureConfig as w, StarsConfig as x, StarsCodegenConfig as y, CONFIG_FILE_NAMES as z };
612
- //# sourceMappingURL=resolve-CBovxOO3.d.ts.map
827
+ export { StarsTypecheckConfig as A, LoadConfigFileOptions as B, StarsExperimentalConfig as C, StarsNitroConfig as D, StarsImportsConfig as E, loadStarsConfig as F, discoverConfigFile as H, ConfigDiagnosticCode as I, configDiagnostics as L, StarsViteConfig as M, defineConfig as N, StarsTsdownConfig as O, LoadStarsConfigOptions as P, CONFIG_EXTENSIONS as R, StarsDevConfig as S, StarsI18nCodegenConfig as T, loadConfigFile as U, LoadedConfigFile as V, StarsBuildConfig as _, ResolvedDevConfig as a, StarsCompatibilityVersion as b, ResolvedI18nCodegenConfig as c, ResolvedStarsConfig as d, ResolvedTunnelConfig as f, resolveStarsConfig as g, readProjectEnvFiles as h, ResolvedCodegenConfig as i, StarsTypechecker as j, StarsTunnelConfig as k, ResolvedImportsConfig as l, displayPath as m, ResolveConfigOptions as n, ResolvedExperimentalConfig as o, ResolvedTypecheckConfig as p, ResolvedBuildConfig as r, ResolvedFutureConfig as s, PackageJsonLike as t, ResolvedNitroConfig as u, StarsBuildTool as v, StarsFutureConfig as w, StarsConfig as x, StarsCodegenConfig as y, CONFIG_FILE_NAMES as z };
828
+ //# sourceMappingURL=resolve-Blb-IcFd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-Blb-IcFd.d.ts","names":[],"sources":["../../src/lib/config/load.ts","../../src/lib/config/errors.ts","../../src/lib/config/index.ts","../../src/config.ts","../../src/lib/config/resolve.ts"],"mappings":";cAKa;cACA;UAEI;;EAEhB;;EAEA;;UAGgB;;EAEhB;EACA,QAAQ;;;;;iBAMO,mBAAmB;;;;;iBAab,eAAe,SAAS,wBAAwB,QAAQ;;;;;;;;;;;;;;;;;;;cCnBjE,qCAAiB;;IAK3B,MAAG;MAAQ;;IACX,MAAG;MAAS;;;;IAGZ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UAAU;EACV,eAAe;EACf,kBAAkB;;UAGF;WACP,MAAM;;WAEN;;WAEA;;WAEA;;;;;;WAMA;;UAGO;WACP;;WAEA;;WAEA,SAAS;;KAGP;WACE;;;;WAEA;WAAwB;WAAuB;;;;WAE/C;WAAsB;WAAsB;WAAuB;;UAEhE;WACP;WACA;WACA;WACA;WACA,KAAK,SAAS;WACd;WACA;WACA;WACA;WACA;WACA,WAAW;WACX,QAAQ;;WAER;;UAGO;WACP;;UAGO;WACP;WACA;WACA;WACA,OAAO;;UAGA;WACP,sBAAsB;;UAGf;WACP;;WAEA;WACA;WACA;;WAEA;;UAGO;WACP;WACA;;UAGO;WACP,MAAM;;UAGC;;WAEP;;WAEA;;WAEA;WACA,aAAa;;WAEb;WACA,OAAO;WACP,KAAK;WACL,SAAS;WACT,SAAS;WACT,cAAc;WACd,QAAQ;;WAER,MAAM,SAAS;;WAEf,QAAQ,SAAS;;UAGV;EAChB;EACA;EACA,QAAQ;EACR,MAAM,OAAO;;;;;;;iBAyCE,mBAAmB,SAAS,uBAAuB;;;;iBA0CnD,YAAY,cAAc;;;;;;;;;iBAkO1B,oBAAoB,cAAc,uBAA8B"}
@@ -1,5 +1,47 @@
1
1
  import { webcrypto } from "node:crypto";
2
2
 
3
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
4
+ function _typeof(o) {
5
+ "@babel/helpers - typeof";
6
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
7
+ return typeof o;
8
+ } : function(o) {
9
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
10
+ }, _typeof(o);
11
+ }
12
+
13
+ //#endregion
14
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
15
+ function toPrimitive(t, r) {
16
+ if ("object" != _typeof(t) || !t) return t;
17
+ var e = t[Symbol.toPrimitive];
18
+ if (void 0 !== e) {
19
+ var i = e.call(t, r || "default");
20
+ if ("object" != _typeof(i)) return i;
21
+ throw new TypeError("@@toPrimitive must return a primitive value.");
22
+ }
23
+ return ("string" === r ? String : Number)(t);
24
+ }
25
+
26
+ //#endregion
27
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
28
+ function toPropertyKey(t) {
29
+ var i = toPrimitive(t, "string");
30
+ return "symbol" == _typeof(i) ? i : i + "";
31
+ }
32
+
33
+ //#endregion
34
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
35
+ function _defineProperty(e, r, t) {
36
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
37
+ value: t,
38
+ enumerable: !0,
39
+ configurable: !0,
40
+ writable: !0
41
+ }) : e[r] = t, e;
42
+ }
43
+
44
+ //#endregion
3
45
  //#region \0@oxc-project+runtime@0.149.0/helpers/esm/checkPrivateRedeclaration.js
4
46
  function _checkPrivateRedeclaration(e, t) {
5
47
  if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
@@ -53,5 +95,5 @@ async function verifyBody(body, signature, timestamp, key) {
53
95
  }
54
96
 
55
97
  //#endregion
56
- export { _assertClassBrand as a, _classPrivateFieldGet2 as i, verifyBody as n, _classPrivateFieldInitSpec as o, _classPrivateFieldSet2 as r, _checkPrivateRedeclaration as s, makeKey as t };
57
- //# sourceMappingURL=security-pO7x9isF.js.map
98
+ export { _assertClassBrand as a, _defineProperty as c, _classPrivateFieldGet2 as i, verifyBody as n, _classPrivateFieldInitSpec as o, _classPrivateFieldSet2 as r, _checkPrivateRedeclaration as s, makeKey as t };
99
+ //# sourceMappingURL=security-CDI6548c.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"security-pO7x9isF.js","names":[],"sources":["../../src/lib/utils/security.ts"],"sourcesContent":["import { webcrypto } from 'node:crypto';\n\nexport type HeaderValue = string | string[];\nexport type Key = webcrypto.CryptoKey;\n\nconst AlgorithmName = 'Ed25519';\n\nfunction headerToString(header: HeaderValue): string {\n\treturn typeof header === 'string' ? header : header[0];\n}\n\nexport function makeKey(key: string): Promise<Key> {\n\treturn webcrypto.subtle.importKey('raw', Buffer.from(key, 'hex'), { name: AlgorithmName }, true, ['verify']);\n}\n\n/**\n * Validates a payload from Discord against its signature and key.\n * @param body The request body.\n * @param signature The value of the `x-signature-ed25519` header.\n * @param signature The value of the `x-signature-timestamp` header.\n * @param key The public key from the Discord developer dashboard, generated by {@link makeKey}\n */\nexport async function verifyBody(body: string, signature: string | string[], timestamp: string | string[], key: Key) {\n\tconst signatureData = Buffer.from(headerToString(signature), 'hex');\n\tconst data = Buffer.isBuffer(body)\n\t\t? Buffer.concat([Buffer.from(headerToString(timestamp)), body])\n\t\t: Buffer.from(`${headerToString(timestamp)}${body}`);\n\n\treturn webcrypto.subtle.verify(AlgorithmName, key, signatureData, Buffer.from(data));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,gBAAgB;AAEtB,SAAS,eAAe,QAA6B;CACpD,OAAO,OAAO,WAAW,WAAW,SAAS,OAAO;AACrD;AAEA,SAAgB,QAAQ,KAA2B;CAClD,OAAO,UAAU,OAAO,UAAU,OAAO,OAAO,KAAK,KAAK,KAAK,GAAG,EAAE,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC5G;;;;;;;;AASA,eAAsB,WAAW,MAAc,WAA8B,WAA8B,KAAU;CACpH,MAAM,gBAAgB,OAAO,KAAK,eAAe,SAAS,GAAG,KAAK;CAClE,MAAM,OAAO,OAAO,SAAS,IAAI,IAC9B,OAAO,OAAO,CAAC,OAAO,KAAK,eAAe,SAAS,CAAC,GAAG,IAAI,CAAC,IAC5D,OAAO,KAAK,GAAG,eAAe,SAAS,IAAI,MAAM;CAEpD,OAAO,UAAU,OAAO,OAAO,eAAe,KAAK,eAAe,OAAO,KAAK,IAAI,CAAC;AACpF"}
1
+ {"version":3,"file":"security-CDI6548c.js","names":[],"sources":["../../src/lib/utils/security.ts"],"sourcesContent":["import { webcrypto } from 'node:crypto';\n\nexport type HeaderValue = string | string[];\nexport type Key = webcrypto.CryptoKey;\n\nconst AlgorithmName = 'Ed25519';\n\nfunction headerToString(header: HeaderValue): string {\n\treturn typeof header === 'string' ? header : header[0];\n}\n\nexport function makeKey(key: string): Promise<Key> {\n\treturn webcrypto.subtle.importKey('raw', Buffer.from(key, 'hex'), { name: AlgorithmName }, true, ['verify']);\n}\n\n/**\n * Validates a payload from Discord against its signature and key.\n * @param body The request body.\n * @param signature The value of the `x-signature-ed25519` header.\n * @param signature The value of the `x-signature-timestamp` header.\n * @param key The public key from the Discord developer dashboard, generated by {@link makeKey}\n */\nexport async function verifyBody(body: string, signature: string | string[], timestamp: string | string[], key: Key) {\n\tconst signatureData = Buffer.from(headerToString(signature), 'hex');\n\tconst data = Buffer.isBuffer(body)\n\t\t? Buffer.concat([Buffer.from(headerToString(timestamp)), body])\n\t\t: Buffer.from(`${headerToString(timestamp)}${body}`);\n\n\treturn webcrypto.subtle.verify(AlgorithmName, key, signatureData, Buffer.from(data));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,gBAAgB;AAEtB,SAAS,eAAe,QAA6B;CACpD,OAAO,OAAO,WAAW,WAAW,SAAS,OAAO;AACrD;AAEA,SAAgB,QAAQ,KAA2B;CAClD,OAAO,UAAU,OAAO,UAAU,OAAO,OAAO,KAAK,KAAK,KAAK,GAAG,EAAE,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC5G;;;;;;;;AASA,eAAsB,WAAW,MAAc,WAA8B,WAA8B,KAAU;CACpH,MAAM,gBAAgB,OAAO,KAAK,eAAe,SAAS,GAAG,KAAK;CAClE,MAAM,OAAO,OAAO,SAAS,IAAI,IAC9B,OAAO,OAAO,CAAC,OAAO,KAAK,eAAe,SAAS,CAAC,GAAG,IAAI,CAAC,IAC5D,OAAO,KAAK,GAAG,eAAe,SAAS,IAAI,MAAM;CAEpD,OAAO,UAAU,OAAO,OAAO,eAAe,KAAK,eAAe,OAAO,KAAK,IAAI,CAAC;AACpF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wolfstar/http-framework",
3
- "version": "4.0.2",
3
+ "version": "5.0.0-next-20260919094537",
4
4
  "description": "The framework for Star Network's HTTP-only bots",
5
5
  "keywords": [
6
6
  "api",
@@ -72,6 +72,7 @@
72
72
  "chokidar": "^5.0.0",
73
73
  "discord-api-types": "^0.38.8",
74
74
  "mlly": "^1.8.2",
75
+ "nostics": "^1.2.0",
75
76
  "unimport": "^7.0.2"
76
77
  },
77
78
  "devDependencies": {
@@ -1,43 +0,0 @@
1
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
2
- function _typeof(o) {
3
- "@babel/helpers - typeof";
4
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
5
- return typeof o;
6
- } : function(o) {
7
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
- }, _typeof(o);
9
- }
10
-
11
- //#endregion
12
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
13
- function toPrimitive(t, r) {
14
- if ("object" != _typeof(t) || !t) return t;
15
- var e = t[Symbol.toPrimitive];
16
- if (void 0 !== e) {
17
- var i = e.call(t, r || "default");
18
- if ("object" != _typeof(i)) return i;
19
- throw new TypeError("@@toPrimitive must return a primitive value.");
20
- }
21
- return ("string" === r ? String : Number)(t);
22
- }
23
-
24
- //#endregion
25
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
26
- function toPropertyKey(t) {
27
- var i = toPrimitive(t, "string");
28
- return "symbol" == _typeof(i) ? i : i + "";
29
- }
30
-
31
- //#endregion
32
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
33
- function _defineProperty(e, r, t) {
34
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
35
- value: t,
36
- enumerable: !0,
37
- configurable: !0,
38
- writable: !0
39
- }) : e[r] = t, e;
40
- }
41
-
42
- //#endregion
43
- export { _defineProperty as t };
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-CBovxOO3.d.ts","names":[],"sources":["../../src/lib/config/load.ts","../../src/lib/config/errors.ts","../../src/lib/config/index.ts","../../src/config.ts","../../src/lib/config/resolve.ts"],"mappings":";cAKa;cACA;UAEI;;EAEhB;;EAEA;;UAGgB;;EAEhB;EACA,QAAQ;;;;;iBAMO,mBAAmB;;;;;iBAab,eAAe,SAAS,wBAAwB,QAAQ;;;UCrC7D;;EAEhB;;EAEA;;EAEA;;EAEA;EACA;;;;;;;;;cAUY,oBAAoB;WAChB;WACA;WACA;WACA;EAEhB,YAAmB,iBAAiB,SAAS;;;;UCtB7B;;;;;EAKhB;;EAEA;;;;;EAKA,MAAM,OAAO;;;;;;;iBAQQ,gBAAgB,UAAS,yBAA8B,QAAQ;;;;;;;;;;;;;;;;;;;;;KCJzE;UAEK;;;;;EAKhB,OAAO;;;;;EAKP;;;;;EAKA;;;;;;;KAQW,kBAAkB;;;;;;;;;;;;;;UAeb;;EAEhB,qCAAqC;;EAErC,8DAA8D;;EAE9D;EACA;;;;;;EAMA;;EAEA;EACA,QAAQ;EACR,SAAS;EACT;EACA;EACA,OAAO;;EAEP;;EAEA;EACA;;EAEA,gBAAgB;;EAEhB;EACA;EACA;EACA,QAAQ;GACP;;;;;;KAOU;;;;;UAMK;;;;;;;;;;;;;;;;EAgBhB,uBAAuB;;;;;;;;;;KAWZ;UAEK;;;;;EAKhB;;;;;EAKA,UAAU;;UAGM;;;;EAIhB;;;;;;;;EAQA;;;;;EAKA;;UAGgB;;EAEhB;;;;;;EAMA;;;;;EAKA;;;;;EAKA;;;;EAIA,MAAM;;;;;EAKN;;;;;EAKA;;;;;;;;;;EAUA;;;;;EAKA;;;;;EAKA;;;;;;;EAOA,sBAAs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