import { type PreactNode } from '@sisense/sdk-ui-preact'; import { type Component, type DefineComponent } from 'vue'; import { type VueComponentAdapterContexts } from './vue-component-adapter'; /** * A preact component. Its render output matches the preact-facing component interfaces, so a * component produced by {@link ComponentTranslator.toPreactComponent} can be handed to any of them * (custom widget map, dashboard header item, ...). * * @internal */ export type PreactComponent = (props: Props) => PreactNode; /** * A Vue component: a component options object, a `defineComponent` result, or any valid Vue * component. * * @internal */ export type VueComponent = Component | DefineComponent; type AnyObject = Record; /** * Translates components between Vue and preact in both directions. * * Shared infrastructure for features that let consumers pass a native Vue component into an * otherwise preact-facing interface — custom widgets and dashboard header items today, widget and * filter-tile headers in the future — and that hand preact components back to consumers, where * every component is exposed as a real Vue component. * * The two methods are inverses of each other, and translation is stable: the same input always * yields the same output instance, so the renderer sees a constant component identity across * re-renders (no unmount/remount) and consumers get back the very component they passed in. * Translating a wrapper back always unwraps it, so a component never gets wrapped twice. * * The translator owns no live component instances: it produces components and adapter *factories*, * and each adapter is created and destroyed by the wrapper that mounts it. Both registries are * keyed weakly, so nothing has to be released explicitly when the host component unmounts. * * @internal */ export type ComponentTranslator = ReturnType; /** * Creates a {@link ComponentTranslator}. * * @param contexts - Parent contexts provided to each Vue component adapted for preact, captured in * the host component's `setup`. * @internal */ export declare function createComponentTranslator(contexts: VueComponentAdapterContexts): { /** * Translates a Vue component into a preact component. * * A Vue wrapper produced by {@link fromPreactComponent} is unwrapped back to the preact * component it renders, rather than being wrapped a second time. */ toPreactComponent: (component: VueComponent) => PreactComponent; /** * Translates a preact component into a Vue component. * * A preact wrapper produced by {@link toPreactComponent} is unwrapped back to the Vue component * it renders; any other preact component is wrapped in a generated Vue component that renders * it, so consumers can render it in a Vue template like any other component. */ fromPreactComponent: (component: PreactComponent) => VueComponent; }; export {};