astro 1.6.10 → 1.6.11
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/astro-jsx.d.ts +4 -0
- package/dist/core/build/vite-plugin-analyzer.js +3 -5
- package/dist/core/compile/compile.js +7 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/index.js +3 -3
- package/dist/core/errors/errors-data.d.ts +341 -21
- package/dist/core/errors/errors-data.js +68 -38
- package/dist/core/errors/errors.d.ts +3 -1
- package/dist/core/errors/errors.js +6 -5
- package/dist/core/errors/utils.d.ts +43 -13
- package/dist/core/messages.js +2 -2
- package/dist/core/path.d.ts +1 -0
- package/dist/core/path.js +5 -0
- package/dist/core/render/result.js +3 -5
- package/dist/core/render/route-cache.js +1 -1
- package/dist/core/routing/validation.js +3 -3
- package/dist/runtime/server/hydration.js +1 -4
- package/dist/vite-plugin-jsx/index.js +2 -0
- package/package.json +1 -1
package/astro-jsx.d.ts
CHANGED
|
@@ -663,6 +663,7 @@ declare namespace astroHTML.JSX {
|
|
|
663
663
|
allow?: string | undefined | null;
|
|
664
664
|
allowfullscreen?: boolean | string | undefined | null;
|
|
665
665
|
allowtransparency?: boolean | string | undefined | null;
|
|
666
|
+
fetchpriority?: 'auto' | 'high' | 'low' | undefined | null;
|
|
666
667
|
/** @deprecated */
|
|
667
668
|
frameborder?: number | string | undefined | null;
|
|
668
669
|
height?: number | string | undefined | null;
|
|
@@ -686,6 +687,7 @@ declare namespace astroHTML.JSX {
|
|
|
686
687
|
alt?: string | undefined | null;
|
|
687
688
|
crossorigin?: 'anonymous' | 'use-credentials' | '' | undefined | null;
|
|
688
689
|
decoding?: 'async' | 'auto' | 'sync' | undefined | null;
|
|
690
|
+
fetchpriority?: 'auto' | 'high' | 'low' | undefined | null;
|
|
689
691
|
height?: number | string | undefined | null;
|
|
690
692
|
loading?: 'eager' | 'lazy' | undefined | null;
|
|
691
693
|
referrerpolicy?: HTMLAttributeReferrerPolicy | undefined | null;
|
|
@@ -784,6 +786,7 @@ declare namespace astroHTML.JSX {
|
|
|
784
786
|
crossorigin?: boolean | string | undefined | null;
|
|
785
787
|
href?: string | URL | undefined | null;
|
|
786
788
|
hreflang?: string | undefined | null;
|
|
789
|
+
fetchpriority?: 'auto' | 'high' | 'low' | undefined | null;
|
|
787
790
|
integrity?: string | undefined | null;
|
|
788
791
|
media?: string | undefined | null;
|
|
789
792
|
imageSrcSet?: string | undefined | null;
|
|
@@ -893,6 +896,7 @@ declare namespace astroHTML.JSX {
|
|
|
893
896
|
charset?: string | undefined | null;
|
|
894
897
|
crossorigin?: string | undefined | null;
|
|
895
898
|
defer?: boolean | string | undefined | null;
|
|
899
|
+
fetchpriority?: 'auto' | 'high' | 'low' | undefined | null;
|
|
896
900
|
integrity?: string | undefined | null;
|
|
897
901
|
nomodule?: boolean | string | undefined | null;
|
|
898
902
|
nonce?: string | undefined | null;
|
|
@@ -75,11 +75,9 @@ function vitePluginAnalyzer(internals) {
|
|
|
75
75
|
const cid = c.resolvedPath ? decodeURI(c.resolvedPath) : c.specifier;
|
|
76
76
|
internals.discoveredClientOnlyComponents.add(cid);
|
|
77
77
|
clientOnlys.push(cid);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
clientOnlys.push(resolvedId.id);
|
|
82
|
-
}
|
|
78
|
+
const resolvedId = await this.resolve(c.specifier, id);
|
|
79
|
+
if (resolvedId) {
|
|
80
|
+
clientOnlys.push(resolvedId.id);
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
for (const [pageInfo] of getTopLevelPages(id, this)) {
|
|
@@ -61,13 +61,17 @@ async function compile({
|
|
|
61
61
|
return result;
|
|
62
62
|
case 1: {
|
|
63
63
|
let error = cssTransformErrors[0];
|
|
64
|
-
if (!error.
|
|
65
|
-
error.
|
|
64
|
+
if (!error.errorCode) {
|
|
65
|
+
error.errorCode = AstroErrorData.UnknownCSSError.code;
|
|
66
66
|
}
|
|
67
67
|
throw cssTransformErrors[0];
|
|
68
68
|
}
|
|
69
69
|
default: {
|
|
70
|
-
throw new AggregateError({
|
|
70
|
+
throw new AggregateError({
|
|
71
|
+
...cssTransformErrors[0],
|
|
72
|
+
code: cssTransformErrors[0].errorCode,
|
|
73
|
+
errors: cssTransformErrors
|
|
74
|
+
});
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
});
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -30,7 +30,7 @@ async function dev(settings, options) {
|
|
|
30
30
|
isRestart: options.isRestart
|
|
31
31
|
})
|
|
32
32
|
);
|
|
33
|
-
const currentVersion = "1.6.
|
|
33
|
+
const currentVersion = "1.6.11";
|
|
34
34
|
if (currentVersion.includes("-")) {
|
|
35
35
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
36
36
|
}
|
|
@@ -31,8 +31,8 @@ function createAPIContext({
|
|
|
31
31
|
if (!(clientAddressSymbol in request)) {
|
|
32
32
|
if (adapterName) {
|
|
33
33
|
throw new AstroError({
|
|
34
|
-
...AstroErrorData.
|
|
35
|
-
message: AstroErrorData.
|
|
34
|
+
...AstroErrorData.ClientAddressNotAvailable,
|
|
35
|
+
message: AstroErrorData.ClientAddressNotAvailable.message(adapterName)
|
|
36
36
|
});
|
|
37
37
|
} else {
|
|
38
38
|
throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
|
|
@@ -87,7 +87,7 @@ function isRedirect(statusCode) {
|
|
|
87
87
|
}
|
|
88
88
|
function throwIfRedirectNotAllowed(response, config) {
|
|
89
89
|
if (config.output !== "server" && isRedirect(response.status)) {
|
|
90
|
-
throw new AstroError(AstroErrorData.
|
|
90
|
+
throw new AstroError(AstroErrorData.StaticRedirectNotAvailable);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
export {
|
|
@@ -1,132 +1,452 @@
|
|
|
1
1
|
export declare const AstroErrorData: {
|
|
2
2
|
readonly UnknownCompilerError: {
|
|
3
|
+
readonly title: "Unknown compiler error.";
|
|
3
4
|
readonly code: 1000;
|
|
4
5
|
};
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @docs
|
|
8
|
+
* @kind heading
|
|
9
|
+
* @name Astro Errors
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @docs
|
|
13
|
+
* @see
|
|
14
|
+
* - [Enabling SSR in Your Project](https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project)
|
|
15
|
+
* - [Astro.redirect](https://docs.astro.build/en/guides/server-side-rendering/#astroredirect)
|
|
16
|
+
* @description
|
|
17
|
+
* The `Astro.redirect` function is only available when [Server-side rendering](/en/guides/server-side-rendering/) is enabled.
|
|
18
|
+
*
|
|
19
|
+
* To redirect on a static website, the [meta refresh attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) can be used. Certain hosts also provide config-based redirects (ex: [Netlify redirects](https://docs.netlify.com/routing/redirects/)).
|
|
20
|
+
*/
|
|
21
|
+
readonly StaticRedirectNotAvailable: {
|
|
22
|
+
readonly title: "`Astro.redirect` is not available in static mode.";
|
|
6
23
|
readonly code: 3001;
|
|
7
|
-
readonly message: "Redirects are only available when using output: 'server'
|
|
24
|
+
readonly message: "Redirects are only available when using `output: 'server'`. Update your Astro config if you need SSR features.";
|
|
8
25
|
readonly hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR.";
|
|
9
26
|
};
|
|
10
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @docs
|
|
29
|
+
* @see
|
|
30
|
+
* - [Official integrations](https://docs.astro.build/en/guides/integrations-guide/#official-integrations)
|
|
31
|
+
* - [Astro.clientAddress](https://docs.astro.build/en/reference/api-reference/#astroclientaddress)
|
|
32
|
+
* @description
|
|
33
|
+
* The adapter you.'re using unfortunately does not support `Astro.clientAddress`.
|
|
34
|
+
*/
|
|
35
|
+
readonly ClientAddressNotAvailable: {
|
|
36
|
+
readonly title: "`Astro.clientAddress` is not available in current adapter.";
|
|
11
37
|
readonly code: 3002;
|
|
12
38
|
readonly message: (adapterName: string) => string;
|
|
13
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* @docs
|
|
42
|
+
* @see
|
|
43
|
+
* - [Enabling SSR in Your Project](https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project)
|
|
44
|
+
* - [Astro.clientAddress](https://docs.astro.build/en/reference/api-reference/#astroclientaddress)
|
|
45
|
+
* @description
|
|
46
|
+
* The `Astro.clientAddress` property is only available when [Server-side rendering](https://docs.astro.build/en/guides/server-side-rendering/) is enabled.
|
|
47
|
+
*
|
|
48
|
+
* To get the user's IP address in static mode, different APIs such as [Ipify](https://www.ipify.org/) can be used in a [Client-side script](https://docs.astro.build/en/core-concepts/astro-components/#client-side-scripts) or it may be possible to get the user's IP using a serverless function hosted on your hosting provider.
|
|
49
|
+
*/
|
|
14
50
|
readonly StaticClientAddressNotAvailable: {
|
|
51
|
+
readonly title: "`Astro.clientAddress` is not available in static mode.";
|
|
15
52
|
readonly code: 3003;
|
|
16
|
-
readonly message: "Astro.clientAddress is only available when using output: 'server'
|
|
53
|
+
readonly message: "`Astro.clientAddress` is only available when using `output: 'server'`. Update your Astro config if you need SSR features.";
|
|
17
54
|
readonly hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR.";
|
|
18
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* @docs
|
|
58
|
+
* @see
|
|
59
|
+
* - [getStaticPaths()](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
|
|
60
|
+
* @description
|
|
61
|
+
* A [dynamic route](https://docs.astro.build/en/core-concepts/routing/#dynamic-routes) was matched, but no corresponding path was found for the requested parameters. This is often caused by a typo in either the generated or the requested path.
|
|
62
|
+
*/
|
|
19
63
|
readonly NoMatchingStaticPathFound: {
|
|
64
|
+
readonly title: "No static path found for requested path.";
|
|
20
65
|
readonly code: 3004;
|
|
21
66
|
readonly message: (pathName: string) => string;
|
|
22
67
|
readonly hint: (possibleRoutes: string[]) => string;
|
|
23
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* @docs
|
|
71
|
+
* @message Route returned a `RETURNED_VALUE`. Only a Response can be returned from Astro files.
|
|
72
|
+
* @see
|
|
73
|
+
* - [Response](https://docs.astro.build/en/guides/server-side-rendering/#response)
|
|
74
|
+
* @description
|
|
75
|
+
* Only instances of [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned inside Astro files.
|
|
76
|
+
* ```astro title="pages/login.astro"
|
|
77
|
+
* ---
|
|
78
|
+
* return new Response(null, {
|
|
79
|
+
* status: 404,
|
|
80
|
+
* statusText: 'Not found'
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* // Alternatively, for redirects, Astro.redirect also returns an instance of Response
|
|
84
|
+
* return Astro.redirect('/login');
|
|
85
|
+
* ---
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
24
89
|
readonly OnlyResponseCanBeReturned: {
|
|
90
|
+
readonly title: "Invalid type returned by Astro page.";
|
|
25
91
|
readonly code: 3005;
|
|
26
92
|
readonly message: (route: string | undefined, returnedValue: string) => string;
|
|
27
93
|
readonly hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information.";
|
|
28
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* @docs
|
|
97
|
+
* @see
|
|
98
|
+
* - [`client:media`](https://docs.astro.build/en/reference/directives-reference/#clientmedia)
|
|
99
|
+
* @description
|
|
100
|
+
* A [media query](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries) parameter is required when using the `client:media` directive.
|
|
101
|
+
*
|
|
102
|
+
* ```astro
|
|
103
|
+
* <Counter client:media="(max-width: 640px)" />
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
29
106
|
readonly MissingMediaQueryDirective: {
|
|
107
|
+
readonly title: "Missing value for `client:media` directive.";
|
|
30
108
|
readonly code: 3006;
|
|
31
|
-
readonly message: (
|
|
109
|
+
readonly message: "Media query not provided for `client:media` directive. A media query similar to `client:media=\"(max-width: 600px)\"` must be provided";
|
|
32
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* @docs
|
|
113
|
+
* @message Unable to render `COMPONENT_NAME`. There are `RENDERER_COUNT` renderer(s) configured in your `astro.config.mjs` file, but none were able to server-side render `COMPONENT_NAME`.
|
|
114
|
+
* @see
|
|
115
|
+
* - [Frameworks components](https://docs.astro.build/en/core-concepts/framework-components/)
|
|
116
|
+
* - [UI Frameworks](https://docs.astro.build/en/guides/integrations-guide/#official-integrations)
|
|
117
|
+
* @description
|
|
118
|
+
* None of the installed integrations were able to render the component you imported. Make sure to install the appropriate integration for the type of component you are trying to include in your page.
|
|
119
|
+
*
|
|
120
|
+
* For JSX / TSX files, [@astrojs/react](https://docs.astro.build/en/guides/integrations-guide/react/), [@astrojs/preact](https://docs.astro.build/en/guides/integrations-guide/preact/) or [@astrojs/solid-js](https://docs.astro.build/en/guides/integrations-guide/solid-js/) can be used. For Vue and Svelte files, the [@astrojs/vue](https://docs.astro.build/en/guides/integrations-guide/vue/) and [@astrojs/svelte](https://docs.astro.build/en/guides/integrations-guide/svelte/) integrations can be used respectively
|
|
121
|
+
*/
|
|
33
122
|
readonly NoMatchingRenderer: {
|
|
123
|
+
readonly title: "No matching renderer found.";
|
|
34
124
|
readonly code: 3007;
|
|
35
125
|
readonly message: (componentName: string, componentExtension: string | undefined, plural: boolean, validRenderersCount: number) => string;
|
|
36
126
|
readonly hint: (probableRenderers: string) => string;
|
|
37
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* @docs
|
|
130
|
+
* @see
|
|
131
|
+
* - [addRenderer option](https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option)
|
|
132
|
+
* - [Hydrating framework components](https://docs.astro.build/en/core-concepts/framework-components/#hydrating-interactive-components)
|
|
133
|
+
* @description
|
|
134
|
+
* Astro tried to hydrate a component on the client, but the renderer used does not provide a client entrypoint to use to hydrate.
|
|
135
|
+
*
|
|
136
|
+
*/
|
|
38
137
|
readonly NoClientEntrypoint: {
|
|
138
|
+
readonly title: "No client entrypoint specified in renderer.";
|
|
39
139
|
readonly code: 3008;
|
|
40
140
|
readonly message: (componentName: string, clientDirective: string, rendererName: string) => string;
|
|
41
141
|
readonly hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer.";
|
|
42
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* @docs
|
|
145
|
+
* @see
|
|
146
|
+
* - [`client:only`](https://docs.astro.build/en/reference/directives-reference/#clientonly)
|
|
147
|
+
* @description
|
|
148
|
+
*
|
|
149
|
+
* `client:only` components are not ran on the server, as such Astro does not know (and cannot guess) which renderer to use and require a hint. Like such:
|
|
150
|
+
*
|
|
151
|
+
* ```astro
|
|
152
|
+
* <SomeReactComponent client:only="react" />
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
43
155
|
readonly NoClientOnlyHint: {
|
|
156
|
+
readonly title: "Missing hint on client:only directive.";
|
|
44
157
|
readonly code: 3009;
|
|
45
158
|
readonly message: (componentName: string) => string;
|
|
46
159
|
readonly hint: (probableRenderers: string) => string;
|
|
47
160
|
};
|
|
48
|
-
|
|
161
|
+
/**
|
|
162
|
+
* @docs
|
|
163
|
+
* @see
|
|
164
|
+
* - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
|
|
165
|
+
* - [`params`](https://docs.astro.build/en/reference/api-reference/#params)
|
|
166
|
+
* @description
|
|
167
|
+
* The `params` property in `getStaticPaths`'s return value (an array of objects) should also be an object.
|
|
168
|
+
*
|
|
169
|
+
* ```astro title="pages/blog/[id].astro"
|
|
170
|
+
* ---
|
|
171
|
+
* export async function getStaticPaths() {
|
|
172
|
+
* return [
|
|
173
|
+
* { params: { slug: "blog" } },
|
|
174
|
+
* { params: { slug: "about" } }
|
|
175
|
+
* ];
|
|
176
|
+
*}
|
|
177
|
+
*---
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
readonly InvalidGetStaticPathParam: {
|
|
181
|
+
readonly title: "Invalid value returned by a `getStaticPaths` path.";
|
|
49
182
|
readonly code: 3010;
|
|
50
183
|
readonly message: (paramType: any) => string;
|
|
51
184
|
readonly hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths.";
|
|
52
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* @docs
|
|
188
|
+
* @see
|
|
189
|
+
* - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
|
|
190
|
+
* - [`params`](https://docs.astro.build/en/reference/api-reference/#params)
|
|
191
|
+
* @description
|
|
192
|
+
* `getStaticPaths`'s return value must be an array of objects.
|
|
193
|
+
*
|
|
194
|
+
* ```ts title="pages/blog/[id].astro"
|
|
195
|
+
* export async function getStaticPaths() {
|
|
196
|
+
* return [ // <-- Array
|
|
197
|
+
* { params: { slug: "blog" } },
|
|
198
|
+
* { params: { slug: "about" } }
|
|
199
|
+
* ];
|
|
200
|
+
*}
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
53
203
|
readonly InvalidGetStaticPathsReturn: {
|
|
204
|
+
readonly title: "Invalid value returned by getStaticPaths.";
|
|
54
205
|
readonly code: 3011;
|
|
55
206
|
readonly message: (returnType: any) => string;
|
|
56
207
|
readonly hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths.";
|
|
57
208
|
};
|
|
58
|
-
|
|
209
|
+
/**
|
|
210
|
+
* @docs
|
|
211
|
+
* @see
|
|
212
|
+
* - [RSS Guide](https://docs.astro.build/en/guides/rss/)
|
|
213
|
+
* @description
|
|
214
|
+
* `getStaticPaths` no longer expose an helper for generating a RSS feed. We recommend migrating to the [@astrojs/rss](https://docs.astro.build/en/guides/rss/#setting-up-astrojsrss)integration instead.
|
|
215
|
+
*/
|
|
216
|
+
readonly GetStaticPathsRemovedRSSHelper: {
|
|
217
|
+
readonly title: "getStaticPaths RSS helper is not available anymore.";
|
|
59
218
|
readonly code: 3012;
|
|
60
|
-
readonly message: "The RSS helper has been removed from getStaticPaths
|
|
219
|
+
readonly message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.";
|
|
61
220
|
readonly hint: "See https://docs.astro.build/en/guides/rss/ for more information.";
|
|
62
221
|
};
|
|
222
|
+
/**
|
|
223
|
+
* @docs
|
|
224
|
+
* @see
|
|
225
|
+
* - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
|
|
226
|
+
* - [`params`](https://docs.astro.build/en/reference/api-reference/#params)
|
|
227
|
+
* @description
|
|
228
|
+
* Every route specified by `getStaticPaths` require a `params` property specifying the path parameters needed to match the route.
|
|
229
|
+
*
|
|
230
|
+
* For instance, the following code:
|
|
231
|
+
* ```astro title="pages/blog/[id].astro"
|
|
232
|
+
* ---
|
|
233
|
+
* export async function getStaticPaths() {
|
|
234
|
+
* return [
|
|
235
|
+
* { params: { id: '1' } }
|
|
236
|
+
* ];
|
|
237
|
+
* }
|
|
238
|
+
* ---
|
|
239
|
+
* ```
|
|
240
|
+
* Will create the following route: `site.com/blog/1`.
|
|
241
|
+
*/
|
|
63
242
|
readonly GetStaticPathsExpectedParams: {
|
|
243
|
+
readonly title: "Missing params property on `getStaticPaths` route.";
|
|
64
244
|
readonly code: 3013;
|
|
65
|
-
readonly message: "Missing or empty required params property on getStaticPaths route";
|
|
245
|
+
readonly message: "Missing or empty required `params` property on `getStaticPaths` route.";
|
|
66
246
|
readonly hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths.";
|
|
67
247
|
};
|
|
248
|
+
/**
|
|
249
|
+
* @docs
|
|
250
|
+
* @see
|
|
251
|
+
* - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
|
|
252
|
+
* - [`params`](https://docs.astro.build/en/reference/api-reference/#params)
|
|
253
|
+
* @description
|
|
254
|
+
* Since `params` are encoded into the URL, only certain types are supported as values.
|
|
255
|
+
*
|
|
256
|
+
* ```astro title="/route/[id].astro"
|
|
257
|
+
* ---
|
|
258
|
+
* export async function getStaticPaths() {
|
|
259
|
+
* return [
|
|
260
|
+
* { params: { id: '1' } } // Works
|
|
261
|
+
* { params: { id: 2 } } // Works
|
|
262
|
+
* { params: { id: false } } // Does not work
|
|
263
|
+
* ];
|
|
264
|
+
* }
|
|
265
|
+
* ---
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* In routes using [rest parameters](https://docs.astro.build/en/core-concepts/routing/#rest-parameters), `undefined` can be used to represent a path with no parameters passed in the URL:
|
|
269
|
+
*
|
|
270
|
+
* ```astro title="/route/[...id].astro"
|
|
271
|
+
* ---
|
|
272
|
+
* export async function getStaticPaths() {
|
|
273
|
+
* return [
|
|
274
|
+
* { params: { id: 1 } } // /route/1
|
|
275
|
+
* { params: { id: 2 } } // /route/2
|
|
276
|
+
* { params: { id: undefined } } // /route/
|
|
277
|
+
* ];
|
|
278
|
+
* }
|
|
279
|
+
* ---
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
68
282
|
readonly GetStaticPathsInvalidRouteParam: {
|
|
283
|
+
readonly title: "Invalid value for `getStaticPaths` route parameter.";
|
|
69
284
|
readonly code: 3014;
|
|
70
|
-
readonly message: (key: string, value: any) => string;
|
|
285
|
+
readonly message: (key: string, value: any, valueType: any) => string;
|
|
71
286
|
readonly hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths.";
|
|
72
287
|
};
|
|
288
|
+
/**
|
|
289
|
+
* @docs
|
|
290
|
+
* @see
|
|
291
|
+
* - [Dynamic Routes](https://docs.astro.build/en/core-concepts/routing/#dynamic-routes)
|
|
292
|
+
* - [`getStaticPaths()`](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
|
|
293
|
+
* - [Server-side Rendering](https://docs.astro.build/en/guides/server-side-rendering/)
|
|
294
|
+
* @description
|
|
295
|
+
* In [Static Mode](https://docs.astro.build/en/core-concepts/routing/#static-ssg-mode), all routes must be determined at build time. As such, dynamic routes must `export` a `getStaticPaths` function returning the different paths to generate.
|
|
296
|
+
*/
|
|
73
297
|
readonly GetStaticPathsRequired: {
|
|
298
|
+
readonly title: "`getStaticPaths()` function required for dynamic routes.";
|
|
74
299
|
readonly code: 3015;
|
|
75
|
-
readonly message: "getStaticPaths() function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.";
|
|
300
|
+
readonly message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.";
|
|
76
301
|
readonly hint: "See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.\n\nAlternatively, set `output: \"server\"` in your Astro config file to switch to a non-static server build.\nSee https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.";
|
|
77
302
|
};
|
|
303
|
+
/**
|
|
304
|
+
* @docs
|
|
305
|
+
* @see
|
|
306
|
+
* - [Named slots](https://docs.astro.build/en/core-concepts/astro-components/#named-slots)
|
|
307
|
+
* @description
|
|
308
|
+
* Certain words cannot be used for slot names due to being already used internally.
|
|
309
|
+
*/
|
|
78
310
|
readonly ReservedSlotName: {
|
|
311
|
+
readonly title: "Invalid slot name.";
|
|
79
312
|
readonly code: 3016;
|
|
80
313
|
readonly message: (slotName: string) => string;
|
|
81
314
|
};
|
|
315
|
+
/**
|
|
316
|
+
* @docs
|
|
317
|
+
* @see
|
|
318
|
+
* - [Server-side Rendering](https://docs.astro.build/en/guides/server-side-rendering/)
|
|
319
|
+
* - [Adding an Adapter](https://docs.astro.build/en/guides/server-side-rendering/#adding-an-adapter)
|
|
320
|
+
* @description
|
|
321
|
+
* To use server-side rendering, an adapter needs to be installed so Astro knows how to generate the proper output for your targetted deployment platform.
|
|
322
|
+
*/
|
|
82
323
|
readonly NoAdapterInstalled: {
|
|
324
|
+
readonly title: "Cannot use Server-side Rendering without an adapter.";
|
|
83
325
|
readonly code: 3017;
|
|
84
326
|
readonly message: "Cannot use `output: 'server'` without an adapter. Please install and configure the appropriate server adapter for your final deployment.";
|
|
85
327
|
readonly hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information.";
|
|
86
328
|
};
|
|
329
|
+
/**
|
|
330
|
+
* @docs
|
|
331
|
+
* @description
|
|
332
|
+
* No import statement was found for one of the components. If there is an import statement, make sure you are using the same identifier in both the imports and the component usage.
|
|
333
|
+
*/
|
|
87
334
|
readonly NoMatchingImport: {
|
|
335
|
+
readonly title: "No import found for component.";
|
|
88
336
|
readonly code: 3018;
|
|
89
337
|
readonly message: (componentName: string) => string;
|
|
90
338
|
readonly hint: "Please make sure the component is properly imported.";
|
|
91
339
|
};
|
|
92
|
-
readonly UnknownCSSError: {
|
|
93
|
-
readonly code: 4000;
|
|
94
|
-
};
|
|
95
|
-
readonly CSSSyntaxError: {
|
|
96
|
-
readonly code: 4001;
|
|
97
|
-
};
|
|
98
340
|
readonly UnknownViteError: {
|
|
99
|
-
readonly
|
|
341
|
+
readonly title: "Unknown Vite Error.";
|
|
342
|
+
readonly code: 4000;
|
|
100
343
|
};
|
|
344
|
+
/**
|
|
345
|
+
* @docs
|
|
346
|
+
* @see
|
|
347
|
+
* - [Type Imports](https://docs.astro.build/en/guides/typescript/#type-imports)
|
|
348
|
+
* @description
|
|
349
|
+
* Astro could not import the requested file. Oftentimes, this is caused by the import path being wrong (either because the file does not exist, or there is a typo in the path)
|
|
350
|
+
*
|
|
351
|
+
* This message can also appear when a type is imported without specifying that it is a [type import](https://docs.astro.build/en/guides/typescript/#type-imports).
|
|
352
|
+
*/
|
|
101
353
|
readonly FailedToLoadModuleSSR: {
|
|
102
|
-
readonly
|
|
354
|
+
readonly title: "Could not import file.";
|
|
355
|
+
readonly code: 4001;
|
|
103
356
|
readonly message: (importName: string) => string;
|
|
104
357
|
readonly hint: "This is often caused by a typo in the import path. Please make sure the file exists.";
|
|
105
358
|
};
|
|
359
|
+
/**
|
|
360
|
+
* @docs
|
|
361
|
+
* @see
|
|
362
|
+
* - [Glob Patterns](https://docs.astro.build/en/guides/imports/#glob-patterns)
|
|
363
|
+
* @description
|
|
364
|
+
* Astro encountered an invalid glob pattern. This is often caused by the glob pattern not being a valid file path.
|
|
365
|
+
*/
|
|
106
366
|
readonly InvalidGlob: {
|
|
107
|
-
readonly
|
|
367
|
+
readonly title: "Invalid glob pattern.";
|
|
368
|
+
readonly code: 4002;
|
|
108
369
|
readonly message: (globPattern: string) => string;
|
|
109
370
|
readonly hint: "See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns.";
|
|
110
371
|
};
|
|
372
|
+
/**
|
|
373
|
+
* @docs
|
|
374
|
+
* @kind heading
|
|
375
|
+
* @name CSS Errors
|
|
376
|
+
*/
|
|
377
|
+
readonly UnknownCSSError: {
|
|
378
|
+
readonly title: "Unknown CSS Error.";
|
|
379
|
+
readonly code: 5000;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* @docs
|
|
383
|
+
* @message
|
|
384
|
+
* **Example error messages:**<br/>
|
|
385
|
+
* CSSSyntaxError: Missed semicolon<br/>
|
|
386
|
+
* CSSSyntaxError: Unclosed string<br/>
|
|
387
|
+
* @description
|
|
388
|
+
* Astro encountered an error while parsing your CSS, due to a syntax error. This is often caused by a missing semicolon
|
|
389
|
+
*/
|
|
390
|
+
readonly CSSSyntaxError: {
|
|
391
|
+
readonly title: "CSS Syntax Error.";
|
|
392
|
+
readonly code: 5001;
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* @docs
|
|
396
|
+
* @kind heading
|
|
397
|
+
* @name Markdown Errors
|
|
398
|
+
*/
|
|
111
399
|
readonly UnknownMarkdownError: {
|
|
400
|
+
readonly title: "Unknown Markdown Error.";
|
|
112
401
|
readonly code: 6000;
|
|
113
402
|
};
|
|
403
|
+
/**
|
|
404
|
+
* @docs
|
|
405
|
+
* @message
|
|
406
|
+
* **Example error messages:**<br/>
|
|
407
|
+
* can not read an implicit mapping pair; a colon is missed<br/>
|
|
408
|
+
* unexpected end of the stream within a double quoted scalar<br/>
|
|
409
|
+
* can not read a block mapping entry; a multiline key may not be an implicit key
|
|
410
|
+
* @description
|
|
411
|
+
* Astro encountered an error while parsing the frontmatter of your Markdown file.
|
|
412
|
+
* This is often caused by a mistake in the syntax, such as a missing colon or a missing end quote.
|
|
413
|
+
*/
|
|
114
414
|
readonly MarkdownFrontmatterParseError: {
|
|
415
|
+
readonly title: "Failed to parse Markdown frontmatter.";
|
|
115
416
|
readonly code: 6001;
|
|
116
417
|
};
|
|
117
418
|
readonly UnknownConfigError: {
|
|
419
|
+
readonly title: "Unknown configuration error.";
|
|
118
420
|
readonly code: 7000;
|
|
119
421
|
};
|
|
422
|
+
/**
|
|
423
|
+
* @docs
|
|
424
|
+
* @see
|
|
425
|
+
* - [--config](https://docs.astro.build/en/reference/cli-reference/#--config-path)
|
|
426
|
+
* @description
|
|
427
|
+
* The specified configuration file using `--config` could not be found. Make sure that it exists or that the path is correct
|
|
428
|
+
*/
|
|
120
429
|
readonly ConfigNotFound: {
|
|
430
|
+
readonly title: "Specified configuration file not found.";
|
|
121
431
|
readonly code: 7001;
|
|
122
432
|
readonly message: (configFile: string) => string;
|
|
123
433
|
};
|
|
434
|
+
/**
|
|
435
|
+
* @docs
|
|
436
|
+
* @see
|
|
437
|
+
* - [Configuration reference](https://docs.astro.build/en/reference/configuration-reference/)
|
|
438
|
+
* - [Migration guide](https://docs.astro.build/en/migrate/)
|
|
439
|
+
* @description
|
|
440
|
+
* Astro detected a legacy configuration option in your configuration file.
|
|
441
|
+
*/
|
|
124
442
|
readonly ConfigLegacyKey: {
|
|
443
|
+
readonly title: "Legacy configuration detected.";
|
|
125
444
|
readonly code: 7002;
|
|
126
445
|
readonly message: (legacyConfigKey: string) => string;
|
|
127
|
-
readonly hint: "Please update your configuration to the new format
|
|
446
|
+
readonly hint: "Please update your configuration to the new format.\nSee https://astro.build/config for more information.";
|
|
128
447
|
};
|
|
129
448
|
readonly UnknownError: {
|
|
449
|
+
readonly title: "Unknown Error.";
|
|
130
450
|
readonly code: 99999;
|
|
131
451
|
};
|
|
132
452
|
};
|
|
@@ -1,141 +1,171 @@
|
|
|
1
1
|
const defineErrors = (errs) => errs;
|
|
2
2
|
const AstroErrorData = defineErrors({
|
|
3
3
|
UnknownCompilerError: {
|
|
4
|
+
title: "Unknown compiler error.",
|
|
4
5
|
code: 1e3
|
|
5
6
|
},
|
|
6
|
-
|
|
7
|
+
StaticRedirectNotAvailable: {
|
|
8
|
+
title: "`Astro.redirect` is not available in static mode.",
|
|
7
9
|
code: 3001,
|
|
8
|
-
message: "Redirects are only available when using output: 'server'
|
|
10
|
+
message: "Redirects are only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
|
|
9
11
|
hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
|
|
10
12
|
},
|
|
11
|
-
|
|
13
|
+
ClientAddressNotAvailable: {
|
|
14
|
+
title: "`Astro.clientAddress` is not available in current adapter.",
|
|
12
15
|
code: 3002,
|
|
13
|
-
message: (adapterName) =>
|
|
16
|
+
message: (adapterName) => `\`Astro.clientAddress\` is not available in the \`${adapterName}\` adapter. File an issue with the adapter to add support.`
|
|
14
17
|
},
|
|
15
18
|
StaticClientAddressNotAvailable: {
|
|
19
|
+
title: "`Astro.clientAddress` is not available in static mode.",
|
|
16
20
|
code: 3003,
|
|
17
|
-
message: "Astro.clientAddress is only available when using output: 'server'
|
|
21
|
+
message: "`Astro.clientAddress` is only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
|
|
18
22
|
hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
|
|
19
23
|
},
|
|
20
24
|
NoMatchingStaticPathFound: {
|
|
25
|
+
title: "No static path found for requested path.",
|
|
21
26
|
code: 3004,
|
|
22
|
-
message: (pathName) => `A getStaticPaths route pattern was matched, but no matching static path was found for requested path
|
|
27
|
+
message: (pathName) => `A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${pathName}\`.`,
|
|
23
28
|
hint: (possibleRoutes) => `Possible dynamic routes being matched: ${possibleRoutes.join(", ")}.`
|
|
24
29
|
},
|
|
25
30
|
OnlyResponseCanBeReturned: {
|
|
31
|
+
title: "Invalid type returned by Astro page.",
|
|
26
32
|
code: 3005,
|
|
27
|
-
message: (route, returnedValue) => `Route ${route ? route : ""} returned a
|
|
33
|
+
message: (route, returnedValue) => `Route ${route ? route : ""} returned a \`${returnedValue}\`. Only a Response can be returned from Astro files.`,
|
|
28
34
|
hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."
|
|
29
35
|
},
|
|
30
36
|
MissingMediaQueryDirective: {
|
|
37
|
+
title: "Missing value for `client:media` directive.",
|
|
31
38
|
code: 3006,
|
|
32
|
-
message:
|
|
39
|
+
message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
|
|
33
40
|
},
|
|
34
41
|
NoMatchingRenderer: {
|
|
42
|
+
title: "No matching renderer found.",
|
|
35
43
|
code: 3007,
|
|
36
|
-
message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render
|
|
44
|
+
message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render \`${componentName}\`.
|
|
37
45
|
|
|
38
|
-
${validRenderersCount > 0 ? `There ${plural ? "are" : "is"} ${validRenderersCount} renderer${plural ? "s" : ""} configured in your \`astro.config.mjs\` file,
|
|
39
|
-
but ${plural ? "none were" : "it was not"} able to server-side render
|
|
46
|
+
${validRenderersCount > 0 ? `There ${plural ? "are." : "is."} ${validRenderersCount} renderer${plural ? "s." : ""} configured in your \`astro.config.mjs\` file,
|
|
47
|
+
but ${plural ? "none were." : "it was not."} able to server-side render \`${componentName}\`.` : `No valid renderer was found ${componentExtension ? `for the \`.${componentExtension}\` file extension.` : `for this file extension.`}`}`,
|
|
40
48
|
hint: (probableRenderers) => `Did you mean to enable the ${probableRenderers} integration?
|
|
41
49
|
|
|
42
50
|
See https://docs.astro.build/en/core-concepts/framework-components/ for more information on how to install and configure integrations.`
|
|
43
51
|
},
|
|
44
52
|
NoClientEntrypoint: {
|
|
53
|
+
title: "No client entrypoint specified in renderer.",
|
|
45
54
|
code: 3008,
|
|
46
|
-
message: (componentName, clientDirective, rendererName) =>
|
|
55
|
+
message: (componentName, clientDirective, rendererName) => `\`${componentName}\` component has a \`client:${clientDirective}\` directive, but no client entrypoint was provided by \`${rendererName}\`.`,
|
|
47
56
|
hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."
|
|
48
57
|
},
|
|
49
58
|
NoClientOnlyHint: {
|
|
59
|
+
title: "Missing hint on client:only directive.",
|
|
50
60
|
code: 3009,
|
|
51
|
-
message: (componentName) => `Unable to render
|
|
52
|
-
hint: (probableRenderers) => `Did you mean to pass client:only="${probableRenderers}"
|
|
61
|
+
message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
|
|
62
|
+
hint: (probableRenderers) => `Did you mean to pass \`client:only="${probableRenderers}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on client:only`
|
|
53
63
|
},
|
|
54
|
-
|
|
64
|
+
InvalidGetStaticPathParam: {
|
|
65
|
+
title: "Invalid value returned by a `getStaticPaths` path.",
|
|
55
66
|
code: 3010,
|
|
56
|
-
message: (paramType) => `Invalid params given to getStaticPaths path. Expected an object
|
|
67
|
+
message: (paramType) => `Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${paramType}\``,
|
|
57
68
|
hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
|
|
58
69
|
},
|
|
59
70
|
InvalidGetStaticPathsReturn: {
|
|
71
|
+
title: "Invalid value returned by getStaticPaths.",
|
|
60
72
|
code: 3011,
|
|
61
|
-
message: (returnType) => `Invalid type returned by getStaticPaths
|
|
73
|
+
message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
|
|
62
74
|
hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
|
|
63
75
|
},
|
|
64
|
-
|
|
76
|
+
GetStaticPathsRemovedRSSHelper: {
|
|
77
|
+
title: "getStaticPaths RSS helper is not available anymore.",
|
|
65
78
|
code: 3012,
|
|
66
|
-
message: "The RSS helper has been removed from getStaticPaths
|
|
79
|
+
message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",
|
|
67
80
|
hint: "See https://docs.astro.build/en/guides/rss/ for more information."
|
|
68
81
|
},
|
|
69
82
|
GetStaticPathsExpectedParams: {
|
|
83
|
+
title: "Missing params property on `getStaticPaths` route.",
|
|
70
84
|
code: 3013,
|
|
71
|
-
message: "Missing or empty required params property on getStaticPaths route",
|
|
85
|
+
message: "Missing or empty required `params` property on `getStaticPaths` route.",
|
|
72
86
|
hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
|
|
73
87
|
},
|
|
74
88
|
GetStaticPathsInvalidRouteParam: {
|
|
89
|
+
title: "Invalid value for `getStaticPaths` route parameter.",
|
|
75
90
|
code: 3014,
|
|
76
|
-
message: (key, value) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected a string or number, received \`${
|
|
91
|
+
message: (key, value, valueType) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected undefined, a string or a number, received \`${valueType}\` (\`${value}\`)`,
|
|
77
92
|
hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
|
|
78
93
|
},
|
|
79
94
|
GetStaticPathsRequired: {
|
|
95
|
+
title: "`getStaticPaths()` function required for dynamic routes.",
|
|
80
96
|
code: 3015,
|
|
81
|
-
message: "getStaticPaths() function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
|
|
97
|
+
message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
|
|
82
98
|
hint: `See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.
|
|
83
99
|
|
|
84
100
|
Alternatively, set \`output: "server"\` in your Astro config file to switch to a non-static server build.
|
|
85
101
|
See https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.`
|
|
86
102
|
},
|
|
87
103
|
ReservedSlotName: {
|
|
104
|
+
title: "Invalid slot name.",
|
|
88
105
|
code: 3016,
|
|
89
|
-
message: (slotName) => `Unable to create a slot named
|
|
106
|
+
message: (slotName) => `Unable to create a slot named \`${slotName}\`. \`${slotName}\` is a reserved slot name. Please update the name of this slot.`
|
|
90
107
|
},
|
|
91
108
|
NoAdapterInstalled: {
|
|
109
|
+
title: "Cannot use Server-side Rendering without an adapter.",
|
|
92
110
|
code: 3017,
|
|
93
111
|
message: `Cannot use \`output: 'server'\` without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
|
|
94
112
|
hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information."
|
|
95
113
|
},
|
|
96
114
|
NoMatchingImport: {
|
|
115
|
+
title: "No import found for component.",
|
|
97
116
|
code: 3018,
|
|
98
|
-
message: (componentName) => `Could not render
|
|
117
|
+
message: (componentName) => `Could not render \`${componentName}\`. No matching import has been found for \`${componentName}\`.`,
|
|
99
118
|
hint: "Please make sure the component is properly imported."
|
|
100
119
|
},
|
|
101
|
-
UnknownCSSError: {
|
|
102
|
-
code: 4e3
|
|
103
|
-
},
|
|
104
|
-
CSSSyntaxError: {
|
|
105
|
-
code: 4001
|
|
106
|
-
},
|
|
107
120
|
UnknownViteError: {
|
|
108
|
-
|
|
121
|
+
title: "Unknown Vite Error.",
|
|
122
|
+
code: 4e3
|
|
109
123
|
},
|
|
110
124
|
FailedToLoadModuleSSR: {
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
title: "Could not import file.",
|
|
126
|
+
code: 4001,
|
|
127
|
+
message: (importName) => `Could not import \`${importName}\`.`,
|
|
113
128
|
hint: "This is often caused by a typo in the import path. Please make sure the file exists."
|
|
114
129
|
},
|
|
115
130
|
InvalidGlob: {
|
|
116
|
-
|
|
117
|
-
|
|
131
|
+
title: "Invalid glob pattern.",
|
|
132
|
+
code: 4002,
|
|
133
|
+
message: (globPattern) => `Invalid glob pattern: \`${globPattern}\`. Glob patterns must start with './', '../' or '/'.`,
|
|
118
134
|
hint: "See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns."
|
|
119
135
|
},
|
|
136
|
+
UnknownCSSError: {
|
|
137
|
+
title: "Unknown CSS Error.",
|
|
138
|
+
code: 5e3
|
|
139
|
+
},
|
|
140
|
+
CSSSyntaxError: {
|
|
141
|
+
title: "CSS Syntax Error.",
|
|
142
|
+
code: 5001
|
|
143
|
+
},
|
|
120
144
|
UnknownMarkdownError: {
|
|
145
|
+
title: "Unknown Markdown Error.",
|
|
121
146
|
code: 6e3
|
|
122
147
|
},
|
|
123
148
|
MarkdownFrontmatterParseError: {
|
|
149
|
+
title: "Failed to parse Markdown frontmatter.",
|
|
124
150
|
code: 6001
|
|
125
151
|
},
|
|
126
152
|
UnknownConfigError: {
|
|
153
|
+
title: "Unknown configuration error.",
|
|
127
154
|
code: 7e3
|
|
128
155
|
},
|
|
129
156
|
ConfigNotFound: {
|
|
157
|
+
title: "Specified configuration file not found.",
|
|
130
158
|
code: 7001,
|
|
131
|
-
message: (configFile) => `Unable to resolve
|
|
159
|
+
message: (configFile) => `Unable to resolve \`--config "${configFile}"\`. Does the file exist?`
|
|
132
160
|
},
|
|
133
161
|
ConfigLegacyKey: {
|
|
162
|
+
title: "Legacy configuration detected.",
|
|
134
163
|
code: 7002,
|
|
135
|
-
message: (legacyConfigKey) => `Legacy configuration detected:
|
|
136
|
-
hint: "Please update your configuration to the new format
|
|
164
|
+
message: (legacyConfigKey) => `Legacy configuration detected: \`${legacyConfigKey}\`.`,
|
|
165
|
+
hint: "Please update your configuration to the new format.\nSee https://astro.build/config for more information."
|
|
137
166
|
},
|
|
138
167
|
UnknownError: {
|
|
168
|
+
title: "Unknown Error.",
|
|
139
169
|
code: 99999
|
|
140
170
|
}
|
|
141
171
|
});
|
|
@@ -2,6 +2,7 @@ import type { DiagnosticCode } from '@astrojs/compiler/shared/diagnostics.js';
|
|
|
2
2
|
import { AstroErrorCodes } from './errors-data.js';
|
|
3
3
|
interface ErrorProperties {
|
|
4
4
|
code: AstroErrorCodes | DiagnosticCode;
|
|
5
|
+
title?: string;
|
|
5
6
|
name?: string;
|
|
6
7
|
message?: string;
|
|
7
8
|
location?: ErrorLocation;
|
|
@@ -16,8 +17,9 @@ export interface ErrorLocation {
|
|
|
16
17
|
}
|
|
17
18
|
declare type ErrorTypes = 'AstroError' | 'CompilerError' | 'CSSError' | 'MarkdownError' | 'InternalError' | 'AggregateError';
|
|
18
19
|
export declare class AstroError extends Error {
|
|
19
|
-
|
|
20
|
+
errorCode: AstroErrorCodes | DiagnosticCode;
|
|
20
21
|
loc: ErrorLocation | undefined;
|
|
22
|
+
title: string | undefined;
|
|
21
23
|
hint: string | undefined;
|
|
22
24
|
frame: string | undefined;
|
|
23
25
|
type: ErrorTypes;
|
|
@@ -5,13 +5,14 @@ class AstroError extends Error {
|
|
|
5
5
|
var _a;
|
|
6
6
|
super(...params);
|
|
7
7
|
this.type = "AstroError";
|
|
8
|
-
const { code, name, message, stack, location, hint, frame } = props;
|
|
9
|
-
this.
|
|
8
|
+
const { code, name, title, message, stack, location, hint, frame } = props;
|
|
9
|
+
this.errorCode = code;
|
|
10
10
|
if (name) {
|
|
11
11
|
this.name = name;
|
|
12
12
|
} else {
|
|
13
|
-
this.name = ((_a = getErrorDataByCode(this.
|
|
13
|
+
this.name = ((_a = getErrorDataByCode(this.errorCode)) == null ? void 0 : _a.name) ?? "UnknownError";
|
|
14
14
|
}
|
|
15
|
+
this.title = title;
|
|
15
16
|
if (message)
|
|
16
17
|
this.message = message;
|
|
17
18
|
this.stack = stack ? stack : this.stack;
|
|
@@ -21,8 +22,8 @@ class AstroError extends Error {
|
|
|
21
22
|
}
|
|
22
23
|
setErrorCode(errorCode) {
|
|
23
24
|
var _a;
|
|
24
|
-
this.
|
|
25
|
-
this.name = ((_a = getErrorDataByCode(this.
|
|
25
|
+
this.errorCode = errorCode;
|
|
26
|
+
this.name = ((_a = getErrorDataByCode(this.errorCode)) == null ? void 0 : _a.name) ?? "UnknownError";
|
|
26
27
|
}
|
|
27
28
|
setLocation(location) {
|
|
28
29
|
this.loc = location;
|
|
@@ -15,104 +15,134 @@ export declare function normalizeLF(code: string): string;
|
|
|
15
15
|
export declare function getErrorDataByCode(code: AstroErrorCodes | DiagnosticCode): {
|
|
16
16
|
name: string;
|
|
17
17
|
data: {
|
|
18
|
+
readonly title: "Unknown compiler error.";
|
|
18
19
|
readonly code: 1000;
|
|
19
20
|
} | {
|
|
21
|
+
readonly title: "`Astro.redirect` is not available in static mode.";
|
|
20
22
|
readonly code: 3001;
|
|
21
|
-
readonly message: "Redirects are only available when using output: 'server'
|
|
23
|
+
readonly message: "Redirects are only available when using `output: 'server'`. Update your Astro config if you need SSR features.";
|
|
22
24
|
readonly hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR.";
|
|
23
25
|
} | {
|
|
26
|
+
readonly title: "`Astro.clientAddress` is not available in current adapter.";
|
|
24
27
|
readonly code: 3002;
|
|
25
28
|
readonly message: (adapterName: string) => string;
|
|
26
29
|
} | {
|
|
30
|
+
readonly title: "`Astro.clientAddress` is not available in static mode.";
|
|
27
31
|
readonly code: 3003;
|
|
28
|
-
readonly message: "Astro.clientAddress is only available when using output: 'server'
|
|
32
|
+
readonly message: "`Astro.clientAddress` is only available when using `output: 'server'`. Update your Astro config if you need SSR features.";
|
|
29
33
|
readonly hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR.";
|
|
30
34
|
} | {
|
|
35
|
+
readonly title: "No static path found for requested path.";
|
|
31
36
|
readonly code: 3004;
|
|
32
37
|
readonly message: (pathName: string) => string;
|
|
33
38
|
readonly hint: (possibleRoutes: string[]) => string;
|
|
34
39
|
} | {
|
|
40
|
+
readonly title: "Invalid type returned by Astro page.";
|
|
35
41
|
readonly code: 3005;
|
|
36
42
|
readonly message: (route: string | undefined, returnedValue: string) => string;
|
|
37
43
|
readonly hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information.";
|
|
38
44
|
} | {
|
|
45
|
+
readonly title: "Missing value for `client:media` directive.";
|
|
39
46
|
readonly code: 3006;
|
|
40
|
-
readonly message: (
|
|
47
|
+
readonly message: "Media query not provided for `client:media` directive. A media query similar to `client:media=\"(max-width: 600px)\"` must be provided";
|
|
41
48
|
} | {
|
|
49
|
+
readonly title: "No matching renderer found.";
|
|
42
50
|
readonly code: 3007;
|
|
43
51
|
readonly message: (componentName: string, componentExtension: string | undefined, plural: boolean, validRenderersCount: number) => string;
|
|
44
52
|
readonly hint: (probableRenderers: string) => string;
|
|
45
53
|
} | {
|
|
54
|
+
readonly title: "No client entrypoint specified in renderer.";
|
|
46
55
|
readonly code: 3008;
|
|
47
56
|
readonly message: (componentName: string, clientDirective: string, rendererName: string) => string;
|
|
48
57
|
readonly hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer.";
|
|
49
58
|
} | {
|
|
59
|
+
readonly title: "Missing hint on client:only directive.";
|
|
50
60
|
readonly code: 3009;
|
|
51
61
|
readonly message: (componentName: string) => string;
|
|
52
62
|
readonly hint: (probableRenderers: string) => string;
|
|
53
63
|
} | {
|
|
64
|
+
readonly title: "Invalid value returned by a `getStaticPaths` path.";
|
|
54
65
|
readonly code: 3010;
|
|
55
66
|
readonly message: (paramType: any) => string;
|
|
56
67
|
readonly hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths.";
|
|
57
68
|
} | {
|
|
69
|
+
readonly title: "Invalid value returned by getStaticPaths.";
|
|
58
70
|
readonly code: 3011;
|
|
59
71
|
readonly message: (returnType: any) => string;
|
|
60
72
|
readonly hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths.";
|
|
61
73
|
} | {
|
|
74
|
+
readonly title: "getStaticPaths RSS helper is not available anymore.";
|
|
62
75
|
readonly code: 3012;
|
|
63
|
-
readonly message: "The RSS helper has been removed from getStaticPaths
|
|
76
|
+
readonly message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.";
|
|
64
77
|
readonly hint: "See https://docs.astro.build/en/guides/rss/ for more information.";
|
|
65
78
|
} | {
|
|
79
|
+
readonly title: "Missing params property on `getStaticPaths` route.";
|
|
66
80
|
readonly code: 3013;
|
|
67
|
-
readonly message: "Missing or empty required params property on getStaticPaths route";
|
|
81
|
+
readonly message: "Missing or empty required `params` property on `getStaticPaths` route.";
|
|
68
82
|
readonly hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths.";
|
|
69
83
|
} | {
|
|
84
|
+
readonly title: "Invalid value for `getStaticPaths` route parameter.";
|
|
70
85
|
readonly code: 3014;
|
|
71
|
-
readonly message: (key: string, value: any) => string;
|
|
86
|
+
readonly message: (key: string, value: any, valueType: any) => string;
|
|
72
87
|
readonly hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths.";
|
|
73
88
|
} | {
|
|
89
|
+
readonly title: "`getStaticPaths()` function required for dynamic routes.";
|
|
74
90
|
readonly code: 3015;
|
|
75
|
-
readonly message: "getStaticPaths() function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.";
|
|
91
|
+
readonly message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.";
|
|
76
92
|
readonly hint: "See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.\n\nAlternatively, set `output: \"server\"` in your Astro config file to switch to a non-static server build.\nSee https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.";
|
|
77
93
|
} | {
|
|
94
|
+
readonly title: "Invalid slot name.";
|
|
78
95
|
readonly code: 3016;
|
|
79
96
|
readonly message: (slotName: string) => string;
|
|
80
97
|
} | {
|
|
98
|
+
readonly title: "Cannot use Server-side Rendering without an adapter.";
|
|
81
99
|
readonly code: 3017;
|
|
82
100
|
readonly message: "Cannot use `output: 'server'` without an adapter. Please install and configure the appropriate server adapter for your final deployment.";
|
|
83
101
|
readonly hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information.";
|
|
84
102
|
} | {
|
|
103
|
+
readonly title: "No import found for component.";
|
|
85
104
|
readonly code: 3018;
|
|
86
105
|
readonly message: (componentName: string) => string;
|
|
87
106
|
readonly hint: "Please make sure the component is properly imported.";
|
|
88
107
|
} | {
|
|
108
|
+
readonly title: "Unknown Vite Error.";
|
|
89
109
|
readonly code: 4000;
|
|
90
110
|
} | {
|
|
111
|
+
readonly title: "Could not import file.";
|
|
91
112
|
readonly code: 4001;
|
|
92
|
-
} | {
|
|
93
|
-
readonly code: 5000;
|
|
94
|
-
} | {
|
|
95
|
-
readonly code: 5001;
|
|
96
113
|
readonly message: (importName: string) => string;
|
|
97
114
|
readonly hint: "This is often caused by a typo in the import path. Please make sure the file exists.";
|
|
98
115
|
} | {
|
|
99
|
-
readonly
|
|
116
|
+
readonly title: "Invalid glob pattern.";
|
|
117
|
+
readonly code: 4002;
|
|
100
118
|
readonly message: (globPattern: string) => string;
|
|
101
119
|
readonly hint: "See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns.";
|
|
102
120
|
} | {
|
|
121
|
+
readonly title: "Unknown CSS Error.";
|
|
122
|
+
readonly code: 5000;
|
|
123
|
+
} | {
|
|
124
|
+
readonly title: "CSS Syntax Error.";
|
|
125
|
+
readonly code: 5001;
|
|
126
|
+
} | {
|
|
127
|
+
readonly title: "Unknown Markdown Error.";
|
|
103
128
|
readonly code: 6000;
|
|
104
129
|
} | {
|
|
130
|
+
readonly title: "Failed to parse Markdown frontmatter.";
|
|
105
131
|
readonly code: 6001;
|
|
106
132
|
} | {
|
|
133
|
+
readonly title: "Unknown configuration error.";
|
|
107
134
|
readonly code: 7000;
|
|
108
135
|
} | {
|
|
136
|
+
readonly title: "Specified configuration file not found.";
|
|
109
137
|
readonly code: 7001;
|
|
110
138
|
readonly message: (configFile: string) => string;
|
|
111
139
|
} | {
|
|
140
|
+
readonly title: "Legacy configuration detected.";
|
|
112
141
|
readonly code: 7002;
|
|
113
142
|
readonly message: (legacyConfigKey: string) => string;
|
|
114
|
-
readonly hint: "Please update your configuration to the new format
|
|
143
|
+
readonly hint: "Please update your configuration to the new format.\nSee https://astro.build/config for more information.";
|
|
115
144
|
} | {
|
|
145
|
+
readonly title: "Unknown Error.";
|
|
116
146
|
readonly code: 99999;
|
|
117
147
|
};
|
|
118
148
|
} | undefined;
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
site,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "1.6.
|
|
50
|
+
const version = "1.6.11";
|
|
51
51
|
const rootPath = site ? site.pathname : "/";
|
|
52
52
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
53
53
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -263,7 +263,7 @@ function printHelp({
|
|
|
263
263
|
message.push(
|
|
264
264
|
linebreak(),
|
|
265
265
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
266
|
-
`v${"1.6.
|
|
266
|
+
`v${"1.6.11"}`
|
|
267
267
|
)} ${headline}`
|
|
268
268
|
);
|
|
269
269
|
}
|
package/dist/core/path.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare function startsWithDotSlash(path: string): boolean;
|
|
|
11
11
|
export declare function isRelativePath(path: string): boolean;
|
|
12
12
|
export declare function joinPaths(...paths: (string | undefined)[]): string;
|
|
13
13
|
export declare function removeFileExtension(path: string): string;
|
|
14
|
+
export declare function removeQueryString(path: string): string;
|
package/dist/core/path.js
CHANGED
|
@@ -46,6 +46,10 @@ function removeFileExtension(path) {
|
|
|
46
46
|
let idx = path.lastIndexOf(".");
|
|
47
47
|
return idx === -1 ? path : path.slice(0, idx);
|
|
48
48
|
}
|
|
49
|
+
function removeQueryString(path) {
|
|
50
|
+
const index = path.lastIndexOf("?");
|
|
51
|
+
return index > 0 ? path.substring(0, index) : path;
|
|
52
|
+
}
|
|
49
53
|
export {
|
|
50
54
|
appendExtension,
|
|
51
55
|
appendForwardSlash,
|
|
@@ -55,6 +59,7 @@ export {
|
|
|
55
59
|
removeFileExtension,
|
|
56
60
|
removeLeadingForwardSlash,
|
|
57
61
|
removeLeadingForwardSlashWindows,
|
|
62
|
+
removeQueryString,
|
|
58
63
|
removeTrailingForwardSlash,
|
|
59
64
|
startsWithDotDotSlash,
|
|
60
65
|
startsWithDotSlash,
|
|
@@ -30,7 +30,7 @@ function onlyAvailableInSSR(name) {
|
|
|
30
30
|
return function _onlyAvailableInSSR() {
|
|
31
31
|
switch (name) {
|
|
32
32
|
case "Astro.redirect":
|
|
33
|
-
throw new AstroError(AstroErrorData.
|
|
33
|
+
throw new AstroError(AstroErrorData.StaticRedirectNotAvailable);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
}
|
|
@@ -147,10 +147,8 @@ function createResult(args) {
|
|
|
147
147
|
if (!(clientAddressSymbol in request)) {
|
|
148
148
|
if (args.adapterName) {
|
|
149
149
|
throw new AstroError({
|
|
150
|
-
...AstroErrorData.
|
|
151
|
-
message: AstroErrorData.
|
|
152
|
-
args.adapterName
|
|
153
|
-
)
|
|
150
|
+
...AstroErrorData.ClientAddressNotAvailable,
|
|
151
|
+
message: AstroErrorData.ClientAddressNotAvailable.message(args.adapterName)
|
|
154
152
|
});
|
|
155
153
|
} else {
|
|
156
154
|
throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
|
|
@@ -21,7 +21,7 @@ async function callGetStaticPaths({
|
|
|
21
21
|
staticPaths = await mod.getStaticPaths({
|
|
22
22
|
paginate: generatePaginateFunction(route),
|
|
23
23
|
rss() {
|
|
24
|
-
throw new AstroError(AstroErrorData.
|
|
24
|
+
throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
if (Array.isArray(staticPaths)) {
|
|
@@ -5,7 +5,7 @@ function validateGetStaticPathsParameter([key, value], route) {
|
|
|
5
5
|
if (!VALID_PARAM_TYPES.includes(typeof value)) {
|
|
6
6
|
throw new AstroError({
|
|
7
7
|
...AstroErrorData.GetStaticPathsInvalidRouteParam,
|
|
8
|
-
message: AstroErrorData.GetStaticPathsInvalidRouteParam.message(key, value),
|
|
8
|
+
message: AstroErrorData.GetStaticPathsInvalidRouteParam.message(key, value, typeof value),
|
|
9
9
|
location: {
|
|
10
10
|
file: route
|
|
11
11
|
}
|
|
@@ -48,8 +48,8 @@ function validateGetStaticPathsResult(result, logging, route) {
|
|
|
48
48
|
}
|
|
49
49
|
if (typeof pathObject.params !== "object") {
|
|
50
50
|
throw new AstroError({
|
|
51
|
-
...AstroErrorData.
|
|
52
|
-
message: AstroErrorData.
|
|
51
|
+
...AstroErrorData.InvalidGetStaticPathParam,
|
|
52
|
+
message: AstroErrorData.InvalidGetStaticPathParam.message(typeof pathObject.params),
|
|
53
53
|
location: {
|
|
54
54
|
file: route.component
|
|
55
55
|
}
|
|
@@ -52,10 +52,7 @@ function extractDirectives(displayName, inputProps) {
|
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
if (extracted.hydration.directive === "media" && typeof extracted.hydration.value !== "string") {
|
|
55
|
-
throw new AstroError(
|
|
56
|
-
...AstroErrorData.MissingMediaQueryDirective,
|
|
57
|
-
message: AstroErrorData.MissingMediaQueryDirective.message(displayName)
|
|
58
|
-
});
|
|
55
|
+
throw new AstroError(AstroErrorData.MissingMediaQueryDirective);
|
|
59
56
|
}
|
|
60
57
|
break;
|
|
61
58
|
}
|
|
@@ -4,6 +4,7 @@ import esbuild from "esbuild";
|
|
|
4
4
|
import * as colors from "kleur/colors";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { error } from "../core/logger/core.js";
|
|
7
|
+
import { removeQueryString } from "../core/path.js";
|
|
7
8
|
import { parseNpmName } from "../core/util.js";
|
|
8
9
|
import tagExportsPlugin from "./tag.js";
|
|
9
10
|
const JSX_EXTENSIONS = /* @__PURE__ */ new Set([".jsx", ".tsx", ".mdx"]);
|
|
@@ -127,6 +128,7 @@ function jsx({ settings, logging }) {
|
|
|
127
128
|
async transform(code, id, opts) {
|
|
128
129
|
var _a;
|
|
129
130
|
const ssr = Boolean(opts == null ? void 0 : opts.ssr);
|
|
131
|
+
id = removeQueryString(id);
|
|
130
132
|
if (!JSX_EXTENSIONS.has(path.extname(id))) {
|
|
131
133
|
return null;
|
|
132
134
|
}
|