server-renderer.d.ts 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { VNode, ComponentInternalInstance, App, Slots, Component, ComponentPublicInstance, Directive } from 'vue';
  2. import { Readable, Writable } from 'node:stream';
  3. export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared';
  4. type SSRBuffer = SSRBufferItem[] & {
  5. hasAsync?: boolean;
  6. };
  7. type SSRBufferItem = string | SSRBuffer | Promise<SSRBuffer>;
  8. type PushFn = (item: SSRBufferItem) => void;
  9. type Props = Record<string, unknown>;
  10. export type SSRContext = {
  11. [key: string]: any;
  12. teleports?: Record<string, string>;
  13. };
  14. export declare function renderVNode(push: PushFn, vnode: VNode, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
  15. export declare function renderToString(input: App | VNode, context?: SSRContext): Promise<string>;
  16. export interface SimpleReadable {
  17. push(chunk: string | null): void;
  18. destroy(err: any): void;
  19. }
  20. export declare function renderToSimpleStream<T extends SimpleReadable>(input: App | VNode, context: SSRContext, stream: T): T;
  21. /**
  22. * @deprecated
  23. */
  24. export declare function renderToStream(input: App | VNode, context?: SSRContext): Readable;
  25. export declare function renderToNodeStream(input: App | VNode, context?: SSRContext): Readable;
  26. export declare function pipeToNodeWritable(input: App | VNode, context: SSRContext | undefined, writable: Writable): void;
  27. export declare function renderToWebStream(input: App | VNode, context?: SSRContext): ReadableStream;
  28. export declare function pipeToWebWritable(input: App | VNode, context: SSRContext | undefined, writable: WritableStream): void;
  29. type SSRSlots = Record<string, SSRSlot>;
  30. type SSRSlot = (props: Props, push: PushFn, parentComponent: ComponentInternalInstance | null, scopeId: string | null) => void;
  31. export declare function ssrRenderSlot(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
  32. export declare function ssrRenderSlotInner(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string, transition?: boolean): void;
  33. export declare function ssrRenderComponent(comp: Component, props?: Props | null, children?: Slots | SSRSlots | null, parentComponent?: ComponentInternalInstance | null, slotScopeId?: string): SSRBuffer | Promise<SSRBuffer>;
  34. export declare function ssrRenderTeleport(parentPush: PushFn, contentRenderFn: (push: PushFn) => void, target: string, disabled: boolean, parentComponent: ComponentInternalInstance): void;
  35. export declare function ssrRenderAttrs(props: Record<string, unknown>, tag?: string): string;
  36. export declare function ssrRenderDynamicAttr(key: string, value: unknown, tag?: string): string;
  37. export declare function ssrRenderAttr(key: string, value: unknown): string;
  38. export declare function ssrRenderClass(raw: unknown): string;
  39. export declare function ssrRenderStyle(raw: unknown): string;
  40. export declare function ssrInterpolate(value: unknown): string;
  41. export declare function ssrRenderList(source: unknown, renderItem: (value: unknown, key: string | number, index?: number) => void): void;
  42. export declare function ssrRenderSuspense(push: PushFn, { default: renderContent }: Record<string, (() => void) | undefined>): Promise<void>;
  43. export declare function ssrGetDirectiveProps(instance: ComponentPublicInstance, dir: Directive, value?: any, arg?: string, modifiers?: Record<string, boolean>): Record<string, any>;
  44. export declare const ssrLooseEqual: (a: unknown, b: unknown) => boolean;
  45. export declare function ssrLooseContain(arr: unknown[], value: unknown): boolean;
  46. export declare function ssrRenderDynamicModel(type: unknown, model: unknown, value: unknown): string;
  47. export declare function ssrGetDynamicModelProps(existingProps: any, model: unknown): {
  48. checked: true;
  49. } | {
  50. value: any;
  51. } | null;
  52. export { renderVNode as ssrRenderVNode };