astro 2.5.5 → 2.5.6
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 +3 -2
- package/dist/assets/services/service.js +6 -0
- package/dist/assets/utils/emitAsset.d.ts +1 -3
- package/dist/assets/utils/emitAsset.js +4 -15
- package/dist/assets/vite-plugin-assets.js +5 -5
- package/dist/content/runtime-assets.d.ts +1 -2
- package/dist/content/runtime-assets.js +2 -3
- package/dist/content/runtime.js +1 -1
- package/dist/content/types-generator.js +9 -5
- package/dist/content/utils.d.ts +2 -2
- package/dist/content/utils.js +4 -4
- package/dist/content/vite-plugin-content-imports.js +113 -150
- package/dist/content/vite-plugin-content-virtual-mod.d.ts +3 -3
- package/dist/content/vite-plugin-content-virtual-mod.js +7 -3
- package/dist/core/app/index.d.ts +0 -2
- package/dist/core/app/index.js +5 -7
- package/dist/core/app/types.d.ts +3 -2
- package/dist/core/build/generate.js +16 -11
- package/dist/core/build/graph.js +3 -2
- package/dist/core/build/internal.d.ts +8 -4
- package/dist/core/build/internal.js +19 -1
- package/dist/core/build/plugins/plugin-css.js +9 -14
- package/dist/core/build/plugins/plugin-middleware.d.ts +0 -1
- package/dist/core/build/plugins/plugin-middleware.js +3 -16
- package/dist/core/build/plugins/plugin-pages.d.ts +10 -0
- package/dist/core/build/plugins/plugin-pages.js +40 -24
- package/dist/core/build/plugins/plugin-ssr.d.ts +2 -2
- package/dist/core/build/plugins/plugin-ssr.js +46 -20
- package/dist/core/build/static-build.js +18 -5
- package/dist/core/build/types.d.ts +2 -2
- package/dist/core/config/schema.d.ts +170 -170
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +57 -8
- package/dist/core/errors/errors-data.js +57 -12
- package/dist/core/messages.js +2 -2
- package/dist/core/render/dev/index.js +1 -2
- package/dist/prerender/routing.d.ts +13 -0
- package/dist/prerender/routing.js +49 -0
- package/dist/runtime/server/astro-global.js +11 -1
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +9 -1
- package/dist/runtime/server/render/astro/instance.js +3 -0
- package/dist/runtime/server/scripts.js +1 -1
- package/dist/vite-plugin-astro-server/route.js +3 -11
- package/package.json +4 -4
|
@@ -454,7 +454,7 @@ export declare const AstroErrorData: {
|
|
|
454
454
|
* For unsupported formats such as SVGs and GIFs, you may be able to use an `img` tag directly:
|
|
455
455
|
* ```astro
|
|
456
456
|
* ---
|
|
457
|
-
* import rocket from '../assets/images/rocket.svg'
|
|
457
|
+
* import rocket from '../assets/images/rocket.svg';
|
|
458
458
|
* ---
|
|
459
459
|
*
|
|
460
460
|
* <img src={rocket.src} width={rocket.width} height={rocket.height} alt="A rocketship in space." />
|
|
@@ -551,7 +551,7 @@ export declare const AstroErrorData: {
|
|
|
551
551
|
* Making changes to the response, such as setting headers, cookies, and the status code cannot be done outside of page components.
|
|
552
552
|
*/
|
|
553
553
|
readonly ResponseSentError: {
|
|
554
|
-
readonly title: "Unable to set response";
|
|
554
|
+
readonly title: "Unable to set response.";
|
|
555
555
|
readonly code: 3030;
|
|
556
556
|
readonly message: "The response has already been sent to the browser and cannot be altered.";
|
|
557
557
|
};
|
|
@@ -570,7 +570,7 @@ export declare const AstroErrorData: {
|
|
|
570
570
|
* ```
|
|
571
571
|
*/
|
|
572
572
|
readonly MiddlewareNoDataOrNextCalled: {
|
|
573
|
-
readonly title: "The middleware didn't return a response or call `next
|
|
573
|
+
readonly title: "The middleware didn't return a response or call `next`.";
|
|
574
574
|
readonly code: 3031;
|
|
575
575
|
readonly message: "The middleware needs to either return a `Response` object or call the `next` function.";
|
|
576
576
|
};
|
|
@@ -588,7 +588,7 @@ export declare const AstroErrorData: {
|
|
|
588
588
|
* ```
|
|
589
589
|
*/
|
|
590
590
|
readonly MiddlewareNotAResponse: {
|
|
591
|
-
readonly title: "The middleware returned something that is not a `Response` object";
|
|
591
|
+
readonly title: "The middleware returned something that is not a `Response` object.";
|
|
592
592
|
readonly code: 3032;
|
|
593
593
|
readonly message: "Any data returned from middleware must be a valid `Response` object.";
|
|
594
594
|
};
|
|
@@ -608,11 +608,61 @@ export declare const AstroErrorData: {
|
|
|
608
608
|
* ```
|
|
609
609
|
*/
|
|
610
610
|
readonly LocalsNotAnObject: {
|
|
611
|
-
readonly title: "Value assigned to `locals` is not accepted";
|
|
611
|
+
readonly title: "Value assigned to `locals` is not accepted.";
|
|
612
612
|
readonly code: 3033;
|
|
613
613
|
readonly message: "`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.";
|
|
614
614
|
readonly hint: "If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`.";
|
|
615
615
|
};
|
|
616
|
+
/**
|
|
617
|
+
* @docs
|
|
618
|
+
* @see
|
|
619
|
+
* - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
|
|
620
|
+
* @description
|
|
621
|
+
* When using the default image services, `Image`'s and `getImage`'s `src` parameter must be either an imported image or an URL, it cannot be a filepath.
|
|
622
|
+
*
|
|
623
|
+
* ```astro
|
|
624
|
+
* ---
|
|
625
|
+
* import { Image } from "astro:assets";
|
|
626
|
+
* import myImage from "../my_image.png";
|
|
627
|
+
* ---
|
|
628
|
+
*
|
|
629
|
+
* <!-- GOOD: `src` is the full imported image. -->
|
|
630
|
+
* <Image src={myImage} alt="Cool image" />
|
|
631
|
+
*
|
|
632
|
+
* <!-- BAD: `src` is an image's `src` path instead of the full image. -->
|
|
633
|
+
* <Image src={myImage.src} alt="Cool image" />
|
|
634
|
+
* ```
|
|
635
|
+
*/
|
|
636
|
+
readonly LocalImageUsedWrongly: {
|
|
637
|
+
readonly title: "ESM imported images must be passed as-is.";
|
|
638
|
+
readonly code: 3034;
|
|
639
|
+
readonly message: (imageFilePath: string) => string;
|
|
640
|
+
};
|
|
641
|
+
/**
|
|
642
|
+
* @docs
|
|
643
|
+
* @see
|
|
644
|
+
* - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob)
|
|
645
|
+
* @description
|
|
646
|
+
* `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vitejs.dev/guide/features.html#glob-import) instead to acheive the same result.
|
|
647
|
+
*/
|
|
648
|
+
readonly AstroGlobUsedOutside: {
|
|
649
|
+
readonly title: "Astro.glob() used outside of an Astro file.";
|
|
650
|
+
readonly code: 3035;
|
|
651
|
+
readonly message: (globStr: string) => string;
|
|
652
|
+
readonly hint: "See Vite's documentation on `import.meta.glob` for more information: https://vitejs.dev/guide/features.html#glob-import";
|
|
653
|
+
};
|
|
654
|
+
/**
|
|
655
|
+
* @docs
|
|
656
|
+
* @see
|
|
657
|
+
* - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob)
|
|
658
|
+
* @description
|
|
659
|
+
* `Astro.glob()` did not return any matching files. There might be a typo in the glob pattern.
|
|
660
|
+
*/
|
|
661
|
+
readonly AstroGlobNoMatch: {
|
|
662
|
+
readonly title: "Astro.glob() did not match any files.";
|
|
663
|
+
readonly code: 3036;
|
|
664
|
+
readonly message: (globStr: string) => string;
|
|
665
|
+
};
|
|
616
666
|
/**
|
|
617
667
|
* @docs
|
|
618
668
|
* @see
|
|
@@ -858,7 +908,6 @@ export declare const AstroErrorData: {
|
|
|
858
908
|
};
|
|
859
909
|
/**
|
|
860
910
|
* @docs
|
|
861
|
-
* @message A content collection schema should not contain `slug` since it is reserved for slug generation. Remove this from your `COLLECTION_NAME` collection schema.
|
|
862
911
|
* @see
|
|
863
912
|
* - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/)
|
|
864
913
|
* @description
|
|
@@ -867,7 +916,7 @@ export declare const AstroErrorData: {
|
|
|
867
916
|
readonly ContentSchemaContainsSlugError: {
|
|
868
917
|
readonly title: "Content Schema should not contain `slug`.";
|
|
869
918
|
readonly code: 9003;
|
|
870
|
-
readonly message: (
|
|
919
|
+
readonly message: (collectionName: string) => string;
|
|
871
920
|
readonly hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field.";
|
|
872
921
|
};
|
|
873
922
|
/**
|
|
@@ -879,7 +928,7 @@ export declare const AstroErrorData: {
|
|
|
879
928
|
readonly CollectionDoesNotExistError: {
|
|
880
929
|
readonly title: "Collection does not exist";
|
|
881
930
|
readonly code: 9004;
|
|
882
|
-
readonly message: (
|
|
931
|
+
readonly message: (collectionName: string) => string;
|
|
883
932
|
readonly hint: "See https://docs.astro.build/en/guides/content-collections/ for more on creating collections.";
|
|
884
933
|
};
|
|
885
934
|
/**
|
|
@@ -466,7 +466,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
466
466
|
* For unsupported formats such as SVGs and GIFs, you may be able to use an `img` tag directly:
|
|
467
467
|
* ```astro
|
|
468
468
|
* ---
|
|
469
|
-
* import rocket from '../assets/images/rocket.svg'
|
|
469
|
+
* import rocket from '../assets/images/rocket.svg';
|
|
470
470
|
* ---
|
|
471
471
|
*
|
|
472
472
|
* <img src={rocket.src} width={rocket.width} height={rocket.height} alt="A rocketship in space." />
|
|
@@ -565,7 +565,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
565
565
|
* Making changes to the response, such as setting headers, cookies, and the status code cannot be done outside of page components.
|
|
566
566
|
*/
|
|
567
567
|
ResponseSentError: {
|
|
568
|
-
title: "Unable to set response",
|
|
568
|
+
title: "Unable to set response.",
|
|
569
569
|
code: 3030,
|
|
570
570
|
message: "The response has already been sent to the browser and cannot be altered."
|
|
571
571
|
},
|
|
@@ -584,7 +584,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
584
584
|
* ```
|
|
585
585
|
*/
|
|
586
586
|
MiddlewareNoDataOrNextCalled: {
|
|
587
|
-
title: "The middleware didn't return a response or call `next
|
|
587
|
+
title: "The middleware didn't return a response or call `next`.",
|
|
588
588
|
code: 3031,
|
|
589
589
|
message: "The middleware needs to either return a `Response` object or call the `next` function."
|
|
590
590
|
},
|
|
@@ -602,7 +602,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
602
602
|
* ```
|
|
603
603
|
*/
|
|
604
604
|
MiddlewareNotAResponse: {
|
|
605
|
-
title: "The middleware returned something that is not a `Response` object",
|
|
605
|
+
title: "The middleware returned something that is not a `Response` object.",
|
|
606
606
|
code: 3032,
|
|
607
607
|
message: "Any data returned from middleware must be a valid `Response` object."
|
|
608
608
|
},
|
|
@@ -622,11 +622,61 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
622
622
|
* ```
|
|
623
623
|
*/
|
|
624
624
|
LocalsNotAnObject: {
|
|
625
|
-
title: "Value assigned to `locals` is not accepted",
|
|
625
|
+
title: "Value assigned to `locals` is not accepted.",
|
|
626
626
|
code: 3033,
|
|
627
627
|
message: "`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.",
|
|
628
628
|
hint: "If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`."
|
|
629
629
|
},
|
|
630
|
+
/**
|
|
631
|
+
* @docs
|
|
632
|
+
* @see
|
|
633
|
+
* - [Assets (Experimental)](https://docs.astro.build/en/guides/assets/)
|
|
634
|
+
* @description
|
|
635
|
+
* When using the default image services, `Image`'s and `getImage`'s `src` parameter must be either an imported image or an URL, it cannot be a filepath.
|
|
636
|
+
*
|
|
637
|
+
* ```astro
|
|
638
|
+
* ---
|
|
639
|
+
* import { Image } from "astro:assets";
|
|
640
|
+
* import myImage from "../my_image.png";
|
|
641
|
+
* ---
|
|
642
|
+
*
|
|
643
|
+
* <!-- GOOD: `src` is the full imported image. -->
|
|
644
|
+
* <Image src={myImage} alt="Cool image" />
|
|
645
|
+
*
|
|
646
|
+
* <!-- BAD: `src` is an image's `src` path instead of the full image. -->
|
|
647
|
+
* <Image src={myImage.src} alt="Cool image" />
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
LocalImageUsedWrongly: {
|
|
651
|
+
title: "ESM imported images must be passed as-is.",
|
|
652
|
+
code: 3034,
|
|
653
|
+
message: (imageFilePath) => `\`Image\`'s and \`getImage\`'s \`src\` parameter must be an imported image or an URL, it cannot be a filepath. Received \`${imageFilePath}\`.`
|
|
654
|
+
},
|
|
655
|
+
/**
|
|
656
|
+
* @docs
|
|
657
|
+
* @see
|
|
658
|
+
* - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob)
|
|
659
|
+
* @description
|
|
660
|
+
* `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vitejs.dev/guide/features.html#glob-import) instead to acheive the same result.
|
|
661
|
+
*/
|
|
662
|
+
AstroGlobUsedOutside: {
|
|
663
|
+
title: "Astro.glob() used outside of an Astro file.",
|
|
664
|
+
code: 3035,
|
|
665
|
+
message: (globStr) => `\`Astro.glob(${globStr})\` can only be used in \`.astro\` files. \`import.meta.glob(${globStr})\` can be used instead to achieve a similar result.`,
|
|
666
|
+
hint: "See Vite's documentation on `import.meta.glob` for more information: https://vitejs.dev/guide/features.html#glob-import"
|
|
667
|
+
},
|
|
668
|
+
/**
|
|
669
|
+
* @docs
|
|
670
|
+
* @see
|
|
671
|
+
* - [Astro.glob](https://docs.astro.build/en/reference/api-reference/#astroglob)
|
|
672
|
+
* @description
|
|
673
|
+
* `Astro.glob()` did not return any matching files. There might be a typo in the glob pattern.
|
|
674
|
+
*/
|
|
675
|
+
AstroGlobNoMatch: {
|
|
676
|
+
title: "Astro.glob() did not match any files.",
|
|
677
|
+
code: 3036,
|
|
678
|
+
message: (globStr) => `\`Astro.glob(${globStr})\` did not return any matching files. Check the pattern for typos.`
|
|
679
|
+
},
|
|
630
680
|
// No headings here, that way Vite errors are merged with Astro ones in the docs, which makes more sense to users.
|
|
631
681
|
// Vite Errors - 4xxx
|
|
632
682
|
/**
|
|
@@ -890,7 +940,6 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
890
940
|
},
|
|
891
941
|
/**
|
|
892
942
|
* @docs
|
|
893
|
-
* @message A content collection schema should not contain `slug` since it is reserved for slug generation. Remove this from your `COLLECTION_NAME` collection schema.
|
|
894
943
|
* @see
|
|
895
944
|
* - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/)
|
|
896
945
|
* @description
|
|
@@ -899,9 +948,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
899
948
|
ContentSchemaContainsSlugError: {
|
|
900
949
|
title: "Content Schema should not contain `slug`.",
|
|
901
950
|
code: 9003,
|
|
902
|
-
message: (
|
|
903
|
-
return `A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${collection} collection schema.`;
|
|
904
|
-
},
|
|
951
|
+
message: (collectionName) => `A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${collectionName} collection schema.`,
|
|
905
952
|
hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
|
|
906
953
|
},
|
|
907
954
|
/**
|
|
@@ -913,9 +960,7 @@ Expected \`${defaultExpectedValue}\` value but got \`${suffix}\`.`;
|
|
|
913
960
|
CollectionDoesNotExistError: {
|
|
914
961
|
title: "Collection does not exist",
|
|
915
962
|
code: 9004,
|
|
916
|
-
message: (
|
|
917
|
-
return `The collection **${collection}** does not exist. Ensure a collection directory with this name exists.`;
|
|
918
|
-
},
|
|
963
|
+
message: (collectionName) => `The collection **${collectionName}** does not exist. Ensure a collection directory with this name exists.`,
|
|
919
964
|
hint: "See https://docs.astro.build/en/guides/content-collections/ for more on creating collections."
|
|
920
965
|
},
|
|
921
966
|
/**
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.5.
|
|
50
|
+
const version = "2.5.6";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -233,7 +233,7 @@ function printHelp({
|
|
|
233
233
|
message.push(
|
|
234
234
|
linebreak(),
|
|
235
235
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"2.5.
|
|
236
|
+
`v${"2.5.6"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { fileURLToPath } from "url";
|
|
2
1
|
import { PAGE_SCRIPT_ID } from "../../../vite-plugin-scripts/index.js";
|
|
3
2
|
import { createAPIContext } from "../../endpoint/index.js";
|
|
4
3
|
import { enhanceViteSSRError } from "../../errors/dev/index.js";
|
|
@@ -22,7 +21,7 @@ async function preload({
|
|
|
22
21
|
}) {
|
|
23
22
|
const renderers = await loadRenderers(env.loader, env.settings);
|
|
24
23
|
try {
|
|
25
|
-
const mod = await env.loader.import(
|
|
24
|
+
const mod = await env.loader.import(viteID(filePath));
|
|
26
25
|
return [renderers, mod];
|
|
27
26
|
} catch (error) {
|
|
28
27
|
if (MarkdownError.is(error) || CSSError.is(error) || AggregateError.is(error)) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AstroSettings, RouteData } from '../@types/astro';
|
|
2
|
+
import { type DevelopmentEnvironment } from '../core/render/dev/index.js';
|
|
3
|
+
type GetSortedPreloadedMatchesParams = {
|
|
4
|
+
env: DevelopmentEnvironment;
|
|
5
|
+
matches: RouteData[];
|
|
6
|
+
settings: AstroSettings;
|
|
7
|
+
};
|
|
8
|
+
export declare function getSortedPreloadedMatches({ env, matches, settings, }: GetSortedPreloadedMatchesParams): Promise<{
|
|
9
|
+
readonly preloadedComponent: import("../core/render/dev/index.js").ComponentPreload;
|
|
10
|
+
readonly route: RouteData;
|
|
11
|
+
readonly filePath: URL;
|
|
12
|
+
}[]>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { preload } from "../core/render/dev/index.js";
|
|
2
|
+
import { getPrerenderStatus } from "./metadata.js";
|
|
3
|
+
async function getSortedPreloadedMatches({
|
|
4
|
+
env,
|
|
5
|
+
matches,
|
|
6
|
+
settings
|
|
7
|
+
}) {
|
|
8
|
+
return (await preloadAndSetPrerenderStatus({
|
|
9
|
+
env,
|
|
10
|
+
matches,
|
|
11
|
+
settings
|
|
12
|
+
})).sort((a, b) => prioritizePrerenderedMatchesComparator(a.route, b.route));
|
|
13
|
+
}
|
|
14
|
+
async function preloadAndSetPrerenderStatus({
|
|
15
|
+
env,
|
|
16
|
+
matches,
|
|
17
|
+
settings
|
|
18
|
+
}) {
|
|
19
|
+
const preloaded = await Promise.all(
|
|
20
|
+
matches.map(async (route) => {
|
|
21
|
+
const filePath = new URL(`./${route.component}`, settings.config.root);
|
|
22
|
+
const preloadedComponent = await preload({ env, filePath });
|
|
23
|
+
const prerenderStatus = getPrerenderStatus({
|
|
24
|
+
filePath,
|
|
25
|
+
loader: env.loader
|
|
26
|
+
});
|
|
27
|
+
if (prerenderStatus !== void 0) {
|
|
28
|
+
route.prerender = prerenderStatus;
|
|
29
|
+
}
|
|
30
|
+
return { preloadedComponent, route, filePath };
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
return preloaded;
|
|
34
|
+
}
|
|
35
|
+
function prioritizePrerenderedMatchesComparator(a, b) {
|
|
36
|
+
if (areRegexesEqual(a.pattern, b.pattern)) {
|
|
37
|
+
if (a.prerender !== b.prerender) {
|
|
38
|
+
return a.prerender ? -1 : 1;
|
|
39
|
+
}
|
|
40
|
+
return a.component < b.component ? -1 : 1;
|
|
41
|
+
}
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
function areRegexesEqual(regexp1, regexp2) {
|
|
45
|
+
return regexp1.source === regexp2.source && regexp1.global === regexp2.global;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
getSortedPreloadedMatches
|
|
49
|
+
};
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { ASTRO_VERSION } from "../../core/constants.js";
|
|
2
|
+
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
|
2
3
|
function createAstroGlobFn() {
|
|
3
4
|
const globHandler = (importMetaGlobResult, globValue) => {
|
|
5
|
+
if (typeof importMetaGlobResult === "string") {
|
|
6
|
+
throw new AstroError({
|
|
7
|
+
...AstroErrorData.AstroGlobUsedOutside,
|
|
8
|
+
message: AstroErrorData.AstroGlobUsedOutside.message(JSON.stringify(importMetaGlobResult))
|
|
9
|
+
});
|
|
10
|
+
}
|
|
4
11
|
let allEntries = [...Object.values(importMetaGlobResult)];
|
|
5
12
|
if (allEntries.length === 0) {
|
|
6
|
-
throw new
|
|
13
|
+
throw new AstroError({
|
|
14
|
+
...AstroErrorData.AstroGlobNoMatch,
|
|
15
|
+
message: AstroErrorData.AstroGlobNoMatch.message(JSON.stringify(importMetaGlobResult))
|
|
16
|
+
});
|
|
7
17
|
}
|
|
8
18
|
return Promise.all(allEntries.map((fn) => fn()));
|
|
9
19
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createComponent } from './astro-component.js';
|
|
2
2
|
export { createAstro } from './astro-global.js';
|
|
3
3
|
export { renderEndpoint } from './endpoint.js';
|
|
4
|
-
export { escapeHTML, HTMLBytes, HTMLString, markHTMLString, unescapeHTML } from './escape.js';
|
|
4
|
+
export { escapeHTML, HTMLBytes, HTMLString, isHTMLString, markHTMLString, unescapeHTML, } from './escape.js';
|
|
5
5
|
export { renderJSX } from './jsx.js';
|
|
6
6
|
export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderAstroTemplateResult as renderAstroComponent, renderComponent, renderComponentToIterable, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderScriptElement, renderSlot, renderSlotToString, renderTemplate as render, renderTemplate, renderToString, renderUniqueStylesheet, stringifyChunk, voidElementNames, } from './render/index.js';
|
|
7
7
|
export type { AstroComponentFactory, AstroComponentInstance, ComponentSlots, RenderInstruction, } from './render/index.js';
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { createComponent } from "./astro-component.js";
|
|
2
2
|
import { createAstro } from "./astro-global.js";
|
|
3
3
|
import { renderEndpoint } from "./endpoint.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
escapeHTML,
|
|
6
|
+
HTMLBytes,
|
|
7
|
+
HTMLString,
|
|
8
|
+
isHTMLString,
|
|
9
|
+
markHTMLString,
|
|
10
|
+
unescapeHTML
|
|
11
|
+
} from "./escape.js";
|
|
5
12
|
import { renderJSX } from "./jsx.js";
|
|
6
13
|
import {
|
|
7
14
|
addAttribute,
|
|
@@ -93,6 +100,7 @@ export {
|
|
|
93
100
|
defineScriptVars,
|
|
94
101
|
defineStyleVars,
|
|
95
102
|
escapeHTML,
|
|
103
|
+
isHTMLString,
|
|
96
104
|
markHTMLString,
|
|
97
105
|
maybeRenderHead,
|
|
98
106
|
mergeSlots,
|
|
@@ -29,6 +29,9 @@ class AstroComponentInstance {
|
|
|
29
29
|
value = await value;
|
|
30
30
|
}
|
|
31
31
|
if (isHeadAndContent(value)) {
|
|
32
|
+
if (this.result.extraHead.length === 0 && value.head) {
|
|
33
|
+
yield renderChild(value.head);
|
|
34
|
+
}
|
|
32
35
|
yield* value.content;
|
|
33
36
|
} else {
|
|
34
37
|
yield* renderChild(value);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import islandScript from "./astro-island.prebuilt.js";
|
|
2
|
-
const ISLAND_STYLES = `<style>astro-island,astro-slot{display:contents}</style>`;
|
|
2
|
+
const ISLAND_STYLES = `<style>astro-island,astro-slot,astro-static-slot{display:contents}</style>`;
|
|
3
3
|
function determineIfNeedsHydrationScript(result) {
|
|
4
4
|
if (result._metadata.hasHydrationScript) {
|
|
5
5
|
return false;
|
|
@@ -9,7 +9,7 @@ import { preload, renderPage } from "../core/render/dev/index.js";
|
|
|
9
9
|
import { getParamsAndProps, GetParamsAndPropsError } from "../core/render/index.js";
|
|
10
10
|
import { createRequest } from "../core/request.js";
|
|
11
11
|
import { matchAllRoutes } from "../core/routing/index.js";
|
|
12
|
-
import {
|
|
12
|
+
import { getSortedPreloadedMatches } from "../prerender/routing.js";
|
|
13
13
|
import { isHybridOutput } from "../prerender/utils.js";
|
|
14
14
|
import { log404 } from "./common.js";
|
|
15
15
|
import { handle404Response, writeSSRResult, writeWebResponse } from "./response.js";
|
|
@@ -20,16 +20,8 @@ function getCustom404Route(manifest) {
|
|
|
20
20
|
async function matchRoute(pathname, env, manifest) {
|
|
21
21
|
const { logging, settings, routeCache } = env;
|
|
22
22
|
const matches = matchAllRoutes(pathname, manifest);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const preloadedComponent = await preload({ env, filePath });
|
|
26
|
-
const prerenderStatus = getPrerenderStatus({
|
|
27
|
-
filePath,
|
|
28
|
-
loader: env.loader
|
|
29
|
-
});
|
|
30
|
-
if (prerenderStatus !== void 0) {
|
|
31
|
-
maybeRoute.prerender = prerenderStatus;
|
|
32
|
-
}
|
|
23
|
+
const preloadedMatches = await getSortedPreloadedMatches({ env, matches, settings });
|
|
24
|
+
for await (const { preloadedComponent, route: maybeRoute, filePath } of preloadedMatches) {
|
|
33
25
|
const [, mod] = preloadedComponent;
|
|
34
26
|
const paramsAndPropsRes = await getParamsAndProps({
|
|
35
27
|
mod,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.6",
|
|
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",
|
|
@@ -103,13 +103,13 @@
|
|
|
103
103
|
"@astrojs/language-server": "^1.0.0",
|
|
104
104
|
"@astrojs/markdown-remark": "^2.2.1",
|
|
105
105
|
"@astrojs/telemetry": "^2.1.1",
|
|
106
|
-
"@astrojs/webapi": "^2.
|
|
107
|
-
"@babel/core": "^7.
|
|
106
|
+
"@astrojs/webapi": "^2.2.0",
|
|
107
|
+
"@babel/core": "^7.21.8",
|
|
108
108
|
"@babel/generator": "^7.18.2",
|
|
109
109
|
"@babel/parser": "^7.18.4",
|
|
110
110
|
"@babel/plugin-transform-react-jsx": "^7.17.12",
|
|
111
111
|
"@babel/traverse": "^7.18.2",
|
|
112
|
-
"@babel/types": "^7.
|
|
112
|
+
"@babel/types": "^7.21.5",
|
|
113
113
|
"@types/babel__core": "^7.1.19",
|
|
114
114
|
"@types/yargs-parser": "^21.0.0",
|
|
115
115
|
"acorn": "^8.8.2",
|