summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Emanuele Stoppa <ematipico@users.noreply.github.com> 2024-06-13 13:05:54 +0000
committerGravatar astrobot-houston <fred+astrobot@astro.build> 2024-06-13 13:05:54 +0000
commita6df7e877f5e485b7f86dd026547e6f58a189edc (patch)
tree886e561f8c142024179b588403d715b5e9ad38b7
parent4385bf7a4dc9c65bff53a30c660f7a909fcabfc9 (diff)
downloadastro-a6df7e877f5e485b7f86dd026547e6f58a189edc.tar.gz
astro-a6df7e877f5e485b7f86dd026547e6f58a189edc.tar.zst
astro-a6df7e877f5e485b7f86dd026547e6f58a189edc.zip
[ci] format
-rw-r--r--examples/container-with-vitest/test/ReactWrapper.test.ts2
-rw-r--r--packages/astro/src/@types/astro.ts4
-rw-r--r--packages/astro/src/container/index.ts31
-rw-r--r--packages/astro/test/container.test.js25
-rw-r--r--packages/integrations/react/server.js1
-rw-r--r--packages/integrations/react/src/index.ts6
-rw-r--r--packages/integrations/react/tsconfig.json2
7 files changed, 36 insertions, 35 deletions
diff --git a/examples/container-with-vitest/test/ReactWrapper.test.ts b/examples/container-with-vitest/test/ReactWrapper.test.ts
index 099e0c8a3..6adbff6cf 100644
--- a/examples/container-with-vitest/test/ReactWrapper.test.ts
+++ b/examples/container-with-vitest/test/ReactWrapper.test.ts
@@ -6,7 +6,7 @@ import ReactWrapper from '../src/components/ReactWrapper.astro';
const renderers = await loadRenderers([getContainerRenderer()]);
const container = await AstroContainer.create({
- renderers
+ renderers,
});
test('ReactWrapper with react renderer', async () => {
diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts
index 69c8f9368..1fbb1c4dc 100644
--- a/packages/astro/src/@types/astro.ts
+++ b/packages/astro/src/@types/astro.ts
@@ -2977,7 +2977,7 @@ export interface AstroRenderer {
jsxTransformOptions?: JSXTransformFn;
}
-export type SSRLoadedRendererValue = {
+export type SSRLoadedRendererValue = {
check: AsyncRendererComponentFn<boolean>;
renderToStaticMarkup: AsyncRendererComponentFn<{
html: string;
@@ -2996,7 +2996,7 @@ export type SSRLoadedRendererValue = {
* page-level data structure.
*/
renderHydrationScript?: () => string;
-}
+};
export interface SSRLoadedRenderer extends Pick<AstroRenderer, 'name' | 'clientEntrypoint'> {
ssr: SSRLoadedRendererValue;
diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts
index 47fac93a9..452f97738 100644
--- a/packages/astro/src/container/index.ts
+++ b/packages/astro/src/container/index.ts
@@ -8,7 +8,8 @@ import type {
Props,
RouteData,
RouteType,
- SSRLoadedRenderer, SSRLoadedRendererValue,
+ SSRLoadedRenderer,
+ SSRLoadedRendererValue,
SSRManifest,
SSRResult,
} from '../@types/astro.js';
@@ -270,34 +271,36 @@ export class experimental_AstroContainer {
/**
* Use this function to manually add a renderer to the container.
- *
- * This function is preferred when you require to use the container with a renderer in environments such as on-demand pages.
- *
+ *
+ * This function is preferred when you require to use the container with a renderer in environments such as on-demand pages.
+ *
* ## Example
- *
+ *
* ```js
* import reactRenderer from "@astrojs/react/server.js";
* import vueRenderer from "@astrojs/vue/server.js";
* import { experimental_AstroContainer as AstroContainer } from "astro/container"
- *
+ *
* const container = await AstroContainer.create();
* container.addServerRenderer("@astrojs/react", reactRenderer);
* container.addServerRenderer("@astrojs/vue", vueRenderer);
* ```
- *
- * @param name The name of the renderer. The name **isn't** arbitrary, and it should match the name of the package.
- * @param renderer The server renderer exported by integration.
+ *
+ * @param name The name of the renderer. The name **isn't** arbitrary, and it should match the name of the package.
+ * @param renderer The server renderer exported by integration.
*/
public addServerRenderer(name: string, renderer: SSRLoadedRendererValue) {
if (!renderer.check || !renderer.renderToStaticMarkup) {
- throw new Error("The renderer you passed isn't valid. A renderer is usually an object that exposes the `check` and `renderToStaticMarkup` functions.\n" +
- "Usually, the renderer is exported by a /server.js entrypoint e.g. `import renderer from '@astrojs/react/server.js'`")
+ throw new Error(
+ "The renderer you passed isn't valid. A renderer is usually an object that exposes the `check` and `renderToStaticMarkup` functions.\n" +
+ "Usually, the renderer is exported by a /server.js entrypoint e.g. `import renderer from '@astrojs/react/server.js'`"
+ );
}
-
+
this.#pipeline.manifest.renderers.push({
name,
- ssr: renderer
- })
+ ssr: renderer,
+ });
}
// NOTE: we keep this private via TS instead via `#` so it's still available on the surface, so we can play with it.
diff --git a/packages/astro/test/container.test.js b/packages/astro/test/container.test.js
index 7f873fb19..dd17cc565 100644
--- a/packages/astro/test/container.test.js
+++ b/packages/astro/test/container.test.js
@@ -1,5 +1,5 @@
import assert from 'node:assert/strict';
-import { describe, it, before } from 'node:test';
+import { before, describe, it } from 'node:test';
import { experimental_AstroContainer } from '../dist/container/index.js';
import {
Fragment,
@@ -12,8 +12,8 @@ import {
renderSlot,
renderTemplate,
} from '../dist/runtime/server/index.js';
-import {loadFixture} from "./test-utils.js";
-import testAdapter from "./test-adapter.js";
+import testAdapter from './test-adapter.js';
+import { loadFixture } from './test-utils.js';
const BaseLayout = createComponent((result, _props, slots) => {
return render`<html>
@@ -234,24 +234,23 @@ describe('Container', () => {
});
describe('Container with renderers', () => {
- let fixture
+ let fixture;
let app;
before(async () => {
fixture = await loadFixture({
root: new URL('./fixtures/container-react/', import.meta.url),
- output: "server",
- adapter: testAdapter()
+ output: 'server',
+ adapter: testAdapter(),
});
await fixture.build();
app = await fixture.loadTestAdapterApp();
});
- it("the endpoint should return the HTML of the React component", async () => {
- const request = new Request("https://example.com/api");
- const response = await app.render(request)
- const html = await response.text()
+ it('the endpoint should return the HTML of the React component', async () => {
+ const request = new Request('https://example.com/api');
+ const response = await app.render(request);
+ const html = await response.text();
- assert.match(html, /I am a react button/)
- })
+ assert.match(html, /I am a react button/);
+ });
});
-
diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js
index efdd72102..c2b255853 100644
--- a/packages/integrations/react/server.js
+++ b/packages/integrations/react/server.js
@@ -230,4 +230,3 @@ export default {
renderToStaticMarkup,
supportsAstroStaticSlot: true,
};
-
diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts
index c20146949..f8a9c4ab2 100644
--- a/packages/integrations/react/src/index.ts
+++ b/packages/integrations/react/src/index.ts
@@ -1,12 +1,12 @@
import react, { type Options as ViteReactPluginOptions } from '@vitejs/plugin-react';
-import type {AstroIntegration, ContainerRenderer} from 'astro';
+import type { AstroIntegration, ContainerRenderer } from 'astro';
import type * as vite from 'vite';
import {
+ type ReactVersionConfig,
+ type SupportedReactVersion,
getReactMajorVersion,
isUnsupportedVersion,
versionsConfig,
- type ReactVersionConfig,
- type SupportedReactVersion,
} from './version.js';
export type ReactIntegrationOptions = Pick<
diff --git a/packages/integrations/react/tsconfig.json b/packages/integrations/react/tsconfig.json
index 3d1121296..1504b4b6d 100644
--- a/packages/integrations/react/tsconfig.json
+++ b/packages/integrations/react/tsconfig.json
@@ -3,5 +3,5 @@
"include": ["src"],
"compilerOptions": {
"outDir": "./dist"
- },
+ }
}