Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBoyle committed Dec 28, 2024
1 parent 2521e40 commit d14ad90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/jsx-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,19 @@ export const jsx = <
return rawResult as Awaited<TOutput>;
}
// Outside streaming context, resolve the value
return (await rawResult.value) as Awaited<TOutput>;
return await rawResult.value;
}

if (isInStreamingContext()) {
// In streaming context, pass the streamable to children function
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-function-type
const childrenResult = await (children as Function)(rawResult);
const resolvedResult = await resolveDeep(childrenResult);
return resolvedResult as Awaited<TOutput>;
} else {
// Outside streaming context, resolve the value first
const resolvedValue = await rawResult.value;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-function-type
const childrenResult = await (children as Function)(
resolvedValue as TOutput,
);
Expand Down
5 changes: 5 additions & 0 deletions src/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,29 @@ export async function execute<T>(element: ExecutableValue): Promise<T> {
if (element.props.children) {
// With children, let them handle the streamable
const childrenResult = await element.props.children(componentResult);
// eslint-disable-next-line @typescript-eslint/return-await
return execute(childrenResult as ExecutableValue);
}
// No children, preserve the streamable
// eslint-disable-next-line @typescript-eslint/return-await
return componentResult as T;
}

// Handle non-streaming cases
if (element.props.children) {
const resolvedResult = await resolveDeep(componentResult);
const childrenResult = await element.props.children(resolvedResult);
// eslint-disable-next-line @typescript-eslint/return-await
return execute(childrenResult as ExecutableValue);
}

// No children, resolve the result
// eslint-disable-next-line @typescript-eslint/return-await
return resolveDeep(componentResult);
}

// For all other cases, use the shared resolver
// eslint-disable-next-line @typescript-eslint/return-await
return resolveDeep(element);
} finally {
// Only restore streaming context if it changed during execution
Expand Down
3 changes: 2 additions & 1 deletion src/stream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Element, StreamComponent, Streamable } from "./types";
import type { Element, Streamable, StreamComponent } from "./types";

import { execute } from "./resolve";

Expand All @@ -25,6 +25,7 @@ export function isStreamComponent(
export async function Stream<T>(props: {
children: Element;
}): Promise<T | Streamable<T>> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const prevIsStreaming = isInStreamingContext();
setStreamingContext(true);

Expand Down

0 comments on commit d14ad90

Please sign in to comment.