astro 5.0.0-beta.5 → 5.0.0-beta.7
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/client.d.ts +1 -0
- package/components/Welcome.astro +172 -0
- package/components/index.ts +3 -1
- package/dist/actions/runtime/middleware.js +10 -4
- package/dist/actions/runtime/route.js +2 -1
- package/dist/actions/runtime/virtual/get-action.js +1 -1
- package/dist/assets/endpoint/node.js +4 -0
- package/dist/assets/internal.js +2 -1
- package/dist/assets/types.d.ts +3 -3
- package/dist/assets/vite-plugin-assets.d.ts +3 -3
- package/dist/assets/vite-plugin-assets.js +6 -7
- package/dist/cli/add/index.js +7 -5
- package/dist/cli/build/index.js +6 -1
- package/dist/cli/dev/index.js +1 -0
- package/dist/cli/docs/open.d.ts +1 -1
- package/dist/cli/docs/open.js +1 -1
- package/dist/cli/exec.d.ts +5 -0
- package/dist/cli/exec.js +23 -0
- package/dist/cli/index.js +3 -3
- package/dist/cli/install-package.js +8 -2
- package/dist/cli/sync/index.d.ts +1 -1
- package/dist/cli/sync/index.js +1 -6
- package/dist/config/entrypoint.d.ts +15 -0
- package/dist/config/entrypoint.js +21 -0
- package/dist/config/index.d.ts +11 -7
- package/dist/config/index.js +5 -10
- package/dist/container/index.d.ts +7 -0
- package/dist/container/index.js +2 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/types-generator.js +10 -3
- package/dist/content/vite-plugin-content-assets.d.ts +1 -2
- package/dist/content/vite-plugin-content-assets.js +1 -4
- package/dist/content/vite-plugin-content-virtual-mod.js +1 -1
- package/dist/core/app/index.js +5 -9
- package/dist/core/app/middlewares.js +4 -1
- package/dist/core/app/node.js +5 -3
- package/dist/core/app/pipeline.d.ts +1 -1
- package/dist/core/app/pipeline.js +2 -2
- package/dist/core/base-pipeline.d.ts +4 -4
- package/dist/core/base-pipeline.js +2 -2
- package/dist/core/build/generate.js +1 -0
- package/dist/core/build/index.d.ts +7 -0
- package/dist/core/build/index.js +10 -9
- package/dist/core/build/pipeline.js +1 -1
- package/dist/core/build/static-build.js +11 -20
- package/dist/core/build/types.d.ts +1 -1
- package/dist/core/constants.d.ts +4 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/create-vite.d.ts +4 -3
- package/dist/core/create-vite.js +7 -6
- package/dist/core/dev/container.js +3 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.js +5 -1
- package/dist/core/errors/errors-data.d.ts +6 -7
- package/dist/core/errors/errors-data.js +1 -1
- package/dist/core/messages.js +6 -2
- package/dist/core/middleware/vite-plugin.js +1 -2
- package/dist/core/preview/vite-plugin-astro-preview.js +1 -1
- package/dist/core/render/params-and-props.js +1 -1
- package/dist/core/render/route-cache.d.ts +2 -2
- package/dist/core/render/route-cache.js +4 -4
- package/dist/core/render-context.d.ts +2 -1
- package/dist/core/render-context.js +25 -37
- package/dist/core/routing/astro-designed-error-pages.js +1 -1
- package/dist/core/routing/rewrite.d.ts +9 -0
- package/dist/core/routing/rewrite.js +38 -1
- package/dist/core/server-islands/endpoint.js +1 -1
- package/dist/core/sync/index.d.ts +2 -1
- package/dist/core/sync/index.js +47 -50
- package/dist/env/config.d.ts +1 -1
- package/dist/env/vite-plugin-env.d.ts +1 -1
- package/dist/env/vite-plugin-env.js +1 -5
- package/dist/prefetch/vite-plugin-prefetch.js +12 -2
- package/dist/runtime/client/dev-toolbar/apps/settings.js +2 -0
- package/dist/runtime/server/render/astro/head-and-content.js +1 -1
- package/dist/runtime/server/render/astro/instance.js +1 -1
- package/dist/runtime/server/render/astro/render-template.js +1 -1
- package/dist/runtime/server/render/component.js +1 -0
- package/dist/runtime/server/render/page.js +1 -4
- package/dist/runtime/server/render/util.js +1 -1
- package/dist/type-utils.d.ts +3 -0
- package/dist/types/public/config.d.ts +33 -18
- package/dist/types/public/content.d.ts +6 -2
- package/dist/vite-plugin-astro/index.js +3 -0
- package/dist/vite-plugin-astro-server/pipeline.js +3 -4
- package/dist/vite-plugin-astro-server/response.js +1 -1
- package/dist/vite-plugin-markdown/index.js +4 -2
- package/package.json +14 -19
- package/templates/actions.mjs +1 -1
- package/config.d.ts +0 -40
- package/config.mjs +0 -16
package/client.d.ts
CHANGED
|
@@ -283,6 +283,7 @@ declare module '*.mdx' {
|
|
|
283
283
|
export const url: MDX['url'];
|
|
284
284
|
export const getHeadings: MDX['getHeadings'];
|
|
285
285
|
export const Content: MDX['Content'];
|
|
286
|
+
export const components: MDX['components'];
|
|
286
287
|
|
|
287
288
|
const load: MDX['default'];
|
|
288
289
|
export default load;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
title?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const cards = [
|
|
7
|
+
{
|
|
8
|
+
href: 'https://docs.astro.build/',
|
|
9
|
+
title: 'Documentation',
|
|
10
|
+
body: 'Learn how Astro works and explore the official API docs.',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
href: 'https://astro.build/integrations/',
|
|
14
|
+
title: 'Integrations',
|
|
15
|
+
body: 'Supercharge your project with new frameworks and libraries.',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
href: 'https://astro.build/themes/',
|
|
19
|
+
title: 'Themes',
|
|
20
|
+
body: 'Explore a galaxy of community-built starter themes.',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
href: 'https://astro.build/chat/',
|
|
24
|
+
title: 'Community',
|
|
25
|
+
body: 'Come say hi to our amazing Discord community. ❤️',
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const { title = 'Welcome to Astro' } = Astro.props;
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
<main>
|
|
33
|
+
<svg
|
|
34
|
+
class="astro-a"
|
|
35
|
+
width="495"
|
|
36
|
+
height="623"
|
|
37
|
+
viewBox="0 0 495 623"
|
|
38
|
+
fill="none"
|
|
39
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
40
|
+
aria-hidden="true"
|
|
41
|
+
>
|
|
42
|
+
<path
|
|
43
|
+
fill-rule="evenodd"
|
|
44
|
+
clip-rule="evenodd"
|
|
45
|
+
d="M167.19 364.254C83.4786 364.254 0 404.819 0 404.819C0 404.819 141.781 19.4876 142.087 18.7291C146.434 7.33701 153.027 0 162.289 0H332.441C341.703 0 348.574 7.33701 352.643 18.7291C352.92 19.5022 494.716 404.819 494.716 404.819C494.716 404.819 426.67 364.254 327.525 364.254L264.41 169.408C262.047 159.985 255.147 153.581 247.358 153.581C239.569 153.581 232.669 159.985 230.306 169.408L167.19 364.254ZM160.869 530.172C160.877 530.18 160.885 530.187 160.894 530.195L160.867 530.181C160.868 530.178 160.868 530.175 160.869 530.172ZM136.218 411.348C124.476 450.467 132.698 504.458 160.869 530.172C160.997 529.696 161.125 529.242 161.248 528.804C161.502 527.907 161.737 527.073 161.917 526.233C165.446 509.895 178.754 499.52 195.577 500.01C211.969 500.487 220.67 508.765 223.202 527.254C224.141 534.12 224.23 541.131 224.319 548.105C224.328 548.834 224.337 549.563 224.347 550.291C224.563 566.098 228.657 580.707 237.264 593.914C245.413 606.426 256.108 615.943 270.749 622.478C270.593 621.952 270.463 621.508 270.35 621.126C270.045 620.086 269.872 619.499 269.685 618.911C258.909 585.935 266.668 563.266 295.344 543.933C298.254 541.971 301.187 540.041 304.12 538.112C310.591 533.854 317.059 529.599 323.279 525.007C345.88 508.329 360.09 486.327 363.431 457.844C364.805 446.148 363.781 434.657 359.848 423.275C358.176 424.287 356.587 425.295 355.042 426.275C351.744 428.366 348.647 430.33 345.382 431.934C303.466 452.507 259.152 455.053 214.03 448.245C184.802 443.834 156.584 436.019 136.218 411.348Z"
|
|
46
|
+
fill="url(#paint0_linear_1805_24383)"></path>
|
|
47
|
+
<defs>
|
|
48
|
+
<linearGradient
|
|
49
|
+
id="paint0_linear_1805_24383"
|
|
50
|
+
x1="247.358"
|
|
51
|
+
y1="0"
|
|
52
|
+
x2="247.358"
|
|
53
|
+
y2="622.479"
|
|
54
|
+
gradientUnits="userSpaceOnUse"
|
|
55
|
+
>
|
|
56
|
+
<stop stop-opacity="0.9"></stop>
|
|
57
|
+
<stop offset="1" stop-opacity="0.2"></stop>
|
|
58
|
+
</linearGradient>
|
|
59
|
+
</defs>
|
|
60
|
+
</svg>
|
|
61
|
+
<h1>{title}</h1>
|
|
62
|
+
<p class="instructions">
|
|
63
|
+
To get started, open the directory <code>src/pages</code> in your project.<br />
|
|
64
|
+
<strong>Code Challenge:</strong> Tweak the "Welcome to Astro" message above.
|
|
65
|
+
</p>
|
|
66
|
+
<ul role="list" class="link-card-grid">
|
|
67
|
+
{
|
|
68
|
+
cards.map((card) => (
|
|
69
|
+
<li class="link-card">
|
|
70
|
+
<a href={card.href}>
|
|
71
|
+
<h2>
|
|
72
|
+
{card.title}
|
|
73
|
+
<span>→</span>
|
|
74
|
+
</h2>
|
|
75
|
+
<p>{card.body}</p>
|
|
76
|
+
</a>
|
|
77
|
+
</li>
|
|
78
|
+
))
|
|
79
|
+
}
|
|
80
|
+
</ul>
|
|
81
|
+
</main>
|
|
82
|
+
|
|
83
|
+
<style>
|
|
84
|
+
main {
|
|
85
|
+
margin: auto;
|
|
86
|
+
padding: 1rem;
|
|
87
|
+
width: 800px;
|
|
88
|
+
max-width: calc(100% - 2rem);
|
|
89
|
+
color: white;
|
|
90
|
+
font-size: 20px;
|
|
91
|
+
line-height: 1.6;
|
|
92
|
+
}
|
|
93
|
+
.astro-a {
|
|
94
|
+
position: absolute;
|
|
95
|
+
top: -32px;
|
|
96
|
+
left: 50%;
|
|
97
|
+
transform: translatex(-50%);
|
|
98
|
+
width: 220px;
|
|
99
|
+
height: auto;
|
|
100
|
+
z-index: -1;
|
|
101
|
+
}
|
|
102
|
+
h1 {
|
|
103
|
+
font-size: 4rem;
|
|
104
|
+
font-weight: 700;
|
|
105
|
+
line-height: 1;
|
|
106
|
+
text-align: center;
|
|
107
|
+
margin-bottom: 1em;
|
|
108
|
+
}
|
|
109
|
+
.instructions {
|
|
110
|
+
margin-bottom: 2rem;
|
|
111
|
+
border: 1px solid rgba(var(--accent-light), 25%);
|
|
112
|
+
background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%));
|
|
113
|
+
padding: 1.5rem;
|
|
114
|
+
border-radius: 8px;
|
|
115
|
+
}
|
|
116
|
+
.instructions code {
|
|
117
|
+
font-size: 0.8em;
|
|
118
|
+
font-weight: bold;
|
|
119
|
+
background: rgba(var(--accent-light), 12%);
|
|
120
|
+
color: rgb(var(--accent-light));
|
|
121
|
+
border-radius: 4px;
|
|
122
|
+
padding: 0.3em 0.4em;
|
|
123
|
+
}
|
|
124
|
+
.instructions strong {
|
|
125
|
+
color: rgb(var(--accent-light));
|
|
126
|
+
}
|
|
127
|
+
.link-card-grid {
|
|
128
|
+
display: grid;
|
|
129
|
+
grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
|
|
130
|
+
gap: 2rem;
|
|
131
|
+
padding: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.link-card {
|
|
135
|
+
list-style: none;
|
|
136
|
+
display: flex;
|
|
137
|
+
padding: 1px;
|
|
138
|
+
background-color: #23262d;
|
|
139
|
+
background-image: none;
|
|
140
|
+
background-size: 400%;
|
|
141
|
+
border-radius: 7px;
|
|
142
|
+
background-position: 100%;
|
|
143
|
+
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
|
|
144
|
+
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
|
|
145
|
+
}
|
|
146
|
+
.link-card > a {
|
|
147
|
+
width: 100%;
|
|
148
|
+
text-decoration: none;
|
|
149
|
+
line-height: 1.4;
|
|
150
|
+
padding: calc(1.5rem - 1px);
|
|
151
|
+
border-radius: 8px;
|
|
152
|
+
color: white;
|
|
153
|
+
background-color: #23262d;
|
|
154
|
+
opacity: 0.8;
|
|
155
|
+
}
|
|
156
|
+
h2 {
|
|
157
|
+
margin: 0;
|
|
158
|
+
font-size: 1.25rem;
|
|
159
|
+
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
|
|
160
|
+
}
|
|
161
|
+
p {
|
|
162
|
+
margin-top: 0.5rem;
|
|
163
|
+
margin-bottom: 0;
|
|
164
|
+
}
|
|
165
|
+
.link-card:is(:hover, :focus-within) {
|
|
166
|
+
background-position: 0;
|
|
167
|
+
background-image: var(--accent-gradient);
|
|
168
|
+
}
|
|
169
|
+
.link-card:is(:hover, :focus-within) h2 {
|
|
170
|
+
color: rgb(var(--accent-light));
|
|
171
|
+
}
|
|
172
|
+
</style>
|
package/components/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// The `ts-ignore` comments here are necessary because we're importing this file inside the `astro:components`
|
|
2
|
-
// virtual module's types, which means that `tsc` will try to resolve these imports.
|
|
2
|
+
// virtual module's types, which means that `tsc` will try to resolve these imports.
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
export { default as Code } from './Code.astro';
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
export { default as Debug } from './Debug.astro';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
export { default as Welcome } from './Welcome.astro';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { decodeBase64, encodeBase64 } from "@oslojs/encoding";
|
|
2
2
|
import { yellow } from "kleur/colors";
|
|
3
3
|
import { defineMiddleware } from "../../core/middleware/index.js";
|
|
4
|
+
import { getOriginPathname } from "../../core/routing/rewrite.js";
|
|
4
5
|
import { ACTION_QUERY_PARAMS } from "../consts.js";
|
|
5
6
|
import { formContentTypes, hasContentType } from "./utils.js";
|
|
6
7
|
import { getAction } from "./virtual/get-action.js";
|
|
@@ -14,7 +15,7 @@ const onRequest = defineMiddleware(async (context, next) => {
|
|
|
14
15
|
if (context.request.method === "POST") {
|
|
15
16
|
console.warn(
|
|
16
17
|
yellow("[astro:actions]"),
|
|
17
|
-
|
|
18
|
+
"POST requests should not be sent to prerendered pages. If you're using Actions, disable prerendering with `export const prerender = false`."
|
|
18
19
|
);
|
|
19
20
|
}
|
|
20
21
|
return next();
|
|
@@ -66,7 +67,8 @@ async function handlePost({
|
|
|
66
67
|
if (contentType && hasContentType(contentType, formContentTypes)) {
|
|
67
68
|
formData = await request.clone().formData();
|
|
68
69
|
}
|
|
69
|
-
const
|
|
70
|
+
const { getActionResult, callAction, props, redirect, ...actionAPIContext } = context;
|
|
71
|
+
const action = baseAction.bind(actionAPIContext);
|
|
70
72
|
const actionResult = await action(formData);
|
|
71
73
|
if (context.url.searchParams.get(ACTION_QUERY_PARAMS.actionRedirect) === "false") {
|
|
72
74
|
return renderResult({
|
|
@@ -93,10 +95,14 @@ async function redirectWithResult({
|
|
|
93
95
|
);
|
|
94
96
|
context.cookies.set(ACTION_QUERY_PARAMS.actionPayload, cookieValue);
|
|
95
97
|
if (actionResult.error) {
|
|
96
|
-
const
|
|
97
|
-
if (!
|
|
98
|
+
const referer2 = context.request.headers.get("Referer");
|
|
99
|
+
if (!referer2) {
|
|
98
100
|
throw new Error("Internal: Referer unexpectedly missing from Action POST request.");
|
|
99
101
|
}
|
|
102
|
+
return context.redirect(referer2);
|
|
103
|
+
}
|
|
104
|
+
const referer = getOriginPathname(context.request);
|
|
105
|
+
if (referer) {
|
|
100
106
|
return context.redirect(referer);
|
|
101
107
|
}
|
|
102
108
|
return context.redirect(context.url.pathname);
|
|
@@ -23,7 +23,8 @@ const POST = async (context) => {
|
|
|
23
23
|
} else {
|
|
24
24
|
return new Response(null, { status: 415 });
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const { getActionResult, callAction, props, redirect, ...actionAPIContext } = context;
|
|
27
|
+
const action = baseAction.bind(actionAPIContext);
|
|
27
28
|
const result = await action(args);
|
|
28
29
|
const serialized = serializeActionResult(result);
|
|
29
30
|
if (serialized.type === "empty") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ActionNotFoundError } from "../../../core/errors/errors-data.js";
|
|
2
2
|
import { AstroError } from "../../../core/errors/errors.js";
|
|
3
3
|
async function getAction(path) {
|
|
4
|
-
const pathKeys = path.replace(
|
|
4
|
+
const pathKeys = path.replace(/^.*\/_actions\//, "").split(".").map((key) => decodeURIComponent(key));
|
|
5
5
|
let { server: actionLookup } = await import("astro:internal-actions");
|
|
6
6
|
if (actionLookup == null || !(typeof actionLookup === "object")) {
|
|
7
7
|
throw new TypeError(
|
|
@@ -18,6 +18,10 @@ async function loadLocalImage(src, url) {
|
|
|
18
18
|
fileUrl = pathToFileURL(removeQueryString(replaceFileSystemReferences(src)));
|
|
19
19
|
} else {
|
|
20
20
|
try {
|
|
21
|
+
const idx = url.pathname.indexOf("/_image");
|
|
22
|
+
if (idx > 0) {
|
|
23
|
+
src = src.slice(idx);
|
|
24
|
+
}
|
|
21
25
|
fileUrl = new URL("." + src, outDir);
|
|
22
26
|
const filePath = fileURLToPath(fileUrl);
|
|
23
27
|
if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
|
package/dist/assets/internal.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isRemotePath } from "@astrojs/internal-helpers/path";
|
|
1
2
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
2
3
|
import { DEFAULT_HASH_PROPS } from "./consts.js";
|
|
3
4
|
import { isLocalService } from "./services/service.js";
|
|
@@ -47,7 +48,7 @@ async function getImage(options, imageConfig) {
|
|
|
47
48
|
...options,
|
|
48
49
|
src: await resolveSrc(options.src)
|
|
49
50
|
};
|
|
50
|
-
if (options.inferSize && isRemoteImage(resolvedOptions.src)) {
|
|
51
|
+
if (options.inferSize && isRemoteImage(resolvedOptions.src) && isRemotePath(resolvedOptions.src)) {
|
|
51
52
|
const result = await inferRemoteSize(resolvedOptions.src);
|
|
52
53
|
resolvedOptions.width ??= result.width;
|
|
53
54
|
resolvedOptions.height ??= result.height;
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WithRequired } from '../type-utils.js';
|
|
1
|
+
import type { OmitPreservingIndexSignature, Simplify, WithRequired } from '../type-utils.js';
|
|
2
2
|
import type { VALID_INPUT_FORMATS, VALID_OUTPUT_FORMATS } from './consts.js';
|
|
3
3
|
import type { ImageService } from './services/service.js';
|
|
4
4
|
export type ImageQualityPreset = 'low' | 'mid' | 'high' | 'max' | (string & {});
|
|
@@ -48,12 +48,12 @@ export type SrcSetValue = UnresolvedSrcSetValue & {
|
|
|
48
48
|
/**
|
|
49
49
|
* A yet to be resolved image transform. Used by `getImage`
|
|
50
50
|
*/
|
|
51
|
-
export type UnresolvedImageTransform =
|
|
51
|
+
export type UnresolvedImageTransform = Simplify<OmitPreservingIndexSignature<ImageTransform, 'src'> & {
|
|
52
52
|
src: ImageMetadata | string | Promise<{
|
|
53
53
|
default: ImageMetadata;
|
|
54
54
|
}>;
|
|
55
55
|
inferSize?: boolean;
|
|
56
|
-
} & {
|
|
56
|
+
}> & {
|
|
57
57
|
[isESMImport]?: never;
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as vite from 'vite';
|
|
2
|
-
import type {
|
|
3
|
-
export default function assets({ settings
|
|
4
|
-
|
|
2
|
+
import type { AstroSettings } from '../types/astro.js';
|
|
3
|
+
export default function assets({ settings }: {
|
|
4
|
+
settings: AstroSettings;
|
|
5
5
|
}): vite.Plugin[];
|
|
@@ -62,12 +62,10 @@ const addStaticImageFactory = (settings) => {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
|
-
function assets({
|
|
66
|
-
settings,
|
|
67
|
-
mode
|
|
68
|
-
}) {
|
|
65
|
+
function assets({ settings }) {
|
|
69
66
|
let resolvedConfig;
|
|
70
67
|
let shouldEmitFile = false;
|
|
68
|
+
let isBuild = false;
|
|
71
69
|
globalThis.astroAsset = {
|
|
72
70
|
referencedImages: /* @__PURE__ */ new Set()
|
|
73
71
|
};
|
|
@@ -75,6 +73,9 @@ function assets({
|
|
|
75
73
|
// Expose the components and different utilities from `astro:assets`
|
|
76
74
|
{
|
|
77
75
|
name: "astro:assets",
|
|
76
|
+
config(_, env) {
|
|
77
|
+
isBuild = env.command === "build";
|
|
78
|
+
},
|
|
78
79
|
async resolveId(id) {
|
|
79
80
|
if (id === VIRTUAL_SERVICE_ID) {
|
|
80
81
|
return await this.resolve(settings.config.image.service.entrypoint);
|
|
@@ -112,9 +113,7 @@ function assets({
|
|
|
112
113
|
}
|
|
113
114
|
},
|
|
114
115
|
buildStart() {
|
|
115
|
-
if (
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
116
|
+
if (!isBuild) return;
|
|
118
117
|
globalThis.astroAsset.addStaticImage = addStaticImageFactory(settings);
|
|
119
118
|
},
|
|
120
119
|
// In build, rewrite paths to ESM imported images in code to their final location
|
package/dist/cli/add/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import { getDefaultExportOptions } from "magicast/helpers";
|
|
|
9
9
|
import preferredPM from "preferred-pm";
|
|
10
10
|
import prompts from "prompts";
|
|
11
11
|
import maxSatisfying from "semver/ranges/max-satisfying.js";
|
|
12
|
-
import { exec } from "tinyexec";
|
|
13
12
|
import yoctoSpinner from "yocto-spinner";
|
|
14
13
|
import {
|
|
15
14
|
loadTSConfig,
|
|
@@ -28,6 +27,7 @@ import { appendForwardSlash } from "../../core/path.js";
|
|
|
28
27
|
import { apply as applyPolyfill } from "../../core/polyfill.js";
|
|
29
28
|
import { ensureProcessNodeEnv, parseNpmName } from "../../core/util.js";
|
|
30
29
|
import { eventCliSession, telemetry } from "../../events/index.js";
|
|
30
|
+
import { exec } from "../exec.js";
|
|
31
31
|
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
|
|
32
32
|
import { fetchPackageJson, fetchPackageVersions } from "../install-package.js";
|
|
33
33
|
const ALIASES = /* @__PURE__ */ new Map([
|
|
@@ -73,7 +73,7 @@ export default async function seed() {
|
|
|
73
73
|
};
|
|
74
74
|
const OFFICIAL_ADAPTER_TO_IMPORT_MAP = {
|
|
75
75
|
netlify: "@astrojs/netlify",
|
|
76
|
-
vercel: "@astrojs/vercel
|
|
76
|
+
vercel: "@astrojs/vercel",
|
|
77
77
|
cloudflare: "@astrojs/cloudflare",
|
|
78
78
|
node: "@astrojs/node"
|
|
79
79
|
};
|
|
@@ -307,7 +307,9 @@ async function add(names, { flags }) {
|
|
|
307
307
|
logger.info("SKIP_FORMAT", msg.success(`Configuration up-to-date.`));
|
|
308
308
|
break;
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
case 3 /* failure */:
|
|
311
|
+
case 1 /* updated */:
|
|
312
|
+
case void 0: {
|
|
311
313
|
const list = integrations.map((integration) => ` - ${integration.packageName}`).join("\n");
|
|
312
314
|
logger.info(
|
|
313
315
|
"SKIP_FORMAT",
|
|
@@ -335,7 +337,7 @@ ${list}`
|
|
|
335
337
|
`Unknown error parsing tsconfig.json or jsconfig.json. Could not update TypeScript settings.`
|
|
336
338
|
);
|
|
337
339
|
}
|
|
338
|
-
|
|
340
|
+
case 1 /* updated */:
|
|
339
341
|
logger.info("SKIP_FORMAT", msg.success(`Successfully updated TypeScript settings`));
|
|
340
342
|
}
|
|
341
343
|
}
|
|
@@ -343,7 +345,7 @@ function isAdapter(integration) {
|
|
|
343
345
|
return integration.type === "adapter";
|
|
344
346
|
}
|
|
345
347
|
const toIdent = (name) => {
|
|
346
|
-
const ident = name.trim().replace(/[-_./]?astro(?:js)?[-_.]?/g, "").replace(/\.js/, "").replace(/[.\-_/]+([a-zA-Z])/g, (_, w) => w.toUpperCase()).replace(/^[^a-zA-Z$_]+/, "");
|
|
348
|
+
const ident = name.trim().replace(/[-_./]?astro(?:js)?[-_.]?/g, "").replace(/\.js/, "").replace(/[.\-_/]+([a-zA-Z])/g, (_, w) => w.toUpperCase()).replace(/^[^a-zA-Z$_]+/, "").replace(/@.*$/, "");
|
|
347
349
|
return `${ident[0].toLowerCase()}${ident.slice(1)}`;
|
|
348
350
|
};
|
|
349
351
|
function createPrettyError(err) {
|
package/dist/cli/build/index.js
CHANGED
|
@@ -9,6 +9,11 @@ async function build({ flags }) {
|
|
|
9
9
|
tables: {
|
|
10
10
|
Flags: [
|
|
11
11
|
["--outDir <directory>", `Specify the output directory for the build.`],
|
|
12
|
+
["--mode", `Specify the mode of the project. Defaults to "production".`],
|
|
13
|
+
[
|
|
14
|
+
"--devOutput",
|
|
15
|
+
"Output a development-based build similar to code transformed in `astro dev`."
|
|
16
|
+
],
|
|
12
17
|
[
|
|
13
18
|
"--force",
|
|
14
19
|
"Clear the content layer and content collection cache, forcing a full rebuild."
|
|
@@ -21,7 +26,7 @@ async function build({ flags }) {
|
|
|
21
26
|
return;
|
|
22
27
|
}
|
|
23
28
|
const inlineConfig = flagsToAstroInlineConfig(flags);
|
|
24
|
-
await _build(inlineConfig);
|
|
29
|
+
await _build(inlineConfig, { devOutput: !!flags.devOutput });
|
|
25
30
|
}
|
|
26
31
|
export {
|
|
27
32
|
build
|
package/dist/cli/dev/index.js
CHANGED
|
@@ -9,6 +9,7 @@ async function dev({ flags }) {
|
|
|
9
9
|
usage: "[...flags]",
|
|
10
10
|
tables: {
|
|
11
11
|
Flags: [
|
|
12
|
+
["--mode", `Specify the mode of the project. Defaults to "development".`],
|
|
12
13
|
["--port", `Specify which port to run on. Defaults to 4321.`],
|
|
13
14
|
["--host", `Listen on all addresses, including LAN and public addresses.`],
|
|
14
15
|
["--host <custom-address>", `Expose on a network IP address at <custom-address>`],
|
package/dist/cli/docs/open.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Result } from 'tinyexec';
|
|
2
2
|
export declare function openInBrowser(url: string): Promise<Result>;
|
package/dist/cli/docs/open.js
CHANGED
package/dist/cli/exec.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NonZeroExitError, x } from "tinyexec";
|
|
2
|
+
function exec(command, args, options) {
|
|
3
|
+
return x(command, args, {
|
|
4
|
+
throwOnError: true,
|
|
5
|
+
...options
|
|
6
|
+
}).then(
|
|
7
|
+
(o) => o,
|
|
8
|
+
(e) => {
|
|
9
|
+
if (e instanceof NonZeroExitError) {
|
|
10
|
+
const fullCommand = args?.length ? `${command} ${args.map((a) => a.includes(" ") ? `"${a}"` : a).join(" ")}` : command;
|
|
11
|
+
const message = `The command \`${fullCommand}\` exited with code ${e.exitCode}`;
|
|
12
|
+
const newError = new Error(message, e.cause ? { cause: e.cause } : void 0);
|
|
13
|
+
newError.stderr = e.output?.stderr;
|
|
14
|
+
newError.stdout = e.output?.stdout;
|
|
15
|
+
throw newError;
|
|
16
|
+
}
|
|
17
|
+
throw e;
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
exec
|
|
23
|
+
};
|
package/dist/cli/index.js
CHANGED
|
@@ -61,7 +61,7 @@ function resolveCommand(flags) {
|
|
|
61
61
|
"db",
|
|
62
62
|
"info",
|
|
63
63
|
"login",
|
|
64
|
-
"
|
|
64
|
+
"logout",
|
|
65
65
|
"link",
|
|
66
66
|
"init"
|
|
67
67
|
]);
|
|
@@ -101,8 +101,8 @@ async function runCommand(cmd, flags) {
|
|
|
101
101
|
}
|
|
102
102
|
case "sync": {
|
|
103
103
|
const { sync } = await import("./sync/index.js");
|
|
104
|
-
|
|
105
|
-
return
|
|
104
|
+
await sync({ flags });
|
|
105
|
+
return;
|
|
106
106
|
}
|
|
107
107
|
case "preferences": {
|
|
108
108
|
const { preferences } = await import("./preferences/index.js");
|
|
@@ -4,9 +4,9 @@ import ci from "ci-info";
|
|
|
4
4
|
import { bold, cyan, dim, magenta } from "kleur/colors";
|
|
5
5
|
import preferredPM from "preferred-pm";
|
|
6
6
|
import prompts from "prompts";
|
|
7
|
-
import { exec } from "tinyexec";
|
|
8
7
|
import whichPm from "which-pm";
|
|
9
8
|
import yoctoSpinner from "yocto-spinner";
|
|
9
|
+
import { exec } from "./exec.js";
|
|
10
10
|
const require2 = createRequire(import.meta.url);
|
|
11
11
|
async function getPackage(packageName, logger, options, otherDeps = []) {
|
|
12
12
|
try {
|
|
@@ -109,7 +109,13 @@ ${message}`
|
|
|
109
109
|
await exec(
|
|
110
110
|
installCommand.pm,
|
|
111
111
|
[installCommand.command, ...installCommand.flags, ...installCommand.dependencies],
|
|
112
|
-
{
|
|
112
|
+
{
|
|
113
|
+
nodeOptions: {
|
|
114
|
+
cwd,
|
|
115
|
+
// reset NODE_ENV to ensure install command run in dev mode
|
|
116
|
+
env: { NODE_ENV: void 0 }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
113
119
|
);
|
|
114
120
|
spinner.success();
|
|
115
121
|
return true;
|
package/dist/cli/sync/index.d.ts
CHANGED
package/dist/cli/sync/index.js
CHANGED
|
@@ -16,12 +16,7 @@ async function sync({ flags }) {
|
|
|
16
16
|
});
|
|
17
17
|
return 0;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
await _sync(flagsToAstroInlineConfig(flags), { telemetry: true });
|
|
21
|
-
return 0;
|
|
22
|
-
} catch (_) {
|
|
23
|
-
return 1;
|
|
24
|
-
}
|
|
19
|
+
await _sync(flagsToAstroInlineConfig(flags), { telemetry: true });
|
|
25
20
|
}
|
|
26
21
|
export {
|
|
27
22
|
sync
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SharpImageServiceConfig } from '../assets/services/sharp.js';
|
|
2
|
+
import type { ImageServiceConfig } from '../types/public/index.js';
|
|
3
|
+
export { defineConfig, getViteConfig } from './index.js';
|
|
4
|
+
export { envField } from '../env/config.js';
|
|
5
|
+
/**
|
|
6
|
+
* Return the configuration needed to use the Sharp-based image service
|
|
7
|
+
*/
|
|
8
|
+
export declare function sharpImageService(config?: SharpImageServiceConfig): ImageServiceConfig;
|
|
9
|
+
/**
|
|
10
|
+
* Return the configuration needed to use the passthrough image service. This image services does not perform
|
|
11
|
+
* any image transformations, and is mainly useful when your platform does not support other image services, or you are
|
|
12
|
+
* not using Astro's built-in image processing.
|
|
13
|
+
* See: https://docs.astro.build/en/guides/images/#configure-no-op-passthrough-service
|
|
14
|
+
*/
|
|
15
|
+
export declare function passthroughImageService(): ImageServiceConfig;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineConfig, getViteConfig } from "./index.js";
|
|
2
|
+
import { envField } from "../env/config.js";
|
|
3
|
+
function sharpImageService(config = {}) {
|
|
4
|
+
return {
|
|
5
|
+
entrypoint: "astro/assets/services/sharp",
|
|
6
|
+
config
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function passthroughImageService() {
|
|
10
|
+
return {
|
|
11
|
+
entrypoint: "astro/assets/services/noop",
|
|
12
|
+
config: {}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
defineConfig,
|
|
17
|
+
envField,
|
|
18
|
+
getViteConfig,
|
|
19
|
+
passthroughImageService,
|
|
20
|
+
sharpImageService
|
|
21
|
+
};
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { UserConfig as ViteUserConfig } from 'vite';
|
|
2
|
-
import type { AstroInlineConfig, AstroUserConfig } from '../types/public/config.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import type { UserConfig as ViteUserConfig, UserConfigFn as ViteUserConfigFn } from 'vite';
|
|
2
|
+
import type { AstroInlineConfig, AstroUserConfig, Locales } from '../types/public/config.js';
|
|
3
|
+
/**
|
|
4
|
+
* See the full Astro Configuration API Documentation
|
|
5
|
+
* https://astro.build/config
|
|
6
|
+
*/
|
|
7
|
+
export declare function defineConfig<const TLocales extends Locales = never>(config: AstroUserConfig<TLocales>): AstroUserConfig<TLocales>;
|
|
8
|
+
/**
|
|
9
|
+
* Use Astro to generate a fully resolved Vite config
|
|
10
|
+
*/
|
|
11
|
+
export declare function getViteConfig(userViteConfig: ViteUserConfig, inlineAstroConfig?: AstroInlineConfig): ViteUserConfigFn;
|
package/dist/config/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Logger } from "../core/logger/core.js";
|
|
2
1
|
import { createRouteManifest } from "../core/routing/index.js";
|
|
3
2
|
import { createDevelopmentManifest } from "../vite-plugin-astro-server/plugin.js";
|
|
4
3
|
function defineConfig(config) {
|
|
@@ -6,11 +5,11 @@ function defineConfig(config) {
|
|
|
6
5
|
}
|
|
7
6
|
function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
|
|
8
7
|
return async ({ mode, command }) => {
|
|
9
|
-
const cmd = command === "serve" ? "dev" :
|
|
8
|
+
const cmd = command === "serve" ? "dev" : "build";
|
|
10
9
|
const [
|
|
11
10
|
fs,
|
|
12
11
|
{ mergeConfig },
|
|
13
|
-
{
|
|
12
|
+
{ createNodeLogger },
|
|
14
13
|
{ resolveConfig, createSettings },
|
|
15
14
|
{ createVite },
|
|
16
15
|
{ runHookConfigSetup, runHookConfigDone },
|
|
@@ -18,16 +17,13 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
|
|
|
18
17
|
] = await Promise.all([
|
|
19
18
|
import("node:fs"),
|
|
20
19
|
import("vite"),
|
|
21
|
-
import("../core/
|
|
20
|
+
import("../core/config/logging.js"),
|
|
22
21
|
import("../core/config/index.js"),
|
|
23
22
|
import("../core/create-vite.js"),
|
|
24
23
|
import("../integrations/hooks.js"),
|
|
25
24
|
import("./vite-plugin-content-listen.js")
|
|
26
25
|
]);
|
|
27
|
-
const logger =
|
|
28
|
-
dest: nodeLogDestination,
|
|
29
|
-
level: "info"
|
|
30
|
-
});
|
|
26
|
+
const logger = createNodeLogger(inlineAstroConfig);
|
|
31
27
|
const { astroConfig: config } = await resolveConfig(inlineAstroConfig, cmd);
|
|
32
28
|
let settings = await createSettings(config, userViteConfig.root);
|
|
33
29
|
settings = await runHookConfigSetup({ settings, command: cmd, logger });
|
|
@@ -35,13 +31,12 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
|
|
|
35
31
|
const devSSRManifest = createDevelopmentManifest(settings);
|
|
36
32
|
const viteConfig = await createVite(
|
|
37
33
|
{
|
|
38
|
-
mode,
|
|
39
34
|
plugins: [
|
|
40
35
|
// Initialize the content listener
|
|
41
36
|
astroContentListenPlugin({ settings, logger, fs })
|
|
42
37
|
]
|
|
43
38
|
},
|
|
44
|
-
{ settings, logger, mode, sync: false, manifest, ssrManifest: devSSRManifest }
|
|
39
|
+
{ settings, command: cmd, logger, mode, sync: false, manifest, ssrManifest: devSSRManifest }
|
|
45
40
|
);
|
|
46
41
|
await runHookConfigDone({ settings, logger });
|
|
47
42
|
return mergeConfig(viteConfig, userViteConfig);
|