@visactor/vgrammar-core 0.13.10 → 0.13.11-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/graph/animation/animation/move.js +7 -7
- package/cjs/graph/animation/animation/move.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +2 -1
- package/cjs/index.js.map +1 -1
- package/cjs/types/animate.d.ts +1 -0
- package/cjs/types/animate.js.map +1 -1
- package/es/graph/animation/animation/move.js +7 -7
- package/es/graph/animation/animation/move.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/types/animate.d.ts +1 -0
- package/es/types/animate.js.map +1 -1
- package/package.json +4 -4
|
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
}), exports.moveOut = exports.moveIn = void 0;
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), moveIn = (element, options, animationParameters) => {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
const {offset: offset = 0, orient: orient, direction: direction, point: pointOpt} = null != options ? options : {};
|
|
8
|
+
var _a, _b, _c, _d;
|
|
9
|
+
const {offset: offset = 0, orient: orient, direction: direction, point: pointOpt, excludeChannels: excludeChannels = []} = null != options ? options : {};
|
|
10
10
|
let changedX = 0, changedY = 0;
|
|
11
11
|
"negative" === orient && (animationParameters.group ? (changedX = null !== (_a = animationParameters.groupWidth) && void 0 !== _a ? _a : animationParameters.group.getBounds().width(),
|
|
12
12
|
changedY = null !== (_b = animationParameters.groupHeight) && void 0 !== _b ? _b : animationParameters.group.getBounds().height(),
|
|
13
13
|
animationParameters.groupWidth = changedX, animationParameters.groupHeight = changedY) : (changedX = animationParameters.width,
|
|
14
14
|
changedY = animationParameters.height)), changedX += offset, changedY += offset;
|
|
15
15
|
const point = (0, vutils_1.isFunction)(pointOpt) ? pointOpt.call(null, element.getDatum(), element, animationParameters) : pointOpt, fromX = point && (0,
|
|
16
|
-
vutils_1.isValidNumber)(point.x) ? point.x : changedX, fromY = point && (0, vutils_1.isValidNumber)(point.y) ? point.y : changedY,
|
|
16
|
+
vutils_1.isValidNumber)(point.x) ? point.x : changedX, fromY = point && (0, vutils_1.isValidNumber)(point.y) ? point.y : changedY, finalAttrsX = excludeChannels.includes("x") ? element.getGraphicItem().getNormalAttribute("x") : null === (_c = element.getFinalGraphicAttributes()) || void 0 === _c ? void 0 : _c.x, finalAttrsY = excludeChannels.includes("y") ? element.getGraphicItem().getNormalAttribute("y") : null === (_d = element.getFinalGraphicAttributes()) || void 0 === _d ? void 0 : _d.y;
|
|
17
17
|
switch (direction) {
|
|
18
18
|
case "x":
|
|
19
19
|
return {
|
|
@@ -21,7 +21,7 @@ const vutils_1 = require("@visactor/vutils"), moveIn = (element, options, animat
|
|
|
21
21
|
x: fromX
|
|
22
22
|
},
|
|
23
23
|
to: {
|
|
24
|
-
x:
|
|
24
|
+
x: finalAttrsX
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -31,7 +31,7 @@ const vutils_1 = require("@visactor/vutils"), moveIn = (element, options, animat
|
|
|
31
31
|
y: fromY
|
|
32
32
|
},
|
|
33
33
|
to: {
|
|
34
|
-
y:
|
|
34
|
+
y: finalAttrsY
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -42,8 +42,8 @@ const vutils_1 = require("@visactor/vutils"), moveIn = (element, options, animat
|
|
|
42
42
|
y: fromY
|
|
43
43
|
},
|
|
44
44
|
to: {
|
|
45
|
-
x:
|
|
46
|
-
y:
|
|
45
|
+
x: finalAttrsX,
|
|
46
|
+
y: finalAttrsY
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animation/move.ts"],"names":[],"mappings":";;;AAAA,6CAA6D;AAMtD,MAAM,MAAM,GAA4B,CAC7C,OAA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IAAA,sBAAa,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACnE,MAAM,KAAK,GAAG,KAAK,IAAI,IAAA,sBAAa,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEnE,QAAQ,SAAS,EAAE;QACjB,KAAK,GAAG;YACN,OAAO;gBACL,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;gBACnD,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE;aACjB,CAAC;QACJ,KAAK,GAAG;YACN,OAAO;gBACL,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;gBACnD,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE;aACjB,CAAC;QACJ,KAAK,IAAI,CAAC;QACV;YACE,OAAO;gBACL,IAAI,EAAE;oBACJ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC;oBACzC,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC;iBAC1C;gBACD,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE;aAC3B,CAAC;KACL;AACH,CAAC,CAAC;AAtCW,QAAA,OAAO,WAsClB","file":"move.js","sourcesContent":["import { isFunction, isValidNumber } from '@visactor/vutils';\nimport type { IElement, IMoveAnimationOptions, IAnimationParameters, TypeAnimation } from '../../../types';\n\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [] } = options ?? {};\n let changedX = 0;\n let changedY = 0;\n\n if (orient === 'negative') {\n // consider the offset of group\n if (animationParameters.group) {\n changedX = (animationParameters as any).groupWidth ?? animationParameters.group.getBounds().width();\n changedY = (animationParameters as any).groupHeight ?? animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupWidth = changedX;\n (animationParameters as any).groupHeight = changedY;\n } else {\n changedX = animationParameters.width;\n changedY = animationParameters.height;\n }\n }\n\n changedX += offset;\n changedY += offset;\n const point = isFunction(pointOpt) ? pointOpt.call(null, element.getDatum(), element, animationParameters) : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n const finalAttrsX = excludeChannels.includes('x')\n ? element.getGraphicItem().getNormalAttribute('x')\n : element.getFinalGraphicAttributes()?.x;\n const finalAttrsY = excludeChannels.includes('y')\n ? element.getGraphicItem().getNormalAttribute('y')\n : element.getFinalGraphicAttributes()?.y;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: fromX },\n to: { x: finalAttrsX }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: finalAttrsY }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: finalAttrsX,\n y: finalAttrsY\n }\n };\n }\n};\n\nexport const moveOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt } = options ?? {};\n\n // consider the offset of group\n const groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null;\n const groupWidth = groupBounds?.width() ?? animationParameters.width;\n const groupHeight = groupBounds?.height() ?? animationParameters.height;\n const changedX = (orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(pointOpt) ? pointOpt.call(null, element.getDatum(), element, animationParameters) : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: element.getGraphicAttribute('x', true) },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: element.getGraphicAttribute('y', true) },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: element.getGraphicAttribute('x', true),\n y: element.getGraphicAttribute('y', true)\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -18,7 +18,8 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
20
|
}), exports.vglobal = exports.ThemeManager = exports.SIGNAL_VIEW_BOX = exports.SIGNAL_WIDTH = exports.SIGNAL_VIEW_WIDTH = exports.SIGNAL_VIEW_HEIGHT = exports.SIGNAL_PADDING = exports.SIGNAL_HEIGHT = exports.SIGNAL_AUTOFIT = exports.Factory = exports.GrammarBase = exports.invokeFunctionType = exports.parseFunctionType = exports.registerCoordinate = exports.Coordinate = exports.registerScale = exports.Scale = exports.View = exports.version = void 0,
|
|
21
|
-
exports.version = "0.13.
|
|
21
|
+
exports.version = "0.13.11-alpha.1", __exportStar(require("./graph"), exports),
|
|
22
|
+
__exportStar(require("./interactions"), exports);
|
|
22
23
|
|
|
23
24
|
var view_1 = require("./view");
|
|
24
25
|
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,0CAAwB;AAExB,iDAA+B;AAE/B,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,sCAAoD;AAA3C,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC7B,gDAAmE;AAA1D,wGAAA,UAAU,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AACvC,qCAAqE;AAA5D,yGAAA,iBAAiB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAC9C,oDAAkD;AAAzC,2GAAA,WAAW,OAAA;AACpB,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAChB,8CAQ0B;AAPxB,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,+GAAA,kBAAkB,OAAA;AAClB,8GAAA,iBAAiB,OAAA;AACjB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AAGjB,uDAAqD;AAA5C,6GAAA,YAAY,OAAA;AAErB,0CAAwB;AACxB,8CAA4B;AAC5B,+CAA6B;AAC7B,8DAA4C;AAE5C,uDAAiD;AAAxC,uGAAA,OAAO,OAAA;AAChB,wCAAsB;AACtB,iDAA+B;AAC/B,wDAAsC;AACtC,4DAA0C;AAC1C,uDAAqC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.13.11-alpha.1\";\n\nexport * from './graph';\n\nexport * from './interactions';\n\nexport { View } from './view';\nexport { Scale, registerScale } from './view/scale';\nexport { Coordinate, registerCoordinate } from './view/coordinate';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n\nexport { vglobal } from '@visactor/vrender-core';\nexport * from './env';\nexport * from './interactions';\nexport * from './semantic-marks/cell';\nexport * from './semantic-marks/interval';\nexport * from './graph/mark/graphic';\n"]}
|
package/cjs/types/animate.d.ts
CHANGED
package/cjs/types/animate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { IGraphic, ACustomAnimate, EasingType } from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { MarkFunctionCallback, MarkFunctionType } from './mark';\nimport type { IMark } from './grammar';\nimport type { IElement } from './element';\nimport type { FunctionCallback } from './signal';\n\nexport type TypeAnimation<T extends IElement> = (\n element: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nexport interface IClipAnimationOptions {\n clipDimension?: 'x' | 'y' | 'auto' | 'default';\n}\n\nexport interface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IGrowAngleAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n overall?: boolean | number;\n}\n\nexport interface IGrowRadiusAnimationOptions {\n orient?: 'inside' | 'outside';\n overall?: boolean | number;\n}\n\nexport interface IGrowPointsAnimationOptions {\n orient?: 'positive' | 'negative';\n}\n\nexport interface IGrowPointsOverallAnimationOptions extends IGrowPointsAnimationOptions {\n center?: IPointLike;\n}\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n}\n\nexport interface IRotateAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n angle?: number;\n}\n\n/** VGrammar 层提供的图元text上的图形属性,现在暂时会和VRender不一致 */\nexport interface TextItemAttributes {\n fontSize?: number;\n lineHeight?: number;\n font?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string | number;\n lineBreak?: string;\n text?: string | string[];\n limit?: number;\n align?: string;\n baseline?: string;\n ellipsis?: string | boolean;\n dir?: string;\n}\n\n/** animation */\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n\n/**\n * state动画,暂时只支持简单配置\n */\nexport interface IStateAnimationConfig {\n duration?: number;\n easing?: EasingType;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n duration?: MarkFunctionValueType<number>;\n oneByOne?: MarkFunctionValueType<boolean | number>;\n startTime?: MarkFunctionValueType<number>;\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IElement, elementB: IElement, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\nexport interface IAnimationTimeSlice {\n effects: IAnimationEffect | IAnimationEffect[];\n duration?: MarkFunctionValueType<number>;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport type IAnimationChannelFunction = (datum: any, element: IElement, parameters: IAnimationParameters) => any;\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IElement,\n parameters: IAnimationParameters\n) => boolean | void;\n\n// TODO: fix ACustomAnimate<any>\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n}\n\n/**\n * Animation timeline should be parsed into animation units,\n * which record all necessary configs for animator to execute animation.\n *\n * animation unit time:\n * |<--initialDelay-->| |<--loopDelay--><--Slices--><--looDelayAfter-->| |<--loopDuration-->|\n * |<-----------------loopDuration--------------->|\n */\nexport interface IAnimationUnit {\n /**\n * initial delay time before any animation loop\n */\n initialDelay: number;\n /**\n * total time for one animation loop\n */\n loopDuration: number;\n /**\n * delay time before time slices\n */\n loopDelay: number;\n /**\n * delay time after time slices\n */\n loopDelayAfter: number;\n /**\n * animating time in one animation loop\n */\n loopAnimateDuration: number;\n loopCount: number;\n totalTime: number;\n timeSlices: IAnimationTimeSlice[];\n}\n\nexport interface IAnimationRecord {\n start: IGraphic;\n end: IGraphic;\n changes: any[];\n}\n\nexport interface IAnimationParameters {\n width: number;\n height: number;\n mark: IMark;\n group: IMark | null;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\nexport interface IParsedAnimationConfig {\n state: string;\n timeline: IAnimationTimeline;\n originConfig: IAnimationConfig;\n id: string;\n}\n\nexport interface IParsedAnimationAttrs {\n from?: any;\n to?: any;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: any;\n}\n\n// animate structure\n\nexport interface IAnimatorOptions {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n}\n\nexport interface IAnimator {\n id: number;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean;\n\n /** execute animation */\n animate: (animationParameters: IAnimationParameters, parameters: any) => this;\n /** set animation callback */\n callback: (callbackFunction: (...args: any[]) => void) => this;\n\n // animation control\n stop: (stopState?: 'start' | 'end', invokeCallback?: boolean) => this;\n pause: () => this;\n resume: () => this;\n\n /** set additional initial animation delay */\n startAt: (startTime: number) => this;\n /** get total animation execution time */\n getTotalAnimationTime: () => number;\n\n getEndAttributes: () => Record<string, any>;\n}\n\nexport interface IAnimateArranger {\n // animation control api\n parallel: (arranger: IAnimateArranger) => this;\n after: (arranger: IAnimateArranger) => this;\n\n // internal properties\n afterArranger: IAnimateArranger;\n parallelArrangers: IAnimateArranger[];\n animators: IAnimator[];\n totalTime: number;\n startTime: number;\n endTime: number;\n arrangeTime: () => void;\n}\n\nexport interface IBaseAnimate {\n // animation control\n stop: () => this;\n pause: () => this;\n resume: () => this;\n\n // internal animation process api\n animate: () => this;\n enable: () => this;\n disable: () => this;\n enableAnimationState: (state: string | string[]) => this;\n disableAnimationState: (state: string | string[]) => this;\n isAnimating: () => boolean;\n\n release: () => void;\n}\n\nexport interface IViewAnimate extends IBaseAnimate {\n animateAddition: (mark: IMark) => this;\n}\n\nexport interface IAnimate extends IBaseAnimate {\n mark: IMark;\n\n // additional animation control\n run: (config: IAnimationConfig | IAnimationConfig[]) => IAnimateArranger;\n runAnimationByState: (animationState: string) => IAnimateArranger;\n stopAnimationByState: (animationState: string) => this;\n pauseAnimationByState: (animationState: string) => this;\n resumeAnimationByState: (animationState: string) => this;\n reverse: () => this;\n restart: () => this;\n record: () => this;\n recordEnd: () => this;\n\n // internal animation process api\n getAnimationConfigs: (animationState: string) => IParsedAnimationConfig[];\n updateConfig: (config: Record<string, IAnimationConfig | IAnimationConfig[]>) => void;\n updateState: (state: MarkFunctionType<string> | null) => void;\n isElementAnimating: (element: IElement) => boolean;\n getAnimatorCount: () => number;\n getElementAnimators: (element: IElement | IElement[], animationState?: string) => IAnimator[];\n release: () => void;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { IGraphic, ACustomAnimate, EasingType } from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { MarkFunctionCallback, MarkFunctionType } from './mark';\nimport type { IMark } from './grammar';\nimport type { IElement } from './element';\nimport type { FunctionCallback } from './signal';\n\nexport type TypeAnimation<T extends IElement> = (\n element: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nexport interface IClipAnimationOptions {\n clipDimension?: 'x' | 'y' | 'auto' | 'default';\n}\n\nexport interface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IGrowAngleAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n overall?: boolean | number;\n}\n\nexport interface IGrowRadiusAnimationOptions {\n orient?: 'inside' | 'outside';\n overall?: boolean | number;\n}\n\nexport interface IGrowPointsAnimationOptions {\n orient?: 'positive' | 'negative';\n}\n\nexport interface IGrowPointsOverallAnimationOptions extends IGrowPointsAnimationOptions {\n center?: IPointLike;\n}\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\n}\n\nexport interface IRotateAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n angle?: number;\n}\n\n/** VGrammar 层提供的图元text上的图形属性,现在暂时会和VRender不一致 */\nexport interface TextItemAttributes {\n fontSize?: number;\n lineHeight?: number;\n font?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string | number;\n lineBreak?: string;\n text?: string | string[];\n limit?: number;\n align?: string;\n baseline?: string;\n ellipsis?: string | boolean;\n dir?: string;\n}\n\n/** animation */\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n\n/**\n * state动画,暂时只支持简单配置\n */\nexport interface IStateAnimationConfig {\n duration?: number;\n easing?: EasingType;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n duration?: MarkFunctionValueType<number>;\n oneByOne?: MarkFunctionValueType<boolean | number>;\n startTime?: MarkFunctionValueType<number>;\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IElement, elementB: IElement, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\nexport interface IAnimationTimeSlice {\n effects: IAnimationEffect | IAnimationEffect[];\n duration?: MarkFunctionValueType<number>;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport type IAnimationChannelFunction = (datum: any, element: IElement, parameters: IAnimationParameters) => any;\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IElement,\n parameters: IAnimationParameters\n) => boolean | void;\n\n// TODO: fix ACustomAnimate<any>\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n}\n\n/**\n * Animation timeline should be parsed into animation units,\n * which record all necessary configs for animator to execute animation.\n *\n * animation unit time:\n * |<--initialDelay-->| |<--loopDelay--><--Slices--><--looDelayAfter-->| |<--loopDuration-->|\n * |<-----------------loopDuration--------------->|\n */\nexport interface IAnimationUnit {\n /**\n * initial delay time before any animation loop\n */\n initialDelay: number;\n /**\n * total time for one animation loop\n */\n loopDuration: number;\n /**\n * delay time before time slices\n */\n loopDelay: number;\n /**\n * delay time after time slices\n */\n loopDelayAfter: number;\n /**\n * animating time in one animation loop\n */\n loopAnimateDuration: number;\n loopCount: number;\n totalTime: number;\n timeSlices: IAnimationTimeSlice[];\n}\n\nexport interface IAnimationRecord {\n start: IGraphic;\n end: IGraphic;\n changes: any[];\n}\n\nexport interface IAnimationParameters {\n width: number;\n height: number;\n mark: IMark;\n group: IMark | null;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\nexport interface IParsedAnimationConfig {\n state: string;\n timeline: IAnimationTimeline;\n originConfig: IAnimationConfig;\n id: string;\n}\n\nexport interface IParsedAnimationAttrs {\n from?: any;\n to?: any;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: any;\n}\n\n// animate structure\n\nexport interface IAnimatorOptions {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n}\n\nexport interface IAnimator {\n id: number;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean;\n\n /** execute animation */\n animate: (animationParameters: IAnimationParameters, parameters: any) => this;\n /** set animation callback */\n callback: (callbackFunction: (...args: any[]) => void) => this;\n\n // animation control\n stop: (stopState?: 'start' | 'end', invokeCallback?: boolean) => this;\n pause: () => this;\n resume: () => this;\n\n /** set additional initial animation delay */\n startAt: (startTime: number) => this;\n /** get total animation execution time */\n getTotalAnimationTime: () => number;\n\n getEndAttributes: () => Record<string, any>;\n}\n\nexport interface IAnimateArranger {\n // animation control api\n parallel: (arranger: IAnimateArranger) => this;\n after: (arranger: IAnimateArranger) => this;\n\n // internal properties\n afterArranger: IAnimateArranger;\n parallelArrangers: IAnimateArranger[];\n animators: IAnimator[];\n totalTime: number;\n startTime: number;\n endTime: number;\n arrangeTime: () => void;\n}\n\nexport interface IBaseAnimate {\n // animation control\n stop: () => this;\n pause: () => this;\n resume: () => this;\n\n // internal animation process api\n animate: () => this;\n enable: () => this;\n disable: () => this;\n enableAnimationState: (state: string | string[]) => this;\n disableAnimationState: (state: string | string[]) => this;\n isAnimating: () => boolean;\n\n release: () => void;\n}\n\nexport interface IViewAnimate extends IBaseAnimate {\n animateAddition: (mark: IMark) => this;\n}\n\nexport interface IAnimate extends IBaseAnimate {\n mark: IMark;\n\n // additional animation control\n run: (config: IAnimationConfig | IAnimationConfig[]) => IAnimateArranger;\n runAnimationByState: (animationState: string) => IAnimateArranger;\n stopAnimationByState: (animationState: string) => this;\n pauseAnimationByState: (animationState: string) => this;\n resumeAnimationByState: (animationState: string) => this;\n reverse: () => this;\n restart: () => this;\n record: () => this;\n recordEnd: () => this;\n\n // internal animation process api\n getAnimationConfigs: (animationState: string) => IParsedAnimationConfig[];\n updateConfig: (config: Record<string, IAnimationConfig | IAnimationConfig[]>) => void;\n updateState: (state: MarkFunctionType<string> | null) => void;\n isElementAnimating: (element: IElement) => boolean;\n getAnimatorCount: () => number;\n getElementAnimators: (element: IElement | IElement[], animationState?: string) => IAnimator[];\n release: () => void;\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { isFunction, isValidNumber } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
export const moveIn = (element, options, animationParameters) => {
|
|
4
|
-
var _a, _b;
|
|
5
|
-
const {offset: offset = 0, orient: orient, direction: direction, point: pointOpt} = null != options ? options : {};
|
|
4
|
+
var _a, _b, _c, _d;
|
|
5
|
+
const {offset: offset = 0, orient: orient, direction: direction, point: pointOpt, excludeChannels: excludeChannels = []} = null != options ? options : {};
|
|
6
6
|
let changedX = 0, changedY = 0;
|
|
7
7
|
"negative" === orient && (animationParameters.group ? (changedX = null !== (_a = animationParameters.groupWidth) && void 0 !== _a ? _a : animationParameters.group.getBounds().width(),
|
|
8
8
|
changedY = null !== (_b = animationParameters.groupHeight) && void 0 !== _b ? _b : animationParameters.group.getBounds().height(),
|
|
9
9
|
animationParameters.groupWidth = changedX, animationParameters.groupHeight = changedY) : (changedX = animationParameters.width,
|
|
10
10
|
changedY = animationParameters.height)), changedX += offset, changedY += offset;
|
|
11
|
-
const point = isFunction(pointOpt) ? pointOpt.call(null, element.getDatum(), element, animationParameters) : pointOpt, fromX = point && isValidNumber(point.x) ? point.x : changedX, fromY = point && isValidNumber(point.y) ? point.y : changedY,
|
|
11
|
+
const point = isFunction(pointOpt) ? pointOpt.call(null, element.getDatum(), element, animationParameters) : pointOpt, fromX = point && isValidNumber(point.x) ? point.x : changedX, fromY = point && isValidNumber(point.y) ? point.y : changedY, finalAttrsX = excludeChannels.includes("x") ? element.getGraphicItem().getNormalAttribute("x") : null === (_c = element.getFinalGraphicAttributes()) || void 0 === _c ? void 0 : _c.x, finalAttrsY = excludeChannels.includes("y") ? element.getGraphicItem().getNormalAttribute("y") : null === (_d = element.getFinalGraphicAttributes()) || void 0 === _d ? void 0 : _d.y;
|
|
12
12
|
switch (direction) {
|
|
13
13
|
case "x":
|
|
14
14
|
return {
|
|
@@ -16,7 +16,7 @@ export const moveIn = (element, options, animationParameters) => {
|
|
|
16
16
|
x: fromX
|
|
17
17
|
},
|
|
18
18
|
to: {
|
|
19
|
-
x:
|
|
19
|
+
x: finalAttrsX
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ export const moveIn = (element, options, animationParameters) => {
|
|
|
26
26
|
y: fromY
|
|
27
27
|
},
|
|
28
28
|
to: {
|
|
29
|
-
y:
|
|
29
|
+
y: finalAttrsY
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -37,8 +37,8 @@ export const moveIn = (element, options, animationParameters) => {
|
|
|
37
37
|
y: fromY
|
|
38
38
|
},
|
|
39
39
|
to: {
|
|
40
|
-
x:
|
|
41
|
-
y:
|
|
40
|
+
x: finalAttrsX,
|
|
41
|
+
y: finalAttrsY
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animation/move.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAM7D,MAAM,CAAC,MAAM,MAAM,GAA4B,CAC7C,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,EAAE;;IACF,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/animation/move.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAM7D,MAAM,CAAC,MAAM,MAAM,GAA4B,CAC7C,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,EAAE;;IACF,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,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AK,GAAG;YACN,OAAO;gBACL,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE;gBACnD,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE;aACjB,CAAC;QACJ,KAAK,IAAI,CAAC;QACV;YACE,OAAO;gBACL,IAAI,EAAE;oBACJ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC;oBACzC,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC;iBAC1C;gBACD,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE;aAC3B,CAAC;KACL;AACH,CAAC,CAAC","file":"move.js","sourcesContent":["import { isFunction, isValidNumber } from '@visactor/vutils';\nimport type { IElement, IMoveAnimationOptions, IAnimationParameters, TypeAnimation } from '../../../types';\n\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [] } = options ?? {};\n let changedX = 0;\n let changedY = 0;\n\n if (orient === 'negative') {\n // consider the offset of group\n if (animationParameters.group) {\n changedX = (animationParameters as any).groupWidth ?? animationParameters.group.getBounds().width();\n changedY = (animationParameters as any).groupHeight ?? animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupWidth = changedX;\n (animationParameters as any).groupHeight = changedY;\n } else {\n changedX = animationParameters.width;\n changedY = animationParameters.height;\n }\n }\n\n changedX += offset;\n changedY += offset;\n const point = isFunction(pointOpt) ? pointOpt.call(null, element.getDatum(), element, animationParameters) : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n const finalAttrsX = excludeChannels.includes('x')\n ? element.getGraphicItem().getNormalAttribute('x')\n : element.getFinalGraphicAttributes()?.x;\n const finalAttrsY = excludeChannels.includes('y')\n ? element.getGraphicItem().getNormalAttribute('y')\n : element.getFinalGraphicAttributes()?.y;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: fromX },\n to: { x: finalAttrsX }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: finalAttrsY }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: finalAttrsX,\n y: finalAttrsY\n }\n };\n }\n};\n\nexport const moveOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt } = options ?? {};\n\n // consider the offset of group\n const groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null;\n const groupWidth = groupBounds?.width() ?? animationParameters.width;\n const groupHeight = groupBounds?.height() ?? animationParameters.height;\n const changedX = (orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(pointOpt) ? pointOpt.call(null, element.getDatum(), element, animationParameters) : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: element.getGraphicAttribute('x', true) },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: element.getGraphicAttribute('y', true) },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: element.getGraphicAttribute('x', true),\n y: element.getGraphicAttribute('y', true)\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n"]}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.13.11-alpha.1\";\n\nexport * from './graph';\n\nexport * from './interactions';\n\nexport { View } from './view';\nexport { Scale, registerScale } from './view/scale';\nexport { Coordinate, registerCoordinate } from './view/coordinate';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n\nexport { vglobal } from '@visactor/vrender-core';\nexport * from './env';\nexport * from './interactions';\nexport * from './semantic-marks/cell';\nexport * from './semantic-marks/interval';\nexport * from './graph/mark/graphic';\n"]}
|
package/es/types/animate.d.ts
CHANGED
package/es/types/animate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { IGraphic, ACustomAnimate, EasingType } from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { MarkFunctionCallback, MarkFunctionType } from './mark';\nimport type { IMark } from './grammar';\nimport type { IElement } from './element';\nimport type { FunctionCallback } from './signal';\n\nexport type TypeAnimation<T extends IElement> = (\n element: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nexport interface IClipAnimationOptions {\n clipDimension?: 'x' | 'y' | 'auto' | 'default';\n}\n\nexport interface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IGrowAngleAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n overall?: boolean | number;\n}\n\nexport interface IGrowRadiusAnimationOptions {\n orient?: 'inside' | 'outside';\n overall?: boolean | number;\n}\n\nexport interface IGrowPointsAnimationOptions {\n orient?: 'positive' | 'negative';\n}\n\nexport interface IGrowPointsOverallAnimationOptions extends IGrowPointsAnimationOptions {\n center?: IPointLike;\n}\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n}\n\nexport interface IRotateAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n angle?: number;\n}\n\n/** VGrammar 层提供的图元text上的图形属性,现在暂时会和VRender不一致 */\nexport interface TextItemAttributes {\n fontSize?: number;\n lineHeight?: number;\n font?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string | number;\n lineBreak?: string;\n text?: string | string[];\n limit?: number;\n align?: string;\n baseline?: string;\n ellipsis?: string | boolean;\n dir?: string;\n}\n\n/** animation */\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n\n/**\n * state动画,暂时只支持简单配置\n */\nexport interface IStateAnimationConfig {\n duration?: number;\n easing?: EasingType;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n duration?: MarkFunctionValueType<number>;\n oneByOne?: MarkFunctionValueType<boolean | number>;\n startTime?: MarkFunctionValueType<number>;\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IElement, elementB: IElement, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\nexport interface IAnimationTimeSlice {\n effects: IAnimationEffect | IAnimationEffect[];\n duration?: MarkFunctionValueType<number>;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport type IAnimationChannelFunction = (datum: any, element: IElement, parameters: IAnimationParameters) => any;\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IElement,\n parameters: IAnimationParameters\n) => boolean | void;\n\n// TODO: fix ACustomAnimate<any>\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n}\n\n/**\n * Animation timeline should be parsed into animation units,\n * which record all necessary configs for animator to execute animation.\n *\n * animation unit time:\n * |<--initialDelay-->| |<--loopDelay--><--Slices--><--looDelayAfter-->| |<--loopDuration-->|\n * |<-----------------loopDuration--------------->|\n */\nexport interface IAnimationUnit {\n /**\n * initial delay time before any animation loop\n */\n initialDelay: number;\n /**\n * total time for one animation loop\n */\n loopDuration: number;\n /**\n * delay time before time slices\n */\n loopDelay: number;\n /**\n * delay time after time slices\n */\n loopDelayAfter: number;\n /**\n * animating time in one animation loop\n */\n loopAnimateDuration: number;\n loopCount: number;\n totalTime: number;\n timeSlices: IAnimationTimeSlice[];\n}\n\nexport interface IAnimationRecord {\n start: IGraphic;\n end: IGraphic;\n changes: any[];\n}\n\nexport interface IAnimationParameters {\n width: number;\n height: number;\n mark: IMark;\n group: IMark | null;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\nexport interface IParsedAnimationConfig {\n state: string;\n timeline: IAnimationTimeline;\n originConfig: IAnimationConfig;\n id: string;\n}\n\nexport interface IParsedAnimationAttrs {\n from?: any;\n to?: any;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: any;\n}\n\n// animate structure\n\nexport interface IAnimatorOptions {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n}\n\nexport interface IAnimator {\n id: number;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean;\n\n /** execute animation */\n animate: (animationParameters: IAnimationParameters, parameters: any) => this;\n /** set animation callback */\n callback: (callbackFunction: (...args: any[]) => void) => this;\n\n // animation control\n stop: (stopState?: 'start' | 'end', invokeCallback?: boolean) => this;\n pause: () => this;\n resume: () => this;\n\n /** set additional initial animation delay */\n startAt: (startTime: number) => this;\n /** get total animation execution time */\n getTotalAnimationTime: () => number;\n\n getEndAttributes: () => Record<string, any>;\n}\n\nexport interface IAnimateArranger {\n // animation control api\n parallel: (arranger: IAnimateArranger) => this;\n after: (arranger: IAnimateArranger) => this;\n\n // internal properties\n afterArranger: IAnimateArranger;\n parallelArrangers: IAnimateArranger[];\n animators: IAnimator[];\n totalTime: number;\n startTime: number;\n endTime: number;\n arrangeTime: () => void;\n}\n\nexport interface IBaseAnimate {\n // animation control\n stop: () => this;\n pause: () => this;\n resume: () => this;\n\n // internal animation process api\n animate: () => this;\n enable: () => this;\n disable: () => this;\n enableAnimationState: (state: string | string[]) => this;\n disableAnimationState: (state: string | string[]) => this;\n isAnimating: () => boolean;\n\n release: () => void;\n}\n\nexport interface IViewAnimate extends IBaseAnimate {\n animateAddition: (mark: IMark) => this;\n}\n\nexport interface IAnimate extends IBaseAnimate {\n mark: IMark;\n\n // additional animation control\n run: (config: IAnimationConfig | IAnimationConfig[]) => IAnimateArranger;\n runAnimationByState: (animationState: string) => IAnimateArranger;\n stopAnimationByState: (animationState: string) => this;\n pauseAnimationByState: (animationState: string) => this;\n resumeAnimationByState: (animationState: string) => this;\n reverse: () => this;\n restart: () => this;\n record: () => this;\n recordEnd: () => this;\n\n // internal animation process api\n getAnimationConfigs: (animationState: string) => IParsedAnimationConfig[];\n updateConfig: (config: Record<string, IAnimationConfig | IAnimationConfig[]>) => void;\n updateState: (state: MarkFunctionType<string> | null) => void;\n isElementAnimating: (element: IElement) => boolean;\n getAnimatorCount: () => number;\n getElementAnimators: (element: IElement | IElement[], animationState?: string) => IAnimator[];\n release: () => void;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { IGraphic, ACustomAnimate, EasingType } from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { MarkFunctionCallback, MarkFunctionType } from './mark';\nimport type { IMark } from './grammar';\nimport type { IElement } from './element';\nimport type { FunctionCallback } from './signal';\n\nexport type TypeAnimation<T extends IElement> = (\n element: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nexport interface IClipAnimationOptions {\n clipDimension?: 'x' | 'y' | 'auto' | 'default';\n}\n\nexport interface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IGrowAngleAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n overall?: boolean | number;\n}\n\nexport interface IGrowRadiusAnimationOptions {\n orient?: 'inside' | 'outside';\n overall?: boolean | number;\n}\n\nexport interface IGrowPointsAnimationOptions {\n orient?: 'positive' | 'negative';\n}\n\nexport interface IGrowPointsOverallAnimationOptions extends IGrowPointsAnimationOptions {\n center?: IPointLike;\n}\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\n}\n\nexport interface IRotateAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n angle?: number;\n}\n\n/** VGrammar 层提供的图元text上的图形属性,现在暂时会和VRender不一致 */\nexport interface TextItemAttributes {\n fontSize?: number;\n lineHeight?: number;\n font?: string;\n fontStyle?: string;\n fontVariant?: string;\n fontWeight?: string | number;\n lineBreak?: string;\n text?: string | string[];\n limit?: number;\n align?: string;\n baseline?: string;\n ellipsis?: string | boolean;\n dir?: string;\n}\n\n/** animation */\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n\n/**\n * state动画,暂时只支持简单配置\n */\nexport interface IStateAnimationConfig {\n duration?: number;\n easing?: EasingType;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n duration?: MarkFunctionValueType<number>;\n oneByOne?: MarkFunctionValueType<boolean | number>;\n startTime?: MarkFunctionValueType<number>;\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IElement, elementB: IElement, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\nexport interface IAnimationTimeSlice {\n effects: IAnimationEffect | IAnimationEffect[];\n duration?: MarkFunctionValueType<number>;\n delay?: MarkFunctionValueType<number>;\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport type IAnimationChannelFunction = (datum: any, element: IElement, parameters: IAnimationParameters) => any;\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IElement,\n parameters: IAnimationParameters\n) => boolean | void;\n\n// TODO: fix ACustomAnimate<any>\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n type?: string;\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: MarkFunctionValueType<any>;\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n}\n\n/**\n * Animation timeline should be parsed into animation units,\n * which record all necessary configs for animator to execute animation.\n *\n * animation unit time:\n * |<--initialDelay-->| |<--loopDelay--><--Slices--><--looDelayAfter-->| |<--loopDuration-->|\n * |<-----------------loopDuration--------------->|\n */\nexport interface IAnimationUnit {\n /**\n * initial delay time before any animation loop\n */\n initialDelay: number;\n /**\n * total time for one animation loop\n */\n loopDuration: number;\n /**\n * delay time before time slices\n */\n loopDelay: number;\n /**\n * delay time after time slices\n */\n loopDelayAfter: number;\n /**\n * animating time in one animation loop\n */\n loopAnimateDuration: number;\n loopCount: number;\n totalTime: number;\n timeSlices: IAnimationTimeSlice[];\n}\n\nexport interface IAnimationRecord {\n start: IGraphic;\n end: IGraphic;\n changes: any[];\n}\n\nexport interface IAnimationParameters {\n width: number;\n height: number;\n mark: IMark;\n group: IMark | null;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\nexport interface IParsedAnimationConfig {\n state: string;\n timeline: IAnimationTimeline;\n originConfig: IAnimationConfig;\n id: string;\n}\n\nexport interface IParsedAnimationAttrs {\n from?: any;\n to?: any;\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n customParameters?: any;\n}\n\n// animate structure\n\nexport interface IAnimatorOptions {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n}\n\nexport interface IAnimator {\n id: number;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean;\n\n /** execute animation */\n animate: (animationParameters: IAnimationParameters, parameters: any) => this;\n /** set animation callback */\n callback: (callbackFunction: (...args: any[]) => void) => this;\n\n // animation control\n stop: (stopState?: 'start' | 'end', invokeCallback?: boolean) => this;\n pause: () => this;\n resume: () => this;\n\n /** set additional initial animation delay */\n startAt: (startTime: number) => this;\n /** get total animation execution time */\n getTotalAnimationTime: () => number;\n\n getEndAttributes: () => Record<string, any>;\n}\n\nexport interface IAnimateArranger {\n // animation control api\n parallel: (arranger: IAnimateArranger) => this;\n after: (arranger: IAnimateArranger) => this;\n\n // internal properties\n afterArranger: IAnimateArranger;\n parallelArrangers: IAnimateArranger[];\n animators: IAnimator[];\n totalTime: number;\n startTime: number;\n endTime: number;\n arrangeTime: () => void;\n}\n\nexport interface IBaseAnimate {\n // animation control\n stop: () => this;\n pause: () => this;\n resume: () => this;\n\n // internal animation process api\n animate: () => this;\n enable: () => this;\n disable: () => this;\n enableAnimationState: (state: string | string[]) => this;\n disableAnimationState: (state: string | string[]) => this;\n isAnimating: () => boolean;\n\n release: () => void;\n}\n\nexport interface IViewAnimate extends IBaseAnimate {\n animateAddition: (mark: IMark) => this;\n}\n\nexport interface IAnimate extends IBaseAnimate {\n mark: IMark;\n\n // additional animation control\n run: (config: IAnimationConfig | IAnimationConfig[]) => IAnimateArranger;\n runAnimationByState: (animationState: string) => IAnimateArranger;\n stopAnimationByState: (animationState: string) => this;\n pauseAnimationByState: (animationState: string) => this;\n resumeAnimationByState: (animationState: string) => this;\n reverse: () => this;\n restart: () => this;\n record: () => this;\n recordEnd: () => this;\n\n // internal animation process api\n getAnimationConfigs: (animationState: string) => IParsedAnimationConfig[];\n updateConfig: (config: Record<string, IAnimationConfig | IAnimationConfig[]>) => void;\n updateState: (state: MarkFunctionType<string> | null) => void;\n isElementAnimating: (element: IElement) => boolean;\n getAnimatorCount: () => number;\n getElementAnimators: (element: IElement | IElement[], animationState?: string) => IAnimator[];\n release: () => void;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vgrammar-core",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.11-alpha.1",
|
|
4
4
|
"description": "VGrammar is a visual grammar library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"grammar",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@visactor/vutils": "~0.18.9",
|
|
28
28
|
"@visactor/vdataset": "~0.18.9",
|
|
29
|
-
"@visactor/vgrammar-coordinate": "0.13.
|
|
30
|
-
"@visactor/vgrammar-util": "0.13.
|
|
29
|
+
"@visactor/vgrammar-coordinate": "0.13.11-alpha.1",
|
|
30
|
+
"@visactor/vgrammar-util": "0.13.11-alpha.1",
|
|
31
31
|
"@visactor/vscale": "~0.18.9",
|
|
32
32
|
"@visactor/vrender-core": "0.19.11",
|
|
33
33
|
"@visactor/vrender-kits": "0.19.11",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"ts-jest": "~29.1.0",
|
|
45
45
|
"@types/jest": "~29.5.0",
|
|
46
46
|
"typescript": "4.9.5",
|
|
47
|
+
"@internal/bundler": "0.0.1",
|
|
47
48
|
"@internal/jest-config": "0.0.1",
|
|
48
49
|
"@internal/eslint-config": "0.0.1",
|
|
49
|
-
"@internal/bundler": "0.0.1",
|
|
50
50
|
"@internal/ts-config": "0.0.1"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|