astro 4.11.6 → 4.12.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/client.d.ts +1 -0
- package/components/Code.astro +12 -0
- package/dist/@types/astro.d.ts +154 -74
- package/dist/actions/index.d.ts +4 -1
- package/dist/actions/index.js +15 -10
- package/dist/assets/internal.js +5 -12
- package/dist/assets/utils/index.d.ts +2 -1
- package/dist/assets/utils/index.js +3 -1
- package/dist/assets/utils/{emitAsset.d.ts → node/emitAsset.d.ts} +1 -1
- package/dist/assets/utils/{emitAsset.js → node/emitAsset.js} +2 -2
- package/dist/assets/utils/remoteProbe.d.ts +2 -2
- package/dist/assets/utils/remoteProbe.js +13 -6
- package/dist/assets/vite-plugin-assets.js +2 -1
- package/dist/cli/check/index.js +7 -5
- package/dist/cli/sync/index.d.ts +1 -1
- package/dist/cli/sync/index.js +6 -3
- package/dist/container/index.js +3 -1
- package/dist/content/runtime-assets.js +1 -1
- package/dist/content/vite-plugin-content-virtual-mod.js +4 -8
- package/dist/core/app/common.js +3 -1
- package/dist/core/app/index.js +3 -2
- package/dist/core/app/pipeline.d.ts +1 -1
- package/dist/core/app/pipeline.js +11 -11
- package/dist/core/app/types.d.ts +6 -2
- package/dist/core/base-pipeline.d.ts +21 -1
- package/dist/core/base-pipeline.js +3 -1
- package/dist/core/build/generate.js +1 -0
- package/dist/core/build/index.js +10 -6
- package/dist/core/build/pipeline.d.ts +6 -0
- package/dist/core/build/pipeline.js +11 -8
- package/dist/core/build/plugins/plugin-manifest.js +3 -1
- package/dist/core/build/plugins/plugin-ssr.js +8 -4
- package/dist/core/build/static-build.js +5 -5
- package/dist/core/config/schema.d.ts +37 -0
- package/dist/core/config/schema.js +5 -2
- package/dist/core/config/settings.js +2 -0
- package/dist/core/constants.d.ts +7 -0
- package/dist/core/constants.js +5 -1
- package/dist/core/create-vite.js +2 -2
- package/dist/core/dev/container.js +8 -0
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/vite.js +1 -2
- package/dist/core/errors/errors-data.d.ts +2 -10
- package/dist/core/errors/errors-data.js +0 -6
- package/dist/core/errors/overlay.js +6 -7
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.js +6 -6
- package/dist/core/redirects/render.js +1 -2
- package/dist/core/render/paginate.js +8 -1
- package/dist/core/render-context.js +8 -1
- package/dist/core/routing/astro-designed-error-pages.d.ts +2 -7
- package/dist/core/routing/astro-designed-error-pages.js +4 -1
- package/dist/core/routing/default.d.ts +10 -0
- package/dist/core/routing/default.js +38 -0
- package/dist/core/routing/manifest/create.d.ts +1 -2
- package/dist/core/routing/manifest/create.js +2 -34
- package/dist/core/routing/manifest/pattern.d.ts +2 -0
- package/dist/core/routing/manifest/pattern.js +35 -0
- package/dist/core/server-islands/endpoint.d.ts +8 -0
- package/dist/core/server-islands/endpoint.js +76 -0
- package/dist/core/server-islands/vite-plugin-server-islands.d.ts +7 -0
- package/dist/core/server-islands/vite-plugin-server-islands.js +82 -0
- package/dist/core/sync/index.d.ts +13 -5
- package/dist/core/sync/index.js +36 -23
- package/dist/core/sync/setup-env-ts.d.ts +8 -0
- package/dist/{vite-plugin-inject-env-ts/index.js → core/sync/setup-env-ts.js} +11 -28
- package/dist/env/errors.d.ts +7 -0
- package/dist/env/errors.js +16 -0
- package/dist/env/runtime.d.ts +4 -3
- package/dist/env/runtime.js +9 -5
- package/dist/env/validators.d.ts +5 -3
- package/dist/env/vite-plugin-env.js +2 -11
- package/dist/integrations/hooks.d.ts +3 -1
- package/dist/integrations/hooks.js +5 -4
- package/dist/jsx/babel.js +6 -8
- package/dist/jsx/rehype.js +4 -8
- package/dist/jsx-runtime/index.js +1 -2
- package/dist/runtime/client/dev-toolbar/entrypoint.js +3 -2
- package/dist/runtime/server/render/component.d.ts +2 -1
- package/dist/runtime/server/render/component.js +4 -0
- package/dist/runtime/server/render/server-islands.d.ts +5 -0
- package/dist/runtime/server/render/server-islands.js +73 -0
- package/dist/runtime/server/render/slot.d.ts +2 -1
- package/dist/runtime/server/render/slot.js +8 -1
- package/dist/vite-plugin-astro/index.js +3 -1
- package/dist/vite-plugin-astro/metadata.d.ts +1 -0
- package/dist/vite-plugin-astro/metadata.js +12 -0
- package/dist/vite-plugin-astro/types.d.ts +1 -0
- package/dist/vite-plugin-astro-server/pipeline.d.ts +7 -0
- package/dist/vite-plugin-astro-server/pipeline.js +20 -5
- package/dist/vite-plugin-astro-server/plugin.js +5 -3
- package/dist/vite-plugin-astro-server/route.js +13 -14
- package/dist/vite-plugin-markdown/index.js +2 -8
- package/dist/vite-plugin-utils/index.d.ts +5 -0
- package/dist/vite-plugin-utils/index.js +5 -0
- package/package.json +5 -4
- package/templates/env/module.mjs +5 -2
- package/dist/vite-plugin-inject-env-ts/index.d.ts +0 -17
package/client.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ declare module 'astro:assets' {
|
|
|
54
54
|
) => Promise<import('./dist/assets/types.js').GetImageResult>;
|
|
55
55
|
imageConfig: import('./dist/@types/astro.js').AstroConfig['image'];
|
|
56
56
|
getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
|
|
57
|
+
inferRemoteSize: typeof import('./dist/assets/utils/index.js').inferRemoteSize;
|
|
57
58
|
Image: typeof import('./components/Image.astro').default;
|
|
58
59
|
Picture: typeof import('./components/Picture.astro').default;
|
|
59
60
|
};
|
package/components/Code.astro
CHANGED
|
@@ -36,6 +36,16 @@ interface Props extends Omit<HTMLAttributes<'pre'>, 'lang'> {
|
|
|
36
36
|
* Supports all themes found above; see https://shiki.style/guide/dual-themes for more information.
|
|
37
37
|
*/
|
|
38
38
|
themes?: Record<string, ThemePresets | ThemeRegistration | ThemeRegistrationRaw>;
|
|
39
|
+
/**
|
|
40
|
+
* Chooses a theme from the "themes" option that you've defined as the default styling theme.
|
|
41
|
+
* - <string>: one of the keys defined in the "themes" option. Will throw an error if the key is not defined.
|
|
42
|
+
* - false: disabled. You'll have to apply the styling theme yourself. No effect if the "themes" option is not set.
|
|
43
|
+
*
|
|
44
|
+
* See https://shiki.style/guide/dual-themes#without-default-color for more information.
|
|
45
|
+
*
|
|
46
|
+
* @default "light"
|
|
47
|
+
*/
|
|
48
|
+
defaultColor?: 'light' | 'dark' | string | false;
|
|
39
49
|
/**
|
|
40
50
|
* Enable word wrapping.
|
|
41
51
|
* - true: enabled.
|
|
@@ -64,6 +74,7 @@ const {
|
|
|
64
74
|
lang = 'plaintext',
|
|
65
75
|
theme = 'github-dark',
|
|
66
76
|
themes = {},
|
|
77
|
+
defaultColor = 'light',
|
|
67
78
|
wrap = false,
|
|
68
79
|
inline = false,
|
|
69
80
|
transformers = [],
|
|
@@ -92,6 +103,7 @@ const highlighter = await getCachedHighlighter({
|
|
|
92
103
|
],
|
|
93
104
|
theme,
|
|
94
105
|
themes,
|
|
106
|
+
defaultColor,
|
|
95
107
|
wrap,
|
|
96
108
|
transformers,
|
|
97
109
|
});
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type * as rollup from 'rollup';
|
|
|
6
6
|
import type * as vite from 'vite';
|
|
7
7
|
import type { ActionAccept, ActionClient, ActionInputSchema } from '../actions/runtime/virtual/server.js';
|
|
8
8
|
import type { RemotePattern } from '../assets/utils/remotePattern.js';
|
|
9
|
-
import type { AssetsPrefix, SerializedSSRManifest } from '../core/app/types.js';
|
|
9
|
+
import type { AssetsPrefix, SSRManifest, SerializedSSRManifest } from '../core/app/types.js';
|
|
10
10
|
import type { PageBuildData } from '../core/build/types.js';
|
|
11
11
|
import type { AstroConfigType } from '../core/config/index.js';
|
|
12
12
|
import type { AstroTimer } from '../core/config/timer.js';
|
|
@@ -37,6 +37,7 @@ export interface AstroBuiltinProps {
|
|
|
37
37
|
'client:media'?: string;
|
|
38
38
|
'client:visible'?: ClientVisibleOptions | boolean;
|
|
39
39
|
'client:only'?: boolean | string;
|
|
40
|
+
'server:defer'?: boolean;
|
|
40
41
|
}
|
|
41
42
|
export type ClientVisibleOptions = Pick<IntersectionObserverInit, 'rootMargin'>;
|
|
42
43
|
export interface TransitionAnimation {
|
|
@@ -2056,6 +2057,70 @@ export interface AstroUserConfig {
|
|
|
2056
2057
|
*/
|
|
2057
2058
|
validateSecrets?: boolean;
|
|
2058
2059
|
};
|
|
2060
|
+
/**
|
|
2061
|
+
* @docs
|
|
2062
|
+
* @name experimental.serverIslands
|
|
2063
|
+
* @type {boolean}
|
|
2064
|
+
* @default `false`
|
|
2065
|
+
* @version 4.12.0
|
|
2066
|
+
* @description
|
|
2067
|
+
*
|
|
2068
|
+
* Enables experimental Server Island features.
|
|
2069
|
+
* Server Islands offer the ability to defer a component to render asynchronously after the page has already rendered.
|
|
2070
|
+
*
|
|
2071
|
+
* To enable, configure an [on-demand server rendering `output` mode](https://docs.astro.build/en/basics/rendering-modes/#on-demand-rendered) with an adapter, and add the `serverIslands` flag to the `experimental` object:
|
|
2072
|
+
*
|
|
2073
|
+
* ```js
|
|
2074
|
+
* {
|
|
2075
|
+
* output: 'hybrid', // or 'server'
|
|
2076
|
+
* adapter: nodejs({ mode: 'standalone' }),
|
|
2077
|
+
* experimental: {
|
|
2078
|
+
* serverIslands: true,
|
|
2079
|
+
* },
|
|
2080
|
+
* }
|
|
2081
|
+
* ```
|
|
2082
|
+
*
|
|
2083
|
+
* Use the `server:defer` directive on any Astro component to delay initial rendering:
|
|
2084
|
+
*
|
|
2085
|
+
* ```astro "server:defer"
|
|
2086
|
+
* ---
|
|
2087
|
+
* import Avatar from '~/components/Avatar.astro';
|
|
2088
|
+
* ---
|
|
2089
|
+
* <Avatar server:defer />
|
|
2090
|
+
* ```
|
|
2091
|
+
*
|
|
2092
|
+
* The outer page will be rendered, either at build-time (`hybrid`) or at runtime (`server`) with the island content omitted and a `<script>` tag included in its place.
|
|
2093
|
+
*
|
|
2094
|
+
* After the page loads in the browser, the script tag will replace itself with the the contents of the island by making a request.
|
|
2095
|
+
*
|
|
2096
|
+
* Any Astro component can be given the `server: defer` attribute to delay its rendering. There is no special API and you can write `.astro` code as normal:
|
|
2097
|
+
*
|
|
2098
|
+
* ```astro
|
|
2099
|
+
* ---
|
|
2100
|
+
* import { getUser } from '../api';
|
|
2101
|
+
*
|
|
2102
|
+
* const user = await getUser(Astro.locals.userId);
|
|
2103
|
+
* ---
|
|
2104
|
+
* <img class="avatar" src={user.imageUrl}>
|
|
2105
|
+
* ```
|
|
2106
|
+
*
|
|
2107
|
+
* #### Server island fallback content
|
|
2108
|
+
*
|
|
2109
|
+
* Since your component will not render with the rest of the page, you may want to add generic content (e.g. a loading message) to temporarily show in its place. This content will be displayed when the page first renders but before the island has loaded.
|
|
2110
|
+
*
|
|
2111
|
+
* Add placeholder content as a child of your Astro component with the `slot="fallback:` attribute. When your island content is available, the fallback content will be replaced.
|
|
2112
|
+
*
|
|
2113
|
+
* The example below displays a generic avatar as fallback content, then animates into a personalized avatar using view transitions:
|
|
2114
|
+
*
|
|
2115
|
+
* ```astro
|
|
2116
|
+
* <Avatar server:defer>
|
|
2117
|
+
* <svg slot="fallback" class="generic-avatar" transition:name="avatar">...</svg>
|
|
2118
|
+
* </Avatar>
|
|
2119
|
+
* ```
|
|
2120
|
+
*
|
|
2121
|
+
* For a complete overview, and to give feedback on this experimental API, see the [Server Islands RFC](https://github.com/withastro/roadmap/pull/963).
|
|
2122
|
+
*/
|
|
2123
|
+
serverIslands?: boolean;
|
|
2059
2124
|
};
|
|
2060
2125
|
}
|
|
2061
2126
|
/**
|
|
@@ -2229,6 +2294,8 @@ export interface AstroSettings {
|
|
|
2229
2294
|
* - the user is on the latest version already
|
|
2230
2295
|
*/
|
|
2231
2296
|
latestAstroVersion: string | undefined;
|
|
2297
|
+
serverIslandMap: NonNullable<SSRManifest['serverIslandMap']>;
|
|
2298
|
+
serverIslandNameMap: NonNullable<SSRManifest['serverIslandNameMap']>;
|
|
2232
2299
|
}
|
|
2233
2300
|
export type AsyncRendererComponentFn<U> = (Component: any, props: any, slots: Record<string, string>, metadata?: AstroComponentMetadata) => Promise<U>;
|
|
2234
2301
|
/** Generic interface for a component (Astro, Svelte, React, etc.) */
|
|
@@ -2426,6 +2493,10 @@ export interface Page<T = any> {
|
|
|
2426
2493
|
prev: string | undefined;
|
|
2427
2494
|
/** url of the next page (if there is one) */
|
|
2428
2495
|
next: string | undefined;
|
|
2496
|
+
/** url of the first page (if the current page is not the first page) */
|
|
2497
|
+
first: string | undefined;
|
|
2498
|
+
/** url of the next page (if the current page in not the last page) */
|
|
2499
|
+
last: string | undefined;
|
|
2429
2500
|
};
|
|
2430
2501
|
}
|
|
2431
2502
|
export type PaginateFunction = <PaginateData, AdditionalPaginateProps extends Props, AdditionalPaginateParams extends Params>(data: PaginateData[], args?: PaginateOptions<AdditionalPaginateProps, AdditionalPaginateParams>) => {
|
|
@@ -2771,84 +2842,91 @@ export interface SSRLoadedRenderer extends Pick<AstroRenderer, 'name' | 'clientE
|
|
|
2771
2842
|
ssr: SSRLoadedRendererValue;
|
|
2772
2843
|
}
|
|
2773
2844
|
export type HookParameters<Hook extends keyof AstroIntegration['hooks'], Fn = AstroIntegration['hooks'][Hook]> = Fn extends (...args: any) => any ? Parameters<Fn>[0] : never;
|
|
2845
|
+
declare global {
|
|
2846
|
+
namespace Astro {
|
|
2847
|
+
interface IntegrationHooks {
|
|
2848
|
+
'astro:config:setup': (options: {
|
|
2849
|
+
config: AstroConfig;
|
|
2850
|
+
command: 'dev' | 'build' | 'preview';
|
|
2851
|
+
isRestart: boolean;
|
|
2852
|
+
updateConfig: (newConfig: DeepPartial<AstroConfig>) => AstroConfig;
|
|
2853
|
+
addRenderer: (renderer: AstroRenderer) => void;
|
|
2854
|
+
addWatchFile: (path: URL | string) => void;
|
|
2855
|
+
injectScript: (stage: InjectedScriptStage, content: string) => void;
|
|
2856
|
+
injectRoute: (injectRoute: InjectedRoute) => void;
|
|
2857
|
+
addClientDirective: (directive: ClientDirectiveConfig) => void;
|
|
2858
|
+
/**
|
|
2859
|
+
* @deprecated Use `addDevToolbarApp` instead.
|
|
2860
|
+
* TODO: Fully remove in Astro 5.0
|
|
2861
|
+
*/
|
|
2862
|
+
addDevOverlayPlugin: (entrypoint: string) => void;
|
|
2863
|
+
addDevToolbarApp: (entrypoint: DevToolbarAppEntry | string) => void;
|
|
2864
|
+
addMiddleware: (mid: AstroIntegrationMiddleware) => void;
|
|
2865
|
+
logger: AstroIntegrationLogger;
|
|
2866
|
+
}) => void | Promise<void>;
|
|
2867
|
+
'astro:config:done': (options: {
|
|
2868
|
+
config: AstroConfig;
|
|
2869
|
+
setAdapter: (adapter: AstroAdapter) => void;
|
|
2870
|
+
logger: AstroIntegrationLogger;
|
|
2871
|
+
}) => void | Promise<void>;
|
|
2872
|
+
'astro:server:setup': (options: {
|
|
2873
|
+
server: vite.ViteDevServer;
|
|
2874
|
+
logger: AstroIntegrationLogger;
|
|
2875
|
+
toolbar: ReturnType<typeof getToolbarServerCommunicationHelpers>;
|
|
2876
|
+
}) => void | Promise<void>;
|
|
2877
|
+
'astro:server:start': (options: {
|
|
2878
|
+
address: AddressInfo;
|
|
2879
|
+
logger: AstroIntegrationLogger;
|
|
2880
|
+
}) => void | Promise<void>;
|
|
2881
|
+
'astro:server:done': (options: {
|
|
2882
|
+
logger: AstroIntegrationLogger;
|
|
2883
|
+
}) => void | Promise<void>;
|
|
2884
|
+
'astro:build:ssr': (options: {
|
|
2885
|
+
manifest: SerializedSSRManifest;
|
|
2886
|
+
/**
|
|
2887
|
+
* This maps a {@link RouteData} to an {@link URL}, this URL represents
|
|
2888
|
+
* the physical file you should import.
|
|
2889
|
+
*/
|
|
2890
|
+
entryPoints: Map<RouteData, URL>;
|
|
2891
|
+
/**
|
|
2892
|
+
* File path of the emitted middleware
|
|
2893
|
+
*/
|
|
2894
|
+
middlewareEntryPoint: URL | undefined;
|
|
2895
|
+
logger: AstroIntegrationLogger;
|
|
2896
|
+
}) => void | Promise<void>;
|
|
2897
|
+
'astro:build:start': (options: {
|
|
2898
|
+
logger: AstroIntegrationLogger;
|
|
2899
|
+
}) => void | Promise<void>;
|
|
2900
|
+
'astro:build:setup': (options: {
|
|
2901
|
+
vite: vite.InlineConfig;
|
|
2902
|
+
pages: Map<string, PageBuildData>;
|
|
2903
|
+
target: 'client' | 'server';
|
|
2904
|
+
updateConfig: (newConfig: vite.InlineConfig) => void;
|
|
2905
|
+
logger: AstroIntegrationLogger;
|
|
2906
|
+
}) => void | Promise<void>;
|
|
2907
|
+
'astro:build:generated': (options: {
|
|
2908
|
+
dir: URL;
|
|
2909
|
+
logger: AstroIntegrationLogger;
|
|
2910
|
+
}) => void | Promise<void>;
|
|
2911
|
+
'astro:build:done': (options: {
|
|
2912
|
+
pages: {
|
|
2913
|
+
pathname: string;
|
|
2914
|
+
}[];
|
|
2915
|
+
dir: URL;
|
|
2916
|
+
routes: RouteData[];
|
|
2917
|
+
logger: AstroIntegrationLogger;
|
|
2918
|
+
cacheManifest: boolean;
|
|
2919
|
+
}) => void | Promise<void>;
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2774
2923
|
export interface AstroIntegration {
|
|
2775
2924
|
/** The name of the integration. */
|
|
2776
2925
|
name: string;
|
|
2777
2926
|
/** The different hooks available to extend. */
|
|
2778
2927
|
hooks: {
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
command: 'dev' | 'build' | 'preview';
|
|
2782
|
-
isRestart: boolean;
|
|
2783
|
-
updateConfig: (newConfig: DeepPartial<AstroConfig>) => AstroConfig;
|
|
2784
|
-
addRenderer: (renderer: AstroRenderer) => void;
|
|
2785
|
-
addWatchFile: (path: URL | string) => void;
|
|
2786
|
-
injectScript: (stage: InjectedScriptStage, content: string) => void;
|
|
2787
|
-
injectRoute: (injectRoute: InjectedRoute) => void;
|
|
2788
|
-
addClientDirective: (directive: ClientDirectiveConfig) => void;
|
|
2789
|
-
/**
|
|
2790
|
-
* @deprecated Use `addDevToolbarApp` instead.
|
|
2791
|
-
* TODO: Fully remove in Astro 5.0
|
|
2792
|
-
*/
|
|
2793
|
-
addDevOverlayPlugin: (entrypoint: string) => void;
|
|
2794
|
-
addDevToolbarApp: (entrypoint: DevToolbarAppEntry | string) => void;
|
|
2795
|
-
addMiddleware: (mid: AstroIntegrationMiddleware) => void;
|
|
2796
|
-
logger: AstroIntegrationLogger;
|
|
2797
|
-
}) => void | Promise<void>;
|
|
2798
|
-
'astro:config:done'?: (options: {
|
|
2799
|
-
config: AstroConfig;
|
|
2800
|
-
setAdapter: (adapter: AstroAdapter) => void;
|
|
2801
|
-
logger: AstroIntegrationLogger;
|
|
2802
|
-
}) => void | Promise<void>;
|
|
2803
|
-
'astro:server:setup'?: (options: {
|
|
2804
|
-
server: vite.ViteDevServer;
|
|
2805
|
-
logger: AstroIntegrationLogger;
|
|
2806
|
-
toolbar: ReturnType<typeof getToolbarServerCommunicationHelpers>;
|
|
2807
|
-
}) => void | Promise<void>;
|
|
2808
|
-
'astro:server:start'?: (options: {
|
|
2809
|
-
address: AddressInfo;
|
|
2810
|
-
logger: AstroIntegrationLogger;
|
|
2811
|
-
}) => void | Promise<void>;
|
|
2812
|
-
'astro:server:done'?: (options: {
|
|
2813
|
-
logger: AstroIntegrationLogger;
|
|
2814
|
-
}) => void | Promise<void>;
|
|
2815
|
-
'astro:build:ssr'?: (options: {
|
|
2816
|
-
manifest: SerializedSSRManifest;
|
|
2817
|
-
/**
|
|
2818
|
-
* This maps a {@link RouteData} to an {@link URL}, this URL represents
|
|
2819
|
-
* the physical file you should import.
|
|
2820
|
-
*/
|
|
2821
|
-
entryPoints: Map<RouteData, URL>;
|
|
2822
|
-
/**
|
|
2823
|
-
* File path of the emitted middleware
|
|
2824
|
-
*/
|
|
2825
|
-
middlewareEntryPoint: URL | undefined;
|
|
2826
|
-
logger: AstroIntegrationLogger;
|
|
2827
|
-
}) => void | Promise<void>;
|
|
2828
|
-
'astro:build:start'?: (options: {
|
|
2829
|
-
logger: AstroIntegrationLogger;
|
|
2830
|
-
}) => void | Promise<void>;
|
|
2831
|
-
'astro:build:setup'?: (options: {
|
|
2832
|
-
vite: vite.InlineConfig;
|
|
2833
|
-
pages: Map<string, PageBuildData>;
|
|
2834
|
-
target: 'client' | 'server';
|
|
2835
|
-
updateConfig: (newConfig: vite.InlineConfig) => void;
|
|
2836
|
-
logger: AstroIntegrationLogger;
|
|
2837
|
-
}) => void | Promise<void>;
|
|
2838
|
-
'astro:build:generated'?: (options: {
|
|
2839
|
-
dir: URL;
|
|
2840
|
-
logger: AstroIntegrationLogger;
|
|
2841
|
-
}) => void | Promise<void>;
|
|
2842
|
-
'astro:build:done'?: (options: {
|
|
2843
|
-
pages: {
|
|
2844
|
-
pathname: string;
|
|
2845
|
-
}[];
|
|
2846
|
-
dir: URL;
|
|
2847
|
-
routes: RouteData[];
|
|
2848
|
-
logger: AstroIntegrationLogger;
|
|
2849
|
-
cacheManifest: boolean;
|
|
2850
|
-
}) => void | Promise<void>;
|
|
2851
|
-
};
|
|
2928
|
+
[K in keyof Astro.IntegrationHooks]?: Astro.IntegrationHooks[K];
|
|
2929
|
+
} & Partial<Record<string, unknown>>;
|
|
2852
2930
|
}
|
|
2853
2931
|
export type RewritePayload = string | URL | Request;
|
|
2854
2932
|
export type MiddlewareNext = (rewritePayload?: RewritePayload) => Promise<Response>;
|
|
@@ -2941,6 +3019,7 @@ export interface SSRResult {
|
|
|
2941
3019
|
componentMetadata: Map<string, SSRComponentMetadata>;
|
|
2942
3020
|
inlinedScripts: Map<string, string>;
|
|
2943
3021
|
createAstro(Astro: AstroGlobalPartial, props: Record<string, any>, slots: Record<string, any> | null): AstroGlobal;
|
|
3022
|
+
params: Params;
|
|
2944
3023
|
resolve: (s: string) => Promise<string>;
|
|
2945
3024
|
response: AstroGlobal['response'];
|
|
2946
3025
|
request: AstroGlobal['request'];
|
|
@@ -2957,6 +3036,7 @@ export interface SSRResult {
|
|
|
2957
3036
|
*/
|
|
2958
3037
|
pathname: string;
|
|
2959
3038
|
cookies: AstroCookies | undefined;
|
|
3039
|
+
serverIslandNameMap: Map<string, string>;
|
|
2960
3040
|
_metadata: SSRMetadata;
|
|
2961
3041
|
}
|
|
2962
3042
|
/**
|
package/dist/actions/index.d.ts
CHANGED
package/dist/actions/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fsMod from "node:fs";
|
|
2
2
|
import { ActionsWithoutServerOutputError } from "../core/errors/errors-data.js";
|
|
3
3
|
import { AstroError } from "../core/errors/errors.js";
|
|
4
4
|
import { isServerLikeOutput, viteID } from "../core/util.js";
|
|
5
5
|
import { ACTIONS_TYPES_FILE, RESOLVED_VIRTUAL_MODULE_ID, VIRTUAL_MODULE_ID } from "./consts.js";
|
|
6
|
-
function astroActions() {
|
|
6
|
+
function astroActions({ fs = fsMod }) {
|
|
7
7
|
return {
|
|
8
8
|
name: VIRTUAL_MODULE_ID,
|
|
9
9
|
hooks: {
|
|
@@ -21,7 +21,7 @@ function astroActions() {
|
|
|
21
21
|
define: {
|
|
22
22
|
"import.meta.env.ACTIONS_PATH": stringifiedActionsImport
|
|
23
23
|
},
|
|
24
|
-
plugins: [vitePluginActions]
|
|
24
|
+
plugins: [vitePluginActions(fs)]
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
params.injectRoute({
|
|
@@ -35,13 +35,14 @@ function astroActions() {
|
|
|
35
35
|
});
|
|
36
36
|
await typegen({
|
|
37
37
|
stringifiedActionsImport,
|
|
38
|
-
root: params.config.root
|
|
38
|
+
root: params.config.root,
|
|
39
|
+
fs
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
|
-
const vitePluginActions = {
|
|
45
|
+
const vitePluginActions = (fs) => ({
|
|
45
46
|
name: VIRTUAL_MODULE_ID,
|
|
46
47
|
enforce: "pre",
|
|
47
48
|
resolveId(id) {
|
|
@@ -51,7 +52,10 @@ const vitePluginActions = {
|
|
|
51
52
|
},
|
|
52
53
|
async load(id, opts) {
|
|
53
54
|
if (id !== RESOLVED_VIRTUAL_MODULE_ID) return;
|
|
54
|
-
let code = await readFile(
|
|
55
|
+
let code = await fs.promises.readFile(
|
|
56
|
+
new URL("../../templates/actions.mjs", import.meta.url),
|
|
57
|
+
"utf-8"
|
|
58
|
+
);
|
|
55
59
|
if (opts?.ssr) {
|
|
56
60
|
code += `
|
|
57
61
|
export * from 'astro/actions/runtime/virtual/server.js';`;
|
|
@@ -61,10 +65,11 @@ export * from 'astro/actions/runtime/virtual/client.js';`;
|
|
|
61
65
|
}
|
|
62
66
|
return code;
|
|
63
67
|
}
|
|
64
|
-
};
|
|
68
|
+
});
|
|
65
69
|
async function typegen({
|
|
66
70
|
stringifiedActionsImport,
|
|
67
|
-
root
|
|
71
|
+
root,
|
|
72
|
+
fs
|
|
68
73
|
}) {
|
|
69
74
|
const content = `declare module "astro:actions" {
|
|
70
75
|
type Actions = typeof import(${stringifiedActionsImport})["server"];
|
|
@@ -72,8 +77,8 @@ async function typegen({
|
|
|
72
77
|
export const actions: Actions;
|
|
73
78
|
}`;
|
|
74
79
|
const dotAstroDir = new URL(".astro/", root);
|
|
75
|
-
await mkdir(dotAstroDir, { recursive: true });
|
|
76
|
-
await writeFile(new URL(ACTIONS_TYPES_FILE, dotAstroDir), content);
|
|
80
|
+
await fs.promises.mkdir(dotAstroDir, { recursive: true });
|
|
81
|
+
await fs.promises.writeFile(new URL(ACTIONS_TYPES_FILE, dotAstroDir), content);
|
|
77
82
|
}
|
|
78
83
|
export {
|
|
79
84
|
astroActions as default
|
package/dist/assets/internal.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
isImageMetadata
|
|
6
6
|
} from "./types.js";
|
|
7
7
|
import { isESMImportedImage, isRemoteImage, resolveSrc } from "./utils/imageKind.js";
|
|
8
|
-
import {
|
|
8
|
+
import { inferRemoteSize } from "./utils/remoteProbe.js";
|
|
9
9
|
async function getConfiguredImageService() {
|
|
10
10
|
if (!globalThis?.astroAsset?.imageService) {
|
|
11
11
|
const { default: service } = await import(
|
|
@@ -48,17 +48,10 @@ async function getImage(options, imageConfig) {
|
|
|
48
48
|
src: await resolveSrc(options.src)
|
|
49
49
|
};
|
|
50
50
|
if (options.inferSize && isRemoteImage(resolvedOptions.src)) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
delete resolvedOptions.inferSize;
|
|
56
|
-
} catch {
|
|
57
|
-
throw new AstroError({
|
|
58
|
-
...AstroErrorData.FailedToFetchRemoteImageDimensions,
|
|
59
|
-
message: AstroErrorData.FailedToFetchRemoteImageDimensions.message(resolvedOptions.src)
|
|
60
|
-
});
|
|
61
|
-
}
|
|
51
|
+
const result = await inferRemoteSize(resolvedOptions.src);
|
|
52
|
+
resolvedOptions.width ??= result.width;
|
|
53
|
+
resolvedOptions.height ??= result.height;
|
|
54
|
+
delete resolvedOptions.inferSize;
|
|
62
55
|
}
|
|
63
56
|
const originalFilePath = isESMImportedImage(resolvedOptions.src) ? resolvedOptions.src.fsPath : void 0;
|
|
64
57
|
const clonedSrc = isESMImportedImage(resolvedOptions.src) ? (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { emitESMImage } from './emitAsset.js';
|
|
1
|
+
export { emitESMImage } from './node/emitAsset.js';
|
|
2
2
|
export { isESMImportedImage, isRemoteImage } from './imageKind.js';
|
|
3
3
|
export { imageMetadata } from './metadata.js';
|
|
4
4
|
export { getOrigQueryParams } from './queryParams.js';
|
|
5
5
|
export { isRemoteAllowed, matchHostname, matchPathname, matchPattern, matchPort, matchProtocol, type RemotePattern, } from './remotePattern.js';
|
|
6
6
|
export { hashTransform, propsToFilename } from './transformToPath.js';
|
|
7
|
+
export { inferRemoteSize } from './remoteProbe.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { emitESMImage } from "./emitAsset.js";
|
|
1
|
+
import { emitESMImage } from "./node/emitAsset.js";
|
|
2
2
|
import { isESMImportedImage, isRemoteImage } from "./imageKind.js";
|
|
3
3
|
import { imageMetadata } from "./metadata.js";
|
|
4
4
|
import { getOrigQueryParams } from "./queryParams.js";
|
|
@@ -11,11 +11,13 @@ import {
|
|
|
11
11
|
matchProtocol
|
|
12
12
|
} from "./remotePattern.js";
|
|
13
13
|
import { hashTransform, propsToFilename } from "./transformToPath.js";
|
|
14
|
+
import { inferRemoteSize } from "./remoteProbe.js";
|
|
14
15
|
export {
|
|
15
16
|
emitESMImage,
|
|
16
17
|
getOrigQueryParams,
|
|
17
18
|
hashTransform,
|
|
18
19
|
imageMetadata,
|
|
20
|
+
inferRemoteSize,
|
|
19
21
|
isESMImportedImage,
|
|
20
22
|
isRemoteAllowed,
|
|
21
23
|
isRemoteImage,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
-
import { prependForwardSlash, slash } from "
|
|
5
|
-
import { imageMetadata } from "
|
|
4
|
+
import { prependForwardSlash, slash } from "../../../core/path.js";
|
|
5
|
+
import { imageMetadata } from "../metadata.js";
|
|
6
6
|
async function emitESMImage(id, _watchMode, fileEmitter) {
|
|
7
7
|
if (!id) {
|
|
8
8
|
return void 0;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
1
|
+
import type { ImageMetadata } from '../types.js';
|
|
2
|
+
export declare function inferRemoteSize(url: string): Promise<Omit<ImageMetadata, 'src' | 'fsPath'>>;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
|
2
|
+
import { imageMetadata } from "./metadata.js";
|
|
3
|
+
async function inferRemoteSize(url) {
|
|
3
4
|
const response = await fetch(url);
|
|
4
5
|
if (!response.body || !response.ok) {
|
|
5
|
-
throw new
|
|
6
|
+
throw new AstroError({
|
|
7
|
+
...AstroErrorData.FailedToFetchRemoteImageDimensions,
|
|
8
|
+
message: AstroErrorData.FailedToFetchRemoteImageDimensions.message(url)
|
|
9
|
+
});
|
|
6
10
|
}
|
|
7
11
|
const reader = response.body.getReader();
|
|
8
12
|
let done, value;
|
|
@@ -18,7 +22,7 @@ async function probe(url) {
|
|
|
18
22
|
tmp.set(value, accumulatedChunks.length);
|
|
19
23
|
accumulatedChunks = tmp;
|
|
20
24
|
try {
|
|
21
|
-
const dimensions =
|
|
25
|
+
const dimensions = await imageMetadata(accumulatedChunks, url);
|
|
22
26
|
if (dimensions) {
|
|
23
27
|
await reader.cancel();
|
|
24
28
|
return dimensions;
|
|
@@ -27,8 +31,11 @@ async function probe(url) {
|
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
|
-
throw new
|
|
34
|
+
throw new AstroError({
|
|
35
|
+
...AstroErrorData.NoImageMetadata,
|
|
36
|
+
message: AstroErrorData.NoImageMetadata.message(url)
|
|
37
|
+
});
|
|
31
38
|
}
|
|
32
39
|
export {
|
|
33
|
-
|
|
40
|
+
inferRemoteSize
|
|
34
41
|
};
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
} from "../core/path.js";
|
|
13
13
|
import { isServerLikeOutput } from "../core/util.js";
|
|
14
14
|
import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from "./consts.js";
|
|
15
|
-
import { emitESMImage } from "./utils/emitAsset.js";
|
|
16
15
|
import { getAssetsPrefix } from "./utils/getAssetsPrefix.js";
|
|
17
16
|
import { isESMImportedImage } from "./utils/imageKind.js";
|
|
17
|
+
import { emitESMImage } from "./utils/node/emitAsset.js";
|
|
18
18
|
import { getProxyCode } from "./utils/proxy.js";
|
|
19
19
|
import { hashTransform, propsToFilename } from "./utils/transformToPath.js";
|
|
20
20
|
const resolvedVirtualModuleId = "\0" + VIRTUAL_MODULE_ID;
|
|
@@ -101,6 +101,7 @@ function assets({
|
|
|
101
101
|
import { getImage as getImageInternal } from "astro/assets";
|
|
102
102
|
export { default as Image } from "astro/components/Image.astro";
|
|
103
103
|
export { default as Picture } from "astro/components/Picture.astro";
|
|
104
|
+
export { inferRemoteSize } from "astro/assets/utils/inferRemoteSize.js";
|
|
104
105
|
|
|
105
106
|
export const imageConfig = ${JSON.stringify(settings.config.image)};
|
|
106
107
|
// This is used by the @astrojs/node integration to locate images.
|
package/dist/cli/check/index.js
CHANGED
|
@@ -20,11 +20,13 @@ async function check(flags) {
|
|
|
20
20
|
);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
if (!flags.noSync && !flags.help) {
|
|
24
|
+
const { default: sync } = await import("../../core/sync/index.js");
|
|
25
|
+
try {
|
|
26
|
+
await sync({ inlineConfig: flagsToAstroInlineConfig(flags) });
|
|
27
|
+
} catch (_) {
|
|
28
|
+
return process.exit(1);
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
const { check: checker, parseArgsAsCheckConfig } = checkPackage;
|
|
30
32
|
const config = parseArgsAsCheckConfig(process.argv);
|
package/dist/cli/sync/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type yargs from 'yargs-parser';
|
|
|
2
2
|
interface SyncOptions {
|
|
3
3
|
flags: yargs.Arguments;
|
|
4
4
|
}
|
|
5
|
-
export declare function sync({ flags }: SyncOptions): Promise<
|
|
5
|
+
export declare function sync({ flags }: SyncOptions): Promise<0 | 1>;
|
|
6
6
|
export {};
|
package/dist/cli/sync/index.js
CHANGED
|
@@ -13,9 +13,12 @@ async function sync({ flags }) {
|
|
|
13
13
|
});
|
|
14
14
|
return 0;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
try {
|
|
17
|
+
await _sync({ inlineConfig: flagsToAstroInlineConfig(flags), telemetry: true });
|
|
18
|
+
return 0;
|
|
19
|
+
} catch (_) {
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
export {
|
|
21
24
|
sync
|
package/dist/container/index.js
CHANGED
|
@@ -5,13 +5,15 @@ import { Logger } from "../core/logger/core.js";
|
|
|
5
5
|
import { nodeLogDestination } from "../core/logger/node.js";
|
|
6
6
|
import { removeLeadingForwardSlash } from "../core/path.js";
|
|
7
7
|
import { RenderContext } from "../core/render-context.js";
|
|
8
|
-
import { getParts,
|
|
8
|
+
import { getParts, validateSegment } from "../core/routing/manifest/create.js";
|
|
9
|
+
import { getPattern } from "../core/routing/manifest/pattern.js";
|
|
9
10
|
import { ContainerPipeline } from "./pipeline.js";
|
|
10
11
|
function createManifest(manifest, renderers, middleware) {
|
|
11
12
|
const defaultMiddleware = (_, next) => {
|
|
12
13
|
return next();
|
|
13
14
|
};
|
|
14
15
|
return {
|
|
16
|
+
hrefRoot: import.meta.url,
|
|
15
17
|
rewritingEnabled: false,
|
|
16
18
|
trailingSlash: manifest?.trailingSlash ?? ASTRO_CONFIG_DEFAULTS.trailingSlash,
|
|
17
19
|
buildFormat: manifest?.buildFormat ?? ASTRO_CONFIG_DEFAULTS.build.format,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { emitESMImage } from "../assets/utils/emitAsset.js";
|
|
2
|
+
import { emitESMImage } from "../assets/utils/node/emitAsset.js";
|
|
3
3
|
function createImage(pluginContext, shouldEmitFile, entryFilePath) {
|
|
4
4
|
return () => {
|
|
5
5
|
return z.string().transform(async (imagePath, ctx) => {
|
|
@@ -8,6 +8,7 @@ import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
|
8
8
|
import { appendForwardSlash, removeFileExtension } from "../core/path.js";
|
|
9
9
|
import { isServerLikeOutput } from "../core/util.js";
|
|
10
10
|
import { rootRelativePath } from "../core/viteUtils.js";
|
|
11
|
+
import { createDefaultAstroMetadata } from "../vite-plugin-astro/metadata.js";
|
|
11
12
|
import {
|
|
12
13
|
CONTENT_FLAG,
|
|
13
14
|
CONTENT_RENDER_FLAG,
|
|
@@ -65,17 +66,12 @@ function astroContentVirtualModPlugin({
|
|
|
65
66
|
IS_SERVER,
|
|
66
67
|
isClient
|
|
67
68
|
});
|
|
69
|
+
const astro = createDefaultAstroMetadata();
|
|
70
|
+
astro.propagation = "in-tree";
|
|
68
71
|
return {
|
|
69
72
|
code,
|
|
70
73
|
meta: {
|
|
71
|
-
astro
|
|
72
|
-
hydratedComponents: [],
|
|
73
|
-
clientOnlyComponents: [],
|
|
74
|
-
scripts: [],
|
|
75
|
-
containsHead: false,
|
|
76
|
-
propagation: "in-tree",
|
|
77
|
-
pageOptions: {}
|
|
78
|
-
}
|
|
74
|
+
astro
|
|
79
75
|
}
|
|
80
76
|
};
|
|
81
77
|
}
|