@marko/run 0.1.6 → 0.1.7

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/README.md CHANGED
@@ -481,9 +481,9 @@ express()
481
481
 
482
482
  **`MarkoRun.Handler`** - Type that represents a handler function to be exported by a +handler or +middleware file
483
483
 
484
- **`MarkoRun.CurrentRoute`** - Type of the route's params and metadata
484
+ **`MarkoRun.Route`** - Type of the route's params and metadata
485
485
 
486
- **`MarkoRun.CurrentContext`** - Type of the request context object in a handler and `out.global` in your Marko files
486
+ **`MarkoRun.Context`** - Type of the request context object in a handler and `out.global` in your Marko files
487
487
 
488
488
 
489
489
  ### Generated Types
@@ -493,13 +493,13 @@ If a [TSConfig](https://www.typescriptlang.org/tsconfig) file is discovered in t
493
493
  These types are replaced with more specific versions per routable file:
494
494
 
495
495
  **`MarkoRun.Handler`**
496
- - Overrides context with specific MarkoRun.CurrentContext
496
+ - Overrides context with specific MarkoRun.Context
497
497
 
498
- **`MarkoRun.CurrentRoute`**
498
+ **`MarkoRun.Route`**
499
499
  - Adds specific parameters and meta types
500
500
  - In middleware and layouts which are used in many routes, this type will be a union of all possible routes that the file will see
501
501
 
502
- **`MarkoRun.CurrentContext`**
502
+ **`MarkoRun.Context`**
503
503
  - In middleware and layouts which are used in many routes, this type will be a union of all possible routes that the file will see.
504
504
  - When an adapter is used, it can provide types for the platform
505
505
 
@@ -232,7 +232,7 @@ async function buildRoutes(walk, basePath) {
232
232
  });
233
233
  }
234
234
  }
235
- pathStack.push(name.toLowerCase());
235
+ pathStack.push(name);
236
236
  }
237
237
  dirStack.push(name);
238
238
  isRoot = false;
@@ -957,7 +957,8 @@ function renderMatch(verb, route, pathIndex) {
957
957
  const handler = `${verb}${route.index}`;
958
958
  const params = ((_a = route.params) == null ? void 0 : _a.length) ? renderParamsInfo(route.params, pathIndex) : "{}";
959
959
  const meta = route.meta ? `meta${route.index}` : "{}";
960
- return `{ handler: ${handler}, params: ${params}, meta: ${meta} }`;
960
+ const path3 = pathToURLPatternString(route.path);
961
+ return `{ handler: ${handler}, params: ${params}, meta: ${meta}, path: '${path3}' }`;
961
962
  }
962
963
  function renderMiddleware(middleware) {
963
964
  const writer = createStringWriter();
@@ -1016,13 +1017,7 @@ interface NoMeta {}
1016
1017
  for (const route of routes.list) {
1017
1018
  const { meta, handler, params, middleware, page, layouts } = route;
1018
1019
  const routeType = `Route${route.index}`;
1019
- const pathType = `\`${route.path.replace(
1020
- /\/\$(\$?)([^\/]*)/,
1021
- (_, catchAll, name) => {
1022
- name = decodeURIComponent(name);
1023
- return catchAll ? `/:${name || "rest"}*` : `/:${name}`;
1024
- }
1025
- )}\``;
1020
+ const pathType = `\`${pathToURLPatternString(route.path)}\``;
1026
1021
  const paramsType = (params == null ? void 0 : params.length) ? renderParamsInfoType(params) : "NoParams";
1027
1022
  let metaType = "NoMeta";
1028
1023
  if (page || handler) {
@@ -1201,6 +1196,15 @@ function writeModuleDeclaration(writer, path3 = "global", routeType = "AnyRoute"
1201
1196
  }
1202
1197
  }`);
1203
1198
  }
1199
+ function pathToURLPatternString(path3) {
1200
+ return path3.replace(
1201
+ /\/\$(\$?)([^\/]*)/g,
1202
+ (_, catchAll, name) => {
1203
+ name = decodeURIComponent(name);
1204
+ return catchAll ? `/:${name || "rest"}*` : `/:${name}`;
1205
+ }
1206
+ );
1207
+ }
1204
1208
 
1205
1209
  // src/vite/utils/ast.ts
1206
1210
  var t = __toESM(require("@babel/types"), 1);
@@ -195,7 +195,7 @@ async function buildRoutes(walk, basePath) {
195
195
  });
196
196
  }
197
197
  }
198
- pathStack.push(name.toLowerCase());
198
+ pathStack.push(name);
199
199
  }
200
200
  dirStack.push(name);
201
201
  isRoot = false;
@@ -920,7 +920,8 @@ function renderMatch(verb, route, pathIndex) {
920
920
  const handler = `${verb}${route.index}`;
921
921
  const params = ((_a = route.params) == null ? void 0 : _a.length) ? renderParamsInfo(route.params, pathIndex) : "{}";
922
922
  const meta = route.meta ? `meta${route.index}` : "{}";
923
- return `{ handler: ${handler}, params: ${params}, meta: ${meta} }`;
923
+ const path3 = pathToURLPatternString(route.path);
924
+ return `{ handler: ${handler}, params: ${params}, meta: ${meta}, path: '${path3}' }`;
924
925
  }
925
926
  function renderMiddleware(middleware) {
926
927
  const writer = createStringWriter();
@@ -979,13 +980,7 @@ interface NoMeta {}
979
980
  for (const route of routes.list) {
980
981
  const { meta, handler, params, middleware, page, layouts } = route;
981
982
  const routeType = `Route${route.index}`;
982
- const pathType = `\`${route.path.replace(
983
- /\/\$(\$?)([^\/]*)/,
984
- (_, catchAll, name) => {
985
- name = decodeURIComponent(name);
986
- return catchAll ? `/:${name || "rest"}*` : `/:${name}`;
987
- }
988
- )}\``;
983
+ const pathType = `\`${pathToURLPatternString(route.path)}\``;
989
984
  const paramsType = (params == null ? void 0 : params.length) ? renderParamsInfoType(params) : "NoParams";
990
985
  let metaType = "NoMeta";
991
986
  if (page || handler) {
@@ -1164,6 +1159,15 @@ function writeModuleDeclaration(writer, path3 = "global", routeType = "AnyRoute"
1164
1159
  }
1165
1160
  }`);
1166
1161
  }
1162
+ function pathToURLPatternString(path3) {
1163
+ return path3.replace(
1164
+ /\/\$(\$?)([^\/]*)/g,
1165
+ (_, catchAll, name) => {
1166
+ name = decodeURIComponent(name);
1167
+ return catchAll ? `/:${name || "rest"}*` : `/:${name}`;
1168
+ }
1169
+ );
1170
+ }
1167
1171
 
1168
1172
  // src/vite/utils/ast.ts
1169
1173
  import * as t from "@babel/types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/run",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "The Marko application framework.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/marko-js/run/tree/main/packages/run",