@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 +5 -5
- package/dist/vite/index.cjs +13 -9
- package/dist/vite/index.js +13 -9
- package/package.json +1 -1
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.
|
|
484
|
+
**`MarkoRun.Route`** - Type of the route's params and metadata
|
|
485
485
|
|
|
486
|
-
**`MarkoRun.
|
|
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.
|
|
496
|
+
- Overrides context with specific MarkoRun.Context
|
|
497
497
|
|
|
498
|
-
**`MarkoRun.
|
|
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.
|
|
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
|
|
package/dist/vite/index.cjs
CHANGED
|
@@ -232,7 +232,7 @@ async function buildRoutes(walk, basePath) {
|
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
pathStack.push(name
|
|
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
|
-
|
|
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
|
|
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);
|
package/dist/vite/index.js
CHANGED
|
@@ -195,7 +195,7 @@ async function buildRoutes(walk, basePath) {
|
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
pathStack.push(name
|
|
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
|
-
|
|
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
|
|
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";
|