import type { Metadata } from '@devvit/protos/lib/Types.js'; import type { RenderPostRequest, RenderPostResponse } from '@devvit/protos/types/devvit/reddit/custom_post/v1alpha/custom_post.js'; import type { LinkedBundle } from '@devvit/protos/types/devvit/runtime/bundle.js'; import { BlockRenderEventType } from '@devvit/protos/types/devvit/ui/block_kit/v1beta/enums.js'; import type { UIDimensions } from '@devvit/protos/types/devvit/ui/common/v1alpha/common.js'; import type { Effect } from '@devvit/protos/types/devvit/ui/effects/v1alpha/effect.js'; import type { UIEvent } from '@devvit/protos/types/devvit/ui/events/v1alpha/event.js'; import type { Struct } from '@devvit/protos/types/google/protobuf/struct.js'; import type { ErrorCallback } from '@devvit/runtime-lite/client/BrowserLiteClient.js'; import type { LiteLoadResponse } from '@devvit/runtime-lite/client/ClientShared.js'; import type { PluginCallback } from '@devvit/runtime-lite/runtime/RuntimeLite.js'; import type { T3, Tid } from '@devvit/shared-types/tid.js'; import type { UIApp } from './remote-app.js'; type AppState = { __postData?: { thingId: Tid | undefined; config: Struct['fields'] | undefined; }; [key: string]: unknown; }; type EventData = { [key: string]: unknown; }; type PausedEffect = { renderType: BlockRenderEventType; effects: readonly Effect[]; }; /** * App render and effect looping logic. Rendering and event processing is as * follows: * * 1. Try the local runtime, if available. * 2. If a local runtime or bundle is unavailable, or local execution fails * (including CircuitBreak), try the remote. * 3. Report execution errors by callback only. In general, all errors are * attempted to be tolerated. * * App / render state is always preserved even on error so a buggy app will try * not to show any issues. A bundle or runtime can be replaced on the fly with * losing state. */ export declare class Dispatcher { #private; onError?: ErrorCallback | undefined; onPluginCall?: PluginCallback | undefined; onRenderPost?: ((req: RenderPostRequest, rsp: RenderPostResponse) => void) | undefined; onUserAction?: ((fx: Effect) => void) | undefined; postConfig?: Struct['fields'] | undefined; postID?: T3 | undefined; /** A client to the remote runtime. */ remote?: UIApp | undefined; /** Dimensions that describe layout information for the custom post entry point */ dimensions: UIDimensions; /** Get the current app state with the current post state. */ get appState(): AppState; /** * Load an app bundle into the local runtime, if available. The bundle is * assumed to implement a UIApp. */ load(app: Readonly): Promise; set meta(meta: Readonly | undefined); queueEvent(ev: UIEvent): void; queueRenderPost(type: BlockRenderEventType, id: string | undefined, data: EventData): void; get rendered(): boolean; get pausedEffects(): readonly PausedEffect[]; /** * Discard app and render state. This is used indirectly by devvit-preview * which frequently loads new bundles. */ resetAppState(): void; set runtimeDebugLogging(on: boolean); /** Set the runtime source code. */ setLocalSrc(src: string | Blob | undefined, name: string): void; /** Unload the app and reject any open requests. */ unload(): void; /** Pause/unpause the app. */ togglePause(paused: boolean): void; } export {}; //# sourceMappingURL=dispatcher.d.ts.map