@visactor/vrender-components 1.0.0-alpha.13 → 1.0.0-alpha.14

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/dist/index.es.js CHANGED
@@ -577,6 +577,9 @@ const EnvContribution = Symbol.for("EnvContribution");
577
577
  const VGlobal = Symbol.for("VGlobal");
578
578
  const DEFAULT_TEXT_FONT_FAMILY$1 = "PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol";
579
579
 
580
+ class Application {}
581
+ const application = new Application();
582
+
580
583
  class PerformanceRAF {
581
584
  constructor() {
582
585
  this.nextAnimationFrameCbs = [], this._rafHandle = null, this.runAnimationFrame = time => {
@@ -585,7 +588,7 @@ class PerformanceRAF {
585
588
  this.nextAnimationFrameCbs = [];
586
589
  for (let i = 0; i < cbs.length; i++) cbs[i] && cbs[i](time);
587
590
  }, this.tryRunAnimationFrameNextFrame = () => {
588
- null === this._rafHandle && 0 !== this.nextAnimationFrameCbs.length && (this._rafHandle = vglobal.getRequestAnimationFrame()(this.runAnimationFrame));
591
+ null === this._rafHandle && 0 !== this.nextAnimationFrameCbs.length && (this._rafHandle = application.global.getRequestAnimationFrame()(this.runAnimationFrame));
589
592
  };
590
593
  }
591
594
  addAnimationFrameCb(callback) {
@@ -830,6 +833,11 @@ var AnimateMode;
830
833
  AnimateMode[AnimateMode.NORMAL = 0] = "NORMAL", AnimateMode[AnimateMode.SET_ATTR_IMMEDIATELY = 1] = "SET_ATTR_IMMEDIATELY";
831
834
  }(AnimateMode || (AnimateMode = {}));
832
835
 
836
+ var STATUS$1;
837
+ !function (STATUS) {
838
+ STATUS[STATUS.INITIAL = 0] = "INITIAL", STATUS[STATUS.RUNNING = 1] = "RUNNING", STATUS[STATUS.PAUSE = 2] = "PAUSE";
839
+ }(STATUS$1 || (STATUS$1 = {}));
840
+
833
841
  var AnimateStepType;
834
842
  !function (AnimateStepType) {
835
843
  AnimateStepType.wait = "wait", AnimateStepType.from = "from", AnimateStepType.to = "to", AnimateStepType.customAnimate = "customAnimate";
@@ -1147,44 +1155,6 @@ function quadLength(p0, p1, p2, iterationCount) {
1147
1155
  return snapLength([p0.x, p1.x, p2.x], [p0.y, p1.y, p2.y]);
1148
1156
  }
1149
1157
 
1150
- class QuadraticBezierCurve extends Curve {
1151
- constructor(p0, p1, p2) {
1152
- super(), this.type = CurveTypeEnum.QuadraticBezierCurve, this.p0 = p0, this.p1 = p1, this.p2 = p2;
1153
- }
1154
- _validPoint() {
1155
- return Number.isFinite(this.p0.x + this.p0.y + this.p1.x + this.p1.y + this.p2.x + this.p2.y);
1156
- }
1157
- getPointAt(t) {
1158
- if (!1 !== this.defined) return quadPointAt(this.p0, this.p1, this.p2, t);
1159
- throw new Error("defined为false的点不能getPointAt");
1160
- }
1161
- calcLength() {
1162
- return this._validPoint() ? quadLength(this.p0, this.p1, this.p2) : 60;
1163
- }
1164
- calcProjLength(direction) {
1165
- return direction === Direction.ROW ? abs(this.p0.x - this.p2.x) : direction === Direction.COLUMN ? abs(this.p0.y - this.p2.y) : 0;
1166
- }
1167
- getAngleAt(t) {
1168
- const minT = max(t - .01, 0),
1169
- maxT = min(t + .01, 1),
1170
- minP = this.getPointAt(minT),
1171
- maxP = this.getPointAt(maxT);
1172
- return atan2(maxP.y - minP.y, maxP.x - minP.x);
1173
- }
1174
- draw(path, x, y, sx, sy, percent) {
1175
- if (path.moveTo(this.p0.x * sx + x, this.p0.y * sy + y), percent >= 1) path.quadraticCurveTo(this.p1.x * sx + x, this.p1.y * sy + y, this.p2.x * sx + x, this.p2.y * sy + y);else if (percent > 0) {
1176
- const [curve1] = divideQuad(this, percent);
1177
- path.quadraticCurveTo(curve1.p1.x * sx + x, curve1.p1.y * sy + y, curve1.p2.x * sx + x, curve1.p2.y * sy + y);
1178
- }
1179
- }
1180
- getYAt(x) {
1181
- throw new Error("QuadraticBezierCurve暂不支持getYAt");
1182
- }
1183
- includeX(x) {
1184
- throw new Error("QuadraticBezierCurve暂不支持includeX");
1185
- }
1186
- }
1187
-
1188
1158
  function divideCubic(curve, t) {
1189
1159
  const {
1190
1160
  p0: p0,
@@ -1200,17 +1170,6 @@ function divideCubic(curve, t) {
1200
1170
  c23 = PointService.pointAtPP(c2, c3, t);
1201
1171
  return [new CubicBezierCurve(p0, c1, c12, pt), new CubicBezierCurve(pt, c23, c3, p3)];
1202
1172
  }
1203
- function divideQuad(curve, t) {
1204
- const {
1205
- p0: p0,
1206
- p1: p1,
1207
- p2: p2
1208
- } = curve,
1209
- pt = quadPointAt(p0, p1, p2, t),
1210
- c1 = PointService.pointAtPP(p0, p1, t),
1211
- c2 = PointService.pointAtPP(p1, p2, t);
1212
- return [new QuadraticBezierCurve(p0, c1, pt), new QuadraticBezierCurve(pt, c2, p2)];
1213
- }
1214
1173
  class CubicBezierCurve extends Curve {
1215
1174
  constructor(p0, p1, p2, p3) {
1216
1175
  super(), this.type = CurveTypeEnum.CubicBezierCurve, this.p0 = p0, this.p1 = p1, this.p2 = p2, this.p3 = p3;
@@ -1851,6 +1810,55 @@ class CatmullRomClosed {
1851
1810
  }
1852
1811
  const genCatmullRomClosedSegments = commonGenCatmullRomSegments("catmullRomClosed", CatmullRomClosed);
1853
1812
 
1813
+ function divideQuad(curve, t) {
1814
+ const {
1815
+ p0: p0,
1816
+ p1: p1,
1817
+ p2: p2
1818
+ } = curve,
1819
+ pt = quadPointAt(p0, p1, p2, t),
1820
+ c1 = PointService.pointAtPP(p0, p1, t),
1821
+ c2 = PointService.pointAtPP(p1, p2, t);
1822
+ return [new QuadraticBezierCurve(p0, c1, pt), new QuadraticBezierCurve(pt, c2, p2)];
1823
+ }
1824
+ class QuadraticBezierCurve extends Curve {
1825
+ constructor(p0, p1, p2) {
1826
+ super(), this.type = CurveTypeEnum.QuadraticBezierCurve, this.p0 = p0, this.p1 = p1, this.p2 = p2;
1827
+ }
1828
+ _validPoint() {
1829
+ return Number.isFinite(this.p0.x + this.p0.y + this.p1.x + this.p1.y + this.p2.x + this.p2.y);
1830
+ }
1831
+ getPointAt(t) {
1832
+ if (!1 !== this.defined) return quadPointAt(this.p0, this.p1, this.p2, t);
1833
+ throw new Error("defined为false的点不能getPointAt");
1834
+ }
1835
+ calcLength() {
1836
+ return this._validPoint() ? quadLength(this.p0, this.p1, this.p2) : 60;
1837
+ }
1838
+ calcProjLength(direction) {
1839
+ return direction === Direction.ROW ? abs(this.p0.x - this.p2.x) : direction === Direction.COLUMN ? abs(this.p0.y - this.p2.y) : 0;
1840
+ }
1841
+ getAngleAt(t) {
1842
+ const minT = max(t - .01, 0),
1843
+ maxT = min(t + .01, 1),
1844
+ minP = this.getPointAt(minT),
1845
+ maxP = this.getPointAt(maxT);
1846
+ return atan2(maxP.y - minP.y, maxP.x - minP.x);
1847
+ }
1848
+ draw(path, x, y, sx, sy, percent) {
1849
+ if (path.moveTo(this.p0.x * sx + x, this.p0.y * sy + y), percent >= 1) path.quadraticCurveTo(this.p1.x * sx + x, this.p1.y * sy + y, this.p2.x * sx + x, this.p2.y * sy + y);else if (percent > 0) {
1850
+ const [curve1] = divideQuad(this, percent);
1851
+ path.quadraticCurveTo(curve1.p1.x * sx + x, curve1.p1.y * sy + y, curve1.p2.x * sx + x, curve1.p2.y * sy + y);
1852
+ }
1853
+ }
1854
+ getYAt(x) {
1855
+ throw new Error("QuadraticBezierCurve暂不支持getYAt");
1856
+ }
1857
+ includeX(x) {
1858
+ throw new Error("QuadraticBezierCurve暂不支持includeX");
1859
+ }
1860
+ }
1861
+
1854
1862
  class CurveContext {
1855
1863
  constructor(path) {
1856
1864
  this.path = path, this._lastX = this._lastY = this._startX = this._startY = 0;
@@ -2541,9 +2549,6 @@ const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImag
2541
2549
  opacity: 1
2542
2550
  });
2543
2551
 
2544
- class Application {}
2545
- const application = new Application();
2546
-
2547
2552
  const parse = function () {
2548
2553
  const tokens = {
2549
2554
  linearGradient: /^(linear\-gradient)/i,
@@ -12454,7 +12459,7 @@ let DefaultCanvasGroupRender = class {
12454
12459
  height: height
12455
12460
  } = group.attribute,
12456
12461
  canvas = context.canvas,
12457
- newCanvas = vglobal.createCanvas({
12462
+ newCanvas = application.global.createCanvas({
12458
12463
  width: canvas.width,
12459
12464
  height: canvas.height,
12460
12465
  dpr: 1
@@ -19124,6 +19129,228 @@ class Animate {
19124
19129
  }
19125
19130
  }
19126
19131
 
19132
+ const performanceRAF = new PerformanceRAF();
19133
+ class RAFTickHandler {
19134
+ constructor() {
19135
+ this.released = !1;
19136
+ }
19137
+ tick(interval, cb) {
19138
+ performanceRAF.addAnimationFrameCb(() => {
19139
+ if (!this.released) return cb(this);
19140
+ });
19141
+ }
19142
+ release() {
19143
+ this.released = !0;
19144
+ }
19145
+ getTime() {
19146
+ return Date.now();
19147
+ }
19148
+ }
19149
+ class DefaultTicker extends EventEmitter {
19150
+ constructor(stage) {
19151
+ super(), this.timelines = [], this.frameTimeHistory = [], this.handleTick = (handler, params) => {
19152
+ const {
19153
+ once = !1
19154
+ } = null != params ? params : {};
19155
+ if (this.ifCanStop()) return this.stop(), !1;
19156
+ const currentTime = handler.getTime();
19157
+ this._lastTickTime = currentTime, this.lastFrameTime < 0 && (this.lastFrameTime = currentTime - this.interval + this.timeOffset, this.frameTimeHistory.push(this.lastFrameTime));
19158
+ const delta = currentTime - this.lastFrameTime,
19159
+ skip = this.checkSkip(delta);
19160
+ return skip || (this._handlerTick(delta), this.lastFrameTime = currentTime, this.frameTimeHistory.push(this.lastFrameTime)), once || handler.tick(this.interval, this.handleTick), !skip;
19161
+ }, this._handlerTick = delta => {
19162
+ this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(timeline => {
19163
+ timeline.tick(delta);
19164
+ }), this.emit("tick", delta));
19165
+ }, this.init(), this.lastFrameTime = -1, this.tickCounts = 0, this.stage = stage, this.autoStop = !0, this.interval = 16, this.computeTimeOffsetAndJitter();
19166
+ }
19167
+ bindStage(stage) {
19168
+ this.stage = stage;
19169
+ }
19170
+ computeTimeOffsetAndJitter() {
19171
+ this.timeOffset = Math.floor(Math.random() * this.interval), this._jitter = Math.min(Math.max(.2 * this.interval, 6), .7 * this.interval);
19172
+ }
19173
+ init() {
19174
+ this.interval = 16, this.status = STATUS$1.INITIAL, application.global.hooks.onSetEnv.tap("graph-ticker", () => {
19175
+ this.initHandler();
19176
+ }), application.global.env && this.initHandler();
19177
+ }
19178
+ addTimeline(timeline) {
19179
+ this.timelines.push(timeline);
19180
+ }
19181
+ remTimeline(timeline) {
19182
+ this.timelines = this.timelines.filter(t => t !== timeline);
19183
+ }
19184
+ getTimelines() {
19185
+ return this.timelines;
19186
+ }
19187
+ initHandler() {
19188
+ this.setupTickHandler();
19189
+ }
19190
+ setupTickHandler() {
19191
+ const handler = new RAFTickHandler();
19192
+ return this.tickerHandler && this.tickerHandler.release(), this.tickerHandler = handler, !0;
19193
+ }
19194
+ setInterval(interval) {
19195
+ this.interval = interval, this.computeTimeOffsetAndJitter();
19196
+ }
19197
+ getInterval() {
19198
+ return this.interval;
19199
+ }
19200
+ setFPS(fps) {
19201
+ this.setInterval(Math.floor(1e3 / fps));
19202
+ }
19203
+ getFPS() {
19204
+ return 1e3 / this.interval;
19205
+ }
19206
+ tick(interval) {
19207
+ this.tickerHandler.tick(interval, handler => this.handleTick(handler, {
19208
+ once: !0
19209
+ }));
19210
+ }
19211
+ tickTo(t) {
19212
+ this.tickerHandler.tickTo && this.tickerHandler.tickTo(t, handler => {
19213
+ this.handleTick(handler, {
19214
+ once: !0
19215
+ });
19216
+ });
19217
+ }
19218
+ pause() {
19219
+ return this.status !== STATUS$1.INITIAL && (this.status = STATUS$1.PAUSE, !0);
19220
+ }
19221
+ resume() {
19222
+ return this.status !== STATUS$1.INITIAL && (this.status = STATUS$1.RUNNING, !0);
19223
+ }
19224
+ ifCanStop() {
19225
+ if (this.autoStop) {
19226
+ if (!this.timelines.length) return !0;
19227
+ if (this.timelines.every(timeline => !timeline.isRunning())) return !0;
19228
+ }
19229
+ return !1;
19230
+ }
19231
+ start() {
19232
+ let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
19233
+ if (this.status === STATUS$1.RUNNING) return !1;
19234
+ if (!this.tickerHandler) return !1;
19235
+ if (!force) {
19236
+ if (this.status === STATUS$1.PAUSE) return !1;
19237
+ if (this.ifCanStop()) return !1;
19238
+ }
19239
+ return this.status = STATUS$1.RUNNING, this.tickerHandler.tick(0, this.handleTick), !0;
19240
+ }
19241
+ stop() {
19242
+ this.status = STATUS$1.INITIAL, this.setupTickHandler(), this.lastFrameTime = -1;
19243
+ }
19244
+ trySyncTickStatus() {
19245
+ this.status === STATUS$1.INITIAL && this.timelines.some(timeline => timeline.isRunning()) ? this.start() : this.status === STATUS$1.RUNNING && this.timelines.every(timeline => !timeline.isRunning()) && this.stop();
19246
+ }
19247
+ release() {
19248
+ var _a;
19249
+ this.stop(), this.timelines = [], null === (_a = this.tickerHandler) || void 0 === _a || _a.release(), this.tickerHandler = null, this.lastFrameTime = -1;
19250
+ }
19251
+ checkSkip(delta) {
19252
+ if ("performance" === this.stage.params.optimize.tickRenderMode) return !1;
19253
+ return delta < this.interval + 2 * (Math.random() - .5) * this._jitter;
19254
+ }
19255
+ }
19256
+
19257
+ class AnimationTransitionRegistry {
19258
+ constructor() {
19259
+ this.transitions = new Map(), this.registerDefaultTransitions();
19260
+ }
19261
+ static getInstance() {
19262
+ return AnimationTransitionRegistry.instance || (AnimationTransitionRegistry.instance = new AnimationTransitionRegistry()), AnimationTransitionRegistry.instance;
19263
+ }
19264
+ registerDefaultTransitions() {
19265
+ this.registerTransition("appear", "*", () => ({
19266
+ allowTransition: !0,
19267
+ stopOriginalTransition: !1
19268
+ })), this.registerTransition("appear", "appear", () => ({
19269
+ allowTransition: !1,
19270
+ stopOriginalTransition: !1
19271
+ })), this.registerTransition("appear", "disappear", () => ({
19272
+ allowTransition: !0,
19273
+ stopOriginalTransition: !0
19274
+ })), this.registerTransition("appear", "exit", () => ({
19275
+ allowTransition: !0,
19276
+ stopOriginalTransition: !0
19277
+ })), this.registerTransition("normal", "*", () => ({
19278
+ allowTransition: !0,
19279
+ stopOriginalTransition: !1
19280
+ })), this.registerTransition("normal", "normal", () => ({
19281
+ allowTransition: !1,
19282
+ stopOriginalTransition: !1
19283
+ })), this.registerTransition("normal", "disappear", () => ({
19284
+ allowTransition: !0,
19285
+ stopOriginalTransition: !0
19286
+ })), this.registerTransition("normal", "exit", () => ({
19287
+ allowTransition: !0,
19288
+ stopOriginalTransition: !0
19289
+ })), this.registerTransition("exit", "*", () => ({
19290
+ allowTransition: !1,
19291
+ stopOriginalTransition: !1
19292
+ })), this.registerTransition("exit", "disappear", () => ({
19293
+ allowTransition: !0,
19294
+ stopOriginalTransition: !0
19295
+ })), this.registerTransition("exit", "enter", () => ({
19296
+ allowTransition: !0,
19297
+ stopOriginalTransition: !0
19298
+ })), this.registerTransition("exit", "exit", () => ({
19299
+ allowTransition: !1,
19300
+ stopOriginalTransition: !1
19301
+ })), this.registerTransition("enter", "*", () => ({
19302
+ allowTransition: !0,
19303
+ stopOriginalTransition: !1
19304
+ })), this.registerTransition("enter", "enter", () => ({
19305
+ allowTransition: !1,
19306
+ stopOriginalTransition: !1
19307
+ })), this.registerTransition("enter", "disappear", () => ({
19308
+ allowTransition: !0,
19309
+ stopOriginalTransition: !0
19310
+ })), this.registerTransition("enter", "exit", () => ({
19311
+ allowTransition: !0,
19312
+ stopOriginalTransition: !0
19313
+ })), this.registerTransition("disappear", "*", () => ({
19314
+ allowTransition: !1,
19315
+ stopOriginalTransition: !1
19316
+ })), this.registerTransition("disappear", "appear", () => ({
19317
+ allowTransition: !0,
19318
+ stopOriginalTransition: !0
19319
+ })), this.registerTransition("update", "*", () => ({
19320
+ allowTransition: !0,
19321
+ stopOriginalTransition: !1
19322
+ })), this.registerTransition("update", "disappear", () => ({
19323
+ allowTransition: !0,
19324
+ stopOriginalTransition: !0
19325
+ })), this.registerTransition("update", "exit", () => ({
19326
+ allowTransition: !0,
19327
+ stopOriginalTransition: !0
19328
+ })), this.registerTransition("state", "*", () => ({
19329
+ allowTransition: !0,
19330
+ stopOriginalTransition: !1
19331
+ })), this.registerTransition("state", "disappear", () => ({
19332
+ allowTransition: !0,
19333
+ stopOriginalTransition: !0
19334
+ })), this.registerTransition("state", "exit", () => ({
19335
+ allowTransition: !0,
19336
+ stopOriginalTransition: !0
19337
+ }));
19338
+ }
19339
+ isTransitionAllowed(fromState, toState, graphic) {
19340
+ var _a, _b, _c, _d;
19341
+ let func = null === (_a = this.transitions.get(fromState)) || void 0 === _a ? void 0 : _a.get(toState);
19342
+ return func ? func(graphic, fromState) : (func = null === (_b = this.transitions.get(fromState)) || void 0 === _b ? void 0 : _b.get("*"), func ? func(graphic, fromState) : (func = null === (_c = this.transitions.get("*")) || void 0 === _c ? void 0 : _c.get(toState), func ? func(graphic, fromState) : (func = null === (_d = this.transitions.get("*")) || void 0 === _d ? void 0 : _d.get("*"), func ? func(graphic, fromState) : {
19343
+ allowTransition: !0,
19344
+ stopOriginalTransition: !0
19345
+ })));
19346
+ }
19347
+ registerTransition(fromState, toState, transition) {
19348
+ let fromStateMap = this.transitions.get(fromState);
19349
+ fromStateMap || (fromStateMap = new Map(), this.transitions.set(fromState, fromStateMap)), fromStateMap.set(toState, transition);
19350
+ }
19351
+ }
19352
+ AnimationTransitionRegistry.getInstance();
19353
+
19127
19354
  class AnimateExecutor {
19128
19355
  static registerBuiltInAnimate(name, animate) {
19129
19356
  AnimateExecutor.builtInAnimateMap[name] = animate;
@@ -19386,6 +19613,213 @@ class AnimateExecutor {
19386
19613
  }
19387
19614
  AnimateExecutor.builtInAnimateMap = {};
19388
19615
 
19616
+ const AnimationStates = {
19617
+ APPEAR: "appear",
19618
+ DISAPPEAR: "disappear",
19619
+ UPDATE: "update",
19620
+ HIGHLIGHT: "highlight",
19621
+ UNHIGHLIGHT: "unhighlight",
19622
+ SELECT: "select",
19623
+ UNSELECT: "unselect",
19624
+ HOVER: "hover",
19625
+ UNHOVER: "unhover",
19626
+ ACTIVE: "active",
19627
+ INACTIVE: "inactive"
19628
+ };
19629
+ class AnimationStateStore {
19630
+ constructor(graphic) {
19631
+ this.graphic = graphic;
19632
+ }
19633
+ registerState(state) {
19634
+ this.states || (this.states = new Map()), this.states.set(state.name, state);
19635
+ }
19636
+ clearStates() {
19637
+ var _a;
19638
+ null === (_a = this.states) || void 0 === _a || _a.clear();
19639
+ }
19640
+ }
19641
+ class AnimationStateManager {
19642
+ constructor(graphic) {
19643
+ this.stateList = null, this.graphic = graphic;
19644
+ }
19645
+ applyState(nextState, animationConfig, callback) {
19646
+ const registry = AnimationTransitionRegistry.getInstance(),
19647
+ shouldStopState = [],
19648
+ shouldApplyState = [];
19649
+ if (this.stateList && this.stateList.length ? nextState.forEach((state, index) => {
19650
+ const result = {
19651
+ allowTransition: !0,
19652
+ stopOriginalTransition: !0
19653
+ };
19654
+ this.stateList.forEach(currState => {
19655
+ const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);
19656
+ result.allowTransition = result.allowTransition && _result.allowTransition;
19657
+ }), result.allowTransition && (shouldApplyState.push({
19658
+ state: state,
19659
+ animationConfig: isArray(animationConfig[index]) ? animationConfig[index].map(item => item.animation) : animationConfig[index].animation,
19660
+ executor: new AnimateExecutor(this.graphic)
19661
+ }), this.stateList.forEach(currState => {
19662
+ registry.isTransitionAllowed(currState.state, state, this.graphic).stopOriginalTransition && shouldStopState.push(currState);
19663
+ }));
19664
+ }) : nextState.forEach((state, index) => {
19665
+ shouldApplyState.push({
19666
+ state: state,
19667
+ animationConfig: isArray(animationConfig[index]) ? animationConfig[index].map(item => item.animation) : animationConfig[index].animation,
19668
+ executor: new AnimateExecutor(this.graphic)
19669
+ });
19670
+ }), shouldStopState.forEach(state => {
19671
+ state.executor.stop();
19672
+ }), shouldApplyState.length) {
19673
+ shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);
19674
+ for (let i = 0; i < shouldApplyState.length; i++) {
19675
+ const nextState = shouldApplyState[i + 1],
19676
+ currentState = shouldApplyState[i];
19677
+ currentState.executor.onEnd(() => {
19678
+ nextState && nextState.executor.execute(nextState.animationConfig), this.stateList = this.stateList.filter(state => state !== currentState), i === shouldApplyState.length - 1 && callback && callback(!1);
19679
+ });
19680
+ }
19681
+ } else callback && callback(!0);
19682
+ this.stateList ? this.stateList = this.stateList.filter(state => !shouldStopState.includes(state)) : this.stateList = [], this.stateList.push(...shouldApplyState);
19683
+ }
19684
+ applyAppearState(animationConfig, callback) {
19685
+ this.applyState([AnimationStates.APPEAR], [{
19686
+ name: AnimationStates.APPEAR,
19687
+ animation: animationConfig
19688
+ }], callback);
19689
+ }
19690
+ applyDisappearState(animationConfig, callback) {
19691
+ this.applyState([AnimationStates.DISAPPEAR], [{
19692
+ name: AnimationStates.DISAPPEAR,
19693
+ animation: animationConfig
19694
+ }], callback);
19695
+ }
19696
+ applyUpdateState(animationConfig, callback) {
19697
+ this.applyState([AnimationStates.UPDATE], [{
19698
+ name: AnimationStates.UPDATE,
19699
+ animation: animationConfig
19700
+ }], callback);
19701
+ }
19702
+ applyHighlightState(animationConfig, callback) {
19703
+ this.applyState([AnimationStates.HIGHLIGHT], [{
19704
+ name: AnimationStates.HIGHLIGHT,
19705
+ animation: animationConfig
19706
+ }], callback);
19707
+ }
19708
+ applyUnhighlightState(animationConfig, callback) {
19709
+ this.applyState([AnimationStates.UNHIGHLIGHT], [{
19710
+ name: AnimationStates.UNHIGHLIGHT,
19711
+ animation: animationConfig
19712
+ }], callback);
19713
+ }
19714
+ stopState(state, type) {
19715
+ var _a;
19716
+ const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find(stateInfo => stateInfo.state === state);
19717
+ stateInfo && stateInfo.executor.stop(type);
19718
+ }
19719
+ clearState() {
19720
+ var _a;
19721
+ null === (_a = this.stateList) || void 0 === _a || _a.forEach(state => {
19722
+ state.executor.stop();
19723
+ }), this.stateList = null;
19724
+ }
19725
+ }
19726
+
19727
+ class GraphicStateExtension {
19728
+ _getAnimationStateManager(graphic) {
19729
+ return graphic._animationStateManager || (graphic._animationStateManager = new AnimationStateManager(graphic)), graphic._animationStateManager;
19730
+ }
19731
+ _getAnimationStateStore(graphic) {
19732
+ return graphic._animationStateStore || (graphic._animationStateStore = new AnimationStateStore(graphic)), graphic._animationStateStore;
19733
+ }
19734
+ registerAnimationState(state) {
19735
+ return this._getAnimationStateStore(this).registerState(state), this;
19736
+ }
19737
+ applyAnimationState(state, animationConfig, callback) {
19738
+ return this._getAnimationStateManager(this).applyState(state, animationConfig, callback), this;
19739
+ }
19740
+ applyAppearState(animationConfig, callback) {
19741
+ return this._getAnimationStateManager(this).applyAppearState(animationConfig, callback), this;
19742
+ }
19743
+ applyDisappearState(animationConfig, callback) {
19744
+ return this._getAnimationStateManager(this).applyDisappearState(animationConfig, callback), this;
19745
+ }
19746
+ applyUpdateState(animationConfig, callback) {
19747
+ return this._getAnimationStateManager(this).applyUpdateState(animationConfig, callback), this;
19748
+ }
19749
+ applyHighlightState(animationConfig, callback) {
19750
+ return this._getAnimationStateManager(this).applyHighlightState(animationConfig, callback), this;
19751
+ }
19752
+ applyUnhighlightState(animationConfig, callback) {
19753
+ return this._getAnimationStateManager(this).applyUnhighlightState(animationConfig, callback), this;
19754
+ }
19755
+ stopAnimationState(state, type) {
19756
+ return this._getAnimationStateManager(this).stopState(state, type), this;
19757
+ }
19758
+ clearAnimationStates() {
19759
+ return this._getAnimationStateManager(this).clearState(), this;
19760
+ }
19761
+ static extend(graphic) {
19762
+ return new GraphicStateExtension()._getAnimationStateManager(graphic), graphic;
19763
+ }
19764
+ }
19765
+
19766
+ class AnimateExtension {
19767
+ getAttributes() {
19768
+ let final = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
19769
+ return final && this.finalAttribute ? this.finalAttribute : this.attribute;
19770
+ }
19771
+ animate(params) {
19772
+ var _a, _b, _c;
19773
+ this.animates || (this.animates = new Map());
19774
+ const animate = new Animate(null == params ? void 0 : params.id, null !== (_b = null !== (_a = null == params ? void 0 : params.timeline) && void 0 !== _a ? _a : this.stage && this.stage.getTimeline()) && void 0 !== _b ? _b : defaultTimeline, null == params ? void 0 : params.slience);
19775
+ if (animate.bind(this), params) {
19776
+ const {
19777
+ onStart: onStart,
19778
+ onEnd: onEnd,
19779
+ onRemove: onRemove
19780
+ } = params;
19781
+ null != onStart && animate.onStart(onStart), null != onEnd && animate.onEnd(onEnd), null != onRemove && animate.onRemove(onRemove);
19782
+ }
19783
+ return this.animates.set(animate.id, animate), animate.onRemove(() => {
19784
+ animate.stop(), this.animates.delete(animate.id);
19785
+ }), null === (_c = this.stage) || void 0 === _c || _c.ticker.start(), animate;
19786
+ }
19787
+ createTimeline() {
19788
+ return new DefaultTimeline();
19789
+ }
19790
+ createTicker(stage) {
19791
+ return new DefaultTicker(stage);
19792
+ }
19793
+ setFinalAttribute(finalAttribute) {
19794
+ this.finalAttribute || (this.finalAttribute = {}), Object.assign(this.finalAttribute, finalAttribute);
19795
+ }
19796
+ initFinalAttribute(finalAttribute) {
19797
+ this.finalAttribute = finalAttribute;
19798
+ }
19799
+ initAnimateExecutor() {
19800
+ this._animateExecutor || (this._animateExecutor = new AnimateExecutor(this));
19801
+ }
19802
+ executeAnimation(config) {
19803
+ return this.initAnimateExecutor(), this._animateExecutor.execute(config), this;
19804
+ }
19805
+ executeAnimations(configs) {
19806
+ return this.initAnimateExecutor(), configs.forEach(config => {
19807
+ this._animateExecutor.execute(config);
19808
+ }), this;
19809
+ }
19810
+ getFinalAttribute() {
19811
+ return this.finalAttribute;
19812
+ }
19813
+ getGraphicAttribute(key) {
19814
+ let prev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
19815
+ return !prev && this.finalAttribute ? this.finalAttribute[key] : this.attribute[key];
19816
+ }
19817
+ }
19818
+
19819
+ function registerAnimate() {
19820
+ mixin(Graphic, GraphicStateExtension), mixin(Graphic, AnimateExtension);
19821
+ }
19822
+
19389
19823
  class ACustomAnimate extends Step {
19390
19824
  constructor(customFrom, customTo, duration, easing, params) {
19391
19825
  super("customAnimate", customTo, duration, easing), this.type = "customAnimate", this.customFrom = customFrom, this.params = params;
@@ -24970,22 +25404,27 @@ var IMarkPointItemPosition;
24970
25404
  function loadBaseMarker() {
24971
25405
  registerGroup();
24972
25406
  loadTagComponent();
25407
+ registerAnimate();
24973
25408
  }
24974
25409
  function loadMarkLineComponent() {
24975
25410
  loadBaseMarker();
24976
25411
  loadSegmentComponent();
25412
+ registerAnimate();
24977
25413
  }
24978
25414
  function loadMarkArcLineComponent() {
24979
25415
  loadBaseMarker();
24980
25416
  loadArcSegmentComponent();
25417
+ registerAnimate();
24981
25418
  }
24982
25419
  function loadMarkAreaComponent() {
24983
25420
  loadBaseMarker();
24984
25421
  registerPolygon();
25422
+ registerAnimate();
24985
25423
  }
24986
25424
  function loadMarkArcAreaComponent() {
24987
25425
  loadBaseMarker();
24988
25426
  registerArc();
25427
+ registerAnimate();
24989
25428
  }
24990
25429
  function loadMarkPointComponent() {
24991
25430
  loadBaseMarker();
@@ -24994,6 +25433,7 @@ function loadMarkPointComponent() {
24994
25433
  registerSymbol();
24995
25434
  registerImage();
24996
25435
  registerLine();
25436
+ registerAnimate();
24997
25437
  }
24998
25438
 
24999
25439
  class Marker extends AbstractComponent {
@@ -26446,7 +26886,7 @@ class MarkPoint extends Marker {
26446
26886
  if (!item) {
26447
26887
  return;
26448
26888
  }
26449
- const { autoRotate = true, refX = 0, refY = 0, refAngle = 0, textStyle = {}, richTextStyle = {}, imageStyle = {}, position: positionType = IMarkPointItemPosition.middle } = itemContent;
26889
+ const { autoRotate = true, refX = 0, refY = 0, refAngle = 0, style, position: positionType = IMarkPointItemPosition.middle } = itemContent;
26450
26890
  const { state } = this.attribute;
26451
26891
  const lineEndAngle = ((_a = this._line) === null || _a === void 0 ? void 0 : _a.getEndAngle()) || 0;
26452
26892
  const itemRefOffsetX = refX * Math.cos(lineEndAngle) + refY * Math.cos(lineEndAngle - Math.PI / 2);
@@ -26454,24 +26894,24 @@ class MarkPoint extends Marker {
26454
26894
  if (itemType === 'text') {
26455
26895
  const offsetX = newItemPosition.x - newPosition.x;
26456
26896
  const offsetY = newItemPosition.y - newPosition.y;
26457
- item.setAttributes(Object.assign(Object.assign({}, textStyle), { textStyle: Object.assign(Object.assign({}, this.getTextAlignAttr(autoRotate, offsetX, offsetY, lineEndAngle, (_b = itemContent.position) !== null && _b !== void 0 ? _b : 'end')), textStyle.textStyle), state: {
26897
+ item.setAttributes(Object.assign(Object.assign({}, style), { style: Object.assign(Object.assign({}, this.getTextAlignAttr(autoRotate, offsetX, offsetY, lineEndAngle, (_b = itemContent.position) !== null && _b !== void 0 ? _b : 'end')), style.textStyle), state: {
26458
26898
  panel: merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.textBackground),
26459
- text: merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.text)
26899
+ text: merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.itemContent)
26460
26900
  } }));
26461
26901
  }
26462
26902
  else if (itemType === 'richText') {
26463
26903
  item.setAttributes({
26464
- dx: this.getItemDx(item, positionType, richTextStyle) + (richTextStyle.dx || 0),
26465
- dy: this.getItemDy(item, positionType, richTextStyle) + (richTextStyle.dy || 0)
26904
+ dx: this.getItemDx(item, positionType, style) + (style.dx || 0),
26905
+ dy: this.getItemDy(item, positionType, style) + (style.dy || 0)
26466
26906
  });
26467
- item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.richText);
26907
+ item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.itemContent);
26468
26908
  }
26469
26909
  else if (itemType === 'image') {
26470
26910
  item.setAttributes({
26471
- dx: this.getItemDx(item, positionType, imageStyle) + (imageStyle.dx || 0),
26472
- dy: this.getItemDy(item, positionType, imageStyle) + (imageStyle.dy || 0)
26911
+ dx: this.getItemDx(item, positionType, style) + (style.dx || 0),
26912
+ dy: this.getItemDy(item, positionType, style) + (style.dy || 0)
26473
26913
  });
26474
- item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.image);
26914
+ item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.itemContent);
26475
26915
  }
26476
26916
  const itemAngle = isPostiveXAxis(lineEndAngle) ? lineEndAngle : lineEndAngle - Math.PI;
26477
26917
  item.setAttributes({
@@ -26504,29 +26944,25 @@ class MarkPoint extends Marker {
26504
26944
  }
26505
26945
  initItem(itemContent, newPosition, newItemPosition) {
26506
26946
  const { state } = this.attribute;
26507
- const { type = 'text', symbolStyle, richTextStyle, imageStyle, renderCustomCallback } = itemContent;
26947
+ const { type = 'text', style, renderCustomCallback } = itemContent;
26508
26948
  let item;
26509
26949
  if (type === 'symbol') {
26510
- item = graphicCreator.symbol(Object.assign(Object.assign({}, newItemPosition), symbolStyle));
26511
- item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.symbol);
26950
+ item = graphicCreator.symbol(Object.assign(Object.assign({}, newItemPosition), style));
26951
+ item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.itemContent);
26512
26952
  }
26513
26953
  else if (type === 'text') {
26514
26954
  item = new Tag(Object.assign(Object.assign({}, newItemPosition), { state: {
26515
26955
  panel: merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.textBackground),
26516
- text: merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.text)
26956
+ text: merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.itemContent)
26517
26957
  } }));
26518
26958
  }
26519
- else if (type === 'richText') {
26520
- item = graphicCreator.richtext(Object.assign(Object.assign({}, newItemPosition), richTextStyle));
26521
- item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.richText);
26522
- }
26523
26959
  else if (type === 'image') {
26524
- item = graphicCreator.image(Object.assign(Object.assign({}, newItemPosition), imageStyle));
26525
- item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.image);
26960
+ item = graphicCreator.image(Object.assign(Object.assign({}, newItemPosition), style));
26961
+ item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.itemContent);
26526
26962
  }
26527
26963
  else if (type === 'custom' && renderCustomCallback) {
26528
26964
  item = renderCustomCallback();
26529
- item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.customMark);
26965
+ item.states = merge({}, DEFAULT_STATES$2, state === null || state === void 0 ? void 0 : state.itemContent);
26530
26966
  }
26531
26967
  item.name = `mark-point-${type}`;
26532
26968
  this.setItemAttributes(item, itemContent, newPosition, newItemPosition, type);
@@ -26714,7 +27150,7 @@ class MarkPoint extends Marker {
26714
27150
  const { itemContent = {}, targetSymbol, itemLine } = this.attribute;
26715
27151
  const { offsetX: itemContentOffsetX = 0, offsetY: itemContentOffsetY = 0 } = itemContent;
26716
27152
  const { offset: targetSymbolOffset = 0, style: targetSymbolStyle, visible: targetItemvisible = false, size: targetSymbolSize } = targetSymbol;
26717
- const targetSize = targetItemvisible ? (_b = (_a = targetSymbolStyle.size) !== null && _a !== void 0 ? _a : targetSymbolSize) !== null && _b !== void 0 ? _b : 20 : 0;
27153
+ const targetSize = targetItemvisible ? ((_b = (_a = targetSymbolStyle.size) !== null && _a !== void 0 ? _a : targetSymbolSize) !== null && _b !== void 0 ? _b : 20) : 0;
26718
27154
  let targetOffsetAngle;
26719
27155
  if (itemLine.type === 'type-do') {
26720
27156
  targetOffsetAngle = deltaXYToAngle(itemContentOffsetY, itemContentOffsetX / 2);
@@ -32610,6 +33046,6 @@ StoryLabelItem.defaultAttributes = {
32610
33046
  theme: 'default'
32611
33047
  };
32612
33048
 
32613
- const version = "1.0.0-alpha.13";
33049
+ const version = "1.0.0-alpha.14";
32614
33050
 
32615
33051
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PolygonSectorCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, StoryLabelItem, Switch, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, WeatherBox, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, scrollbarModule, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };