astro 4.12.0 → 4.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +8 -1
- package/dist/container/index.d.ts +29 -1
- package/dist/container/index.js +38 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/runtime/client/dev-toolbar/toolbar.js +5 -0
- package/dist/runtime/server/render/component.js +5 -2
- package/package.json +1 -1
package/client.d.ts
CHANGED
|
@@ -70,7 +70,14 @@ declare module 'astro:assets' {
|
|
|
70
70
|
export type RemoteImageProps = import('./dist/type-utils.js').Simplify<
|
|
71
71
|
import('./dist/assets/types.js').RemoteImageProps<ImgAttributes>
|
|
72
72
|
>;
|
|
73
|
-
export const {
|
|
73
|
+
export const {
|
|
74
|
+
getImage,
|
|
75
|
+
getConfiguredImageService,
|
|
76
|
+
imageConfig,
|
|
77
|
+
Image,
|
|
78
|
+
Picture,
|
|
79
|
+
inferRemoteSize,
|
|
80
|
+
}: AstroAssets;
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
type ImageMetadata = import('./dist/assets/types.js').ImageMetadata;
|
|
@@ -66,6 +66,10 @@ export type AddServerRenderer = {
|
|
|
66
66
|
renderer: SSRLoadedRendererValue;
|
|
67
67
|
name: string;
|
|
68
68
|
};
|
|
69
|
+
export type AddClientRenderer = {
|
|
70
|
+
name: string;
|
|
71
|
+
entrypoint: string;
|
|
72
|
+
};
|
|
69
73
|
export type AstroContainerUserConfig = Omit<AstroUserConfig, 'integrations' | 'adapter'>;
|
|
70
74
|
/**
|
|
71
75
|
* Options that are used for the entire lifecycle of the current instance of the container.
|
|
@@ -130,7 +134,7 @@ export declare class experimental_AstroContainer {
|
|
|
130
134
|
*/
|
|
131
135
|
static create(containerOptions?: AstroContainerOptions): Promise<experimental_AstroContainer>;
|
|
132
136
|
/**
|
|
133
|
-
* Use this function to manually add a renderer to the container.
|
|
137
|
+
* Use this function to manually add a **server** renderer to the container.
|
|
134
138
|
*
|
|
135
139
|
* This function is preferred when you require to use the container with a renderer in environments such as on-demand pages.
|
|
136
140
|
*
|
|
@@ -153,6 +157,30 @@ export declare class experimental_AstroContainer {
|
|
|
153
157
|
* @param options.renderer The server renderer exported by integration.
|
|
154
158
|
*/
|
|
155
159
|
addServerRenderer(options: AddServerRenderer): void;
|
|
160
|
+
/**
|
|
161
|
+
* Use this function to manually add a **client** renderer to the container.
|
|
162
|
+
*
|
|
163
|
+
* When rendering components that use the `client:*` directives, you need to use this function.
|
|
164
|
+
*
|
|
165
|
+
* ## Example
|
|
166
|
+
*
|
|
167
|
+
* ```js
|
|
168
|
+
* import reactRenderer from "@astrojs/react/server.js";
|
|
169
|
+
* import { experimental_AstroContainer as AstroContainer } from "astro/container"
|
|
170
|
+
*
|
|
171
|
+
* const container = await AstroContainer.create();
|
|
172
|
+
* container.addServerRenderer(reactRenderer);
|
|
173
|
+
* container.addClientRenderer({
|
|
174
|
+
* name: "@astrojs/react",
|
|
175
|
+
* entrypoint: "@astrojs/react/client.js"
|
|
176
|
+
* });
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @param options {object}
|
|
180
|
+
* @param options.name The name of the renderer. The name **isn't** arbitrary, and it should match the name of the package.
|
|
181
|
+
* @param options.entrypoint The entrypoint of the client renderer.
|
|
182
|
+
*/
|
|
183
|
+
addClientRenderer(options: AddClientRenderer): void;
|
|
156
184
|
private static createFromManifest;
|
|
157
185
|
/**
|
|
158
186
|
* @description
|
package/dist/container/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
+
import { getDefaultClientDirectives } from "../core/client-directive/index.js";
|
|
2
3
|
import { ASTRO_CONFIG_DEFAULTS } from "../core/config/schema.js";
|
|
3
4
|
import { validateConfig } from "../core/config/validate.js";
|
|
4
5
|
import { Logger } from "../core/logger/core.js";
|
|
@@ -23,7 +24,7 @@ function createManifest(manifest, renderers, middleware) {
|
|
|
23
24
|
entryModules: manifest?.entryModules ?? {},
|
|
24
25
|
routes: manifest?.routes ?? [],
|
|
25
26
|
adapterName: "",
|
|
26
|
-
clientDirectives: manifest?.clientDirectives ??
|
|
27
|
+
clientDirectives: manifest?.clientDirectives ?? getDefaultClientDirectives(),
|
|
27
28
|
renderers: renderers ?? manifest?.renderers ?? [],
|
|
28
29
|
base: manifest?.base ?? ASTRO_CONFIG_DEFAULTS.base,
|
|
29
30
|
componentMetadata: manifest?.componentMetadata ?? /* @__PURE__ */ new Map(),
|
|
@@ -96,7 +97,7 @@ class experimental_AstroContainer {
|
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
99
|
/**
|
|
99
|
-
* Use this function to manually add a renderer to the container.
|
|
100
|
+
* Use this function to manually add a **server** renderer to the container.
|
|
100
101
|
*
|
|
101
102
|
* This function is preferred when you require to use the container with a renderer in environments such as on-demand pages.
|
|
102
103
|
*
|
|
@@ -137,6 +138,41 @@ class experimental_AstroContainer {
|
|
|
137
138
|
});
|
|
138
139
|
}
|
|
139
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Use this function to manually add a **client** renderer to the container.
|
|
143
|
+
*
|
|
144
|
+
* When rendering components that use the `client:*` directives, you need to use this function.
|
|
145
|
+
*
|
|
146
|
+
* ## Example
|
|
147
|
+
*
|
|
148
|
+
* ```js
|
|
149
|
+
* import reactRenderer from "@astrojs/react/server.js";
|
|
150
|
+
* import { experimental_AstroContainer as AstroContainer } from "astro/container"
|
|
151
|
+
*
|
|
152
|
+
* const container = await AstroContainer.create();
|
|
153
|
+
* container.addServerRenderer(reactRenderer);
|
|
154
|
+
* container.addClientRenderer({
|
|
155
|
+
* name: "@astrojs/react",
|
|
156
|
+
* entrypoint: "@astrojs/react/client.js"
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @param options {object}
|
|
161
|
+
* @param options.name The name of the renderer. The name **isn't** arbitrary, and it should match the name of the package.
|
|
162
|
+
* @param options.entrypoint The entrypoint of the client renderer.
|
|
163
|
+
*/
|
|
164
|
+
addClientRenderer(options) {
|
|
165
|
+
const { entrypoint, name } = options;
|
|
166
|
+
const rendererIndex = this.#pipeline.manifest.renderers.findIndex((r) => r.name === name);
|
|
167
|
+
if (rendererIndex === -1) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
"You tried to add the " + name + " client renderer, but its server renderer wasn't added. You must add the server renderer first. Use the `addServerRenderer` function."
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const renderer = this.#pipeline.manifest.renderers[rendererIndex];
|
|
173
|
+
renderer.clientEntrypoint = entrypoint;
|
|
174
|
+
this.#pipeline.manifest.renderers[rendererIndex] = renderer;
|
|
175
|
+
}
|
|
140
176
|
// NOTE: we keep this private via TS instead via `#` so it's still available on the surface, so we can play with it.
|
|
141
177
|
// @ematipico: I plan to use it for a possible integration that could help people
|
|
142
178
|
static async createFromManifest(manifest) {
|
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.12.
|
|
22
|
+
const currentVersion = "4.12.1";
|
|
23
23
|
const isPrerelease = currentVersion.includes("-");
|
|
24
24
|
if (!isPrerelease) {
|
|
25
25
|
try {
|
package/dist/core/messages.js
CHANGED
|
@@ -37,7 +37,7 @@ function serverStart({
|
|
|
37
37
|
host,
|
|
38
38
|
base
|
|
39
39
|
}) {
|
|
40
|
-
const version = "4.12.
|
|
40
|
+
const version = "4.12.1";
|
|
41
41
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
42
42
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
43
43
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -269,7 +269,7 @@ function printHelp({
|
|
|
269
269
|
message.push(
|
|
270
270
|
linebreak(),
|
|
271
271
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
272
|
-
`v${"4.12.
|
|
272
|
+
`v${"4.12.1"}`
|
|
273
273
|
)} ${headline}`
|
|
274
274
|
);
|
|
275
275
|
}
|
|
@@ -31,6 +31,11 @@ class AstroDevToolbar extends HTMLElement {
|
|
|
31
31
|
z-index: 999999;
|
|
32
32
|
view-transition-name: astro-dev-toolbar;
|
|
33
33
|
display: contents;
|
|
34
|
+
|
|
35
|
+
/* Hide the dev toolbar on window.print() (CTRL + P) */
|
|
36
|
+
@media print {
|
|
37
|
+
display: none;
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
::view-transition-old(astro-dev-toolbar),
|
|
@@ -387,8 +387,11 @@ async function renderComponent(result, displayName, Component, props, slots = {}
|
|
|
387
387
|
handleCancellation
|
|
388
388
|
);
|
|
389
389
|
function handleCancellation(e) {
|
|
390
|
-
if (result.cancelled)
|
|
391
|
-
|
|
390
|
+
if (result.cancelled)
|
|
391
|
+
return {
|
|
392
|
+
render() {
|
|
393
|
+
}
|
|
394
|
+
};
|
|
392
395
|
throw e;
|
|
393
396
|
}
|
|
394
397
|
}
|