diff --git a/.changeset/sixty-fireants-beg.md b/.changeset/sixty-fireants-beg.md new file mode 100644 index 00000000..5182774f --- /dev/null +++ b/.changeset/sixty-fireants-beg.md @@ -0,0 +1,5 @@ +--- +'@lightmill/react-experiment': patch +--- + +Fix Run props type regression introduced in 6ee33d3d21882c2e6d8cc12ec0cfda5506fce46a. diff --git a/packages/react-experiment/src/run.tsx b/packages/react-experiment/src/run.tsx index d25c6796..ec6cc8d2 100644 --- a/packages/react-experiment/src/run.tsx +++ b/packages/react-experiment/src/run.tsx @@ -1,9 +1,8 @@ import * as React from 'react'; -import { ReadonlyDeep } from 'type-fest'; import { RegisteredTask, Typed, RegisteredLog } from './config.js'; import { loggerContext, noLoggerSymbol, timelineContext } from './contexts.js'; import useManagedTimeline, { - Timeline, + AnyIteratorOrIterable, TimelineState, } from './useManagedTimeline.js'; @@ -16,7 +15,7 @@ export type RunElements = { export type Logger = (log: Log) => Promise; export type RunProps = { - elements: Readonly>; + elements: RunElements; confirmBeforeUnload?: boolean; } & UseRunParameter; @@ -75,13 +74,13 @@ type UseRunParameter = { onLog?: Logger; resumeAfter?: { type: Task['type']; number: number }; } & ( - | { timeline: ReadonlyDeep>; loading?: boolean } - | { timeline?: ReadonlyDeep> | null; loading: true } + | { timeline: AnyIteratorOrIterable; loading?: boolean } + | { timeline?: AnyIteratorOrIterable | null; loading: true } ); type RunState = Exclude, { status: 'error' }> & { onLog: ((newLog: Log) => void) | null; }; -function useRun({ +function useRun({ onCompleted, timeline, resumeAfter, diff --git a/packages/react-experiment/src/useManagedTimeline.ts b/packages/react-experiment/src/useManagedTimeline.ts index 6820aa47..dde9d551 100644 --- a/packages/react-experiment/src/useManagedTimeline.ts +++ b/packages/react-experiment/src/useManagedTimeline.ts @@ -11,11 +11,11 @@ export type TimelineState = | { status: 'error'; error: Error } | { status: 'running'; task: Task; onTaskCompleted: () => void }; -export type AsyncTimeline = AsyncIterator | AsyncIterable; - -export type SyncTimeline = Iterator | Iterable; - -export type Timeline = AsyncTimeline | SyncTimeline; +export type AnyIteratorOrIterable = + | AsyncIterator + | AsyncIterable + | Iterator + | Iterable; type Options = { onTimelineCompleted?: () => void; @@ -23,7 +23,7 @@ type Options = { onTaskStarted?: (task: Task) => void; onTaskCompleted?: (task: Task) => void; onTaskLoadingError?: (error: unknown) => void; - timeline?: Timeline | null; + timeline?: AnyIteratorOrIterable | null; resumeAfter?: { type: Task['type']; number: number }; };