@guren/server 0.1.1-alpha.3 → 0.1.1-alpha.5
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.
- package/dist/index.js +18 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1071,10 +1071,12 @@ var Application = class {
|
|
|
1071
1071
|
import { serveStatic } from "hono/bun";
|
|
1072
1072
|
import { dirname, extname, resolve } from "path";
|
|
1073
1073
|
import { fileURLToPath } from "url";
|
|
1074
|
+
import { createRequire } from "module";
|
|
1074
1075
|
var DEFAULT_PREFIX = "/resources/js";
|
|
1075
1076
|
var DEFAULT_VENDOR_PATH = "/vendor/inertia-client.tsx";
|
|
1076
1077
|
var DEFAULT_JSX_RUNTIME = "https://esm.sh/react@19.0.0/jsx-dev-runtime?dev";
|
|
1077
|
-
var
|
|
1078
|
+
var require2 = createRequire(import.meta.url);
|
|
1079
|
+
var gurenInertiaClient = require2.resolve("@guren/inertia-client/app");
|
|
1078
1080
|
function registerDevAssets(app, options) {
|
|
1079
1081
|
if (typeof Bun === "undefined") {
|
|
1080
1082
|
throw new Error("Bun runtime is required for dev asset serving.");
|
|
@@ -1103,7 +1105,21 @@ function registerDevAssets(app, options) {
|
|
|
1103
1105
|
const tsTranspiler = new Bun.Transpiler({ loader: "ts", ...transpilerOptions });
|
|
1104
1106
|
app.hono.get(`${prefix}/*`, (ctx) => handleTranspileRequest(ctx, resourcesJsDir, prefix, reactImportPattern, tsxTranspiler, tsTranspiler, jsxRuntimeUrl));
|
|
1105
1107
|
if (options.inertiaClient !== false) {
|
|
1106
|
-
|
|
1108
|
+
const inertiaClientDir = dirname(inertiaClientSource);
|
|
1109
|
+
const inertiaClientBase = inertiaClientPath.replace(/[^/]*$/u, "") || "/";
|
|
1110
|
+
const inertiaClientPattern = `${inertiaClientBase.endsWith("/") ? inertiaClientBase : `${inertiaClientBase}/`}*`;
|
|
1111
|
+
const inertiaClientRequestPath = inertiaClientPath.slice(inertiaClientBase.length);
|
|
1112
|
+
app.hono.get(inertiaClientPattern, (ctx) => {
|
|
1113
|
+
const relativeRequest = ctx.req.path.slice(inertiaClientBase.length) || inertiaClientRequestPath;
|
|
1114
|
+
if (relativeRequest === inertiaClientRequestPath) {
|
|
1115
|
+
return transpileFile(inertiaClientSource, reactImportPattern, tsxTranspiler, tsTranspiler, jsxRuntimeUrl);
|
|
1116
|
+
}
|
|
1117
|
+
const candidatePath = resolve(inertiaClientDir, relativeRequest);
|
|
1118
|
+
if (!candidatePath.startsWith(inertiaClientDir)) {
|
|
1119
|
+
return ctx.notFound();
|
|
1120
|
+
}
|
|
1121
|
+
return transpileFile(candidatePath, reactImportPattern, tsxTranspiler, tsTranspiler, jsxRuntimeUrl);
|
|
1122
|
+
});
|
|
1107
1123
|
}
|
|
1108
1124
|
const publicPathOption = options.publicPath === void 0 ? "../public" : options.publicPath;
|
|
1109
1125
|
const publicDir = options.publicDir ?? (moduleDir && publicPathOption ? resolve(moduleDir, publicPathOption) : void 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/server",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"test": "bun test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@guren/inertia-client": "^0.1.1-alpha.
|
|
40
|
+
"@guren/inertia-client": "^0.1.1-alpha.5",
|
|
41
41
|
"hono": "^4.4.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|