@holo-js/adapter-next 0.3.18 → 0.3.20

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/config.mjs CHANGED
@@ -154,6 +154,7 @@ function withHolo(nextConfig = {}) {
154
154
  const existingIgnoreIssue = existingTurbopack.ignoreIssue ?? [];
155
155
  const hasRealtime = isOptionalServerExternalPackageInstalled("@holo-js/realtime", packageManifest);
156
156
  const validationLoader = fileURLToPath(new URL("./validation-loader.mjs", import.meta.url));
157
+ const routeLoader = fileURLToPath(new URL("./route-loader.mjs", import.meta.url));
157
158
  const realtimeDefinitionLoader = fileURLToPath(new URL("./realtime-definition-loader.mjs", import.meta.url));
158
159
  const mergedTurbopack = {
159
160
  ...existingTurbopack,
@@ -161,7 +162,8 @@ function withHolo(nextConfig = {}) {
161
162
  ...existingTurbopack.rules ?? {},
162
163
  "*": [
163
164
  ...existingTurbopack.rules?.["*"] ? [existingTurbopack.rules["*"]].flat() : [],
164
- { condition: { all: ["browser", { not: "foreign" }, { path: /\.[cm]?[jt]sx?$/ }] }, loaders: [validationLoader] }
165
+ { condition: { all: ["browser", { not: "foreign" }, { path: /\.[cm]?[jt]sx?$/ }] }, loaders: [validationLoader] },
166
+ { condition: { all: [{ not: "browser" }, { not: "foreign" }, { path: /(?:^|[\\/])app[\\/].*[\\/]route\.[cm]?[jt]s$/ }] }, loaders: [routeLoader] }
165
167
  ],
166
168
  ...hasRealtime ? {
167
169
  "*.{ts,tsx,js,jsx,mts,mjs,cts,cjs}": [
@@ -204,7 +206,8 @@ function withHolo(nextConfig = {}) {
204
206
  nextWebpackConfig.module.rules = [
205
207
  ...nextWebpackConfig.module.rules ?? [],
206
208
  ...hasRealtime ? [createRealtimeDefinitionWebpackRule(realtimeDefinitionLoader, context.isServer)] : [],
207
- ...!context.isServer ? [{ test: /\.[cm]?[jt]sx?$/, exclude: /node_modules/, use: [{ loader: validationLoader }] }] : []
209
+ ...!context.isServer ? [{ test: /\.[cm]?[jt]sx?$/, exclude: /node_modules/, use: [{ loader: validationLoader }] }] : [],
210
+ ...context.isServer ? [{ test: /[\\/]app[\\/].*[\\/]route\.[cm]?[jt]s$/, exclude: /node_modules/, use: [{ loader: routeLoader }] }] : []
208
211
  ];
209
212
  return nextWebpackConfig;
210
213
  },
@@ -0,0 +1,6 @@
1
+ declare function routeLoader(this: {
2
+ cacheable?: () => void;
3
+ readonly resourcePath: string;
4
+ }, source: string): string;
5
+
6
+ export { routeLoader as default };
@@ -0,0 +1,9 @@
1
+ // src/route-loader.ts
2
+ import { compileNextRoute } from "@holo-js/adapter-shared/build";
3
+ function routeLoader(source) {
4
+ this.cacheable?.();
5
+ return compileNextRoute(source, this.resourcePath);
6
+ }
7
+ export {
8
+ routeLoader as default
9
+ };
package/dist/runtime.d.ts CHANGED
@@ -164,7 +164,9 @@ declare function createNextHoloHelpers<TCustom extends HoloConfigMap = HoloConfi
164
164
  useConfig: <TPath extends DotPath<HoloConfigValues<TCustom>>>(path: TPath) => Promise<ValueAtPath<HoloConfigValues<TCustom>, TPath>>;
165
165
  config: <TPath extends DotPath<HoloConfigValues<TCustom>>>(path: TPath) => Promise<ValueAtPath<HoloConfigValues<TCustom>, TPath>>;
166
166
  };
167
+ declare function routeHandler<TArgs extends readonly unknown[]>(handler: (...args: TArgs) => Response | Promise<Response>): (...args: TArgs) => Promise<Response>;
167
168
  declare const adapterNextRuntimeInternals: {
169
+ routeHandler: typeof routeHandler;
168
170
  safeDecodeCookieSegment: typeof safeDecodeCookieSegment;
169
171
  parseResponseCookie: typeof parseResponseCookie;
170
172
  parseRequestCookies: typeof parseRequestCookies;
package/dist/runtime.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  // src/runtime.ts
2
2
  import { initializeHolo } from "@holo-js/core/runtime";
3
+ import { validationInternals } from "@holo-js/validation";
4
+ import { serializeRateLimitError } from "@holo-js/adapter-shared/server-errors";
3
5
 
4
6
  // src/request-context.ts
5
7
  import { runWithNextRequest as runWithSharedNextRequest } from "@holo-js/adapter-shared/next/request-context";
@@ -219,7 +221,22 @@ function createNextHoloHelpers(options) {
219
221
  config: useConfig
220
222
  };
221
223
  }
224
+ function routeHandler(handler) {
225
+ return async (...args) => {
226
+ try {
227
+ return await handler(...args);
228
+ } catch (error) {
229
+ const payload = validationInternals.serializeValidationException(error) ?? serializeRateLimitError(error);
230
+ if (!payload) throw error;
231
+ return Response.json(payload, {
232
+ status: payload.status,
233
+ ...payload.retryAfterSeconds === void 0 ? {} : { headers: { "Retry-After": String(payload.retryAfterSeconds) } }
234
+ });
235
+ }
236
+ };
237
+ }
222
238
  var adapterNextRuntimeInternals = {
239
+ routeHandler,
223
240
  safeDecodeCookieSegment,
224
241
  parseResponseCookie,
225
242
  parseRequestCookies,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holo-js/adapter-next",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "Holo-JS Framework - Next.js adapter",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,14 +43,14 @@
43
43
  "test": "vitest --run"
44
44
  },
45
45
  "dependencies": {
46
- "@holo-js/adapter-shared": "^0.3.18",
47
- "@holo-js/config": "^0.3.18",
48
- "@holo-js/core": "^0.3.18",
49
- "@holo-js/validation": "^0.3.18"
46
+ "@holo-js/adapter-shared": "^0.3.20",
47
+ "@holo-js/config": "^0.3.20",
48
+ "@holo-js/core": "^0.3.20",
49
+ "@holo-js/validation": "^0.3.20"
50
50
  },
51
51
  "peerDependencies": {
52
- "@holo-js/forms": "^0.3.18",
53
- "@holo-js/realtime": "^0.3.18",
52
+ "@holo-js/forms": "^0.3.20",
53
+ "@holo-js/realtime": "^0.3.20",
54
54
  "next": "^16.3.5",
55
55
  "react": "^19.2.6"
56
56
  },
@@ -63,7 +63,7 @@
63
63
  }
64
64
  },
65
65
  "devDependencies": {
66
- "@holo-js/realtime": "^0.3.18",
66
+ "@holo-js/realtime": "^0.3.20",
67
67
  "@types/node": "^22.10.2",
68
68
  "next": "^16.3.5",
69
69
  "tsup": "^8.3.5",