@marko/run 0.2.8 → 0.2.10
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/dist/.tsbuildinfo +1 -1
- package/dist/adapter/index.cjs +128 -30
- package/dist/adapter/index.js +128 -30
- package/dist/adapter/load-dev-worker.mjs +17 -2
- package/dist/adapter/utils.d.ts +1 -1
- package/dist/cli/index.mjs +56 -28
- package/dist/components/routes-explorer/+layout.marko +17 -0
- package/dist/components/routes-explorer/+page.marko +1 -0
- package/dist/vite/index.cjs +52 -28
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +52 -28
- package/dist/vite/routes/builder.d.ts +6 -1
- package/dist/vite/types.d.ts +10 -0
- package/dist/vite/utils/server.d.ts +1 -1
- package/package.json +5 -2
- package/dist/adapter/runtime.cjs +0 -22
- package/dist/adapter/runtime.d.ts +0 -1
- package/dist/adapter/runtime.js +0 -0
package/dist/vite/index.cjs
CHANGED
|
@@ -388,10 +388,7 @@ function matchRoutableFile(filename) {
|
|
|
388
388
|
function isSpecialType(type) {
|
|
389
389
|
return type === RoutableFileTypes.NotFound || type === RoutableFileTypes.Error;
|
|
390
390
|
}
|
|
391
|
-
async function buildRoutes(
|
|
392
|
-
if (basePath) {
|
|
393
|
-
basePath = basePath.replace(/^\/+|\/+$/g, "");
|
|
394
|
-
}
|
|
391
|
+
async function buildRoutes(sources) {
|
|
395
392
|
const uniqueRoutes = /* @__PURE__ */ new Map();
|
|
396
393
|
const routes = [];
|
|
397
394
|
const special = {};
|
|
@@ -401,23 +398,30 @@ async function buildRoutes(walk, basePath = "") {
|
|
|
401
398
|
const currentMiddleware = /* @__PURE__ */ new Set();
|
|
402
399
|
const root = new VDir();
|
|
403
400
|
const dirStack = [];
|
|
404
|
-
let
|
|
401
|
+
let basePath;
|
|
402
|
+
let importPrefix;
|
|
403
|
+
let activeDirs;
|
|
404
|
+
let isBaseDir;
|
|
405
405
|
let nextFileId = 1;
|
|
406
406
|
let nextRouteIndex = 1;
|
|
407
|
-
|
|
408
|
-
await walk({
|
|
407
|
+
const walkOptions = {
|
|
409
408
|
onEnter({ name }) {
|
|
410
|
-
|
|
409
|
+
const prevDirStackLength = dirStack.length;
|
|
410
|
+
if (isBaseDir) {
|
|
411
411
|
isBaseDir = false;
|
|
412
|
-
|
|
412
|
+
if (!basePath) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
name = basePath;
|
|
416
|
+
} else {
|
|
417
|
+
dirStack.push(name);
|
|
413
418
|
}
|
|
414
|
-
dirStack.push(name);
|
|
415
419
|
const previousDirs = activeDirs;
|
|
416
420
|
const paths = parseFlatRoute(name);
|
|
417
421
|
activeDirs = VDir.addPaths(previousDirs, paths);
|
|
418
422
|
return () => {
|
|
419
423
|
activeDirs = previousDirs;
|
|
420
|
-
dirStack.
|
|
424
|
+
dirStack.length = prevDirStackLength;
|
|
421
425
|
};
|
|
422
426
|
},
|
|
423
427
|
onFile({ name, path: path3 }) {
|
|
@@ -445,14 +449,24 @@ async function buildRoutes(walk, basePath = "") {
|
|
|
445
449
|
type,
|
|
446
450
|
filePath: path3,
|
|
447
451
|
relativePath,
|
|
448
|
-
importPath: `${
|
|
452
|
+
importPath: `${importPrefix}/${relativePath}`,
|
|
449
453
|
verbs: type === RoutableFileTypes.Page ? ["get"] : void 0
|
|
450
454
|
};
|
|
451
455
|
for (const dir of dirs) {
|
|
452
456
|
dir.addFile(file);
|
|
453
457
|
}
|
|
454
458
|
}
|
|
455
|
-
}
|
|
459
|
+
};
|
|
460
|
+
if (!Array.isArray(sources)) {
|
|
461
|
+
sources = [sources];
|
|
462
|
+
}
|
|
463
|
+
for (const source of sources) {
|
|
464
|
+
importPrefix = source.importPrefix ? source.importPrefix.replace(/^\/+|\/+$/g, "") : "";
|
|
465
|
+
basePath = source.basePath || "";
|
|
466
|
+
activeDirs = [root];
|
|
467
|
+
isBaseDir = true;
|
|
468
|
+
await source.walker(walkOptions);
|
|
469
|
+
}
|
|
456
470
|
traverse(root);
|
|
457
471
|
return {
|
|
458
472
|
list: routes,
|
|
@@ -1002,12 +1016,13 @@ globalThis.__marko_run__ = { match, fetch, invoke };
|
|
|
1002
1016
|
} else if (pathname.charAt(0) !== '/') {
|
|
1003
1017
|
pathname = '/' + pathname;
|
|
1004
1018
|
}`
|
|
1005
|
-
).writeBlockStart(`switch (method
|
|
1019
|
+
).writeBlockStart(`switch (method) {`);
|
|
1006
1020
|
for (const verb of httpVerbs) {
|
|
1007
1021
|
const filteredRoutes = routes.list.filter((route) => hasVerb(route, verb));
|
|
1008
1022
|
if (filteredRoutes.length) {
|
|
1009
1023
|
const trie = createRouteTrie(filteredRoutes);
|
|
1010
|
-
writer.
|
|
1024
|
+
writer.writeLines(`case '${verb.toUpperCase()}':`);
|
|
1025
|
+
writer.writeBlockStart(`case '${verb.toLowerCase()}': {`);
|
|
1011
1026
|
writeRouterVerb(writer, trie, verb);
|
|
1012
1027
|
writer.writeBlockEnd("}");
|
|
1013
1028
|
}
|
|
@@ -1159,13 +1174,14 @@ function writeRouterVerb(writer, trie, verb, level = 0, offset = 1) {
|
|
|
1159
1174
|
if (terminal) {
|
|
1160
1175
|
const useSwitch = terminal.length > 1;
|
|
1161
1176
|
if (useSwitch) {
|
|
1162
|
-
writer.writeBlockStart(`switch (${value}
|
|
1177
|
+
writer.writeBlockStart(`switch (${value}) {`);
|
|
1163
1178
|
}
|
|
1164
1179
|
for (const { key, path: path3, route: route2 } of terminal) {
|
|
1180
|
+
const decodedKey = decodeURIComponent(key);
|
|
1165
1181
|
if (useSwitch) {
|
|
1166
|
-
writer.write(`case '${
|
|
1182
|
+
writer.write(`case '${decodedKey}': `, true);
|
|
1167
1183
|
} else {
|
|
1168
|
-
writer.write(`if (${value}
|
|
1184
|
+
writer.write(`if (${value} === '${decodedKey}') `, true);
|
|
1169
1185
|
}
|
|
1170
1186
|
writer.write(
|
|
1171
1187
|
`return ${renderMatch(verb, route2, path3)}; // ${path3.path}
|
|
@@ -1202,7 +1218,7 @@ function writeRouterVerb(writer, trie, verb, level = 0, offset = 1) {
|
|
|
1202
1218
|
if (children) {
|
|
1203
1219
|
const useSwitch = children.length > 1;
|
|
1204
1220
|
if (useSwitch) {
|
|
1205
|
-
writer.writeBlockStart(`switch (${value}
|
|
1221
|
+
writer.writeBlockStart(`switch (${value}) {`);
|
|
1206
1222
|
}
|
|
1207
1223
|
for (const child of children) {
|
|
1208
1224
|
const decodedKey = decodeURIComponent(child.key);
|
|
@@ -1210,7 +1226,7 @@ function writeRouterVerb(writer, trie, verb, level = 0, offset = 1) {
|
|
|
1210
1226
|
writer.writeBlockStart(`case '${decodedKey}': {`);
|
|
1211
1227
|
} else {
|
|
1212
1228
|
writer.writeBlockStart(
|
|
1213
|
-
`if (${value}
|
|
1229
|
+
`if (${value} === '${decodedKey}') {`
|
|
1214
1230
|
);
|
|
1215
1231
|
}
|
|
1216
1232
|
const nextOffset = typeof offset === "string" ? index : offset + child.key.length + 1;
|
|
@@ -1691,6 +1707,8 @@ var setExternalPluginOptions = (viteConfig, value) => setConfig(viteConfig, Plug
|
|
|
1691
1707
|
var getExternalAdapterOptions = (viteConfig) => getConfig(viteConfig, AdapterConfigKey);
|
|
1692
1708
|
|
|
1693
1709
|
// src/vite/plugin.ts
|
|
1710
|
+
var import_debug = __toESM(require("debug"), 1);
|
|
1711
|
+
var debug = (0, import_debug.default)("@marko/run");
|
|
1694
1712
|
var __dirname = import_path2.default.dirname((0, import_url2.fileURLToPath)(__importMetaURL));
|
|
1695
1713
|
var PLUGIN_NAME_PREFIX = "marko-run-vite";
|
|
1696
1714
|
var POSIX_SEP = "/";
|
|
@@ -1750,10 +1768,10 @@ function markoRun(opts = {}) {
|
|
|
1750
1768
|
virtualFiles.clear();
|
|
1751
1769
|
isRendered = false;
|
|
1752
1770
|
const buildStartTime = performance.now();
|
|
1753
|
-
routes = await buildRoutes(
|
|
1754
|
-
createFSWalker(resolvedRoutesDir),
|
|
1755
|
-
routesDir
|
|
1756
|
-
);
|
|
1771
|
+
routes = await buildRoutes({
|
|
1772
|
+
walker: createFSWalker(resolvedRoutesDir),
|
|
1773
|
+
importPrefix: routesDir
|
|
1774
|
+
});
|
|
1757
1775
|
times.routesBuild = performance.now() - buildStartTime;
|
|
1758
1776
|
if (!routes.list.length) {
|
|
1759
1777
|
throw new Error("No routes generated");
|
|
@@ -1799,6 +1817,12 @@ function markoRun(opts = {}) {
|
|
|
1799
1817
|
times.routesRender = performance.now() - renderStartTime;
|
|
1800
1818
|
if (render) {
|
|
1801
1819
|
await writeTypesFile(routes);
|
|
1820
|
+
if (adapter == null ? void 0 : adapter.routesGenerated) {
|
|
1821
|
+
await adapter.routesGenerated(routes, new Map(virtualFiles.entries()), {
|
|
1822
|
+
buildTime: times.routesBuild,
|
|
1823
|
+
renderTime: times.routesRender
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1802
1826
|
if (!isBuild) {
|
|
1803
1827
|
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
|
|
1804
1828
|
}
|
|
@@ -2096,7 +2120,7 @@ function markoRun(opts = {}) {
|
|
|
2096
2120
|
}
|
|
2097
2121
|
await store.set(routeDataFilename, JSON.stringify(routeData));
|
|
2098
2122
|
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
|
|
2099
|
-
} else {
|
|
2123
|
+
} else if (process.env.MR_EXPLORER !== "true") {
|
|
2100
2124
|
logRoutesTable(routes, bundle, options);
|
|
2101
2125
|
}
|
|
2102
2126
|
},
|
|
@@ -2203,19 +2227,19 @@ async function resolveAdapter(root, options, log) {
|
|
|
2203
2227
|
if (name.startsWith("@marko/run-adapter") || name.indexOf("marko-run-adapter") !== -1) {
|
|
2204
2228
|
try {
|
|
2205
2229
|
const module3 = await import(name);
|
|
2206
|
-
log &&
|
|
2230
|
+
log && debug(
|
|
2207
2231
|
`Using adapter ${name} listed in your package.json dependecies`
|
|
2208
2232
|
);
|
|
2209
2233
|
return module3.default();
|
|
2210
2234
|
} catch (err) {
|
|
2211
|
-
log &&
|
|
2235
|
+
log && debug(`Attempt to use package '${name}' failed %O`, err);
|
|
2212
2236
|
}
|
|
2213
2237
|
}
|
|
2214
2238
|
}
|
|
2215
2239
|
}
|
|
2216
2240
|
const defaultAdapter = "@marko/run/adapter";
|
|
2217
2241
|
const module2 = await import(defaultAdapter);
|
|
2218
|
-
log &&
|
|
2242
|
+
log && debug("Using default adapter");
|
|
2219
2243
|
return module2.default();
|
|
2220
2244
|
}
|
|
2221
2245
|
var markoEntryFileRegex = /__marko-run__([^.]+)\.(.+)\.marko\.([^.]+)$/;
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default, getPackageData } from "./plugin";
|
|
2
2
|
export { getAvailablePort, isPortInUse, loadEnv, parseEnv, spawnServer, } from "./utils/server";
|
|
3
3
|
export type { SpawnedServer } from "./utils/server";
|
|
4
|
-
export type { Adapter, AdapterConfig, Options, BuiltRoutes, HttpVerb, PackageData,
|
|
4
|
+
export type { Adapter, AdapterConfig, Options, BuiltRoutes, ExplorerData, HttpVerb, PackageData, PathInfo, RoutableFile, RoutableFileType, Route, RouteGenerationData } from "./types";
|
package/dist/vite/index.js
CHANGED
|
@@ -344,10 +344,7 @@ function matchRoutableFile(filename) {
|
|
|
344
344
|
function isSpecialType(type) {
|
|
345
345
|
return type === RoutableFileTypes.NotFound || type === RoutableFileTypes.Error;
|
|
346
346
|
}
|
|
347
|
-
async function buildRoutes(
|
|
348
|
-
if (basePath) {
|
|
349
|
-
basePath = basePath.replace(/^\/+|\/+$/g, "");
|
|
350
|
-
}
|
|
347
|
+
async function buildRoutes(sources) {
|
|
351
348
|
const uniqueRoutes = /* @__PURE__ */ new Map();
|
|
352
349
|
const routes = [];
|
|
353
350
|
const special = {};
|
|
@@ -357,23 +354,30 @@ async function buildRoutes(walk, basePath = "") {
|
|
|
357
354
|
const currentMiddleware = /* @__PURE__ */ new Set();
|
|
358
355
|
const root = new VDir();
|
|
359
356
|
const dirStack = [];
|
|
360
|
-
let
|
|
357
|
+
let basePath;
|
|
358
|
+
let importPrefix;
|
|
359
|
+
let activeDirs;
|
|
360
|
+
let isBaseDir;
|
|
361
361
|
let nextFileId = 1;
|
|
362
362
|
let nextRouteIndex = 1;
|
|
363
|
-
|
|
364
|
-
await walk({
|
|
363
|
+
const walkOptions = {
|
|
365
364
|
onEnter({ name }) {
|
|
366
|
-
|
|
365
|
+
const prevDirStackLength = dirStack.length;
|
|
366
|
+
if (isBaseDir) {
|
|
367
367
|
isBaseDir = false;
|
|
368
|
-
|
|
368
|
+
if (!basePath) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
name = basePath;
|
|
372
|
+
} else {
|
|
373
|
+
dirStack.push(name);
|
|
369
374
|
}
|
|
370
|
-
dirStack.push(name);
|
|
371
375
|
const previousDirs = activeDirs;
|
|
372
376
|
const paths = parseFlatRoute(name);
|
|
373
377
|
activeDirs = VDir.addPaths(previousDirs, paths);
|
|
374
378
|
return () => {
|
|
375
379
|
activeDirs = previousDirs;
|
|
376
|
-
dirStack.
|
|
380
|
+
dirStack.length = prevDirStackLength;
|
|
377
381
|
};
|
|
378
382
|
},
|
|
379
383
|
onFile({ name, path: path3 }) {
|
|
@@ -401,14 +405,24 @@ async function buildRoutes(walk, basePath = "") {
|
|
|
401
405
|
type,
|
|
402
406
|
filePath: path3,
|
|
403
407
|
relativePath,
|
|
404
|
-
importPath: `${
|
|
408
|
+
importPath: `${importPrefix}/${relativePath}`,
|
|
405
409
|
verbs: type === RoutableFileTypes.Page ? ["get"] : void 0
|
|
406
410
|
};
|
|
407
411
|
for (const dir of dirs) {
|
|
408
412
|
dir.addFile(file);
|
|
409
413
|
}
|
|
410
414
|
}
|
|
411
|
-
}
|
|
415
|
+
};
|
|
416
|
+
if (!Array.isArray(sources)) {
|
|
417
|
+
sources = [sources];
|
|
418
|
+
}
|
|
419
|
+
for (const source of sources) {
|
|
420
|
+
importPrefix = source.importPrefix ? source.importPrefix.replace(/^\/+|\/+$/g, "") : "";
|
|
421
|
+
basePath = source.basePath || "";
|
|
422
|
+
activeDirs = [root];
|
|
423
|
+
isBaseDir = true;
|
|
424
|
+
await source.walker(walkOptions);
|
|
425
|
+
}
|
|
412
426
|
traverse(root);
|
|
413
427
|
return {
|
|
414
428
|
list: routes,
|
|
@@ -958,12 +972,13 @@ globalThis.__marko_run__ = { match, fetch, invoke };
|
|
|
958
972
|
} else if (pathname.charAt(0) !== '/') {
|
|
959
973
|
pathname = '/' + pathname;
|
|
960
974
|
}`
|
|
961
|
-
).writeBlockStart(`switch (method
|
|
975
|
+
).writeBlockStart(`switch (method) {`);
|
|
962
976
|
for (const verb of httpVerbs) {
|
|
963
977
|
const filteredRoutes = routes.list.filter((route) => hasVerb(route, verb));
|
|
964
978
|
if (filteredRoutes.length) {
|
|
965
979
|
const trie = createRouteTrie(filteredRoutes);
|
|
966
|
-
writer.
|
|
980
|
+
writer.writeLines(`case '${verb.toUpperCase()}':`);
|
|
981
|
+
writer.writeBlockStart(`case '${verb.toLowerCase()}': {`);
|
|
967
982
|
writeRouterVerb(writer, trie, verb);
|
|
968
983
|
writer.writeBlockEnd("}");
|
|
969
984
|
}
|
|
@@ -1115,13 +1130,14 @@ function writeRouterVerb(writer, trie, verb, level = 0, offset = 1) {
|
|
|
1115
1130
|
if (terminal) {
|
|
1116
1131
|
const useSwitch = terminal.length > 1;
|
|
1117
1132
|
if (useSwitch) {
|
|
1118
|
-
writer.writeBlockStart(`switch (${value}
|
|
1133
|
+
writer.writeBlockStart(`switch (${value}) {`);
|
|
1119
1134
|
}
|
|
1120
1135
|
for (const { key, path: path3, route: route2 } of terminal) {
|
|
1136
|
+
const decodedKey = decodeURIComponent(key);
|
|
1121
1137
|
if (useSwitch) {
|
|
1122
|
-
writer.write(`case '${
|
|
1138
|
+
writer.write(`case '${decodedKey}': `, true);
|
|
1123
1139
|
} else {
|
|
1124
|
-
writer.write(`if (${value}
|
|
1140
|
+
writer.write(`if (${value} === '${decodedKey}') `, true);
|
|
1125
1141
|
}
|
|
1126
1142
|
writer.write(
|
|
1127
1143
|
`return ${renderMatch(verb, route2, path3)}; // ${path3.path}
|
|
@@ -1158,7 +1174,7 @@ function writeRouterVerb(writer, trie, verb, level = 0, offset = 1) {
|
|
|
1158
1174
|
if (children) {
|
|
1159
1175
|
const useSwitch = children.length > 1;
|
|
1160
1176
|
if (useSwitch) {
|
|
1161
|
-
writer.writeBlockStart(`switch (${value}
|
|
1177
|
+
writer.writeBlockStart(`switch (${value}) {`);
|
|
1162
1178
|
}
|
|
1163
1179
|
for (const child of children) {
|
|
1164
1180
|
const decodedKey = decodeURIComponent(child.key);
|
|
@@ -1166,7 +1182,7 @@ function writeRouterVerb(writer, trie, verb, level = 0, offset = 1) {
|
|
|
1166
1182
|
writer.writeBlockStart(`case '${decodedKey}': {`);
|
|
1167
1183
|
} else {
|
|
1168
1184
|
writer.writeBlockStart(
|
|
1169
|
-
`if (${value}
|
|
1185
|
+
`if (${value} === '${decodedKey}') {`
|
|
1170
1186
|
);
|
|
1171
1187
|
}
|
|
1172
1188
|
const nextOffset = typeof offset === "string" ? index : offset + child.key.length + 1;
|
|
@@ -1647,6 +1663,8 @@ var setExternalPluginOptions = (viteConfig, value) => setConfig(viteConfig, Plug
|
|
|
1647
1663
|
var getExternalAdapterOptions = (viteConfig) => getConfig(viteConfig, AdapterConfigKey);
|
|
1648
1664
|
|
|
1649
1665
|
// src/vite/plugin.ts
|
|
1666
|
+
import createDebug from "debug";
|
|
1667
|
+
var debug = createDebug("@marko/run");
|
|
1650
1668
|
var __dirname = path2.dirname(fileURLToPath(import.meta.url));
|
|
1651
1669
|
var PLUGIN_NAME_PREFIX = "marko-run-vite";
|
|
1652
1670
|
var POSIX_SEP = "/";
|
|
@@ -1706,10 +1724,10 @@ function markoRun(opts = {}) {
|
|
|
1706
1724
|
virtualFiles.clear();
|
|
1707
1725
|
isRendered = false;
|
|
1708
1726
|
const buildStartTime = performance.now();
|
|
1709
|
-
routes = await buildRoutes(
|
|
1710
|
-
createFSWalker(resolvedRoutesDir),
|
|
1711
|
-
routesDir
|
|
1712
|
-
);
|
|
1727
|
+
routes = await buildRoutes({
|
|
1728
|
+
walker: createFSWalker(resolvedRoutesDir),
|
|
1729
|
+
importPrefix: routesDir
|
|
1730
|
+
});
|
|
1713
1731
|
times.routesBuild = performance.now() - buildStartTime;
|
|
1714
1732
|
if (!routes.list.length) {
|
|
1715
1733
|
throw new Error("No routes generated");
|
|
@@ -1755,6 +1773,12 @@ function markoRun(opts = {}) {
|
|
|
1755
1773
|
times.routesRender = performance.now() - renderStartTime;
|
|
1756
1774
|
if (render) {
|
|
1757
1775
|
await writeTypesFile(routes);
|
|
1776
|
+
if (adapter == null ? void 0 : adapter.routesGenerated) {
|
|
1777
|
+
await adapter.routesGenerated(routes, new Map(virtualFiles.entries()), {
|
|
1778
|
+
buildTime: times.routesBuild,
|
|
1779
|
+
renderTime: times.routesRender
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1758
1782
|
if (!isBuild) {
|
|
1759
1783
|
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
|
|
1760
1784
|
}
|
|
@@ -2052,7 +2076,7 @@ function markoRun(opts = {}) {
|
|
|
2052
2076
|
}
|
|
2053
2077
|
await store.set(routeDataFilename, JSON.stringify(routeData));
|
|
2054
2078
|
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
|
|
2055
|
-
} else {
|
|
2079
|
+
} else if (process.env.MR_EXPLORER !== "true") {
|
|
2056
2080
|
logRoutesTable(routes, bundle, options);
|
|
2057
2081
|
}
|
|
2058
2082
|
},
|
|
@@ -2159,19 +2183,19 @@ async function resolveAdapter(root, options, log) {
|
|
|
2159
2183
|
if (name.startsWith("@marko/run-adapter") || name.indexOf("marko-run-adapter") !== -1) {
|
|
2160
2184
|
try {
|
|
2161
2185
|
const module2 = await import(name);
|
|
2162
|
-
log &&
|
|
2186
|
+
log && debug(
|
|
2163
2187
|
`Using adapter ${name} listed in your package.json dependecies`
|
|
2164
2188
|
);
|
|
2165
2189
|
return module2.default();
|
|
2166
2190
|
} catch (err) {
|
|
2167
|
-
log &&
|
|
2191
|
+
log && debug(`Attempt to use package '${name}' failed %O`, err);
|
|
2168
2192
|
}
|
|
2169
2193
|
}
|
|
2170
2194
|
}
|
|
2171
2195
|
}
|
|
2172
2196
|
const defaultAdapter = "@marko/run/adapter";
|
|
2173
2197
|
const module = await import(defaultAdapter);
|
|
2174
|
-
log &&
|
|
2198
|
+
log && debug("Using default adapter");
|
|
2175
2199
|
return module.default();
|
|
2176
2200
|
}
|
|
2177
2201
|
var markoEntryFileRegex = /__marko-run__([^.]+)\.(.+)\.marko\.([^.]+)$/;
|
|
@@ -3,4 +3,9 @@ import type { Walker } from "./walk";
|
|
|
3
3
|
export declare function isRoutableFile(filename: string): boolean;
|
|
4
4
|
export declare function matchRoutableFile(filename: string): RoutableFileType | null;
|
|
5
5
|
export declare function isSpecialType(type: RoutableFileType): type is keyof SpecialRoutes;
|
|
6
|
-
export
|
|
6
|
+
export interface RouteSource {
|
|
7
|
+
walker: Walker;
|
|
8
|
+
importPrefix?: string;
|
|
9
|
+
basePath?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildRoutes(sources: RouteSource | RouteSource[]): Promise<BuiltRoutes>;
|
package/dist/vite/types.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export interface Adapter {
|
|
|
31
31
|
startPreview?(entry: string | undefined, options: StartPreviewOptions): Promise<SpawnedServer> | SpawnedServer;
|
|
32
32
|
buildEnd?(config: ResolvedConfig, routes: Route[], builtEntries: string[], sourceEntries: string[]): Promise<void> | void;
|
|
33
33
|
typeInfo?(writer: (data: string) => void): Promise<string> | string;
|
|
34
|
+
routesGenerated?(routes: BuiltRoutes, virtualFiles: Map<string, string>, data: RouteGenerationData): Promise<void> | void;
|
|
34
35
|
}
|
|
35
36
|
export interface RouterOptions {
|
|
36
37
|
trailingSlashes: "Ignore" | "RedirectWithout" | "RedirectWith" | "RewriteWithout" | "RewriteWith";
|
|
@@ -83,3 +84,12 @@ export interface PackageData {
|
|
|
83
84
|
dependencies?: Record<string, string>;
|
|
84
85
|
devDependencies?: Record<string, string>;
|
|
85
86
|
}
|
|
87
|
+
export interface RouteGenerationData {
|
|
88
|
+
buildTime: number;
|
|
89
|
+
renderTime: number;
|
|
90
|
+
}
|
|
91
|
+
export interface ExplorerData {
|
|
92
|
+
meta: RouteGenerationData;
|
|
93
|
+
routes: Record<string, Route>;
|
|
94
|
+
files: Record<string, string>;
|
|
95
|
+
}
|
|
@@ -11,7 +11,7 @@ export interface SpawnedServer {
|
|
|
11
11
|
export declare function parseEnv(envFile: string): Promise<import("dotenv").DotenvParseOutput | undefined>;
|
|
12
12
|
export declare function loadEnv(envFile: string): void;
|
|
13
13
|
export declare function spawnServer(cmd: string, args?: string[], port?: number, env?: string | Record<string, string>, cwd?: string, wait?: number, stdio?: StdioOptions): Promise<SpawnedServer>;
|
|
14
|
-
export declare function spawnServerWorker(module: string, args?: string[], port?: number, env?: string | Record<string, string
|
|
14
|
+
export declare function spawnServerWorker(module: string, args?: string[], port?: number, env?: string | Record<string, string>, wait?: boolean): Promise<Worker>;
|
|
15
15
|
export declare function waitForError(proc: ChildProcess, port: number): Promise<void>;
|
|
16
16
|
export declare function waitForServer(port: number, wait?: number): Promise<Socket>;
|
|
17
17
|
export declare function waitForWorker(worker: Worker, port: number): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/run",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "The Marko application framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/marko-js/run/tree/main/packages/run",
|
|
@@ -102,7 +102,6 @@
|
|
|
102
102
|
"esbuild": "^0.19.5",
|
|
103
103
|
"express": "^4.18.2",
|
|
104
104
|
"jsdom": "^21.1.1",
|
|
105
|
-
"marko": "^5.31.12",
|
|
106
105
|
"mocha": "^10.2.0",
|
|
107
106
|
"mocha-snap": "^4.3.0",
|
|
108
107
|
"playwright": "^1.39.0",
|
|
@@ -115,15 +114,19 @@
|
|
|
115
114
|
"typescript": "^4.7.4"
|
|
116
115
|
},
|
|
117
116
|
"dependencies": {
|
|
117
|
+
"@marko/compiler": "^5.33.3",
|
|
118
|
+
"@marko/run-explorer": "^0.1.0",
|
|
118
119
|
"@marko/vite": "^3.1.4",
|
|
119
120
|
"browserslist": "^4.22.1",
|
|
120
121
|
"cli-table3": "^0.6.3",
|
|
121
122
|
"compression": "^1.7.4",
|
|
123
|
+
"debug": "^4.3.4",
|
|
122
124
|
"dotenv": "^16.0.3",
|
|
123
125
|
"esbuild-plugin-browserslist": "^0.9.1",
|
|
124
126
|
"glob": "^8.1.0",
|
|
125
127
|
"human-format": "^1.0.2",
|
|
126
128
|
"kleur": "^4.1.5",
|
|
129
|
+
"marko": "^5",
|
|
127
130
|
"parse-node-args": "^1.1.2",
|
|
128
131
|
"sade": "^1.8.1",
|
|
129
132
|
"serve-static": "^1.15.0",
|
package/dist/adapter/runtime.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/adapter/runtime.ts
|
|
17
|
-
var runtime_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(runtime_exports);
|
|
19
|
-
|
|
20
|
-
// scripts/importMetaURL.js
|
|
21
|
-
var import_url = require("url");
|
|
22
|
-
var __importMetaURL = (0, import_url.pathToFileURL)(__filename);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/adapter/runtime.js
DELETED
|
File without changes
|