astro 1.0.0-beta.3 → 1.0.0-beta.6
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/LICENSE +34 -0
- package/dist/cli/index.js +11 -2
- package/dist/cli/open.js +26 -0
- package/dist/core/build/generate.js +3 -2
- package/dist/core/build/index.js +1 -0
- package/dist/core/build/static-build.js +2 -2
- package/dist/core/build/vite-plugin-ssr.js +8 -2
- package/dist/core/config.js +15 -3
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/request.js +31 -1
- package/dist/core/routing/manifest/create.js +1 -0
- package/dist/core/routing/manifest/serialization.js +5 -4
- package/dist/integrations/index.js +4 -1
- package/dist/types/@types/astro.d.ts +118 -9
- package/dist/types/cli/open.d.ts +2 -0
- package/dist/types/core/request.d.ts +2 -1
- package/dist/types/integrations/index.d.ts +2 -1
- package/dist/vite-plugin-astro-server/index.js +11 -2
- package/dist/vite-plugin-build-css/index.js +4 -1
- package/dist/vite-plugin-build-html/index.js +2 -1
- package/env.d.ts +3 -2
- package/package.json +25 -24
package/LICENSE
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Fred K. Schott
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
"""
|
|
25
|
+
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
|
|
26
|
+
|
|
27
|
+
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
|
|
28
|
+
|
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
30
|
+
|
|
31
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
32
|
+
|
|
33
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
34
|
+
"""
|
package/dist/cli/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import add from "../core/add/index.js";
|
|
|
7
7
|
import devServer from "../core/dev/index.js";
|
|
8
8
|
import preview from "../core/preview/index.js";
|
|
9
9
|
import { check } from "./check.js";
|
|
10
|
+
import { openInBrowser } from "./open.js";
|
|
10
11
|
import { loadConfig } from "../core/config.js";
|
|
11
12
|
import { printHelp, formatErrorMessage, formatConfigErrorMessage } from "../core/messages.js";
|
|
12
13
|
import { createSafeError } from "../core/util.js";
|
|
@@ -16,6 +17,7 @@ function printAstroHelp() {
|
|
|
16
17
|
headline: "Futuristic web development tool.",
|
|
17
18
|
commands: [
|
|
18
19
|
["add", "Add an integration to your configuration."],
|
|
20
|
+
["docs", "Launch Astro's Doc site directly from the terminal. "],
|
|
19
21
|
["dev", "Run Astro in development mode."],
|
|
20
22
|
["build", "Build a pre-compiled production-ready site."],
|
|
21
23
|
["preview", "Preview your build locally before deploying."],
|
|
@@ -36,7 +38,7 @@ function printAstroHelp() {
|
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
async function printVersion() {
|
|
39
|
-
const version = "1.0.0-beta.
|
|
41
|
+
const version = "1.0.0-beta.5";
|
|
40
42
|
console.log();
|
|
41
43
|
console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${version}`)}`);
|
|
42
44
|
}
|
|
@@ -48,7 +50,7 @@ function resolveCommand(flags) {
|
|
|
48
50
|
return "version";
|
|
49
51
|
else if (flags.help)
|
|
50
52
|
return "help";
|
|
51
|
-
const supportedCommands = /* @__PURE__ */ new Set(["dev", "build", "preview", "check"]);
|
|
53
|
+
const supportedCommands = /* @__PURE__ */ new Set(["dev", "build", "preview", "check", "docs"]);
|
|
52
54
|
if (supportedCommands.has(cmd)) {
|
|
53
55
|
return cmd;
|
|
54
56
|
}
|
|
@@ -119,6 +121,13 @@ async function cli(args) {
|
|
|
119
121
|
return throwAndExit(err);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
124
|
+
case "docs": {
|
|
125
|
+
try {
|
|
126
|
+
return await openInBrowser("https://docs.astro.build/");
|
|
127
|
+
} catch (err) {
|
|
128
|
+
return throwAndExit(err);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
122
131
|
default: {
|
|
123
132
|
throw new Error(`Error running ${cmd}`);
|
|
124
133
|
}
|
package/dist/cli/open.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
const getPlatformSpecificCommand = () => {
|
|
3
|
+
const isGitPod = Boolean(process.env.GITPOD_REPO_ROOT);
|
|
4
|
+
const platform = isGitPod ? "gitpod" : process.platform;
|
|
5
|
+
switch (platform) {
|
|
6
|
+
case "android":
|
|
7
|
+
case "linux":
|
|
8
|
+
return ["xdg-open"];
|
|
9
|
+
case "darwin":
|
|
10
|
+
return ["open"];
|
|
11
|
+
case "win32":
|
|
12
|
+
return ["cmd", ["/c", "start"]];
|
|
13
|
+
case "gitpod":
|
|
14
|
+
return ["/ide/bin/remote-cli/gitpod-code", ["--openExternal"]];
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(`It looks like your platform ("${platform}") isn't supported!
|
|
17
|
+
To view Astro's docs, please visit https://docs.astro.build`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
async function openInBrowser(url) {
|
|
21
|
+
const [command, args = []] = getPlatformSpecificCommand();
|
|
22
|
+
return execa(command, [...args, encodeURI(url)]);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
openInBrowser
|
|
26
|
+
};
|
|
@@ -116,6 +116,7 @@ async function generatePath(pathname, opts, gopts) {
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
+
const ssr = isBuildingToSSR(opts.astroConfig);
|
|
119
120
|
const url = new URL(origin + pathname);
|
|
120
121
|
const options = {
|
|
121
122
|
legacyBuild: false,
|
|
@@ -139,11 +140,11 @@ async function generatePath(pathname, opts, gopts) {
|
|
|
139
140
|
const fullyRelativePath = relPath[0] === "." ? relPath : "./" + relPath;
|
|
140
141
|
return fullyRelativePath;
|
|
141
142
|
},
|
|
142
|
-
request: createRequest({ url, headers: new Headers(), logging }),
|
|
143
|
+
request: createRequest({ url, headers: new Headers(), logging, ssr }),
|
|
143
144
|
route: pageData.route,
|
|
144
145
|
routeCache,
|
|
145
146
|
site: astroConfig.site ? new URL(astroConfig.base, astroConfig.site).toString() : astroConfig.site,
|
|
146
|
-
ssr
|
|
147
|
+
ssr
|
|
147
148
|
};
|
|
148
149
|
let body;
|
|
149
150
|
if (pageData.route.type === "endpoint") {
|
package/dist/core/build/index.js
CHANGED
|
@@ -204,11 +204,11 @@ async function copyFiles(fromFolder, toFolder) {
|
|
|
204
204
|
const files = await glob("**/*", {
|
|
205
205
|
cwd: fileURLToPath(fromFolder)
|
|
206
206
|
});
|
|
207
|
-
await fs.promises.mkdir(toFolder, { recursive: true });
|
|
208
207
|
await Promise.all(files.map(async (filename) => {
|
|
209
208
|
const from = new URL(filename, fromFolder);
|
|
210
209
|
const to = new URL(filename, toFolder);
|
|
211
|
-
|
|
210
|
+
const lastFolder = new URL("./", to);
|
|
211
|
+
return fs.promises.mkdir(lastFolder, { recursive: true }).then(() => fs.promises.copyFile(from, to));
|
|
212
212
|
}));
|
|
213
213
|
}
|
|
214
214
|
async function ssrMoveAssets(opts) {
|
|
@@ -31,8 +31,14 @@ const _manifest = Object.assign(_deserializeManifest('${manifestReplace}'), {
|
|
|
31
31
|
const _args = ${adapter.args ? JSON.stringify(adapter.args) : "undefined"};
|
|
32
32
|
|
|
33
33
|
${adapter.exports ? `const _exports = adapter.createExports(_manifest, _args);
|
|
34
|
-
${adapter.exports.map((name) =>
|
|
35
|
-
|
|
34
|
+
${adapter.exports.map((name) => {
|
|
35
|
+
if (name === "default") {
|
|
36
|
+
return `const _default = _exports['default'];
|
|
37
|
+
export { _default as default };`;
|
|
38
|
+
} else {
|
|
39
|
+
return `export const ${name} = _exports['${name}'];`;
|
|
40
|
+
}
|
|
41
|
+
}).join("\n")}
|
|
36
42
|
` : ""}
|
|
37
43
|
const _start = 'start';
|
|
38
44
|
if(_start in adapter) {
|
package/dist/core/config.js
CHANGED
|
@@ -22,7 +22,7 @@ import path from "path";
|
|
|
22
22
|
import { pathToFileURL, fileURLToPath } from "url";
|
|
23
23
|
import { mergeConfig as mergeViteConfig } from "vite";
|
|
24
24
|
import { z } from "zod";
|
|
25
|
-
import load from "@proload/core";
|
|
25
|
+
import load, { ProloadError } from "@proload/core";
|
|
26
26
|
import loadTypeScript from "@proload/plugin-tsm";
|
|
27
27
|
import postcssrc from "postcss-load-config";
|
|
28
28
|
import { arraify, isObject } from "./util.js";
|
|
@@ -224,9 +224,21 @@ async function loadConfig(configOptions) {
|
|
|
224
224
|
let userConfigPath;
|
|
225
225
|
if (flags == null ? void 0 : flags.config) {
|
|
226
226
|
userConfigPath = /^\.*\//.test(flags.config) ? flags.config : `./${flags.config}`;
|
|
227
|
-
userConfigPath = fileURLToPath(new URL(userConfigPath, pathToFileURL(root)));
|
|
227
|
+
userConfigPath = fileURLToPath(new URL(userConfigPath, appendForwardSlash(pathToFileURL(root).toString())));
|
|
228
|
+
}
|
|
229
|
+
let config;
|
|
230
|
+
try {
|
|
231
|
+
config = await load("astro", {
|
|
232
|
+
mustExist: !!userConfigPath,
|
|
233
|
+
cwd: root,
|
|
234
|
+
filePath: userConfigPath
|
|
235
|
+
});
|
|
236
|
+
} catch (err) {
|
|
237
|
+
if (err instanceof ProloadError && flags.config) {
|
|
238
|
+
throw new Error(`Unable to resolve --config "${flags.config}"! Does the file exist?`);
|
|
239
|
+
}
|
|
240
|
+
throw err;
|
|
228
241
|
}
|
|
229
|
-
const config = await load("astro", { mustExist: false, cwd: root, filePath: userConfigPath });
|
|
230
242
|
if (config) {
|
|
231
243
|
userConfig = config.value;
|
|
232
244
|
}
|
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.5";
|
|
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.5";
|
|
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.5"}`)} ${headline}`);
|
|
174
174
|
}
|
|
175
175
|
if (usage) {
|
|
176
176
|
message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
|
package/dist/core/request.js
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
20
|
import { warn } from "./logger/core.js";
|
|
2
21
|
function createRequest({
|
|
3
22
|
url,
|
|
4
23
|
headers,
|
|
5
24
|
method = "GET",
|
|
6
25
|
body = void 0,
|
|
7
|
-
logging
|
|
26
|
+
logging,
|
|
27
|
+
ssr
|
|
8
28
|
}) {
|
|
9
29
|
let headersObj = headers instanceof Headers ? headers : new Headers(Object.entries(headers));
|
|
10
30
|
const request = new Request(url.toString(), {
|
|
@@ -26,6 +46,16 @@ function createRequest({
|
|
|
26
46
|
}
|
|
27
47
|
}
|
|
28
48
|
});
|
|
49
|
+
if (!ssr) {
|
|
50
|
+
const _headers = request.headers;
|
|
51
|
+
const headersDesc = Object.getOwnPropertyDescriptor(request, "headers") || {};
|
|
52
|
+
Object.defineProperty(request, "headers", __spreadProps(__spreadValues({}, headersDesc), {
|
|
53
|
+
get() {
|
|
54
|
+
warn(logging, "ssg", `Headers are not exposed in static-site generation (SSG) mode. To enable reading headers you need to set an SSR adapter in your config.`);
|
|
55
|
+
return _headers;
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
29
59
|
return request;
|
|
30
60
|
}
|
|
31
61
|
export {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
function createRouteData(pattern, params, component, pathname, type) {
|
|
1
|
+
function createRouteData(pattern, params, component, pathname, type, segments) {
|
|
2
2
|
return {
|
|
3
3
|
type,
|
|
4
4
|
pattern,
|
|
5
5
|
params,
|
|
6
6
|
component,
|
|
7
7
|
generate: () => "",
|
|
8
|
-
pathname: pathname || void 0
|
|
8
|
+
pathname: pathname || void 0,
|
|
9
|
+
segments
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
12
|
function serializeRouteData(routeData) {
|
|
@@ -14,9 +15,9 @@ function serializeRouteData(routeData) {
|
|
|
14
15
|
return outRouteData;
|
|
15
16
|
}
|
|
16
17
|
function deserializeRouteData(rawRouteData) {
|
|
17
|
-
const { component, params, pathname, type } = rawRouteData;
|
|
18
|
+
const { component, params, pathname, type, segments } = rawRouteData;
|
|
18
19
|
const pattern = new RegExp(rawRouteData.pattern);
|
|
19
|
-
return createRouteData(pattern, params, component, pathname, type);
|
|
20
|
+
return createRouteData(pattern, params, component, pathname, type, segments);
|
|
20
21
|
}
|
|
21
22
|
export {
|
|
22
23
|
deserializeRouteData,
|
|
@@ -16,6 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
16
16
|
};
|
|
17
17
|
import { mergeConfig } from "../core/config.js";
|
|
18
18
|
import ssgAdapter from "../adapter-ssg/index.js";
|
|
19
|
+
import { isBuildingToSSR } from "../core/util.js";
|
|
19
20
|
async function runHookConfigSetup({
|
|
20
21
|
config: _config,
|
|
21
22
|
command
|
|
@@ -120,14 +121,16 @@ async function runHookBuildSetup({
|
|
|
120
121
|
}
|
|
121
122
|
async function runHookBuildDone({
|
|
122
123
|
config,
|
|
124
|
+
buildConfig,
|
|
123
125
|
pages,
|
|
124
126
|
routes
|
|
125
127
|
}) {
|
|
128
|
+
const dir = isBuildingToSSR(config) ? buildConfig.client : config.outDir;
|
|
126
129
|
for (const integration of config.integrations) {
|
|
127
130
|
if (integration.hooks["astro:build:done"]) {
|
|
128
131
|
await integration.hooks["astro:build:done"]({
|
|
129
132
|
pages: pages.map((p) => ({ pathname: p })),
|
|
130
|
-
dir
|
|
133
|
+
dir,
|
|
131
134
|
routes
|
|
132
135
|
});
|
|
133
136
|
}
|
|
@@ -62,21 +62,107 @@ export interface BuildConfig {
|
|
|
62
62
|
staticMode: boolean | undefined;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Astro
|
|
66
|
-
*
|
|
65
|
+
* Astro global available in all contexts in .astro files
|
|
66
|
+
*
|
|
67
|
+
* [Astro reference](https://docs.astro.build/reference/api-reference/#astro-global)
|
|
67
68
|
*/
|
|
68
69
|
export interface AstroGlobal extends AstroGlobalPartial {
|
|
69
|
-
/**
|
|
70
|
+
/** Canonical URL of the current page. If the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option is set, its origin will be the origin of this URL.
|
|
71
|
+
*
|
|
72
|
+
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrocanonicalurl)
|
|
73
|
+
*/
|
|
70
74
|
canonicalURL: URL;
|
|
71
|
-
/**
|
|
75
|
+
/** Parameters passed to a dynamic page generated using [getStaticPaths](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
|
|
76
|
+
*
|
|
77
|
+
* Example usage:
|
|
78
|
+
* ```astro
|
|
79
|
+
* ---
|
|
80
|
+
* export async function getStaticPaths() {
|
|
81
|
+
* return [
|
|
82
|
+
* { params: { id: '1' } },
|
|
83
|
+
* ];
|
|
84
|
+
* }
|
|
85
|
+
*
|
|
86
|
+
* const { id } = Astro.params;
|
|
87
|
+
* ---
|
|
88
|
+
* <h1>{id}</h1>
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#params)
|
|
92
|
+
*/
|
|
72
93
|
params: Params;
|
|
73
|
-
/**
|
|
94
|
+
/** List of props passed to this component
|
|
95
|
+
*
|
|
96
|
+
* A common way to get specific props is through [destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment), ex:
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const { name } = Astro.props
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* [Astro reference](https://docs.astro.build/en/core-concepts/astro-components/#component-props)
|
|
102
|
+
*/
|
|
74
103
|
props: Record<string, number | string | any>;
|
|
75
|
-
/**
|
|
104
|
+
/** Information about the current request. This is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object
|
|
105
|
+
*
|
|
106
|
+
* For example, to get a URL object of the current URL, you can use:
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const url = new URL(Astro.request.url);
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrorequest)
|
|
112
|
+
*/
|
|
76
113
|
request: Request;
|
|
77
|
-
/**
|
|
114
|
+
/** Redirect to another page (**SSR Only**)
|
|
115
|
+
*
|
|
116
|
+
* Example usage:
|
|
117
|
+
* ```typescript
|
|
118
|
+
* if(!isLoggedIn) {
|
|
119
|
+
* return Astro.redirect('/login');
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* [Astro reference](https://docs.astro.build/en/guides/server-side-rendering/#astroredirect)
|
|
124
|
+
*/
|
|
125
|
+
redirect(path: string): Response;
|
|
126
|
+
/**
|
|
127
|
+
* The <Astro.self /> element allows a component to reference itself recursively.
|
|
128
|
+
*
|
|
129
|
+
* [Astro reference](https://docs.astro.build/en/guides/server-side-rendering/#astroself)
|
|
130
|
+
*/
|
|
131
|
+
self: AstroComponentFactory;
|
|
132
|
+
/** Utility functions for modifying an Astro component’s slotted children
|
|
133
|
+
*
|
|
134
|
+
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
|
|
135
|
+
*/
|
|
78
136
|
slots: Record<string, true | undefined> & {
|
|
137
|
+
/**
|
|
138
|
+
* Check whether content for this slot name exists
|
|
139
|
+
*
|
|
140
|
+
* Example usage:
|
|
141
|
+
* ```typescript
|
|
142
|
+
* if (Astro.slots.has('default')) {
|
|
143
|
+
* // Do something...
|
|
144
|
+
* }
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
|
|
148
|
+
*/
|
|
79
149
|
has(slotName: string): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Asychronously renders this slot and returns HTML
|
|
152
|
+
*
|
|
153
|
+
* Example usage:
|
|
154
|
+
* ```astro
|
|
155
|
+
* ---
|
|
156
|
+
* let html: string = '';
|
|
157
|
+
* if (Astro.slots.has('default')) {
|
|
158
|
+
* html = await Astro.slots.render('default')
|
|
159
|
+
* }
|
|
160
|
+
* ---
|
|
161
|
+
* <Fragment set:html={html} />
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
|
|
165
|
+
*/
|
|
80
166
|
render(slotName: string, args?: any[]): Promise<string>;
|
|
81
167
|
};
|
|
82
168
|
}
|
|
@@ -84,12 +170,29 @@ export interface AstroGlobalPartial {
|
|
|
84
170
|
/**
|
|
85
171
|
* @deprecated since version 0.24. See the {@link https://astro.build/deprecated/resolve upgrade guide} for more details.
|
|
86
172
|
*/
|
|
87
|
-
resolve
|
|
88
|
-
/** @deprecated Use
|
|
173
|
+
resolve(path: string): string;
|
|
174
|
+
/** @deprecated since version 0.26. Use [Astro.glob()](https://docs.astro.build/en/reference/api-reference/#astroglob) instead. */
|
|
89
175
|
fetchContent(globStr: string): Promise<any[]>;
|
|
176
|
+
/**
|
|
177
|
+
* Fetch local files into your static site setup
|
|
178
|
+
*
|
|
179
|
+
* Example usage:
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const posts = await Astro.glob('../pages/post/*.md');
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroglob)
|
|
185
|
+
*/
|
|
90
186
|
glob(globStr: `${any}.astro`): Promise<ComponentInstance[]>;
|
|
91
187
|
glob<T extends Record<string, any>>(globStr: `${any}.md`): Promise<MarkdownInstance<T>[]>;
|
|
92
188
|
glob<T extends Record<string, any>>(globStr: string): Promise<T[]>;
|
|
189
|
+
/**
|
|
190
|
+
* Returns a [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object built from the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option
|
|
191
|
+
*
|
|
192
|
+
* If `site` is undefined, the URL object will instead be built from `localhost`
|
|
193
|
+
*
|
|
194
|
+
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrosite)
|
|
195
|
+
*/
|
|
93
196
|
site: URL;
|
|
94
197
|
}
|
|
95
198
|
declare type ServerConfig = {
|
|
@@ -724,12 +827,18 @@ export interface AstroIntegration {
|
|
|
724
827
|
};
|
|
725
828
|
}
|
|
726
829
|
export declare type RouteType = 'page' | 'endpoint';
|
|
830
|
+
export interface RoutePart {
|
|
831
|
+
content: string;
|
|
832
|
+
dynamic: boolean;
|
|
833
|
+
spread: boolean;
|
|
834
|
+
}
|
|
727
835
|
export interface RouteData {
|
|
728
836
|
component: string;
|
|
729
837
|
generate: (data?: any) => string;
|
|
730
838
|
params: string[];
|
|
731
839
|
pathname?: string;
|
|
732
840
|
pattern: RegExp;
|
|
841
|
+
segments: RoutePart[][];
|
|
733
842
|
type: RouteType;
|
|
734
843
|
}
|
|
735
844
|
export declare type SerializedRouteData = Omit<RouteData, 'generate' | 'pattern'> & {
|
|
@@ -9,6 +9,7 @@ export interface CreateRequestOptions {
|
|
|
9
9
|
method?: string;
|
|
10
10
|
body?: RequestBody | undefined;
|
|
11
11
|
logging: LogOptions;
|
|
12
|
+
ssr: boolean;
|
|
12
13
|
}
|
|
13
|
-
export declare function createRequest({ url, headers, method, body, logging, }: CreateRequestOptions): Request;
|
|
14
|
+
export declare function createRequest({ url, headers, method, body, logging, ssr, }: CreateRequestOptions): Request;
|
|
14
15
|
export {};
|
|
@@ -30,8 +30,9 @@ export declare function runHookBuildSetup({ config, vite, target, }: {
|
|
|
30
30
|
vite: ViteConfigWithSSR;
|
|
31
31
|
target: 'server' | 'client';
|
|
32
32
|
}): Promise<void>;
|
|
33
|
-
export declare function runHookBuildDone({ config, pages, routes, }: {
|
|
33
|
+
export declare function runHookBuildDone({ config, buildConfig, pages, routes, }: {
|
|
34
34
|
config: AstroConfig;
|
|
35
|
+
buildConfig: BuildConfig;
|
|
35
36
|
pages: string[];
|
|
36
37
|
routes: RouteData[];
|
|
37
38
|
}): Promise<void>;
|
|
@@ -34,7 +34,15 @@ function writeHtmlResponse(res, statusCode, html) {
|
|
|
34
34
|
}
|
|
35
35
|
async function writeWebResponse(res, webResponse) {
|
|
36
36
|
const { status, headers, body } = webResponse;
|
|
37
|
-
|
|
37
|
+
let _headers = {};
|
|
38
|
+
if ("raw" in headers) {
|
|
39
|
+
for (const [key, value] of Object.entries(headers.raw())) {
|
|
40
|
+
res.setHeader(key, value);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
_headers = Object.fromEntries(headers.entries());
|
|
44
|
+
}
|
|
45
|
+
res.writeHead(status, _headers);
|
|
38
46
|
if (body) {
|
|
39
47
|
if (body instanceof Readable) {
|
|
40
48
|
body.pipe(res);
|
|
@@ -128,7 +136,8 @@ async function handleRequest(routeCache, viteServer, logging, manifest, config,
|
|
|
128
136
|
headers: buildingToSSR ? req.headers : new Headers(),
|
|
129
137
|
method: req.method,
|
|
130
138
|
body,
|
|
131
|
-
logging
|
|
139
|
+
logging,
|
|
140
|
+
ssr: buildingToSSR
|
|
132
141
|
});
|
|
133
142
|
try {
|
|
134
143
|
if (!pathname.startsWith(devRoot)) {
|
|
@@ -33,6 +33,9 @@ function isStyleVirtualModule(id) {
|
|
|
33
33
|
function isPageStyleVirtualModule(id) {
|
|
34
34
|
return id.startsWith(ASTRO_PAGE_STYLE_PREFIX);
|
|
35
35
|
}
|
|
36
|
+
function isRawOrUrlModule(id) {
|
|
37
|
+
return id.match(/(\?|\&)([^=]+)(raw|url)/gm);
|
|
38
|
+
}
|
|
36
39
|
function rollupPluginAstroBuildCSS(options) {
|
|
37
40
|
const { internals, legacy } = options;
|
|
38
41
|
const styleSourceMap = /* @__PURE__ */ new Map();
|
|
@@ -44,7 +47,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
44
47
|
const info = ctx.getModuleInfo(id);
|
|
45
48
|
if (info) {
|
|
46
49
|
for (const importedId of info.importedIds) {
|
|
47
|
-
if (!seen.has(importedId)) {
|
|
50
|
+
if (!seen.has(importedId) && !isRawOrUrlModule(importedId)) {
|
|
48
51
|
yield* walkStyles(ctx, importedId, seen);
|
|
49
52
|
}
|
|
50
53
|
}
|
package/env.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ type Astro = import('astro').AstroGlobal;
|
|
|
4
4
|
|
|
5
5
|
// We duplicate the description here because editors won't show the JSDoc comment from the imported type (but will for its properties, ex: Astro.request will show the AstroGlobal.request description)
|
|
6
6
|
/**
|
|
7
|
-
* Astro
|
|
8
|
-
*
|
|
7
|
+
* Astro global available in all contexts in .astro files
|
|
8
|
+
*
|
|
9
|
+
* [Astro documentation](https://docs.astro.build/reference/api-reference/#astro-global)
|
|
9
10
|
*/
|
|
10
11
|
declare const Astro: Readonly<Astro>;
|
|
11
12
|
|
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.6",
|
|
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",
|
|
@@ -65,25 +65,16 @@
|
|
|
65
65
|
"README.md",
|
|
66
66
|
"vendor"
|
|
67
67
|
],
|
|
68
|
-
"scripts": {
|
|
69
|
-
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
|
|
70
|
-
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
|
71
|
-
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
|
72
|
-
"postbuild": "astro-scripts copy \"src/**/*.astro\"",
|
|
73
|
-
"benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js",
|
|
74
|
-
"test": "mocha --exit --timeout 20000 --ignore **/lit-element.test.js && mocha --timeout 20000 **/lit-element.test.js",
|
|
75
|
-
"test:match": "mocha --timeout 20000 -g"
|
|
76
|
-
},
|
|
77
68
|
"dependencies": {
|
|
78
69
|
"@astrojs/compiler": "^0.14.1",
|
|
79
|
-
"@astrojs/language-server": "^0.13.
|
|
70
|
+
"@astrojs/language-server": "^0.13.4",
|
|
80
71
|
"@astrojs/markdown-remark": "^0.8.1",
|
|
81
72
|
"@astrojs/prism": "0.4.1",
|
|
82
73
|
"@astrojs/webapi": "^0.11.0",
|
|
83
|
-
"@babel/core": "^7.17.
|
|
84
|
-
"@babel/generator": "^7.17.
|
|
85
|
-
"@babel/parser": "^7.17.
|
|
86
|
-
"@babel/traverse": "^7.17.
|
|
74
|
+
"@babel/core": "^7.17.9",
|
|
75
|
+
"@babel/generator": "^7.17.9",
|
|
76
|
+
"@babel/parser": "^7.17.9",
|
|
77
|
+
"@babel/traverse": "^7.17.9",
|
|
87
78
|
"@proload/core": "^0.2.2",
|
|
88
79
|
"@proload/plugin-tsm": "^0.1.1",
|
|
89
80
|
"@web/parse5-utils": "^1.3.0",
|
|
@@ -94,8 +85,8 @@
|
|
|
94
85
|
"debug": "^4.3.4",
|
|
95
86
|
"diff": "^5.0.0",
|
|
96
87
|
"eol": "^0.9.1",
|
|
97
|
-
"es-module-lexer": "^0.10.
|
|
98
|
-
"esbuild": "0.14.
|
|
88
|
+
"es-module-lexer": "^0.10.5",
|
|
89
|
+
"esbuild": "^0.14.34",
|
|
99
90
|
"estree-walker": "^3.0.1",
|
|
100
91
|
"execa": "^6.1.0",
|
|
101
92
|
"fast-glob": "^3.2.11",
|
|
@@ -120,7 +111,7 @@
|
|
|
120
111
|
"rehype-slug": "^5.0.1",
|
|
121
112
|
"resolve": "^1.22.0",
|
|
122
113
|
"rollup": "^2.70.1",
|
|
123
|
-
"semver": "^7.3.
|
|
114
|
+
"semver": "^7.3.6",
|
|
124
115
|
"serialize-javascript": "^6.0.0",
|
|
125
116
|
"shiki": "^0.10.1",
|
|
126
117
|
"shorthash": "^0.0.2",
|
|
@@ -134,7 +125,7 @@
|
|
|
134
125
|
"tsconfig-resolver": "^3.0.1",
|
|
135
126
|
"vite": "^2.9.1",
|
|
136
127
|
"yargs-parser": "^21.0.1",
|
|
137
|
-
"zod": "^3.14.
|
|
128
|
+
"zod": "^3.14.4"
|
|
138
129
|
},
|
|
139
130
|
"devDependencies": {
|
|
140
131
|
"@babel/types": "^7.17.0",
|
|
@@ -152,19 +143,29 @@
|
|
|
152
143
|
"@types/mocha": "^9.1.0",
|
|
153
144
|
"@types/parse5": "^6.0.3",
|
|
154
145
|
"@types/path-browserify": "^1.0.0",
|
|
155
|
-
"@types/prettier": "^2.
|
|
146
|
+
"@types/prettier": "^2.6.0",
|
|
156
147
|
"@types/resolve": "^1.20.1",
|
|
157
148
|
"@types/rimraf": "^3.0.2",
|
|
158
149
|
"@types/send": "^0.17.1",
|
|
159
150
|
"@types/yargs-parser": "^21.0.0",
|
|
160
|
-
"astro-scripts": "
|
|
151
|
+
"astro-scripts": "0.0.2",
|
|
161
152
|
"chai": "^4.3.6",
|
|
162
153
|
"cheerio": "^1.0.0-rc.10",
|
|
163
154
|
"mocha": "^9.2.2",
|
|
164
|
-
"sass": "^1.
|
|
155
|
+
"sass": "^1.50.0"
|
|
165
156
|
},
|
|
166
157
|
"engines": {
|
|
167
158
|
"node": "^14.15.0 || >=16.0.0",
|
|
168
159
|
"npm": ">=6.14.0"
|
|
169
|
-
}
|
|
170
|
-
|
|
160
|
+
},
|
|
161
|
+
"scripts": {
|
|
162
|
+
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
|
|
163
|
+
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
|
164
|
+
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
|
165
|
+
"postbuild": "astro-scripts copy \"src/**/*.astro\"",
|
|
166
|
+
"benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js",
|
|
167
|
+
"test": "mocha --exit --timeout 20000 --ignore **/lit-element.test.js && mocha --timeout 20000 **/lit-element.test.js",
|
|
168
|
+
"test:match": "mocha --timeout 20000 -g"
|
|
169
|
+
},
|
|
170
|
+
"readme": "<a href=\"https://astro.build\">\n <img src=\"https://raw.githubusercontent.com/withastro/astro/main/assets/social/banner.svg\" />\n</a>\n\n<div center>\n\n**Astro** is a new kind of static site builder for the modern web—powerful developer experience meets lightweight output.\n\n</div>\n\n### [🚀 Read the launch post →](https://astro.build/blog/introducing-astro)\n\n### [📚 Learn Astro →](https://docs.astro.build/en/getting-started/)\n\n## Project Status\n\n⚠️ **Astro is still beta software—missing features and bugs are to be expected!** We are quickly working our way towards a stable, production-ready v1.0 release, but we are still finalizing some of Astro's APIs.\n\nThat being said, there are quite a few Astro sites in production already. We're incredibly grateful to everyone who has made an early bet on Astro!\n\n## Quick Start\n\n<table>\n <tbody>\n <tr>\n <td>\n <img width=\"441\" height=\"1px\">\n <strong>👾 Online</strong>\n </td>\n <td>\n <img width=\"441\" height=\"1px\">\n <strong>📦 Local</strong>\n </td>\n </tr>\n <tr>\n<td>\n\nTry Astro in your browser!\n\n[Launch astro.new →](https://astro.new)\n\n</td>\n<td>\n\nGet started with Astro using our interactive CLI!\n\n```bash\nnpm init astro my-astro-project\n```\n\n</td>\n </tr>\n </tbody>\n</table>\n\n## Sponsors\n\nYou can sponsor Astro's development on [Open Collective](https://opencollective.com/astrodotbuild). Astro is generously supported by the following companies and individuals:\n\n### Platinum Sponsors\n\n<table>\n <tbody>\n <tr>\n <td align=\"center\"><a href=\"https://www.netlify.com/#gh-light-mode-only\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/netlify.svg#gh-light-mode-only\" alt=\"Netlify\" /></a><a href=\"https://www.netlify.com/#gh-dark-mode-only\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/netlify-dark.svg#gh-dark-mode-only\" alt=\"Netlify\" />\n </a></td>\n <td align=\"center\"><a href=\"https://www.vercel.com/#gh-light-mode-only\" target=\"_blank\"><img width=\"150\" height=\"34\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/vercel.svg#gh-light-mode-only\" alt=\"Vercel\" /></a><a href=\"https://www.vercel.com/#gh-dark-mode-only\"><img width=\"150\" height=\"34\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/vercel-dark.svg#gh-dark-mode-only\" alt=\"Vercel\" />\n </a></td>\n </tr>\n </tbody>\n</table>\n\n### Gold Sponsors\n\n<table>\n <tbody>\n <tr>\n <td align=\"center\">\n <a href=\"https://divRIOTS.com#gh-light-mode-only\" target=\"_blank\">\n <img width=\"150\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/divriots.svg#gh-light-mode-only\" alt=\"‹div›RIOTS\" />\n </a>\n <a href=\"https://divRIOTS.com#gh-dark-mode-only\" target=\"_blank\">\n <img width=\"150\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/divriots-dark.svg#gh-dark-mode-only\" alt=\"‹div›RIOTS\" />\n </a>\n </td>\n <td align=\"center\">\n <a href=\"https://stackupdigital.co.uk/#gh-light-mode-only\" target=\"_blank\">\n <img width=\"162\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/stackup.svg#gh-light-mode-only\" alt=\"StackUp Digital\" />\n </a>\n <a href=\"https://stackupdigital.co.uk/#gh-dark-mode-only\" target=\"_blank\">\n <img width=\"130\" height=\"32\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/stackup-dark.svg#gh-dark-mode-only\" alt=\"StackUp Digital\" />\n </a>\n </td>\n </tr>\n </tbody>\n</table>\n\n### Sponsors\n\n<table>\n <tbody>\n <tr>\n <td align=\"center\"><a href=\"https://sentry.io\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/sentry.svg\" alt=\"Sentry\" /></a></td><td align=\"center\"><a href=\"https://qoddi.com\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://devcenter.qoddi.com/wp-content/uploads/2021/11/blog-transparent-logo-1.png\" alt=\"Qoddi App Platform\" /></a></td>\n </tr>\n </tbody>\n</table>\n"
|
|
171
|
+
}
|