mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-28 07:14:40 +08:00
@@ -53,14 +53,12 @@
|
||||
"@tauri-apps/plugin-process": "^2.3.1",
|
||||
"@tauri-apps/plugin-shell": "2.3.3",
|
||||
"@tauri-apps/plugin-updater": "2.9.0",
|
||||
"@types/json-schema": "^7.0.15",
|
||||
"ahooks": "^3.9.6",
|
||||
"axios": "^1.13.2",
|
||||
"dayjs": "1.11.19",
|
||||
"foxact": "^0.2.49",
|
||||
"i18next": "^25.6.3",
|
||||
"js-yaml": "^4.1.1",
|
||||
"json-schema": "^0.4.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"monaco-editor": "^0.55.1",
|
||||
"monaco-yaml": "^5.4.0",
|
||||
@@ -107,7 +105,6 @@
|
||||
"husky": "^9.1.7",
|
||||
"jiti": "^2.6.1",
|
||||
"lint-staged": "^16.2.7",
|
||||
"meta-json-schema": "^1.19.16",
|
||||
"node-fetch": "^3.3.2",
|
||||
"prettier": "^3.7.2",
|
||||
"sass": "^1.94.2",
|
||||
|
||||
20
pnpm-lock.yaml
generated
20
pnpm-lock.yaml
generated
@@ -68,9 +68,6 @@ importers:
|
||||
'@tauri-apps/plugin-updater':
|
||||
specifier: 2.9.0
|
||||
version: 2.9.0
|
||||
'@types/json-schema':
|
||||
specifier: ^7.0.15
|
||||
version: 7.0.15
|
||||
ahooks:
|
||||
specifier: ^3.9.6
|
||||
version: 3.9.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||
@@ -89,9 +86,6 @@ importers:
|
||||
js-yaml:
|
||||
specifier: ^4.1.1
|
||||
version: 4.1.1
|
||||
json-schema:
|
||||
specifier: ^0.4.0
|
||||
version: 0.4.0
|
||||
lodash-es:
|
||||
specifier: ^4.17.21
|
||||
version: 4.17.21
|
||||
@@ -225,9 +219,6 @@ importers:
|
||||
lint-staged:
|
||||
specifier: ^16.2.7
|
||||
version: 16.2.7
|
||||
meta-json-schema:
|
||||
specifier: ^1.19.16
|
||||
version: 1.19.16
|
||||
node-fetch:
|
||||
specifier: ^3.3.2
|
||||
version: 3.3.2
|
||||
@@ -3072,9 +3063,6 @@ packages:
|
||||
json-schema-traverse@0.4.1:
|
||||
resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}
|
||||
|
||||
json-schema@0.4.0:
|
||||
resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==}
|
||||
|
||||
json-stable-stringify-without-jsonify@1.0.1:
|
||||
resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==}
|
||||
|
||||
@@ -3193,10 +3181,6 @@ packages:
|
||||
resolution: {integrity: sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
meta-json-schema@1.19.16:
|
||||
resolution: {integrity: sha512-Py3XR3VRXs3tAMg3sy7fmex8IU4p4FTxVbF86WTtssWpFcSNbBUjk0QjpdhGrh+9qPMSwCJY1drXnvgDq9XQ7Q==}
|
||||
engines: {node: '>=18', pnpm: '>=9'}
|
||||
|
||||
micromark-core-commonmark@2.0.3:
|
||||
resolution: {integrity: sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==}
|
||||
|
||||
@@ -7257,8 +7241,6 @@ snapshots:
|
||||
|
||||
json-schema-traverse@0.4.1: {}
|
||||
|
||||
json-schema@0.4.0: {}
|
||||
|
||||
json-stable-stringify-without-jsonify@1.0.1: {}
|
||||
|
||||
json5@1.0.2:
|
||||
@@ -7450,8 +7432,6 @@ snapshots:
|
||||
|
||||
meow@13.2.0: {}
|
||||
|
||||
meta-json-schema@1.19.16: {}
|
||||
|
||||
micromark-core-commonmark@2.0.3:
|
||||
dependencies:
|
||||
decode-named-character-reference: 1.1.0
|
||||
|
||||
@@ -4,5 +4,4 @@ onlyBuiltDependencies:
|
||||
- core-js
|
||||
- es5-ext
|
||||
- esbuild
|
||||
- meta-json-schema
|
||||
- unrs-resolver
|
||||
|
||||
@@ -16,9 +16,6 @@ import {
|
||||
} from "@mui/material";
|
||||
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { type JSONSchema7 } from "json-schema";
|
||||
import mergeSchema from "meta-json-schema/schemas/clash-verge-merge-json-schema.json";
|
||||
import metaSchema from "meta-json-schema/schemas/meta-json-schema.json";
|
||||
import * as monaco from "monaco-editor";
|
||||
import { configureMonacoYaml } from "monaco-yaml";
|
||||
import { nanoid } from "nanoid";
|
||||
@@ -34,12 +31,6 @@ import getSystem from "@/utils/get-system";
|
||||
const appWindow = getCurrentWebviewWindow();
|
||||
|
||||
type Language = "yaml" | "javascript" | "css";
|
||||
type Schema<T extends Language> = LanguageSchemaMap[T];
|
||||
interface LanguageSchemaMap {
|
||||
yaml: "clash" | "merge";
|
||||
javascript: never;
|
||||
css: never;
|
||||
}
|
||||
|
||||
interface Props<T extends Language> {
|
||||
open: boolean;
|
||||
@@ -47,11 +38,10 @@ interface Props<T extends Language> {
|
||||
// Initial content loader: prefer passing a stable function. A plain Promise is supported,
|
||||
// but it won't trigger background refreshes and should be paired with a stable `dataKey`.
|
||||
initialData: Promise<string> | (() => Promise<string>);
|
||||
// Logical document id; reloads when this or language/schema changes.
|
||||
// Logical document id; reloads when this or language changes.
|
||||
dataKey?: string | number;
|
||||
readOnly?: boolean;
|
||||
language: T;
|
||||
schema?: Schema<T>;
|
||||
onChange?: (prev?: string, curr?: string) => void;
|
||||
onSave?: (prev?: string, curr?: string) => void | Promise<void>;
|
||||
onClose: () => void;
|
||||
@@ -61,24 +51,10 @@ let initialized = false;
|
||||
const monacoInitialization = () => {
|
||||
if (initialized) return;
|
||||
|
||||
// YAML worker and schemas
|
||||
// YAML worker setup
|
||||
configureMonacoYaml(monaco, {
|
||||
validate: true,
|
||||
enableSchemaRequest: true,
|
||||
schemas: [
|
||||
{
|
||||
uri: "http://example.com/meta-json-schema.json",
|
||||
fileMatch: ["**/*.clash.yaml"],
|
||||
// @ts-expect-error -- meta schema JSON import does not satisfy JSONSchema7 at compile time
|
||||
schema: metaSchema as JSONSchema7,
|
||||
},
|
||||
{
|
||||
uri: "http://example.com/clash-verge-merge-json-schema.json",
|
||||
fileMatch: ["**/*.merge.yaml"],
|
||||
// @ts-expect-error -- merge schema JSON import does not satisfy JSONSchema7 at compile time
|
||||
schema: mergeSchema as JSONSchema7,
|
||||
},
|
||||
],
|
||||
});
|
||||
// PAC type definitions for JS suggestions
|
||||
monaco.typescript.javascriptDefaults.addExtraLib(pac, "pac.d.ts");
|
||||
@@ -98,7 +74,6 @@ export const EditorViewer = <T extends Language>(props: Props<T>) => {
|
||||
dataKey,
|
||||
readOnly = false,
|
||||
language = "yaml",
|
||||
schema,
|
||||
onChange,
|
||||
onSave,
|
||||
onClose,
|
||||
@@ -261,9 +236,8 @@ export const EditorViewer = <T extends Language>(props: Props<T>) => {
|
||||
currData.current = data;
|
||||
|
||||
setInitialText(data);
|
||||
// Build a path that matches YAML schemas when applicable, and avoids "undefined" in name
|
||||
// Build a stable model path and avoid "undefined" in the name
|
||||
const pathParts = [String(dataKey ?? nanoid()), instanceIdRef.current];
|
||||
if (schema) pathParts.push(String(schema));
|
||||
pathParts.push(language);
|
||||
|
||||
setModelPath(pathParts.join("."));
|
||||
@@ -282,7 +256,6 @@ export const EditorViewer = <T extends Language>(props: Props<T>) => {
|
||||
|
||||
setInitialText("");
|
||||
const pathParts = [String(dataKey ?? nanoid()), instanceIdRef.current];
|
||||
if (schema) pathParts.push(String(schema));
|
||||
pathParts.push(language);
|
||||
|
||||
setModelPath(pathParts.join("."));
|
||||
@@ -297,7 +270,7 @@ export const EditorViewer = <T extends Language>(props: Props<T>) => {
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [open, dataKey, language, schema]);
|
||||
}, [open, dataKey, language]);
|
||||
/* eslint-enable @eslint-react/hooks-extra/no-direct-set-state-in-use-effect */
|
||||
|
||||
const onMount = async (editor: monaco.editor.IStandaloneCodeEditor) => {
|
||||
|
||||
@@ -834,7 +834,6 @@ export const ProfileItem = (props: Props) => {
|
||||
initialData={() => readProfileFile(uid)}
|
||||
dataKey={uid}
|
||||
language="yaml"
|
||||
schema="clash"
|
||||
onSave={async (prev, curr) => {
|
||||
await saveProfileFile(uid, curr ?? "");
|
||||
onSave?.(prev, curr);
|
||||
@@ -881,7 +880,6 @@ export const ProfileItem = (props: Props) => {
|
||||
initialData={() => readProfileFile(option?.merge ?? "")}
|
||||
dataKey={`merge:${option?.merge ?? ""}`}
|
||||
language="yaml"
|
||||
schema="merge"
|
||||
onSave={async (prev, curr) => {
|
||||
await saveProfileFile(option?.merge ?? "", curr ?? "");
|
||||
onSave?.(prev, curr);
|
||||
|
||||
@@ -184,7 +184,6 @@ export const ProfileMore = (props: Props) => {
|
||||
initialData={() => readProfileFile(id)}
|
||||
dataKey={id}
|
||||
language={id === "Merge" ? "yaml" : "javascript"}
|
||||
schema={id === "Merge" ? "merge" : undefined}
|
||||
onSave={async (prev, curr) => {
|
||||
await saveProfileFile(id, curr ?? "");
|
||||
onSave?.(prev, curr);
|
||||
|
||||
@@ -35,7 +35,6 @@ export const ConfigViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
dataKey="runtime-config"
|
||||
readOnly
|
||||
language="yaml"
|
||||
schema="clash"
|
||||
onClose={() => setOpen(false)}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user