async compiler
- Lenguaje dominante
- JavaScript
- Estrellas
- 31.5k
- Forks
- 5.8k
- Merge medio
- 9 d 8 h
- PR fusionados (30 d)
- 2
Descripción
## Feature request
#### What problem does this feature solve?
Returning a promise from the function passed to `vm.config.renderer.code` doesn't work as one would expect.
I wanted to use an async method (`crypto.subtle.digest` in my mermaid plugin:
```js
hook.mounted(function() {
const renderer = vm.config.markdown.renderer
const original = renderer.code || renderer.origin.code
renderer.code = renderer.origin.code = async function(code, lang) {
if (lang === 'mermaid') {
const sha256 = Array.from(new Uint8Array(await window.crypto.subtle.digest('SHA-256', new TextEncoder().encode(code)))).map(b => b.toString(16).padStart(2, '0')).join('')
const mermaidId = `mermaid-svg-${sha256}`
return `${mermaid.render(mermaidId, code)}`
}
else return original.apply(this, arguments)
}
})
```
But all my code fences are now being replaced, in the HTML document, with:
```html
[object Promise]
```
#### What does the proposed API look like?
No change, but the compiler should be promise-aware (so that when the result of calling a function is a promise, it awaits it).
#### How should this be implemented in your opinion?
I'm not sure how the compiler works at the moment.
#### Are you willing to work on this yourself?
If time allows, which is probably negative :-/
Guía de contribución
Línea de trabajo
Empieza rastreando cómo el compilador invoca `vm.config.renderer.code` y cómo su valor de retorno se convierte en HTML, especialmente cuando `renderer.code` devuelve una promesa. Se considera terminado cuando se esperan los resultados asíncronos del renderer, mientras que la representación síncrona existente de los bloques de código permanece sin cambios; el issue no especifica archivos ni pruebas que ejecutar.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- web-dev
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 30/100