bun-plugin-stx 0.2.147 → 0.2.149
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.
|
@@ -75,21 +75,35 @@ function filePathToPattern(filePath, pagesDir) {
|
|
|
75
75
|
}
|
|
76
76
|
function patternToRegex(pattern) {
|
|
77
77
|
const params = [];
|
|
78
|
-
let regexStr =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
let regexStr = "";
|
|
79
|
+
let i = 0;
|
|
80
|
+
while (i < pattern.length) {
|
|
81
|
+
const rest = pattern.slice(i);
|
|
82
|
+
const optional = /^\/:([^/?*]+)\?/.exec(rest);
|
|
83
|
+
if (optional) {
|
|
84
|
+
params.push(optional[1]);
|
|
85
|
+
regexStr += "(?:/([^/]+))?";
|
|
86
|
+
i += optional[0].length;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const catchAll = /^:([^/?*]+)\*/.exec(rest);
|
|
90
|
+
if (catchAll) {
|
|
91
|
+
params.push(catchAll[1]);
|
|
92
|
+
regexStr += "(.+)";
|
|
93
|
+
i += catchAll[0].length;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const required = /^:([^/?*]+)/.exec(rest);
|
|
97
|
+
if (required) {
|
|
98
|
+
params.push(required[1]);
|
|
99
|
+
regexStr += "([^/]+)";
|
|
100
|
+
i += required[0].length;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
regexStr += pattern[i].replace(/[.+^${}()|[\]\\*?]/g, "\\$&");
|
|
104
|
+
i += 1;
|
|
105
|
+
}
|
|
106
|
+
return { regex: new RegExp(`^${regexStr}$`), params };
|
|
93
107
|
}
|
|
94
108
|
function matchRoute(pathname, routes) {
|
|
95
109
|
const normalizedPath = pathname === "" ? "/" : pathname;
|
package/dist/serve.js
CHANGED
|
@@ -8299,6 +8299,8 @@ class ConfigLoader2 {
|
|
|
8299
8299
|
try {
|
|
8300
8300
|
result = await this.loadConfigurationStrategies(baseOptions, true, cache);
|
|
8301
8301
|
} catch (error) {
|
|
8302
|
+
if (baseOptions.configFile)
|
|
8303
|
+
throw error;
|
|
8302
8304
|
const isStrictMode = baseOptions.__strictErrorHandling;
|
|
8303
8305
|
if (error instanceof Error && error.name === "ConfigNotFoundError") {
|
|
8304
8306
|
if (isStrictMode) {
|
|
@@ -8373,6 +8375,7 @@ class ConfigLoader2 {
|
|
|
8373
8375
|
const {
|
|
8374
8376
|
name = "",
|
|
8375
8377
|
alias,
|
|
8378
|
+
configFile,
|
|
8376
8379
|
cwd,
|
|
8377
8380
|
configDir,
|
|
8378
8381
|
defaultConfig: defaultConfig4,
|
|
@@ -8382,6 +8385,17 @@ class ConfigLoader2 {
|
|
|
8382
8385
|
} = options;
|
|
8383
8386
|
const baseDir = cwd || process20.cwd();
|
|
8384
8387
|
const searchPaths = [];
|
|
8388
|
+
if (configFile) {
|
|
8389
|
+
const explicitPath = resolve12(baseDir, configFile);
|
|
8390
|
+
searchPaths.push(explicitPath);
|
|
8391
|
+
const envDefaults = checkEnv ? applyEnvVarsToConfig3(name, defaultConfig4, verbose) : defaultConfig4;
|
|
8392
|
+
const explicitResult = await this.fileLoader.tryLoadFromPaths([explicitPath], envDefaults, { arrayStrategy, verbose, cacheTtl: cacheOptions?.ttl, useCache: !cacheOptions?.ttl || cacheOptions.ttl > 100 });
|
|
8393
|
+
if (!explicitResult)
|
|
8394
|
+
throw ErrorFactory2.configNotFound(name || configFile, searchPaths, alias);
|
|
8395
|
+
if (verbose)
|
|
8396
|
+
log3.success(`Configuration loaded from explicit path: ${explicitPath}`);
|
|
8397
|
+
return this.finalizeResult(explicitResult, searchPaths, checkEnv, name, verbose);
|
|
8398
|
+
}
|
|
8385
8399
|
const localResult = await this.loadLocalConfiguration(name, alias, baseDir, configDir, defaultConfig4, arrayStrategy, verbose, checkEnv, cacheOptions);
|
|
8386
8400
|
if (localResult) {
|
|
8387
8401
|
searchPaths.push(...this.getLocalSearchPaths(name, alias, baseDir, configDir));
|
|
@@ -8569,6 +8583,8 @@ class ConfigLoader2 {
|
|
|
8569
8583
|
}
|
|
8570
8584
|
if (options.cwd)
|
|
8571
8585
|
keyParts.push(`cwd:${options.cwd}`);
|
|
8586
|
+
if (options.configFile)
|
|
8587
|
+
keyParts.push(`configFile:${options.configFile}`);
|
|
8572
8588
|
if (options.configDir)
|
|
8573
8589
|
keyParts.push(`configDir:${options.configDir}`);
|
|
8574
8590
|
if ("checkEnv" in options)
|
|
@@ -8629,6 +8645,8 @@ async function loadConfig6(options) {
|
|
|
8629
8645
|
}
|
|
8630
8646
|
return result?.config ?? defaultConfig4;
|
|
8631
8647
|
} catch (error) {
|
|
8648
|
+
if (options.configFile)
|
|
8649
|
+
throw error;
|
|
8632
8650
|
const errorName = error instanceof Error ? error.name : "UnknownError";
|
|
8633
8651
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
8634
8652
|
const isConfigError = errorName === "ConfigNotFoundError" || errorName === "ConfigLoadError" || errorName === "ConfigValidationError" || errorMessage.includes("config");
|
|
@@ -8696,8 +8714,8 @@ function applyEnvVarsToConfig3(name, config6, verbose = false) {
|
|
|
8696
8714
|
}
|
|
8697
8715
|
return processConfigLevel(config6);
|
|
8698
8716
|
}
|
|
8699
|
-
var defaultConfigDir4 = resolve12(process20.cwd(), "config");
|
|
8700
|
-
var defaultGeneratedDir4 = resolve12(process20.cwd(), "src/generated");
|
|
8717
|
+
var defaultConfigDir4 = /* @__PURE__ */ resolve12(process20.cwd(), "config");
|
|
8718
|
+
var defaultGeneratedDir4 = /* @__PURE__ */ resolve12(process20.cwd(), "src/generated");
|
|
8701
8719
|
|
|
8702
8720
|
// src/serve.ts
|
|
8703
8721
|
import { extractPageResponseStatus, stateDir, stateDirName } from "@stacksjs/stx";
|
|
@@ -9343,7 +9361,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9343
9361
|
pageMiddlewarePatterns.length = 0;
|
|
9344
9362
|
await Promise.all(files.map((f) => detectPageMiddleware(f)));
|
|
9345
9363
|
try {
|
|
9346
|
-
const { Router } = await import("./chunk-
|
|
9364
|
+
const { Router } = await import("./chunk-7nan8etz.js");
|
|
9347
9365
|
const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
|
|
9348
9366
|
const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName() });
|
|
9349
9367
|
if (!options.quiet)
|
package/package.json
CHANGED