@marko/run 0.1.2 → 0.1.4

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.
@@ -3,7 +3,7 @@ import path2 from "path";
3
3
  import crypto from "crypto";
4
4
  import fs2 from "fs";
5
5
  import glob from "glob";
6
- import { mergeConfig } from "vite";
6
+ import { mergeConfig, resolvePackageData } from "vite";
7
7
  import markoVitePlugin, { FileStore } from "@marko/vite";
8
8
 
9
9
  // src/vite/constants.ts
@@ -626,7 +626,7 @@ function renderRouter(routes, options = {
626
626
  writer.writeLines(`// @marko/run/router`);
627
627
  const imports = writer.branch("imports");
628
628
  imports.writeLines(
629
- `import { NotHandled, NotMatched, createInput } from 'virtual:marko-run/internal';`
629
+ `import { NotHandled, NotMatched, createContext } from 'virtual:marko-run/internal';`
630
630
  );
631
631
  for (const route of routes.list) {
632
632
  const verbs = getVerbs(route);
@@ -643,7 +643,7 @@ function renderRouter(routes, options = {
643
643
  `import page${key} from '${virtualFilePrefix}/${markoRunFilePrefix}special__${key}.marko${serverEntryQuery}';`
644
644
  );
645
645
  }
646
- writer.writeLines(``).writeBlockStart(`export function match(method, pathname) {`).writeLines(
646
+ writer.writeLines("").writeBlockStart(`export function match(method, pathname) {`).writeLines(
647
647
  `if (!pathname) {
648
648
  pathname = '/';
649
649
  } else if (pathname.charAt(0) !== '/') {
@@ -661,17 +661,10 @@ function renderRouter(routes, options = {
661
661
  }
662
662
  writer.writeBlockEnd("}").writeLines("return null;").writeBlockEnd("}");
663
663
  writer.write(`
664
- export async function invoke(route, request, platform, url = new URL(request.url)) {
665
- const context = {
666
- url,
667
- request,
668
- platform
669
- };
670
- const buildInput = createInput(context);
664
+ export async function invoke(route, request, platform, url) {
665
+ const [context, buildInput] = createContext(route, request, platform, url);
671
666
  try {
672
667
  if (route) {
673
- context.params = route.params;
674
- context.meta = route.meta;
675
668
  try {
676
669
  const response = await route.handler(context, buildInput);
677
670
  if (response) return response;
@@ -682,36 +675,40 @@ export async function invoke(route, request, platform, url = new URL(request.url
682
675
  throw error;
683
676
  }
684
677
  }
685
- `).indent = 2;
678
+ `);
686
679
  if (routes.special[RoutableFileTypes.NotFound]) {
680
+ writer.indent = 2;
681
+ imports.writeLines(
682
+ `
683
+ const page404ResponseInit = {
684
+ status: 404,
685
+ headers: { "content-type": "text/html;charset=UTF-8" },
686
+ };`
687
+ );
687
688
  writer.write(
688
689
  ` } else {
689
- context.params = {};
690
- context.meta = {};
691
690
  }
692
691
  if (context.request.headers.get('Accept')?.includes('text/html')) {
693
- return new Response(page404.stream(buildInput()), {
694
- status: 404,
695
- headers: { "content-type": "text/html;charset=UTF-8" },
696
- });
692
+ return new Response(page404.stream(buildInput()), page404ResponseInit);
697
693
  }
698
694
  `
699
695
  );
700
696
  } else {
697
+ writer.indent = 3;
701
698
  writer.writeBlockEnd("}");
702
699
  }
703
700
  writer.indent--;
704
701
  writer.writeBlockStart(`} catch (error) {`);
705
702
  if (routes.special[RoutableFileTypes.Error]) {
703
+ imports.writeLines(`
704
+ const page500ResponseInit = {
705
+ status: 404,
706
+ headers: { "content-type": "text/html;charset=UTF-8" },
707
+ };`);
706
708
  writer.writeBlockStart(
707
709
  `if (context.request.headers.get('Accept')?.includes('text/html')) {`
708
- ).writeBlock(
709
- `return new Response(page500.stream(buildInput({ error })), {`,
710
- [
711
- `status: 500,`,
712
- `headers: { "content-type": "text/html;charset=UTF-8" },`
713
- ],
714
- `});`
710
+ ).writeLines(
711
+ `return new Response(page500.stream(buildInput({ error })), page500ResponseInit);`
715
712
  ).writeBlockEnd("}");
716
713
  }
717
714
  writer.writeLines(`throw error;`).writeBlockEnd("}").writeBlockEnd("}").write(`
@@ -892,7 +889,7 @@ function renderParamsInfo(params, pathIndex) {
892
889
  for (const { name, index } of params) {
893
890
  if (index >= 0) {
894
891
  result += `${sep} ${wrapPropertyName(name)}: s${index + 1}`;
895
- sep || (sep = ",");
892
+ sep = ",";
896
893
  } else if (pathIndex) {
897
894
  catchAll = name;
898
895
  }
@@ -947,8 +944,8 @@ function stripTsExtension(path3) {
947
944
  }
948
945
  return path3;
949
946
  }
950
- function renderRouteTypeInfo(routes, pathPrefix = ".", adapterTypes = "") {
951
- var _a, _b;
947
+ async function renderRouteTypeInfo(routes, pathPrefix = ".", adapter) {
948
+ var _a, _b, _c, _d;
952
949
  const writer = createStringWriter();
953
950
  writer.writeLines(
954
951
  `/*
@@ -956,28 +953,25 @@ function renderRouteTypeInfo(routes, pathPrefix = ".", adapterTypes = "") {
956
953
  Do NOT manually edit this file or your changes will be lost.
957
954
  */
958
955
  `,
959
- `import type { HandlerLike, Route as AnyRoute, Context as AnyContext, ValidatePath, ValidateHref } from "@marko/run";`,
960
- adapterTypes,
961
- `
962
-
963
- declare global {
964
- namespace MarkoRun {`
956
+ `import type { HandlerLike, Route as AnyRoute, Context as AnyContext, ParamsObject, ValidatePath, ValidateHref } from "@marko/run";`
965
957
  );
966
- const pathsWriter = writer.branch("paths");
967
- writer.write(`
968
- type GetablePath<T extends string> = ValidatePath<GetPaths, T>;
969
- type GetableHref<T extends string> = ValidateHref<GetPaths, T>;
970
- type PostablePath<T extends string> = ValidatePath<PostPaths, T>;
971
- type PostableHref<T extends string> = ValidateHref<PostPaths, T>;
958
+ let platformType = "unknown";
959
+ if (adapter && adapter.typeInfo) {
960
+ platformType = await adapter.typeInfo((data) => writer.write(data));
961
+ writer.writeLines("");
972
962
  }
973
- }
963
+ writer.writeLines(`
964
+ interface NoParams extends ParamsObject {}
965
+ interface NoMeta {}
974
966
  `);
967
+ const pathsWriter = writer.branch("paths");
975
968
  const routesWriter = writer.branch("types");
976
969
  const serverWriter = writer.branch("server");
977
970
  const middlewareRouteTypes = /* @__PURE__ */ new Map();
978
971
  const layoutRouteTypes = /* @__PURE__ */ new Map();
979
972
  const getPaths = /* @__PURE__ */ new Set();
980
973
  const postPaths = /* @__PURE__ */ new Set();
974
+ writeModuleDeclaration(serverWriter, void 0, void 0, platformType);
981
975
  for (const route of routes.list) {
982
976
  const { meta, handler, params, middleware, page, layouts } = route;
983
977
  const routeType = `Route${route.index}`;
@@ -985,8 +979,8 @@ declare global {
985
979
  /\/\$(\$?)([^\/]*)/,
986
980
  (_, catchAll, name) => catchAll ? `/:${name || "rest"}*` : `/:${name}`
987
981
  )}\``;
988
- const paramsType = params ? renderParamsInfoType(params) : "{}";
989
- let metaType = "undefined";
982
+ const paramsType = (params == null ? void 0 : params.length) ? renderParamsInfoType(params) : "NoParams";
983
+ let metaType = "NoMeta";
990
984
  if (page || handler) {
991
985
  const isGet = page || ((_a = handler == null ? void 0 : handler.verbs) == null ? void 0 : _a.includes("get"));
992
986
  const isPost = (_b = handler == null ? void 0 : handler.verbs) == null ? void 0 : _b.includes("post");
@@ -1006,31 +1000,31 @@ declare global {
1006
1000
  }
1007
1001
  }
1008
1002
  if (meta) {
1009
- metaType = `typeof import('${pathPrefix}/${stripTsExtension(
1010
- meta.relativePath
1011
- )}')`;
1003
+ const path3 = stripTsExtension(`${pathPrefix}/${meta.relativePath}`);
1004
+ metaType = `typeof import('${path3}')`;
1012
1005
  if (/\.(ts|js|mjs)$/.test(meta.relativePath)) {
1013
1006
  metaType += `['default']`;
1014
1007
  }
1015
1008
  }
1016
1009
  if (handler) {
1017
- writeRouteTypeModule(
1010
+ writeModuleDeclaration(
1018
1011
  serverWriter,
1019
- pathPrefix,
1020
- handler.relativePath,
1021
- routeType
1012
+ `${pathPrefix}/${handler.relativePath}`,
1013
+ routeType,
1014
+ platformType
1022
1015
  );
1023
1016
  }
1024
1017
  if (page) {
1025
- writer.writeLines(`
1026
- declare module '${pathPrefix}/${page.relativePath}' {
1027
- export interface Input {}
1028
-
1029
- namespace MarkoRun {
1030
- type Route = ${routeType};
1031
- type Context = AnyContext<AnyContext['platform'], Route>;
1032
- }
1033
- }`);
1018
+ writeModuleDeclaration(
1019
+ writer,
1020
+ `${pathPrefix}/${page.relativePath}`,
1021
+ routeType,
1022
+ platformType,
1023
+ `
1024
+ export interface Input {
1025
+ renderBody: Marko.Body;
1026
+ }`
1027
+ );
1034
1028
  }
1035
1029
  if (middleware) {
1036
1030
  let i = 0;
@@ -1060,74 +1054,106 @@ declare module '${pathPrefix}/${page.relativePath}' {
1060
1054
  }
1061
1055
  }
1062
1056
  routesWriter.writeLines(
1063
- `interface ${routeType} extends AnyRoute<${paramsType}, ${metaType}, ${pathType}> {}`
1057
+ `type ${routeType} = AnyRoute<${paramsType}, ${metaType}, ${pathType}>;`
1064
1058
  );
1065
1059
  }
1066
- pathsWriter.write(" type GetPaths =");
1067
- for (const path3 of getPaths) {
1068
- pathsWriter.write(`
1069
- | '${path3}'`);
1060
+ pathsWriter.write(`type Get =`);
1061
+ if (getPaths.size) {
1062
+ for (const path3 of getPaths) {
1063
+ pathsWriter.write(`
1064
+ | '${path3}'`);
1065
+ }
1066
+ } else {
1067
+ pathsWriter.write(" never");
1070
1068
  }
1071
1069
  pathsWriter.writeLines(";", "");
1072
- pathsWriter.write(" type PostPaths =");
1073
- for (const path3 of postPaths) {
1074
- pathsWriter.write(`
1075
- | '${path3}'`);
1070
+ pathsWriter.write("type Post =");
1071
+ if (postPaths.size) {
1072
+ for (const path3 of postPaths) {
1073
+ pathsWriter.write(`
1074
+ | '${path3}'`);
1075
+ }
1076
+ } else {
1077
+ pathsWriter.write(" never");
1076
1078
  }
1077
- pathsWriter.writeLines(";");
1079
+ pathsWriter.writeLines(";", "");
1078
1080
  pathsWriter.join();
1079
1081
  for (const [file, { routeTypes }] of middlewareRouteTypes) {
1080
- writeRouteTypeModule(
1082
+ writeModuleDeclaration(
1081
1083
  serverWriter,
1082
- pathPrefix,
1083
- file.relativePath,
1084
- routeTypes.join(" | ")
1084
+ `${pathPrefix}/${file.relativePath}`,
1085
+ routeTypes.join(" | "),
1086
+ platformType
1085
1087
  );
1086
1088
  }
1087
1089
  for (const [file, { routeTypes }] of layoutRouteTypes) {
1088
- writer.writeLines(`
1089
- declare module '${pathPrefix}/${file.relativePath}' {
1090
+ writeModuleDeclaration(
1091
+ writer,
1092
+ `${pathPrefix}/${file.relativePath}`,
1093
+ routeTypes.join(" | "),
1094
+ platformType,
1095
+ `
1090
1096
  export interface Input {
1091
1097
  renderBody: Marko.Body;
1098
+ }`
1099
+ );
1092
1100
  }
1093
-
1094
- namespace MarkoRun {
1095
- type Route = ${routeTypes.join(" | ")};
1096
- type Context = AnyContext<AnyContext['platform'], Route>;
1097
- }
1098
- }`);
1101
+ if ((_c = routes.special["404"]) == null ? void 0 : _c.page) {
1102
+ writeModuleDeclaration(
1103
+ writer,
1104
+ `${pathPrefix}/${routes.special["404"].page.relativePath}`,
1105
+ void 0,
1106
+ platformType,
1107
+ `
1108
+ export interface Input {}`
1109
+ );
1099
1110
  }
1100
- for (const route of [routes.special["404"], routes.special["500"]]) {
1101
- if (route && route.page) {
1102
- writer.write(`
1103
- declare module '${pathPrefix}/${route.page.relativePath}' {
1104
- export interface Input {`);
1105
- if (route.page.type === RoutableFileTypes.Error) {
1106
- writer.write(`
1111
+ if ((_d = routes.special["500"]) == null ? void 0 : _d.page) {
1112
+ writeModuleDeclaration(
1113
+ writer,
1114
+ `${pathPrefix}/${routes.special["500"].page.relativePath}`,
1115
+ void 0,
1116
+ platformType,
1117
+ `
1118
+ export interface Input {
1107
1119
  error: unknown;
1108
- `);
1109
- }
1110
- writer.writeLines(`}
1111
-
1112
- namespace MarkoRun {
1113
- type Route = AnyRoute;
1114
- type Context = AnyContext<AnyContext['platform'], Route>;
1115
- }
1116
- }`);
1117
- }
1120
+ }`
1121
+ );
1118
1122
  }
1119
1123
  serverWriter.join();
1120
1124
  return writer.end();
1121
1125
  }
1122
- function writeRouteTypeModule(writer, pathPrefix, path3, routeType) {
1123
- writer.writeLines(`
1124
- declare module '${pathPrefix}/${stripTsExtension(path3)}' {
1126
+ function writeModuleDeclaration(writer, path3 = "global", routeType = "AnyRoute", platformType = "unknown", moduleTypes) {
1127
+ writer.writeLines("");
1128
+ if (path3 === "global") {
1129
+ writer.write("declare global {");
1130
+ } else {
1131
+ writer.write(`declare module '${stripTsExtension(path3)}' {`);
1132
+ }
1133
+ if (moduleTypes) {
1134
+ writer.writeLines(moduleTypes);
1135
+ }
1136
+ const isMarko = path3.endsWith(".marko");
1137
+ writer.write(`
1125
1138
  namespace MarkoRun {
1139
+ type GetPaths = Get;
1140
+ type PostPaths = Post;
1141
+ type GetablePath<T extends string> = ValidatePath<Get, T>;
1142
+ type GetableHref<T extends string> = ValidateHref<Get, T>;
1143
+ type PostablePath<T extends string> = ValidatePath<Post, T>;
1144
+ type PostableHref<T extends string> = ValidateHref<Post, T>;
1145
+ type Platform = ${platformType};`);
1146
+ if (path3 !== "global") {
1147
+ writer.write(`
1126
1148
  type Route = ${routeType};
1127
- type Context = AnyContext<AnyContext['platform'], Route>;
1149
+ type Context = AnyContext<Platform, Route>${isMarko ? " & Marko.Global" : ""};
1128
1150
  type Handler<_Params = Route['params'], _Meta = Route['meta']> = HandlerLike<Route>;
1129
1151
  function route(handler: Handler): typeof handler;
1130
1152
  function route<_Params = Route['params'], _Meta = Route['meta']>(handler: Handler): typeof handler;
1153
+ const NotHandled: unique symbol;
1154
+ const NotMatched: unique symbol;`);
1155
+ }
1156
+ writer.writeLines(`
1131
1157
  }
1132
1158
  }`);
1133
1159
  }
@@ -1325,8 +1351,9 @@ var normalizePath = path2.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_
1325
1351
  function isMarkoFile(id) {
1326
1352
  return id.endsWith(markoExt);
1327
1353
  }
1328
- function markoServe(opts = {}) {
1329
- const { routesDir = "src/routes", adapter, ...markoOptions } = opts;
1354
+ function markoRun(opts = {}) {
1355
+ let { routesDir = "src/routes", adapter, ...markoOptions } = opts;
1356
+ let compiler;
1330
1357
  let store;
1331
1358
  let root;
1332
1359
  let resolvedRoutesDir;
@@ -1357,8 +1384,11 @@ function markoServe(opts = {}) {
1357
1384
  "{.tsconfig*,tsconfig*.json}"
1358
1385
  ))) {
1359
1386
  const filepath = path2.join(typesDir, "routes.d.ts");
1360
- const adapterTypeInfo = (adapter == null ? void 0 : adapter.writeTypeInfo) && await (adapter == null ? void 0 : adapter.writeTypeInfo());
1361
- const data = renderRouteTypeInfo(routes, path2.relative(typesDir, routesDir), adapterTypeInfo);
1387
+ const data = await renderRouteTypeInfo(
1388
+ routes,
1389
+ path2.relative(typesDir, routesDir),
1390
+ adapter
1391
+ );
1362
1392
  if (data !== typesFile || !fs2.existsSync(filepath)) {
1363
1393
  await ensureDir(typesDir);
1364
1394
  await fs2.promises.writeFile(filepath, typesFile = data);
@@ -1371,13 +1401,16 @@ function markoServe(opts = {}) {
1371
1401
  route.handler.verbs = await extractVerbs(route.handler.filePath);
1372
1402
  if (!route.handler.verbs.length) {
1373
1403
  console.warn(
1374
- `Did not find any valid exports in middleware entry file:'${route.handler.filePath}' - expected to find any of 'get', 'post', 'put' or 'del'`
1404
+ `Did not find any valid exports in middleware entry file:'${route.handler.filePath}' - expected to find any of 'GET', 'POST', 'PUT' or 'DELETE'`
1375
1405
  );
1376
1406
  }
1377
1407
  }
1378
1408
  if (route.page) {
1379
1409
  virtualFiles.set(
1380
- path2.posix.join(root, `${markoRunFilePrefix}route__${route.key}.marko`),
1410
+ path2.posix.join(
1411
+ root,
1412
+ `${markoRunFilePrefix}route__${route.key}.marko`
1413
+ ),
1381
1414
  render ? renderRouteTemplate(route) : ""
1382
1415
  );
1383
1416
  }
@@ -1388,7 +1421,10 @@ function markoServe(opts = {}) {
1388
1421
  }
1389
1422
  for (const route of Object.values(routes.special)) {
1390
1423
  virtualFiles.set(
1391
- path2.posix.join(root, `${markoRunFilePrefix}special__${route.key}.marko`),
1424
+ path2.posix.join(
1425
+ root,
1426
+ `${markoRunFilePrefix}special__${route.key}.marko`
1427
+ ),
1392
1428
  render ? renderRouteTemplate(route) : ""
1393
1429
  );
1394
1430
  }
@@ -1428,22 +1464,32 @@ function markoServe(opts = {}) {
1428
1464
  if (externalPluginOptions) {
1429
1465
  opts = mergeConfig(opts, externalPluginOptions);
1430
1466
  }
1467
+ root = normalizePath(config2.root || process.cwd());
1468
+ isBuild = env.command === "build";
1469
+ isSSRBuild = isBuild && Boolean((_a = config2.build) == null ? void 0 : _a.ssr);
1470
+ adapter = await resolveAdapter(root, opts, config2.logLevel !== "silent" && !isBuild || isSSRBuild);
1431
1471
  if (adapter) {
1432
1472
  const externalAdapterConfig = getExternalAdapterOptions(config2);
1433
1473
  if (externalAdapterConfig && adapter.configure) {
1434
1474
  adapter.configure(externalAdapterConfig);
1435
1475
  }
1436
- const adapterOptions = await ((_a = adapter.pluginOptions) == null ? void 0 : _a.call(adapter, opts));
1476
+ const adapterOptions = await ((_b = adapter.pluginOptions) == null ? void 0 : _b.call(adapter, opts));
1437
1477
  if (adapterOptions) {
1438
1478
  opts = mergeConfig(opts, adapterOptions);
1439
1479
  }
1440
1480
  }
1441
- root = normalizePath(config2.root || process.cwd());
1481
+ compiler ?? (compiler = await import(opts.compiler || "@marko/compiler"));
1482
+ compiler.taglib.register("@marko/run", {
1483
+ "<*>": {
1484
+ transform: path2.resolve(
1485
+ __dirname,
1486
+ "../components/src-attributes-transformer.cjs"
1487
+ )
1488
+ }
1489
+ });
1442
1490
  store = opts.store || new FileStore(
1443
1491
  `marko-serve-vite-${crypto.createHash("SHA1").update(root).digest("hex")}`
1444
1492
  );
1445
- isBuild = env.command === "build";
1446
- isSSRBuild = isBuild && Boolean((_b = config2.build) == null ? void 0 : _b.ssr);
1447
1493
  resolvedRoutesDir = path2.resolve(root, routesDir);
1448
1494
  typesDir = path2.join(root, ".marko-run");
1449
1495
  devEntryFile = path2.join(root, "index.html");
@@ -1685,6 +1731,31 @@ async function ensureDir(dir) {
1685
1731
  await fs2.promises.mkdir(dir, { recursive: true });
1686
1732
  }
1687
1733
  }
1734
+ async function resolveAdapter(root, options, log) {
1735
+ const { adapter } = options;
1736
+ if (adapter !== void 0) {
1737
+ return adapter;
1738
+ }
1739
+ const pkg = resolvePackageData(".", root);
1740
+ if (pkg) {
1741
+ const dependecies = { ...pkg.data.dependecies, ...pkg.data.devDependencies };
1742
+ for (const name of Object.keys(dependecies)) {
1743
+ if (name.startsWith("@marko/run-adapter") || name.indexOf("marko-run-adapter") !== -1) {
1744
+ try {
1745
+ const module2 = await import(name);
1746
+ log && console.log(`Using adapter ${name} listed in your package.json dependecies`);
1747
+ return module2.default();
1748
+ } catch (err) {
1749
+ log && console.warn(`Attempt to use package '${name}' failed`, err);
1750
+ }
1751
+ }
1752
+ }
1753
+ }
1754
+ const defaultAdapter = "@marko/run/adapter";
1755
+ const module = await import(defaultAdapter);
1756
+ log && console.log("Using default adapter");
1757
+ return module.default();
1758
+ }
1688
1759
 
1689
1760
  // src/vite/utils/server.ts
1690
1761
  import net from "net";
@@ -1756,7 +1827,7 @@ function sleep(ms) {
1756
1827
  return new Promise((resolve) => setTimeout(resolve, ms));
1757
1828
  }
1758
1829
  export {
1759
- markoServe as default,
1830
+ markoRun as default,
1760
1831
  getAvailablePort,
1761
1832
  isPortInUse,
1762
1833
  loadEnv,
@@ -1,3 +1,4 @@
1
1
  import type { Plugin } from "vite";
2
- import type { Options } from "./types";
3
- export default function markoServe(opts?: Options): Plugin[];
2
+ import type { Options, Adapter } from "./types";
3
+ export default function markoRun(opts?: Options): Plugin[];
4
+ export declare function resolveAdapter(root: string, options: Options, log?: boolean): Promise<Adapter | null>;
@@ -8,7 +8,7 @@ export interface WalkOptions {
8
8
  onEnter?: (dir: WalkEntry) => (() => void) | false | void;
9
9
  maxDepth?: number;
10
10
  }
11
- export declare type Walker = (options: WalkOptions) => Promise<void>;
11
+ export type Walker = (options: WalkOptions) => Promise<void>;
12
12
  export declare function createFSWalker(dir: string): Walker;
13
- export declare type TestFileTree = [string, (string | TestFileTree)[]];
13
+ export type TestFileTree = [string, (string | TestFileTree)[]];
14
14
  export declare function createTestWalker(dir: TestFileTree): Walker;
@@ -2,7 +2,7 @@ import type { RoutableFileType, HttpVerb, RoutableFileTypes } from "./constants"
2
2
  import type { Options as MarkoViteOptions } from "@marko/vite";
3
3
  import type { ResolvedConfig, UserConfig } from "vite";
4
4
  export type { RoutableFileType, HttpVerb };
5
- export declare type StartServer = (port?: number) => Promise<void>;
5
+ export type StartServer = (port?: number) => Promise<void>;
6
6
  export interface AdapterConfig {
7
7
  [name: PropertyKey]: any;
8
8
  }
@@ -15,7 +15,7 @@ export interface Adapter {
15
15
  startDev?(configFile: string, port: number, envFile?: string): Promise<void> | void;
16
16
  startPreview?(dir: string, entry?: string, port?: number, envFile?: string): Promise<void> | void;
17
17
  buildEnd?(config: ResolvedConfig, routes: Route[], builtEntries: string[], sourceEntries: string[]): Promise<void> | void;
18
- writeTypeInfo?(): Promise<string> | string;
18
+ typeInfo?(writer: (data: string) => void): Promise<string> | string;
19
19
  }
20
20
  export interface RouterOptions {
21
21
  trailingSlashes: 'Ignore' | 'RedirectWithout' | 'RedirectWith' | 'RewriteWithout' | 'RewriteWith';
@@ -23,9 +23,9 @@ export interface RouterOptions {
23
23
  export interface MarkoServeOptions extends Partial<RouterOptions> {
24
24
  routesDir?: string;
25
25
  emitRoutes?(routes: Route[]): void | Promise<void>;
26
- adapter?: Adapter;
26
+ adapter?: Adapter | null;
27
27
  }
28
- export declare type Options = MarkoServeOptions & MarkoViteOptions;
28
+ export type Options = MarkoServeOptions & MarkoViteOptions;
29
29
  export interface Route {
30
30
  key: string;
31
31
  index: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/run",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "The Marko application framework.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/marko-js/run/tree/main/packages/run",
@@ -108,7 +108,9 @@
108
108
  "kleur": "^4.1.5",
109
109
  "sade": "^1.8.1",
110
110
  "serve-static": "^1.15.0",
111
+ "strip-ansi": "^7.0.1",
111
112
  "undici": "^5.20.0",
112
- "vite": "^4.1.4"
113
+ "vite": "^4.1.4",
114
+ "warp10": "^2.1.0"
113
115
  }
114
116
  }