Skip to content

feat(Output): add console #333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: set in exports & doc
  • Loading branch information
Dsaquel committed Apr 17, 2025
commit b8a7a51aee40c80262d6bfffe9b49adcc53400d9
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ import Monaco from '@vue/repl/monaco-editor'
</template>
```

### With Luna Console (4.5.2)

Console UI to print console logs.
**Be aware**: Because we are getting logs that pass into a `postMessage` they are some types/logs that are currently not supported such as elements html, declared functions, `console.trace()`, etc... More of the supported types [here](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#things_that_dont_work_with_structured_clone).

```vue
<script setup>
import { Repl } from '@vue/repl'
import LunaConsole from '@vue/repl/luna-console'
</script>

<template>
<Repl showConsole :console="LunaConsole" />
</template>
```

## Advanced Usage

Customize the behavior of the REPL by manually initializing the store.
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"import": "./dist/codemirror-editor.js",
"require": null
},
"./luna-console": {
"types": "./dist/luna-console.d.ts",
"import": "./dist/luna-console.js",
"require": null
},
"./core": {
"types": "./dist/core.d.ts",
"import": "./dist/core.js",
Expand Down
2 changes: 1 addition & 1 deletion src/output/srcdoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
'countReset',
].forEach((level) => {
const original = console[level]
console[level] = async (...args) => {
console[level] = (...args) => {
const msg = args[0]
if (typeof msg === 'string') {
if (
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default mergeConfig(base, {
core: './src/core.ts',
'monaco-editor': './src/editor/MonacoEditor.vue',
'codemirror-editor': './src/editor/CodeMirrorEditor.vue',
'luna-console': './src/output/LunaConsole.vue',
},
formats: ['es'],
fileName: () => '[name].js',
Expand Down