diff --git a/src/content/docs/en/reference/adapter-reference.mdx b/src/content/docs/en/reference/adapter-reference.mdx index 7313348ed0cb4..7ad70ddc446cb 100644 --- a/src/content/docs/en/reference/adapter-reference.mdx +++ b/src/content/docs/en/reference/adapter-reference.mdx @@ -254,7 +254,7 @@ You will need to create a file that executes during server-side requests to enab
-**Type:** `(manifest: SSRManifest, options: any) => Record(manifest: SSRManifest, options: any) => Record\
-**Type:** `(manifest: SSRManifest, options: any) => Record(manifest: SSRManifest, options: any) => Record\
-**Type:** `(renderer:` [`AstroRenderer`](https://github.com/withastro/astro/blob/fdd607c5755034edf262e7b275732519328a33b2/packages/astro/src/%40types/astro.ts#L872-L883) `) => void;`
+**Type:** (renderer: AstroRenderer) => void;
**Examples:** [`svelte`](https://github.com/withastro/astro/blob/main/packages/integrations/svelte/src/index.ts), [`react`](https://github.com/withastro/astro/blob/main/packages/integrations/react/src/index.ts), [`preact`](https://github.com/withastro/astro/blob/main/packages/integrations/preact/src/index.ts), [`vue`](https://github.com/withastro/astro/blob/main/packages/integrations/vue/src/index.ts), [`solid`](https://github.com/withastro/astro/blob/main/packages/integrations/solid/src/index.ts)
-**Type:** `(directive:` [`ClientDirectiveConfig`](https://github.com/withastro/astro/blob/00327c213f74627ac9ca1dec774efa5bf71e9375/packages/astro/src/%40types/astro.ts#L1872-L1875) `) => void;`
+**Type:** (directive: ClientDirectiveConfig) => void;
-**Type:** `(middleware:` [`AstroIntegrationMiddleware`](https://github.com/withastro/astro/blob/852ac0f75dfca1b2602e9cdbfa0447d9998e2449/packages/astro/src/%40types/astro.ts#L2124-L2127) `) => void;`
+**Type:** (middleware: AstroIntegrationMiddleware) => void;
-**Type:** [`RouteOptions`](https://github.com/withastro/astro/blob/3b10b97a4fecd1dfd959b160a07b5b8427fe40a7/packages/astro/src/types/public/integrations.ts#L14-L27) +**Type:** `{ readonly component: string; prerender?: boolean; }`
An object with a `component` property to identify the route and the following additional values to allow you to configure the generated route: `prerender`. @@ -810,7 +810,7 @@ A function that sends a message to the dev toolbar that an app can listen for. T A function for integrations to trigger an update to the content layer during `astro dev`. This can be used, for example, to register a webhook endpoint during dev, or to open a socket to a CMS to listen for changes. -By default, `refreshContent` will refresh all collections. You can optionally pass a `loaders` property, which is an array of loader names. If provided, only collections that use those loaders will be refreshed. For example, A CMS integration could use this property to only refresh its own collections. +By default, `refreshContent()` will refresh all collections. You can optionally pass a `loaders` property, which is an array of loader names. If provided, only collections that use those loaders will be refreshed. For example, A CMS integration could use this property to only refresh its own collections. You can also pass a `context` object to the loaders. This can be used to pass arbitrary data such as the webhook body, or an event from the websocket. @@ -873,10 +873,10 @@ The loader can then access the `refreshContextData` property to get the webhook-**Type:** [`AddressInfo`](https://microsoft.github.io/PowerBI-JavaScript/interfaces/_node_modules__types_node_net_d_._net_.addressinfo.html) +**Type:** `AddressInfo`
-The address, family and port number supplied by the [Node.js Net module](https://nodejs.org/api/net.html). +The address, family and port number supplied by the [`server.address()` method of the Node.js Net module](https://nodejs.org/api/net.html#serveraddress). ### `astro:server:done` @@ -955,10 +955,10 @@ export default {
-**Type:** Map\
+**Type:** `Map
+
+**Type:** `string`
+
+ +**Type:** `string` +
+ +Specifies the source component URL. + +###### `route` + ++ +**Type:** [`RouteData`](#routedata) +
+ +Describes the information about the page route. + +###### `moduleSpecifier` + ++ +**Type:** `string` +
+ +Defines a string that can be resolved into a file path for the module. + +###### `styles` + +
+
+**Type:** `Array<{ depth: number; order: number; sheet: { type: 'inline'; content: string } | { type: 'external'; src: string } }>`
+
@@ -1052,7 +1103,7 @@ export default {
-**Type:** [`SerializedSSRManifest`](https://github.com/withastro/astro/blob/3b10b97a4fecd1dfd959b160a07b5b8427fe40a7/packages/astro/src/core/app/types.ts#L91-L109) +**Type:** [`SerializedSSRManifest`](#serialized-ssr-manifest-properties)
Allows you to create a custom build by accessing the SSR manifest. @@ -1071,6 +1122,77 @@ export default { } ``` +##### Serialized SSR manifest properties + +A serialized version of the [`SSRManifest`](#ssrmanifest), accessible through the [`astro:build:ssr` hook](#astrobuildssr). This contains the same information as `SSRManifest`, with some properties converted to serializable formats. + +###### `routes` + ++ +**Type:** `SerializedRouteInfo[]` +
+ +Defines a list of serialized route information. Each route contains the same properties as [`SSRManifest.routes`](#routes-1), with `routeData` converted to a JSON-serializable format. + +###### `assets` + ++ +**Type:** `string[]` +
+ +Defines a list of serialized asset file paths. + +###### `componentMetadata` + +
+
+**Type:** [string, SSRComponentMetadata][]
+
+ +**Type:** `[string, string][]` +
+ +Defines an array of key-value pairs where each entry is a tuple. The first element is the script identifier and the second is the script content. + +###### `clientDirectives` + +
+
+**Type:** `[string, string][]`
+
+
+**Type:** `[string, string][]`
+
+
+**Type:** `string`
+
@@ -1146,7 +1268,9 @@ export default { **Type:** [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL)
-A URL path to the build output directory. Note that if you need a valid absolute path string, you should use Node's built-in [`fileURLToPath`](https://nodejs.org/api/url.html#urlfileurltopathurl-options) utility. +A URL path to the build output directory. + +The following example uses Node's built-in [`fileURLToPath()`](https://nodejs.org/api/url.html#urlfileurltopathurl-options) utility to compute a valid absolute path string for a file provided by the integration: ```js import { fileURLToPath } from 'node:url'; @@ -1187,7 +1311,9 @@ export default { **Type:** [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) -A URL path to the build output directory. Note that if you need a valid absolute path string, you should use Node's built-in [`fileURLToPath`](https://nodejs.org/api/url.html#urlfileurltopathurl-options) utility. +A URL path to the build output directory. + +The following example uses Node's built-in [`fileURLToPath()`](https://nodejs.org/api/url.html#urlfileurltopathurl-options) utility to compute a valid absolute path string for a file provided by the integration before writing to it: ```js import { writeFile } from 'node:fs/promises'; @@ -1242,7 +1368,7 @@ Contains URLs to output files paths, grouped by [`IntegrationResolvedRoute`](#in **Type:** `{ pathname: string }[]` -A list of all generated pages. It is an object with one property. +A list of all generated pages. Each entry is an object with one property: - `pathname` - the finalized path of the page. @@ -1269,12 +1395,21 @@ The following types can be imported from the `astro` module: ```ts import type { AstroIntegrationLogger, + AstroIntegrationMiddleware, + AstroMiddlewareInstance, + AstroRenderer, + ClientDirectiveConfig, HookParameters, IntegrationResolvedRoute, RedirectConfig, RouteData, RoutePart, RouteType, + SSRComponentMetadata, + SSRLoadedRenderer, + SSRLoadedRendererValue, + SSRManifest, + SSRManifestCSP, ValidRedirectStatus, // The following are deprecated: IntegrationRouteData, @@ -1344,9 +1479,110 @@ The example above will produce logs with `[astro-format]` by default, and `[astr [astro-format/build] Build finished. ``` +### `AstroIntegrationMiddleware` + ++ +**Type:** `{ order: "pre" | "post"; entrypoint: string | URL; }` +
+ +Describes a [middleware added by an integration](#addmiddleware-option). + +#### `order` + ++ +**Type:** `"pre" | "post"` +
+ +Specifies whether the middleware should run before (`pre`) or after (`post`) other middleware. + +#### `entrypoint` + ++ +**Type:** `string | URL` +
+ +Defines the import path of the middleware. + +### `AstroMiddlewareInstance` + +
+
+**Type:** \{ onRequest?: MiddlewareHandler; \}
+
+ +**Type:** `{ name: string; clientEntrypoint?: string | URL; serverEntrypoint: string | URL; }` +
+ +Describes a [component framework renderer added by an integration](#addrenderer-option). + +#### `name` + ++ +**Type:** `string` +
+ +The name of the component framework renderer. + +#### `clientEntrypoint` + ++ +**Type:** `string | URL` +
+ +Defines the import path of the renderer that runs on the client whenever your component is used. + +#### `serverEntrypoint` + ++ +**Type:** `string | URL` +
+ +Defines the import path of the renderer that runs during server-side requests or static builds whenever your component is used. + +### `ClientDirectiveConfig` + ++ +**Type:** `{ name: string; entrypoint: string | URL; }` +
+ +Describes a [custom client directive added by an integration](#addclientdirective-option). + +#### `name` + ++ +**Type:** `string` +
+ +A custom name for the event triggered by the directive. + +#### `entrypoint` + ++ +**Type:** `string | URL` +
+ +Defines the import path of the code executed whenever the directive is used. + ### `HookParameters` -You can get the type of a hook’s arguments by passing the hook’s name to the `HookParameters` utility type. In the following example, a function’s `options` argument is typed to match the parameters of the `astro:config:setup` hook: +You can get the type of a hook’s arguments by passing the hook’s name to the `HookParameters` utility type. + +In the following example, a function’s `options` argument is typed to match the parameters of the [`astro:config:setup` hook](#astroconfigsetup): ```ts /HookParameters(?:<.+>)?/ import type { HookParameters } from 'astro'; @@ -1436,7 +1672,7 @@ Describes the destination of a redirect. This can be a string or an object conta ### `RouteData` -Describes the information about a route. This contains the following properties: +Describes the information about a route. #### `route` @@ -1609,7 +1845,7 @@ Determines if a route comes from Astro core (`internal`), an integration (`exter **Type:** `{ content: string; dynamic: boolean; spread: boolean; }` -Describes a route segment. This contains the following properties: +Describes a route segment. #### `content` @@ -1655,6 +1891,659 @@ A union of supported route types: * `redirect`: a route points to another route that lives in the file system * `fallback`: a route that doesn't exist in the file system that needs to be handled with other means, usually a middleware +### `SSRComponentMetadata` + ++ +**Type:** `{ propagation: PropagationHint; containsHead: boolean; }` +
+ +Describes the build metadata of a component rendered by the server. + +#### `propagation` + ++ +**Type:** `'none' | 'self' | 'in-tree'` +
+ +A description of how to render head content from this component, including whether the Astro runtime needs to wait for a component: +- `none`: The component does not propagate the head content. +- `self`: The component appends the head content. +- `in-tree`: Another component within this component's dependency tree appends the head content. + +#### `containsHead` + ++ +**Type**: `boolean` +
+ +Determines whether the component contains the head content. + +### `SSRLoadedRenderer` + ++ +**Type:** `{ name: string; clientEntrypoint?: string | URL; ssr: SSRLoadedRendererValue; }` +
+ +Describes a renderer available for the server to use. This is a subset of [`AstroRenderer`](#astrorenderer) with additional properties. + +#### `ssr` + ++ +**Type:** [`SSRLoadedRendererValue`](#ssrloadedrenderervalue) +
+ +Defines the functions and configuration used by the server for this framework. + +### `SSRLoadedRendererValue` + +Contains the functions and configuration necessary to render components on the server from a specific UI framework. + +#### `name` + ++ +**Type:** `string` +
+ +Specifies the name identifier for the renderer. + +#### `check()` + +
+
+**Type:** `AsyncRendererComponentFn
+
+**Type:** `AsyncRendererComponentFn<{ html: string; attrs?: Record
+
+**Type:** `boolean`
+
+
+**Type:** `() => string`
+
+
+**Type:** `string`
+
+ +**Type:** `string` +
+ +Defines the name of the [server adapter](/en/guides/on-demand-rendering/#server-adapters) used for on-demand rendering. + +#### `routes` + ++ +**Type:** `RouteInfo[]` +
+ +A list of information about the routes available in this project. Each entry contains the following properties. + +##### `routeData` + ++ +**Type:** [`RouteData`](#routedata) +
+ +An object describing known information about a route. + +##### `file` + ++ +**Type:** `string` +
+ +Specifies the file path to the built route entrypoint. + +##### `links` + ++ +**Type:** `string[]` +
+ +Defines a list of [HTML `link` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link) required by this route. + +##### `scripts` + ++ +**Type:** `Array<{ children: string; stage: string } | { type: 'inline' | 'external'; value: string }>` +
+ +Defines a list of scripts associated with this route. This includes both integration-injected scripts with `children` and `stage` properties and hoisted scripts with `type` and `value` properties. + +##### `styles` + +
+
+**Type:** `Array<{ type: "inline"; content: string; } | { type: "external"; src: string; }>`
+
+ +**Type:** `string` +
+ +Specifies the [configured `site`](/en/reference/configuration-reference/#site). + +#### `base` + ++ +**Type:** `string` +
+ +Specifies the [configured `base` path](/en/reference/configuration-reference/#base) to deploy to. + +#### `userAssetsBase` + +
+
+**Type:** `string | undefined`
+
+
+**Type:** [`AstroConfig['trailingSlash']`](/en/reference/configuration-reference/#trailingslash)
+
+
+**Type:** [`NonNullable
+
+
+**Type:** `boolean`
+
+
+**Type:** `string | ({ fallback: string; } & Record
+
+
+**Type:** SSRLoadedRenderer[]
+
+
+**Type:** `Map
+
+
+**Type:** `Record
+
+**Type:** `Map
+
+
+**Type:** `Set
+
+**Type:** Map\
+
+
+**Type:** `{ page: ImportComponentInstance; onRequest?: MiddlewareHandler; renderers: SSRLoadedRenderer[]; }`
+
+
+**Type:** `() => Promise
+
+**Type:** [`MiddlewareHandler`](/en/reference/modules/astro-middleware/#middlewarehandler)
+
+
+**Type:** SSRLoadedRenderer[]
+
+
+**Type:** Map\
+
+
+**Type:** `Map
+
+
+**Type:** `Map
+
+
+**Type:** `Promise
+
+
+**Type:** `SSRManifestI18n | undefined`
+
+ +**Type:** `"manual" | "pathname-prefix-always" | "pathname-prefix-other-locales" | "pathname-prefix-always-no-redirect" | "domains-prefix-always" | "domains-prefix-other-locales" | "domains-prefix-always-no-redirect"` +
+ +Defines the [i18n routing strategy](/en/reference/configuration-reference/#i18nrouting) configured. This determines how locales are handled in URLs and whether redirects occur. + +##### `locales` + ++ +**Type:** `Locales` +
+ +Specifies a list of [supported locales configured in the project](/en/reference/configuration-reference/#i18nlocales). + +##### `defaultLocale` + ++ +**Type:** `string` +
+ +Determines the [default locale configured in the project](/en/reference/configuration-reference/#i18ndefaultlocale). + +##### `fallback` + +
+
+**Type:** `Record
+ +**Type:** `"redirect" | "rewrite"` +
+ +Determines the [configured fallback strategy for the project](/en/reference/configuration-reference/#i18nroutingfallbacktype). + +##### `domainLookupTable` + +
+
+**Type:** `Record
+
+**Type:** () => Promise\<AstroMiddlewareInstance\> | AstroMiddlewareInstance
+
+
+**Type:** () => Promise\<\{ server: Record\
+
+
+**Type:** `boolean`
+
+
+**Type:** Partial\<RemotePattern\>[]
+
+
+**Type:** SessionConfig\
+
+
+**Type:** `string | URL`
+
+
+**Type:** `string | URL`
+
+
+**Type:** `string | URL`
+
+
+**Type:** `string | URL`
+
+
+**Type:** `string | URL`
+
+
+**Type:** `string | URL`
+
+
+**Type:** SSRManifestCSP | undefined
+
+
+**Type:** `Record
+
+
+
+ +**Type:** `'adapter' | 'meta' | 'header' | undefined` +
+ +Specifies whether CSP directives should be injected as a `meta` element, as a response `header`, or by the [`adapter` when it supports setting response headers](/en/reference/adapter-reference/#experimentalstaticheaders). + +#### `algorithm` + ++ +**Type:** `'SHA-256' | 'SHA-384' | 'SHA-512'` +
+ +Specifies the [configured hash function](/en/reference/experimental-flags/csp/#algorithm). + +#### `scriptHashes` + ++ +**Type:** `string[]` +
+ +Specifies a list of generated hashes for project scripts and [user-supplied hashes](/en/reference/experimental-flags/csp/#hashes) for external scripts. + +#### `scriptResources` + ++ +**Type:** `string[]` +
+ +Specifies a list of valid sources combining the [configured script resources](/en/reference/experimental-flags/csp/#resources) and the [injected script resources](/en/reference/experimental-flags/csp/#cspinsertscriptresource). + +#### `isStrictDynamic` + ++ +**Type:** `boolean` +
+ +Determines whether support for [dynamic script injection is enabled in the configuration](/en/reference/experimental-flags/csp/#strictdynamic). + +#### `styleHashes` + ++ +**Type:** `string[]` +
+ +Specifies a list of generated hashes for project styles and [user-supplied hashes](/en/reference/experimental-flags/csp/#hashes) for external styles. + +#### `styleResources` + ++ +**Type:** `string[]` +
+ +Specifies a list of valid sources combining the [configured style resources](/en/reference/experimental-flags/csp/#resources) and the [injected script resources](/en/reference/experimental-flags/csp/#cspinsertscriptresource). + +#### `directives` + ++ +**Type:** `CspDirective[]` +
+ +Specifies the [configured list of valid sources](/en/reference/experimental-flags/csp/#directives) for specific content types. + ### `ValidRedirectStatus`