Skip to content

Commit 4dc0d60

Browse files
committed
chore: expose SSRStreamWriter type
1 parent 4b3a4b2 commit 4dc0d60

File tree

7 files changed

+118
-12
lines changed

7 files changed

+118
-12
lines changed

packages/docs/src/routes/api/qwik/api.json

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@
21052105
}
21062106
],
21072107
"kind": "TypeAlias",
2108-
"content": "```typescript\nexport type SSRStreamChildren = AsyncGenerator<JSXChildren, void, any> | ((stream: StreamWriter) => Promise<void>) | (() => AsyncGenerator<JSXChildren, void, any>);\n```\n**References:** [JSXChildren](#jsxchildren)",
2108+
"content": "```typescript\nexport type SSRStreamChildren = AsyncGenerator<JSXChildren, void, any> | ((stream: SSRStreamWriter) => Promise<void>) | (() => AsyncGenerator<JSXChildren, void, any>);\n```\n**References:** [JSXChildren](#jsxchildren)<!-- -->, [SSRStreamWriter](#ssrstreamwriter)",
21092109
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/jsx/utils.public.ts",
21102110
"mdFile": "core.ssrstreamchildren.md"
21112111
},
@@ -2123,6 +2123,20 @@
21232123
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/jsx/utils.public.ts",
21242124
"mdFile": "core.ssrstreamprops.md"
21252125
},
2126+
{
2127+
"name": "SSRStreamWriter",
2128+
"id": "ssrstreamwriter",
2129+
"hierarchy": [
2130+
{
2131+
"name": "SSRStreamWriter",
2132+
"id": "ssrstreamwriter"
2133+
}
2134+
],
2135+
"kind": "Interface",
2136+
"content": "```typescript\nexport interface SSRStreamWriter \n```\n\n\n<table><thead><tr><th>\n\nMethod\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[write(chunk)](#ssrstreamwriter-write)\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>",
2137+
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/jsx/utils.public.ts",
2138+
"mdFile": "core.ssrstreamwriter.md"
2139+
},
21262140
{
21272141
"name": "SVGAttributes",
21282142
"id": "svgattributes",
@@ -2612,6 +2626,23 @@
26122626
"content": "Override the `getLocale` with `lang` within the `fn` execution.\n\n\n```typescript\nexport declare function withLocale<T>(locale: string, fn: () => T): T;\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nlocale\n\n\n</td><td>\n\nstring\n\n\n</td><td>\n\n\n</td></tr>\n<tr><td>\n\nfn\n\n\n</td><td>\n\n() =&gt; T\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n\n**Returns:**\n\nT",
26132627
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-locale.ts",
26142628
"mdFile": "core.withlocale.md"
2629+
},
2630+
{
2631+
"name": "write",
2632+
"id": "ssrstreamwriter-write",
2633+
"hierarchy": [
2634+
{
2635+
"name": "SSRStreamWriter",
2636+
"id": "ssrstreamwriter-write"
2637+
},
2638+
{
2639+
"name": "write",
2640+
"id": "ssrstreamwriter-write"
2641+
}
2642+
],
2643+
"kind": "MethodSignature",
2644+
"content": "```typescript\nwrite(chunk: JSXOutput): void;\n```\n\n\n<table><thead><tr><th>\n\nParameter\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\nchunk\n\n\n</td><td>\n\n[JSXOutput](#jsxoutput)\n\n\n</td><td>\n\n\n</td></tr>\n</tbody></table>\n\n**Returns:**\n\nvoid",
2645+
"mdFile": "core.ssrstreamwriter.write.md"
26152646
}
26162647
]
26172648
}

packages/docs/src/routes/api/qwik/index.mdx

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,11 +4500,11 @@ SSRStreamBlock: FunctionComponent<{
45004500
```typescript
45014501
export type SSRStreamChildren =
45024502
| AsyncGenerator<JSXChildren, void, any>
4503-
| ((stream: StreamWriter) => Promise<void>)
4503+
| ((stream: SSRStreamWriter) => Promise<void>)
45044504
| (() => AsyncGenerator<JSXChildren, void, any>);
45054505
```
45064506
4507-
**References:** [JSXChildren](#jsxchildren)
4507+
**References:** [JSXChildren](#jsxchildren), [SSRStreamWriter](#ssrstreamwriter)
45084508
45094509
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/jsx/utils.public.ts)
45104510
@@ -4520,6 +4520,32 @@ export type SSRStreamProps = {
45204520
45214521
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/jsx/utils.public.ts)
45224522
4523+
## SSRStreamWriter
4524+
4525+
```typescript
4526+
export interface SSRStreamWriter
4527+
```
4528+
4529+
<table><thead><tr><th>
4530+
4531+
Method
4532+
4533+
</th><th>
4534+
4535+
Description
4536+
4537+
</th></tr></thead>
4538+
<tbody><tr><td>
4539+
4540+
[write(chunk)](#ssrstreamwriter-write)
4541+
4542+
</td><td>
4543+
4544+
</td></tr>
4545+
</tbody></table>
4546+
4547+
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/jsx/utils.public.ts)
4548+
45234549
## SVGAttributes
45244550
45254551
The TS types don't include the SVG attributes so we have to define them ourselves
@@ -9919,3 +9945,39 @@ fn
99199945
T
99209946
99219947
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/use/use-locale.ts)
9948+
9949+
## write
9950+
9951+
```typescript
9952+
write(chunk: JSXOutput): void;
9953+
```
9954+
9955+
<table><thead><tr><th>
9956+
9957+
Parameter
9958+
9959+
</th><th>
9960+
9961+
Type
9962+
9963+
</th><th>
9964+
9965+
Description
9966+
9967+
</th></tr></thead>
9968+
<tbody><tr><td>
9969+
9970+
chunk
9971+
9972+
</td><td>
9973+
9974+
[JSXOutput](#jsxoutput)
9975+
9976+
</td><td>
9977+
9978+
</td></tr>
9979+
</tbody></table>
9980+
9981+
**Returns:**
9982+
9983+
void

packages/qwik/src/core/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ export {
6161
SSRComment,
6262
SkipRender,
6363
} from './shared/jsx/utils.public';
64-
export type { SSRStreamProps, SSRHintProps, SSRStreamChildren } from './shared/jsx/utils.public';
64+
export type {
65+
SSRStreamProps,
66+
SSRHintProps,
67+
SSRStreamChildren,
68+
SSRStreamWriter,
69+
} from './shared/jsx/utils.public';
6570
export { Slot } from './shared/jsx/slot.public';
6671
export {
6772
Fragment,

packages/qwik/src/core/qwik.core.api.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,16 +1075,20 @@ export const SSRStreamBlock: FunctionComponent<{
10751075
children?: JSXOutput;
10761076
}>;
10771077

1078-
// Warning: (ae-incompatible-release-tags) The symbol "SSRStreamChildren" is marked as @public, but its signature references "StreamWriter" which is marked as @internal
1079-
//
10801078
// @public (undocumented)
1081-
export type SSRStreamChildren = AsyncGenerator<JSXChildren, void, any> | ((stream: StreamWriter) => Promise<void>) | (() => AsyncGenerator<JSXChildren, void, any>);
1079+
export type SSRStreamChildren = AsyncGenerator<JSXChildren, void, any> | ((stream: SSRStreamWriter) => Promise<void>) | (() => AsyncGenerator<JSXChildren, void, any>);
10821080

10831081
// @public (undocumented)
10841082
export type SSRStreamProps = {
10851083
children: SSRStreamChildren;
10861084
};
10871085

1086+
// @public (undocumented)
1087+
export interface SSRStreamWriter {
1088+
// (undocumented)
1089+
write(chunk: JSXOutput): void;
1090+
}
1091+
10881092
// Warning: (ae-internal-missing-underscore) The name "StreamWriter" should be prefixed with an underscore because the declaration is marked as @internal
10891093
//
10901094
// @internal (undocumented)

packages/qwik/src/core/shared/jsx/utils.public.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { STREAM_BLOCK_END_COMMENT, STREAM_BLOCK_START_COMMENT } from '../utils/markers';
2-
import type { StreamWriter } from '../../ssr/ssr-types';
32
import { jsx, RenderOnce } from './jsx-runtime';
43
import type { FunctionComponent, JSXNode, JSXOutput } from './types/jsx-node';
54
import type { JSXChildren } from './types/jsx-qwik-attributes';
@@ -27,10 +26,15 @@ export type SSRStreamProps = {
2726
children: SSRStreamChildren;
2827
};
2928

29+
/** @public */
30+
export interface SSRStreamWriter {
31+
write(chunk: JSXOutput): void;
32+
}
33+
3034
/** @public */
3135
export type SSRStreamChildren =
3236
| AsyncGenerator<JSXChildren, void, any>
33-
| ((stream: StreamWriter) => Promise<void>)
37+
| ((stream: SSRStreamWriter) => Promise<void>)
3438
| (() => AsyncGenerator<JSXChildren, void, any>);
3539

3640
/** @public */

packages/qwik/src/core/ssr/ssr-render-jsx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function processJSXNode(
248248
if (isFunction(generator)) {
249249
value = generator({
250250
async write(chunk) {
251-
await _walkJSX(ssr, chunk as JSXOutput, {
251+
await _walkJSX(ssr, chunk, {
252252
currentStyleScoped: options.styleScoped,
253253
parentComponentFrame: options.parentComponentFrame,
254254
});

packages/qwik/src/core/tests/ssr-render.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Slot, useSignal } from '@qwik.dev/core';
1+
import { Slot, useSignal, SSRStreamWriter } from '@qwik.dev/core';
22
import { ssrRenderToDom, trigger } from '@qwik.dev/core/testing';
33
import { describe, expect, it } from 'vitest';
44
import { component$ } from '../shared/component.public';
@@ -245,7 +245,7 @@ describe('v2 ssr render', () => {
245245
const { vNode } = await ssrRenderToDom(
246246
<ul>
247247
<SSRStream>
248-
{async function (stream: any) {
248+
{async function (stream: SSRStreamWriter) {
249249
for (let i = 0; i < 5; i++) {
250250
stream.write(<SSRRaw data={`<li>raw: ${i}</li>`} />);
251251
await delay(10);

0 commit comments

Comments
 (0)