https://github.com/codevideo/codevideo-virtual-author
A TypeScript class that represents a virtual author in the CodeVideo ecosystem.
https://github.com/codevideo/codevideo-virtual-author
Last synced: 4 months ago
JSON representation
A TypeScript class that represents a virtual author in the CodeVideo ecosystem.
- Host: GitHub
- URL: https://github.com/codevideo/codevideo-virtual-author
- Owner: codevideo
- Created: 2025-02-01T08:40:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-03T09:38:28.000Z (over 1 year ago)
- Last Synced: 2025-03-25T12:18:49.201Z (about 1 year ago)
- Language: TypeScript
- Size: 52.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @fullstackcraft/codevideo-virtual-author

`codevideo-virtual-author` is a TypeScript class that simulates a virtual author that can speak. This lightweight and versatile library is ideal for building educational tools, code playgrounds, and interactive coding environments within web applications.
This library heavily relies on the types from [codevideo-types](https://github.com/codevideo/codevideo-types)
## Example Usage
```typescript
import { VirtualAuthor } from '@fullstackcraftllc/codevideo-virtual-author';
// Initialize a VirtualAuthor instance with initial existing command history
const virtualAuthor = new VirtualAuthor();
// Apply speak action to the virtual author
virtualAuthor.applyActions([
{ name: 'speak-before', value: "Hi! I'm Chris, virtual CodeVideo author!" }
]);
// Use the virtual author object
const actionsApplied = virtualAuthor.getActionsApplied();
const currentSpeechCaption = virtualAuthor.getCurrentSpeechCaption();
// Log the final code and actions applied
console.log('Actions applied:');
console.log(actionsApplied);
console.log('Current speech caption:');
console.log(currentSpeechCaption); // "Hi! I'm Chris, virtual CodeVideo author!"
```
## Available Methods
### `applyAction(action: IAction): void`
Apply a single action to the code.
### `applyActions(actions: Array): void`
Apply a series of actions to the virtual author.
### `getActionsApplied(): Array`
Get the actions applied to the virtual author.
### `getCurrentSpeechCaption(): string`
Get the current speech caption of the virtual author. Returns an empty string if no speech caption is set.
## Why?
Why do we need a seemingly useless class? This library, along with [`codevideo-virtual-code-block`](https://github.com/codevideo/codevideo-virtual-code-block) create the backbone of [`codevideo-virtual-code-editor`](https://github.com/codevideo/codevideo-virtual-code-editor) which are used to validate steps across the CodeVideo ecosystem. This is a small part of a larger project to create a declarative way to build, edit, and generate step by step educational video software courses.
See more at [codevideo.io](https://codevideo.io)