diff --git a/packages/g6-extension-react/__tests__/demos/react-node.tsx b/packages/g6-extension-react/__tests__/demos/react-node.tsx index 597f4ef84a..316acba96b 100644 --- a/packages/g6-extension-react/__tests__/demos/react-node.tsx +++ b/packages/g6-extension-react/__tests__/demos/react-node.tsx @@ -1,5 +1,5 @@ import { DatabaseFilled } from '@ant-design/icons'; -import type { Graph as G6Graph, G6Spec, NodeData } from '@antv/g6'; +import type { Graph as G6Graph, GraphOptions, NodeData } from '@antv/g6'; import { ExtensionCategory, register } from '@antv/g6'; import { Badge, Button, Flex, Form, Input, Layout, Select, Table, Tag, Typography } from 'antd'; import { useRef, useState } from 'react'; @@ -60,7 +60,7 @@ export const ReactNodeDemo = () => { ); }; - const [options, setOptions] = useState({ + const [options, setOptions] = useState({ data: { nodes: [ { diff --git a/packages/g6-extension-react/src/graph/graph.tsx b/packages/g6-extension-react/src/graph/graph.tsx index 555daa1134..4c677ca886 100644 --- a/packages/g6-extension-react/src/graph/graph.tsx +++ b/packages/g6-extension-react/src/graph/graph.tsx @@ -1,9 +1,9 @@ -import type { G6Spec } from '@antv/g6'; +import type { GraphOptions } from '@antv/g6'; import { Graph as G6Graph } from '@antv/g6'; import { useEffect, useRef } from 'react'; export interface GraphProps { - options: G6Spec; + options: GraphOptions; onRender?: (graph: G6Graph) => void; onDestroy?: () => void; } diff --git a/packages/g6/__tests__/demos/animation-element-position.ts b/packages/g6/__tests__/demos/animation-element-position.ts index f81dc89886..a4ce7de5b2 100644 --- a/packages/g6/__tests__/demos/animation-element-position.ts +++ b/packages/g6/__tests__/demos/animation-element-position.ts @@ -1,8 +1,8 @@ -import type { G6Spec } from '@/src'; +import type { GraphOptions } from '@/src'; import { Graph } from '@/src'; export const animationElementPosition: TestCase = async (context) => { - const options: G6Spec = { + const options: GraphOptions = { ...context, data: { nodes: [ diff --git a/packages/g6/__tests__/demos/animation-element-state-switch.ts b/packages/g6/__tests__/demos/animation-element-state-switch.ts index 68cc861f08..631823275c 100644 --- a/packages/g6/__tests__/demos/animation-element-state-switch.ts +++ b/packages/g6/__tests__/demos/animation-element-state-switch.ts @@ -1,8 +1,8 @@ -import type { G6Spec } from '@/src'; +import type { GraphOptions } from '@/src'; import { Graph } from '@/src'; export const animationElementStateSwitch: TestCase = async (context) => { - const options: G6Spec = { + const options: GraphOptions = { ...context, data: { nodes: [ diff --git a/packages/g6/__tests__/demos/animation-element-style-position.ts b/packages/g6/__tests__/demos/animation-element-style-position.ts index df6959be97..2735f8300d 100644 --- a/packages/g6/__tests__/demos/animation-element-style-position.ts +++ b/packages/g6/__tests__/demos/animation-element-style-position.ts @@ -1,7 +1,7 @@ -import { Graph, type G6Spec } from '@/src'; +import { Graph, type GraphOptions } from '@/src'; export const animationElementStylePosition: TestCase = async (context) => { - const options: G6Spec = { + const options: GraphOptions = { ...context, data: { nodes: [ diff --git a/packages/g6/__tests__/demos/layout-forceatlas2-wasm.ts b/packages/g6/__tests__/demos/layout-forceatlas2-wasm.ts index 35ddfc5947..2e68e5553d 100644 --- a/packages/g6/__tests__/demos/layout-forceatlas2-wasm.ts +++ b/packages/g6/__tests__/demos/layout-forceatlas2-wasm.ts @@ -1,4 +1,4 @@ -import type { G6Spec } from '@/src'; +import type { GraphOptions } from '@/src'; import { Graph, register } from '@/src'; import data from '@@/dataset/soccer.json'; @@ -9,7 +9,7 @@ export const layoutForceatlas2WASM: TestCase = async (context) => { const supported = await supportsThreads(); const threads = await initThreads(supported); - const options: G6Spec = { + const options: GraphOptions = { ...context, data, theme: 'light', diff --git a/packages/g6/__tests__/demos/layout-fruchterman-gpu.ts b/packages/g6/__tests__/demos/layout-fruchterman-gpu.ts index 6faa46761e..8c5662125e 100644 --- a/packages/g6/__tests__/demos/layout-fruchterman-gpu.ts +++ b/packages/g6/__tests__/demos/layout-fruchterman-gpu.ts @@ -1,11 +1,11 @@ -import type { G6Spec } from '@/src'; +import type { GraphOptions } from '@/src'; import { Graph, register } from '@/src'; import data from '@@/dataset/soccer.json'; export const layoutFruchtermanGPU: TestCase = async (context) => { register('layout', 'fruchterman-gpu', (await import('@antv/layout-gpu')).FruchtermanLayout); - const options: G6Spec = { + const options: GraphOptions = { ...context, data, theme: 'light', diff --git a/packages/g6/__tests__/demos/layout-fruchterman-wasm.ts b/packages/g6/__tests__/demos/layout-fruchterman-wasm.ts index 73a24b97b7..06ddcfd55a 100644 --- a/packages/g6/__tests__/demos/layout-fruchterman-wasm.ts +++ b/packages/g6/__tests__/demos/layout-fruchterman-wasm.ts @@ -1,4 +1,4 @@ -import type { G6Spec } from '@/src'; +import type { GraphOptions } from '@/src'; import { Graph, register } from '@/src'; import data from '@@/dataset/soccer.json'; @@ -10,7 +10,7 @@ export const layoutFruchtermanWASM: TestCase = async (context) => { const supported = await supportsThreads(); const threads = await initThreads(supported); - const options: G6Spec = { + const options: GraphOptions = { ...context, data, theme: 'light', diff --git a/packages/g6/__tests__/demos/layout-indented.ts b/packages/g6/__tests__/demos/layout-indented.ts index b4ebc3f8ad..529f8046a3 100644 --- a/packages/g6/__tests__/demos/layout-indented.ts +++ b/packages/g6/__tests__/demos/layout-indented.ts @@ -1,9 +1,9 @@ -import type { G6Spec } from '@/src'; +import type { GraphOptions } from '@/src'; import { Graph, treeToGraphData } from '@/src'; import tree from '@@/dataset/file-system.json'; export const layoutIndented: TestCase = async (context) => { - const options: G6Spec = { + const options: GraphOptions = { ...context, y: -200, zoom: 0.5, diff --git a/packages/g6/__tests__/unit/spec/index.spec.ts b/packages/g6/__tests__/unit/spec/index.spec.ts index 825af0a114..ad00c8476b 100644 --- a/packages/g6/__tests__/unit/spec/index.spec.ts +++ b/packages/g6/__tests__/unit/spec/index.spec.ts @@ -1,9 +1,9 @@ -import type { G6Spec } from '@/src'; +import type { GraphOptions } from '@/src'; import { Renderer } from '@antv/g-canvas'; describe('spec', () => { it('spec', () => { - const options: G6Spec = { + const options: GraphOptions = { width: 800, height: 600, renderer: () => new Renderer(), diff --git a/packages/g6/__tests__/utils/create.ts b/packages/g6/__tests__/utils/create.ts index f884bf93a9..22403fc5f9 100644 --- a/packages/g6/__tests__/utils/create.ts +++ b/packages/g6/__tests__/utils/create.ts @@ -1,4 +1,4 @@ -import type { G6Spec } from '@/src'; +import type { GraphOptions } from '@/src'; import { Graph } from '@/src'; import { Circle } from '@/src/elements'; import { Canvas } from '@/src/runtime/canvas'; @@ -83,7 +83,7 @@ export async function createDemoGraph(demo: TestCase, context?: Partial Get options * @returns 配置项 | options */ - public getOptions(): G6Spec { + public getOptions(): GraphOptions { return this.options; } @@ -108,7 +108,7 @@ export class Graph extends EventEmitter { * * To update devicePixelRatio and container properties, please destroy and recreate the instance */ - public setOptions(options: G6Spec): void { + public setOptions(options: GraphOptions): void { const { animation, background, @@ -147,12 +147,12 @@ export class Graph extends EventEmitter { if (isNumber(padding) || isArray(padding)) this.options.padding = padding; } - public setBackground(background: G6Spec['background']): void { + public setBackground(background: GraphOptions['background']): void { this.options.background = background; this.context.canvas?.setBackground(background); } - public getBackground(): G6Spec['background'] { + public getBackground(): GraphOptions['background'] { return this.options.background; } @@ -166,11 +166,11 @@ export class Graph extends EventEmitter { this.options.height = height; } - public setZoomRange(zoomRange: G6Spec['zoomRange']): void { + public setZoomRange(zoomRange: GraphOptions['zoomRange']): void { this.options.zoomRange = zoomRange; } - public getZoomRange(): G6Spec['zoomRange'] { + public getZoomRange(): GraphOptions['zoomRange'] { return this.options.zoomRange; } diff --git a/packages/g6/src/runtime/types.ts b/packages/g6/src/runtime/types.ts index 33370e60fa..36ba45d4c1 100644 --- a/packages/g6/src/runtime/types.ts +++ b/packages/g6/src/runtime/types.ts @@ -1,4 +1,4 @@ -import type { G6Spec } from '../spec'; +import type { GraphOptions } from '../spec'; import type { BatchController } from './batch'; import type { BehaviorController } from './behavior'; import type { Canvas } from './canvas'; @@ -28,7 +28,7 @@ export interface RuntimeContext { * * G6 options */ - options: G6Spec; + options: GraphOptions; /** * 数据模型 * diff --git a/packages/g6/src/spec/spec.ts b/packages/g6/src/spec/graph.ts similarity index 93% rename from packages/g6/src/spec/spec.ts rename to packages/g6/src/spec/graph.ts index c033201f1b..0024d1f10d 100644 --- a/packages/g6/src/spec/spec.ts +++ b/packages/g6/src/spec/graph.ts @@ -12,12 +12,12 @@ import type { TransformOptions } from './transform'; import type { ViewportOptions } from './viewport'; /** - * Spec 定义 + * Graph 配置项 * - * Specification definition + * Graph options */ -export interface G6Spec extends CanvasOptions, ViewportOptions { +export interface GraphOptions extends CanvasOptions, ViewportOptions { /** * 启用关闭、全局动画 * diff --git a/packages/g6/src/spec/index.ts b/packages/g6/src/spec/index.ts index 550846d6e8..e2098da2f7 100644 --- a/packages/g6/src/spec/index.ts +++ b/packages/g6/src/spec/index.ts @@ -4,9 +4,9 @@ export type { ComboData, EdgeData, GraphData, NodeData } from './data'; export type { ComboOptions } from './element/combo'; export type { EdgeOptions } from './element/edge'; export type { NodeOptions } from './element/node'; +export type { GraphOptions } from './graph'; export type { LayoutOptions } from './layout'; export type { PluginOptions } from './plugin'; -export type { G6Spec } from './spec'; export type { ThemeOptions } from './theme'; export type { TransformOptions } from './transform'; export type { ViewportOptions } from './viewport'; diff --git a/packages/g6/src/utils/animation.ts b/packages/g6/src/utils/animation.ts index 2ea12fb7f7..1fe0577d22 100644 --- a/packages/g6/src/utils/animation.ts +++ b/packages/g6/src/utils/animation.ts @@ -1,7 +1,7 @@ import type { DisplayObject, IAnimation } from '@antv/g'; import { isEqual, isNil, isObject } from '@antv/util'; import { DEFAULT_ANIMATION_OPTIONS } from '../constants'; -import type { G6Spec } from '../spec'; +import type { GraphOptions } from '../spec'; import type { AnimatableTask, Keyframe } from '../types'; import { isNode } from './element'; import { getDescendantShapes } from './shape'; @@ -229,7 +229,7 @@ export function executeAnimatableTasks(tasks: AnimatableTask[], callbacks: Callb * @returns 动画配置 | animation configuration */ export function getAnimation( - options: G6Spec, + options: GraphOptions, localAnimation: boolean | EffectTiming | undefined, ): false | EffectTiming { const { animation } = options;