import React from 'react'; import { Module, NpmRegistry, Sandbox } from '../../types'; import { Settings } from './types'; export type Props = { sandbox: Sandbox; privacy?: number; /** * We only use preview secrets for private sandboxes (I think it is to identify the user in the * preview, because that lives on csb.app and therefore doesn’t have the regular user cookie). */ previewSecret?: string; settings: Settings; customNpmRegistries: NpmRegistry[]; onInitialized?: (preview: BasePreview) => () => void; extraModules?: { [path: string]: { code: string; path: string; }; }; currentModule?: Module; initialPath?: string; url?: string; isInProjectView?: boolean; onClearErrors?: () => void; onAction?: (action: Object) => void; onOpenNewWindow?: () => void; onToggleProjectView?: () => void; isResizing?: boolean; onResize?: (height: number) => void; showNavigation?: boolean; inactive?: boolean; dragging?: boolean; hide?: boolean; noPreview?: boolean; alignDirection?: 'right' | 'bottom'; delay?: number; className?: string; onMount?: (preview: BasePreview) => () => void; overlayMessage?: string; Wrapper?: React.FC<{ children: any; }>; isResponsiveModeActive?: boolean; isResponsivePreviewResizing?: boolean; isPreviewCommentModeActive?: boolean; toggleResponsiveMode?: () => void; createPreviewComment?: () => void; isScreenshotLoading?: boolean; /** * Whether to show a screenshot in the preview as a "placeholder" while loading * to reduce perceived loading time */ showScreenshotOverlay?: boolean; }; type State = { frameInitialized: boolean; url: string; urlInAddressBar: string; back: boolean; forward: boolean; showScreenshot: boolean; useFallbackDomain: boolean; }; interface IModulesByPath { [path: string]: { path: string; code: null | string; isBinary?: boolean; }; } declare class BasePreview extends React.PureComponent { serverPreview: boolean; element: HTMLIFrameElement; onUnmount: () => void; constructor(props: Props); UNSAFE_componentWillUpdate(nextProps: Props, nextState: State): void; componentDidMount(): void; /** * We have a different domain for the preview (currently :id.csb.app), some corporate * firewalls block calls to these domains. Which is why we ping the domain here, if it * returns a bad response we fall back to using our main domain (:id.codesandbox.io). * * We use a different domain for the preview, since Chrome runs iframes from a different root * domain in a different process, which means for us that we have a snappier editor */ testFallbackDomainIfNeeded: () => void; currentUrl: () => string; static defaultProps: { showNavigation: boolean; delay: boolean; }; listener: () => void; disposeInitializer: () => void; initialPath: string; componentWillUnmount(): void; componentDidUpdate(prevProps: Props): void; openNewWindow: () => void; sendPreviewSecret: () => void; handlePrivacyChange: () => void; handleSandboxChange: () => void; updateAddressbarUrl(): void; handleDependenciesChange: () => void; handleMessage: (data: any, source: any) => void; executeCode: () => void; getRenderedModule: () => string; getModulesToSend: () => IModulesByPath; executeCodeImmediately: (initialRender?: boolean, showScreen?: boolean) => void; setIframeElement: (el: HTMLIFrameElement) => void; clearErrors: () => void; updateUrl: (url: string) => void; sendUrl: () => void; handleRefresh: () => void; refreshHashedUrl: (url: any) => void; handleBack: () => void; handleForward: () => void; commitUrl: (url: string, back: boolean, forward: boolean) => void; toggleProjectView: () => void; render(): JSX.Element; } export default BasePreview;