@marko/run 0.5.13 → 0.5.15

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.
@@ -1,13 +1,13 @@
1
1
  import { InlineConfig } from "vite";
2
2
  import { NotHandled, NotMatched } from "./namespace";
3
- import type { GetPaths, PostPaths, GetablePath, GetableHref, PostablePath, PostableHref, Platform, HandlerTypeFn, RuntimeModule, AnyRoute, AnyContext, AnyHandler } from "./types";
3
+ import type { AnyContext, AnyHandler, AnyRoute, GetableHref, GetablePath, GetPaths, HandlerTypeFn, Platform, PostableHref, PostablePath, PostPaths, RuntimeModule } from "./types";
4
4
  declare global {
5
5
  var __marko_run__: RuntimeModule;
6
6
  var __marko_run_vite_config__: InlineConfig | undefined;
7
7
  namespace MarkoRun {
8
8
  /** @deprecated use `((context, next) => { ... }) satisfies MarkoRun.Handler` instead */
9
9
  export const route: HandlerTypeFn;
10
- export { GetPaths, PostPaths, GetablePath, GetableHref, PostablePath, PostableHref, Platform, NotHandled, NotMatched, AnyRoute as Route, AnyContext as Context, AnyHandler as Handler, };
10
+ export { AnyContext as Context, GetableHref, GetablePath, GetPaths, AnyHandler as Handler, NotHandled, NotMatched, Platform, PostableHref, PostablePath, PostPaths, AnyRoute as Route, };
11
11
  }
12
12
  }
13
- export type { AppData, Context, DefineApp, Fetch, HandlerTypeFn, HandlerLike, InputObject, Invoke, Match, MultiRouteContext, NextFunction, ParamsObject, Platform, Route, Routes, RouteHandler, RouteWithHandler, RuntimeModule, } from "./types";
13
+ export type { AppData, Context, DefineApp, Fetch, HandlerLike, HandlerTypeFn, InputObject, Invoke, Match, MultiRouteContext, NextFunction, ParamsObject, Platform, Route, RouteHandler, Routes, RouteWithHandler, RuntimeModule, } from "./types";
@@ -30,7 +30,9 @@ __export(internal_exports, {
30
30
  notHandled: () => notHandled,
31
31
  notMatched: () => notMatched,
32
32
  pageResponse: () => pageResponse,
33
- passthrough: () => passthrough
33
+ passthrough: () => passthrough,
34
+ stripResponseBody: () => stripResponseBody,
35
+ stripResponseBodySync: () => stripResponseBodySync
34
36
  });
35
37
  module.exports = __toCommonJS(internal_exports);
36
38
 
@@ -160,6 +162,12 @@ function normalize(obj) {
160
162
  }
161
163
  return passthrough;
162
164
  }
165
+ function stripResponseBodySync(response) {
166
+ return response.body ? new Response(null, response) : response;
167
+ }
168
+ function stripResponseBody(response) {
169
+ return "then" in response ? response.then(stripResponseBodySync) : stripResponseBodySync(response);
170
+ }
163
171
  function passthrough() {
164
172
  }
165
173
  function noContent() {
@@ -185,5 +193,7 @@ function notMatched() {
185
193
  notHandled,
186
194
  notMatched,
187
195
  pageResponse,
188
- passthrough
196
+ passthrough,
197
+ stripResponseBody,
198
+ stripResponseBodySync
189
199
  });
@@ -1,4 +1,4 @@
1
- import type { InputObject, NextFunction, AnyRoute, Context, MultiRouteContext, RouteHandler, Platform } from "./types";
1
+ import type { AnyRoute, Awaitable, Context, InputObject, MultiRouteContext, NextFunction, Platform, RouteHandler } from "./types";
2
2
  export declare function pageResponse(template: any, input: Record<PropertyKey, unknown>): Response;
3
3
  export declare const NotHandled: typeof MarkoRun.NotHandled;
4
4
  export declare const NotMatched: typeof MarkoRun.NotMatched;
@@ -6,6 +6,8 @@ export declare function createContext<TRoute extends AnyRoute>(route: TRoute | u
6
6
  export declare function call<TRoute extends AnyRoute>(handler: RouteHandler<TRoute>, next: NextFunction, context: MultiRouteContext<TRoute>): Promise<Response>;
7
7
  export declare function compose(handlers: RouteHandler[]): RouteHandler;
8
8
  export declare function normalize(obj: RouteHandler | RouteHandler[] | Promise<RouteHandler | RouteHandler[]>): RouteHandler;
9
+ export declare function stripResponseBodySync(response: Response): Response;
10
+ export declare function stripResponseBody(response: Awaitable<Response>): Awaitable<Response>;
9
11
  export declare function passthrough(): void;
10
12
  export declare function noContent(): Response;
11
13
  export declare function notHandled(): void;
@@ -120,6 +120,12 @@ function normalize(obj) {
120
120
  }
121
121
  return passthrough;
122
122
  }
123
+ function stripResponseBodySync(response) {
124
+ return response.body ? new Response(null, response) : response;
125
+ }
126
+ function stripResponseBody(response) {
127
+ return "then" in response ? response.then(stripResponseBodySync) : stripResponseBodySync(response);
128
+ }
123
129
  function passthrough() {
124
130
  }
125
131
  function noContent() {
@@ -144,5 +150,7 @@ export {
144
150
  notHandled,
145
151
  notMatched,
146
152
  pageResponse,
147
- passthrough
153
+ passthrough,
154
+ stripResponseBody,
155
+ stripResponseBodySync
148
156
  };
@@ -1,3 +1,3 @@
1
1
  export declare const NotHandled: unique symbol;
2
2
  export declare const NotMatched: unique symbol;
3
- export type { GetPaths, PostPaths, GetablePath, GetableHref, PostablePath, PostableHref, Platform } from "./types";
3
+ export type { GetableHref, GetablePath, GetPaths, Platform, PostableHref, PostablePath, PostPaths, } from "./types";
@@ -1,4 +1,4 @@
1
- type Awaitable<T> = Promise<T> | T;
1
+ export type Awaitable<T> = Promise<T> | T;
2
2
  type OneOrMany<T> = T | T[];
3
3
  type NoParams = {};
4
4
  type AllKeys<T> = T extends T ? keyof T : never;
@@ -1,4 +1,4 @@
1
- import type { Adapter, Route, BuiltRoutes, RoutableFile, RouterOptions } from "../types";
1
+ import type { Adapter, BuiltRoutes, RoutableFile, Route, RouterOptions } from "../types";
2
2
  export declare function renderRouteTemplate(route: Route, getRelativePath: (path: string) => string): string;
3
3
  export declare function renderEntryTemplate(name: string, files: string[], pageInputs?: string[]): string;
4
4
  export declare function renderRouteEntry(route: Route, entriesDir: string): string;
@@ -1,7 +1,7 @@
1
1
  type ValuesOf<T> = T[keyof T];
2
2
  export declare const markoRunFilePrefix = "__marko-run__";
3
3
  export declare const virtualFilePrefix = "virtual:marko-run";
4
- export declare const httpVerbs: readonly ["get", "post", "put", "delete"];
4
+ export declare const httpVerbs: readonly ["get", "head", "post", "put", "delete", "patch", "options"];
5
5
  export declare const serverEntryQuery = "?marko-server-entry";
6
6
  export declare const browserEntryQuery = "?marko-browser-entry";
7
7
  export declare const RoutableFileTypes: {
@@ -14,5 +14,5 @@ export declare const RoutableFileTypes: {
14
14
  readonly Error: "500";
15
15
  };
16
16
  export type RoutableFileType = ValuesOf<typeof RoutableFileTypes>;
17
- export type HttpVerb = typeof httpVerbs[number];
17
+ export type HttpVerb = (typeof httpVerbs)[number];
18
18
  export {};