@marko/run 0.2.3 → 0.2.5
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 +9 -3
- package/dist/adapter/index.js +9 -3
- package/dist/cli/index.mjs +1878 -37
- package/dist/vite/index.cjs +31 -25
- package/dist/vite/index.js +31 -25
- package/dist/vite/plugin.d.ts +3 -2
- package/dist/vite/types.d.ts +2 -0
- package/dist/vite/utils/log.d.ts +2 -2
- package/dist/vite/utils/server.d.ts +1 -1
- package/package.json +1 -1
package/dist/vite/index.cjs
CHANGED
|
@@ -1494,7 +1494,10 @@ var HttpVerbOrder = {
|
|
|
1494
1494
|
put: 2,
|
|
1495
1495
|
delete: 3
|
|
1496
1496
|
};
|
|
1497
|
-
function logRoutesTable(routes, bundle) {
|
|
1497
|
+
function logRoutesTable(routes, bundle, options) {
|
|
1498
|
+
function getRouteChunkName(route) {
|
|
1499
|
+
return options.sanitizeFileName(`${route.entryName}.marko`);
|
|
1500
|
+
}
|
|
1498
1501
|
const hasMiddleware = routes.list.some((route) => route.middleware.length);
|
|
1499
1502
|
const hasMeta = routes.list.some((route) => route.meta);
|
|
1500
1503
|
const headings = ["Method", "Path", "Entry"];
|
|
@@ -1529,7 +1532,7 @@ function logRoutesTable(routes, bundle) {
|
|
|
1529
1532
|
}
|
|
1530
1533
|
if (verb === "get" && route.page) {
|
|
1531
1534
|
entryType.push(import_kleur.default.yellow("page"));
|
|
1532
|
-
size = prettySize(computeRouteSize(route, bundle));
|
|
1535
|
+
size = prettySize(computeRouteSize(getRouteChunkName(route), bundle));
|
|
1533
1536
|
}
|
|
1534
1537
|
const row = [import_kleur.default.bold(HttpVerbColors[verb](verb.toUpperCase()))];
|
|
1535
1538
|
if (verbs.length === 1 || firstRow) {
|
|
@@ -1548,18 +1551,15 @@ function logRoutesTable(routes, bundle) {
|
|
|
1548
1551
|
const row = [import_kleur.default.bold(import_kleur.default.white("*")), key, import_kleur.default.yellow("page")];
|
|
1549
1552
|
hasMiddleware && row.push("");
|
|
1550
1553
|
hasMeta && row.push("");
|
|
1551
|
-
row.push(prettySize(computeRouteSize(route, bundle)));
|
|
1554
|
+
row.push(prettySize(computeRouteSize(getRouteChunkName(route), bundle)));
|
|
1552
1555
|
table.push(row);
|
|
1553
1556
|
}
|
|
1554
1557
|
console.log(table.toString());
|
|
1555
1558
|
}
|
|
1556
|
-
function computeRouteSize(
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
if (chunk.type === "chunk" && chunk.isEntry && chunk.name === entryName) {
|
|
1561
|
-
return computeChunkSize(chunk, bundle);
|
|
1562
|
-
}
|
|
1559
|
+
function computeRouteSize(entryName, bundle) {
|
|
1560
|
+
for (const chunk of Object.values(bundle)) {
|
|
1561
|
+
if (chunk.type === "chunk" && chunk.isEntry && chunk.name === entryName) {
|
|
1562
|
+
return computeChunkSize(chunk, bundle);
|
|
1563
1563
|
}
|
|
1564
1564
|
}
|
|
1565
1565
|
return [0, 0];
|
|
@@ -1600,7 +1600,7 @@ function prettySize([bytes, compBytes]) {
|
|
|
1600
1600
|
else if (compBytes < 50 * 1e3)
|
|
1601
1601
|
str += import_kleur.default.yellow(compSize);
|
|
1602
1602
|
else
|
|
1603
|
-
import_kleur.default.bold(import_kleur.default.red(compSize));
|
|
1603
|
+
str += import_kleur.default.bold(import_kleur.default.red(compSize));
|
|
1604
1604
|
return str;
|
|
1605
1605
|
}
|
|
1606
1606
|
function prettyPath(path3) {
|
|
@@ -1624,6 +1624,7 @@ var getExternalAdapterOptions = (viteConfig) => getConfig(viteConfig, AdapterCon
|
|
|
1624
1624
|
// src/vite/plugin.ts
|
|
1625
1625
|
var import_url2 = require("url");
|
|
1626
1626
|
var __dirname = import_path2.default.dirname((0, import_url2.fileURLToPath)(__importMetaURL));
|
|
1627
|
+
var PLUGIN_NAME_PREFIX = "marko-run-vite";
|
|
1627
1628
|
var POSIX_SEP = "/";
|
|
1628
1629
|
var WINDOWS_SEP = "\\";
|
|
1629
1630
|
var normalizePath = import_path2.default.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
|
|
@@ -1726,10 +1727,10 @@ function markoRun(opts = {}) {
|
|
|
1726
1727
|
});
|
|
1727
1728
|
return [
|
|
1728
1729
|
{
|
|
1729
|
-
name:
|
|
1730
|
+
name: `${PLUGIN_NAME_PREFIX}:pre`,
|
|
1730
1731
|
enforce: "pre",
|
|
1731
1732
|
async config(config2, env) {
|
|
1732
|
-
var _a, _b, _c, _d, _e, _f
|
|
1733
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1733
1734
|
const externalPluginOptions = getExternalPluginOptions(config2);
|
|
1734
1735
|
if (externalPluginOptions) {
|
|
1735
1736
|
opts = (0, import_vite.mergeConfig)(opts, externalPluginOptions);
|
|
@@ -1745,7 +1746,8 @@ function markoRun(opts = {}) {
|
|
|
1745
1746
|
if (adapter) {
|
|
1746
1747
|
(_b = adapter.configure) == null ? void 0 : _b.call(adapter, {
|
|
1747
1748
|
...getExternalAdapterOptions(config2),
|
|
1748
|
-
root
|
|
1749
|
+
root,
|
|
1750
|
+
isBuild
|
|
1749
1751
|
});
|
|
1750
1752
|
const adapterOptions = await ((_c = adapter.pluginOptions) == null ? void 0 : _c.call(adapter, opts));
|
|
1751
1753
|
if (adapterOptions) {
|
|
@@ -1834,9 +1836,11 @@ function markoRun(opts = {}) {
|
|
|
1834
1836
|
]
|
|
1835
1837
|
} : void 0
|
|
1836
1838
|
};
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1839
|
+
if (adapter == null ? void 0 : adapter.viteConfig) {
|
|
1840
|
+
const adapterConfig = await adapter.viteConfig(config2);
|
|
1841
|
+
if (adapterConfig) {
|
|
1842
|
+
pluginConfig = (0, import_vite.mergeConfig)(pluginConfig, adapterConfig);
|
|
1843
|
+
}
|
|
1840
1844
|
}
|
|
1841
1845
|
return setExternalPluginOptions(pluginConfig, opts);
|
|
1842
1846
|
},
|
|
@@ -1946,7 +1950,7 @@ function markoRun(opts = {}) {
|
|
|
1946
1950
|
},
|
|
1947
1951
|
...(0, import_vite2.default)(markoVitePluginOptions),
|
|
1948
1952
|
{
|
|
1949
|
-
name:
|
|
1953
|
+
name: `${PLUGIN_NAME_PREFIX}:post`,
|
|
1950
1954
|
enforce: "post",
|
|
1951
1955
|
generateBundle(options, bundle) {
|
|
1952
1956
|
if (options.sourcemap && options.sourcemap !== "inline") {
|
|
@@ -1982,7 +1986,7 @@ function markoRun(opts = {}) {
|
|
|
1982
1986
|
await store.set(routeDataFilename, JSON.stringify(routeData));
|
|
1983
1987
|
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
|
|
1984
1988
|
} else if (isBuild) {
|
|
1985
|
-
logRoutesTable(routes, bundle);
|
|
1989
|
+
logRoutesTable(routes, bundle, options);
|
|
1986
1990
|
}
|
|
1987
1991
|
},
|
|
1988
1992
|
async closeBundle() {
|
|
@@ -2075,9 +2079,8 @@ async function getPackageData(dir) {
|
|
|
2075
2079
|
return null;
|
|
2076
2080
|
}
|
|
2077
2081
|
async function resolveAdapter(root, options, log) {
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
return adapter;
|
|
2082
|
+
if (options && options.adapter !== void 0) {
|
|
2083
|
+
return options.adapter;
|
|
2081
2084
|
}
|
|
2082
2085
|
const pkg = await getPackageData(root);
|
|
2083
2086
|
if (pkg) {
|
|
@@ -2193,11 +2196,14 @@ async function getConnection(port) {
|
|
|
2193
2196
|
async function isPortInUse(port) {
|
|
2194
2197
|
return Boolean(await getConnection(port));
|
|
2195
2198
|
}
|
|
2196
|
-
async function getAvailablePort() {
|
|
2199
|
+
async function getAvailablePort(port) {
|
|
2200
|
+
if (port && !await isPortInUse(port)) {
|
|
2201
|
+
return port;
|
|
2202
|
+
}
|
|
2197
2203
|
return new Promise((resolve) => {
|
|
2198
2204
|
const server = import_net.default.createServer().listen(0, () => {
|
|
2199
|
-
const { port } = server.address();
|
|
2200
|
-
server.close(() => resolve(
|
|
2205
|
+
const { port: port2 } = server.address();
|
|
2206
|
+
server.close(() => resolve(port2));
|
|
2201
2207
|
});
|
|
2202
2208
|
});
|
|
2203
2209
|
}
|
package/dist/vite/index.js
CHANGED
|
@@ -1454,7 +1454,10 @@ var HttpVerbOrder = {
|
|
|
1454
1454
|
put: 2,
|
|
1455
1455
|
delete: 3
|
|
1456
1456
|
};
|
|
1457
|
-
function logRoutesTable(routes, bundle) {
|
|
1457
|
+
function logRoutesTable(routes, bundle, options) {
|
|
1458
|
+
function getRouteChunkName(route) {
|
|
1459
|
+
return options.sanitizeFileName(`${route.entryName}.marko`);
|
|
1460
|
+
}
|
|
1458
1461
|
const hasMiddleware = routes.list.some((route) => route.middleware.length);
|
|
1459
1462
|
const hasMeta = routes.list.some((route) => route.meta);
|
|
1460
1463
|
const headings = ["Method", "Path", "Entry"];
|
|
@@ -1489,7 +1492,7 @@ function logRoutesTable(routes, bundle) {
|
|
|
1489
1492
|
}
|
|
1490
1493
|
if (verb === "get" && route.page) {
|
|
1491
1494
|
entryType.push(kleur.yellow("page"));
|
|
1492
|
-
size = prettySize(computeRouteSize(route, bundle));
|
|
1495
|
+
size = prettySize(computeRouteSize(getRouteChunkName(route), bundle));
|
|
1493
1496
|
}
|
|
1494
1497
|
const row = [kleur.bold(HttpVerbColors[verb](verb.toUpperCase()))];
|
|
1495
1498
|
if (verbs.length === 1 || firstRow) {
|
|
@@ -1508,18 +1511,15 @@ function logRoutesTable(routes, bundle) {
|
|
|
1508
1511
|
const row = [kleur.bold(kleur.white("*")), key, kleur.yellow("page")];
|
|
1509
1512
|
hasMiddleware && row.push("");
|
|
1510
1513
|
hasMeta && row.push("");
|
|
1511
|
-
row.push(prettySize(computeRouteSize(route, bundle)));
|
|
1514
|
+
row.push(prettySize(computeRouteSize(getRouteChunkName(route), bundle)));
|
|
1512
1515
|
table.push(row);
|
|
1513
1516
|
}
|
|
1514
1517
|
console.log(table.toString());
|
|
1515
1518
|
}
|
|
1516
|
-
function computeRouteSize(
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
if (chunk.type === "chunk" && chunk.isEntry && chunk.name === entryName) {
|
|
1521
|
-
return computeChunkSize(chunk, bundle);
|
|
1522
|
-
}
|
|
1519
|
+
function computeRouteSize(entryName, bundle) {
|
|
1520
|
+
for (const chunk of Object.values(bundle)) {
|
|
1521
|
+
if (chunk.type === "chunk" && chunk.isEntry && chunk.name === entryName) {
|
|
1522
|
+
return computeChunkSize(chunk, bundle);
|
|
1523
1523
|
}
|
|
1524
1524
|
}
|
|
1525
1525
|
return [0, 0];
|
|
@@ -1560,7 +1560,7 @@ function prettySize([bytes, compBytes]) {
|
|
|
1560
1560
|
else if (compBytes < 50 * 1e3)
|
|
1561
1561
|
str += kleur.yellow(compSize);
|
|
1562
1562
|
else
|
|
1563
|
-
kleur.bold(kleur.red(compSize));
|
|
1563
|
+
str += kleur.bold(kleur.red(compSize));
|
|
1564
1564
|
return str;
|
|
1565
1565
|
}
|
|
1566
1566
|
function prettyPath(path3) {
|
|
@@ -1584,6 +1584,7 @@ var getExternalAdapterOptions = (viteConfig) => getConfig(viteConfig, AdapterCon
|
|
|
1584
1584
|
// src/vite/plugin.ts
|
|
1585
1585
|
import { fileURLToPath } from "url";
|
|
1586
1586
|
var __dirname = path2.dirname(fileURLToPath(import.meta.url));
|
|
1587
|
+
var PLUGIN_NAME_PREFIX = "marko-run-vite";
|
|
1587
1588
|
var POSIX_SEP = "/";
|
|
1588
1589
|
var WINDOWS_SEP = "\\";
|
|
1589
1590
|
var normalizePath = path2.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_SEP) : (id) => id;
|
|
@@ -1686,10 +1687,10 @@ function markoRun(opts = {}) {
|
|
|
1686
1687
|
});
|
|
1687
1688
|
return [
|
|
1688
1689
|
{
|
|
1689
|
-
name:
|
|
1690
|
+
name: `${PLUGIN_NAME_PREFIX}:pre`,
|
|
1690
1691
|
enforce: "pre",
|
|
1691
1692
|
async config(config2, env) {
|
|
1692
|
-
var _a, _b, _c, _d, _e, _f
|
|
1693
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1693
1694
|
const externalPluginOptions = getExternalPluginOptions(config2);
|
|
1694
1695
|
if (externalPluginOptions) {
|
|
1695
1696
|
opts = mergeConfig(opts, externalPluginOptions);
|
|
@@ -1705,7 +1706,8 @@ function markoRun(opts = {}) {
|
|
|
1705
1706
|
if (adapter) {
|
|
1706
1707
|
(_b = adapter.configure) == null ? void 0 : _b.call(adapter, {
|
|
1707
1708
|
...getExternalAdapterOptions(config2),
|
|
1708
|
-
root
|
|
1709
|
+
root,
|
|
1710
|
+
isBuild
|
|
1709
1711
|
});
|
|
1710
1712
|
const adapterOptions = await ((_c = adapter.pluginOptions) == null ? void 0 : _c.call(adapter, opts));
|
|
1711
1713
|
if (adapterOptions) {
|
|
@@ -1794,9 +1796,11 @@ function markoRun(opts = {}) {
|
|
|
1794
1796
|
]
|
|
1795
1797
|
} : void 0
|
|
1796
1798
|
};
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1799
|
+
if (adapter == null ? void 0 : adapter.viteConfig) {
|
|
1800
|
+
const adapterConfig = await adapter.viteConfig(config2);
|
|
1801
|
+
if (adapterConfig) {
|
|
1802
|
+
pluginConfig = mergeConfig(pluginConfig, adapterConfig);
|
|
1803
|
+
}
|
|
1800
1804
|
}
|
|
1801
1805
|
return setExternalPluginOptions(pluginConfig, opts);
|
|
1802
1806
|
},
|
|
@@ -1906,7 +1910,7 @@ function markoRun(opts = {}) {
|
|
|
1906
1910
|
},
|
|
1907
1911
|
...markoVitePlugin(markoVitePluginOptions),
|
|
1908
1912
|
{
|
|
1909
|
-
name:
|
|
1913
|
+
name: `${PLUGIN_NAME_PREFIX}:post`,
|
|
1910
1914
|
enforce: "post",
|
|
1911
1915
|
generateBundle(options, bundle) {
|
|
1912
1916
|
if (options.sourcemap && options.sourcemap !== "inline") {
|
|
@@ -1942,7 +1946,7 @@ function markoRun(opts = {}) {
|
|
|
1942
1946
|
await store.set(routeDataFilename, JSON.stringify(routeData));
|
|
1943
1947
|
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
|
|
1944
1948
|
} else if (isBuild) {
|
|
1945
|
-
logRoutesTable(routes, bundle);
|
|
1949
|
+
logRoutesTable(routes, bundle, options);
|
|
1946
1950
|
}
|
|
1947
1951
|
},
|
|
1948
1952
|
async closeBundle() {
|
|
@@ -2035,9 +2039,8 @@ async function getPackageData(dir) {
|
|
|
2035
2039
|
return null;
|
|
2036
2040
|
}
|
|
2037
2041
|
async function resolveAdapter(root, options, log) {
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
return adapter;
|
|
2042
|
+
if (options && options.adapter !== void 0) {
|
|
2043
|
+
return options.adapter;
|
|
2041
2044
|
}
|
|
2042
2045
|
const pkg = await getPackageData(root);
|
|
2043
2046
|
if (pkg) {
|
|
@@ -2153,11 +2156,14 @@ async function getConnection(port) {
|
|
|
2153
2156
|
async function isPortInUse(port) {
|
|
2154
2157
|
return Boolean(await getConnection(port));
|
|
2155
2158
|
}
|
|
2156
|
-
async function getAvailablePort() {
|
|
2159
|
+
async function getAvailablePort(port) {
|
|
2160
|
+
if (port && !await isPortInUse(port)) {
|
|
2161
|
+
return port;
|
|
2162
|
+
}
|
|
2157
2163
|
return new Promise((resolve) => {
|
|
2158
2164
|
const server = net.createServer().listen(0, () => {
|
|
2159
|
-
const { port } = server.address();
|
|
2160
|
-
server.close(() => resolve(
|
|
2165
|
+
const { port: port2 } = server.address();
|
|
2166
|
+
server.close(() => resolve(port2));
|
|
2161
2167
|
});
|
|
2162
2168
|
});
|
|
2163
2169
|
}
|
package/dist/vite/plugin.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Plugin } from "vite";
|
|
1
|
+
import type { Plugin, ResolvedConfig } from "vite";
|
|
2
2
|
import type { Options, Adapter, PackageData } from "./types";
|
|
3
3
|
export default function markoRun(opts?: Options): Plugin[];
|
|
4
4
|
export declare function getPackageData(dir: string): Promise<PackageData | null>;
|
|
5
|
-
export declare function resolveAdapter(root: string, options
|
|
5
|
+
export declare function resolveAdapter(root: string, options?: Options, log?: boolean): Promise<Adapter | null>;
|
|
6
|
+
export declare function isPluginIncluded(config: ResolvedConfig): boolean;
|
package/dist/vite/types.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { SpawnedServer } from "./utils/server";
|
|
|
5
5
|
export type { RoutableFileType, HttpVerb };
|
|
6
6
|
export type StartServer = (port?: number) => Promise<void>;
|
|
7
7
|
export interface AdapterConfig {
|
|
8
|
+
root: string;
|
|
9
|
+
isBuild: boolean;
|
|
8
10
|
[name: PropertyKey]: any;
|
|
9
11
|
}
|
|
10
12
|
export interface StartOptions {
|
package/dist/vite/utils/log.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { OutputBundle } from "rollup";
|
|
1
|
+
import type { OutputBundle, NormalizedOutputOptions } from "rollup";
|
|
2
2
|
import type { BuiltRoutes } from "../types";
|
|
3
|
-
export declare function logRoutesTable(routes: BuiltRoutes, bundle: OutputBundle): void;
|
|
3
|
+
export declare function logRoutesTable(routes: BuiltRoutes, bundle: OutputBundle, options: NormalizedOutputOptions): void;
|
|
@@ -17,4 +17,4 @@ export declare function waitForServer(port: number, wait?: number): Promise<Sock
|
|
|
17
17
|
export declare function waitForWorker(worker: Worker, port: number): Promise<void>;
|
|
18
18
|
export declare function getConnection(port: number): Promise<Socket | null>;
|
|
19
19
|
export declare function isPortInUse(port: number): Promise<boolean>;
|
|
20
|
-
export declare function getAvailablePort(): Promise<number>;
|
|
20
|
+
export declare function getAvailablePort(port?: number): Promise<number>;
|