import { BootOptions } from '@webcontainer/api'; import { ComponentOptionsMixin } from 'vue'; import { ComponentProvideOptions } from 'vue'; import { ComputedRef } from 'vue'; import { DefineComponent } from 'vue'; import { Extension } from '@codemirror/state'; import { ExtractPropTypes } from 'vue'; import { Ignore } from 'ignore'; import { ITheme } from '@xterm/xterm'; import { PropType } from 'vue'; import { PublicProps } from 'vue'; import { Ref } from 'vue'; import { WebContainer } from '@webcontainer/api'; import { WebContainerProcess } from '@webcontainer/api'; declare type __VLS_NonUndefinedable = T extends undefined ? never : T; declare type __VLS_NonUndefinedable_2 = T extends undefined ? never : T; declare type __VLS_Prettify = { [K in keyof T]: T[K]; } & {}; declare type __VLS_TypePropsToRuntimeProps = { [K in keyof T]-?: {} extends Pick ? { type: PropType<__VLS_NonUndefinedable>; } : { type: PropType; required: true; }; }; declare type __VLS_TypePropsToRuntimeProps_2 = { [K in keyof T]-?: {} extends Pick ? { type: PropType<__VLS_NonUndefinedable_2>; } : { type: PropType; required: true; }; }; declare type __VLS_WithDefaults = { [K in keyof Pick]: K extends keyof D ? __VLS_Prettify : P[K]; }; declare type __VLS_WithTemplateSlots = T & { new (): { $slots: S; }; }; /** * Context information for an editor tab. */ export declare type EditorTabContext = { /** * When true, the close icon next to the tab label will be omitted. */ suppressClose?: boolean; }; export declare const i18nMessages: { ar: { krgz: { dir: string; sandbox: { general: { close: string; restart: string; stop: string; }; loading: { booting: string; editor: string; files: string; preview: string; processes: string; terminals: string; }; panel: { editor: { readonly: string; }; preview: { reload: string; }; terminals: { new: string; open: string; }; }; toggle: { code: string; fullscreen: string; processes: string; result: string; solve: string; theme: string; terminal: string; }; }; }; }; de: { krgz: { dir: string; sandbox: { general: { close: string; restart: string; stop: string; }; loading: { booting: string; editor: string; files: string; preview: string; processes: string; terminals: string; }; panel: { editor: { readonly: string; }; preview: { reload: string; }; terminals: { new: string; open: string; }; }; toggle: { code: string; fullscreen: string; processes: string; result: string; solve: string; theme: string; terminal: string; }; }; }; }; en: { krgz: { dir: string; sandbox: { general: { close: string; restart: string; stop: string; }; loading: { booting: string; editor: string; files: string; preview: string; processes: string; terminals: string; }; panel: { editor: { readonly: string; }; preview: { reload: string; }; terminals: { new: string; open: string; }; }; toggle: { code: string; fullscreen: string; processes: string; result: string; solve: string; theme: string; terminal: string; }; }; }; }; }; export declare const KrgzEditorTabs: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>; export declare const KrgzExplorer: DefineComponent, { depth: number; path: string; }>>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly, { depth: number; path: string; }>>> & Readonly<{}>, { path: string; depth: number; }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>; export declare const KrgzPreview: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>; export declare const KrgzProcessTabs: DefineComponent>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>; export declare const KrgzSandbox: __VLS_WithTemplateSlots; shownPanels: PropType<("code" | "processes" | "result" | "terminal")[]>; booting: { type: PropType; }; hideExplorer: { type: PropType; }; hideFullScreenToggle: { type: PropType; }; hideSolveButton: { type: PropType; }; hideThemeToggle: { type: PropType; }; multiPanelFrom: { type: PropType<"xs" | "sm" | "lg" | "none" | "md" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl">; }; }>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, { solve: () => void; }, string, PublicProps, Readonly; shownPanels: PropType<("code" | "processes" | "result" | "terminal")[]>; booting: { type: PropType; }; hideExplorer: { type: PropType; }; hideFullScreenToggle: { type: PropType; }; hideSolveButton: { type: PropType; }; hideThemeToggle: { type: PropType; }; multiPanelFrom: { type: PropType<"xs" | "sm" | "lg" | "none" | "md" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl">; }; }>> & Readonly<{ onSolve?: (() => any) | undefined; }>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>, { explorer?(_: {}): any; editor?(_: {}): any; terminal?(_: {}): any; preview?(_: {}): any; processes?(_: {}): any; }>; /** * Type representing available panels. */ export declare type Panel = (typeof panels)[number]; /** * List of available panels. */ export declare const panels: readonly ["code", "processes", "result", "terminal"]; /** * Context information for a process / terminal tab. */ export declare type ProcessTabContext = { /** * Arguments to be passed to `WebContainer.spawn()`. */ args?: string[]; /** * When true, a restart icon will appear next to the label and the process can be restarted. * Ignored when `isTerminal: true`. */ canRestart?: boolean; /** * When true, a restart icon will appear next to the label and the process can be stopped. * Ignored when `isTerminal: true`. */ canStop?: boolean; /** * Command to be passed to `WebContainer.spawn()`. */ command: string; /** * Exit code of the finished / terminated process. */ exitCode?: number; /** * When true, the process will run in the background and will not be shown in the tab list. */ isHidden?: boolean; /** * When true, the process is treated as a terminal: some flags are ignored and the tab will be shown in the * terminals panel and not in the processes panel. */ isTerminal?: boolean; /** * Used to persist the logs and re-fill xterm when the tab is closed and re-opened. */ logs?: string[]; /** * The process instance. */ process?: WebContainerProcess; /** * Input handler, needed to accept input in xterm and pass it to the process in the web container. * @param chunk */ processInputHandler?: (chunk?: string | undefined) => Promise; /** * Output handler, needed to read and store the logs to be displayed by xterm. * @param data */ processOutputHandler?: (data: string) => void; /** * When true, the close icon next to the tab label will be omitted. */ suppressClose?: boolean; /** * When true, xterm will not accept user input. */ suppressInput?: boolean; }; /** * Provide the promise resulting from `WebContainer.boot()` to be injected and used by components and composables. * * Keep in mind that [only one WebContainer instance can run at a time](https://webcontainers.io/api#%E2%96%B8-boot). * It is the responsibility of the consumer to make sure that the old instance has been torn down before booting another. * * @example * provideWebContainer(WebContainer.boot()) * // or * const { boot, isBooting } = useSandboxBoot() * provideWebContainer(boot) * * @param webContainerPromise the promise returned by `WebContainer.boot()` */ export declare const provideWebContainer: (webContainerPromise: Promise) => void; export declare type SandboxOptions = { /** * Editor related options. */ editor: { /** * Default value to be used when creating editor tabs. */ suppressClose?: boolean; /** * Themes to be used by codemirror. * * Using callbacks to overcome the readonly nature of the options returned by `useSandbox()`. * * It is also to avoid the "Type instantiation is excessively deep and possibly infinite." error. * * The callbacks return an array to allow passing multiple themes (e.g. base theme and a theme for overrides). */ theme?: { /** * Callback that returns a list of dark codemirror themes. */ dark?: () => Extension[]; /** * Callback that returns a list of light codemirror themes. */ light?: () => Extension[]; }; }; /** * Path patterns to be used for matching. * The matchers use .gitignore-style matching through [ignore](https://www.npmjs.com/package/ignore) to determine * whether a give path matches one of the patterns. */ explorer: { /** * List of patterns to determine whether an entity (directory or file) should be hidden in the file explorer. */ hidden?: string[]; /** * List of patterns to determine whether an entity (directory or file) should be marked as readonly in the file * explorer and editor tabs. */ readonly?: string[]; /** * List of patterns to determine whether changing an entity (directory or file) should trigger the re-installation * of dependencies and re-bootstrapping. */ reinstall?: string[]; }; /** * Preview related options. */ preview: { /** * When true, the address bar in the preview panel will not be shown. */ suppressAddressBar?: boolean; }; /** * Preview / terminal related options. */ process: { /** * Predefined commands. */ commands: { /** * Dependency installation command. * @default npm install */ install: string; /** * Command to start dev server. * @default npm start */ devServer: string; /** * Command to start a terminal. * @default jsh */ terminal: string; }; /** * Package manager. Setting this option adjusts the predefined commands accordingly. */ packageManager: 'npm' | 'pnpm' | 'yarn'; /** * Callbacks to spawn the processes of the predefined commands. * Implemented as a sensible default and do some opinionated stuff. * * If more control is needed, a process can be started using `useSandbox().processTabs.open()`. */ starters?: { /** * Dependency installation process starter. */ install?: () => Promise; /** * Dev server process starter. */ devServer?: () => Promise; /** * Terminal process starter. */ terminal?: () => Promise; }; }; /** * Terminal related options. */ terminal: { /** * Maximum number of terminal tabs to be opened simultaneously. * @default 3 */ maxCount?: number; /** * Theme to be used by xterm to output process and terminal logs. * * Using callbacks to overcome the readonly nature of the options returned by useSandbox(). */ theme?: { /** * Callback to return dark xterm theme. */ dark?: () => ITheme; /** * Callback to return light xterm theme. */ light?: () => ITheme; }; }; }; /** * Generic tab definition. */ export declare type Tab = { /** * Unique tab ID */ id: string; /** * Additional context information. */ context?: T; /** * Label to be shown in the tab list. */ label: string; /** * Order of the tab. When a tab is opened or focused it gets a new order = `[current max order] + 1`. */ order: number; }; /** * The main composable of Karagöz Sandbox. * * Injects and uses the provided web container promise, performs bootstrapping and returns an object that * is the central piece in the logic of the sandbox. * * This composable is created as a shared instance (singleton, if you will) using VueUse's `createSharedComposable()`. */ export declare const useSandbox: typeof useSandboxInternal; /** * A simple composable for convenience to boot a web container and return the promise along with the status. * @param options */ export declare const useSandboxBoot: (options?: BootOptions) => { boot: Promise; isBooting: Ref; }; declare function useSandboxInternal(): { bootstrap: () => Promise; /** * A computed ref that gives access to the web container instance. */ container: ComputedRef; /** * Editor tabs manager. Responsible for opening, focusing and closing editor tabs. */ editorTabs: { open: (id: string, label?: string | undefined, context?: EditorTabContext | undefined) => void; close: (id: string) => void; current: ComputedRef | undefined>; findTab: (id: string) => Tab | undefined; findTabIndex: (id: string) => number; tabs: ComputedRef[]>; updateContext: (id: string, setter: (ctx: EditorTabContext) => EditorTabContext) => void; }; /** * Provides matchers for different purposes. * The matchers use [ignore](https://www.npmjs.com/package/ignore) to determine whether a give path matches one * of the patterns specified in the sandbox options. */ explorer: { hidden: ComputedRef; readonly: ComputedRef; reinstall: ComputedRef; }; options: { readonly editor: { readonly suppressClose?: boolean | undefined; readonly theme?: { readonly dark?: (() => Extension[]) | undefined; readonly light?: (() => Extension[]) | undefined; } | undefined; }; readonly explorer: { readonly hidden?: readonly string[] | undefined; readonly readonly?: readonly string[] | undefined; readonly reinstall?: readonly string[] | undefined; }; readonly preview: { readonly suppressAddressBar?: boolean | undefined; }; readonly process: { readonly commands: { readonly install: string; readonly devServer: string; readonly terminal: string; }; readonly packageManager: "npm" | "pnpm" | "yarn"; readonly starters?: { readonly install?: (() => Promise) | undefined; readonly devServer?: (() => Promise) | undefined; readonly terminal?: (() => Promise) | undefined; } | undefined; }; readonly terminal: { readonly maxCount?: number | undefined; readonly theme?: { readonly dark?: (() => ITheme) | undefined; readonly light?: (() => ITheme) | undefined; } | undefined; }; }; preview: { /** * A reference to the preview iframe element. */ frame: Ref; /** * Reload the preview. */ reload: () => Promise; /** * Computed ref containing a boolean flag. When true, the address bar in the preview panel will not be shown. */ suppressAddressBar: ComputedRef; /** * The preview URL. */ url: ComputedRef; }; /** * Process tabs manager. Responsible for opening, focusing and closing process and terminal tabs. */ processTabs: { availableTerminals: ComputedRef; close: (id: string) => void; kill: (id: string) => void; open: (id: string, label?: string | undefined, context?: ProcessTabContext | undefined) => Promise; restart: (id: string) => Promise; current: ComputedRef | undefined>; findTab: (id: string) => Tab | undefined; findTabIndex: (id: string) => number; tabs: ComputedRef[]>; updateContext: (id: string, setter: (ctx: ProcessTabContext) => ProcessTabContext) => void; }; setOption: (key: K, newValueOrSetter: T | ((oldValue: T) => T)) => void; setPackageManager: (pm: SandboxOptions['process']['packageManager']) => void; }; export { }