Skip to content

Commit 69314a5

Browse files
committed
chore(utils|apps/playgoround): simplify code
1 parent fdcac33 commit 69314a5

File tree

4 files changed

+10
-32
lines changed

4 files changed

+10
-32
lines changed

apps/playground/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"@shikijs/themes": "^3.4.0",
4545
"@unocss/reset": "^66.1.1",
4646
"@velin-dev/core": "workspace:^",
47+
"@velin-dev/utils": "workspace:^",
4748
"@velin-dev/vue": "workspace:^",
4849
"@vitejs/plugin-vue": "^5.2.4",
4950
"@volar/jsdelivr": "^2.4.13",

apps/playground/src/components/Editor/store.ts

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {
1010
import type { OutputModes } from '../../types/vue-repl'
1111
import type { ImportMap } from './import-map'
1212

13+
import { File as VueFile } from '@velin-dev/utils/transformers/vue'
1314
import {
1415
computed,
1516
reactive,
@@ -28,6 +29,10 @@ import { compileFile } from './transform'
2829
export const importMapFile = 'import-map.json'
2930
export const tsconfigFile = 'tsconfig.json'
3031

32+
export class File extends VueFile {
33+
editorViewState: editor.ICodeEditorViewState | null = null
34+
}
35+
3136
export function useStore(
3237
{
3338
files = ref(Object.create(null)),
@@ -505,38 +510,6 @@ export type Store = Pick<
505510
| 'getTsConfig'
506511
>
507512

508-
export class File {
509-
compiled = {
510-
js: '',
511-
css: '',
512-
ssr: '',
513-
}
514-
515-
editorViewState: editor.ICodeEditorViewState | null = null
516-
517-
constructor(
518-
public filename: string,
519-
public code = '',
520-
public hidden = false,
521-
) {}
522-
523-
get language() {
524-
if (this.filename.endsWith('.vue')) {
525-
return 'vue'
526-
}
527-
if (this.filename.endsWith('.html')) {
528-
return 'html'
529-
}
530-
if (this.filename.endsWith('.css')) {
531-
return 'css'
532-
}
533-
if (this.filename.endsWith('.ts')) {
534-
return 'typescript'
535-
}
536-
return 'javascript'
537-
}
538-
}
539-
540513
function addSrcPrefix(file: string) {
541514
return file === importMapFile
542515
|| file === tsconfigFile
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './moduleCompiler'
2+
export * from './shared'

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)