astro 4.12.3 → 4.13.0
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/dist/@types/astro.d.ts +0 -102
- package/dist/container/index.js +0 -1
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/types-generator.js +5 -3
- package/dist/core/app/types.d.ts +0 -1
- package/dist/core/build/generate.js +9 -3
- package/dist/core/build/plugins/plugin-manifest.js +0 -1
- package/dist/core/config/schema.d.ts +0 -34
- package/dist/core/config/schema.js +0 -4
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +2 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.d.ts +1 -2
- package/dist/core/middleware/callMiddleware.js +2 -12
- package/dist/core/render-context.js +11 -37
- package/dist/vite-plugin-astro-server/plugin.js +0 -1
- package/package.json +20 -20
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1755,53 +1755,6 @@ export interface AstroUserConfig {
|
|
|
1755
1755
|
* ```
|
|
1756
1756
|
*/
|
|
1757
1757
|
contentCollectionCache?: boolean;
|
|
1758
|
-
/**
|
|
1759
|
-
* @docs
|
|
1760
|
-
* @name experimental.contentCollectionJsonSchema
|
|
1761
|
-
* @type {boolean}
|
|
1762
|
-
* @default `false`
|
|
1763
|
-
* @version 4.5.0
|
|
1764
|
-
* @description
|
|
1765
|
-
* This feature will auto-generate a JSON schema for content collections of `type: 'data'` which can be used as the `$schema` value for TypeScript-style autocompletion/hints in tools like VSCode.
|
|
1766
|
-
*
|
|
1767
|
-
* To enable this feature, add the experimental flag:
|
|
1768
|
-
*
|
|
1769
|
-
* ```diff
|
|
1770
|
-
* import { defineConfig } from 'astro/config';
|
|
1771
|
-
|
|
1772
|
-
* export default defineConfig({
|
|
1773
|
-
* experimental: {
|
|
1774
|
-
* + contentCollectionJsonSchema: true
|
|
1775
|
-
* }
|
|
1776
|
-
* });
|
|
1777
|
-
* ```
|
|
1778
|
-
*
|
|
1779
|
-
* This experimental implementation requires you to manually reference the schema in each data entry file of the collection:
|
|
1780
|
-
*
|
|
1781
|
-
* ```diff
|
|
1782
|
-
* // src/content/test/entry.json
|
|
1783
|
-
* {
|
|
1784
|
-
* + "$schema": "../../../.astro/collections/test.schema.json",
|
|
1785
|
-
* "test": "test"
|
|
1786
|
-
* }
|
|
1787
|
-
* ```
|
|
1788
|
-
*
|
|
1789
|
-
* Alternatively, you can set this in your [VSCode `json.schemas` settings](https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings):
|
|
1790
|
-
*
|
|
1791
|
-
* ```diff
|
|
1792
|
-
* "json.schemas": [
|
|
1793
|
-
* {
|
|
1794
|
-
* "fileMatch": [
|
|
1795
|
-
* "/src/content/test/**"
|
|
1796
|
-
* ],
|
|
1797
|
-
* "url": "./.astro/collections/test.schema.json"
|
|
1798
|
-
* }
|
|
1799
|
-
* ]
|
|
1800
|
-
* ```
|
|
1801
|
-
*
|
|
1802
|
-
* Note that this initial implementation uses a library with [known issues for advanced Zod schemas](https://github.com/StefanTerdell/zod-to-json-schema#known-issues), so you may wish to consult these limitations before enabling the experimental flag.
|
|
1803
|
-
*/
|
|
1804
|
-
contentCollectionJsonSchema?: boolean;
|
|
1805
1758
|
/**
|
|
1806
1759
|
* @docs
|
|
1807
1760
|
* @name experimental.clientPrerender
|
|
@@ -1866,61 +1819,6 @@ export interface AstroUserConfig {
|
|
|
1866
1819
|
* In the event of route collisions, where two routes of equal route priority attempt to build the same URL, Astro will log a warning identifying the conflicting routes.
|
|
1867
1820
|
*/
|
|
1868
1821
|
globalRoutePriority?: boolean;
|
|
1869
|
-
/**
|
|
1870
|
-
* @docs
|
|
1871
|
-
* @name experimental.rewriting
|
|
1872
|
-
* @type {boolean}
|
|
1873
|
-
* @default `false`
|
|
1874
|
-
* @version 4.8.0
|
|
1875
|
-
* @description
|
|
1876
|
-
*
|
|
1877
|
-
* Enables a routing feature for rewriting requests in Astro pages, endpoints and Astro middleware, giving you programmatic control over your routes.
|
|
1878
|
-
*
|
|
1879
|
-
* ```js
|
|
1880
|
-
* {
|
|
1881
|
-
* experimental: {
|
|
1882
|
-
* rewriting: true,
|
|
1883
|
-
* },
|
|
1884
|
-
* }
|
|
1885
|
-
* ```
|
|
1886
|
-
*
|
|
1887
|
-
* Use `Astro.rewrite` in your `.astro` files to reroute to a different page:
|
|
1888
|
-
*
|
|
1889
|
-
* ```astro "rewrite"
|
|
1890
|
-
* ---
|
|
1891
|
-
* // src/pages/dashboard.astro
|
|
1892
|
-
* if (!Astro.props.allowed) {
|
|
1893
|
-
* return Astro.rewrite("/")
|
|
1894
|
-
* }
|
|
1895
|
-
* ---
|
|
1896
|
-
* ```
|
|
1897
|
-
*
|
|
1898
|
-
* Use `context.rewrite` in your endpoint files to reroute to a different page:
|
|
1899
|
-
*
|
|
1900
|
-
* ```js
|
|
1901
|
-
* // src/pages/api.js
|
|
1902
|
-
* export function GET(ctx) {
|
|
1903
|
-
* if (!ctx.locals.allowed) {
|
|
1904
|
-
* return ctx.rewrite("/")
|
|
1905
|
-
* }
|
|
1906
|
-
* }
|
|
1907
|
-
* ```
|
|
1908
|
-
*
|
|
1909
|
-
* Use `next("/")` in your middleware file to reroute to a different page, and then call the next middleware function:
|
|
1910
|
-
*
|
|
1911
|
-
* ```js
|
|
1912
|
-
* // src/middleware.js
|
|
1913
|
-
* export function onRequest(ctx, next) {
|
|
1914
|
-
* if (!ctx.cookies.get("allowed")) {
|
|
1915
|
-
* return next("/") // new signature
|
|
1916
|
-
* }
|
|
1917
|
-
* return next();
|
|
1918
|
-
* }
|
|
1919
|
-
* ```
|
|
1920
|
-
*
|
|
1921
|
-
* For a complete overview, and to give feedback on this experimental API, see the [Rerouting RFC](https://github.com/withastro/roadmap/blob/feat/reroute/proposals/0047-rerouting.md).
|
|
1922
|
-
*/
|
|
1923
|
-
rewriting?: boolean;
|
|
1924
1822
|
/**
|
|
1925
1823
|
* @docs
|
|
1926
1824
|
* @name experimental.env
|
package/dist/container/index.js
CHANGED
|
@@ -15,7 +15,6 @@ function createManifest(manifest, renderers, middleware) {
|
|
|
15
15
|
};
|
|
16
16
|
return {
|
|
17
17
|
hrefRoot: import.meta.url,
|
|
18
|
-
rewritingEnabled: false,
|
|
19
18
|
trailingSlash: manifest?.trailingSlash ?? ASTRO_CONFIG_DEFAULTS.trailingSlash,
|
|
20
19
|
buildFormat: manifest?.buildFormat ?? ASTRO_CONFIG_DEFAULTS.build.format,
|
|
21
20
|
compressHTML: manifest?.compressHTML ?? ASTRO_CONFIG_DEFAULTS.compressHTML,
|
|
@@ -283,7 +283,7 @@ async function writeContentFiles({
|
|
|
283
283
|
let contentTypesStr = "";
|
|
284
284
|
let dataTypesStr = "";
|
|
285
285
|
const collectionSchemasDir = new URL("./collections/", settings.dotAstroDir);
|
|
286
|
-
if (
|
|
286
|
+
if (!fs.existsSync(collectionSchemasDir)) {
|
|
287
287
|
fs.mkdirSync(collectionSchemasDir, { recursive: true });
|
|
288
288
|
}
|
|
289
289
|
for (const [collection, config] of Object.entries(contentConfig?.collections ?? {})) {
|
|
@@ -376,7 +376,7 @@ async function writeContentFiles({
|
|
|
376
376
|
dataTypesStr += `};
|
|
377
377
|
`;
|
|
378
378
|
}
|
|
379
|
-
if (
|
|
379
|
+
if (collectionConfig?.schema) {
|
|
380
380
|
let zodSchemaForJson = typeof collectionConfig.schema === "function" ? collectionConfig.schema({ image: () => z.string() }) : collectionConfig.schema;
|
|
381
381
|
if (zodSchemaForJson instanceof z.ZodObject) {
|
|
382
382
|
zodSchemaForJson = zodSchemaForJson.extend({
|
|
@@ -390,7 +390,9 @@ async function writeContentFiles({
|
|
|
390
390
|
zodToJsonSchema(zodSchemaForJson, {
|
|
391
391
|
name: collectionKey.replace(/"/g, ""),
|
|
392
392
|
markdownDescription: true,
|
|
393
|
-
errorMessages: true
|
|
393
|
+
errorMessages: true,
|
|
394
|
+
// Fix for https://github.com/StefanTerdell/zod-to-json-schema/issues/110
|
|
395
|
+
dateStrategy: ["format:date-time", "format:date", "integer"]
|
|
394
396
|
}),
|
|
395
397
|
null,
|
|
396
398
|
2
|
package/dist/core/app/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { bgGreen, black, blue, bold, dim, green, magenta } from "kleur/colors";
|
|
4
|
+
import { bgGreen, black, blue, bold, dim, green, magenta, red } from "kleur/colors";
|
|
5
5
|
import PQueue from "p-queue";
|
|
6
6
|
import {
|
|
7
7
|
generateImagesForPath,
|
|
@@ -143,6 +143,7 @@ ${bgGreen(black(` ${verb} static routes `))}`);
|
|
|
143
143
|
}
|
|
144
144
|
await runHookBuildGenerated({ config, logger });
|
|
145
145
|
}
|
|
146
|
+
const THRESHOLD_SLOW_RENDER_TIME_MS = 500;
|
|
146
147
|
async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
|
|
147
148
|
const { config, logger } = pipeline;
|
|
148
149
|
const pageModulePromise = ssrEntry.page;
|
|
@@ -178,7 +179,13 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
|
|
|
178
179
|
const timeEnd = performance.now();
|
|
179
180
|
const timeChange = getTimeStat(prevTimeEnd, timeEnd);
|
|
180
181
|
const timeIncrease = `(+${timeChange})`;
|
|
181
|
-
|
|
182
|
+
let timeIncreaseLabel;
|
|
183
|
+
if (timeEnd - prevTimeEnd > THRESHOLD_SLOW_RENDER_TIME_MS) {
|
|
184
|
+
timeIncreaseLabel = red(timeIncrease);
|
|
185
|
+
} else {
|
|
186
|
+
timeIncreaseLabel = dim(timeIncrease);
|
|
187
|
+
}
|
|
188
|
+
logger.info("SKIP_FORMAT", ` ${timeIncreaseLabel}`);
|
|
182
189
|
prevTimeEnd = timeEnd;
|
|
183
190
|
}
|
|
184
191
|
}
|
|
@@ -398,7 +405,6 @@ function createBuildManifest(settings, internals, renderers, middleware) {
|
|
|
398
405
|
i18n: i18nManifest,
|
|
399
406
|
buildFormat: settings.config.build.format,
|
|
400
407
|
middleware,
|
|
401
|
-
rewritingEnabled: settings.config.experimental.rewriting,
|
|
402
408
|
checkOrigin: settings.config.security?.checkOrigin ?? false,
|
|
403
409
|
experimentalEnvGetSecretEnabled: false
|
|
404
410
|
};
|
|
@@ -213,7 +213,6 @@ function buildManifest(opts, internals, staticFiles) {
|
|
|
213
213
|
i18n: i18nManifest,
|
|
214
214
|
buildFormat: settings.config.build.format,
|
|
215
215
|
checkOrigin: settings.config.security?.checkOrigin ?? false,
|
|
216
|
-
rewritingEnabled: settings.config.experimental.rewriting,
|
|
217
216
|
serverIslandNameMap: Array.from(settings.serverIslandNameMap),
|
|
218
217
|
experimentalEnvGetSecretEnabled: settings.config.experimental.env !== void 0 && (settings.adapter?.supportedAstroFeatures.envGetSecret ?? "unsupported") !== "unsupported"
|
|
219
218
|
};
|
|
@@ -54,10 +54,8 @@ export declare const ASTRO_CONFIG_DEFAULTS: {
|
|
|
54
54
|
actions: false;
|
|
55
55
|
directRenderScript: false;
|
|
56
56
|
contentCollectionCache: false;
|
|
57
|
-
contentCollectionJsonSchema: false;
|
|
58
57
|
clientPrerender: false;
|
|
59
58
|
globalRoutePriority: false;
|
|
60
|
-
rewriting: false;
|
|
61
59
|
serverIslands: false;
|
|
62
60
|
env: {
|
|
63
61
|
validateSecrets: false;
|
|
@@ -402,10 +400,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
402
400
|
actions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
403
401
|
directRenderScript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
404
402
|
contentCollectionCache: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
405
|
-
contentCollectionJsonSchema: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
406
403
|
clientPrerender: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
407
404
|
globalRoutePriority: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
408
|
-
rewriting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
409
405
|
env: z.ZodOptional<z.ZodObject<{
|
|
410
406
|
schema: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
411
407
|
context: z.ZodLiteral<"client">;
|
|
@@ -621,10 +617,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
621
617
|
actions: boolean;
|
|
622
618
|
directRenderScript: boolean;
|
|
623
619
|
contentCollectionCache: boolean;
|
|
624
|
-
contentCollectionJsonSchema: boolean;
|
|
625
620
|
clientPrerender: boolean;
|
|
626
621
|
globalRoutePriority: boolean;
|
|
627
|
-
rewriting: boolean;
|
|
628
622
|
serverIslands: boolean;
|
|
629
623
|
env?: {
|
|
630
624
|
validateSecrets: boolean;
|
|
@@ -672,10 +666,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
672
666
|
actions?: boolean | undefined;
|
|
673
667
|
directRenderScript?: boolean | undefined;
|
|
674
668
|
contentCollectionCache?: boolean | undefined;
|
|
675
|
-
contentCollectionJsonSchema?: boolean | undefined;
|
|
676
669
|
clientPrerender?: boolean | undefined;
|
|
677
670
|
globalRoutePriority?: boolean | undefined;
|
|
678
|
-
rewriting?: boolean | undefined;
|
|
679
671
|
serverIslands?: boolean | undefined;
|
|
680
672
|
env?: {
|
|
681
673
|
validateSecrets?: boolean | undefined;
|
|
@@ -801,10 +793,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
801
793
|
actions: boolean;
|
|
802
794
|
directRenderScript: boolean;
|
|
803
795
|
contentCollectionCache: boolean;
|
|
804
|
-
contentCollectionJsonSchema: boolean;
|
|
805
796
|
clientPrerender: boolean;
|
|
806
797
|
globalRoutePriority: boolean;
|
|
807
|
-
rewriting: boolean;
|
|
808
798
|
serverIslands: boolean;
|
|
809
799
|
env?: {
|
|
810
800
|
validateSecrets: boolean;
|
|
@@ -966,10 +956,8 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
966
956
|
actions?: boolean | undefined;
|
|
967
957
|
directRenderScript?: boolean | undefined;
|
|
968
958
|
contentCollectionCache?: boolean | undefined;
|
|
969
|
-
contentCollectionJsonSchema?: boolean | undefined;
|
|
970
959
|
clientPrerender?: boolean | undefined;
|
|
971
960
|
globalRoutePriority?: boolean | undefined;
|
|
972
|
-
rewriting?: boolean | undefined;
|
|
973
961
|
serverIslands?: boolean | undefined;
|
|
974
962
|
env?: {
|
|
975
963
|
validateSecrets?: boolean | undefined;
|
|
@@ -1355,10 +1343,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1355
1343
|
actions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1356
1344
|
directRenderScript: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1357
1345
|
contentCollectionCache: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1358
|
-
contentCollectionJsonSchema: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1359
1346
|
clientPrerender: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1360
1347
|
globalRoutePriority: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1361
|
-
rewriting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
1362
1348
|
env: z.ZodOptional<z.ZodObject<{
|
|
1363
1349
|
schema: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
1364
1350
|
context: z.ZodLiteral<"client">;
|
|
@@ -1574,10 +1560,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1574
1560
|
actions: boolean;
|
|
1575
1561
|
directRenderScript: boolean;
|
|
1576
1562
|
contentCollectionCache: boolean;
|
|
1577
|
-
contentCollectionJsonSchema: boolean;
|
|
1578
1563
|
clientPrerender: boolean;
|
|
1579
1564
|
globalRoutePriority: boolean;
|
|
1580
|
-
rewriting: boolean;
|
|
1581
1565
|
serverIslands: boolean;
|
|
1582
1566
|
env?: {
|
|
1583
1567
|
validateSecrets: boolean;
|
|
@@ -1625,10 +1609,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1625
1609
|
actions?: boolean | undefined;
|
|
1626
1610
|
directRenderScript?: boolean | undefined;
|
|
1627
1611
|
contentCollectionCache?: boolean | undefined;
|
|
1628
|
-
contentCollectionJsonSchema?: boolean | undefined;
|
|
1629
1612
|
clientPrerender?: boolean | undefined;
|
|
1630
1613
|
globalRoutePriority?: boolean | undefined;
|
|
1631
|
-
rewriting?: boolean | undefined;
|
|
1632
1614
|
serverIslands?: boolean | undefined;
|
|
1633
1615
|
env?: {
|
|
1634
1616
|
validateSecrets?: boolean | undefined;
|
|
@@ -1829,10 +1811,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1829
1811
|
actions: boolean;
|
|
1830
1812
|
directRenderScript: boolean;
|
|
1831
1813
|
contentCollectionCache: boolean;
|
|
1832
|
-
contentCollectionJsonSchema: boolean;
|
|
1833
1814
|
clientPrerender: boolean;
|
|
1834
1815
|
globalRoutePriority: boolean;
|
|
1835
|
-
rewriting: boolean;
|
|
1836
1816
|
serverIslands: boolean;
|
|
1837
1817
|
env?: {
|
|
1838
1818
|
validateSecrets: boolean;
|
|
@@ -1994,10 +1974,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
1994
1974
|
actions?: boolean | undefined;
|
|
1995
1975
|
directRenderScript?: boolean | undefined;
|
|
1996
1976
|
contentCollectionCache?: boolean | undefined;
|
|
1997
|
-
contentCollectionJsonSchema?: boolean | undefined;
|
|
1998
1977
|
clientPrerender?: boolean | undefined;
|
|
1999
1978
|
globalRoutePriority?: boolean | undefined;
|
|
2000
|
-
rewriting?: boolean | undefined;
|
|
2001
1979
|
serverIslands?: boolean | undefined;
|
|
2002
1980
|
env?: {
|
|
2003
1981
|
validateSecrets?: boolean | undefined;
|
|
@@ -2124,10 +2102,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2124
2102
|
actions: boolean;
|
|
2125
2103
|
directRenderScript: boolean;
|
|
2126
2104
|
contentCollectionCache: boolean;
|
|
2127
|
-
contentCollectionJsonSchema: boolean;
|
|
2128
2105
|
clientPrerender: boolean;
|
|
2129
2106
|
globalRoutePriority: boolean;
|
|
2130
|
-
rewriting: boolean;
|
|
2131
2107
|
serverIslands: boolean;
|
|
2132
2108
|
env?: {
|
|
2133
2109
|
validateSecrets: boolean;
|
|
@@ -2289,10 +2265,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2289
2265
|
actions?: boolean | undefined;
|
|
2290
2266
|
directRenderScript?: boolean | undefined;
|
|
2291
2267
|
contentCollectionCache?: boolean | undefined;
|
|
2292
|
-
contentCollectionJsonSchema?: boolean | undefined;
|
|
2293
2268
|
clientPrerender?: boolean | undefined;
|
|
2294
2269
|
globalRoutePriority?: boolean | undefined;
|
|
2295
|
-
rewriting?: boolean | undefined;
|
|
2296
2270
|
serverIslands?: boolean | undefined;
|
|
2297
2271
|
env?: {
|
|
2298
2272
|
validateSecrets?: boolean | undefined;
|
|
@@ -2419,10 +2393,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2419
2393
|
actions: boolean;
|
|
2420
2394
|
directRenderScript: boolean;
|
|
2421
2395
|
contentCollectionCache: boolean;
|
|
2422
|
-
contentCollectionJsonSchema: boolean;
|
|
2423
2396
|
clientPrerender: boolean;
|
|
2424
2397
|
globalRoutePriority: boolean;
|
|
2425
|
-
rewriting: boolean;
|
|
2426
2398
|
serverIslands: boolean;
|
|
2427
2399
|
env?: {
|
|
2428
2400
|
validateSecrets: boolean;
|
|
@@ -2584,10 +2556,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2584
2556
|
actions?: boolean | undefined;
|
|
2585
2557
|
directRenderScript?: boolean | undefined;
|
|
2586
2558
|
contentCollectionCache?: boolean | undefined;
|
|
2587
|
-
contentCollectionJsonSchema?: boolean | undefined;
|
|
2588
2559
|
clientPrerender?: boolean | undefined;
|
|
2589
2560
|
globalRoutePriority?: boolean | undefined;
|
|
2590
|
-
rewriting?: boolean | undefined;
|
|
2591
2561
|
serverIslands?: boolean | undefined;
|
|
2592
2562
|
env?: {
|
|
2593
2563
|
validateSecrets?: boolean | undefined;
|
|
@@ -2714,10 +2684,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2714
2684
|
actions: boolean;
|
|
2715
2685
|
directRenderScript: boolean;
|
|
2716
2686
|
contentCollectionCache: boolean;
|
|
2717
|
-
contentCollectionJsonSchema: boolean;
|
|
2718
2687
|
clientPrerender: boolean;
|
|
2719
2688
|
globalRoutePriority: boolean;
|
|
2720
|
-
rewriting: boolean;
|
|
2721
2689
|
serverIslands: boolean;
|
|
2722
2690
|
env?: {
|
|
2723
2691
|
validateSecrets: boolean;
|
|
@@ -2879,10 +2847,8 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
2879
2847
|
actions?: boolean | undefined;
|
|
2880
2848
|
directRenderScript?: boolean | undefined;
|
|
2881
2849
|
contentCollectionCache?: boolean | undefined;
|
|
2882
|
-
contentCollectionJsonSchema?: boolean | undefined;
|
|
2883
2850
|
clientPrerender?: boolean | undefined;
|
|
2884
2851
|
globalRoutePriority?: boolean | undefined;
|
|
2885
|
-
rewriting?: boolean | undefined;
|
|
2886
2852
|
serverIslands?: boolean | undefined;
|
|
2887
2853
|
env?: {
|
|
2888
2854
|
validateSecrets?: boolean | undefined;
|
|
@@ -44,10 +44,8 @@ const ASTRO_CONFIG_DEFAULTS = {
|
|
|
44
44
|
actions: false,
|
|
45
45
|
directRenderScript: false,
|
|
46
46
|
contentCollectionCache: false,
|
|
47
|
-
contentCollectionJsonSchema: false,
|
|
48
47
|
clientPrerender: false,
|
|
49
48
|
globalRoutePriority: false,
|
|
50
|
-
rewriting: false,
|
|
51
49
|
serverIslands: false,
|
|
52
50
|
env: {
|
|
53
51
|
validateSecrets: false
|
|
@@ -328,10 +326,8 @@ const AstroConfigSchema = z.object({
|
|
|
328
326
|
actions: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.actions),
|
|
329
327
|
directRenderScript: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.directRenderScript),
|
|
330
328
|
contentCollectionCache: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.contentCollectionCache),
|
|
331
|
-
contentCollectionJsonSchema: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.contentCollectionJsonSchema),
|
|
332
329
|
clientPrerender: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.clientPrerender),
|
|
333
330
|
globalRoutePriority: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.globalRoutePriority),
|
|
334
|
-
rewriting: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.rewriting),
|
|
335
331
|
env: z.object({
|
|
336
332
|
schema: EnvSchema.optional(),
|
|
337
333
|
validateSecrets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.env.validateSecrets)
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -19,7 +19,7 @@ async function dev(inlineConfig) {
|
|
|
19
19
|
await telemetry.record([]);
|
|
20
20
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
21
21
|
const logger = restart.container.logger;
|
|
22
|
-
const currentVersion = "4.
|
|
22
|
+
const currentVersion = "4.13.0";
|
|
23
23
|
const isPrerelease = currentVersion.includes("-");
|
|
24
24
|
if (!isPrerelease) {
|
|
25
25
|
try {
|
|
@@ -1021,6 +1021,7 @@ export declare const MissingMiddlewareForInternationalization: {
|
|
|
1021
1021
|
message: string;
|
|
1022
1022
|
};
|
|
1023
1023
|
/**
|
|
1024
|
+
* @deprecated
|
|
1024
1025
|
* @docs
|
|
1025
1026
|
* @description
|
|
1026
1027
|
* The user tried to rewrite using a route that doesn't exist, or it emitted a runtime error during its rendering phase.
|
|
@@ -1143,7 +1144,7 @@ export declare const ServerOnlyModule: {
|
|
|
1143
1144
|
*
|
|
1144
1145
|
* @see
|
|
1145
1146
|
* - [Request.clone()](https://developer.mozilla.org/en-US/docs/Web/API/Request/clone)
|
|
1146
|
-
* - [Astro.rewrite](https://docs.astro.build/en/reference/
|
|
1147
|
+
* - [Astro.rewrite](https://docs.astro.build/en/reference/api-reference/#astrorewrite)
|
|
1147
1148
|
*/
|
|
1148
1149
|
export declare const RewriteWithBodyUsed: {
|
|
1149
1150
|
name: string;
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "4.
|
|
41
|
+
const version = "4.13.0";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -270,7 +270,7 @@ function printHelp({
|
|
|
270
270
|
message.push(
|
|
271
271
|
linebreak(),
|
|
272
272
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
273
|
-
`v${"4.
|
|
273
|
+
`v${"4.13.0"}`
|
|
274
274
|
)} ${headline}`
|
|
275
275
|
);
|
|
276
276
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { APIContext, MiddlewareHandler, RewritePayload } from '../../@types/astro.js';
|
|
2
|
-
import type { Logger } from '../logger/core.js';
|
|
3
2
|
/**
|
|
4
3
|
* Utility function that is in charge of calling the middleware.
|
|
5
4
|
*
|
|
@@ -34,4 +33,4 @@ import type { Logger } from '../logger/core.js';
|
|
|
34
33
|
* @param apiContext The API context
|
|
35
34
|
* @param responseFunction A callback function that should return a promise with the response
|
|
36
35
|
*/
|
|
37
|
-
export declare function callMiddleware(onRequest: MiddlewareHandler, apiContext: APIContext, responseFunction: (apiContext: APIContext, rewritePayload?: RewritePayload) => Promise<Response> | Response
|
|
36
|
+
export declare function callMiddleware(onRequest: MiddlewareHandler, apiContext: APIContext, responseFunction: (apiContext: APIContext, rewritePayload?: RewritePayload) => Promise<Response> | Response): Promise<Response>;
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
2
|
-
async function callMiddleware(onRequest, apiContext, responseFunction
|
|
2
|
+
async function callMiddleware(onRequest, apiContext, responseFunction) {
|
|
3
3
|
let nextCalled = false;
|
|
4
4
|
let responseFunctionPromise = void 0;
|
|
5
5
|
const next = async (payload) => {
|
|
6
6
|
nextCalled = true;
|
|
7
|
-
|
|
8
|
-
responseFunctionPromise = responseFunction(apiContext, payload);
|
|
9
|
-
} else {
|
|
10
|
-
if (payload) {
|
|
11
|
-
logger.warn(
|
|
12
|
-
"router",
|
|
13
|
-
"The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
responseFunctionPromise = responseFunction(apiContext);
|
|
17
|
-
}
|
|
7
|
+
responseFunctionPromise = responseFunction(apiContext, payload);
|
|
18
8
|
return responseFunctionPromise;
|
|
19
9
|
};
|
|
20
10
|
let middlewarePromise = onRequest(apiContext, next);
|
|
@@ -105,23 +105,16 @@ class RenderContext {
|
|
|
105
105
|
}
|
|
106
106
|
const lastNext = async (ctx, payload) => {
|
|
107
107
|
if (payload) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.status = 200;
|
|
119
|
-
} else {
|
|
120
|
-
this.pipeline.logger.error(
|
|
121
|
-
"router",
|
|
122
|
-
"The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
|
|
123
|
-
);
|
|
124
|
-
}
|
|
108
|
+
pipeline.logger.debug("router", "Called rewriting to:", payload);
|
|
109
|
+
const [routeData, component] = await pipeline.tryRewrite(
|
|
110
|
+
payload,
|
|
111
|
+
this.request,
|
|
112
|
+
this.originalRoute
|
|
113
|
+
);
|
|
114
|
+
this.routeData = routeData;
|
|
115
|
+
componentInstance = component;
|
|
116
|
+
this.isRewriting = true;
|
|
117
|
+
this.status = 200;
|
|
125
118
|
}
|
|
126
119
|
let response2;
|
|
127
120
|
switch (this.routeData.type) {
|
|
@@ -165,13 +158,7 @@ class RenderContext {
|
|
|
165
158
|
}
|
|
166
159
|
return response2;
|
|
167
160
|
};
|
|
168
|
-
const response = await callMiddleware(
|
|
169
|
-
middleware,
|
|
170
|
-
apiContext,
|
|
171
|
-
lastNext,
|
|
172
|
-
this.pipeline.manifest.rewritingEnabled,
|
|
173
|
-
this.pipeline.logger
|
|
174
|
-
);
|
|
161
|
+
const response = await callMiddleware(middleware, apiContext, lastNext);
|
|
175
162
|
if (response.headers.get(ROUTE_TYPE_HEADER)) {
|
|
176
163
|
response.headers.delete(ROUTE_TYPE_HEADER);
|
|
177
164
|
}
|
|
@@ -187,19 +174,6 @@ class RenderContext {
|
|
|
187
174
|
}
|
|
188
175
|
async #executeRewrite(reroutePayload) {
|
|
189
176
|
this.pipeline.logger.debug("router", "Calling rewrite: ", reroutePayload);
|
|
190
|
-
if (!this.pipeline.manifest.rewritingEnabled) {
|
|
191
|
-
this.pipeline.logger.error(
|
|
192
|
-
"router",
|
|
193
|
-
"The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
|
|
194
|
-
);
|
|
195
|
-
return new Response(
|
|
196
|
-
"The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config.",
|
|
197
|
-
{
|
|
198
|
-
status: 500,
|
|
199
|
-
statusText: "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
|
|
200
|
-
}
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
177
|
const [routeData, component, newURL] = await this.pipeline.tryRewrite(
|
|
204
178
|
reroutePayload,
|
|
205
179
|
this.request,
|
|
@@ -116,7 +116,6 @@ function createDevelopmentManifest(settings) {
|
|
|
116
116
|
inlinedScripts: /* @__PURE__ */ new Map(),
|
|
117
117
|
i18n: i18nManifest,
|
|
118
118
|
checkOrigin: settings.config.security?.checkOrigin ?? false,
|
|
119
|
-
rewritingEnabled: settings.config.experimental.rewriting,
|
|
120
119
|
experimentalEnvGetSecretEnabled: false,
|
|
121
120
|
middleware(_, next) {
|
|
122
121
|
return next();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -110,13 +110,13 @@
|
|
|
110
110
|
"vendor"
|
|
111
111
|
],
|
|
112
112
|
"dependencies": {
|
|
113
|
-
"@astrojs/compiler": "^2.
|
|
114
|
-
"@babel/core": "^7.
|
|
115
|
-
"@babel/generator": "^7.
|
|
116
|
-
"@babel/parser": "^7.
|
|
117
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
118
|
-
"@babel/traverse": "^7.
|
|
119
|
-
"@babel/types": "^7.
|
|
113
|
+
"@astrojs/compiler": "^2.10.0",
|
|
114
|
+
"@babel/core": "^7.25.2",
|
|
115
|
+
"@babel/generator": "^7.25.0",
|
|
116
|
+
"@babel/parser": "^7.25.3",
|
|
117
|
+
"@babel/plugin-transform-react-jsx": "^7.25.2",
|
|
118
|
+
"@babel/traverse": "^7.25.3",
|
|
119
|
+
"@babel/types": "^7.25.2",
|
|
120
120
|
"@types/babel__core": "^7.20.5",
|
|
121
121
|
"@types/cookie": "^0.6.0",
|
|
122
122
|
"acorn": "^8.12.1",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"common-ancestor-path": "^1.0.1",
|
|
130
130
|
"cookie": "^0.6.0",
|
|
131
131
|
"cssesc": "^3.0.0",
|
|
132
|
-
"debug": "^4.3.
|
|
132
|
+
"debug": "^4.3.6",
|
|
133
133
|
"deterministic-object-hash": "^2.0.2",
|
|
134
134
|
"devalue": "^5.0.0",
|
|
135
135
|
"diff": "^5.2.0",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"http-cache-semantics": "^4.1.1",
|
|
148
148
|
"js-yaml": "^4.1.0",
|
|
149
149
|
"kleur": "^4.1.5",
|
|
150
|
-
"magic-string": "^0.30.
|
|
150
|
+
"magic-string": "^0.30.11",
|
|
151
151
|
"mrmime": "^2.0.0",
|
|
152
152
|
"ora": "^8.0.1",
|
|
153
153
|
"p-limit": "^6.1.0",
|
|
@@ -157,18 +157,18 @@
|
|
|
157
157
|
"prompts": "^2.4.2",
|
|
158
158
|
"rehype": "^13.0.1",
|
|
159
159
|
"semver": "^7.6.3",
|
|
160
|
-
"shiki": "^1.
|
|
160
|
+
"shiki": "^1.12.0",
|
|
161
161
|
"string-width": "^7.2.0",
|
|
162
162
|
"strip-ansi": "^7.1.0",
|
|
163
163
|
"tsconfck": "^3.1.1",
|
|
164
164
|
"unist-util-visit": "^5.0.0",
|
|
165
165
|
"vfile": "^6.0.2",
|
|
166
|
-
"vite": "^5.3.
|
|
166
|
+
"vite": "^5.3.5",
|
|
167
167
|
"vitefu": "^0.2.5",
|
|
168
168
|
"which-pm": "^3.0.0",
|
|
169
169
|
"yargs-parser": "^21.1.1",
|
|
170
170
|
"zod": "^3.23.8",
|
|
171
|
-
"zod-to-json-schema": "^3.23.
|
|
171
|
+
"zod-to-json-schema": "^3.23.2",
|
|
172
172
|
"@astrojs/internal-helpers": "0.4.1",
|
|
173
173
|
"@astrojs/markdown-remark": "5.2.0",
|
|
174
174
|
"@astrojs/telemetry": "3.1.0"
|
|
@@ -177,8 +177,8 @@
|
|
|
177
177
|
"sharp": "^0.33.3"
|
|
178
178
|
},
|
|
179
179
|
"devDependencies": {
|
|
180
|
-
"@astrojs/check": "^0.
|
|
181
|
-
"@playwright/test": "^1.45.
|
|
180
|
+
"@astrojs/check": "^0.9.0",
|
|
181
|
+
"@playwright/test": "^1.45.3",
|
|
182
182
|
"@types/aria-query": "^5.0.4",
|
|
183
183
|
"@types/babel__generator": "^7.6.8",
|
|
184
184
|
"@types/babel__traverse": "^7.20.6",
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
"@types/html-escaper": "^3.0.2",
|
|
194
194
|
"@types/http-cache-semantics": "^4.0.4",
|
|
195
195
|
"@types/js-yaml": "^4.0.9",
|
|
196
|
-
"@types/probe-image-size": "^7.2.
|
|
196
|
+
"@types/probe-image-size": "^7.2.5",
|
|
197
197
|
"@types/prompts": "^2.4.9",
|
|
198
198
|
"@types/semver": "^7.5.8",
|
|
199
199
|
"@types/send": "^0.17.4",
|
|
@@ -204,17 +204,17 @@
|
|
|
204
204
|
"expect-type": "^0.19.0",
|
|
205
205
|
"mdast-util-mdx": "^3.0.0",
|
|
206
206
|
"mdast-util-mdx-jsx": "^3.1.2",
|
|
207
|
-
"memfs": "^4.
|
|
208
|
-
"node-mocks-http": "^1.15.
|
|
207
|
+
"memfs": "^4.11.0",
|
|
208
|
+
"node-mocks-http": "^1.15.1",
|
|
209
209
|
"parse-srcset": "^1.0.2",
|
|
210
210
|
"rehype-autolink-headings": "^7.1.0",
|
|
211
211
|
"rehype-slug": "^6.0.0",
|
|
212
212
|
"rehype-toc": "^3.0.2",
|
|
213
213
|
"remark-code-titles": "^0.1.2",
|
|
214
|
-
"rollup": "^4.19.
|
|
214
|
+
"rollup": "^4.19.1",
|
|
215
215
|
"sass": "^1.77.8",
|
|
216
216
|
"srcset-parse": "^1.1.0",
|
|
217
|
-
"undici": "^6.19.
|
|
217
|
+
"undici": "^6.19.5",
|
|
218
218
|
"unified": "^11.0.5",
|
|
219
219
|
"astro-scripts": "0.0.14"
|
|
220
220
|
},
|