import type { Dispatch, ReactNode, SetStateAction } from 'react'; import type { WorkflowAction, WorkflowEditing } from '../editing.js'; import type { WorkflowEngine } from '../engine.js'; import type { RunLink } from '../graph/types.js'; import { type UIStringOverrides } from './strings.js'; export { useLocale } from './locale.js'; export { type ErrorPageKind, mergeStrings, type UIStringOverrides, type UIStrings, useStrings, } from './strings.js'; export interface UINavigation { goTo: (to: string) => void; /** Opens the source of a step that runs another workflow, named by its `uses`; * `sourceUrl` is a page the server resolved for it, when there is one. */ openStepSource: (uses: string, sourceUrl?: string) => void; openExternal: (href: string) => void; /** Goes back one entry in the history, such as an error page's "Back". Bind it * to the router's history; the browser's by default. */ goBack: () => void; /** Whether there is an entry of this app's to go back to; when there isn't, an * error page offers the way home instead. Bind it to the router's own * answer; by default, whether the tab's history holds more than this page. */ canGoBack: () => boolean; } export type WorkflowJsonRef = { kind: 'marketplace'; slug: string; version: string; } | { kind: 'workflow'; name: string; }; export interface RunFileResult { data: string | undefined; isLoading: boolean; error: unknown; } export type PersistedStateHook = (key: string, defaultValue: T) => [T, Dispatch>]; /** The values a problem's message shows, by name, as a problem's `params` carries them. */ export type ProblemParams = Readonly>; /** A problem code's message in the reader's language, with its params; undefined when the host has * none for the code. `type` is the problem's type URI: one that names an application, such as * `/problems/workflow/undefined_input`, picks that application's message for the code over the * host's own. */ export type ProblemMessage = (code: string, params?: ProblemParams, type?: string) => string | undefined; /** A problem that may carry a code: a run's warning, or one the workflow editor marks. */ export interface CodedProblem { /** Its text as the server wrote it, shown when the host has no message for its code. */ message: string; code?: string | null | undefined; params?: ProblemParams | null | undefined; /** Its type URI, which the host's message for its code is looked up by too. */ type?: string | null | undefined; } export interface UIData { /** * Host-bound hook resolving a file in a run's artifact tree (logs, scripts). * A null path skips fetching; refreshInterval polls while set. Must be a * stable function reference — components call it as a hook. */ useRunFile: (slug: string, path: string | null, options?: { refreshInterval?: number; }) => RunFileResult; resolveWorkflowJson?: (ref: WorkflowJsonRef) => Promise; /** The names of the reader's own saved inputs for a workflow, which a step can name too. */ resolveSavedInputs?: (ref: WorkflowJsonRef) => Promise; /** The built-in actions a workflow step can use, for the editor's step form. */ workflowActions?: Record; resolveSecretVariables?: () => Promise; /** Repository files, so the editor can read the workflow a step's repository `uses` names. */ repoSuggestions?: { file: (repo: string, ref: string, path: string) => Promise; }; /** * Provisions browser-access CORS rules on a storage. Absent, the storage * explorer hides its "add CORS rules" affordance. */ provisionCorsRules?: (args: { csp: string; type?: string | undefined; username: string; storageName: string; }) => Promise<{ error?: string; }>; usePersistedState: PersistedStateHook; /** * Host-bound hook returning a problem code's message in the reader's language, such as * `useCodeMessage` from `@parallelworks/problem/react`. A run's warnings and the editor's * problems that carry a `code` show it, given their `params` and `type`, and their own `message` * when it gives nothing. Absent, they show their `message`. Must be a stable function reference — * components call it as a hook. */ useProblemMessage: () => ProblemMessage; } import type { FieldComponent } from '../form/fieldRegistry.js'; import type { Breadcrumb } from './Breadcrumbs.js'; /** An internal navigation link, which hosts bind to their router's Link. Its * `href` is a full in-app URL that may carry a search and a hash, such as * `/runs/42?tab=logs#step-3`, and the host routes all of it client-side on a * plain click, leaving modified and middle clicks to the browser. It passes * every other prop, ref included, to its anchor, so menus and tooltips can * attach to it. Components render it through `AppLink`, which sanitizes the * href and keeps full page loads and other origins off the router. */ export type UILinkComponent = React.ComponentType & { href: string; }>; /** The provider's link slot, with a plain anchor fallback. */ export declare function useLink(): UILinkComponent; export interface UISlots { /** Internal navigation links; absent falls back to a plain anchor. */ link?: UILinkComponent; /** * Host-supplied form field components, merged over the form engine's core * registry by field type. Lazy components are supported — the registry * renders fields inside a Suspense boundary. */ formFields?: Record; /** Links and sessions block for a run's sidebar; absent hides the section. */ runSessions?: (args: { runId: string; runNumber: number; runActive: boolean; links?: Record | undefined; }) => ReactNode; /** Rich read-only YAML viewer; absent falls back to a plain
. */
    yamlViewer?: (args: {
        value: string;
        height: number;
        width: number;
        contentKey: string;
    }) => ReactNode;
    /** Icon for a subworkflow step; absent hides icon-bound affordances. */
    workflowIcon?: (args: {
        image?: string | undefined;
        type?: string | undefined;
        className?: string;
    }) => ReactNode;
    /** Icon URL for a storage type; absent falls back to a generic disk icon.
     * Scheme-dependent variants are the host's concern — bind with the host's
     * own theme state. */
    storageIconUrl?: (args: {
        type: string;
    }) => string | undefined;
    /**
     * The storage explorer's access-management drawer; absent hides the
     * affordance. `storage` and `groups` are the host's own objects passed back
     * through the explorer opaquely.
     */
    accessDrawer?: (args: {
        open: boolean;
        setOpen: (open: boolean) => void;
        storage: unknown;
        groups?: unknown;
    }) => ReactNode;
    /** Pin affordance rendered after the page header's crumb trail; absent hides it. */
    breadcrumbPin?: (args: {
        crumbs: readonly Breadcrumb[];
    }) => ReactNode;
    /** Control rendered at the start of the page header row, before the crumb
     * trail — the host's app-nav toggle. Absent hides it. */
    navToggle?: () => ReactNode;
}
/** An engine, or a loader so the host can keep the engine out of its first-load bundle. */
export type WorkflowEngineSource = WorkflowEngine | (() => Promise);
/** How avatars without a picture are colored. `name` gives each person a color from the theme's
 *  categorical palette, picked by name, and one initial for a one-word name. `kind` gives every
 *  person one tint and every agent another (and a square), with two initials for a one-word name,
 *  for an app that tells people and agents apart at a glance. */
export type AvatarColoring = 'name' | 'kind';
/** How the host colors avatars, UIProvider's `avatarColoring`. */
export declare function useAvatarColoring(): AvatarColoring;
/** Whether single-key shortcuts are on, UIProvider's `characterKeyShortcuts`. */
export declare function useCharacterKeyShortcuts(): boolean;
export declare function useNavigation(): UINavigation;
export declare function useWorkflowJsonResolver(): UIData['resolveWorkflowJson'];
export declare function useRepoSuggestions(): UIData['repoSuggestions'];
export declare function useSavedInputsResolver(): UIData['resolveSavedInputs'];
export declare function useWorkflowActions(): Record;
export declare function useSecretVariablesResolver(): UIData['resolveSecretVariables'];
export declare function useSlots(): UISlots;
/** The engine when one is provided and `enabled`; suspends while a loader resolves. */
export declare function useOptionalWorkflowEngine(enabled?: boolean): WorkflowEngine | undefined;
export declare function useWorkflowEngine(): WorkflowEngine;
/** The engine once it has loaded, without suspending; renders again when a loader resolves. */
export declare function useLoadedWorkflowEngine(): WorkflowEngine | undefined;
/** The engine's workflow editing, which the visual editor can't work without. */
export declare function useWorkflowEditing(): WorkflowEditing;
/** Resolves the engine without suspending, for async callers such as editor completions. */
export declare function useWorkflowEngineLoader(): () => Promise;
export declare function useProvisionCorsRules(): UIData['provisionCorsRules'];
export declare function useRunFile(slug: string, path: string | null, options?: {
    refreshInterval?: number;
}): RunFileResult;
/** A coded problem's text in the reader's language: the host's message for its code and type, or
 *  else its own `message`. */
export declare function useProblemText(): (problem: CodedProblem) => string;
export declare function usePersistedState(key: string, defaultValue: T): [T, Dispatch>];
export interface UIProviderProps {
    /** Translations over the English defaults, at any depth. Define them outside a component, or
     *  memoize them: the provider compares them by value, but a function made each render differs. */
    strings?: UIStringOverrides | undefined;
    /** How the package navigates; read at the moment it navigates, so a new one never re-renders. */
    navigation?: Partial | undefined;
    /** The host's data hooks and resolvers. `useRunFile`, `usePersistedState` and
     *  `useProblemMessage` are called as hooks, so each must stay the same function for the life of
     *  the app. */
    data?: Partial | undefined;
    /** Components the host renders inside the package's; a component made each render would
     *  remount everything it renders. */
    slots?: UISlots | undefined;
    /** The engine, or a loader that resolves to it. A loader is called once, the first one
     *  passed, so it may be written inline. */
    engine?: WorkflowEngineSource | undefined;
    /** The nonce the page's Content Security Policy allows inline scripts by,
     *  for a host that renders on the server: a few components emit a script
     *  that places them before hydration. The components render no inline
     *  `