astro 4.3.7 → 4.4.1
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/Image.astro +4 -0
- package/components/Picture.astro +4 -0
- package/dist/@types/astro.d.ts +42 -42
- package/dist/assets/build/generate.d.ts +1 -1
- package/dist/assets/build/generate.js +1 -2
- package/dist/assets/internal.js +14 -0
- package/dist/assets/types.d.ts +23 -2
- package/dist/assets/utils/metadata.js +3 -3
- package/dist/assets/utils/remoteProbe.d.ts +2 -0
- package/dist/assets/utils/remoteProbe.js +35 -0
- package/dist/assets/utils/vendor/image-size/detector.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/detector.js +24 -0
- package/dist/assets/utils/vendor/image-size/lookup.d.ts +10 -0
- package/dist/assets/utils/vendor/image-size/lookup.js +26 -0
- package/dist/assets/utils/vendor/image-size/types/bmp.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/bmp.js +11 -0
- package/dist/assets/utils/vendor/image-size/types/cur.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/cur.js +17 -0
- package/dist/assets/utils/vendor/image-size/types/dds.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/dds.js +11 -0
- package/dist/assets/utils/vendor/image-size/types/gif.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/gif.js +12 -0
- package/dist/assets/utils/vendor/image-size/types/heif.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/heif.js +53 -0
- package/dist/assets/utils/vendor/image-size/types/icns.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/icns.js +85 -0
- package/dist/assets/utils/vendor/image-size/types/ico.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/ico.js +43 -0
- package/dist/assets/utils/vendor/image-size/types/index.d.ts +3 -0
- package/dist/assets/utils/vendor/image-size/types/index.js +43 -0
- package/dist/assets/utils/vendor/image-size/types/interface.d.ts +13 -0
- package/dist/assets/utils/vendor/image-size/types/interface.js +0 -0
- package/dist/assets/utils/vendor/image-size/types/j2c.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/j2c.js +12 -0
- package/dist/assets/utils/vendor/image-size/types/jp2.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/jp2.js +25 -0
- package/dist/assets/utils/vendor/image-size/types/jpg.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/jpg.js +97 -0
- package/dist/assets/utils/vendor/image-size/types/ktx.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/ktx.js +19 -0
- package/dist/assets/utils/vendor/image-size/types/png.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/png.js +34 -0
- package/dist/assets/utils/vendor/image-size/types/pnm.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/pnm.js +69 -0
- package/dist/assets/utils/vendor/image-size/types/psd.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/psd.js +11 -0
- package/dist/assets/utils/vendor/image-size/types/svg.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/svg.js +94 -0
- package/dist/assets/utils/vendor/image-size/types/tga.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/tga.js +15 -0
- package/dist/assets/utils/vendor/image-size/types/tiff.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/tiff.js +66 -0
- package/dist/assets/utils/vendor/image-size/types/utils.d.ts +15 -0
- package/dist/assets/utils/vendor/image-size/types/utils.js +60 -0
- package/dist/assets/utils/vendor/image-size/types/webp.d.ts +2 -0
- package/dist/assets/utils/vendor/image-size/types/webp.js +52 -0
- package/dist/cli/add/babel.d.ts +1 -1
- package/dist/cli/add/index.js +10 -3
- package/dist/cli/db/index.js +2 -0
- package/dist/cli/info/index.js +2 -0
- package/dist/cli/preferences/index.js +2 -0
- package/dist/content/runtime.js +3 -1
- package/dist/content/types-generator.js +7 -27
- package/dist/core/app/index.js +39 -122
- package/dist/core/app/pipeline.d.ts +7 -0
- package/dist/core/app/pipeline.js +39 -0
- package/dist/core/base-pipeline.d.ts +59 -0
- package/dist/core/base-pipeline.js +27 -0
- package/dist/core/build/generate.d.ts +1 -1
- package/dist/core/build/generate.js +39 -109
- package/dist/core/build/index.js +0 -4
- package/dist/core/build/{buildPipeline.d.ts → pipeline.d.ts} +13 -13
- package/dist/core/build/pipeline.js +180 -0
- package/dist/core/build/plugins/plugin-css.js +6 -5
- package/dist/core/build/plugins/plugin-hoisted-scripts.js +6 -5
- package/dist/core/build/plugins/util.d.ts +2 -1
- package/dist/core/build/plugins/util.js +12 -1
- package/dist/core/build/types.d.ts +0 -2
- package/dist/core/constants.d.ts +10 -1
- package/dist/core/constants.js +14 -4
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.js +1 -1
- package/dist/core/endpoint/index.d.ts +5 -4
- package/dist/core/endpoint/index.js +7 -34
- package/dist/core/errors/errors-data.d.ts +16 -3
- package/dist/core/errors/errors-data.js +9 -2
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.d.ts +1 -1
- package/dist/core/middleware/callMiddleware.js +2 -9
- package/dist/core/middleware/index.d.ts +2 -2
- package/dist/core/middleware/index.js +74 -9
- package/dist/core/module-loader/vite.js +4 -4
- package/dist/core/preview/index.js +2 -0
- package/dist/core/preview/static-preview-server.js +1 -7
- package/dist/core/redirects/helpers.d.ts +1 -3
- package/dist/core/redirects/helpers.js +0 -29
- package/dist/core/redirects/index.d.ts +2 -1
- package/dist/core/redirects/index.js +3 -3
- package/dist/core/redirects/render.d.ts +2 -0
- package/dist/core/redirects/render.js +33 -0
- package/dist/core/render/index.d.ts +7 -13
- package/dist/core/render/index.js +7 -7
- package/dist/core/render/params-and-props.d.ts +8 -3
- package/dist/core/render/params-and-props.js +24 -16
- package/dist/core/render/result.d.ts +6 -5
- package/dist/core/render/result.js +3 -4
- package/dist/core/render-context.d.ts +32 -0
- package/dist/core/render-context.js +219 -0
- package/dist/core/routing/index.d.ts +0 -1
- package/dist/core/routing/index.js +0 -2
- package/dist/core/routing/manifest/create.js +11 -27
- package/dist/core/routing/params.d.ts +1 -7
- package/dist/core/routing/params.js +0 -15
- package/dist/core/sync/index.js +3 -3
- package/dist/i18n/middleware.d.ts +0 -5
- package/dist/i18n/middleware.js +61 -69
- package/dist/i18n/utils.d.ts +25 -0
- package/dist/{core/render/context.js → i18n/utils.js} +3 -49
- package/dist/prerender/routing.d.ts +1 -1
- package/dist/prerender/routing.js +20 -21
- package/dist/runtime/client/dev-toolbar/apps/astro.js +14 -10
- package/dist/runtime/client/dev-toolbar/apps/audit/a11y.js +2 -2
- package/dist/runtime/client/dev-toolbar/apps/audit/index.d.ts +1 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/index.js +115 -6
- package/dist/runtime/client/dev-toolbar/apps/audit/perf.d.ts +2 -0
- package/dist/runtime/client/dev-toolbar/apps/audit/perf.js +110 -0
- package/dist/runtime/client/dev-toolbar/apps/utils/highlight.d.ts +1 -1
- package/dist/runtime/client/dev-toolbar/apps/utils/highlight.js +6 -1
- package/dist/runtime/client/dev-toolbar/ui-library/card.js +1 -1
- package/dist/runtime/server/astro-island.js +10 -1
- package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +7 -0
- package/dist/runtime/server/astro-island.prebuilt-dev.js +4 -0
- 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/endpoint.js +2 -2
- package/dist/runtime/server/render/astro/render.d.ts +1 -0
- package/dist/runtime/server/render/astro/render.js +81 -2
- package/dist/runtime/server/render/component.js +6 -0
- package/dist/runtime/server/render/page.js +15 -2
- package/dist/runtime/server/render/util.d.ts +7 -0
- package/dist/runtime/server/render/util.js +15 -0
- package/dist/runtime/server/scripts.js +2 -4
- package/dist/runtime/server/transition.js +14 -1
- package/dist/vite-plugin-astro/hmr.d.ts +1 -0
- package/dist/vite-plugin-astro/hmr.js +7 -4
- package/dist/vite-plugin-astro-server/error.d.ts +2 -2
- package/dist/vite-plugin-astro-server/error.js +2 -5
- package/dist/vite-plugin-astro-server/index.d.ts +0 -6
- package/dist/vite-plugin-astro-server/index.js +0 -19
- package/dist/vite-plugin-astro-server/pipeline.d.ts +19 -0
- package/dist/vite-plugin-astro-server/pipeline.js +117 -0
- package/dist/vite-plugin-astro-server/plugin.js +3 -4
- package/dist/vite-plugin-astro-server/request.d.ts +3 -4
- package/dist/vite-plugin-astro-server/request.js +6 -9
- package/dist/vite-plugin-astro-server/route.d.ts +3 -4
- package/dist/vite-plugin-astro-server/route.js +34 -162
- package/dist/vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.js +3 -3
- package/package.json +7 -12
- package/dist/core/app/ssrPipeline.d.ts +0 -3
- package/dist/core/app/ssrPipeline.js +0 -6
- package/dist/core/build/buildPipeline.js +0 -150
- package/dist/core/pipeline.d.ts +0 -39
- package/dist/core/pipeline.js +0 -107
- package/dist/core/render/context.d.ts +0 -52
- package/dist/core/render/core.d.ts +0 -10
- package/dist/core/render/core.js +0 -65
- package/dist/core/render/environment.d.ts +0 -34
- package/dist/core/render/environment.js +0 -6
- package/dist/runtime/server/consts.d.ts +0 -1
- package/dist/runtime/server/consts.js +0 -4
- package/dist/vite-plugin-astro-server/devPipeline.d.ts +0 -22
- package/dist/vite-plugin-astro-server/devPipeline.js +0 -65
|
@@ -2,7 +2,6 @@ import type * as vite from 'vite';
|
|
|
2
2
|
import type { InlineConfig } from 'vite';
|
|
3
3
|
import type { AstroConfig, AstroSettings, ComponentInstance, ManifestData, MiddlewareHandler, RouteData, RuntimeMode, SSRLoadedRenderer } from '../../@types/astro.js';
|
|
4
4
|
import type { Logger } from '../logger/core.js';
|
|
5
|
-
import type { RouteCache } from '../render/route-cache.js';
|
|
6
5
|
export type ComponentPath = string;
|
|
7
6
|
export type ViteID = string;
|
|
8
7
|
export type PageOutput = AstroConfig['output'];
|
|
@@ -40,7 +39,6 @@ export interface StaticBuildOptions {
|
|
|
40
39
|
mode: RuntimeMode;
|
|
41
40
|
origin: string;
|
|
42
41
|
pageNames: string[];
|
|
43
|
-
routeCache: RouteCache;
|
|
44
42
|
viteConfig: InlineConfig;
|
|
45
43
|
teardownCompiler: boolean;
|
|
46
44
|
}
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
export declare const ASTRO_VERSION: string;
|
|
2
|
+
export declare const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
|
|
3
|
+
export declare const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
|
|
4
|
+
/**
|
|
5
|
+
* A response with one of these status codes will be rewritten
|
|
6
|
+
* with the result of rendering the respective error page.
|
|
7
|
+
*/
|
|
8
|
+
export declare const REROUTABLE_STATUS_CODES: number[];
|
|
9
|
+
export declare const clientAddressSymbol: unique symbol;
|
|
10
|
+
export declare const clientLocalsSymbol: unique symbol;
|
|
11
|
+
export declare const responseSentSymbol: unique symbol;
|
|
2
12
|
export declare const SUPPORTED_MARKDOWN_FILE_EXTENSIONS: readonly [".markdown", ".mdown", ".mkdn", ".mkd", ".mdwn", ".md"];
|
|
3
13
|
export declare const MIDDLEWARE_PATH_SEGMENT_NAME = "middleware";
|
|
4
|
-
export declare const ROUTE_DATA_SYMBOL = "astro.routeData";
|
package/dist/core/constants.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
const ASTRO_VERSION = "4.
|
|
1
|
+
const ASTRO_VERSION = "4.4.1";
|
|
2
|
+
const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
|
|
3
|
+
const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
|
|
4
|
+
const REROUTABLE_STATUS_CODES = [404, 500];
|
|
5
|
+
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
6
|
+
const clientLocalsSymbol = Symbol.for("astro.locals");
|
|
7
|
+
const responseSentSymbol = Symbol.for("astro.responseSent");
|
|
2
8
|
const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
|
|
3
9
|
".markdown",
|
|
4
10
|
".mdown",
|
|
@@ -8,10 +14,14 @@ const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
|
|
|
8
14
|
".md"
|
|
9
15
|
];
|
|
10
16
|
const MIDDLEWARE_PATH_SEGMENT_NAME = "middleware";
|
|
11
|
-
const ROUTE_DATA_SYMBOL = "astro.routeData";
|
|
12
17
|
export {
|
|
13
18
|
ASTRO_VERSION,
|
|
14
19
|
MIDDLEWARE_PATH_SEGMENT_NAME,
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
REROUTABLE_STATUS_CODES,
|
|
21
|
+
REROUTE_DIRECTIVE_HEADER,
|
|
22
|
+
ROUTE_TYPE_HEADER,
|
|
23
|
+
SUPPORTED_MARKDOWN_FILE_EXTENSIONS,
|
|
24
|
+
clientAddressSymbol,
|
|
25
|
+
clientLocalsSymbol,
|
|
26
|
+
responseSentSymbol
|
|
17
27
|
};
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
|
|
|
23
23
|
base: restart.container.settings.config.base
|
|
24
24
|
})
|
|
25
25
|
);
|
|
26
|
-
const currentVersion = "4.
|
|
26
|
+
const currentVersion = "4.4.1";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
package/dist/core/dev/restart.js
CHANGED
|
@@ -54,7 +54,7 @@ async function restartContainer(container) {
|
|
|
54
54
|
formatErrorMessage(collectErrorMetadata(error), logger.level() === "debug") + "\n"
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
|
-
container.viteServer.
|
|
57
|
+
container.viteServer.hot.send({
|
|
58
58
|
type: "error",
|
|
59
59
|
err: {
|
|
60
60
|
message: error.message,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { APIContext,
|
|
2
|
-
import
|
|
1
|
+
import type { APIContext, Locales, Params } from '../../@types/astro.js';
|
|
2
|
+
import type { AstroCookies } from '../cookies/index.js';
|
|
3
3
|
import type { RoutingStrategies } from '../config/schema.js';
|
|
4
4
|
type CreateAPIContext = {
|
|
5
5
|
request: Request;
|
|
@@ -10,12 +10,13 @@ type CreateAPIContext = {
|
|
|
10
10
|
locales: Locales | undefined;
|
|
11
11
|
routingStrategy: RoutingStrategies | undefined;
|
|
12
12
|
defaultLocale: string | undefined;
|
|
13
|
+
route: string;
|
|
14
|
+
cookies: AstroCookies;
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* Creates a context that holds all the information needed to handle an Astro endpoint.
|
|
16
18
|
*
|
|
17
19
|
* @param {CreateAPIContext} payload
|
|
18
20
|
*/
|
|
19
|
-
export declare function createAPIContext({ request, params, site, props, adapterName, locales, routingStrategy, defaultLocale, }: CreateAPIContext): APIContext;
|
|
20
|
-
export declare function callEndpoint(mod: EndpointHandler, env: Environment, ctx: RenderContext, onRequest: MiddlewareHandler | undefined): Promise<Response>;
|
|
21
|
+
export declare function createAPIContext({ request, params, site, props, adapterName, locales, routingStrategy, defaultLocale, route, cookies, }: CreateAPIContext): APIContext;
|
|
21
22
|
export {};
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ASTRO_VERSION } from "../constants.js";
|
|
3
|
-
import { AstroCookies, attachCookiesToResponse } from "../cookies/index.js";
|
|
1
|
+
import { ASTRO_VERSION, clientAddressSymbol, clientLocalsSymbol } from "../constants.js";
|
|
4
2
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
5
|
-
import { callMiddleware } from "../middleware/callMiddleware.js";
|
|
6
3
|
import {
|
|
7
4
|
computeCurrentLocale,
|
|
8
5
|
computePreferredLocale,
|
|
9
6
|
computePreferredLocaleList
|
|
10
|
-
} from "
|
|
11
|
-
import {} from "../render/index.js";
|
|
12
|
-
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
13
|
-
const clientLocalsSymbol = Symbol.for("astro.locals");
|
|
7
|
+
} from "../../i18n/utils.js";
|
|
14
8
|
function createAPIContext({
|
|
15
9
|
request,
|
|
16
10
|
params,
|
|
@@ -19,13 +13,15 @@ function createAPIContext({
|
|
|
19
13
|
adapterName,
|
|
20
14
|
locales,
|
|
21
15
|
routingStrategy,
|
|
22
|
-
defaultLocale
|
|
16
|
+
defaultLocale,
|
|
17
|
+
route,
|
|
18
|
+
cookies
|
|
23
19
|
}) {
|
|
24
20
|
let preferredLocale = void 0;
|
|
25
21
|
let preferredLocaleList = void 0;
|
|
26
22
|
let currentLocale = void 0;
|
|
27
23
|
const context = {
|
|
28
|
-
cookies
|
|
24
|
+
cookies,
|
|
29
25
|
request,
|
|
30
26
|
params,
|
|
31
27
|
site: site ? new URL(site) : void 0,
|
|
@@ -64,7 +60,7 @@ function createAPIContext({
|
|
|
64
60
|
return currentLocale;
|
|
65
61
|
}
|
|
66
62
|
if (locales) {
|
|
67
|
-
currentLocale = computeCurrentLocale(
|
|
63
|
+
currentLocale = computeCurrentLocale(route, locales, routingStrategy, defaultLocale);
|
|
68
64
|
}
|
|
69
65
|
return currentLocale;
|
|
70
66
|
},
|
|
@@ -104,29 +100,6 @@ function createAPIContext({
|
|
|
104
100
|
};
|
|
105
101
|
return context;
|
|
106
102
|
}
|
|
107
|
-
async function callEndpoint(mod, env, ctx, onRequest) {
|
|
108
|
-
const context = createAPIContext({
|
|
109
|
-
request: ctx.request,
|
|
110
|
-
params: ctx.params,
|
|
111
|
-
props: ctx.props,
|
|
112
|
-
site: env.site,
|
|
113
|
-
adapterName: env.adapterName,
|
|
114
|
-
routingStrategy: ctx.routing,
|
|
115
|
-
defaultLocale: ctx.defaultLocale,
|
|
116
|
-
locales: ctx.locales
|
|
117
|
-
});
|
|
118
|
-
let response;
|
|
119
|
-
if (onRequest) {
|
|
120
|
-
response = await callMiddleware(onRequest, context, async () => {
|
|
121
|
-
return await renderEndpoint(mod, context, env.ssr, env.logger);
|
|
122
|
-
});
|
|
123
|
-
} else {
|
|
124
|
-
response = await renderEndpoint(mod, context, env.ssr, env.logger);
|
|
125
|
-
}
|
|
126
|
-
attachCookiesToResponse(response, context.cookies);
|
|
127
|
-
return response;
|
|
128
|
-
}
|
|
129
103
|
export {
|
|
130
|
-
callEndpoint,
|
|
131
104
|
createAPIContext
|
|
132
105
|
};
|
|
@@ -453,12 +453,12 @@ export declare const InvalidImageService: {
|
|
|
453
453
|
/**
|
|
454
454
|
* @docs
|
|
455
455
|
* @message
|
|
456
|
-
* Missing width and height attributes for `IMAGE_URL`. When using remote images, both dimensions are
|
|
456
|
+
* Missing width and height attributes for `IMAGE_URL`. When using remote images, both dimensions are required in order to avoid cumulative layout shift (CLS).
|
|
457
457
|
* @see
|
|
458
458
|
* - [Images](https://docs.astro.build/en/guides/images/)
|
|
459
|
-
* - [Image component#width-and-height-required](https://docs.astro.build/en/guides/images/#width-and-height-required-for-
|
|
459
|
+
* - [Image component#width-and-height-required](https://docs.astro.build/en/guides/images/#width-and-height-required-for-images-in-public)
|
|
460
460
|
* @description
|
|
461
|
-
* For remote images, `width` and `height` cannot be inferred from the original file.
|
|
461
|
+
* For remote images, `width` and `height` cannot automatically be inferred from the original file. To avoid cumulative layout shift (CLS), either specify these two properties, or set [`inferSize`](https://docs.astro.build/en/guides/images/#infersize) to `true` to fetch a remote image's original dimensions.
|
|
462
462
|
*
|
|
463
463
|
* If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](https://docs.astro.build/en/guides/imports/#other-assets).
|
|
464
464
|
*/
|
|
@@ -468,6 +468,19 @@ export declare const MissingImageDimension: {
|
|
|
468
468
|
message: (missingDimension: 'width' | 'height' | 'both', imageURL: string) => string;
|
|
469
469
|
hint: string;
|
|
470
470
|
};
|
|
471
|
+
/**
|
|
472
|
+
* @docs
|
|
473
|
+
* @message
|
|
474
|
+
* Failed to get the dimensions for `IMAGE_URL`.
|
|
475
|
+
* @description
|
|
476
|
+
* Determining the remote image's dimensions failed. This is typically caused by an incorrect URL or attempting to infer the size of an image in the public folder which is not possible.
|
|
477
|
+
*/
|
|
478
|
+
export declare const FailedToFetchRemoteImageDimensions: {
|
|
479
|
+
name: string;
|
|
480
|
+
title: string;
|
|
481
|
+
message: (imageURL: string) => string;
|
|
482
|
+
hint: string;
|
|
483
|
+
};
|
|
471
484
|
/**
|
|
472
485
|
* @docs
|
|
473
486
|
* @description
|
|
@@ -164,8 +164,14 @@ const InvalidImageService = {
|
|
|
164
164
|
const MissingImageDimension = {
|
|
165
165
|
name: "MissingImageDimension",
|
|
166
166
|
title: "Missing image dimensions",
|
|
167
|
-
message: (missingDimension, imageURL) => `Missing ${missingDimension === "both" ? "width and height attributes" : `${missingDimension} attribute`} for ${imageURL}. When using remote images, both dimensions are
|
|
168
|
-
hint: "If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](https://docs.astro.build/en/guides/imports/#other-assets)."
|
|
167
|
+
message: (missingDimension, imageURL) => `Missing ${missingDimension === "both" ? "width and height attributes" : `${missingDimension} attribute`} for ${imageURL}. When using remote images, both dimensions are required unless in order to avoid CLS.`,
|
|
168
|
+
hint: "If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](https://docs.astro.build/en/guides/imports/#other-assets). You can also use `inferSize={true}` for remote images to get the original dimensions."
|
|
169
|
+
};
|
|
170
|
+
const FailedToFetchRemoteImageDimensions = {
|
|
171
|
+
name: "FailedToFetchRemoteImageDimensions",
|
|
172
|
+
title: "Failed to retrieve remote image dimensions",
|
|
173
|
+
message: (imageURL) => `Failed to get the dimensions for ${imageURL}.`,
|
|
174
|
+
hint: "Verify your remote image URL is accurate, and that you are not using `inferSize` with a file located in your `public/` folder."
|
|
169
175
|
};
|
|
170
176
|
const UnsupportedImageFormat = {
|
|
171
177
|
name: "UnsupportedImageFormat",
|
|
@@ -490,6 +496,7 @@ export {
|
|
|
490
496
|
DuplicateContentEntrySlugError,
|
|
491
497
|
ExpectedImage,
|
|
492
498
|
ExpectedImageOptions,
|
|
499
|
+
FailedToFetchRemoteImageDimensions,
|
|
493
500
|
FailedToFindPageMapSSR,
|
|
494
501
|
FailedToLoadModuleSSR,
|
|
495
502
|
GenerateContentTypesError,
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.
|
|
39
|
+
const version = "4.4.1";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -261,7 +261,7 @@ function printHelp({
|
|
|
261
261
|
message.push(
|
|
262
262
|
linebreak(),
|
|
263
263
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
264
|
-
`v${"4.
|
|
264
|
+
`v${"4.4.1"}`
|
|
265
265
|
)} ${headline}`
|
|
266
266
|
);
|
|
267
267
|
}
|
|
@@ -33,4 +33,4 @@ import type { APIContext, MiddlewareHandler } from '../../@types/astro.js';
|
|
|
33
33
|
* @param apiContext The API context
|
|
34
34
|
* @param responseFunction A callback function that should return a promise with the response
|
|
35
35
|
*/
|
|
36
|
-
export declare function callMiddleware(onRequest: MiddlewareHandler, apiContext: APIContext, responseFunction: () => Promise<Response>): Promise<Response>;
|
|
36
|
+
export declare function callMiddleware(onRequest: MiddlewareHandler, apiContext: APIContext, responseFunction: () => Promise<Response> | Response): Promise<Response>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { attachCookiesToResponse, responseHasCookies } from "../cookies/index.js";
|
|
2
1
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
3
2
|
async function callMiddleware(onRequest, apiContext, responseFunction) {
|
|
4
3
|
let nextCalled = false;
|
|
@@ -15,7 +14,7 @@ async function callMiddleware(onRequest, apiContext, responseFunction) {
|
|
|
15
14
|
if (value instanceof Response === false) {
|
|
16
15
|
throw new AstroError(AstroErrorData.MiddlewareNotAResponse);
|
|
17
16
|
}
|
|
18
|
-
return
|
|
17
|
+
return value;
|
|
19
18
|
} else {
|
|
20
19
|
if (responseFunctionPromise) {
|
|
21
20
|
return responseFunctionPromise;
|
|
@@ -28,16 +27,10 @@ async function callMiddleware(onRequest, apiContext, responseFunction) {
|
|
|
28
27
|
} else if (value instanceof Response === false) {
|
|
29
28
|
throw new AstroError(AstroErrorData.MiddlewareNotAResponse);
|
|
30
29
|
} else {
|
|
31
|
-
return
|
|
30
|
+
return value;
|
|
32
31
|
}
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
|
-
function ensureCookiesAttached(apiContext, response) {
|
|
36
|
-
if (apiContext.cookies !== void 0 && !responseHasCookies(response)) {
|
|
37
|
-
attachCookiesToResponse(response, apiContext.cookies);
|
|
38
|
-
}
|
|
39
|
-
return response;
|
|
40
|
-
}
|
|
41
34
|
export {
|
|
42
35
|
callMiddleware
|
|
43
36
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MiddlewareHandler, Params } from '../../@types/astro.js';
|
|
1
|
+
import type { APIContext, MiddlewareHandler, Params } from '../../@types/astro.js';
|
|
2
2
|
import { sequence } from './sequence.js';
|
|
3
3
|
declare function defineMiddleware(fn: MiddlewareHandler): MiddlewareHandler;
|
|
4
4
|
/**
|
|
@@ -21,7 +21,7 @@ export type CreateContext = {
|
|
|
21
21
|
/**
|
|
22
22
|
* Creates a context to be passed to Astro middleware `onRequest` function.
|
|
23
23
|
*/
|
|
24
|
-
declare function createContext({ request, params, userDefinedLocales }: CreateContext):
|
|
24
|
+
declare function createContext({ request, params, userDefinedLocales, }: CreateContext): APIContext;
|
|
25
25
|
/**
|
|
26
26
|
* It attempts to serialize `value` and return it as a string.
|
|
27
27
|
*
|
|
@@ -1,18 +1,83 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AstroCookies } from "../cookies/index.js";
|
|
2
2
|
import { sequence } from "./sequence.js";
|
|
3
|
+
import { ASTRO_VERSION } from "../constants.js";
|
|
4
|
+
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
5
|
+
import {
|
|
6
|
+
computeCurrentLocale,
|
|
7
|
+
computePreferredLocale,
|
|
8
|
+
computePreferredLocaleList
|
|
9
|
+
} from "../../i18n/utils.js";
|
|
10
|
+
const clientAddressSymbol = Symbol.for("astro.clientAddress");
|
|
11
|
+
const clientLocalsSymbol = Symbol.for("astro.locals");
|
|
3
12
|
function defineMiddleware(fn) {
|
|
4
13
|
return fn;
|
|
5
14
|
}
|
|
6
|
-
function createContext({
|
|
7
|
-
|
|
15
|
+
function createContext({
|
|
16
|
+
request,
|
|
17
|
+
params = {},
|
|
18
|
+
userDefinedLocales = []
|
|
19
|
+
}) {
|
|
20
|
+
let preferredLocale = void 0;
|
|
21
|
+
let preferredLocaleList = void 0;
|
|
22
|
+
let currentLocale = void 0;
|
|
23
|
+
const url = new URL(request.url);
|
|
24
|
+
const route = url.pathname;
|
|
25
|
+
return {
|
|
26
|
+
cookies: new AstroCookies(request),
|
|
8
27
|
request,
|
|
9
|
-
params
|
|
10
|
-
props: {},
|
|
28
|
+
params,
|
|
11
29
|
site: void 0,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
30
|
+
generator: `Astro v${ASTRO_VERSION}`,
|
|
31
|
+
props: {},
|
|
32
|
+
redirect(path, status) {
|
|
33
|
+
return new Response(null, {
|
|
34
|
+
status: status || 302,
|
|
35
|
+
headers: {
|
|
36
|
+
Location: path
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
get preferredLocale() {
|
|
41
|
+
return preferredLocale ??= computePreferredLocale(request, userDefinedLocales);
|
|
42
|
+
},
|
|
43
|
+
get preferredLocaleList() {
|
|
44
|
+
return preferredLocaleList ??= computePreferredLocaleList(request, userDefinedLocales);
|
|
45
|
+
},
|
|
46
|
+
get currentLocale() {
|
|
47
|
+
return currentLocale ??= computeCurrentLocale(
|
|
48
|
+
route,
|
|
49
|
+
userDefinedLocales,
|
|
50
|
+
void 0,
|
|
51
|
+
void 0
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
url,
|
|
55
|
+
get clientAddress() {
|
|
56
|
+
if (clientAddressSymbol in request) {
|
|
57
|
+
return Reflect.get(request, clientAddressSymbol);
|
|
58
|
+
}
|
|
59
|
+
throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
|
|
60
|
+
},
|
|
61
|
+
get locals() {
|
|
62
|
+
let locals = Reflect.get(request, clientLocalsSymbol);
|
|
63
|
+
if (locals === void 0) {
|
|
64
|
+
locals = {};
|
|
65
|
+
Reflect.set(request, clientLocalsSymbol, locals);
|
|
66
|
+
}
|
|
67
|
+
if (typeof locals !== "object") {
|
|
68
|
+
throw new AstroError(AstroErrorData.LocalsNotAnObject);
|
|
69
|
+
}
|
|
70
|
+
return locals;
|
|
71
|
+
},
|
|
72
|
+
// We define a custom property, so we can check the value passed to locals
|
|
73
|
+
set locals(val) {
|
|
74
|
+
if (typeof val !== "object") {
|
|
75
|
+
throw new AstroError(AstroErrorData.LocalsNotAnObject);
|
|
76
|
+
} else {
|
|
77
|
+
Reflect.set(request, clientLocalsSymbol, val);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
16
81
|
}
|
|
17
82
|
function isLocalsSerializable(value) {
|
|
18
83
|
let type = typeof value;
|
|
@@ -24,8 +24,8 @@ function createViteLoader(viteServer) {
|
|
|
24
24
|
events.emit("file-change", args);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
const _wsSend = viteServer.
|
|
28
|
-
viteServer.
|
|
27
|
+
const _wsSend = viteServer.hot.send;
|
|
28
|
+
viteServer.hot.send = function(...args) {
|
|
29
29
|
if (isTsconfigUpdated) {
|
|
30
30
|
isTsconfigUpdated = false;
|
|
31
31
|
return;
|
|
@@ -63,13 +63,13 @@ function createViteLoader(viteServer) {
|
|
|
63
63
|
return viteServer.ssrFixStacktrace(err);
|
|
64
64
|
},
|
|
65
65
|
clientReload() {
|
|
66
|
-
viteServer.
|
|
66
|
+
viteServer.hot.send({
|
|
67
67
|
type: "full-reload",
|
|
68
68
|
path: "*"
|
|
69
69
|
});
|
|
70
70
|
},
|
|
71
71
|
webSocketSend(msg) {
|
|
72
|
-
return viteServer.
|
|
72
|
+
return viteServer.hot.send(msg);
|
|
73
73
|
},
|
|
74
74
|
isHttps() {
|
|
75
75
|
return !!viteServer.config.server.https;
|
|
@@ -11,7 +11,9 @@ import { createSettings } from "../config/settings.js";
|
|
|
11
11
|
import createStaticPreviewServer from "./static-preview-server.js";
|
|
12
12
|
import { getResolvedHostForHttpServer } from "./util.js";
|
|
13
13
|
import { ensureProcessNodeEnv } from "../util.js";
|
|
14
|
+
import { apply as applyPolyfills } from "../polyfill.js";
|
|
14
15
|
async function preview(inlineConfig) {
|
|
16
|
+
applyPolyfills();
|
|
15
17
|
ensureProcessNodeEnv("production");
|
|
16
18
|
const logger = createNodeLogger(inlineConfig);
|
|
17
19
|
const { userConfig, astroConfig } = await resolveConfig(inlineConfig ?? {}, "preview");
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
2
|
import { performance } from "perf_hooks";
|
|
3
|
-
import enableDestroy from "server-destroy";
|
|
4
3
|
import { preview } from "vite";
|
|
5
4
|
import * as msg from "../messages.js";
|
|
6
5
|
import { getResolvedHostForHttpServer } from "./util.js";
|
|
@@ -30,7 +29,6 @@ async function createStaticPreviewServer(settings, logger) {
|
|
|
30
29
|
}
|
|
31
30
|
throw err;
|
|
32
31
|
}
|
|
33
|
-
enableDestroy(previewServer.httpServer);
|
|
34
32
|
logger.info(
|
|
35
33
|
"SKIP_FORMAT",
|
|
36
34
|
msg.serverStart({
|
|
@@ -51,11 +49,7 @@ async function createStaticPreviewServer(settings, logger) {
|
|
|
51
49
|
port: settings.config.server.port,
|
|
52
50
|
closed,
|
|
53
51
|
server: previewServer.httpServer,
|
|
54
|
-
stop:
|
|
55
|
-
await new Promise((resolve, reject) => {
|
|
56
|
-
previewServer.httpServer.destroy((err) => err ? reject(err) : resolve(void 0));
|
|
57
|
-
});
|
|
58
|
-
}
|
|
52
|
+
stop: previewServer.close.bind(previewServer)
|
|
59
53
|
};
|
|
60
54
|
}
|
|
61
55
|
export {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RedirectRouteData, RouteData } from '../../@types/astro.js';
|
|
2
2
|
export declare function routeIsRedirect(route: RouteData | undefined): route is RedirectRouteData;
|
|
3
3
|
export declare function routeIsFallback(route: RouteData | undefined): route is RedirectRouteData;
|
|
4
|
-
export declare function redirectRouteGenerate(redirectRoute: RouteData, data: Params): string;
|
|
5
|
-
export declare function redirectRouteStatus(redirectRoute: RouteData, method?: string): ValidRedirectStatus;
|
|
@@ -4,36 +4,7 @@ function routeIsRedirect(route) {
|
|
|
4
4
|
function routeIsFallback(route) {
|
|
5
5
|
return route?.type === "fallback";
|
|
6
6
|
}
|
|
7
|
-
function redirectRouteGenerate(redirectRoute, data) {
|
|
8
|
-
const routeData = redirectRoute.redirectRoute;
|
|
9
|
-
const route = redirectRoute.redirect;
|
|
10
|
-
if (typeof routeData !== "undefined") {
|
|
11
|
-
return routeData?.generate(data) || routeData?.pathname || "/";
|
|
12
|
-
} else if (typeof route === "string") {
|
|
13
|
-
let target = route;
|
|
14
|
-
for (const param of Object.keys(data)) {
|
|
15
|
-
const paramValue = data[param];
|
|
16
|
-
target = target.replace(`[${param}]`, paramValue);
|
|
17
|
-
target = target.replace(`[...${param}]`, paramValue);
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
} else if (typeof route === "undefined") {
|
|
21
|
-
return "/";
|
|
22
|
-
}
|
|
23
|
-
return route.destination;
|
|
24
|
-
}
|
|
25
|
-
function redirectRouteStatus(redirectRoute, method = "GET") {
|
|
26
|
-
const routeData = redirectRoute.redirectRoute;
|
|
27
|
-
if (routeData && typeof redirectRoute.redirect === "object") {
|
|
28
|
-
return redirectRoute.redirect.status;
|
|
29
|
-
} else if (method !== "GET") {
|
|
30
|
-
return 308;
|
|
31
|
-
}
|
|
32
|
-
return 301;
|
|
33
|
-
}
|
|
34
7
|
export {
|
|
35
|
-
redirectRouteGenerate,
|
|
36
|
-
redirectRouteStatus,
|
|
37
8
|
routeIsFallback,
|
|
38
9
|
routeIsRedirect
|
|
39
10
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { RedirectComponentInstance, RedirectSinglePageBuiltModule } from './component.js';
|
|
2
|
-
export {
|
|
2
|
+
export { routeIsRedirect } from './helpers.js';
|
|
3
3
|
export { getRedirectLocationOrThrow } from './validate.js';
|
|
4
|
+
export { renderRedirect } from './render.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RedirectComponentInstance, RedirectSinglePageBuiltModule } from "./component.js";
|
|
2
|
-
import {
|
|
2
|
+
import { routeIsRedirect } from "./helpers.js";
|
|
3
3
|
import { getRedirectLocationOrThrow } from "./validate.js";
|
|
4
|
+
import { renderRedirect } from "./render.js";
|
|
4
5
|
export {
|
|
5
6
|
RedirectComponentInstance,
|
|
6
7
|
RedirectSinglePageBuiltModule,
|
|
7
8
|
getRedirectLocationOrThrow,
|
|
8
|
-
|
|
9
|
-
redirectRouteStatus,
|
|
9
|
+
renderRedirect,
|
|
10
10
|
routeIsRedirect
|
|
11
11
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
async function renderRedirect(renderContext) {
|
|
2
|
+
const {
|
|
3
|
+
request: { method },
|
|
4
|
+
routeData
|
|
5
|
+
} = renderContext;
|
|
6
|
+
const { redirect, redirectRoute } = routeData;
|
|
7
|
+
const status = redirectRoute && typeof redirect === "object" ? redirect.status : method === "GET" ? 301 : 308;
|
|
8
|
+
const headers = { location: redirectRouteGenerate(renderContext) };
|
|
9
|
+
return new Response(null, { status, headers });
|
|
10
|
+
}
|
|
11
|
+
function redirectRouteGenerate(renderContext) {
|
|
12
|
+
const {
|
|
13
|
+
params,
|
|
14
|
+
routeData: { redirect, redirectRoute }
|
|
15
|
+
} = renderContext;
|
|
16
|
+
if (typeof redirectRoute !== "undefined") {
|
|
17
|
+
return redirectRoute?.generate(params) || redirectRoute?.pathname || "/";
|
|
18
|
+
} else if (typeof redirect === "string") {
|
|
19
|
+
let target = redirect;
|
|
20
|
+
for (const param of Object.keys(params)) {
|
|
21
|
+
const paramValue = params[param];
|
|
22
|
+
target = target.replace(`[${param}]`, paramValue);
|
|
23
|
+
target = target.replace(`[...${param}]`, paramValue);
|
|
24
|
+
}
|
|
25
|
+
return target;
|
|
26
|
+
} else if (typeof redirect === "undefined") {
|
|
27
|
+
return "/";
|
|
28
|
+
}
|
|
29
|
+
return redirect.destination;
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
renderRedirect
|
|
33
|
+
};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
5
|
-
export { createEnvironment } from './environment.js';
|
|
6
|
-
export { getParamsAndProps } from './params-and-props.js';
|
|
1
|
+
import type { ComponentInstance, RouteData } from '../../@types/astro.js';
|
|
2
|
+
import type { Pipeline } from '../base-pipeline.js';
|
|
3
|
+
export { Pipeline } from '../base-pipeline.js';
|
|
4
|
+
export { getParams, getProps } from './params-and-props.js';
|
|
7
5
|
export { loadRenderer } from './renderer.js';
|
|
8
|
-
export
|
|
6
|
+
export { createResult } from './result.js';
|
|
9
7
|
export interface SSROptions {
|
|
10
|
-
/** The
|
|
11
|
-
|
|
8
|
+
/** The pipeline instance */
|
|
9
|
+
pipeline: Pipeline;
|
|
12
10
|
/** location of file on disk */
|
|
13
11
|
filePath: URL;
|
|
14
12
|
/** the web request (needed for dynamic routes) */
|
|
@@ -19,8 +17,4 @@ export interface SSROptions {
|
|
|
19
17
|
request: Request;
|
|
20
18
|
/** optional, in case we need to render something outside a dev server */
|
|
21
19
|
route: RouteData;
|
|
22
|
-
/**
|
|
23
|
-
* Optional middlewares
|
|
24
|
-
*/
|
|
25
|
-
middleware?: AstroMiddlewareInstance;
|
|
26
20
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getParamsAndProps } from "./params-and-props.js";
|
|
1
|
+
import { Pipeline } from "../base-pipeline.js";
|
|
2
|
+
import { getParams, getProps } from "./params-and-props.js";
|
|
4
3
|
import { loadRenderer } from "./renderer.js";
|
|
4
|
+
import { createResult } from "./result.js";
|
|
5
5
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
Pipeline,
|
|
7
|
+
createResult,
|
|
8
|
+
getParams,
|
|
9
|
+
getProps,
|
|
10
10
|
loadRenderer
|
|
11
11
|
};
|
|
@@ -3,11 +3,16 @@ import type { Logger } from '../logger/core.js';
|
|
|
3
3
|
import type { RouteCache } from './route-cache.js';
|
|
4
4
|
interface GetParamsAndPropsOptions {
|
|
5
5
|
mod: ComponentInstance | undefined;
|
|
6
|
-
|
|
6
|
+
routeData?: RouteData | undefined;
|
|
7
7
|
routeCache: RouteCache;
|
|
8
8
|
pathname: string;
|
|
9
9
|
logger: Logger;
|
|
10
|
-
|
|
10
|
+
serverLike: boolean;
|
|
11
11
|
}
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function getProps(opts: GetParamsAndPropsOptions): Promise<Props>;
|
|
13
|
+
/**
|
|
14
|
+
* When given a route with the pattern `/[x]/[y]/[z]/svelte`, and a pathname `/a/b/c/svelte`,
|
|
15
|
+
* returns the params object: { x: "a", y: "b", z: "c" }.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getParams(route: RouteData, pathname: string): Params;
|
|
13
18
|
export {};
|