fix(components): ui prop override with class (#136)

This commit is contained in:
Benjamin Canac
2024-07-03 14:35:58 +02:00
committed by GitHub
parent 5a22c62b2a
commit 235556d3e0
50 changed files with 383 additions and 375 deletions

View File

@@ -2,10 +2,10 @@ import type { Options } from 'prettier'
import PrettierWorker from '@/workers/prettier.js?worker&inline'
export interface SimplePrettier {
format: (source: string, options?: Options) => Promise<string>;
format: (source: string, options?: Options) => Promise<string>
}
function createPrettierWorkerApi (worker: Worker): SimplePrettier {
function createPrettierWorkerApi(worker: Worker): SimplePrettier {
let counter = 0
const handlers = {}
@@ -17,6 +17,7 @@ function createPrettierWorkerApi (worker: Worker): SimplePrettier {
}
const [resolve, reject] = handlers[uid]
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete handlers[uid]
if (error) {
@@ -26,7 +27,7 @@ function createPrettierWorkerApi (worker: Worker): SimplePrettier {
}
})
function postMessage<T> (message) {
function postMessage<T>(message) {
const uid = ++counter
return new Promise<T>((resolve, reject) => {
handlers[uid] = [resolve, reject]
@@ -35,19 +36,19 @@ function createPrettierWorkerApi (worker: Worker): SimplePrettier {
}
return {
format (source: string, options?: Options) {
format(source: string, options?: Options) {
return postMessage({ type: 'format', source, options })
}
}
}
export default defineNuxtPlugin({
async setup () {
async setup() {
let prettier: SimplePrettier
if (import.meta.server) {
const prettierModule = await import('prettier')
prettier = {
format (source, options = {
format(source, options = {
parser: 'markdown'
}) {
return prettierModule.format(source, options)