@marko/run 0.9.7 → 0.11.0-rc.1

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.
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ // scripts/importMetaURL.js
4
+ var import_url = require("url");
5
+ var __importMetaURL = (0, import_url.pathToFileURL)(__filename);
6
+
7
+ // src/runtime/url-builder.ts
8
+ var encode = encodeURIComponent;
9
+ var pathParts = /* @__PURE__ */ new Map();
10
+ function parsePathParts(path) {
11
+ let parts = pathParts.get(path);
12
+ if (!parts) {
13
+ let lastEnd = 0;
14
+ let paramStart;
15
+ pathParts.set(path, parts = [[]]);
16
+ while (lastEnd >= 0 && (paramStart = path.indexOf("/$", lastEnd) + 1)) {
17
+ parts.push(path.slice(lastEnd, paramStart++));
18
+ if (path.charAt(paramStart) === "$") {
19
+ paramStart++;
20
+ lastEnd = -1;
21
+ } else {
22
+ lastEnd = path.indexOf("/", paramStart);
23
+ }
24
+ parts[0].push(path.slice(paramStart, lastEnd < 0 ? void 0 : lastEnd));
25
+ }
26
+ parts.push(lastEnd >= 0 ? path.slice(lastEnd) : "");
27
+ }
28
+ return parts;
29
+ }
30
+ function joinHref(path, options) {
31
+ let result = path;
32
+ if (options.search) {
33
+ const query = "" + new URLSearchParams(options.search);
34
+ if (query) result += "?" + query;
35
+ }
36
+ if (options.hash) result += "#" + encode(options.hash);
37
+ return result;
38
+ }
39
+ function href(path, ...[options]) {
40
+ return options ? "params" in options ? ((parts) => href_keys(parts, options, ...parts[0]))(
41
+ parsePathParts(path)
42
+ ) : joinHref(path, options) : path;
43
+ }
44
+ function href_path(strings, ...params) {
45
+ let i = 0;
46
+ let j = 0;
47
+ let result = strings[i++];
48
+ if (!result || Array.isArray(result)) result = strings[i++];
49
+ while (i < strings.length) {
50
+ const param = params[j++];
51
+ result += (Array.isArray(param) ? param.map(encode).join("/") : encode(param)) + strings[i++];
52
+ }
53
+ return result;
54
+ }
55
+ function href_values(strings, options, ...params) {
56
+ return joinHref(href_path(strings, ...params), options);
57
+ }
58
+ function href_keys(strings, options, ...keys) {
59
+ return href_values(strings, options, ...keys.map((k) => options.params[k]));
60
+ }
61
+
62
+ // src/runtime/client.ts
63
+ window.Run || (window.Run = {
64
+ href
65
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,59 @@
1
+ // src/runtime/url-builder.ts
2
+ var encode = encodeURIComponent;
3
+ var pathParts = /* @__PURE__ */ new Map();
4
+ function parsePathParts(path) {
5
+ let parts = pathParts.get(path);
6
+ if (!parts) {
7
+ let lastEnd = 0;
8
+ let paramStart;
9
+ pathParts.set(path, parts = [[]]);
10
+ while (lastEnd >= 0 && (paramStart = path.indexOf("/$", lastEnd) + 1)) {
11
+ parts.push(path.slice(lastEnd, paramStart++));
12
+ if (path.charAt(paramStart) === "$") {
13
+ paramStart++;
14
+ lastEnd = -1;
15
+ } else {
16
+ lastEnd = path.indexOf("/", paramStart);
17
+ }
18
+ parts[0].push(path.slice(paramStart, lastEnd < 0 ? void 0 : lastEnd));
19
+ }
20
+ parts.push(lastEnd >= 0 ? path.slice(lastEnd) : "");
21
+ }
22
+ return parts;
23
+ }
24
+ function joinHref(path, options) {
25
+ let result = path;
26
+ if (options.search) {
27
+ const query = "" + new URLSearchParams(options.search);
28
+ if (query) result += "?" + query;
29
+ }
30
+ if (options.hash) result += "#" + encode(options.hash);
31
+ return result;
32
+ }
33
+ function href(path, ...[options]) {
34
+ return options ? "params" in options ? ((parts) => href_keys(parts, options, ...parts[0]))(
35
+ parsePathParts(path)
36
+ ) : joinHref(path, options) : path;
37
+ }
38
+ function href_path(strings, ...params) {
39
+ let i = 0;
40
+ let j = 0;
41
+ let result = strings[i++];
42
+ if (!result || Array.isArray(result)) result = strings[i++];
43
+ while (i < strings.length) {
44
+ const param = params[j++];
45
+ result += (Array.isArray(param) ? param.map(encode).join("/") : encode(param)) + strings[i++];
46
+ }
47
+ return result;
48
+ }
49
+ function href_values(strings, options, ...params) {
50
+ return joinHref(href_path(strings, ...params), options);
51
+ }
52
+ function href_keys(strings, options, ...keys) {
53
+ return href_values(strings, options, ...keys.map((k) => options.params[k]));
54
+ }
55
+
56
+ // src/runtime/client.ts
57
+ window.Run || (window.Run = {
58
+ href
59
+ });
@@ -1,9 +1,15 @@
1
1
  import { InlineConfig } from "vite";
2
+ import type { AnyRoute, GetableHref, GetablePath, GetPaths, HandlerLike, MultiRouteContext, PostableHref, PostablePath, PostPaths } from "./legacy-types";
2
3
  import { NotHandled, NotMatched } from "./namespace";
3
- import type { AnyRoute, GetableHref, GetablePath, GetPaths, HandlerLike, HandlerTypeFn, MultiRouteContext, Platform, PostableHref, PostablePath, PostPaths, RuntimeModule } from "./types";
4
+ import type { GetContext, GlobalNamespace, Platform, RuntimeModule } from "./types";
4
5
  declare global {
5
6
  var __marko_run__: RuntimeModule;
6
7
  var __marko_run_vite_config__: InlineConfig | undefined;
8
+ var Run: GlobalNamespace;
9
+ namespace Run {
10
+ type Context = GetContext;
11
+ }
12
+ /** @deprecated use \`Run\` namespace instead */
7
13
  namespace MarkoRun {
8
14
  export { GetableHref, GetablePath, GetPaths, NotHandled, NotMatched, Platform, PostableHref, PostablePath, PostPaths, };
9
15
  export type Route = AnyRoute;
@@ -16,8 +22,7 @@ declare global {
16
22
  export type DELETE = HandlerLike<AnyRoute, "DELETE">;
17
23
  export type PATCH = HandlerLike<AnyRoute, "PATCH">;
18
24
  export type OPTIONS = HandlerLike<AnyRoute, "OPTIONS">;
19
- /** @deprecated use `((context, next) => { ... }) satisfies MarkoRun.Handler` instead */
20
- export const route: HandlerTypeFn;
21
25
  }
22
26
  }
23
- export type { AppData, Context, DefineApp, Fetch, HandlerLike, HandlerTypeFn, InputObject, Invoke, LayoutInput, Match, MultiRouteContext, NextFunction, ParamsObject, Platform, Route, RouteHandler, Routes, RouteWithHandler, RuntimeModule, Verb, } from "./types";
27
+ export type { HandlerLike, HandlerTypeFn, InputObject, MultiRouteContext, ParamsObject, Route, RouteHandler, Routes, } from "./legacy-types";
28
+ export type { App, Context, ContextForFile, DefineRoutes, Fetch, GetContext, Handler, Invoke, LayoutInput, Match, Meta, Middleware, Namespace, NextFunction, NormalizedHandler, PartialTemplate, Platform, RouteForFileDef, RouteMatch, RuntimeModule, Template, HttpVerb as Verb, } from "./types";
@@ -25,12 +25,15 @@ __export(internal_exports, {
25
25
  call: () => call,
26
26
  compose: () => compose,
27
27
  createContext: () => createContext,
28
+ mergeOptions: () => mergeOptions,
28
29
  noContent: () => noContent,
29
30
  normalizeHandler: () => normalizeHandler,
30
31
  normalizeMeta: () => getMetaDataLookup,
32
+ normalizeValidator: () => normalizeValidator,
31
33
  notHandled: () => notHandled,
32
34
  notMatched: () => notMatched,
33
35
  passthrough: () => passthrough,
36
+ render: () => render,
34
37
  stripResponseBody: () => stripResponseBody,
35
38
  stripResponseBodySync: () => stripResponseBodySync
36
39
  });
@@ -40,6 +43,10 @@ module.exports = __toCommonJS(internal_exports);
40
43
  var import_url = require("url");
41
44
  var __importMetaURL = (0, import_url.pathToFileURL)(__filename);
42
45
 
46
+ // src/runtime/internal.ts
47
+ var import_node_url = require("node:url");
48
+ var import_form_data_parser = require("@remix-run/form-data-parser");
49
+
43
50
  // src/vite/constants.ts
44
51
  var httpVerbs = [
45
52
  "get",
@@ -51,6 +58,61 @@ var httpVerbs = [
51
58
  "options"
52
59
  ];
53
60
 
61
+ // src/runtime/url-builder.ts
62
+ var encode = encodeURIComponent;
63
+ var pathParts = /* @__PURE__ */ new Map();
64
+ function parsePathParts(path) {
65
+ let parts = pathParts.get(path);
66
+ if (!parts) {
67
+ let lastEnd = 0;
68
+ let paramStart;
69
+ pathParts.set(path, parts = [[]]);
70
+ while (lastEnd >= 0 && (paramStart = path.indexOf("/$", lastEnd) + 1)) {
71
+ parts.push(path.slice(lastEnd, paramStart++));
72
+ if (path.charAt(paramStart) === "$") {
73
+ paramStart++;
74
+ lastEnd = -1;
75
+ } else {
76
+ lastEnd = path.indexOf("/", paramStart);
77
+ }
78
+ parts[0].push(path.slice(paramStart, lastEnd < 0 ? void 0 : lastEnd));
79
+ }
80
+ parts.push(lastEnd >= 0 ? path.slice(lastEnd) : "");
81
+ }
82
+ return parts;
83
+ }
84
+ function joinHref(path, options) {
85
+ let result = path;
86
+ if (options.search) {
87
+ const query = "" + new URLSearchParams(options.search);
88
+ if (query) result += "?" + query;
89
+ }
90
+ if (options.hash) result += "#" + encode(options.hash);
91
+ return result;
92
+ }
93
+ function href(path, ...[options]) {
94
+ return options ? "params" in options ? ((parts) => href_keys(parts, options, ...parts[0]))(
95
+ parsePathParts(path)
96
+ ) : joinHref(path, options) : path;
97
+ }
98
+ function href_path(strings, ...params) {
99
+ let i = 0;
100
+ let j = 0;
101
+ let result = strings[i++];
102
+ if (!result || Array.isArray(result)) result = strings[i++];
103
+ while (i < strings.length) {
104
+ const param = params[j++];
105
+ result += (Array.isArray(param) ? param.map(encode).join("/") : encode(param)) + strings[i++];
106
+ }
107
+ return result;
108
+ }
109
+ function href_values(strings, options, ...params) {
110
+ return joinHref(href_path(strings, ...params), options);
111
+ }
112
+ function href_keys(strings, options, ...keys) {
113
+ return href_values(strings, options, ...keys.map((k) => options.params[k]));
114
+ }
115
+
54
116
  // src/vite/utils/meta-data.ts
55
117
  var verbKeys = new Set(httpVerbs.map((v) => v.toUpperCase()));
56
118
  function isObject(obj) {
@@ -84,10 +146,10 @@ function getMetaDataLookup(data) {
84
146
  }
85
147
 
86
148
  // src/runtime/internal.ts
87
- var NotHandled = Symbol(
149
+ var NotHandled = /* @__PURE__ */ Symbol(
88
150
  "marko-run not handled"
89
151
  );
90
- var NotMatched = Symbol(
152
+ var NotMatched = /* @__PURE__ */ Symbol(
91
153
  "marko-run not matched"
92
154
  );
93
155
  var parentContextLookup = /* @__PURE__ */ new WeakMap();
@@ -98,11 +160,20 @@ var pageResponseInit = {
98
160
  };
99
161
  globalThis.MarkoRun ?? (globalThis.MarkoRun = {
100
162
  NotHandled,
101
- NotMatched,
102
- route(handler) {
103
- return handler;
104
- }
163
+ NotMatched
105
164
  });
165
+ if (!globalThis.Run) {
166
+ const namespace = {
167
+ href
168
+ };
169
+ for (const v of [...httpVerbs, "all"]) {
170
+ const verb = v.toUpperCase();
171
+ const def = createDefineHandler();
172
+ def.href = href;
173
+ namespace[verb] = def;
174
+ }
175
+ globalThis.Run = namespace;
176
+ }
106
177
  var toReadable = (rendered) => {
107
178
  toReadable = rendered.toReadable ? (rendered2) => rendered2.toReadable() : (rendered2) => {
108
179
  let cancelled = false;
@@ -130,39 +201,120 @@ var toReadable = (rendered) => {
130
201
  };
131
202
  return toReadable(rendered);
132
203
  };
133
- function createContext(route, request, platform, url = new URL(request.url)) {
134
- let meta;
135
- let params;
136
- let path;
137
- if (route) {
138
- meta = route.meta;
139
- params = route.params;
140
- path = route.path;
141
- } else {
142
- meta = {};
143
- params = {};
144
- path = "";
204
+ function searchParamsToObject(params) {
205
+ const obj = {};
206
+ for (const [key, value] of params) {
207
+ const prev = obj[key];
208
+ obj[key] = prev ? Array.isArray(prev) ? [...prev, value] : [prev, value] : value;
145
209
  }
146
- return {
147
- request,
210
+ return obj;
211
+ }
212
+ async function readBodyWithLimit(request, maxBytes) {
213
+ if (maxBytes < 0) {
214
+ return await request.text();
215
+ }
216
+ const contentLength = request.headers.get("content-length");
217
+ if (contentLength !== null && Number(contentLength) > maxBytes) {
218
+ throw new Error("Request body too large");
219
+ }
220
+ if (!request.body) {
221
+ throw new Error("Missing request body");
222
+ }
223
+ const reader = request.body.getReader();
224
+ const bytes = new Uint8Array(maxBytes);
225
+ let receivedBytes = 0;
226
+ try {
227
+ while (true) {
228
+ const { done, value } = await reader.read();
229
+ if (done) break;
230
+ if (receivedBytes + value.byteLength > maxBytes) {
231
+ await reader.cancel();
232
+ throw new Error("Request body too large");
233
+ }
234
+ bytes.set(value, receivedBytes);
235
+ receivedBytes += value.byteLength;
236
+ }
237
+ } finally {
238
+ reader.releaseLock();
239
+ }
240
+ return new TextDecoder("utf-8", { fatal: true }).decode(
241
+ bytes.subarray(0, receivedBytes)
242
+ );
243
+ }
244
+ function createContext(route, request, platform, url = new URL(request.url)) {
245
+ const context = {
246
+ route: (route == null ? void 0 : route.path) || "",
148
247
  method: request.method,
248
+ meta: (route == null ? void 0 : route.meta) || {},
249
+ get params() {
250
+ const value = route ? route.options.params ? route.options.params(route.params) : route.params : {};
251
+ Object.defineProperty(context, "params", {
252
+ configurable: true,
253
+ enumerable: true,
254
+ value
255
+ });
256
+ return value;
257
+ },
258
+ get search() {
259
+ const search = searchParamsToObject(url.searchParams);
260
+ const value = (route == null ? void 0 : route.options.search) ? route.options.search(search) : search;
261
+ Object.defineProperty(context, "search", {
262
+ configurable: true,
263
+ enumerable: true,
264
+ value
265
+ });
266
+ return value;
267
+ },
268
+ body: route && request.body ? async () => {
269
+ const contentType = request.headers.get("Content-Type");
270
+ let value;
271
+ if (contentType == null ? void 0 : contentType.includes("application/json")) {
272
+ const { maxBytes, validator } = route.options.json;
273
+ const json = maxBytes < 0 ? await request.json() : JSON.parse(await readBodyWithLimit(request, maxBytes));
274
+ value = validator ? validator(json) : json;
275
+ } else {
276
+ const {
277
+ maxBytes,
278
+ maxParts,
279
+ maxFiles,
280
+ maxFileBytes,
281
+ onFile,
282
+ validator
283
+ } = route.options.form;
284
+ const data = searchParamsToObject(
285
+ (contentType == null ? void 0 : contentType.includes("multipart/form-data")) ? await (0, import_form_data_parser.parseFormData)(
286
+ request,
287
+ {
288
+ maxParts,
289
+ maxFiles,
290
+ maxFileSize: maxFileBytes,
291
+ maxTotalSize: maxBytes
292
+ },
293
+ onFile ? (file) => onFile(context, file) : void 0
294
+ ) : new import_node_url.URLSearchParams(
295
+ await readBodyWithLimit(request, maxBytes)
296
+ )
297
+ );
298
+ value = validator ? validator(data) : validator;
299
+ }
300
+ Object.defineProperty(context, "body", {
301
+ configurable: true,
302
+ enumerable: true,
303
+ value
304
+ });
305
+ return value;
306
+ } : void 0,
307
+ data: {},
149
308
  url,
309
+ request,
150
310
  platform,
151
- meta,
152
- params,
153
- route: path,
154
311
  serializedGlobals,
155
312
  parent: parentContextLookup.get(request),
156
313
  async fetch(resource, init) {
157
- let request2;
158
- let url2;
159
- if (resource instanceof Request) {
160
- request2 = new Request(resource, init);
161
- url2 = new URL(request2.url);
162
- } else {
163
- url2 = typeof resource === "string" ? new URL(resource, this.url) : resource;
164
- request2 = new Request(url2, init);
165
- }
314
+ const request2 = new Request(
315
+ typeof resource === "string" ? new URL(resource, this.url) : resource,
316
+ init
317
+ );
166
318
  parentContextLookup.set(request2, this);
167
319
  return await globalThis.__marko_run__.fetch(request2, this.platform) || new Response(null, { status: 404 });
168
320
  },
@@ -197,16 +349,26 @@ function createContext(route, request, platform, url = new URL(request.url)) {
197
349
  );
198
350
  }
199
351
  };
352
+ return context;
353
+ }
354
+ function render(context, template, input, data) {
355
+ if (data) {
356
+ Object.assign(context.data, data);
357
+ }
358
+ return context.render(template, input);
200
359
  }
201
- async function call(handler, next, context) {
360
+ async function call(handler, next, context, data) {
202
361
  let response;
362
+ if (data) {
363
+ Object.assign(context.data, data);
364
+ }
203
365
  if (!process.env.NODE_ENV || process.env.NODE_ENV === "development") {
204
366
  let nextCallCount = 0;
205
367
  let didThrow = false;
206
368
  try {
207
- response = await handler(context, () => {
369
+ response = await handler(context, (d) => {
208
370
  nextCallCount++;
209
- return next();
371
+ return next(d);
210
372
  });
211
373
  } catch (error) {
212
374
  didThrow = true;
@@ -245,14 +407,14 @@ async function call(handler, next, context) {
245
407
  function compose(handlers) {
246
408
  const len = handlers.length;
247
409
  if (!len) {
248
- return (_context, next) => next();
410
+ return passthroughHandler;
249
411
  } else if (len === 1) {
250
412
  return handlers[0];
251
413
  }
252
414
  return (context, next) => {
253
415
  let i = 0;
254
- return (function nextHandler() {
255
- return i < len ? call(handlers[i++], nextHandler, context) : next();
416
+ return (function nextHandler(data) {
417
+ return i < len ? call(handlers[i++], nextHandler, context, data) : next(data);
256
418
  })();
257
419
  };
258
420
  }
@@ -273,6 +435,87 @@ function normalizeHandler(obj) {
273
435
  }
274
436
  return passthrough;
275
437
  }
438
+ function createDefineHandler() {
439
+ return (optionsOrHandlers, handlers) => {
440
+ let handler;
441
+ if (typeof optionsOrHandlers === "function") {
442
+ handler = optionsOrHandlers;
443
+ handler.options = {};
444
+ } else if (Array.isArray(optionsOrHandlers)) {
445
+ handler = compose(optionsOrHandlers);
446
+ handler.options = {};
447
+ } else if (typeof handlers === "function") {
448
+ handler = handlers;
449
+ handler.options = optionsOrHandlers;
450
+ } else if (Array.isArray(handlers)) {
451
+ handler = compose(handlers);
452
+ handler.options = optionsOrHandlers;
453
+ } else {
454
+ handler = passthroughHandler;
455
+ handler.options = optionsOrHandlers;
456
+ }
457
+ return handler;
458
+ };
459
+ }
460
+ function normalizeValidator(validator) {
461
+ return validator && typeof validator !== "function" ? (input) => {
462
+ const result = validator["~standard"].validate(input);
463
+ if (result instanceof Promise) {
464
+ throw new TypeError("Schema validation must be synchronous");
465
+ }
466
+ return result.issues ? [input, result.issues] : [result.value, void 0];
467
+ } : validator;
468
+ }
469
+ var defaultMaxBytes = 1024 * 1024;
470
+ var defaultMaxParts = 1e3;
471
+ var defaultMaxFiles = 20;
472
+ function mergeOptions(...fns) {
473
+ const merged = {};
474
+ for (const fn of fns) {
475
+ if (typeof fn === "function" && "options" in fn) {
476
+ const { options } = fn;
477
+ for (const k in options) {
478
+ const key = k;
479
+ const option = options[key];
480
+ if (typeof option === "object" && typeof merged[key] === "object") {
481
+ Object.assign(merged[key], option);
482
+ } else if (option) {
483
+ merged[key] = option;
484
+ }
485
+ }
486
+ }
487
+ }
488
+ const result = {
489
+ params: normalizeValidator(merged.params),
490
+ search: normalizeValidator(merged.search)
491
+ };
492
+ if (merged.json) {
493
+ const { maxBytes = defaultMaxBytes, validator } = typeof merged.json === "function" || "~standard" in merged.json ? { validator: merged.json } : merged.json;
494
+ result.json = {
495
+ maxBytes,
496
+ validator: normalizeValidator(validator)
497
+ };
498
+ }
499
+ if (merged.form) {
500
+ const {
501
+ maxBytes,
502
+ maxFiles = defaultMaxFiles,
503
+ maxFileBytes = defaultMaxBytes,
504
+ maxParts = defaultMaxParts,
505
+ onFile,
506
+ validator
507
+ } = typeof merged.form === "function" || "~standard" in merged.form ? { validator: merged.form } : merged.form;
508
+ result.form = {
509
+ maxBytes: maxBytes ?? maxFiles * maxFileBytes,
510
+ maxFileBytes,
511
+ maxFiles,
512
+ maxParts,
513
+ onFile,
514
+ validator: normalizeValidator(validator)
515
+ };
516
+ }
517
+ return result;
518
+ }
276
519
  function stripResponseBodySync(response) {
277
520
  return response.body ? new Response(null, response) : response;
278
521
  }
@@ -281,6 +524,7 @@ function stripResponseBody(response) {
281
524
  }
282
525
  function passthrough() {
283
526
  }
527
+ var passthroughHandler = (_ctx, next) => next();
284
528
  function noContent() {
285
529
  return new Response(null, {
286
530
  status: 204
@@ -299,12 +543,15 @@ function notMatched() {
299
543
  call,
300
544
  compose,
301
545
  createContext,
546
+ mergeOptions,
302
547
  noContent,
303
548
  normalizeHandler,
304
549
  normalizeMeta,
550
+ normalizeValidator,
305
551
  notHandled,
306
552
  notMatched,
307
553
  passthrough,
554
+ render,
308
555
  stripResponseBody,
309
556
  stripResponseBodySync
310
557
  });
@@ -1,11 +1,15 @@
1
- import type { AnyRoute, Awaitable, Context, MultiRouteContext, NextFunction, Platform, RouteHandler } from "./types";
1
+ import type { Awaitable, RouteHandler } from "./legacy-types";
2
+ import type { Context, HandlerFunction, HandlerOptions, NextFunction, NormalizedHandler, NormalizedHandlerOptions, Platform, RouteData, RouteMatch, Validator } from "./types";
2
3
  export { getMetaDataLookup as normalizeMeta } from "../vite/utils/meta-data";
3
4
  export declare const NotHandled: typeof MarkoRun.NotHandled;
4
5
  export declare const NotMatched: typeof MarkoRun.NotMatched;
5
- export declare function createContext<TRoute extends AnyRoute>(route: TRoute | null, request: Request, platform: Platform, url?: URL): Context<TRoute>;
6
- export declare function call<TRoute extends AnyRoute>(handler: RouteHandler<TRoute>, next: NextFunction, context: MultiRouteContext<TRoute>): Promise<Response>;
7
- export declare function compose(handlers: RouteHandler[]): RouteHandler;
6
+ export declare function createContext(route: RouteMatch | null, request: Request, platform: Platform, url?: URL): Context;
7
+ export declare function render<T>(context: Context, template: Marko.Template<T>, input: T, data?: RouteData): Response;
8
+ export declare function call(handler: HandlerFunction, next: NextFunction, context: Context, data?: RouteData): Promise<Response>;
9
+ export declare function compose(handlers: HandlerFunction[]): HandlerFunction;
8
10
  export declare function normalizeHandler(obj: RouteHandler | RouteHandler[] | Promise<RouteHandler | RouteHandler[]>): RouteHandler;
11
+ export declare function normalizeValidator<T>(validator: Validator<T> | undefined): import("./types").ValidatorFn<T> | undefined;
12
+ export declare function mergeOptions(...fns: (NormalizedHandler<Context, "ALL", any, HandlerOptions> | HandlerFunction)[]): NormalizedHandlerOptions;
9
13
  export declare function stripResponseBodySync(response: Response): Response;
10
14
  export declare function stripResponseBody(response: Awaitable<Response>): Awaitable<Response>;
11
15
  export declare function passthrough(): void;