@guren/server 0.1.1-alpha.4 → 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.
Files changed (2) hide show
  1. package/dist/index.js +15 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1105,7 +1105,21 @@ function registerDevAssets(app, options) {
1105
1105
  const tsTranspiler = new Bun.Transpiler({ loader: "ts", ...transpilerOptions });
1106
1106
  app.hono.get(`${prefix}/*`, (ctx) => handleTranspileRequest(ctx, resourcesJsDir, prefix, reactImportPattern, tsxTranspiler, tsTranspiler, jsxRuntimeUrl));
1107
1107
  if (options.inertiaClient !== false) {
1108
- app.hono.get(inertiaClientPath, () => transpileFile(inertiaClientSource, reactImportPattern, tsxTranspiler, tsTranspiler, jsxRuntimeUrl));
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
+ });
1109
1123
  }
1110
1124
  const publicPathOption = options.publicPath === void 0 ? "../public" : options.publicPath;
1111
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.4",
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.4",
40
+ "@guren/inertia-client": "^0.1.1-alpha.5",
41
41
  "hono": "^4.4.0"
42
42
  },
43
43
  "devDependencies": {