@bitbybit-dev/occt-worker
Version:
Bit By Bit Developers CAD algorithms using OpenCascade Technology kernel adapted for WebWorker
46 lines (45 loc) • 1.78 kB
TypeScript
import { CacheHelper } from "./cache-helper";
import { ShapeResolver } from "./shape-resolver";
import { OCCTService } from "@bitbybit-dev/occt";
/**
* CommandResult represents the outcome of a command handler.
*/
export interface CommandResult {
/** Whether the command was handled (if false, default processing should occur) */
handled: boolean;
/** The result to return to the caller (if handled is true) */
result?: unknown;
}
/**
* CommandContext provides dependencies needed by command handlers.
*/
export interface CommandContext {
/** The OpenCascade service instance */
openCascade: OCCTService;
/** The cache helper for managing shape cache */
cacheHelper: CacheHelper;
/** The shape resolver for resolving cached shapes */
shapeResolver: ShapeResolver;
/** Function to add dependencies when OpenCascade isn't ready yet */
addPendingDependency: (key: string, value: unknown) => void;
}
/**
* CommandHandler is a function that handles a specific reserved function.
*/
export type CommandHandler = (inputs: Record<string, unknown>, context: CommandContext) => CommandResult;
/**
* CommandHandlers provides specialized handling for reserved functions.
*
* These functions have custom logic that differs from the standard
* cache-and-execute flow used by most OCCT operations.
*/
export declare const CommandHandlers: Record<string, CommandHandler>;
/**
* Gets the command handler for a given function name.
* Returns undefined if no special handler exists for the function.
*/
export declare function getCommandHandler(functionName: string): CommandHandler | undefined;
/**
* Checks if a function name has a special command handler.
*/
export declare function hasCommandHandler(functionName: string): boolean;