pull/16748/head
S. Elliott Johnson 11 months ago
parent b64b0956cf
commit 9ddf6e63a5

@ -15,6 +15,7 @@ packages/svelte/src/internal/client/warnings.js
packages/svelte/src/internal/shared/errors.js packages/svelte/src/internal/shared/errors.js
packages/svelte/src/internal/shared/warnings.js packages/svelte/src/internal/shared/warnings.js
packages/svelte/src/internal/server/errors.js packages/svelte/src/internal/server/errors.js
packages/svelte/src/internal/server/warnings.js
packages/svelte/tests/migrate/samples/*/output.svelte packages/svelte/tests/migrate/samples/*/output.svelte
packages/svelte/tests/**/*.svelte packages/svelte/tests/**/*.svelte
packages/svelte/tests/**/_expected* packages/svelte/tests/**/_expected*

@ -1,6 +1,6 @@
/** @import { SvelteComponent } from '../index.js' */ /** @import { SvelteComponent } from '../index.js' */
import { asClassComponent as as_class_component, createClassComponent } from './legacy-client.js'; import { asClassComponent as as_class_component, createClassComponent } from './legacy-client.js';
import { render, render_async } from '../internal/server/index.js'; import { render } from '../internal/server/index.js';
// By having this as a separate entry point for server environments, we save the client bundle from having to include the server runtime // By having this as a separate entry point for server environments, we save the client bundle from having to include the server runtime
@ -31,21 +31,9 @@ export function asClassComponent(component) {
html: result.body html: result.body
}; };
}; };
/** @type {(props?: {}, opts?: { $$slots?: {}; context?: Map<any, any>; }) => Promise<{ html: any; css: { code: string; map: any; }; head: string; }> } */
const _render_async = async (props, { context } = {}) => {
// @ts-expect-error the typings are off, but this will work if the component is compiled in SSR mode
const result = await render_async(component, { props, context });
return {
css: { code: '', map: null },
head: result.head,
html: result.body
};
};
// @ts-expect-error this is present for SSR // @ts-expect-error this is present for SSR
component_constructor.render = _render; component_constructor.render = _render;
// @ts-expect-error this is present for SSR
component_constructor.renderAsync = _render_async;
// @ts-ignore // @ts-ignore
return component_constructor; return component_constructor;

@ -2502,12 +2502,13 @@ declare module 'svelte/server' {
body: string; body: string;
} }
interface RenderOutput extends SyncRenderOutput { type RenderOutput = SyncRenderOutput & Thenable<SyncRenderOutput>;
/** Render the component asynchronously by `await`ing or calling `then` on the result of `render`. */
then: ( interface Thenable<T> {
onfulfilled: (value: SyncRenderOutput) => void, then<TResult1 = T, TResult2 = never>(
onrejected: (reason: unknown) => void onfulfilled?: ((value: T) => TResult1 | Thenable<TResult1>) | undefined | null,
) => void; onrejected?: ((reason: any) => TResult2 | Thenable<TResult2>) | undefined | null
): Thenable<TResult1 | TResult2>;
} }
export {}; export {};

Loading…
Cancel
Save