feat: editor import PAC definition

This commit is contained in:
dongchengjie 2024-05-18 14:59:17 +08:00
parent bd3b41c809
commit b25cf5eadb
3 changed files with 30 additions and 15 deletions

View File

@ -37,8 +37,9 @@
"i18next": "^23.11.3", "i18next": "^23.11.3",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"meta-json-schema": "1.18.4-beta5", "meta-json-schema": "1.18.4-beta5",
"monaco-editor": "^0.47.0", "monaco-editor": "^0.48.0",
"monaco-yaml": "^5.1.1", "monaco-yaml": "^5.1.1",
"types-pac": "^1.0.2",
"nanoid": "^5.0.7", "nanoid": "^5.0.7",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",

View File

@ -65,11 +65,11 @@ importers:
specifier: 1.18.4-beta5 specifier: 1.18.4-beta5
version: 1.18.4-beta5 version: 1.18.4-beta5
monaco-editor: monaco-editor:
specifier: ^0.47.0 specifier: ^0.48.0
version: 0.47.0 version: 0.48.0
monaco-yaml: monaco-yaml:
specifier: ^5.1.1 specifier: ^5.1.1
version: 5.1.1(monaco-editor@0.47.0) version: 5.1.1(monaco-editor@0.48.0)
nanoid: nanoid:
specifier: ^5.0.7 specifier: ^5.0.7
version: 5.0.7 version: 5.0.7
@ -109,6 +109,9 @@ importers:
tar: tar:
specifier: ^6.2.1 specifier: ^6.2.1
version: 6.2.1 version: 6.2.1
types-pac:
specifier: ^1.0.2
version: 1.0.2
devDependencies: devDependencies:
"@actions/github": "@actions/github":
specifier: ^5.1.1 specifier: ^5.1.1
@ -172,7 +175,7 @@ importers:
version: 5.2.11(@types/node@20.12.10)(sass@1.77.0) version: 5.2.11(@types/node@20.12.10)(sass@1.77.0)
vite-plugin-monaco-editor: vite-plugin-monaco-editor:
specifier: ^1.1.0 specifier: ^1.1.0
version: 1.1.0(monaco-editor@0.47.0) version: 1.1.0(monaco-editor@0.48.0)
vite-plugin-svgr: vite-plugin-svgr:
specifier: ^4.2.0 specifier: ^4.2.0
version: 4.2.0(rollup@4.17.2)(typescript@5.4.5)(vite@5.2.11(@types/node@20.12.10)(sass@1.77.0)) version: 4.2.0(rollup@4.17.2)(typescript@5.4.5)(vite@5.2.11(@types/node@20.12.10)(sass@1.77.0))
@ -2626,10 +2629,10 @@ packages:
engines: { node: ">=10" } engines: { node: ">=10" }
hasBin: true hasBin: true
monaco-editor@0.47.0: monaco-editor@0.48.0:
resolution: resolution:
{ {
integrity: sha512-VabVvHvQ9QmMwXu4du008ZDuyLnHs9j7ThVFsiJoXSOQk18+LF89N4ADzPbFenm0W4V2bGHnFBztIRQTgBfxzw==, integrity: sha512-goSDElNqFfw7iDHMg8WDATkfcyeLTNpBHQpO8incK6p5qZt5G/1j41X0xdGzpIkGojGXM+QiRQyLjnfDVvrpwA==,
} }
monaco-languageserver-types@0.3.3: monaco-languageserver-types@0.3.3:
@ -3296,6 +3299,12 @@ packages:
} }
engines: { node: ">=0.6.11 <=0.7.0 || >=0.7.3" } engines: { node: ">=0.6.11 <=0.7.0 || >=0.7.3" }
types-pac@1.0.2:
resolution:
{
integrity: sha512-9zOLBtvgzEesEgpkJPrrh+uGTzSdNcYA+gk1jv3+14ytTsuxnunBko98OgbCCgUfcMzraEi4h+3zPrZaPoEsQg==,
}
typescript@5.4.5: typescript@5.4.5:
resolution: resolution:
{ {
@ -5125,7 +5134,7 @@ snapshots:
mkdirp@1.0.4: {} mkdirp@1.0.4: {}
monaco-editor@0.47.0: {} monaco-editor@0.48.0: {}
monaco-languageserver-types@0.3.3: monaco-languageserver-types@0.3.3:
dependencies: dependencies:
@ -5139,19 +5148,19 @@ snapshots:
monaco-types@0.1.0: {} monaco-types@0.1.0: {}
monaco-worker-manager@2.0.1(monaco-editor@0.47.0): monaco-worker-manager@2.0.1(monaco-editor@0.48.0):
dependencies: dependencies:
monaco-editor: 0.47.0 monaco-editor: 0.48.0
monaco-yaml@5.1.1(monaco-editor@0.47.0): monaco-yaml@5.1.1(monaco-editor@0.48.0):
dependencies: dependencies:
"@types/json-schema": 7.0.15 "@types/json-schema": 7.0.15
jsonc-parser: 3.2.1 jsonc-parser: 3.2.1
monaco-editor: 0.47.0 monaco-editor: 0.48.0
monaco-languageserver-types: 0.3.3 monaco-languageserver-types: 0.3.3
monaco-marker-data-provider: 1.2.2 monaco-marker-data-provider: 1.2.2
monaco-types: 0.1.0 monaco-types: 0.1.0
monaco-worker-manager: 2.0.1(monaco-editor@0.47.0) monaco-worker-manager: 2.0.1(monaco-editor@0.48.0)
path-browserify: 1.0.1 path-browserify: 1.0.1
prettier: 2.8.8 prettier: 2.8.8
vscode-languageserver-textdocument: 1.0.11 vscode-languageserver-textdocument: 1.0.11
@ -5514,6 +5523,8 @@ snapshots:
tunnel@0.0.6: {} tunnel@0.0.6: {}
types-pac@1.0.2: {}
typescript@5.4.5: {} typescript@5.4.5: {}
undici-types@5.26.5: {} undici-types@5.26.5: {}
@ -5586,9 +5597,9 @@ snapshots:
unist-util-stringify-position: 4.0.0 unist-util-stringify-position: 4.0.0
vfile-message: 4.0.2 vfile-message: 4.0.2
vite-plugin-monaco-editor@1.1.0(monaco-editor@0.47.0): vite-plugin-monaco-editor@1.1.0(monaco-editor@0.48.0):
dependencies: dependencies:
monaco-editor: 0.47.0 monaco-editor: 0.48.0
vite-plugin-svgr@4.2.0(rollup@4.17.2)(typescript@5.4.5)(vite@5.2.11(@types/node@20.12.10)(sass@1.77.0)): vite-plugin-svgr@4.2.0(rollup@4.17.2)(typescript@5.4.5)(vite@5.2.11(@types/node@20.12.10)(sass@1.77.0)):
dependencies: dependencies:

View File

@ -21,6 +21,7 @@ import { configureMonacoYaml } from "monaco-yaml";
import { type JSONSchema7 } from "json-schema"; import { type JSONSchema7 } from "json-schema";
import metaSchema from "meta-json-schema/schemas/meta-json-schema.json"; import metaSchema from "meta-json-schema/schemas/meta-json-schema.json";
import mergeSchema from "meta-json-schema/schemas/clash-verge-merge-json-schema.json"; import mergeSchema from "meta-json-schema/schemas/clash-verge-merge-json-schema.json";
import pac from "types-pac/pac.d.ts?raw";
interface Props { interface Props {
mode: "profile" | "text"; mode: "profile" | "text";
@ -51,6 +52,8 @@ configureMonacoYaml(monaco, {
}, },
], ],
}); });
// PAC definition
monaco.languages.typescript.javascriptDefaults.addExtraLib(pac, "pac.d.ts");
export const EditorViewer = (props: Props) => { export const EditorViewer = (props: Props) => {
const { mode, property, open, language, schema, onClose, onChange } = props; const { mode, property, open, language, schema, onClose, onChange } = props;