astro 4.9.1 → 4.9.2

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.
@@ -1,4 +1,4 @@
1
- import type { AstroRenderer, AstroUserConfig, RouteType } from '../@types/astro.js';
1
+ import type { AstroRenderer, AstroUserConfig, Props, RouteType } from '../@types/astro.js';
2
2
  import type { AstroComponentFactory } from '../runtime/server/index.js';
3
3
  /**
4
4
  * Options to be passed when rendering a route
@@ -50,6 +50,14 @@ export type ContainerRenderOptions = {
50
50
  * ```
51
51
  */
52
52
  routeType?: RouteType;
53
+ /**
54
+ * Allows to pass `Astro.props` to an Astro component:
55
+ *
56
+ * ```js
57
+ * container.renderToString(Endpoint, { props: { "lorem": "ipsum" } });
58
+ * ```
59
+ */
60
+ props?: Props;
53
61
  };
54
62
  export type AstroContainerUserConfig = Omit<AstroUserConfig, 'integrations' | 'adapter'>;
55
63
  /**
@@ -185,6 +185,9 @@ class experimental_AstroContainer {
185
185
  if (options.params) {
186
186
  renderContext.params = options.params;
187
187
  }
188
+ if (options.props) {
189
+ renderContext.props = options.props;
190
+ }
188
191
  return renderContext.render(componentInstance, slots);
189
192
  }
190
193
  #createRoute(url, params, type) {
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.9.1";
1
+ const ASTRO_VERSION = "4.9.2";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404";
@@ -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.9.1";
22
+ const currentVersion = "4.9.2";
23
23
  const isPrerelease = currentVersion.includes("-");
24
24
  if (!isPrerelease) {
25
25
  try {
@@ -37,7 +37,7 @@ function serverStart({
37
37
  host,
38
38
  base
39
39
  }) {
40
- const version = "4.9.1";
40
+ const version = "4.9.2";
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.9.1"}`
272
+ `v${"4.9.2"}`
273
273
  )} ${headline}`
274
274
  );
275
275
  }
@@ -1,4 +1,4 @@
1
- import type { APIContext, AstroGlobal, AstroGlobalPartial, ComponentInstance, MiddlewareHandler, RouteData, SSRResult } from '../@types/astro.js';
1
+ import type { APIContext, AstroGlobal, AstroGlobalPartial, ComponentInstance, MiddlewareHandler, Props, RouteData, SSRResult } from '../@types/astro.js';
2
2
  import type { ActionAPIContext } from '../actions/runtime/store.js';
3
3
  import { AstroCookies } from './cookies/index.js';
4
4
  import { type Pipeline } from './render/index.js';
@@ -18,6 +18,7 @@ export declare class RenderContext {
18
18
  protected cookies: AstroCookies;
19
19
  params: import("../@types/astro.js").Params;
20
20
  protected url: URL;
21
+ props: Props;
21
22
  private constructor();
22
23
  /**
23
24
  * A flag that tells the render content if the rewriting was triggered
@@ -21,7 +21,7 @@ import { sequence } from "./middleware/index.js";
21
21
  import { renderRedirect } from "./redirects/render.js";
22
22
  import { Slots, getParams, getProps } from "./render/index.js";
23
23
  class RenderContext {
24
- constructor(pipeline, locals, middleware, pathname, request, routeData, status, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url)) {
24
+ constructor(pipeline, locals, middleware, pathname, request, routeData, status, cookies = new AstroCookies(request), params = getParams(routeData, pathname), url = new URL(request.url), props = {}) {
25
25
  this.pipeline = pipeline;
26
26
  this.locals = locals;
27
27
  this.middleware = middleware;
@@ -32,6 +32,7 @@ class RenderContext {
32
32
  this.cookies = cookies;
33
33
  this.params = params;
34
34
  this.url = url;
35
+ this.props = props;
35
36
  }
36
37
  /**
37
38
  * A flag that tells the render content if the rewriting was triggered
@@ -74,7 +75,7 @@ class RenderContext {
74
75
  async render(componentInstance, slots = {}) {
75
76
  const { cookies, middleware, pathname, pipeline } = this;
76
77
  const { logger, routeCache, serverLike, streaming } = pipeline;
77
- const props = await getProps({
78
+ const props = Object.keys(this.props).length > 0 ? this.props : await getProps({
78
79
  mod: componentInstance,
79
80
  routeData: this.routeData,
80
81
  routeCache,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.9.1",
3
+ "version": "4.9.2",
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",