/**
 * The functions provided by this module are used to communicate certain properties
 * about the currently running code so that Next.js can make decisions on how to handle
 * the current execution in different rendering modes such as pre-rendering, resuming, and SSR.
 *
 * Today Next.js treats all code as potentially static. Certain APIs may only make sense when dynamically rendering.
 * Traditionally this meant deopting the entire render to dynamic however with PPR we can now deopt parts
 * of a React tree as dynamic while still keeping other parts static. There are really two different kinds of
 * Dynamic indications.
 *
 * The first is simply an intention to be dynamic. unstable_noStore is an example of this where
 * the currently executing code simply declares that the current scope is dynamic but if you use it
 * inside unstable_cache it can still be cached. This type of indication can be removed if we ever
 * make the default dynamic to begin with because the only way you would ever be static is inside
 * a cache scope which this indication does not affect.
 *
 * The second is an indication that a dynamic data source was read. This is a stronger form of dynamic
 * because it means that it is inappropriate to cache this at all. using a dynamic data source inside
 * unstable_cache should error. If you want to use some dynamic data inside unstable_cache you should
 * read that data outside the cache and pass it in as an argument to the cached function.
 */
import type { WorkStore } from '../app-render/work-async-storage.external';
import type { WorkUnitStore, PrerenderStoreModern, ValidationStoreClient } from '../app-render/work-unit-async-storage.external';
import type { ValidationBoundaryTracking } from './instant-validation/boundary-tracking';
import type { InstantValidationSampleTracking } from './instant-validation/instant-samples';
export type DynamicAccess = {
    /**
     * If debugging, this will contain the stack trace of where the dynamic access
     * occurred. This is used to provide more information to the user about why
     * their page is being rendered dynamically.
     */
    stack?: string;
    /**
     * The expression that was accessed dynamically.
     */
    expression: string;
};
export type DynamicTrackingState = {
    /**
     * When true, stack information will also be tracked during dynamic access.
     */
    readonly isDebugDynamicAccesses: boolean | undefined;
    /**
     * The dynamic accesses that occurred during the render.
     */
    readonly dynamicAccesses: Array<DynamicAccess>;
    syncDynamicErrorWithStack: null | Error;
};
export type DynamicValidationState = {
    hasSuspenseAboveBody: boolean;
    hasDynamicMetadata: boolean;
    dynamicMetadata: null | Error;
    hasDynamicViewport: boolean;
    hasAllowedDynamic: boolean;
    dynamicErrors: Array<Error>;
};
export declare function createDynamicTrackingState(isDebugDynamicAccesses: boolean | undefined): DynamicTrackingState;
export declare function createDynamicValidationState(): DynamicValidationState;
export declare function getFirstDynamicReason(trackingState: DynamicTrackingState): undefined | string;
/**
 * This function communicates that the current scope should be treated as dynamic.
 *
 * In most cases this function is a no-op but if called during
 * a PPR prerender it will postpone the current sub-tree and calling
 * it during a normal prerender will cause the entire prerender to abort
 */
export declare function markCurrentScopeAsDynamic(store: WorkStore, workUnitStore: undefined | Exclude<WorkUnitStore, PrerenderStoreModern>, expression: string): void;
export declare function abortOnSynchronousPlatformIOAccess(route: string, expression: string, errorWithStack: Error, prerenderStore: PrerenderStoreModern): void;
/**
 * This component will call `React.postpone` that throws the postponed error.
 */
type PostponeProps = {
    reason: string;
    route: string;
};
export declare function Postpone({ reason, route }: PostponeProps): never;
export declare function postponeWithTracking(route: string, expression: string, dynamicTracking: null | DynamicTrackingState): never;
export declare function isDynamicPostpone(err: unknown): boolean;
type DigestError = Error & {
    digest: string;
};
export declare function isPrerenderInterruptedError(error: unknown): error is DigestError;
export declare function accessedDynamicData(dynamicAccesses: Array<DynamicAccess>): boolean;
export declare function consumeDynamicAccess(serverDynamic: DynamicTrackingState, clientDynamic: DynamicTrackingState): DynamicTrackingState['dynamicAccesses'];
export declare function formatDynamicAPIAccesses(dynamicAccesses: Array<DynamicAccess>): string[];
/**
 * This is a bit of a hack to allow us to abort a render using a Postpone instance instead of an Error which changes React's
 * abort semantics slightly.
 */
export declare function createRenderInBrowserAbortSignal(): AbortSignal;
/**
 * In a prerender, we may end up with hanging Promises as inputs due them
 * stalling on connection() or because they're loading dynamic data. In that
 * case we need to abort the encoding of arguments since they'll never complete.
 */
export declare function createHangingInputAbortSignal(workUnitStore: WorkUnitStore): AbortSignal | undefined;
export declare function annotateDynamicAccess(expression: string, prerenderStore: PrerenderStoreModern | ValidationStoreClient): void;
export declare function useDynamicRouteParams(expression: string): undefined;
export declare function useDynamicSearchParams(expression: string): void;
export declare function trackAllowedDynamicAccess(workStore: WorkStore, componentStack: string, dynamicValidation: DynamicValidationState, clientDynamic: DynamicTrackingState): void;
export declare enum DynamicHoleKind {
    /** We know that this hole is caused by runtime data. */
    Runtime = 1,
    /** We know that this hole is caused by dynamic data. */
    Dynamic = 2
}
/** Stores dynamic reasons used during an SSR render in instant validation. */
export type InstantValidationState = {
    hasDynamicMetadata: boolean;
    hasAllowedClientDynamicAboveBoundary: boolean;
    dynamicMetadata: null | Error;
    hasDynamicViewport: boolean;
    hasAllowedDynamic: boolean;
    dynamicErrors: Array<Error>;
    validationPreventingErrors: Array<Error>;
    thrownErrorsOutsideBoundary: Array<unknown>;
    createInstantStack: (() => Error) | null;
};
export declare function createInstantValidationState(createInstantStack: (() => Error) | null): InstantValidationState;
export declare function trackDynamicHoleInNavigation(workStore: WorkStore, componentStack: string, dynamicValidation: InstantValidationState, clientDynamic: DynamicTrackingState, kind: DynamicHoleKind, boundaryState: ValidationBoundaryTracking): void;
export declare function trackThrownErrorInNavigation(workStore: WorkStore, dynamicValidation: InstantValidationState, thrownValue: unknown, componentStack: string): void;
export declare function trackDynamicHoleInRuntimeShell(workStore: WorkStore, componentStack: string, dynamicValidation: DynamicValidationState, clientDynamic: DynamicTrackingState): void;
export declare function trackDynamicHoleInStaticShell(workStore: WorkStore, componentStack: string, dynamicValidation: DynamicValidationState, clientDynamic: DynamicTrackingState): void;
export declare enum PreludeState {
    Full = 0,
    Empty = 1,
    Errored = 2
}
export declare function logDisallowedDynamicError(workStore: WorkStore, error: Error): void;
export declare function throwIfDisallowedDynamic(workStore: WorkStore, prelude: PreludeState, dynamicValidation: DynamicValidationState, serverDynamic: DynamicTrackingState): void;
export declare function getStaticShellDisallowedDynamicReasons(workStore: WorkStore, prelude: PreludeState, dynamicValidation: DynamicValidationState, configAllowsBlocking: boolean): Array<Error>;
export declare function getNavigationDisallowedDynamicReasons(workStore: WorkStore, prelude: PreludeState, dynamicValidation: InstantValidationState, validationSampleTracking: InstantValidationSampleTracking | null, boundaryState: ValidationBoundaryTracking): Array<Error>;
export {};
