Revert "fix: update js-yaml imports for v5"

This reverts commit 250198d547.

Revert "chore(deps): update dependency js-yaml to v5 (#7331)"

This reverts commit b44f671fc2.
This commit is contained in:
Tunglies
2026-06-29 05:17:04 +08:00
parent 250198d547
commit 3a4cd2c361
7 changed files with 40 additions and 48 deletions
+1 -1
View File
@@ -58,7 +58,7 @@
"foxact": "^0.3.4",
"foxts": "^5.4.2",
"i18next": "^26.2.0",
"js-yaml": "^5.0.0",
"js-yaml": "^4.1.1",
"lodash-es": "^4.18.1",
"meta-json-schema": "^1.19.25",
"monaco-editor": "^0.55.1",
+2 -10
View File
@@ -81,8 +81,8 @@ importers:
specifier: ^26.2.0
version: 26.2.0(typescript@6.0.3)
js-yaml:
specifier: ^5.0.0
version: 5.1.0
specifier: ^4.1.1
version: 4.1.1
lodash-es:
specifier: ^4.18.1
version: 4.18.1
@@ -2659,10 +2659,6 @@ packages:
resolution: {integrity: sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==}
hasBin: true
js-yaml@5.1.0:
resolution: {integrity: sha512-s8VA5jkR8f22S3NAXmhKPFqGUduqZGlsufabVOgN14iTdw/RXcym7bKkbwjxLK9Yw2lEvvmJjFp119+KPeo8Kg==}
hasBin: true
jsesc@3.1.0:
resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==}
engines: {node: '>=6'}
@@ -6229,10 +6225,6 @@ snapshots:
dependencies:
argparse: 2.0.1
js-yaml@5.1.0:
dependencies:
argparse: 2.0.1
jsesc@3.1.0: {}
json-buffer@3.0.1: {}
+11 -11
View File
@@ -32,7 +32,7 @@ import {
cancelIdleCallback,
requestIdleCallback,
} from 'foxact/request-idle-callback'
import { dump, load } from 'js-yaml'
import yaml from 'js-yaml'
import {
startTransition,
useCallback,
@@ -126,7 +126,7 @@ const buildGroupsYaml = (
append: IProxyGroupConfig[],
deleteList: string[],
) => {
return dump(
return yaml.dump(
{
prepend,
append,
@@ -334,7 +334,7 @@ export const GroupsEditorViewer = (props: Props) => {
}
const fetchContent = useCallback(async () => {
const data = await readProfileFile(property)
const obj = load(data) as ISeqProfileConfig | null
const obj = yaml.load(data) as ISeqProfileConfig | null
setPrependSeq(obj?.prepend || [])
setAppendSeq(obj?.append || [])
@@ -358,7 +358,7 @@ export const GroupsEditorViewer = (props: Props) => {
return
}
const obj = load(currData) as ISeqProfileConfig | null
const obj = yaml.load(currData) as ISeqProfileConfig | null
startTransition(() => {
setPrependSeq(obj?.prepend ?? [])
setAppendSeq(obj?.append ?? [])
@@ -397,13 +397,13 @@ export const GroupsEditorViewer = (props: Props) => {
const fetchProxyPolicy = useCallback(async () => {
const data = await readProfileFile(profileUid)
const proxiesData = await readProfileFile(proxiesUid)
const originGroupsObj = load(data) as {
const originGroupsObj = yaml.load(data) as {
'proxy-groups': IProxyGroupConfig[]
} | null
const originProxiesObj = load(data) as { proxies: [] } | null
const originProxiesObj = yaml.load(data) as { proxies: [] } | null
const originProxies = originProxiesObj?.proxies || []
const moreProxiesObj = load(proxiesData) as ISeqProfileConfig | null
const moreProxiesObj = yaml.load(proxiesData) as ISeqProfileConfig | null
const morePrependProxies = moreProxiesObj?.prepend || []
const moreAppendProxies = moreProxiesObj?.append || []
const moreDeleteProxies = normalizeDeleteSeq(moreProxiesObj?.delete)
@@ -443,21 +443,21 @@ export const GroupsEditorViewer = (props: Props) => {
const mergeData = await readProfileFile(mergeUid)
const globalMergeData = await readProfileFile('Merge')
const originGroupsObj = load(data) as {
const originGroupsObj = yaml.load(data) as {
'proxy-groups': IProxyGroupConfig[]
} | null
const originProviderObj = load(data) as {
const originProviderObj = yaml.load(data) as {
'proxy-providers': Record<string, unknown>
} | null
const originProvider = originProviderObj?.['proxy-providers'] || {}
const moreProviderObj = load(mergeData) as {
const moreProviderObj = yaml.load(mergeData) as {
'proxy-providers': Record<string, unknown>
} | null
const moreProvider = moreProviderObj?.['proxy-providers'] || {}
const globalProviderObj = load(globalMergeData) as {
const globalProviderObj = yaml.load(globalMergeData) as {
'proxy-providers': Record<string, unknown>
} | null
const globalProvider = globalProviderObj?.['proxy-providers'] || {}
@@ -25,7 +25,7 @@ import {
styled,
} from '@mui/material'
import { useLockFn } from 'ahooks'
import { dump, load } from 'js-yaml'
import yaml from 'js-yaml'
import {
startTransition,
useCallback,
@@ -272,7 +272,7 @@ export const ProxiesEditorViewer = (props: Props) => {
const fetchProfile = useCallback(async () => {
const data = await readProfileFile(profileUid)
const originProxiesObj = load(data) as {
const originProxiesObj = yaml.load(data) as {
proxies: IProxyConfig[]
} | null
@@ -281,7 +281,7 @@ export const ProxiesEditorViewer = (props: Props) => {
const fetchContent = useCallback(async () => {
const data = await readProfileFile(property)
const obj = load(data) as ISeqProfileConfig | null
const obj = yaml.load(data) as ISeqProfileConfig | null
setPrependSeq(obj?.prepend || [])
setAppendSeq(obj?.append || [])
@@ -296,7 +296,7 @@ export const ProxiesEditorViewer = (props: Props) => {
return
}
const obj = load(currData) as ISeqProfileConfig | null
const obj = yaml.load(currData) as ISeqProfileConfig | null
startTransition(() => {
setPrependSeq(obj?.prepend ?? [])
setAppendSeq(obj?.append ?? [])
@@ -312,7 +312,7 @@ export const ProxiesEditorViewer = (props: Props) => {
const serialize = () => {
try {
setCurrData(
dump(
yaml.dump(
{ prepend: prependSeq, append: appendSeq, delete: deleteSeq },
{ forceQuotes: true },
),
+13 -13
View File
@@ -27,7 +27,7 @@ import {
styled,
} from '@mui/material'
import { useLockFn } from 'ahooks'
import { dump, load } from 'js-yaml'
import yaml from 'js-yaml'
import {
startTransition,
useCallback,
@@ -407,7 +407,7 @@ export const RulesEditorViewer = (props: Props) => {
}
const fetchContent = useCallback(async () => {
const data = await readProfileFile(property)
const obj = load(data) as ISeqProfileConfig | null
const obj = yaml.load(data) as ISeqProfileConfig | null
setPrependSeq(obj?.prepend || [])
setAppendSeq(obj?.append || [])
@@ -422,7 +422,7 @@ export const RulesEditorViewer = (props: Props) => {
return
}
const obj = load(currData) as ISeqProfileConfig | null
const obj = yaml.load(currData) as ISeqProfileConfig | null
startTransition(() => {
setPrependSeq(obj?.prepend ?? [])
setAppendSeq(obj?.append ?? [])
@@ -439,7 +439,7 @@ export const RulesEditorViewer = (props: Props) => {
const serialize = () => {
try {
setCurrData(
dump(
yaml.dump(
{ prepend: prependSeq, append: appendSeq, delete: deleteSeq },
{ forceQuotes: true },
),
@@ -471,13 +471,13 @@ export const RulesEditorViewer = (props: Props) => {
const mergeData = await readProfileFile(mergeUid) // merge配置文件
const globalMergeData = await readProfileFile('Merge') // global merge配置文件
const rulesObj = load(data) as { rules: [] } | null
const rulesObj = yaml.load(data) as { rules: [] } | null
const originGroupsObj = load(data) as {
const originGroupsObj = yaml.load(data) as {
'proxy-groups': IProxyGroupConfig[]
} | null
const originGroups = originGroupsObj?.['proxy-groups'] || []
const moreGroupsObj = load(groupsData) as ISeqProfileConfig | null
const moreGroupsObj = yaml.load(groupsData) as ISeqProfileConfig | null
const rawPrependGroups = moreGroupsObj?.['prepend']
const morePrependGroups = Array.isArray(rawPrependGroups)
? (rawPrependGroups as IProxyGroupConfig[])
@@ -503,29 +503,29 @@ export const RulesEditorViewer = (props: Props) => {
moreAppendGroups,
)
const originRuleSetObj = load(data) as {
const originRuleSetObj = yaml.load(data) as {
'rule-providers': Record<string, unknown>
} | null
const originRuleSet = originRuleSetObj?.['rule-providers'] || {}
const moreRuleSetObj = load(mergeData) as {
const moreRuleSetObj = yaml.load(mergeData) as {
'rule-providers': Record<string, unknown>
} | null
const moreRuleSet = moreRuleSetObj?.['rule-providers'] || {}
const globalRuleSetObj = load(globalMergeData) as {
const globalRuleSetObj = yaml.load(globalMergeData) as {
'rule-providers': Record<string, unknown>
} | null
const globalRuleSet = globalRuleSetObj?.['rule-providers'] || {}
const ruleSet = Object.assign({}, originRuleSet, moreRuleSet, globalRuleSet)
const originSubRuleObj = load(data) as {
const originSubRuleObj = yaml.load(data) as {
'sub-rules': Record<string, unknown>
} | null
const originSubRule = originSubRuleObj?.['sub-rules'] || {}
const moreSubRuleObj = load(mergeData) as {
const moreSubRuleObj = yaml.load(mergeData) as {
'sub-rules': Record<string, unknown>
} | null
const moreSubRule = moreSubRuleObj?.['sub-rules'] || {}
const globalSubRuleObj = load(globalMergeData) as {
const globalSubRuleObj = yaml.load(globalMergeData) as {
'sub-rules': Record<string, unknown>
} | null
const globalSubRule = globalSubRuleObj?.['sub-rules'] || {}
+2 -2
View File
@@ -33,7 +33,7 @@ import {
Typography,
useTheme,
} from '@mui/material'
import { load } from 'js-yaml'
import yaml from 'js-yaml'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
@@ -431,7 +431,7 @@ export const ProxyChain = ({
if (chainConfigData) {
try {
// JSON is valid YAML, so one parser covers both persisted formats.
const parsedConfig = load(chainConfigData) as ParsedChainConfig
const parsedConfig = yaml.load(chainConfigData) as ParsedChainConfig
const chainItems = toChainItems(parsedConfig)
if (chainItems.length > 0) {
+6 -6
View File
@@ -14,7 +14,7 @@ import {
} from '@mui/material'
import { invoke } from '@tauri-apps/api/core'
import { useLockFn } from 'ahooks'
import { dump, load } from 'js-yaml'
import yaml from 'js-yaml'
import type { Ref } from 'react'
import {
useCallback,
@@ -385,7 +385,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
config.hosts = hosts
}
setYamlContent(dump(config, { forceQuotes: true }))
setYamlContent(yaml.dump(config, { forceQuotes: true }))
}, [generateDnsConfig, setYamlContent, values.hosts])
// 重置为默认值
@@ -428,7 +428,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
// 从YAML更新表单值
const updateValuesFromYaml = useCallback(() => {
try {
const parsedYaml = load(yamlContent) as any
const parsedYaml = yaml.load(yamlContent) as any
if (!parsedYaml) return
skipYamlSyncRef.current = true
@@ -478,7 +478,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
if (dnsConfigExists) {
const dnsConfig = await invoke<string>('get_dns_config_content', {})
const config = load(dnsConfig) as any
const config = yaml.load(dnsConfig) as any
updateValuesFromConfig(config)
setYamlContent(dnsConfig)
@@ -524,7 +524,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
}
} else {
// 使用YAML编辑器的值
const parsedConfig = load(yamlContent)
const parsedConfig = yaml.load(yamlContent)
if (typeof parsedConfig !== 'object' || parsedConfig === null) {
throw new Error(t('settings.modals.dns.errors.invalid'))
}
@@ -594,7 +594,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
// 允许YAML编辑后立即分析和更新表单值
try {
const config = load(value || '') as any
const config = yaml.load(value || '') as any
if (config && typeof config === 'object') {
setTimeout(() => {
updateValuesFromConfig(config)