CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-vue--repl

Vue component for editing Vue components with interactive REPL functionality.

Pending
Overview
Eval results
Files

repl-component.mddocs/

REPL Component

The main REPL component provides a complete code editing and preview experience with configurable layout, themes, and editor options. It orchestrates the editor panels and preview output with real-time compilation.

Capabilities

Repl Component

Main Vue component that provides the complete REPL interface with editor and output panels.

/**
 * Main REPL component providing editor and preview functionality
 * @param props - Configuration options for the REPL
 */
interface ReplProps {
  /** UI theme for the REPL interface */
  theme?: 'dark' | 'light';
  /** Whether preview iframe should inherit the theme */
  previewTheme?: boolean;
  /** Editor component to use (required) - CodeMirror or Monaco */
  editor: EditorComponentType;
  /** Custom store instance, defaults to new store */
  store?: Store;
  /** Whether panels should auto-resize */
  autoResize?: boolean;
  /** Show compilation output tab in preview */
  showCompileOutput?: boolean;
  /** Show source map visualization option */
  showOpenSourceMap?: boolean;
  /** Show import map editor tab */
  showImportMap?: boolean;
  /** Show SSR output tab */
  showSsrOutput?: boolean;
  /** Show TypeScript config editor tab */
  showTsConfig?: boolean;
  /** Clear console on file changes */
  clearConsole?: boolean;
  /** Panel layout orientation */
  layout?: 'horizontal' | 'vertical';
  /** Reverse the position of editor and preview panels */
  layoutReverse?: boolean;
  /** Enable server-side rendering mode */
  ssr?: boolean;
  /** Preview iframe customization options */
  previewOptions?: PreviewOptions;
  /** Editor-specific configuration options */
  editorOptions?: EditorOptions;
  /** Split pane UI customization options */
  splitPaneOptions?: SplitPaneOptions;
}

interface PreviewOptions {
  /** Custom HTML to inject into preview iframe head */
  headHTML?: string;
  /** Custom HTML to inject into preview iframe body */
  bodyHTML?: string;
  /** HTML to show when preview is loading */
  placeholderHTML?: string;
  /** Custom code injection for advanced use cases */
  customCode?: {
    /** Custom import statements to add to preview */
    importCode?: string;
    /** Custom code to execute in preview context */
    useCode?: string;
  };
  /** Whether to display runtime errors in preview */
  showRuntimeError?: boolean;
  /** Whether to display runtime warnings in preview */
  showRuntimeWarning?: boolean;
}

interface EditorOptions {
  /** Custom error display text, or false to hide */
  showErrorText?: string | false;
  /** Custom auto-save indicator text, or false to hide */
  autoSaveText?: string | false;
  /** Monaco editor specific configuration options */
  monacoOptions?: monaco.editor.IStandaloneEditorConstructionOptions;
}

interface SplitPaneOptions {
  /** Text for code panel toggle button */
  codeTogglerText?: string;
  /** Text for output panel toggle button */
  outputTogglerText?: string;
}

Usage Examples:

import { Repl } from "@vue/repl";
import Monaco from "@vue/repl/monaco-editor";

// Basic usage with Monaco editor
<template>
  <Repl :editor="Monaco" />
</template>

// Advanced configuration
<template>
  <Repl 
    :editor="Monaco"
    theme="dark"
    :previewTheme="true"
    layout="vertical"
    :showCompileOutput="true"
    :showImportMap="true"
    :previewOptions="{
      headHTML: '<meta name=\"viewport\" content=\"width=device-width\">',
      showRuntimeError: true
    }"
    :editorOptions="{
      monacoOptions: {
        fontSize: 14,
        minimap: { enabled: false }
      }
    }"
  />
</template>

Repl Methods

Methods exposed by the Repl component for programmatic control.

/**
 * Reload the preview iframe, useful for clearing runtime state
 */
function reload(): void;

Usage Example:

<template>
  <Repl ref="repl" :editor="Monaco" />
  <button @click="$refs.repl.reload()">Reload Preview</button>
</template>

Auto-Save Model

The Repl component supports v-model for auto-save functionality.

/**
 * Auto-save model value - whether files are automatically saved
 */
const autoSave: ModelRef<boolean>;

Usage Example:

<template>
  <Repl 
    v-model:autoSave="autoSaveEnabled"
    :editor="Monaco" 
  />
  <label>
    <input type="checkbox" v-model="autoSaveEnabled" />
    Enable Auto-save
  </label>
</template>

<script setup>
import { ref } from 'vue';
const autoSaveEnabled = ref(true);
</script>

Default Values

The Repl component provides sensible defaults for all optional props:

  • theme: 'light'
  • previewTheme: false
  • autoResize: true
  • showCompileOutput: true
  • showOpenSourceMap: false
  • showImportMap: true
  • showSsrOutput: false
  • showTsConfig: true
  • clearConsole: true
  • layoutReverse: false
  • ssr: false
  • layout: 'horizontal'
  • All option objects default to empty objects: {}

Error Handling

The Repl component includes built-in error handling:

  • Editor prop validation: Throws error if editor prop is not provided
  • Compilation errors: Displayed in the errors panel and compilation output
  • Runtime errors: Captured and displayed in preview when previewOptions.showRuntimeError is true
  • Import resolution errors: Shown in compilation output with helpful messages

Install with Tessl CLI

npx tessl i tessl/npm-vue--repl

docs

editor-components.md

file-system.md

import-map-management.md

index.md

preview-system.md

repl-component.md

store-management.md

tile.json