UNPKG

py_sandpack

Version:

PySandpack is a React library designed to provide a sandbox environment for executing Python code directly in the browser. It is ideal for educational purposes, quick experiments, or running Python scripts without requiring a local Python installation.

99 lines (71 loc) 2.58 kB
import { default as default_2 } from 'react'; import { JSX as JSX_2 } from 'react/jsx-runtime'; import { ReactCodeMirrorProps } from '@uiw/react-codemirror'; declare type BaseProtocol<T, P> = { type: T; payload: P; } declare type Codes = Record<string, string>; declare function codes2SearchParam(codes: Codes): string; declare type CodesKey = 'pySandpackCodes'; declare type CodesProtocol = BaseProtocol<CodesKey, { codes: Codes }>; declare type CommonProps = { hideRunner?: boolean; hidePySandbox?: boolean; }; declare type Ext2PySpMessageProtocol = CodesProtocol /* | AnyOthers */; declare type Lang = 'python'; declare namespace MessageUtil { export { sendMsgToPySandpackFrom, sendMsgFromPySandPackTo } } declare function PySandpack(props: { codes: Codes; lang: Lang; editorProps?: PySandpackEditorProps; }): JSX_2.Element; export default PySandpack; declare type PySandpackContextType = PySandpackCoreProperties & { isReady: boolean; setCodes: (codes: Codes) => void; runCodes: (() => void); }; declare type PySandpackCoreProperties = { codes: Codes; results: Results | undefined; error: Error | undefined; isRunning: boolean; lang: Lang; }; export declare function PySandpackEditor(props: PySandpackEditorProps): JSX_2.Element; declare type PySandpackEditorProps = ReactCodeMirrorProps & CommonProps; export declare function PySandpackPreview(props: { showSplashScreen?: boolean; }): JSX_2.Element; export declare function PySandpackProvider(props: PySandpackProviderProps): JSX_2.Element; declare type PySandpackProviderProps = { lang: Lang; codes: Codes; children: default_2.ReactNode; onRunCodes?: () => void; }; export declare const PySandpackUtil: { UrlUtil: typeof UrlUtil; MessageUtil: typeof MessageUtil; }; declare type PySp2ExtMessageProtocol = ReadyProtocol /* | AnyOthers */; declare type ReadyProtocol = BaseProtocol<'pySandpackReady', undefined>; declare type Results = Record<string, any>; declare function searchParam2Codes(): Codes | undefined; declare function sendMsgFromPySandPackTo(target: Window, message: PySp2ExtMessageProtocol): void; declare function sendMsgToPySandpackFrom(target: Window, message: Ext2PySpMessageProtocol): void; declare namespace UrlUtil { export { searchParam2Codes, codes2SearchParam } } export declare const usePySandpack: () => PySandpackContextType; export { }