import * as React from 'react'; import { Root } from 'react-dom/client'; type ManifestContentScript = ({ world: "MAIN"; persist_across_sessions?: boolean; } | { world?: "ISOLATED"; match_about_blank?: boolean; match_origin_as_fallback?: boolean; /** * https://developer.chrome.com/docs/extensions/mv3/content_scripts/#matchAndGlob */ exclude_globs?: string[]; include_globs?: string[]; }) & { matches: string[]; /** * https://developer.chrome.com/docs/extensions/mv3/content_scripts/#matchAndGlob */ exclude_matches?: string[]; js?: string[]; css?: string[]; all_frames?: boolean; /** * https://developer.chrome.com/docs/extensions/mv3/content_scripts/#run_time */ run_at?: "document_start" | "document_end" | "document_idle"; }; type PlasmoCSConfig = Omit, "js">; /** * @deprecated use **PlasmoCSConfig** instead */ type PlasmoContentScript = PlasmoCSConfig; type Async = Promise | T; type Getter = (props?: P) => Async; type InsertPosition = "beforebegin" | "afterbegin" | "beforeend" | "afterend"; type ElementInsertOptions = { element: Element; insertPosition?: InsertPosition; }; type ElementInsertOptionsList = ElementInsertOptions[]; type GetElement = Getter; type GetElementInsertOptions = Getter; type PlasmoCSUIOverlayAnchor = { element: Element; root?: Root; type: "overlay"; }; type PlasmoCSUIInlineAnchor = { element: Element; type: "inline"; insertPosition?: InsertPosition; root?: Root; }; type PlasmoCSUIAnchor = PlasmoCSUIOverlayAnchor | PlasmoCSUIInlineAnchor; type PlasmoCSUIProps = { anchor?: PlasmoCSUIAnchor; }; type PlasmoCSUIMountState = { document: Document; observer: MutationObserver | null; mountInterval: NodeJS.Timer | null; isMounting: boolean; isMutated: boolean; /** * Used to quickly check if element is already mounted */ hostSet: Set; /** * Used to add more metadata to the host Set */ hostMap: WeakMap; /** * Used to align overlay anchor with elements on the page */ overlayTargetList: Element[]; }; type PlasmoGetRootContainer = (props: { mountState?: PlasmoCSUIMountState; } & PlasmoCSUIProps) => Async; type PlasmoGetOverlayAnchor = GetElement; type PlasmoGetOverlayAnchorList = Getter; type PlasmoGetInlineAnchor = GetElement | GetElementInsertOptions; type PlasmoGetInlineAnchorList = Getter; type PlasmoMountShadowHost = (props: { mountState?: PlasmoCSUIMountState; shadowHost: Element; } & PlasmoCSUIProps) => Async; type PlasmoGetShadowHostId = Getter; type PlasmoGetStyle = Getter; type PlasmoGetSfcStyleContent = Getter; /** * @return a cleanup unwatch function that will be run when unmounted */ type PlasmoWatchOverlayAnchor = (updatePosition: () => Promise) => (() => void) | void; type PlasmoCSUIContainerProps = { id?: string; children?: React.ReactNode; watchOverlayAnchor?: PlasmoWatchOverlayAnchor; } & PlasmoCSUIProps; type PlasmoCSUIJSXContainer = (p?: PlasmoCSUIContainerProps) => React.JSX.Element; type PlasmoCSUIHTMLContainer = (p?: PlasmoCSUIContainerProps) => HTMLElement; type PlasmoCreateShadowRoot = (shadowHost: HTMLElement) => Async; type PlasmoRender = (props: { createRootContainer?: (p?: PlasmoCSUIAnchor) => Async; } & PlasmoCSUIProps, InlineCSUIContainer?: T, OverlayCSUIContainer?: T) => Async; type PlasmoCSUIWatch = (props: { render: (anchor: PlasmoCSUIAnchor) => Async; observer: { start: (render: (anchor?: PlasmoCSUIAnchor) => void) => void; mountState: PlasmoCSUIMountState; }; }) => void; type PlasmoCSUI = { default: any; getStyle: PlasmoGetStyle; getSfcStyleContent: PlasmoGetSfcStyleContent; getShadowHostId: PlasmoGetShadowHostId; getOverlayAnchor: PlasmoGetOverlayAnchor; getOverlayAnchorList: PlasmoGetOverlayAnchorList; getInlineAnchor: PlasmoGetInlineAnchor; getInlineAnchorList: PlasmoGetInlineAnchorList; getRootContainer: PlasmoGetRootContainer; createShadowRoot: PlasmoCreateShadowRoot; watchOverlayAnchor: PlasmoWatchOverlayAnchor; mountShadowHost: PlasmoMountShadowHost; render: PlasmoRender; watch: PlasmoCSUIWatch; }; export type { PlasmoCSConfig, PlasmoCSUI, PlasmoCSUIAnchor, PlasmoCSUIContainerProps, PlasmoCSUIHTMLContainer, PlasmoCSUIJSXContainer, PlasmoCSUIMountState, PlasmoCSUIProps, PlasmoCSUIWatch, PlasmoContentScript, PlasmoCreateShadowRoot, PlasmoGetInlineAnchor, PlasmoGetInlineAnchorList, PlasmoGetOverlayAnchor, PlasmoGetOverlayAnchorList, PlasmoGetRootContainer, PlasmoGetSfcStyleContent, PlasmoGetShadowHostId, PlasmoGetStyle, PlasmoMountShadowHost, PlasmoRender, PlasmoWatchOverlayAnchor };