astro 3.0.0-beta.3 → 3.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ViewTransitions.astro +13 -10
- package/components/shiki-themes.js +0 -6
- package/content-types.template.d.ts +2 -24
- package/dist/@types/astro.d.ts +17 -52
- package/dist/content/utils.js +4 -1
- package/dist/core/app/index.js +1 -1
- package/dist/core/app/ssrPipeline.js +3 -25
- package/dist/core/build/buildPipeline.d.ts +1 -6
- package/dist/core/build/buildPipeline.js +2 -38
- package/dist/core/build/generate.js +10 -9
- package/dist/core/config/config.js +0 -52
- package/dist/core/config/schema.d.ts +144 -1
- package/dist/core/config/schema.js +2 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/container.js +5 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/dev/index.d.ts +1 -1
- package/dist/core/endpoint/index.d.ts +6 -9
- package/dist/core/endpoint/index.js +67 -10
- package/dist/core/errors/errors-data.d.ts +12 -12
- package/dist/core/errors/errors-data.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/pipeline.d.ts +2 -8
- package/dist/core/pipeline.js +1 -10
- package/dist/core/polyfill.js +5 -6
- package/dist/core/render/core.d.ts +2 -5
- package/dist/core/render/core.js +8 -8
- package/dist/runtime/server/hydration.js +0 -5
- package/dist/runtime/server/render/common.d.ts +1 -1
- package/dist/runtime/server/render/common.js +13 -15
- package/dist/runtime/server/render/component.d.ts +1 -1
- package/dist/runtime/server/render/component.js +15 -1
- package/dist/runtime/server/render/head.d.ts +1 -1
- package/dist/runtime/server/render/head.js +3 -2
- package/dist/runtime/server/render/index.d.ts +1 -1
- package/dist/runtime/server/render/instruction.d.ts +16 -0
- package/dist/runtime/server/render/instruction.js +13 -0
- package/dist/runtime/server/render/slot.d.ts +1 -1
- package/dist/runtime/server/render/util.js +2 -2
- package/dist/runtime/server/util.d.ts +0 -1
- package/dist/runtime/server/util.js +0 -23
- package/dist/vite-plugin-astro-server/devPipeline.d.ts +1 -2
- package/dist/vite-plugin-astro-server/devPipeline.js +2 -32
- package/dist/vite-plugin-astro-server/route.js +4 -2
- package/package.json +6 -5
- package/dist/runtime/server/render/types.d.ts +0 -12
- package/dist/runtime/server/render/types.js +0 -0
- package/dist/vite-plugin-mdx/import-source.d.ts +0 -3
- package/dist/vite-plugin-mdx/import-source.js +0 -35
|
@@ -101,9 +101,8 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
101
101
|
|
|
102
102
|
const parser = new DOMParser();
|
|
103
103
|
|
|
104
|
-
async function updateDOM(
|
|
104
|
+
async function updateDOM(html: string, state?: State, fallback?: Fallback) {
|
|
105
105
|
const doc = parser.parseFromString(html, 'text/html');
|
|
106
|
-
doc.documentElement.dataset.astroTransition = dir;
|
|
107
106
|
|
|
108
107
|
// Check for a head element that should persist, either because it has the data
|
|
109
108
|
// attribute or is a link el.
|
|
@@ -233,15 +232,17 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
233
232
|
location.href = href;
|
|
234
233
|
return;
|
|
235
234
|
}
|
|
235
|
+
document.documentElement.dataset.astroTransition = dir;
|
|
236
236
|
if (supportsViewTransitions) {
|
|
237
|
-
finished = document.startViewTransition(() => updateDOM(
|
|
237
|
+
finished = document.startViewTransition(() => updateDOM(html, state)).finished;
|
|
238
238
|
} else {
|
|
239
|
-
finished = updateDOM(
|
|
239
|
+
finished = updateDOM(html, state, getFallback());
|
|
240
240
|
}
|
|
241
241
|
try {
|
|
242
242
|
await finished;
|
|
243
243
|
} finally {
|
|
244
|
-
|
|
244
|
+
// skip this for the moment as it tends to stop fallback animations
|
|
245
|
+
// document.documentElement.removeAttribute('data-astro-transition');
|
|
245
246
|
await runScripts();
|
|
246
247
|
markScriptsExec();
|
|
247
248
|
onload();
|
|
@@ -291,8 +292,7 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
291
292
|
transitionEnabledOnThisPage()
|
|
292
293
|
) {
|
|
293
294
|
ev.preventDefault();
|
|
294
|
-
navigate('forward', link.href, { index: currentHistoryIndex, scrollY: 0 });
|
|
295
|
-
currentHistoryIndex++;
|
|
295
|
+
navigate('forward', link.href, { index: ++currentHistoryIndex, scrollY: 0 });
|
|
296
296
|
const newState: State = { index: currentHistoryIndex, scrollY };
|
|
297
297
|
persistState({ index: currentHistoryIndex - 1, scrollY });
|
|
298
298
|
history.pushState(newState, '', link.href);
|
|
@@ -306,10 +306,11 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
306
306
|
return;
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
//
|
|
309
|
+
// History entries without state are created by the browser (e.g. for hash links)
|
|
310
|
+
// Our view transition entries always have state.
|
|
311
|
+
// Just ignore stateless entries.
|
|
312
|
+
// The browser will handle navigation fine without our help
|
|
310
313
|
if (ev.state === null) {
|
|
311
|
-
persistState({ index: currentHistoryIndex, scrollY });
|
|
312
|
-
ev.preventDefault();
|
|
313
314
|
return;
|
|
314
315
|
}
|
|
315
316
|
|
|
@@ -344,6 +345,8 @@ const { fallback = 'animate' } = Astro.props as Props;
|
|
|
344
345
|
addEventListener(
|
|
345
346
|
'scroll',
|
|
346
347
|
throttle(() => {
|
|
348
|
+
// only updste history entries that are managed by us
|
|
349
|
+
// leave other entries alone and do not accidently add state.
|
|
347
350
|
if (history.state) {
|
|
348
351
|
persistState({ ...history.state, scrollY });
|
|
349
352
|
}
|
|
@@ -34,10 +34,4 @@ export const themes = {
|
|
|
34
34
|
'solarized-light': () => import('shiki/themes/solarized-light.json').then(mod => mod.default),
|
|
35
35
|
'vitesse-dark': () => import('shiki/themes/vitesse-dark.json').then(mod => mod.default),
|
|
36
36
|
'vitesse-light': () => import('shiki/themes/vitesse-light.json').then(mod => mod.default),
|
|
37
|
-
// old theme names for compat
|
|
38
|
-
'material-darker': () => import('shiki/themes/material-theme-darker').then(mod => mod.default),
|
|
39
|
-
'material-default': () => import('shiki/themes/material-theme').then(mod => mod.default),
|
|
40
|
-
'material-lighter': () => import('shiki/themes/material-theme-lighter').then(mod => mod.default),
|
|
41
|
-
'material-ocean': () => import('shiki/themes/material-theme-ocean').then(mod => mod.default),
|
|
42
|
-
'material-palenight': () => import('shiki/themes/material-theme-palenight').then(mod => mod.default),
|
|
43
37
|
};
|
|
@@ -14,25 +14,6 @@ declare module 'astro:content' {
|
|
|
14
14
|
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
|
15
15
|
export type CollectionEntry<C extends keyof AnyEntryMap> = Flatten<AnyEntryMap[C]>;
|
|
16
16
|
|
|
17
|
-
// TODO: Remove this when having this fallback is no longer relevant. 2.3? 3.0? - erika, 2023-04-04
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated
|
|
20
|
-
* `astro:content` no longer provide `image()`.
|
|
21
|
-
*
|
|
22
|
-
* Please use it through `schema`, like such:
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { defineCollection, z } from "astro:content";
|
|
25
|
-
*
|
|
26
|
-
* defineCollection({
|
|
27
|
-
* schema: ({ image }) =>
|
|
28
|
-
* z.object({
|
|
29
|
-
* image: image(),
|
|
30
|
-
* }),
|
|
31
|
-
* });
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export const image: never;
|
|
35
|
-
|
|
36
17
|
// This needs to be in sync with ImageMetadata
|
|
37
18
|
export type ImageFunction = () => import('astro/zod').ZodObject<{
|
|
38
19
|
src: import('astro/zod').ZodString;
|
|
@@ -53,12 +34,9 @@ declare module 'astro:content' {
|
|
|
53
34
|
|
|
54
35
|
type BaseSchemaWithoutEffects =
|
|
55
36
|
| import('astro/zod').AnyZodObject
|
|
56
|
-
| import('astro/zod').ZodUnion<
|
|
37
|
+
| import('astro/zod').ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]>
|
|
57
38
|
| import('astro/zod').ZodDiscriminatedUnion<string, import('astro/zod').AnyZodObject[]>
|
|
58
|
-
| import('astro/zod').ZodIntersection<
|
|
59
|
-
import('astro/zod').AnyZodObject,
|
|
60
|
-
import('astro/zod').AnyZodObject
|
|
61
|
-
>;
|
|
39
|
+
| import('astro/zod').ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
|
|
62
40
|
|
|
63
41
|
type BaseSchema =
|
|
64
42
|
| BaseSchemaWithoutEffects
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { LogOptions, LoggerLevel } from '../core/logger/core';
|
|
|
18
18
|
import type { AstroIntegrationLogger } from '../core/logger/core';
|
|
19
19
|
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
|
|
20
20
|
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
|
21
|
+
import type { ResponseWithEncoding } from '../core/endpoint/index.js';
|
|
21
22
|
export type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark';
|
|
22
23
|
export type { ExternalImageService, ImageService, LocalImageService, } from '../assets/services/service';
|
|
23
24
|
export type { GetImageResult, ImageInputFormat, ImageMetadata, ImageOutputFormat, ImageQuality, ImageQualityPreset, ImageTransform, } from '../assets/types';
|
|
@@ -63,14 +64,10 @@ export interface AstroDefineVarsAttribute {
|
|
|
63
64
|
'define:vars'?: any;
|
|
64
65
|
}
|
|
65
66
|
export interface AstroStyleAttributes {
|
|
66
|
-
/** @deprecated Use `is:global` instead */
|
|
67
|
-
global?: boolean;
|
|
68
67
|
'is:global'?: boolean;
|
|
69
68
|
'is:inline'?: boolean;
|
|
70
69
|
}
|
|
71
70
|
export interface AstroScriptAttributes {
|
|
72
|
-
/** @deprecated Hoist is now the default behavior */
|
|
73
|
-
hoist?: boolean;
|
|
74
71
|
'is:inline'?: boolean;
|
|
75
72
|
}
|
|
76
73
|
export interface AstroComponentMetadata {
|
|
@@ -540,7 +537,7 @@ export interface AstroUserConfig {
|
|
|
540
537
|
* @docs
|
|
541
538
|
* @name scopedStyleStrategy
|
|
542
539
|
* @type {('where' | 'class' | 'attribute')}
|
|
543
|
-
* @default `'
|
|
540
|
+
* @default `'attribute'`
|
|
544
541
|
* @version 2.4
|
|
545
542
|
* @description
|
|
546
543
|
*
|
|
@@ -551,7 +548,7 @@ export interface AstroUserConfig {
|
|
|
551
548
|
*
|
|
552
549
|
* Using `'class'` is helpful when you want to ensure that element selectors within an Astro component override global style defaults (e.g. from a global stylesheet).
|
|
553
550
|
* Using `'where'` gives you more control over specifity, but requires that you use higher-specifity selectors, layers, and other tools to control which selectors are applied.
|
|
554
|
-
* Using
|
|
551
|
+
* Using 'attribute' is useful when you are manipulating the `class` attribute of elements and need to avoid conflicts between your own styling logic and Astro's application of styles.
|
|
555
552
|
*/
|
|
556
553
|
scopedStyleStrategy?: 'where' | 'class' | 'attribute';
|
|
557
554
|
/**
|
|
@@ -787,22 +784,12 @@ export interface AstroUserConfig {
|
|
|
787
784
|
* @name build.split
|
|
788
785
|
* @type {boolean}
|
|
789
786
|
* @default `false`
|
|
790
|
-
* @version
|
|
787
|
+
* @deprecated Deprecated since version 3.0.
|
|
791
788
|
* @description
|
|
792
|
-
*
|
|
789
|
+
* The build config option `build.split` has been replaced by the adapter configuration option [`functionPerRoute`](/en/reference/adapter-reference/#functionperroute).
|
|
793
790
|
*
|
|
794
|
-
*
|
|
795
|
-
* Each file emitted will render only one page. The pages will be emitted
|
|
796
|
-
* inside a `dist/pages/` directory, and the emitted files will keep the same file paths
|
|
797
|
-
* of the `src/pages` directory.
|
|
791
|
+
* Please see your [SSR adapter's documentation](/en/guides/integrations-guide/#official-integrations) for using `functionPerRoute` to define how your SSR code is bundled.
|
|
798
792
|
*
|
|
799
|
-
* ```js
|
|
800
|
-
* {
|
|
801
|
-
* build: {
|
|
802
|
-
* split: true
|
|
803
|
-
* }
|
|
804
|
-
* }
|
|
805
|
-
* ```
|
|
806
793
|
*/
|
|
807
794
|
split?: boolean;
|
|
808
795
|
/**
|
|
@@ -810,19 +797,11 @@ export interface AstroUserConfig {
|
|
|
810
797
|
* @name build.excludeMiddleware
|
|
811
798
|
* @type {boolean}
|
|
812
799
|
* @default `false`
|
|
813
|
-
* @version
|
|
800
|
+
* @deprecated Deprecated since version 3.0.
|
|
814
801
|
* @description
|
|
815
|
-
*
|
|
802
|
+
* The build config option `build.excludeMiddleware` has been replaced by the adapter configuration option [`edgeMiddleware`](/en/reference/adapter-reference/#edgemiddleware).
|
|
816
803
|
*
|
|
817
|
-
*
|
|
818
|
-
*
|
|
819
|
-
* ```js
|
|
820
|
-
* {
|
|
821
|
-
* build: {
|
|
822
|
-
* excludeMiddleware: true
|
|
823
|
-
* }
|
|
824
|
-
* }
|
|
825
|
-
* ```
|
|
804
|
+
* Please see your [SSR adapter's documentation](/en/guides/integrations-guide/#official-integrations) for using `edgeMiddleware` to define whether or not any SSR middleware code will be bundled when built.
|
|
826
805
|
*/
|
|
827
806
|
excludeMiddleware?: boolean;
|
|
828
807
|
};
|
|
@@ -1004,6 +983,7 @@ export interface AstroUserConfig {
|
|
|
1004
983
|
* @name markdown.drafts
|
|
1005
984
|
* @type {boolean}
|
|
1006
985
|
* @default `false`
|
|
986
|
+
* @deprecated Deprecated since version 3.0. Use content collections instead.
|
|
1007
987
|
* @description
|
|
1008
988
|
* Control whether Markdown draft pages should be included in the build.
|
|
1009
989
|
*
|
|
@@ -1142,7 +1122,7 @@ export interface AstroUserConfig {
|
|
|
1142
1122
|
* @name Integrations
|
|
1143
1123
|
* @description
|
|
1144
1124
|
*
|
|
1145
|
-
* Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown
|
|
1125
|
+
* Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown).
|
|
1146
1126
|
*
|
|
1147
1127
|
* Read our [Integrations Guide](https://docs.astro.build/en/guides/integrations-guide/) for help getting started with Astro Integrations.
|
|
1148
1128
|
*
|
|
@@ -1250,26 +1230,6 @@ export interface AstroUserConfig {
|
|
|
1250
1230
|
*/
|
|
1251
1231
|
optimizeHoistedScript?: boolean;
|
|
1252
1232
|
};
|
|
1253
|
-
/** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
|
|
1254
|
-
renderers?: never;
|
|
1255
|
-
/** @deprecated `projectRoot` has been renamed to `root` */
|
|
1256
|
-
projectRoot?: never;
|
|
1257
|
-
/** @deprecated `src` has been renamed to `srcDir` */
|
|
1258
|
-
src?: never;
|
|
1259
|
-
/** @deprecated `pages` has been removed. It is no longer configurable. */
|
|
1260
|
-
pages?: never;
|
|
1261
|
-
/** @deprecated `public` has been renamed to `publicDir` */
|
|
1262
|
-
public?: never;
|
|
1263
|
-
/** @deprecated `dist` has been renamed to `outDir` */
|
|
1264
|
-
dist?: never;
|
|
1265
|
-
/** @deprecated `styleOptions` has been renamed to `style` */
|
|
1266
|
-
styleOptions?: never;
|
|
1267
|
-
/** @deprecated `markdownOptions` has been renamed to `markdown` */
|
|
1268
|
-
markdownOptions?: never;
|
|
1269
|
-
/** @deprecated `buildOptions` has been renamed to `build` */
|
|
1270
|
-
buildOptions?: never;
|
|
1271
|
-
/** @deprecated `devOptions` has been renamed to `server` */
|
|
1272
|
-
devOptions?: never;
|
|
1273
1233
|
}
|
|
1274
1234
|
/**
|
|
1275
1235
|
* IDs for different stages of JS script injection:
|
|
@@ -1430,6 +1390,10 @@ export interface ComponentInstance {
|
|
|
1430
1390
|
default: AstroComponentFactory;
|
|
1431
1391
|
css?: string[];
|
|
1432
1392
|
prerender?: boolean;
|
|
1393
|
+
/**
|
|
1394
|
+
* Only used for logging if deprecated drafts feature is used
|
|
1395
|
+
*/
|
|
1396
|
+
frontmatter?: Record<string, any>;
|
|
1433
1397
|
getStaticPaths?: (options: GetStaticPathsOptions) => GetStaticPathsResult;
|
|
1434
1398
|
}
|
|
1435
1399
|
export interface AstroInstance {
|
|
@@ -1788,10 +1752,11 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
1788
1752
|
* ```
|
|
1789
1753
|
*/
|
|
1790
1754
|
locals: App.Locals;
|
|
1755
|
+
ResponseWithEncoding: typeof ResponseWithEncoding;
|
|
1791
1756
|
}
|
|
1792
1757
|
export type EndpointOutput = {
|
|
1793
1758
|
body: Body;
|
|
1794
|
-
encoding?:
|
|
1759
|
+
encoding?: BufferEncoding;
|
|
1795
1760
|
} | {
|
|
1796
1761
|
body: Uint8Array;
|
|
1797
1762
|
encoding: 'binary';
|
package/dist/content/utils.js
CHANGED
|
@@ -136,7 +136,10 @@ function getDataEntryId({
|
|
|
136
136
|
collection
|
|
137
137
|
}) {
|
|
138
138
|
const relativePath = getRelativeEntryPath(entry, collection, contentDir);
|
|
139
|
-
const withoutFileExt = relativePath.replace(
|
|
139
|
+
const withoutFileExt = normalizePath(relativePath).replace(
|
|
140
|
+
new RegExp(path.extname(relativePath) + "$"),
|
|
141
|
+
""
|
|
142
|
+
);
|
|
140
143
|
return withoutFileExt;
|
|
141
144
|
}
|
|
142
145
|
function getContentEntryIdAndSlug({
|
package/dist/core/app/index.js
CHANGED
|
@@ -137,7 +137,7 @@ class App {
|
|
|
137
137
|
return this.#renderError(request, { status: 500 });
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
if (
|
|
140
|
+
if (routeData.type === "page" || routeData.type === "redirect") {
|
|
141
141
|
if (STATUS_CODES.has(response.status)) {
|
|
142
142
|
return this.#renderError(request, {
|
|
143
143
|
response,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import mime from "mime";
|
|
2
|
-
import { attachCookiesToResponse } from "../cookies/index.js";
|
|
3
1
|
import { Pipeline } from "../pipeline.js";
|
|
4
2
|
class EndpointNotFoundError extends Error {
|
|
5
3
|
originalResponse;
|
|
@@ -9,36 +7,16 @@ class EndpointNotFoundError extends Error {
|
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
9
|
class SSRRoutePipeline extends Pipeline {
|
|
12
|
-
#encoder = new TextEncoder();
|
|
13
10
|
constructor(env) {
|
|
14
11
|
super(env);
|
|
15
12
|
this.setEndpointHandler(this.#ssrEndpointHandler);
|
|
16
13
|
}
|
|
17
14
|
// This function is responsible for handling the result coming from an endpoint.
|
|
18
15
|
async #ssrEndpointHandler(request, response) {
|
|
19
|
-
if (response.
|
|
20
|
-
|
|
21
|
-
throw new EndpointNotFoundError(response.response);
|
|
22
|
-
}
|
|
23
|
-
return response.response;
|
|
24
|
-
} else {
|
|
25
|
-
const url = new URL(request.url);
|
|
26
|
-
const headers = new Headers();
|
|
27
|
-
const mimeType = mime.getType(url.pathname);
|
|
28
|
-
if (mimeType) {
|
|
29
|
-
headers.set("Content-Type", `${mimeType};charset=utf-8`);
|
|
30
|
-
} else {
|
|
31
|
-
headers.set("Content-Type", "text/plain;charset=utf-8");
|
|
32
|
-
}
|
|
33
|
-
const bytes = response.encoding !== "binary" ? this.#encoder.encode(response.body) : response.body;
|
|
34
|
-
headers.set("Content-Length", bytes.byteLength.toString());
|
|
35
|
-
const newResponse = new Response(bytes, {
|
|
36
|
-
status: 200,
|
|
37
|
-
headers
|
|
38
|
-
});
|
|
39
|
-
attachCookiesToResponse(newResponse, response.cookies);
|
|
40
|
-
return newResponse;
|
|
16
|
+
if (response.headers.get("X-Astro-Response") === "Not-Found") {
|
|
17
|
+
throw new EndpointNotFoundError(response);
|
|
41
18
|
}
|
|
19
|
+
return response;
|
|
42
20
|
}
|
|
43
21
|
}
|
|
44
22
|
export {
|
|
@@ -2,8 +2,7 @@ import { Pipeline } from '../pipeline.js';
|
|
|
2
2
|
import type { BuildInternals } from './internal';
|
|
3
3
|
import type { PageBuildData, StaticBuildOptions } from './types';
|
|
4
4
|
import type { SSRManifest } from '../app/types';
|
|
5
|
-
import type { AstroConfig, AstroSettings
|
|
6
|
-
import type { BufferEncoding } from 'vfile';
|
|
5
|
+
import type { AstroConfig, AstroSettings } from '../../@types/astro';
|
|
7
6
|
/**
|
|
8
7
|
* This pipeline is responsible to gather the files emitted by the SSR build and generate the pages by executing these files.
|
|
9
8
|
*/
|
|
@@ -35,8 +34,4 @@ export declare class BuildPipeline extends Pipeline {
|
|
|
35
34
|
* It returns a map of page information and their relative entry point as a string.
|
|
36
35
|
*/
|
|
37
36
|
retrieveRoutesToGenerate(): Map<PageBuildData, string>;
|
|
38
|
-
computeBodyAndEncoding(routeType: RouteType, response: Response): Promise<{
|
|
39
|
-
body: string | Uint8Array;
|
|
40
|
-
encoding: BufferEncoding;
|
|
41
|
-
}>;
|
|
42
37
|
}
|
|
@@ -10,7 +10,6 @@ class BuildPipeline extends Pipeline {
|
|
|
10
10
|
#internals;
|
|
11
11
|
#staticBuildOptions;
|
|
12
12
|
#manifest;
|
|
13
|
-
#currentEndpointBody;
|
|
14
13
|
constructor(staticBuildOptions, internals, manifest) {
|
|
15
14
|
const ssr = isServerLikeOutput(staticBuildOptions.settings.config);
|
|
16
15
|
super(
|
|
@@ -123,43 +122,8 @@ class BuildPipeline extends Pipeline {
|
|
|
123
122
|
}
|
|
124
123
|
return pages;
|
|
125
124
|
}
|
|
126
|
-
async #handleEndpointResult(
|
|
127
|
-
|
|
128
|
-
if (!response.response.body) {
|
|
129
|
-
return new Response(null);
|
|
130
|
-
}
|
|
131
|
-
const ab = await response.response.arrayBuffer();
|
|
132
|
-
const body = new Uint8Array(ab);
|
|
133
|
-
this.#currentEndpointBody = {
|
|
134
|
-
body,
|
|
135
|
-
encoding: "utf-8"
|
|
136
|
-
};
|
|
137
|
-
return response.response;
|
|
138
|
-
} else {
|
|
139
|
-
if (response.encoding) {
|
|
140
|
-
this.#currentEndpointBody = {
|
|
141
|
-
body: response.body,
|
|
142
|
-
encoding: response.encoding
|
|
143
|
-
};
|
|
144
|
-
const headers = new Headers();
|
|
145
|
-
headers.set("X-Astro-Encoding", response.encoding);
|
|
146
|
-
return new Response(response.body, {
|
|
147
|
-
headers
|
|
148
|
-
});
|
|
149
|
-
} else {
|
|
150
|
-
return new Response(response.body);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
async computeBodyAndEncoding(routeType, response) {
|
|
155
|
-
const encoding = response.headers.get("X-Astro-Encoding") ?? "utf-8";
|
|
156
|
-
if (this.#currentEndpointBody) {
|
|
157
|
-
const currentEndpointBody = this.#currentEndpointBody;
|
|
158
|
-
this.#currentEndpointBody = void 0;
|
|
159
|
-
return currentEndpointBody;
|
|
160
|
-
} else {
|
|
161
|
-
return { body: await response.text(), encoding };
|
|
162
|
-
}
|
|
125
|
+
async #handleEndpointResult(_, response) {
|
|
126
|
+
return response;
|
|
163
127
|
}
|
|
164
128
|
}
|
|
165
129
|
export {
|
|
@@ -190,6 +190,10 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline, logger) {
|
|
|
190
190
|
const pageModule = await pageModulePromise();
|
|
191
191
|
if (shouldSkipDraft(pageModule, pipeline.getSettings())) {
|
|
192
192
|
logger.info(null, `${magenta("\u26A0\uFE0F")} Skipping draft ${pageData.route.component}`);
|
|
193
|
+
logger.warn(
|
|
194
|
+
"astro",
|
|
195
|
+
`The drafts feature is deprecated. You should migrate to content collections instead. See https://docs.astro.build/en/guides/content-collections/#filtering-collection-queries for more information.`
|
|
196
|
+
);
|
|
193
197
|
return;
|
|
194
198
|
}
|
|
195
199
|
const generationOptions = {
|
|
@@ -211,15 +215,17 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline, logger) {
|
|
|
211
215
|
pipeline.getStaticBuildOptions(),
|
|
212
216
|
builtPaths
|
|
213
217
|
);
|
|
218
|
+
let prevTimeEnd = timeStart;
|
|
214
219
|
for (let i = 0; i < paths.length; i++) {
|
|
215
220
|
const path = paths[i];
|
|
216
221
|
await generatePath(path, generationOptions, pipeline);
|
|
217
222
|
const timeEnd = performance.now();
|
|
218
|
-
const timeChange = getTimeStat(
|
|
223
|
+
const timeChange = getTimeStat(prevTimeEnd, timeEnd);
|
|
219
224
|
const timeIncrease = `(+${timeChange})`;
|
|
220
225
|
const filePath = getOutputFilename(pipeline.getConfig(), path, pageData.route.type);
|
|
221
226
|
const lineIcon = i === paths.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
222
227
|
logger.info(null, ` ${cyan(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`);
|
|
228
|
+
prevTimeEnd = timeEnd;
|
|
223
229
|
}
|
|
224
230
|
}
|
|
225
231
|
async function getPathsForRoute(pageData, mod, opts, builtPaths) {
|
|
@@ -417,19 +423,14 @@ async function generatePath(pathname, gopts, pipeline) {
|
|
|
417
423
|
} else {
|
|
418
424
|
if (!response.body)
|
|
419
425
|
return;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
encoding = result.encoding;
|
|
426
|
+
body = Buffer.from(await response.arrayBuffer());
|
|
427
|
+
encoding = response.headers.get("X-Astro-Encoding") ?? "utf-8";
|
|
423
428
|
}
|
|
424
429
|
const outFolder = getOutFolder(pipeline.getConfig(), pathname, pageData.route.type);
|
|
425
430
|
const outFile = getOutFile(pipeline.getConfig(), outFolder, pathname, pageData.route.type);
|
|
426
431
|
pageData.route.distURL = outFile;
|
|
427
|
-
const possibleEncoding = response.headers.get("X-Astro-Encoding");
|
|
428
|
-
if (possibleEncoding) {
|
|
429
|
-
encoding = possibleEncoding;
|
|
430
|
-
}
|
|
431
432
|
await fs.promises.mkdir(outFolder, { recursive: true });
|
|
432
|
-
await fs.promises.writeFile(outFile, body, encoding
|
|
433
|
+
await fs.promises.writeFile(outFile, body, encoding);
|
|
433
434
|
}
|
|
434
435
|
function createBuildManifest(settings, internals, renderers) {
|
|
435
436
|
return {
|
|
@@ -10,59 +10,7 @@ import { formatConfigErrorMessage } from "../messages.js";
|
|
|
10
10
|
import { mergeConfig } from "./merge.js";
|
|
11
11
|
import { createRelativeSchema } from "./schema.js";
|
|
12
12
|
import { loadConfigWithVite } from "./vite-load.js";
|
|
13
|
-
const LEGACY_ASTRO_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
14
|
-
"projectRoot",
|
|
15
|
-
"src",
|
|
16
|
-
"pages",
|
|
17
|
-
"public",
|
|
18
|
-
"dist",
|
|
19
|
-
"styleOptions",
|
|
20
|
-
"markdownOptions",
|
|
21
|
-
"buildOptions",
|
|
22
|
-
"devOptions"
|
|
23
|
-
]);
|
|
24
13
|
async function validateConfig(userConfig, root, cmd) {
|
|
25
|
-
if (userConfig.hasOwnProperty("renderers")) {
|
|
26
|
-
console.error('Astro "renderers" are now "integrations"!');
|
|
27
|
-
console.error("Update your configuration and install new dependencies:");
|
|
28
|
-
try {
|
|
29
|
-
const rendererKeywords = userConfig.renderers.map(
|
|
30
|
-
(r) => r.replace("@astrojs/renderer-", "")
|
|
31
|
-
);
|
|
32
|
-
const rendererImports = rendererKeywords.map((r) => ` import ${r} from '@astrojs/${r === "solid" ? "solid-js" : r}';`).join("\n");
|
|
33
|
-
const rendererIntegrations = rendererKeywords.map((r) => ` ${r}(),`).join("\n");
|
|
34
|
-
console.error("");
|
|
35
|
-
console.error(colors.dim(" // astro.config.js"));
|
|
36
|
-
if (rendererImports.length > 0) {
|
|
37
|
-
console.error(colors.green(rendererImports));
|
|
38
|
-
}
|
|
39
|
-
console.error("");
|
|
40
|
-
console.error(colors.dim(" // ..."));
|
|
41
|
-
if (rendererIntegrations.length > 0) {
|
|
42
|
-
console.error(colors.green(" integrations: ["));
|
|
43
|
-
console.error(colors.green(rendererIntegrations));
|
|
44
|
-
console.error(colors.green(" ],"));
|
|
45
|
-
} else {
|
|
46
|
-
console.error(colors.green(" integrations: [],"));
|
|
47
|
-
}
|
|
48
|
-
console.error("");
|
|
49
|
-
} catch (err) {
|
|
50
|
-
}
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
let legacyConfigKey;
|
|
54
|
-
for (const key of Object.keys(userConfig)) {
|
|
55
|
-
if (LEGACY_ASTRO_CONFIG_KEYS.has(key)) {
|
|
56
|
-
legacyConfigKey = key;
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (legacyConfigKey) {
|
|
61
|
-
throw new AstroError({
|
|
62
|
-
...AstroErrorData.ConfigLegacyKey,
|
|
63
|
-
message: AstroErrorData.ConfigLegacyKey.message(legacyConfigKey)
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
14
|
const AstroConfigRelativeSchema = createRelativeSchema(cmd, root);
|
|
67
15
|
let result;
|
|
68
16
|
try {
|