@marko/run 0.10.0 → 0.11.0-rc.2

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";
@@ -22,15 +22,19 @@ var internal_exports = {};
22
22
  __export(internal_exports, {
23
23
  NotHandled: () => NotHandled,
24
24
  NotMatched: () => NotMatched,
25
+ assertHandlerVerb: () => assertHandlerVerb,
25
26
  call: () => call,
26
27
  compose: () => compose,
27
28
  createContext: () => createContext,
29
+ mergeOptions: () => mergeOptions,
28
30
  noContent: () => noContent,
29
31
  normalizeHandler: () => normalizeHandler,
30
32
  normalizeMeta: () => getMetaDataLookup,
33
+ normalizeValidator: () => normalizeValidator,
31
34
  notHandled: () => notHandled,
32
35
  notMatched: () => notMatched,
33
36
  passthrough: () => passthrough,
37
+ render: () => render,
34
38
  stripResponseBody: () => stripResponseBody,
35
39
  stripResponseBodySync: () => stripResponseBodySync
36
40
  });
@@ -40,6 +44,10 @@ module.exports = __toCommonJS(internal_exports);
40
44
  var import_url = require("url");
41
45
  var __importMetaURL = (0, import_url.pathToFileURL)(__filename);
42
46
 
47
+ // src/runtime/internal.ts
48
+ var import_node_url = require("node:url");
49
+ var import_form_data_parser = require("@remix-run/form-data-parser");
50
+
43
51
  // src/vite/constants.ts
44
52
  var httpVerbs = [
45
53
  "get",
@@ -51,6 +59,83 @@ var httpVerbs = [
51
59
  "options"
52
60
  ];
53
61
 
62
+ // src/runtime/thenable.ts
63
+ var kPromise = /* @__PURE__ */ Symbol("promise");
64
+ var kReadFn = /* @__PURE__ */ Symbol("read fn");
65
+ function thenFn(resolve, reject) {
66
+ return (this[kPromise] || (this[kPromise] = this[kReadFn]())).then(resolve, reject);
67
+ }
68
+ function catchFn(reject) {
69
+ return (this[kPromise] || (this[kPromise] = this[kReadFn]())).catch(reject);
70
+ }
71
+ function finallyFn(resolve) {
72
+ return (this[kPromise] || (this[kPromise] = this[kReadFn]())).finally(resolve);
73
+ }
74
+ function thenable(fn) {
75
+ return {
76
+ [kPromise]: null,
77
+ [kReadFn]: fn,
78
+ then: thenFn,
79
+ catch: catchFn,
80
+ finally: finallyFn
81
+ };
82
+ }
83
+
84
+ // src/runtime/url-builder.ts
85
+ var encode = encodeURIComponent;
86
+ var pathParts = /* @__PURE__ */ new Map();
87
+ function parsePathParts(path) {
88
+ let parts = pathParts.get(path);
89
+ if (!parts) {
90
+ let lastEnd = 0;
91
+ let paramStart;
92
+ pathParts.set(path, parts = [[]]);
93
+ while (lastEnd >= 0 && (paramStart = path.indexOf("/$", lastEnd) + 1)) {
94
+ parts.push(path.slice(lastEnd, paramStart++));
95
+ if (path.charAt(paramStart) === "$") {
96
+ paramStart++;
97
+ lastEnd = -1;
98
+ } else {
99
+ lastEnd = path.indexOf("/", paramStart);
100
+ }
101
+ parts[0].push(path.slice(paramStart, lastEnd < 0 ? void 0 : lastEnd));
102
+ }
103
+ parts.push(lastEnd >= 0 ? path.slice(lastEnd) : "");
104
+ }
105
+ return parts;
106
+ }
107
+ function joinHref(path, options) {
108
+ let result = path;
109
+ if (options.search) {
110
+ const query = "" + new URLSearchParams(options.search);
111
+ if (query) result += "?" + query;
112
+ }
113
+ if (options.hash) result += "#" + encode(options.hash);
114
+ return result;
115
+ }
116
+ function href(path, ...[options]) {
117
+ return options ? "params" in options ? ((parts) => href_keys(parts, options, ...parts[0]))(
118
+ parsePathParts(path)
119
+ ) : joinHref(path, options) : path;
120
+ }
121
+ function href_path(strings, ...params) {
122
+ let i = 0;
123
+ let j = 0;
124
+ let result = strings[i++];
125
+ if (!result || Array.isArray(result)) result = strings[i++];
126
+ while (i < strings.length) {
127
+ const param = params[j++];
128
+ result += (Array.isArray(param) ? param.map(encode).join("/") : encode(param)) + strings[i++];
129
+ }
130
+ return result;
131
+ }
132
+ function href_values(strings, options, ...params) {
133
+ return joinHref(href_path(strings, ...params), options);
134
+ }
135
+ function href_keys(strings, options, ...keys) {
136
+ return href_values(strings, options, ...keys.map((k) => options.params[k]));
137
+ }
138
+
54
139
  // src/vite/utils/meta-data.ts
55
140
  var verbKeys = new Set(httpVerbs.map((v) => v.toUpperCase()));
56
141
  function isObject(obj) {
@@ -98,10 +183,17 @@ var pageResponseInit = {
98
183
  };
99
184
  globalThis.MarkoRun ?? (globalThis.MarkoRun = {
100
185
  NotHandled,
101
- NotMatched,
102
- route(handler) {
103
- return handler;
104
- }
186
+ NotMatched
187
+ });
188
+ globalThis.Run ?? (globalThis.Run = {
189
+ href,
190
+ ALL: createDefineHandler("ALL"),
191
+ ...Object.fromEntries(
192
+ httpVerbs.map((v) => {
193
+ const verb = v.toUpperCase();
194
+ return [v.toUpperCase(), createDefineHandler(verb)];
195
+ })
196
+ )
105
197
  });
106
198
  var toReadable = (rendered) => {
107
199
  toReadable = rendered.toReadable ? (rendered2) => rendered2.toReadable() : (rendered2) => {
@@ -130,27 +222,98 @@ var toReadable = (rendered) => {
130
222
  };
131
223
  return toReadable(rendered);
132
224
  };
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 = "";
225
+ function searchParamsToObject(params) {
226
+ const obj = {};
227
+ for (const [key, value] of params) {
228
+ const prev = obj[key];
229
+ obj[key] = prev ? Array.isArray(prev) ? [...prev, value] : [prev, value] : value;
145
230
  }
146
- return {
147
- request,
231
+ return obj;
232
+ }
233
+ async function readBodyWithLimit(request, maxBytes) {
234
+ if (maxBytes < 0) {
235
+ return await request.text();
236
+ }
237
+ const contentLength = request.headers.get("content-length");
238
+ if (contentLength !== null && Number(contentLength) > maxBytes) {
239
+ throw new Error("Request body too large");
240
+ }
241
+ if (!request.body) {
242
+ throw new Error("Missing request body");
243
+ }
244
+ const reader = request.body.getReader();
245
+ const bytes = new Uint8Array(maxBytes);
246
+ let receivedBytes = 0;
247
+ try {
248
+ while (true) {
249
+ const { done, value } = await reader.read();
250
+ if (done) break;
251
+ if (receivedBytes + value.byteLength > maxBytes) {
252
+ await reader.cancel();
253
+ throw new Error("Request body too large");
254
+ }
255
+ bytes.set(value, receivedBytes);
256
+ receivedBytes += value.byteLength;
257
+ }
258
+ } finally {
259
+ reader.releaseLock();
260
+ }
261
+ return new TextDecoder("utf-8", { fatal: true }).decode(
262
+ bytes.subarray(0, receivedBytes)
263
+ );
264
+ }
265
+ async function readBody(route, context) {
266
+ const { request } = context;
267
+ const contentType = request.headers.get("Content-Type");
268
+ if (contentType == null ? void 0 : contentType.includes("application/json")) {
269
+ const { maxBytes: maxBytes2, validator: validator2 } = route.options.json;
270
+ const json = maxBytes2 < 0 ? await request.json() : JSON.parse(await readBodyWithLimit(request, maxBytes2));
271
+ return validator2 ? validator2(json) : json;
272
+ }
273
+ const { maxBytes, maxParts, maxFiles, maxFileBytes, onFile, validator } = route.options.form;
274
+ const data = searchParamsToObject(
275
+ (contentType == null ? void 0 : contentType.includes("multipart/form-data")) ? await (0, import_form_data_parser.parseFormData)(
276
+ request,
277
+ {
278
+ maxParts,
279
+ maxFiles,
280
+ maxFileSize: maxFileBytes,
281
+ maxTotalSize: maxBytes
282
+ },
283
+ onFile ? (file) => onFile(context, file) : void 0
284
+ ) : new import_node_url.URLSearchParams(await readBodyWithLimit(request, maxBytes))
285
+ );
286
+ return validator && validator(data);
287
+ }
288
+ function createContext(route, request, platform, url = new URL(request.url)) {
289
+ const context = {
290
+ route: (route == null ? void 0 : route.path) || "",
148
291
  method: request.method,
292
+ meta: (route == null ? void 0 : route.meta) || {},
293
+ get params() {
294
+ const value = route ? route.options.params ? route.options.params(route.params) : route.params : {};
295
+ Object.defineProperty(context, "params", {
296
+ configurable: true,
297
+ enumerable: true,
298
+ value
299
+ });
300
+ return value;
301
+ },
302
+ get search() {
303
+ const search = searchParamsToObject(url.searchParams);
304
+ const value = (route == null ? void 0 : route.options.search) ? route.options.search(search) : search;
305
+ Object.defineProperty(context, "search", {
306
+ configurable: true,
307
+ enumerable: true,
308
+ value
309
+ });
310
+ return value;
311
+ },
312
+ body: route && request.body ? thenable(() => readBody(route, context)) : void 0,
313
+ data: {},
149
314
  url,
315
+ request,
150
316
  platform,
151
- meta,
152
- params,
153
- route: path,
154
317
  serializedGlobals,
155
318
  parent: parentContextLookup.get(request),
156
319
  async fetch(resource, init) {
@@ -192,16 +355,37 @@ function createContext(route, request, platform, url = new URL(request.url)) {
192
355
  );
193
356
  }
194
357
  };
358
+ return context;
359
+ }
360
+ function render(context, template, input, data) {
361
+ if (data) {
362
+ Object.assign(context.data, data);
363
+ }
364
+ return context.render(template, input);
195
365
  }
196
- async function call(handler, next, context) {
366
+ var handlerMethod = /* @__PURE__ */ new WeakMap();
367
+ async function call(handler, next, context, data) {
197
368
  let response;
369
+ if (data) {
370
+ Object.assign(context.data, data);
371
+ }
372
+ let method = handlerMethod.get(handler);
373
+ if (method === void 0) {
374
+ handlerMethod.set(
375
+ handler,
376
+ method = "verb" in handler && handler.verb !== "ALL" ? handler.verb : false
377
+ );
378
+ }
379
+ if (method && method !== context.method) {
380
+ return next(data);
381
+ }
198
382
  if (!process.env.NODE_ENV || process.env.NODE_ENV === "development") {
199
383
  let nextCallCount = 0;
200
384
  let didThrow = false;
201
385
  try {
202
- response = await handler(context, () => {
386
+ response = await handler(context, (d) => {
203
387
  nextCallCount++;
204
- return next();
388
+ return next(d);
205
389
  });
206
390
  } catch (error) {
207
391
  didThrow = true;
@@ -235,19 +419,19 @@ async function call(handler, next, context) {
235
419
  if (response === null || response === NotMatched || response === NotHandled) {
236
420
  throw response || NotMatched;
237
421
  }
238
- return response || next();
422
+ return response || next(data);
239
423
  }
240
424
  function compose(handlers) {
241
425
  const len = handlers.length;
242
426
  if (!len) {
243
- return (_context, next) => next();
427
+ return passthroughHandler;
244
428
  } else if (len === 1) {
245
429
  return handlers[0];
246
430
  }
247
431
  return (context, next) => {
248
432
  let i = 0;
249
- return (function nextHandler() {
250
- return i < len ? call(handlers[i++], nextHandler, context) : next();
433
+ return (function nextHandler(data) {
434
+ return i < len ? call(handlers[i++], nextHandler, context, data) : next(data);
251
435
  })();
252
436
  };
253
437
  }
@@ -268,6 +452,104 @@ function normalizeHandler(obj) {
268
452
  }
269
453
  return passthrough;
270
454
  }
455
+ function assertHandlerVerb(verb, handler) {
456
+ if ("verb" in handler && handler.verb !== verb) {
457
+ throw new Error(
458
+ `Expected verb ${verb} but handler was defined with Run.${handler.verb}`
459
+ );
460
+ }
461
+ }
462
+ function createDefineHandler(verb) {
463
+ return (optionsOrHandlers, handlers) => {
464
+ let handler;
465
+ if (typeof optionsOrHandlers === "function") {
466
+ assertHandlerVerb(verb, optionsOrHandlers);
467
+ handler = optionsOrHandlers;
468
+ handler.options ?? (handler.options = {});
469
+ } else if (Array.isArray(optionsOrHandlers)) {
470
+ for (const h of optionsOrHandlers) assertHandlerVerb(verb, h);
471
+ handler = compose(optionsOrHandlers);
472
+ handler.options = mergeOptions(...optionsOrHandlers);
473
+ } else if (typeof handlers === "function") {
474
+ assertHandlerVerb(verb, handlers);
475
+ handler = handlers;
476
+ handler.options = mergeOptions(handlers, optionsOrHandlers);
477
+ } else if (Array.isArray(handlers)) {
478
+ for (const h of handlers) assertHandlerVerb(verb, h);
479
+ handler = compose(handlers);
480
+ handler.options = mergeOptions(...handlers, optionsOrHandlers);
481
+ } else {
482
+ handler = passthroughHandler;
483
+ handler.options = optionsOrHandlers;
484
+ }
485
+ handler.verb = verb;
486
+ return handler;
487
+ };
488
+ }
489
+ function normalizeValidator(validator) {
490
+ return validator && typeof validator !== "function" ? (input) => {
491
+ const result = validator["~standard"].validate(input);
492
+ if (result instanceof Promise) {
493
+ throw new TypeError("Schema validation must be synchronous");
494
+ }
495
+ return result.issues ? [input, result.issues] : [result.value, void 0];
496
+ } : validator;
497
+ }
498
+ var defaultMaxBytes = 1024 * 1024;
499
+ var defaultMaxParts = 1e3;
500
+ var defaultMaxFiles = 20;
501
+ function mergeOptions(...arr) {
502
+ const merged = {};
503
+ for (const item of arr) {
504
+ let options;
505
+ if (typeof item === "object") {
506
+ options = item;
507
+ } else if ("options" in item) {
508
+ options = item.options;
509
+ } else {
510
+ continue;
511
+ }
512
+ for (const k in options) {
513
+ const key = k;
514
+ const option = options[key];
515
+ if (typeof option === "object" && typeof merged[key] === "object") {
516
+ Object.assign(merged[key], option);
517
+ } else if (option) {
518
+ merged[key] = option;
519
+ }
520
+ }
521
+ }
522
+ const result = {
523
+ params: normalizeValidator(merged.params),
524
+ search: normalizeValidator(merged.search)
525
+ };
526
+ if (merged.json) {
527
+ const { maxBytes = defaultMaxBytes, validator } = typeof merged.json === "function" || "~standard" in merged.json ? { validator: merged.json } : merged.json;
528
+ result.json = {
529
+ maxBytes,
530
+ validator: normalizeValidator(validator)
531
+ };
532
+ }
533
+ if (merged.form) {
534
+ const {
535
+ maxBytes,
536
+ maxFiles = defaultMaxFiles,
537
+ maxFileBytes = defaultMaxBytes,
538
+ maxParts = defaultMaxParts,
539
+ onFile,
540
+ validator
541
+ } = typeof merged.form === "function" || "~standard" in merged.form ? { validator: merged.form } : merged.form;
542
+ result.form = {
543
+ maxBytes: maxBytes ?? maxFiles * maxFileBytes,
544
+ maxFileBytes,
545
+ maxFiles,
546
+ maxParts,
547
+ onFile,
548
+ validator: normalizeValidator(validator)
549
+ };
550
+ }
551
+ return result;
552
+ }
271
553
  function stripResponseBodySync(response) {
272
554
  return response.body ? new Response(null, response) : response;
273
555
  }
@@ -276,6 +558,7 @@ function stripResponseBody(response) {
276
558
  }
277
559
  function passthrough() {
278
560
  }
561
+ var passthroughHandler = (_ctx, next) => next();
279
562
  function noContent() {
280
563
  return new Response(null, {
281
564
  status: 204
@@ -291,15 +574,19 @@ function notMatched() {
291
574
  0 && (module.exports = {
292
575
  NotHandled,
293
576
  NotMatched,
577
+ assertHandlerVerb,
294
578
  call,
295
579
  compose,
296
580
  createContext,
581
+ mergeOptions,
297
582
  noContent,
298
583
  normalizeHandler,
299
584
  normalizeMeta,
585
+ normalizeValidator,
300
586
  notHandled,
301
587
  notMatched,
302
588
  passthrough,
589
+ render,
303
590
  stripResponseBody,
304
591
  stripResponseBodySync
305
592
  });
@@ -1,11 +1,16 @@
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, HttpVerbOrAll, 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 assertHandlerVerb(verb: HttpVerbOrAll, handler: HandlerFunction): void;
12
+ export declare function normalizeValidator<T>(validator: Validator<T> | undefined): import("./types").ValidatorFn<T> | undefined;
13
+ export declare function mergeOptions(...arr: (NormalizedHandler<Context, "ALL", any, HandlerOptions> | HandlerFunction | HandlerOptions)[]): NormalizedHandlerOptions;
9
14
  export declare function stripResponseBodySync(response: Response): Response;
10
15
  export declare function stripResponseBody(response: Awaitable<Response>): Awaitable<Response>;
11
16
  export declare function passthrough(): void;