astro 1.0.0-beta.8 → 1.0.0-beta.9
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/cli/index.js +1 -1
- package/dist/core/build/generate.js +2 -2
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/path.js +9 -5
- package/dist/core/util.js +2 -2
- package/dist/runtime/server/index.js +16 -4
- package/dist/types/core/path.d.ts +3 -2
- package/dist/types/runtime/server/index.d.ts +1 -0
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -37,7 +37,7 @@ function printAstroHelp() {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
async function printVersion() {
|
|
40
|
-
const version = "1.0.0-beta.
|
|
40
|
+
const version = "1.0.0-beta.9";
|
|
41
41
|
console.log();
|
|
42
42
|
console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${version}`)}`);
|
|
43
43
|
}
|
|
@@ -3,7 +3,7 @@ import { bgGreen, black, cyan, dim, green, magenta } from "kleur/colors";
|
|
|
3
3
|
import npath from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { debug, info } from "../logger/core.js";
|
|
6
|
-
import { prependForwardSlash } from "../../core/path.js";
|
|
6
|
+
import { prependForwardSlash, removeLeadingForwardSlash } from "../../core/path.js";
|
|
7
7
|
import { BEFORE_HYDRATION_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
|
|
8
8
|
import { call as callEndpoint } from "../endpoint/index.js";
|
|
9
9
|
import { render } from "../render/core.js";
|
|
@@ -116,7 +116,7 @@ async function generatePath(pathname, opts, gopts) {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
const ssr = isBuildingToSSR(opts.astroConfig);
|
|
119
|
-
const url = new URL(
|
|
119
|
+
const url = new URL(opts.astroConfig.base + removeLeadingForwardSlash(pathname), origin);
|
|
120
120
|
const options = {
|
|
121
121
|
legacyBuild: false,
|
|
122
122
|
links,
|
package/dist/core/dev/index.js
CHANGED
|
@@ -36,7 +36,7 @@ async function dev(config, options = { logging: nodeLogOptions }) {
|
|
|
36
36
|
site,
|
|
37
37
|
https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
|
|
38
38
|
}));
|
|
39
|
-
const currentVersion = "1.0.0-beta.
|
|
39
|
+
const currentVersion = "1.0.0-beta.9";
|
|
40
40
|
if (currentVersion.includes("-")) {
|
|
41
41
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
42
42
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -45,7 +45,7 @@ function devStart({
|
|
|
45
45
|
https,
|
|
46
46
|
site
|
|
47
47
|
}) {
|
|
48
|
-
const version = "1.0.0-beta.
|
|
48
|
+
const version = "1.0.0-beta.9";
|
|
49
49
|
const rootPath = site ? site.pathname : "/";
|
|
50
50
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
51
51
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -170,7 +170,7 @@ function printHelp({
|
|
|
170
170
|
};
|
|
171
171
|
let message = [];
|
|
172
172
|
if (headline) {
|
|
173
|
-
message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.
|
|
173
|
+
message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.9"}`)} ${headline}`);
|
|
174
174
|
}
|
|
175
175
|
if (usage) {
|
|
176
176
|
message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
|
package/dist/core/path.js
CHANGED
|
@@ -4,9 +4,15 @@ function appendForwardSlash(path) {
|
|
|
4
4
|
function prependForwardSlash(path) {
|
|
5
5
|
return path[0] === "/" ? path : "/" + path;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function removeTrailingForwardSlash(path) {
|
|
8
8
|
return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
|
|
9
9
|
}
|
|
10
|
+
function removeLeadingForwardSlash(path) {
|
|
11
|
+
return path.startsWith("/") ? path.substring(1) : path;
|
|
12
|
+
}
|
|
13
|
+
function trimSlashes(path) {
|
|
14
|
+
return path.replace(/^\/|\/$/g, "");
|
|
15
|
+
}
|
|
10
16
|
function startsWithForwardSlash(path) {
|
|
11
17
|
return path[0] === "/";
|
|
12
18
|
}
|
|
@@ -30,15 +36,13 @@ function prependDotSlash(path) {
|
|
|
30
36
|
}
|
|
31
37
|
return "./" + path;
|
|
32
38
|
}
|
|
33
|
-
function trimSlashes(path) {
|
|
34
|
-
return path.replace(/^\/|\/$/g, "");
|
|
35
|
-
}
|
|
36
39
|
export {
|
|
37
40
|
appendForwardSlash,
|
|
38
41
|
isRelativePath,
|
|
39
42
|
prependDotSlash,
|
|
40
43
|
prependForwardSlash,
|
|
41
|
-
|
|
44
|
+
removeLeadingForwardSlash,
|
|
45
|
+
removeTrailingForwardSlash,
|
|
42
46
|
startsWithDotDotSlash,
|
|
43
47
|
startsWithDotSlash,
|
|
44
48
|
startsWithForwardSlash,
|
package/dist/core/util.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from "path";
|
|
|
4
4
|
import resolve from "resolve";
|
|
5
5
|
import slash from "slash";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
7
|
-
import {
|
|
7
|
+
import { removeTrailingForwardSlash } from "./path.js";
|
|
8
8
|
function isObject(value) {
|
|
9
9
|
return typeof value === "object" && value != null;
|
|
10
10
|
}
|
|
@@ -24,7 +24,7 @@ function getOutputFilename(astroConfig, name) {
|
|
|
24
24
|
if (astroConfig.build.format === "directory" && !STATUS_CODE_REGEXP.test(name)) {
|
|
25
25
|
return path.posix.join(name, "index.html");
|
|
26
26
|
}
|
|
27
|
-
return `${
|
|
27
|
+
return `${removeTrailingForwardSlash(name || "index")}.html`;
|
|
28
28
|
}
|
|
29
29
|
function parseNpmName(spec) {
|
|
30
30
|
if (!spec || spec[0] === "." || spec[0] === "/")
|
|
@@ -192,7 +192,7 @@ but ${plural ? "none were" : "it was not"} able to server-side render ${metadata
|
|
|
192
192
|
Did you mean to enable ${formatList(probableRendererNames.map((r) => "`" + r + "`"))}?`);
|
|
193
193
|
} else if (matchingRenderers.length === 1) {
|
|
194
194
|
renderer = matchingRenderers[0];
|
|
195
|
-
({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children));
|
|
195
|
+
({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children, metadata));
|
|
196
196
|
} else {
|
|
197
197
|
throw new Error(`Unable to render ${metadata.displayName}!
|
|
198
198
|
|
|
@@ -211,7 +211,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
|
|
|
211
211
|
if (metadata.hydrate === "only") {
|
|
212
212
|
html = await renderSlot(result, slots == null ? void 0 : slots.fallback);
|
|
213
213
|
} else {
|
|
214
|
-
({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children));
|
|
214
|
+
({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children, metadata));
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
if (!html && typeof Component === "string") {
|
|
@@ -310,10 +310,22 @@ function defineScriptVars(vars) {
|
|
|
310
310
|
}
|
|
311
311
|
return markHTMLString(output);
|
|
312
312
|
}
|
|
313
|
+
function getHandlerFromModule(mod, method) {
|
|
314
|
+
if (mod[method]) {
|
|
315
|
+
return mod[method];
|
|
316
|
+
}
|
|
317
|
+
if (method === "delete" && mod["del"]) {
|
|
318
|
+
return mod["del"];
|
|
319
|
+
}
|
|
320
|
+
if (mod["all"]) {
|
|
321
|
+
return mod["all"];
|
|
322
|
+
}
|
|
323
|
+
return void 0;
|
|
324
|
+
}
|
|
313
325
|
async function renderEndpoint(mod, request, params) {
|
|
314
326
|
var _a;
|
|
315
|
-
const chosenMethod = (
|
|
316
|
-
const handler = mod
|
|
327
|
+
const chosenMethod = (_a = request.method) == null ? void 0 : _a.toLowerCase();
|
|
328
|
+
const handler = getHandlerFromModule(mod, chosenMethod);
|
|
317
329
|
if (!handler || typeof handler !== "function") {
|
|
318
330
|
throw new Error(`Endpoint handler not found! Expected an exported function for "${chosenMethod}"`);
|
|
319
331
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export declare function appendForwardSlash(path: string): string;
|
|
2
2
|
export declare function prependForwardSlash(path: string): string;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function removeTrailingForwardSlash(path: string): string;
|
|
4
|
+
export declare function removeLeadingForwardSlash(path: string): string;
|
|
5
|
+
export declare function trimSlashes(path: string): string;
|
|
4
6
|
export declare function startsWithForwardSlash(path: string): boolean;
|
|
5
7
|
export declare function startsWithDotDotSlash(path: string): boolean;
|
|
6
8
|
export declare function startsWithDotSlash(path: string): boolean;
|
|
7
9
|
export declare function isRelativePath(path: string): boolean;
|
|
8
10
|
export declare function prependDotSlash(path: string): string;
|
|
9
|
-
export declare function trimSlashes(path: string): string;
|
|
@@ -23,6 +23,7 @@ export declare function addAttribute(value: any, key: string, shouldEscape?: boo
|
|
|
23
23
|
export declare function spreadAttributes(values: Record<any, any>, shouldEscape?: boolean): any;
|
|
24
24
|
export declare function defineStyleVars(selector: string, vars: Record<any, any>): any;
|
|
25
25
|
export declare function defineScriptVars(vars: Record<any, any>): any;
|
|
26
|
+
/** Renders an endpoint request to completion, returning the body. */
|
|
26
27
|
export declare function renderEndpoint(mod: EndpointHandler, request: Request, params: Params): Promise<Response | import("../../@types/astro").EndpointOutput<string>>;
|
|
27
28
|
export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<string>;
|
|
28
29
|
export declare function renderPage(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.9",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@astrojs/compiler": "^0.14.1",
|
|
79
79
|
"@astrojs/language-server": "^0.13.4",
|
|
80
|
-
"@astrojs/markdown-remark": "^0.
|
|
80
|
+
"@astrojs/markdown-remark": "^0.9.0",
|
|
81
81
|
"@astrojs/prism": "0.4.1",
|
|
82
82
|
"@astrojs/webapi": "^0.11.0",
|
|
83
83
|
"@babel/core": "^7.17.9",
|