astro 7.0.0-alpha.0 → 7.0.0-alpha.2
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/Code.astro +1 -1
- package/dist/actions/handler.d.ts +32 -0
- package/dist/actions/handler.js +45 -0
- package/dist/actions/runtime/server.js +1 -1
- package/dist/assets/build/generate.js +1 -1
- package/dist/assets/build/remote.d.ts +3 -2
- package/dist/assets/build/remote.js +16 -9
- package/dist/assets/endpoint/dev.js +1 -1
- package/dist/assets/endpoint/generic.js +8 -20
- package/dist/assets/endpoint/loadImage.d.ts +11 -0
- package/dist/assets/endpoint/loadImage.js +19 -0
- package/dist/assets/endpoint/shared.js +7 -2
- package/dist/assets/fonts/config.d.ts +4 -4
- package/dist/assets/fonts/core/optimize-fallbacks.js +38 -13
- package/dist/assets/fonts/definitions.d.ts +2 -2
- package/dist/assets/fonts/infra/system-fallbacks-provider.d.ts +2 -2
- package/dist/assets/fonts/infra/system-fallbacks-provider.js +46 -9
- package/dist/assets/fonts/types.d.ts +1 -0
- package/dist/assets/index.d.ts +1 -0
- package/dist/assets/index.js +2 -0
- package/dist/assets/internal.js +22 -3
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/services/service.js +9 -9
- package/dist/assets/services/sharp.js +53 -18
- package/dist/assets/utils/generateImageStylesCSS.js +26 -6
- package/dist/assets/utils/index.d.ts +1 -0
- package/dist/assets/utils/index.js +2 -0
- package/dist/assets/utils/inferSourceFormat.d.ts +8 -3
- package/dist/assets/utils/inferSourceFormat.js +15 -4
- package/dist/assets/utils/metadata.js +1 -1
- package/dist/assets/utils/redirectValidation.d.ts +48 -0
- package/dist/assets/utils/redirectValidation.js +48 -0
- package/dist/assets/utils/remoteProbe.js +25 -2
- package/dist/assets/utils/vendor/image-size/types/svg.js +1 -1
- package/dist/cli/add/index.js +7 -58
- package/dist/cli/dev/background.d.ts +16 -0
- package/dist/cli/dev/background.js +116 -0
- package/dist/cli/dev/index.js +82 -3
- package/dist/cli/dev/logs.d.ts +6 -0
- package/dist/cli/dev/logs.js +72 -0
- package/dist/cli/dev/status.d.ts +15 -0
- package/dist/cli/dev/status.js +27 -0
- package/dist/cli/dev/stop.d.ts +12 -0
- package/dist/cli/dev/stop.js +43 -0
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/container/index.js +18 -14
- package/dist/content/content-layer.js +16 -11
- package/dist/content/data-store.d.ts +1 -1
- package/dist/content/loaders/types.d.ts +1 -1
- package/dist/content/runtime-assets.d.ts +2 -2
- package/dist/content/runtime.d.ts +1 -1
- package/dist/content/runtime.js +9 -4
- package/dist/content/server-listeners.js +0 -4
- package/dist/content/types-generator.js +5 -1
- package/dist/content/utils.d.ts +1 -1
- package/dist/content/utils.js +1 -1
- package/dist/content/vite-plugin-content-assets.js +1 -0
- package/dist/content/vite-plugin-content-virtual-mod.js +9 -1
- package/dist/core/app/base.d.ts +42 -15
- package/dist/core/app/base.js +151 -375
- package/dist/core/app/dev/app.d.ts +3 -2
- package/dist/core/app/dev/app.js +4 -60
- package/dist/core/app/entrypoints/node.d.ts +1 -1
- package/dist/core/app/entrypoints/node.js +2 -0
- package/dist/core/app/entrypoints/virtual/dev.js +2 -0
- package/dist/core/app/entrypoints/virtual/prod.js +4 -1
- package/dist/core/app/node.d.ts +16 -0
- package/dist/core/app/node.js +59 -13
- package/dist/core/app/prepare-response.d.ts +11 -0
- package/dist/core/app/prepare-response.js +18 -0
- package/dist/core/app/render-options.d.ts +11 -0
- package/dist/core/app/render-options.js +11 -0
- package/dist/core/base-pipeline.d.ts +48 -1
- package/dist/core/base-pipeline.js +63 -8
- package/dist/core/build/app.d.ts +3 -4
- package/dist/core/build/app.js +3 -17
- package/dist/core/build/generate.js +8 -1
- package/dist/core/build/index.d.ts +0 -11
- package/dist/core/build/index.js +0 -3
- package/dist/core/build/internal.d.ts +7 -0
- package/dist/core/build/plugins/plugin-chunk-imports.d.ts +6 -0
- package/dist/core/build/plugins/plugin-chunk-imports.js +29 -17
- package/dist/core/build/plugins/plugin-css.js +40 -1
- package/dist/core/build/plugins/plugin-internals.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +11 -1
- package/dist/core/build/static-build.js +22 -141
- package/dist/core/build/types.d.ts +0 -1
- package/dist/core/build/util.js +8 -1
- package/dist/core/build/vite-build-config.d.ts +28 -0
- package/dist/core/build/vite-build-config.js +165 -0
- package/dist/core/cache/handler.d.ts +29 -0
- package/dist/core/cache/handler.js +81 -0
- package/dist/core/compile/style.js +18 -1
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/index.js +4 -1
- package/dist/core/config/merge.js +4 -0
- package/dist/core/config/schemas/base.d.ts +25 -13
- package/dist/core/config/schemas/base.js +39 -10
- package/dist/core/config/schemas/relative.d.ts +76 -49
- package/dist/core/config/schemas/relative.js +2 -3
- package/dist/core/config/settings.js +2 -4
- package/dist/core/config/tsconfig.d.ts +24 -9
- package/dist/core/config/tsconfig.js +54 -45
- package/dist/core/config/validate.js +59 -0
- package/dist/core/constants.d.ts +27 -1
- package/dist/core/constants.js +14 -1
- package/dist/core/cookies/cookies.d.ts +7 -2
- package/dist/core/cookies/cookies.js +11 -4
- package/dist/core/cookies/response.d.ts +1 -1
- package/dist/core/cookies/response.js +1 -2
- package/dist/core/create-vite.js +18 -1
- package/dist/core/csp/config.js +17 -5
- package/dist/core/csp/runtime.js +6 -4
- package/dist/core/dev/dev.d.ts +1 -0
- package/dist/core/dev/dev.js +4 -13
- package/dist/core/dev/lockfile.d.ts +54 -0
- package/dist/core/dev/lockfile.js +93 -0
- package/dist/core/errors/build-handler.d.ts +17 -0
- package/dist/core/errors/build-handler.js +22 -0
- package/dist/core/errors/default-handler.d.ts +14 -0
- package/dist/core/errors/default-handler.js +144 -0
- package/dist/core/errors/dev-handler.d.ts +21 -0
- package/dist/core/errors/dev-handler.js +82 -0
- package/dist/core/errors/errors-data.d.ts +43 -38
- package/dist/core/errors/errors-data.js +79 -73
- package/dist/core/errors/handler.d.ts +9 -0
- package/dist/core/errors/handler.js +0 -0
- package/dist/core/errors/zod-error-map.js +30 -1
- package/dist/core/fetch/default-handler.d.ts +17 -0
- package/dist/core/fetch/default-handler.js +45 -0
- package/dist/core/fetch/fetch-state.d.ts +230 -0
- package/dist/core/fetch/fetch-state.js +896 -0
- package/dist/core/fetch/index.d.ts +61 -0
- package/dist/core/fetch/index.js +121 -0
- package/dist/core/fetch/types.d.ts +25 -0
- package/dist/core/fetch/types.js +0 -0
- package/dist/core/fetch/vite-plugin.d.ts +5 -0
- package/dist/core/fetch/vite-plugin.js +76 -0
- package/dist/core/hono/index.d.ts +21 -0
- package/dist/core/hono/index.js +101 -0
- package/dist/core/i18n/domain.d.ts +12 -0
- package/dist/core/i18n/domain.js +66 -0
- package/dist/core/i18n/handler.d.ts +18 -0
- package/dist/core/i18n/handler.js +122 -0
- package/dist/core/logger/core.d.ts +9 -1
- package/dist/core/logger/core.js +17 -1
- package/dist/core/messages/runtime.d.ts +0 -3
- package/dist/core/messages/runtime.js +1 -9
- package/dist/core/middleware/astro-middleware.d.ts +27 -0
- package/dist/core/middleware/astro-middleware.js +51 -0
- package/dist/core/module-loader/vite.js +1 -2
- package/dist/core/pages/handler.d.ts +20 -0
- package/dist/core/pages/handler.js +75 -0
- package/dist/core/preview/index.js +6 -5
- package/dist/core/preview/static-preview-server.js +5 -2
- package/dist/core/redirects/render.d.ts +2 -2
- package/dist/core/redirects/render.js +7 -8
- package/dist/core/render/params-and-props.js +2 -2
- package/dist/core/render/route-cache.d.ts +1 -0
- package/dist/core/render/route-cache.js +4 -4
- package/dist/core/render/slots.js +9 -2
- package/dist/core/rewrites/handler.d.ts +37 -0
- package/dist/core/rewrites/handler.js +67 -0
- package/dist/core/routing/3xx.js +8 -4
- package/dist/core/routing/create-manifest.js +11 -1
- package/dist/core/routing/handler.d.ts +17 -0
- package/dist/core/routing/handler.js +171 -0
- package/dist/core/routing/match.d.ts +0 -7
- package/dist/core/routing/match.js +0 -5
- package/dist/core/routing/parse-route.js +1 -1
- package/dist/core/routing/pattern.js +1 -1
- package/dist/core/routing/rewrite.js +2 -5
- package/dist/core/routing/router.d.ts +8 -0
- package/dist/core/routing/router.js +28 -0
- package/dist/core/routing/trailing-slash-handler.d.ts +18 -0
- package/dist/core/routing/trailing-slash-handler.js +67 -0
- package/dist/core/routing/validation.js +1 -1
- package/dist/core/server-islands/vite-plugin-server-islands.d.ts +6 -1
- package/dist/core/server-islands/vite-plugin-server-islands.js +13 -3
- package/dist/core/session/config.d.ts +1 -1
- package/dist/core/session/drivers.d.ts +1 -1
- package/dist/core/session/handler.d.ts +11 -0
- package/dist/core/session/handler.js +33 -0
- package/dist/core/session/runtime.js +7 -2
- package/dist/core/util/normalized-url.d.ts +10 -0
- package/dist/core/util/normalized-url.js +24 -0
- package/dist/core/util/pathname.d.ts +10 -1
- package/dist/core/util/pathname.js +13 -4
- package/dist/environments.js +1 -1
- package/dist/events/session.d.ts +8 -0
- package/dist/events/session.js +11 -0
- package/dist/i18n/middleware.d.ts +10 -0
- package/dist/i18n/middleware.js +4 -88
- package/dist/i18n/utils.js +2 -2
- package/dist/jsx/rehype.d.ts +1 -1
- package/dist/manifest/virtual-module.js +3 -1
- package/dist/markdown/index.d.ts +4 -0
- package/dist/markdown/index.js +14 -0
- package/dist/prefetch/index.js +12 -7
- package/dist/prerender/utils.js +5 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js +9 -0
- package/dist/runtime/server/astro-island.js +57 -20
- package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt-dev.js +1 -1
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/jsx.js +1 -1
- package/dist/runtime/server/render/common.js +10 -4
- package/dist/runtime/server/render/component.js +8 -6
- package/dist/runtime/server/render/head.js +1 -5
- package/dist/runtime/server/render/server-islands.js +2 -1
- package/dist/runtime/server/render/util.js +2 -2
- package/dist/runtime/server/scripts.js +6 -0
- package/dist/runtime/server/transition.d.ts +1 -6
- package/dist/runtime/server/transition.js +0 -8
- package/dist/transitions/events.d.ts +0 -14
- package/dist/transitions/events.js +0 -14
- package/dist/transitions/index.d.ts +0 -1
- package/dist/transitions/index.js +0 -2
- package/dist/transitions/vite-plugin-transitions.js +2 -4
- package/dist/types/public/config.d.ts +96 -14
- package/dist/types/public/content.d.ts +5 -5
- package/dist/types/public/index.d.ts +2 -1
- package/dist/types/public/integrations.d.ts +11 -3
- package/dist/types/public/internal.d.ts +1 -1
- package/dist/types/public/manifest.d.ts +1 -1
- package/dist/virtual-modules/i18n.d.ts +2 -2
- package/dist/virtual-modules/i18n.js +1 -1
- package/dist/vite-plugin-app/app.d.ts +13 -6
- package/dist/vite-plugin-app/app.js +51 -89
- package/dist/vite-plugin-app/createAstroServerApp.d.ts +3 -1
- package/dist/vite-plugin-app/createAstroServerApp.js +4 -3
- package/dist/vite-plugin-astro-server/plugin.js +11 -5
- package/dist/vite-plugin-astro-server/route-guard.d.ts +33 -0
- package/dist/vite-plugin-astro-server/route-guard.js +42 -23
- package/dist/vite-plugin-dev-status/index.d.ts +2 -0
- package/dist/vite-plugin-dev-status/index.js +15 -0
- package/dist/vite-plugin-head/index.js +36 -19
- package/dist/vite-plugin-hmr-reload/index.d.ts +1 -1
- package/dist/vite-plugin-hmr-reload/index.js +23 -1
- package/dist/vite-plugin-integrations-container/index.js +15 -6
- package/dist/vite-plugin-markdown/content-entry-type.js +7 -4
- package/dist/vite-plugin-markdown/images.js +9 -11
- package/dist/vite-plugin-markdown/index.js +12 -11
- package/dist/vite-plugin-utils/index.d.ts +1 -0
- package/dist/vite-plugin-utils/index.js +10 -1
- package/package.json +23 -16
- package/templates/content/types.d.ts +1 -0
- package/types/transitions.d.ts +0 -7
- package/dist/core/render-context.d.ts +0 -77
- package/dist/core/render-context.js +0 -826
package/dist/core/app/base.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { RoutesList } from '../../types/astro.js';
|
|
2
2
|
import type { RemotePattern, RouteData } from '../../types/public/index.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type Pipeline } from '../base-pipeline.js';
|
|
4
4
|
import { getSetCookiesFromResponse } from '../cookies/index.js';
|
|
5
5
|
import { AstroIntegrationLogger, type AstroLogger } from '../logger/core.js';
|
|
6
|
-
import
|
|
6
|
+
import type { FetchHandler } from '../fetch/types.js';
|
|
7
|
+
import type { ErrorHandler } from '../errors/handler.js';
|
|
7
8
|
import type { WaitUntilHook } from '../wait-until.js';
|
|
8
9
|
import type { AppPipeline } from './pipeline.js';
|
|
9
10
|
import type { SSRManifest } from './types.js';
|
|
@@ -60,7 +61,7 @@ export interface RenderOptions {
|
|
|
60
61
|
routeData?: RouteData;
|
|
61
62
|
}
|
|
62
63
|
type RequiredRenderOptions = Required<RenderOptions>;
|
|
63
|
-
interface ResolvedRenderOptions {
|
|
64
|
+
export interface ResolvedRenderOptions {
|
|
64
65
|
addCookieHeader: RequiredRenderOptions['addCookieHeader'];
|
|
65
66
|
clientAddress: RequiredRenderOptions['clientAddress'] | undefined;
|
|
66
67
|
prerenderedErrorPageFetch: RequiredRenderOptions['prerenderedErrorPageFetch'] | undefined;
|
|
@@ -79,20 +80,38 @@ export interface RenderErrorOptions extends ResolvedRenderOptions {
|
|
|
79
80
|
* Allows passing an error to 500.astro. It will be available through `Astro.props.error`.
|
|
80
81
|
*/
|
|
81
82
|
error?: unknown;
|
|
83
|
+
/**
|
|
84
|
+
* The pathname to use for the error page render context. If omitted, the
|
|
85
|
+
* error handler computes it from `request` via a short-lived `FetchState`.
|
|
86
|
+
*/
|
|
87
|
+
pathname?: string;
|
|
82
88
|
}
|
|
83
89
|
type ErrorPagePath = `${string}/404` | `${string}/500` | `${string}/404/` | `${string}/500/` | `${string}404.html` | `${string}500.html`;
|
|
84
90
|
export declare abstract class BaseApp<P extends Pipeline = AppPipeline> {
|
|
85
91
|
#private;
|
|
86
92
|
manifest: SSRManifest;
|
|
87
|
-
manifestData:
|
|
93
|
+
manifestData: {
|
|
94
|
+
routes: RouteData[];
|
|
95
|
+
};
|
|
88
96
|
pipeline: P;
|
|
89
97
|
baseWithoutTrailingSlash: string;
|
|
90
98
|
get logger(): AstroLogger;
|
|
91
99
|
get adapterLogger(): AstroIntegrationLogger;
|
|
92
100
|
constructor(manifest: SSRManifest, streaming?: boolean, ...args: any[]);
|
|
101
|
+
/**
|
|
102
|
+
* Override the fetch handler used to dispatch requests. Entrypoints
|
|
103
|
+
* call this with the default export of `virtual:astro:fetchable` to
|
|
104
|
+
* plug in a user-authored handler from `src/app.ts`.
|
|
105
|
+
*/
|
|
106
|
+
setFetchHandler(handler: {
|
|
107
|
+
fetch: FetchHandler;
|
|
108
|
+
}): void;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the error handler strategy used by this app. Override to
|
|
111
|
+
* provide environment-specific behavior (dev overlay, build-time throws, etc.).
|
|
112
|
+
*/
|
|
113
|
+
protected createErrorHandler(): ErrorHandler;
|
|
93
114
|
abstract isDev(): boolean;
|
|
94
|
-
createRenderContext(payload: CreateRenderContext): Promise<RenderContext>;
|
|
95
|
-
getAdapterLogger(): AstroIntegrationLogger;
|
|
96
115
|
/**
|
|
97
116
|
* Resets the cached adapter logger so it picks up a new logger instance.
|
|
98
117
|
* Used by BuildApp when the logger is replaced via setOptions().
|
|
@@ -113,10 +132,17 @@ export declare abstract class BaseApp<P extends Pipeline = AppPipeline> {
|
|
|
113
132
|
set setManifestData(newManifestData: RoutesList);
|
|
114
133
|
removeBase(pathname: string): string;
|
|
115
134
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
135
|
+
* Decodes a pathname with `decodeURI`, falling back to the raw pathname when it
|
|
136
|
+
* contains an invalid percent-sequence (e.g. `%C0%AF`, an overlong-UTF-8 encoding of
|
|
137
|
+
* `/` commonly sent by path-traversal scanners). A raw `decodeURI()` would throw
|
|
138
|
+
* `URIError: URI malformed`, and because `match()` runs before `render()` that error
|
|
139
|
+
* escapes the adapter's request handler as an uncaught exception (HTTP 500) that user
|
|
140
|
+
* middleware can't catch.
|
|
141
|
+
*/
|
|
142
|
+
private safeDecodeURI;
|
|
143
|
+
/**
|
|
144
|
+
* Extracts the base-stripped, decoded pathname from a request.
|
|
145
|
+
* Used by adapters to compute the pathname for dev-mode route matching.
|
|
120
146
|
*/
|
|
121
147
|
getPathnameFromRequest(request: Request): string;
|
|
122
148
|
/**
|
|
@@ -128,7 +154,6 @@ export declare abstract class BaseApp<P extends Pipeline = AppPipeline> {
|
|
|
128
154
|
* @param allowPrerenderedRoutes
|
|
129
155
|
*/
|
|
130
156
|
match(request: Request, allowPrerenderedRoutes?: boolean): RouteData | undefined;
|
|
131
|
-
private createRouter;
|
|
132
157
|
/**
|
|
133
158
|
* A matching route function to use in the development server.
|
|
134
159
|
* Contrary to the `.match` function, this function resolves props and params, returning the correct
|
|
@@ -137,7 +162,6 @@ export declare abstract class BaseApp<P extends Pipeline = AppPipeline> {
|
|
|
137
162
|
*/
|
|
138
163
|
devMatch(pathname?: string): Promise<DevMatch | undefined> | undefined;
|
|
139
164
|
private computePathnameFromDomain;
|
|
140
|
-
private redirectTrailingSlash;
|
|
141
165
|
render(request: Request, { addCookieHeader, clientAddress, locals, prerenderedErrorPageFetch, routeData, waitUntil, }?: RenderOptions): Promise<Response>;
|
|
142
166
|
setCookieHeaders(response: Response): Generator<string, string[], any>;
|
|
143
167
|
/**
|
|
@@ -154,10 +178,13 @@ export declare abstract class BaseApp<P extends Pipeline = AppPipeline> {
|
|
|
154
178
|
static getSetCookieFromResponse: typeof getSetCookiesFromResponse;
|
|
155
179
|
/**
|
|
156
180
|
* If it is a known error code, try sending the according page (e.g. 404.astro / 500.astro).
|
|
157
|
-
* This also handles pre-rendered /404 or /500 routes
|
|
181
|
+
* This also handles pre-rendered /404 or /500 routes.
|
|
182
|
+
*
|
|
183
|
+
* Delegates to the app's configured `ErrorHandler`. To customize behavior
|
|
184
|
+
* for a specific environment, override `createErrorHandler()` rather than
|
|
185
|
+
* this method.
|
|
158
186
|
*/
|
|
159
|
-
renderError(request: Request,
|
|
160
|
-
private mergeResponses;
|
|
187
|
+
renderError(request: Request, options: RenderErrorOptions): Promise<Response>;
|
|
161
188
|
getDefaultStatusCode(routeData: RouteData, pathname: string): number;
|
|
162
189
|
getManifest(): SSRManifest;
|
|
163
190
|
logThisRequest({ pathname, method, statusCode, isRewrite, timeStart, }: {
|