From 45d4f0e89cc38c4c680bb2915d8525fd834bf214 Mon Sep 17 00:00:00 2001 From: Slinetrac Date: Sat, 29 Nov 2025 15:10:41 +0800 Subject: [PATCH] chore: remove meta-json-schema #5656 #5478 --- package.json | 3 -- pnpm-lock.yaml | 20 ----------- pnpm-workspace.yaml | 1 - src/components/profile/editor-viewer.tsx | 35 +++---------------- src/components/profile/profile-item.tsx | 2 -- src/components/profile/profile-more.tsx | 1 - src/components/setting/mods/config-viewer.tsx | 1 - 7 files changed, 4 insertions(+), 59 deletions(-) diff --git a/package.json b/package.json index 2cc34370d..ac628ab42 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 52e626e16..dc3407f67 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 53065f925..97a7be15c 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -4,5 +4,4 @@ onlyBuiltDependencies: - core-js - es5-ext - esbuild - - meta-json-schema - unrs-resolver diff --git a/src/components/profile/editor-viewer.tsx b/src/components/profile/editor-viewer.tsx index d876fcc28..6ab2e0ae8 100644 --- a/src/components/profile/editor-viewer.tsx +++ b/src/components/profile/editor-viewer.tsx @@ -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 = LanguageSchemaMap[T]; -interface LanguageSchemaMap { - yaml: "clash" | "merge"; - javascript: never; - css: never; -} interface Props { open: boolean; @@ -47,11 +38,10 @@ interface Props { // 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 | (() => Promise); - // 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; onChange?: (prev?: string, curr?: string) => void; onSave?: (prev?: string, curr?: string) => void | Promise; 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 = (props: Props) => { dataKey, readOnly = false, language = "yaml", - schema, onChange, onSave, onClose, @@ -261,9 +236,8 @@ export const EditorViewer = (props: Props) => { 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 = (props: Props) => { 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 = (props: Props) => { 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) => { diff --git a/src/components/profile/profile-item.tsx b/src/components/profile/profile-item.tsx index 7393ea50e..800c10238 100644 --- a/src/components/profile/profile-item.tsx +++ b/src/components/profile/profile-item.tsx @@ -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); diff --git a/src/components/profile/profile-more.tsx b/src/components/profile/profile-more.tsx index 896d54e67..10d9017ab 100644 --- a/src/components/profile/profile-more.tsx +++ b/src/components/profile/profile-more.tsx @@ -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); diff --git a/src/components/setting/mods/config-viewer.tsx b/src/components/setting/mods/config-viewer.tsx index d10ed2001..f71d809e7 100644 --- a/src/components/setting/mods/config-viewer.tsx +++ b/src/components/setting/mods/config-viewer.tsx @@ -35,7 +35,6 @@ export const ConfigViewer = forwardRef((_, ref) => { dataKey="runtime-config" readOnly language="yaml" - schema="clash" onClose={() => setOpen(false)} /> );