diff --git a/README.md b/README.md
index ff4c19b..9d146da 100644
--- a/README.md
+++ b/README.md
@@ -14,14 +14,14 @@
English | [简体中文](./README.zh-CN.md)
-Vue SFC REPL as a Vue 2.7 component.
+Vue SFC REPL as a Vue 2.7+ component.
## 💻 Simple Usage
```vue
@@ -43,4 +43,4 @@ VCV is licensed under the terms of the [MIT License](./LICENSE).
Copyright (c) 2021-present Anduril
-[preview-ol-v03]:https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/987ab9814e314f92a244fdf6510e6224~tplv-k3u1fbpfcp-watermark.image?
+[preview-ol-v03]: https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/987ab9814e314f92a244fdf6510e6224~tplv-k3u1fbpfcp-watermark.image?
diff --git a/index.html b/index.html
index 5e2c7ee..50aa7be 100644
--- a/index.html
+++ b/index.html
@@ -5,7 +5,7 @@
- Vue SFC Playground
+ Vue Code View Playground
diff --git a/src/monaco/userWorker.ts b/src/monaco/userWorker.ts
new file mode 100644
index 0000000..5fb71a3
--- /dev/null
+++ b/src/monaco/userWorker.ts
@@ -0,0 +1,30 @@
+// https://github.com/vitejs/vite/discussions/1791#discussioncomment-321046
+// https://github.com/microsoft/monaco-editor/blob/HEAD/docs/integrate-esm.md#using-vite
+// https://github.com/microsoft/monaco-editor/tree/main/samples/browser-esm-vite-react
+import * as monaco from 'monaco-editor';
+import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
+import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
+import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
+import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
+import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
+
+// @ts-ignore
+self.MonacoEnvironment = {
+ getWorker(_: any, label: string) {
+ if (label === 'json') {
+ return new jsonWorker();
+ }
+ if (label === 'css' || label === 'scss' || label === 'less') {
+ return new cssWorker();
+ }
+ if (label === 'html' || label === 'handlebars' || label === 'razor') {
+ return new htmlWorker();
+ }
+ if (label === 'typescript' || label === 'javascript') {
+ return new tsWorker();
+ }
+ return new editorWorker();
+ }
+};
+
+monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
\ No newline at end of file
diff --git a/src/utils.ts b/src/utils.ts
index 7553e2d..3c9c9dd 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,13 +1,29 @@
import { zlibSync, unzlibSync, strToU8, strFromU8 } from "fflate";
-export function debounce(fn: Function, n = 100) {
- let handle: any;
- return (...args: any[]) => {
- if (handle) clearTimeout(handle);
- handle = setTimeout(() => {
- fn(...args);
- }, n);
- };
+// export function debounce(fn: Function, n = 100) {
+// let handle: any;
+// return (...args: any[]) => {
+// if (handle) clearTimeout(handle);
+// handle = setTimeout(() => {
+// fn(...args);
+// }, n);
+// };
+// }
+
+export function debounce any>(
+ fn: T,
+ delay: number = 300
+): T {
+ let prevTimer: number | null = null
+ return ((...args: any[]) => {
+ if (prevTimer) {
+ clearTimeout(prevTimer)
+ }
+ prevTimer = window.setTimeout(() => {
+ fn(...args)
+ prevTimer = null
+ }, delay)
+ }) as T
}
export function utoa(data: string): string {
diff --git a/tsconfig.json b/tsconfig.json
index 84ec459..96dc7d1 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -16,7 +16,9 @@
"esModuleInterop": true,
"removeComments": false,
"lib": ["ESNext", "DOM"],
- "rootDir": "."
+ "rootDir": ".",
+ "composite": true,
+ "allowSyntheticDefaultImports": true
// "isolatedModules": true,
// "skipLibCheck": true,
// "noEmit": true