astro 3.5.1 → 3.5.3
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 +2 -1
- package/dist/@types/astro.d.ts +67 -62
- package/dist/content/vite-plugin-content-assets.js +1 -1
- package/dist/content/vite-plugin-content-virtual-mod.js +1 -1
- package/dist/core/build/plugins/plugin-css.js +8 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/vite-plugin.js +4 -2
- package/dist/transitions/router.js +1 -1
- package/package.json +1 -1
|
@@ -89,7 +89,8 @@ const { fallback = 'animate', handleForms } = Astro.props;
|
|
|
89
89
|
|
|
90
90
|
const form = el as HTMLFormElement;
|
|
91
91
|
const formData = new FormData(form);
|
|
92
|
-
|
|
92
|
+
// Use the form action, if defined, otherwise fallback to current path.
|
|
93
|
+
let action = form.action ?? location.pathname;
|
|
93
94
|
const options: Options = {};
|
|
94
95
|
if (form.method === 'get') {
|
|
95
96
|
const params = new URLSearchParams(formData as any);
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -464,67 +464,6 @@ export interface AstroUserConfig {
|
|
|
464
464
|
* ```
|
|
465
465
|
*/
|
|
466
466
|
redirects?: Record<string, RedirectConfig>;
|
|
467
|
-
/**
|
|
468
|
-
* @docs
|
|
469
|
-
* @name prefetch
|
|
470
|
-
* @type {boolean | object}
|
|
471
|
-
* @description
|
|
472
|
-
* Enable prefetching for links on your site to provide faster page transitions.
|
|
473
|
-
* (Enabled by default on pages using the `<ViewTransitions />` router. Set `prefetch: false` to opt out of this behaviour.)
|
|
474
|
-
*
|
|
475
|
-
* This configuration automatically adds a prefetch script to every page in the project
|
|
476
|
-
* giving you access to the `data-astro-prefetch` attribute.
|
|
477
|
-
* Add this attribute to any `<a />` link on your page to enable prefetching for that page.
|
|
478
|
-
*
|
|
479
|
-
* ```html
|
|
480
|
-
* <a href="/about" data-astro-prefetch>About</a>
|
|
481
|
-
* ```
|
|
482
|
-
* Further customize the default prefetching behavior using the [`prefetch.defaultStrategy`](#prefetchdefaultstrategy) and [`prefetch.prefetchAll`](#prefetchprefetchall) options.
|
|
483
|
-
*
|
|
484
|
-
* See the [Prefetch guide](https://docs.astro.build/en/guides/prefetch/) for more information.
|
|
485
|
-
*/
|
|
486
|
-
prefetch?: boolean | {
|
|
487
|
-
/**
|
|
488
|
-
* @docs
|
|
489
|
-
* @name prefetch.prefetchAll
|
|
490
|
-
* @type {boolean}
|
|
491
|
-
* @description
|
|
492
|
-
* Enable prefetching for all links, including those without the `data-astro-prefetch` attribute.
|
|
493
|
-
* This value defaults to `true` when using the `<ViewTransitions />` router. Otherwise, the default value is `false`.
|
|
494
|
-
*
|
|
495
|
-
* ```js
|
|
496
|
-
* prefetch: {
|
|
497
|
-
* prefetchAll: true
|
|
498
|
-
* }
|
|
499
|
-
* ```
|
|
500
|
-
*
|
|
501
|
-
* When set to `true`, you can disable prefetching individually by setting `data-astro-prefetch="false"` on any individual links.
|
|
502
|
-
*
|
|
503
|
-
* ```html
|
|
504
|
-
* <a href="/about" data-astro-prefetch="false">About</a>
|
|
505
|
-
*```
|
|
506
|
-
*/
|
|
507
|
-
prefetchAll?: boolean;
|
|
508
|
-
/**
|
|
509
|
-
* @docs
|
|
510
|
-
* @name prefetch.defaultStrategy
|
|
511
|
-
* @type {'tap' | 'hover' | 'viewport'}
|
|
512
|
-
* @default `'hover'`
|
|
513
|
-
* @description
|
|
514
|
-
* The default prefetch strategy to use when the `data-astro-prefetch` attribute is set on a link with no value.
|
|
515
|
-
*
|
|
516
|
-
* - `'tap'`: Prefetch just before you click on the link.
|
|
517
|
-
* - `'hover'`: Prefetch when you hover over or focus on the link. (default)
|
|
518
|
-
* - `'viewport'`: Prefetch as the links enter the viewport.
|
|
519
|
-
*
|
|
520
|
-
* You can override this default value and select a different strategy for any individual link by setting a value on the attribute.
|
|
521
|
-
*
|
|
522
|
-
* ```html
|
|
523
|
-
* <a href="/about" data-astro-prefetch="viewport">About</a>
|
|
524
|
-
* ```
|
|
525
|
-
*/
|
|
526
|
-
defaultStrategy?: 'tap' | 'hover' | 'viewport';
|
|
527
|
-
};
|
|
528
467
|
/**
|
|
529
468
|
* @docs
|
|
530
469
|
* @name site
|
|
@@ -893,6 +832,68 @@ export interface AstroUserConfig {
|
|
|
893
832
|
*/
|
|
894
833
|
excludeMiddleware?: boolean;
|
|
895
834
|
};
|
|
835
|
+
/**
|
|
836
|
+
* @docs
|
|
837
|
+
* @kind heading
|
|
838
|
+
* @name Prefetch Options
|
|
839
|
+
* @type {boolean | object}
|
|
840
|
+
* @description
|
|
841
|
+
* Enable prefetching for links on your site to provide faster page transitions.
|
|
842
|
+
* (Enabled by default on pages using the `<ViewTransitions />` router. Set `prefetch: false` to opt out of this behaviour.)
|
|
843
|
+
*
|
|
844
|
+
* This configuration automatically adds a prefetch script to every page in the project
|
|
845
|
+
* giving you access to the `data-astro-prefetch` attribute.
|
|
846
|
+
* Add this attribute to any `<a />` link on your page to enable prefetching for that page.
|
|
847
|
+
*
|
|
848
|
+
* ```html
|
|
849
|
+
* <a href="/about" data-astro-prefetch>About</a>
|
|
850
|
+
* ```
|
|
851
|
+
* Further customize the default prefetching behavior using the [`prefetch.defaultStrategy`](#prefetchdefaultstrategy) and [`prefetch.prefetchAll`](#prefetchprefetchall) options.
|
|
852
|
+
*
|
|
853
|
+
* See the [Prefetch guide](https://docs.astro.build/en/guides/prefetch/) for more information.
|
|
854
|
+
*/
|
|
855
|
+
prefetch?: boolean | {
|
|
856
|
+
/**
|
|
857
|
+
* @docs
|
|
858
|
+
* @name prefetch.prefetchAll
|
|
859
|
+
* @type {boolean}
|
|
860
|
+
* @description
|
|
861
|
+
* Enable prefetching for all links, including those without the `data-astro-prefetch` attribute.
|
|
862
|
+
* This value defaults to `true` when using the `<ViewTransitions />` router. Otherwise, the default value is `false`.
|
|
863
|
+
*
|
|
864
|
+
* ```js
|
|
865
|
+
* prefetch: {
|
|
866
|
+
* prefetchAll: true
|
|
867
|
+
* }
|
|
868
|
+
* ```
|
|
869
|
+
*
|
|
870
|
+
* When set to `true`, you can disable prefetching individually by setting `data-astro-prefetch="false"` on any individual links.
|
|
871
|
+
*
|
|
872
|
+
* ```html
|
|
873
|
+
* <a href="/about" data-astro-prefetch="false">About</a>
|
|
874
|
+
*```
|
|
875
|
+
*/
|
|
876
|
+
prefetchAll?: boolean;
|
|
877
|
+
/**
|
|
878
|
+
* @docs
|
|
879
|
+
* @name prefetch.defaultStrategy
|
|
880
|
+
* @type {'tap' | 'hover' | 'viewport'}
|
|
881
|
+
* @default `'hover'`
|
|
882
|
+
* @description
|
|
883
|
+
* The default prefetch strategy to use when the `data-astro-prefetch` attribute is set on a link with no value.
|
|
884
|
+
*
|
|
885
|
+
* - `'tap'`: Prefetch just before you click on the link.
|
|
886
|
+
* - `'hover'`: Prefetch when you hover over or focus on the link. (default)
|
|
887
|
+
* - `'viewport'`: Prefetch as the links enter the viewport.
|
|
888
|
+
*
|
|
889
|
+
* You can override this default value and select a different strategy for any individual link by setting a value on the attribute.
|
|
890
|
+
*
|
|
891
|
+
* ```html
|
|
892
|
+
* <a href="/about" data-astro-prefetch="viewport">About</a>
|
|
893
|
+
* ```
|
|
894
|
+
*/
|
|
895
|
+
defaultStrategy?: 'tap' | 'hover' | 'viewport';
|
|
896
|
+
};
|
|
896
897
|
/**
|
|
897
898
|
* @docs
|
|
898
899
|
* @kind heading
|
|
@@ -1351,6 +1352,7 @@ export interface AstroUserConfig {
|
|
|
1351
1352
|
i18n?: {
|
|
1352
1353
|
/**
|
|
1353
1354
|
* @docs
|
|
1355
|
+
* @kind h4
|
|
1354
1356
|
* @name experimental.i18n.defaultLocale
|
|
1355
1357
|
* @type {string}
|
|
1356
1358
|
* @version 3.5.0
|
|
@@ -1363,6 +1365,7 @@ export interface AstroUserConfig {
|
|
|
1363
1365
|
defaultLocale: string;
|
|
1364
1366
|
/**
|
|
1365
1367
|
* @docs
|
|
1368
|
+
* @kind h4
|
|
1366
1369
|
* @name experimental.i18n.locales
|
|
1367
1370
|
* @type {string[]}
|
|
1368
1371
|
* @version 3.5.0
|
|
@@ -1375,6 +1378,7 @@ export interface AstroUserConfig {
|
|
|
1375
1378
|
locales: string[];
|
|
1376
1379
|
/**
|
|
1377
1380
|
* @docs
|
|
1381
|
+
* @kind h4
|
|
1378
1382
|
* @name experimental.i18n.fallback
|
|
1379
1383
|
* @type {Record<string, string>}
|
|
1380
1384
|
* @version 3.5.0
|
|
@@ -1384,7 +1388,7 @@ export interface AstroUserConfig {
|
|
|
1384
1388
|
*
|
|
1385
1389
|
* Use this object to declare a fallback `locale` route for each language you support. If no fallback is specified, then unavailable pages will return a 404.
|
|
1386
1390
|
*
|
|
1387
|
-
*
|
|
1391
|
+
* ##### Example
|
|
1388
1392
|
*
|
|
1389
1393
|
* The following example configures your content fallback strategy to redirect unavailable pages in `/pt-br/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404.
|
|
1390
1394
|
*
|
|
@@ -1406,6 +1410,7 @@ export interface AstroUserConfig {
|
|
|
1406
1410
|
fallback?: Record<string, string>;
|
|
1407
1411
|
/**
|
|
1408
1412
|
* @docs
|
|
1413
|
+
* @kind h4
|
|
1409
1414
|
* @name experimental.i18n.routingStrategy
|
|
1410
1415
|
* @type {'prefix-always' | 'prefix-other-locales'}
|
|
1411
1416
|
* @default 'prefix-other-locales'
|
|
@@ -139,7 +139,7 @@ function astroConfigBuildPlugin(options, internals) {
|
|
|
139
139
|
const pageData = getPageDataByViteID(internals, pageViteID);
|
|
140
140
|
if (!pageData)
|
|
141
141
|
continue;
|
|
142
|
-
const _entryCss =
|
|
142
|
+
const _entryCss = pageData.propagatedStyles?.get(id);
|
|
143
143
|
const _entryScripts = pageData.propagatedScripts?.get(id);
|
|
144
144
|
if (_entryCss) {
|
|
145
145
|
for (const value of _entryCss) {
|
|
@@ -34,6 +34,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
34
34
|
let resolvedConfig;
|
|
35
35
|
const pagesToCss = {};
|
|
36
36
|
const pagesToPropagatedCss = {};
|
|
37
|
+
const isContentCollectionCache = options.buildOptions.settings.config.output === "static" && options.buildOptions.settings.config.experimental.contentCollectionCache;
|
|
37
38
|
const cssBuildPlugin = {
|
|
38
39
|
name: "astro:rollup-plugin-build-css",
|
|
39
40
|
outputOptions(outputOptions) {
|
|
@@ -52,7 +53,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
52
53
|
if (new URL(pageInfo.id, "file://").searchParams.has(PROPAGATED_ASSET_FLAG)) {
|
|
53
54
|
const chunkId2 = assetName.createNameHash(id, [id]);
|
|
54
55
|
internals.cssModuleToChunkIdMap.set(id, chunkId2);
|
|
55
|
-
if (
|
|
56
|
+
if (isContentCollectionCache) {
|
|
56
57
|
const propagatedStyles = internals.propagatedStylesMap.get(pageInfo.id) ?? /* @__PURE__ */ new Set();
|
|
57
58
|
propagatedStyles.add({ type: "external", src: chunkId2 });
|
|
58
59
|
internals.propagatedStylesMap.set(pageInfo.id, propagatedStyles);
|
|
@@ -174,7 +175,12 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
174
175
|
return;
|
|
175
176
|
if (pageData.styles.some((s) => s.sheet === sheet))
|
|
176
177
|
return;
|
|
177
|
-
|
|
178
|
+
let propagatedStyles;
|
|
179
|
+
if (isContentCollectionCache) {
|
|
180
|
+
propagatedStyles = internals.propagatedStylesMap.get(pageInfoId) ?? internals.propagatedStylesMap.set(pageInfoId, /* @__PURE__ */ new Set()).get(pageInfoId);
|
|
181
|
+
} else {
|
|
182
|
+
propagatedStyles = pageData.propagatedStyles.get(pageInfoId) ?? pageData.propagatedStyles.set(pageInfoId, /* @__PURE__ */ new Set()).get(pageInfoId);
|
|
183
|
+
}
|
|
178
184
|
propagatedStyles.add(sheet);
|
|
179
185
|
sheetAddedToPage = true;
|
|
180
186
|
});
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -20,7 +20,7 @@ async function dev(inlineConfig) {
|
|
|
20
20
|
base: restart.container.settings.config.base
|
|
21
21
|
})
|
|
22
22
|
);
|
|
23
|
-
const currentVersion = "3.5.
|
|
23
|
+
const currentVersion = "3.5.3";
|
|
24
24
|
if (currentVersion.includes("-")) {
|
|
25
25
|
logger.warn(null, msg.prerelease({ currentVersion }));
|
|
26
26
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -50,7 +50,7 @@ function serverStart({
|
|
|
50
50
|
base,
|
|
51
51
|
isRestart = false
|
|
52
52
|
}) {
|
|
53
|
-
const version = "3.5.
|
|
53
|
+
const version = "3.5.3";
|
|
54
54
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
55
55
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
56
56
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -235,7 +235,7 @@ function printHelp({
|
|
|
235
235
|
message.push(
|
|
236
236
|
linebreak(),
|
|
237
237
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
238
|
-
`v${"3.5.
|
|
238
|
+
`v${"3.5.3"}`
|
|
239
239
|
)} ${headline}`
|
|
240
240
|
);
|
|
241
241
|
}
|
|
@@ -8,6 +8,7 @@ function vitePluginMiddleware({ settings }) {
|
|
|
8
8
|
let isCommandBuild = false;
|
|
9
9
|
let resolvedMiddlewareId = void 0;
|
|
10
10
|
const hasIntegrationMiddleware = settings.middlewares.pre.length > 0 || settings.middlewares.post.length > 0;
|
|
11
|
+
let userMiddlewareIsPresent = false;
|
|
11
12
|
return {
|
|
12
13
|
name: "@astro/plugin-middleware",
|
|
13
14
|
config(opts, { command }) {
|
|
@@ -19,6 +20,7 @@ function vitePluginMiddleware({ settings }) {
|
|
|
19
20
|
const middlewareId = await this.resolve(
|
|
20
21
|
`${decodeURI(settings.config.srcDir.pathname)}${MIDDLEWARE_PATH_SEGMENT_NAME}`
|
|
21
22
|
);
|
|
23
|
+
userMiddlewareIsPresent = !!middlewareId;
|
|
22
24
|
if (middlewareId) {
|
|
23
25
|
resolvedMiddlewareId = middlewareId.id;
|
|
24
26
|
return MIDDLEWARE_MODULE_ID;
|
|
@@ -47,13 +49,13 @@ function vitePluginMiddleware({ settings }) {
|
|
|
47
49
|
const preMiddleware = createMiddlewareImports(settings.middlewares.pre, "pre");
|
|
48
50
|
const postMiddleware = createMiddlewareImports(settings.middlewares.post, "post");
|
|
49
51
|
const source = `
|
|
50
|
-
import { onRequest as userOnRequest } from '${resolvedMiddlewareId}'
|
|
52
|
+
${userMiddlewareIsPresent ? `import { onRequest as userOnRequest } from '${resolvedMiddlewareId}';` : ""}
|
|
51
53
|
import { sequence } from 'astro:middleware';
|
|
52
54
|
${preMiddleware.importsCode}${postMiddleware.importsCode}
|
|
53
55
|
|
|
54
56
|
export const onRequest = sequence(
|
|
55
57
|
${preMiddleware.sequenceCode}${preMiddleware.sequenceCode ? "," : ""}
|
|
56
|
-
userOnRequest${postMiddleware.sequenceCode ? "," : ""}
|
|
58
|
+
${userMiddlewareIsPresent ? `userOnRequest${postMiddleware.sequenceCode ? "," : ""}` : ""}
|
|
57
59
|
${postMiddleware.sequenceCode}
|
|
58
60
|
);
|
|
59
61
|
`.trim();
|
|
@@ -312,7 +312,7 @@ function navigate(href, options) {
|
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
314
|
const toLocation = new URL(href, location.href);
|
|
315
|
-
if (location.origin === toLocation.origin && samePage(toLocation)) {
|
|
315
|
+
if (location.origin === toLocation.origin && samePage(toLocation) && !options?.formData) {
|
|
316
316
|
moveToLocation(toLocation, options?.history === "replace", true);
|
|
317
317
|
} else {
|
|
318
318
|
transition("forward", toLocation, options ?? {});
|