feat(web): migrate from es-toolkit/compat to native es-toolkit (#30244) (#30246)

This commit is contained in:
yyh
2025-12-31 11:13:22 +08:00
committed by GitHub
parent 64dc98e607
commit 2aaaa4bd34
160 changed files with 172 additions and 169 deletions

View File

@ -2,7 +2,7 @@
import type { RefObject } from 'react'
import type { Plugin, PluginCategoryEnum } from '@/app/components/plugins/types'
import { RiArrowRightUpLine, RiSearchLine } from '@remixicon/react'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import Link from 'next/link'
import { useEffect, useImperativeHandle, useMemo, useRef } from 'react'
import { useTranslation } from 'react-i18next'

View File

@ -3,7 +3,7 @@ import type {
Edge,
OnSelectBlock,
} from './types'
import { intersection } from 'es-toolkit/compat'
import { intersection } from 'es-toolkit/array'
import {
memo,
useCallback,

View File

@ -1,7 +1,7 @@
'use client'
import type { EnvironmentVariable } from '@/app/components/workflow/types'
import { RiCloseLine, RiLock2Line } from '@remixicon/react'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import * as React from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'

View File

@ -10,9 +10,7 @@ import type { IOtherOptions } from '@/service/base'
import type { SchemaTypeDefinition } from '@/service/use-common'
import type { FlowType } from '@/types/common'
import type { VarInInspect } from '@/types/workflow'
import {
noop,
} from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { useContext } from 'react'
import {
useStore as useZustandStore,

View File

@ -3,7 +3,7 @@ import type {
Node,
} from '../types'
import ELK from 'elkjs/lib/elk.bundled.js'
import { cloneDeep } from 'es-toolkit/compat'
import { cloneDeep } from 'es-toolkit/object'
import { useCallback } from 'react'
import {
useReactFlow,

View File

@ -13,7 +13,7 @@ import type { VarInInspect } from '@/types/workflow'
import {
useEventListener,
} from 'ahooks'
import { isEqual } from 'es-toolkit/compat'
import { isEqual } from 'es-toolkit/predicate'
import { setAutoFreeze } from 'immer'
import dynamic from 'next/dynamic'
import {

View File

@ -4,7 +4,7 @@ import type { NodeOutPutVar } from '../../../types'
import type { ToolVarInputs } from '../../tool/types'
import type { CredentialFormSchema, CredentialFormSchemaNumberInput, CredentialFormSchemaTextInput } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { PluginMeta } from '@/app/components/plugins/types'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import Link from 'next/link'
import { memo } from 'react'
import { useTranslation } from 'react-i18next'

View File

@ -1,7 +1,7 @@
'use client'
import type { FC } from 'react'
import Editor, { loader } from '@monaco-editor/react'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import * as React from 'react'
import { useEffect, useMemo, useRef, useState } from 'react'
import {

View File

@ -1,6 +1,6 @@
'use client'
import type { FC } from 'react'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import * as React from 'react'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'

View File

@ -5,7 +5,7 @@ import type {
NodeOutPutVar,
} from '@/app/components/workflow/types'
import { useBoolean } from 'ahooks'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import * as React from 'react'
import { useEffect } from 'react'
import { useTranslation } from 'react-i18next'

View File

@ -1,7 +1,7 @@
import type {
Node,
} from '../../../../types'
import { isEqual } from 'es-toolkit/compat'
import { isEqual } from 'es-toolkit/predicate'
import { memo, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import {

View File

@ -3,7 +3,7 @@ import type {
OnSelectBlock,
} from '@/app/components/workflow/types'
import { RiMoreFill } from '@remixicon/react'
import { intersection } from 'es-toolkit/compat'
import { intersection } from 'es-toolkit/array'
import {
useCallback,
} from 'react'

View File

@ -2,7 +2,7 @@ import type {
Node,
OnSelectBlock,
} from '@/app/components/workflow/types'
import { intersection } from 'es-toolkit/compat'
import { intersection } from 'es-toolkit/array'
import {
memo,
useCallback,

View File

@ -33,7 +33,8 @@ import type {
import type { PromptItem } from '@/models/debug'
import type { RAGPipelineVariable } from '@/models/pipeline'
import type { SchemaTypeDefinition } from '@/service/use-common'
import { isArray, uniq } from 'es-toolkit/compat'
import { uniq } from 'es-toolkit/array'
import { isArray } from 'es-toolkit/compat'
import { produce } from 'immer'
import {
AGENT_OUTPUT_STRUCT,

View File

@ -11,7 +11,7 @@ import {
RiLoader4Line,
RiMoreLine,
} from '@remixicon/react'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { produce } from 'immer'
import * as React from 'react'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'

View File

@ -4,7 +4,7 @@ import type { StructuredOutput } from '../../../llm/types'
import type { Field } from '@/app/components/workflow/nodes/llm/types'
import type { NodeOutPutVar, ValueSelector, Var } from '@/app/components/workflow/types'
import { useHover } from 'ahooks'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import * as React from 'react'
import { useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'

View File

@ -3,7 +3,7 @@ import {
RiErrorWarningFill,
RiMoreLine,
} from '@remixicon/react'
import { capitalize } from 'es-toolkit/compat'
import { capitalize } from 'es-toolkit/string'
import { memo } from 'react'
import Tooltip from '@/app/components/base/tooltip'
import { cn } from '@/utils/classnames'

View File

@ -1,7 +1,8 @@
import type { CommonNodeType, InputVar, TriggerNodeType, ValueSelector, Var, Variable } from '@/app/components/workflow/types'
import type { FlowType } from '@/types/common'
import type { NodeRunResult, NodeTracing } from '@/types/workflow'
import { noop, unionBy } from 'es-toolkit/compat'
import { unionBy } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { produce } from 'immer'
import { useCallback, useEffect, useRef, useState } from 'react'

View File

@ -3,7 +3,7 @@ import type { FC } from 'react'
import type { AssignerNodeOperation } from '../../types'
import type { ValueSelector, Var } from '@/app/components/workflow/types'
import { RiDeleteBinLine } from '@remixicon/react'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { produce } from 'immer'
import * as React from 'react'
import { useCallback } from 'react'

View File

@ -4,7 +4,7 @@ import type {
} from '@/app/components/workflow/types'
import { RiArrowDownSLine } from '@remixicon/react'
import { useBoolean } from 'ahooks'
import { capitalize } from 'es-toolkit/compat'
import { capitalize } from 'es-toolkit/string'
import {
memo,
useCallback,

View File

@ -7,7 +7,7 @@ import {
RiDeleteBinLine,
RiDraggable,
} from '@remixicon/react'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import * as React from 'react'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'

View File

@ -2,7 +2,7 @@ import type { ErrorHandleMode, ValueSelector, Var } from '../../types'
import type { IterationNodeType } from './types'
import type { Item } from '@/app/components/base/select'
import type { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
import { isEqual } from 'es-toolkit/compat'
import { isEqual } from 'es-toolkit/predicate'
import { produce } from 'immer'
import { useCallback } from 'react'
import {

View File

@ -1,5 +1,5 @@
import { RiArrowDownSLine } from '@remixicon/react'
import { capitalize } from 'es-toolkit/compat'
import { capitalize } from 'es-toolkit/string'
import { useState } from 'react'
import Button from '@/app/components/base/button'
import {

View File

@ -1,5 +1,5 @@
import type { MetadataShape } from '@/app/components/workflow/nodes/knowledge-retrieval/types'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import {
useCallback,
useState,

View File

@ -9,7 +9,7 @@ import type {
MultipleRetrievalConfig,
} from './types'
import type { DataSet } from '@/models/datasets'
import { isEqual } from 'es-toolkit/compat'
import { isEqual } from 'es-toolkit/predicate'
import { produce } from 'immer'
import {
useCallback,

View File

@ -3,10 +3,8 @@ import type {
DataSet,
SelectedDatasetsMode,
} from '@/models/datasets'
import {
uniq,
xorBy,
} from 'es-toolkit/compat'
import { uniq } from 'es-toolkit/array'
import { xorBy } from 'es-toolkit/compat'
import { DATASET_DEFAULT } from '@/config'
import {
DEFAULT_WEIGHTED_SCORE,

View File

@ -1,4 +1,4 @@
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import {
createContext,
useContext,

View File

@ -1,7 +1,7 @@
import type { VisualEditorProps } from '.'
import type { Field } from '../../../types'
import type { EditData } from './edit-card'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { produce } from 'immer'
import Toast from '@/app/components/base/toast'
import { ArrayType, Type } from '../../../types'

View File

@ -2,7 +2,7 @@ import type { RefObject } from 'react'
import type { LLMNodeType } from './types'
import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form'
import type { InputVar, PromptItem, Var, Variable } from '@/app/components/workflow/types'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { InputVarType, VarType } from '@/app/components/workflow/types'

View File

@ -4,7 +4,7 @@ import type {
} from '@/app/components/workflow/types'
import { RiArrowDownSLine } from '@remixicon/react'
import { useBoolean } from 'ahooks'
import { capitalize } from 'es-toolkit/compat'
import { capitalize } from 'es-toolkit/string'
import {
memo,
useCallback,

View File

@ -2,7 +2,7 @@ import type { RefObject } from 'react'
import type { ParameterExtractorNodeType } from './types'
import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form'
import type { InputVar, Var, Variable } from '@/app/components/workflow/types'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { InputVarType, VarType } from '@/app/components/workflow/types'

View File

@ -3,7 +3,7 @@ import type { FC } from 'react'
import type { Topic } from '@/app/components/workflow/nodes/question-classifier/types'
import type { ValueSelector, Var } from '@/app/components/workflow/types'
import { RiDraggable } from '@remixicon/react'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { produce } from 'immer'
import * as React from 'react'
import { useCallback, useEffect, useRef, useState } from 'react'

View File

@ -2,7 +2,7 @@ import type { RefObject } from 'react'
import type { QuestionClassifierNodeType } from './types'
import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form'
import type { InputVar, Var, Variable } from '@/app/components/workflow/types'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { InputVarType, VarType } from '@/app/components/workflow/types'

View File

@ -5,7 +5,7 @@ import {
RiDeleteBinLine,
} from '@remixicon/react'
import { useBoolean, useHover } from 'ahooks'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import * as React from 'react'
import { useCallback, useRef } from 'react'
import { useTranslation } from 'react-i18next'

View File

@ -4,7 +4,7 @@ import type { ToolVarInputs } from '../types'
import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { Tool } from '@/app/components/tools/types'
import type { ToolWithProvider, ValueSelector, Var } from '@/app/components/workflow/types'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { produce } from 'immer'
import * as React from 'react'
import { useCallback, useState } from 'react'

View File

@ -1,7 +1,7 @@
'use client'
import type { FC } from 'react'
import type { ValueSelector, Var } from '@/app/components/workflow/types'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { produce } from 'immer'
import * as React from 'react'
import { useCallback } from 'react'

View File

@ -11,7 +11,7 @@ import {
RiLinkUnlinkM,
} from '@remixicon/react'
import { useClickAway } from 'ahooks'
import { escape } from 'es-toolkit/compat'
import { escape } from 'es-toolkit/string'
import {
memo,
useEffect,

View File

@ -5,7 +5,7 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
import {
mergeRegister,
} from '@lexical/utils'
import { escape } from 'es-toolkit/compat'
import { escape } from 'es-toolkit/string'
import {
CLICK_COMMAND,
COMMAND_PRIORITY_LOW,

View File

@ -1,6 +1,6 @@
import type { ConversationVariable } from '@/app/components/workflow/types'
import { RiDeleteBinLine, RiEditLine } from '@remixicon/react'
import { capitalize } from 'es-toolkit/compat'
import { capitalize } from 'es-toolkit/string'
import { memo, useState } from 'react'
import { BubbleX } from '@/app/components/base/icons/src/vender/line/others'
import { cn } from '@/utils/classnames'

View File

@ -5,7 +5,8 @@ import type {
import { RiCloseLine } from '@remixicon/react'
import { useMount } from 'ahooks'
import copy from 'copy-to-clipboard'
import { capitalize, noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import { capitalize } from 'es-toolkit/string'
import * as React from 'react'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'

View File

@ -1,7 +1,8 @@
import type { StartNodeType } from '../../nodes/start/types'
import { RiCloseLine, RiEqualizer2Line } from '@remixicon/react'
import { debounce, noop } from 'es-toolkit/compat'
import { debounce } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import {
memo,
useCallback,

View File

@ -1,6 +1,6 @@
import type { EnvironmentVariable } from '@/app/components/workflow/types'
import { RiDeleteBinLine, RiEditLine, RiLock2Line } from '@remixicon/react'
import { capitalize } from 'es-toolkit/compat'
import { capitalize } from 'es-toolkit/string'
import { memo, useState } from 'react'
import { Env } from '@/app/components/base/icons/src/vender/line/others'
import { useStore } from '@/app/components/workflow/store'

View File

@ -1,5 +1,5 @@
import type { GlobalVariable } from '@/app/components/workflow/types'
import { capitalize } from 'es-toolkit/compat'
import { capitalize } from 'es-toolkit/string'
import { memo } from 'react'
import { GlobalVariable as GlobalVariableIcon } from '@/app/components/base/icons/src/vender/line/others'

View File

@ -1,5 +1,5 @@
import type { AgentLogItem, AgentLogItemWithChildren, NodeTracing } from '@/types/workflow'
import { cloneDeep } from 'es-toolkit/compat'
import { cloneDeep } from 'es-toolkit/object'
import { BlockEnum } from '@/app/components/workflow/types'
const supportedAgentLogNodes = [BlockEnum.Agent, BlockEnum.Tool]

View File

@ -1,5 +1,5 @@
import type { NodeTracing } from '@/types/workflow'
import { cloneDeep } from 'es-toolkit/compat'
import { cloneDeep } from 'es-toolkit/object'
import { BlockEnum } from '../../../types'
import formatAgentNode from './agent'
import { addChildrenToIterationNode } from './iteration'

View File

@ -1,4 +1,4 @@
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import format from '.'
import graphToLogStruct from '../graph-to-log-struct'

View File

@ -1,4 +1,4 @@
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import format from '.'
import graphToLogStruct from '../graph-to-log-struct'

View File

@ -5,7 +5,7 @@ import type {
Node,
} from '@/app/components/workflow/types'
import ELK from 'elkjs/lib/elk.bundled.js'
import { cloneDeep } from 'es-toolkit/compat'
import { cloneDeep } from 'es-toolkit/object'
import {
CUSTOM_NODE,
NODE_LAYOUT_HORIZONTAL_PADDING,

View File

@ -7,9 +7,7 @@ import type {
Edge,
Node,
} from '../types'
import {
cloneDeep,
} from 'es-toolkit/compat'
import { cloneDeep } from 'es-toolkit/object'
import {
getConnectedEdges,
} from 'reactflow'

View File

@ -3,7 +3,7 @@ import type { TemporalState } from 'zundo'
import type { StoreApi } from 'zustand'
import type { WorkflowHistoryEventT } from './hooks'
import type { Edge, Node } from './types'
import { noop } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
import isDeepEqual from 'fast-deep-equal'
import { createContext, useContext, useMemo, useState } from 'react'
import { temporal } from 'zundo'