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 5c92e2c commit ecb0014
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
7. Support parallel execution of steps (either dynamic via something liek a collector, or static via a few explicitly defined siblings)
*/

import { jsx, jsxs, Fragment } from "./jsx-runtime";
import { Component, StreamComponent } from "./component";
import { Stream } from "./stream";
import { Fragment, jsx, jsxs } from "./jsx-runtime";
import { execute } from "./resolve";
import { Stream } from "./stream";
import { Element, ExecutableValue, Streamable } from "./types";

// Collect component props
Expand Down
6 changes: 2 additions & 4 deletions src/jsx-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/no-namespace */
import type { Streamable } from "./types";

import { getCurrentContext } from "./context";
import { resolveDeep } from "./resolve";
import { isInStreamingContext } from "./stream";
import { getCurrentContext } from "./context";

export namespace JSX {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -61,8 +61,6 @@ export const jsx = <

// Return a promise that will be handled by execute()
return (async (): Promise<Awaited<TOutput> | Awaited<TOutput>[]> => {
const parentContext = getCurrentContext();

// Execute component
const rawResult = await component(props ?? ({} as TProps));
const currentContext = getCurrentContext();
Expand Down Expand Up @@ -111,7 +109,7 @@ export const jsx = <
return result as Awaited<TOutput>;
}
// Outside streaming context, resolve the value
return (await result.value) as Awaited<TOutput>;
return await result.value;
}

// If there are no function children, return the resolved result
Expand Down
3 changes: 2 additions & 1 deletion src/parallel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Element } from "./types";
import { execute } from "./resolve";

import { getCurrentContext } from "./context";
import { execute } from "./resolve";

export async function Parallel<T>(props: {
children: Element[] | Element;
Expand Down
6 changes: 4 additions & 2 deletions src/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type {
WorkflowComponent,
} from "./types";

import { ExecutionContext, getCurrentContext } from "./context";
import { JSX } from "./jsx-runtime";
import { isInStreamingContext } from "./stream";
import { ExecutionContext, getCurrentContext } from "./context";

type ComponentType<P, O> = WorkflowComponent<P, O> | StreamComponent<P, O>;

Expand Down Expand Up @@ -53,6 +53,7 @@ export async function resolveDeep<T>(value: unknown): Promise<T> {

// Handle promises first
if (value instanceof Promise) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const resolved = await value;
return resolveDeep(resolved);
}
Expand Down Expand Up @@ -123,12 +124,13 @@ export async function execute<T>(
element: ExecutableValue,
context?: ExecutionContext,
): Promise<T> {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (element === null || element === undefined) {
throw new Error("Cannot execute null or undefined element");
}

// Use provided context or current context
const executionContext = context || getCurrentContext();
const executionContext = context ?? getCurrentContext();
const wasInStreamingContext = isInStreamingContext();

try {
Expand Down
2 changes: 1 addition & 1 deletion src/stream.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Element, Streamable, StreamComponent } from "./types";

import { execute } from "./resolve";
import { getCurrentContext, withContext } from "./context";
import { execute } from "./resolve";

// Helper to check if a component is a stream component
export function isStreamComponent(
Expand Down

0 comments on commit ecb0014

Please sign in to comment.