UNPKG

adnbn

Version:

Addon Bone - Cross-browser web extension framework with shared code base

39 lines (36 loc) 2.02 kB
import { ReactNode, FC } from 'react'; import { Optional } from 'utility-types'; import { Options } from 'html-rspack-tags-plugin'; import { ExcludeFunctionsFromProperties, Awaiter, PickNonFunctionProperties } from './helpers.js'; import { T as EntrypointOptions, a5 as EntrypointBuilder } from '../manifest-DAV18Z2K.js'; import './app.js'; import './browser.js'; import './locale.js'; interface ViewConfig { as?: string; title?: string; template?: string; } type ViewOptions = ViewConfig & EntrypointOptions & ExcludeFunctionsFromProperties<Options>; type ViewEntrypointOptions = ViewOptions; type ViewRenderReactComponent<T extends ViewConfig> = FC<T>; type ViewRenderValue<T extends ViewConfig> = string | Element | ReactNode | ViewRenderReactComponent<T>; type ViewRenderHandler<T extends ViewConfig> = (props: T) => Awaiter<void | ViewRenderValue<T>>; type ViewContainerTag = Exclude<keyof HTMLElementTagNameMap, "html" | "body">; type ViewContainerOptions = { [Tag in ViewContainerTag]: { tagName: Tag; } & Exclude<Optional<PickNonFunctionProperties<HTMLElementTagNameMap[Tag]>>, "id">; }[ViewContainerTag]; type ViewContainerFactory<T extends ViewConfig> = (props: T) => Awaiter<Element | ViewContainerTag | ViewContainerOptions>; type ViewContainerCreator<T extends ViewConfig> = (props: T) => Awaiter<Element>; interface ViewDefinition<T extends ViewConfig> extends ViewOptions { render?: ViewRenderValue<T> | ViewRenderHandler<T>; container?: ViewContainerTag | ViewContainerOptions | ViewContainerFactory<T>; } interface ViewResolvedDefinition<T extends ViewConfig> extends ViewDefinition<T> { render: ViewRenderHandler<T>; container: ViewContainerCreator<T>; } type ViewBuilder = EntrypointBuilder; export type { ViewBuilder, ViewConfig, ViewContainerCreator, ViewContainerFactory, ViewContainerOptions, ViewContainerTag, ViewDefinition, ViewEntrypointOptions, ViewOptions, ViewRenderHandler, ViewRenderReactComponent, ViewRenderValue, ViewResolvedDefinition };