逐步完成前后端服务器

This commit is contained in:
2025-09-09 15:00:30 +08:00
parent fcb09432e9
commit c7dfa1e9fc
2937 changed files with 1477567 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import Eventful from '../core/Eventful';
import Animator from './Animator';
import Clip from './Clip';
export declare function getTime(): number;
interface Stage {
update?: () => void;
}
interface AnimationOption {
stage?: Stage;
}
export default class Animation extends Eventful {
stage: Stage;
private _head;
private _tail;
private _running;
private _time;
private _pausedTime;
private _pauseStart;
private _paused;
constructor(opts?: AnimationOption);
addClip(clip: Clip): void;
addAnimator(animator: Animator<any>): void;
removeClip(clip: Clip): void;
removeAnimator(animator: Animator<any>): void;
update(notTriggerFrameAndStageUpdate?: boolean): void;
_startLoop(): void;
start(): void;
stop(): void;
pause(): void;
resume(): void;
clear(): void;
isFinished(): boolean;
animate<T>(target: T, options: {
loop?: boolean;
}): Animator<T>;
}
export {};

View File

@ -0,0 +1,147 @@
import { __extends } from "tslib";
import Eventful from '../core/Eventful.js';
import requestAnimationFrame from './requestAnimationFrame.js';
import Animator from './Animator.js';
export function getTime() {
return new Date().getTime();
}
var Animation = (function (_super) {
__extends(Animation, _super);
function Animation(opts) {
var _this = _super.call(this) || this;
_this._running = false;
_this._time = 0;
_this._pausedTime = 0;
_this._pauseStart = 0;
_this._paused = false;
opts = opts || {};
_this.stage = opts.stage || {};
return _this;
}
Animation.prototype.addClip = function (clip) {
if (clip.animation) {
this.removeClip(clip);
}
if (!this._head) {
this._head = this._tail = clip;
}
else {
this._tail.next = clip;
clip.prev = this._tail;
clip.next = null;
this._tail = clip;
}
clip.animation = this;
};
Animation.prototype.addAnimator = function (animator) {
animator.animation = this;
var clip = animator.getClip();
if (clip) {
this.addClip(clip);
}
};
Animation.prototype.removeClip = function (clip) {
if (!clip.animation) {
return;
}
var prev = clip.prev;
var next = clip.next;
if (prev) {
prev.next = next;
}
else {
this._head = next;
}
if (next) {
next.prev = prev;
}
else {
this._tail = prev;
}
clip.next = clip.prev = clip.animation = null;
};
Animation.prototype.removeAnimator = function (animator) {
var clip = animator.getClip();
if (clip) {
this.removeClip(clip);
}
animator.animation = null;
};
Animation.prototype.update = function (notTriggerFrameAndStageUpdate) {
var time = getTime() - this._pausedTime;
var delta = time - this._time;
var clip = this._head;
while (clip) {
var nextClip = clip.next;
var finished = clip.step(time, delta);
if (finished) {
clip.ondestroy();
this.removeClip(clip);
clip = nextClip;
}
else {
clip = nextClip;
}
}
this._time = time;
if (!notTriggerFrameAndStageUpdate) {
this.trigger('frame', delta);
this.stage.update && this.stage.update();
}
};
Animation.prototype._startLoop = function () {
var self = this;
this._running = true;
function step() {
if (self._running) {
requestAnimationFrame(step);
!self._paused && self.update();
}
}
requestAnimationFrame(step);
};
Animation.prototype.start = function () {
if (this._running) {
return;
}
this._time = getTime();
this._pausedTime = 0;
this._startLoop();
};
Animation.prototype.stop = function () {
this._running = false;
};
Animation.prototype.pause = function () {
if (!this._paused) {
this._pauseStart = getTime();
this._paused = true;
}
};
Animation.prototype.resume = function () {
if (this._paused) {
this._pausedTime += getTime() - this._pauseStart;
this._paused = false;
}
};
Animation.prototype.clear = function () {
var clip = this._head;
while (clip) {
var nextClip = clip.next;
clip.prev = clip.next = clip.animation = null;
clip = nextClip;
}
this._head = this._tail = null;
};
Animation.prototype.isFinished = function () {
return this._head == null;
};
Animation.prototype.animate = function (target, options) {
options = options || {};
this.start();
var animator = new Animator(target, options.loop);
this.addAnimator(animator);
return animator;
};
return Animation;
}(Eventful));
export default Animation;

View File

@ -0,0 +1,95 @@
import Clip from './Clip';
import { ArrayLike, Dictionary } from '../core/types';
import { AnimationEasing } from './easing';
import Animation from './Animation';
declare type NumberArray = ArrayLike<number>;
declare type InterpolatableType = string | number | NumberArray | NumberArray[];
export declare function cloneValue(value: InterpolatableType): number | any[];
declare type ValueType = 0 | 1 | 2 | 3 | 4 | 5 | 6;
declare type Keyframe = {
time: number;
value: unknown;
percent: number;
rawValue: unknown;
easing?: AnimationEasing;
easingFunc?: (percent: number) => number;
additiveValue?: unknown;
};
declare class Track {
keyframes: Keyframe[];
propName: string;
valType: ValueType;
discrete: boolean;
_invalid: boolean;
private _finished;
private _needsSort;
private _additiveTrack;
private _additiveValue;
private _lastFr;
private _lastFrP;
constructor(propName: string);
isFinished(): boolean;
setFinished(): void;
needsAnimate(): boolean;
getAdditiveTrack(): Track;
addKeyframe(time: number, rawValue: unknown, easing?: AnimationEasing): Keyframe;
prepare(maxTime: number, additiveTrack?: Track): void;
step(target: any, percent: number): void;
private _addToTarget;
}
declare type DoneCallback = () => void;
declare type AbortCallback = () => void;
export declare type OnframeCallback<T> = (target: T, percent: number) => void;
export declare type AnimationPropGetter<T> = (target: T, key: string) => InterpolatableType;
export declare type AnimationPropSetter<T> = (target: T, key: string, value: InterpolatableType) => void;
export default class Animator<T> {
animation?: Animation;
targetName?: string;
scope?: string;
__fromStateTransition?: string;
private _tracks;
private _trackKeys;
private _target;
private _loop;
private _delay;
private _maxTime;
private _force;
private _paused;
private _started;
private _allowDiscrete;
private _additiveAnimators;
private _doneCbs;
private _onframeCbs;
private _abortedCbs;
private _clip;
constructor(target: T, loop: boolean, allowDiscreteAnimation?: boolean, additiveTo?: Animator<any>[]);
getMaxTime(): number;
getDelay(): number;
getLoop(): boolean;
getTarget(): T;
changeTarget(target: T): void;
when(time: number, props: Dictionary<any>, easing?: AnimationEasing): this;
whenWithKeys(time: number, props: Dictionary<any>, propNames: string[], easing?: AnimationEasing): this;
pause(): void;
resume(): void;
isPaused(): boolean;
duration(duration: number): this;
private _doneCallback;
private _abortedCallback;
private _setTracksFinished;
private _getAdditiveTrack;
start(easing?: AnimationEasing): this;
stop(forwardToLast?: boolean): void;
delay(time: number): this;
during(cb: OnframeCallback<T>): this;
done(cb: DoneCallback): this;
aborted(cb: AbortCallback): this;
getClip(): Clip;
getTrack(propName: string): Track;
getTracks(): Track[];
stopTracks(propNames: string[], forwardToLast?: boolean): boolean;
saveTo(target: T, trackKeys?: readonly string[], firstOrLast?: boolean): void;
__changeFinalValue(finalProps: Dictionary<any>, trackKeys?: readonly string[]): void;
}
export declare type AnimatorTrack = Track;
export {};

737
frontend/node_modules/zrender/lib/animation/Animator.js generated vendored Normal file
View File

@ -0,0 +1,737 @@
import Clip from './Clip.js';
import * as color from '../tool/color.js';
import { eqNaN, extend, isArrayLike, isFunction, isGradientObject, isNumber, isString, keys, logError, map } from '../core/util.js';
import easingFuncs from './easing.js';
import { createCubicEasingFunc } from './cubicEasing.js';
import { isLinearGradient, isRadialGradient } from '../svg/helper.js';
;
var arraySlice = Array.prototype.slice;
function interpolateNumber(p0, p1, percent) {
return (p1 - p0) * percent + p0;
}
function interpolate1DArray(out, p0, p1, percent) {
var len = p0.length;
for (var i = 0; i < len; i++) {
out[i] = interpolateNumber(p0[i], p1[i], percent);
}
return out;
}
function interpolate2DArray(out, p0, p1, percent) {
var len = p0.length;
var len2 = len && p0[0].length;
for (var i = 0; i < len; i++) {
if (!out[i]) {
out[i] = [];
}
for (var j = 0; j < len2; j++) {
out[i][j] = interpolateNumber(p0[i][j], p1[i][j], percent);
}
}
return out;
}
function add1DArray(out, p0, p1, sign) {
var len = p0.length;
for (var i = 0; i < len; i++) {
out[i] = p0[i] + p1[i] * sign;
}
return out;
}
function add2DArray(out, p0, p1, sign) {
var len = p0.length;
var len2 = len && p0[0].length;
for (var i = 0; i < len; i++) {
if (!out[i]) {
out[i] = [];
}
for (var j = 0; j < len2; j++) {
out[i][j] = p0[i][j] + p1[i][j] * sign;
}
}
return out;
}
function fillColorStops(val0, val1) {
var len0 = val0.length;
var len1 = val1.length;
var shorterArr = len0 > len1 ? val1 : val0;
var shorterLen = Math.min(len0, len1);
var last = shorterArr[shorterLen - 1] || { color: [0, 0, 0, 0], offset: 0 };
for (var i = shorterLen; i < Math.max(len0, len1); i++) {
shorterArr.push({
offset: last.offset,
color: last.color.slice()
});
}
}
function fillArray(val0, val1, arrDim) {
var arr0 = val0;
var arr1 = val1;
if (!arr0.push || !arr1.push) {
return;
}
var arr0Len = arr0.length;
var arr1Len = arr1.length;
if (arr0Len !== arr1Len) {
var isPreviousLarger = arr0Len > arr1Len;
if (isPreviousLarger) {
arr0.length = arr1Len;
}
else {
for (var i = arr0Len; i < arr1Len; i++) {
arr0.push(arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]));
}
}
}
var len2 = arr0[0] && arr0[0].length;
for (var i = 0; i < arr0.length; i++) {
if (arrDim === 1) {
if (isNaN(arr0[i])) {
arr0[i] = arr1[i];
}
}
else {
for (var j = 0; j < len2; j++) {
if (isNaN(arr0[i][j])) {
arr0[i][j] = arr1[i][j];
}
}
}
}
}
export function cloneValue(value) {
if (isArrayLike(value)) {
var len = value.length;
if (isArrayLike(value[0])) {
var ret = [];
for (var i = 0; i < len; i++) {
ret.push(arraySlice.call(value[i]));
}
return ret;
}
return arraySlice.call(value);
}
return value;
}
function rgba2String(rgba) {
rgba[0] = Math.floor(rgba[0]) || 0;
rgba[1] = Math.floor(rgba[1]) || 0;
rgba[2] = Math.floor(rgba[2]) || 0;
rgba[3] = rgba[3] == null ? 1 : rgba[3];
return 'rgba(' + rgba.join(',') + ')';
}
function guessArrayDim(value) {
return isArrayLike(value && value[0]) ? 2 : 1;
}
var VALUE_TYPE_NUMBER = 0;
var VALUE_TYPE_1D_ARRAY = 1;
var VALUE_TYPE_2D_ARRAY = 2;
var VALUE_TYPE_COLOR = 3;
var VALUE_TYPE_LINEAR_GRADIENT = 4;
var VALUE_TYPE_RADIAL_GRADIENT = 5;
var VALUE_TYPE_UNKOWN = 6;
function isGradientValueType(valType) {
return valType === VALUE_TYPE_LINEAR_GRADIENT || valType === VALUE_TYPE_RADIAL_GRADIENT;
}
function isArrayValueType(valType) {
return valType === VALUE_TYPE_1D_ARRAY || valType === VALUE_TYPE_2D_ARRAY;
}
var tmpRgba = [0, 0, 0, 0];
var Track = (function () {
function Track(propName) {
this.keyframes = [];
this.discrete = false;
this._invalid = false;
this._needsSort = false;
this._lastFr = 0;
this._lastFrP = 0;
this.propName = propName;
}
Track.prototype.isFinished = function () {
return this._finished;
};
Track.prototype.setFinished = function () {
this._finished = true;
if (this._additiveTrack) {
this._additiveTrack.setFinished();
}
};
Track.prototype.needsAnimate = function () {
return this.keyframes.length >= 1;
};
Track.prototype.getAdditiveTrack = function () {
return this._additiveTrack;
};
Track.prototype.addKeyframe = function (time, rawValue, easing) {
this._needsSort = true;
var keyframes = this.keyframes;
var len = keyframes.length;
var discrete = false;
var valType = VALUE_TYPE_UNKOWN;
var value = rawValue;
if (isArrayLike(rawValue)) {
var arrayDim = guessArrayDim(rawValue);
valType = arrayDim;
if (arrayDim === 1 && !isNumber(rawValue[0])
|| arrayDim === 2 && !isNumber(rawValue[0][0])) {
discrete = true;
}
}
else {
if (isNumber(rawValue) && !eqNaN(rawValue)) {
valType = VALUE_TYPE_NUMBER;
}
else if (isString(rawValue)) {
if (!isNaN(+rawValue)) {
valType = VALUE_TYPE_NUMBER;
}
else {
var colorArray = color.parse(rawValue);
if (colorArray) {
value = colorArray;
valType = VALUE_TYPE_COLOR;
}
}
}
else if (isGradientObject(rawValue)) {
var parsedGradient = extend({}, value);
parsedGradient.colorStops = map(rawValue.colorStops, function (colorStop) { return ({
offset: colorStop.offset,
color: color.parse(colorStop.color)
}); });
if (isLinearGradient(rawValue)) {
valType = VALUE_TYPE_LINEAR_GRADIENT;
}
else if (isRadialGradient(rawValue)) {
valType = VALUE_TYPE_RADIAL_GRADIENT;
}
value = parsedGradient;
}
}
if (len === 0) {
this.valType = valType;
}
else if (valType !== this.valType || valType === VALUE_TYPE_UNKOWN) {
discrete = true;
}
this.discrete = this.discrete || discrete;
var kf = {
time: time,
value: value,
rawValue: rawValue,
percent: 0
};
if (easing) {
kf.easing = easing;
kf.easingFunc = isFunction(easing)
? easing
: easingFuncs[easing] || createCubicEasingFunc(easing);
}
keyframes.push(kf);
return kf;
};
Track.prototype.prepare = function (maxTime, additiveTrack) {
var kfs = this.keyframes;
if (this._needsSort) {
kfs.sort(function (a, b) {
return a.time - b.time;
});
}
var valType = this.valType;
var kfsLen = kfs.length;
var lastKf = kfs[kfsLen - 1];
var isDiscrete = this.discrete;
var isArr = isArrayValueType(valType);
var isGradient = isGradientValueType(valType);
for (var i = 0; i < kfsLen; i++) {
var kf = kfs[i];
var value = kf.value;
var lastValue = lastKf.value;
kf.percent = kf.time / maxTime;
if (!isDiscrete) {
if (isArr && i !== kfsLen - 1) {
fillArray(value, lastValue, valType);
}
else if (isGradient) {
fillColorStops(value.colorStops, lastValue.colorStops);
}
}
}
if (!isDiscrete
&& valType !== VALUE_TYPE_RADIAL_GRADIENT
&& additiveTrack
&& this.needsAnimate()
&& additiveTrack.needsAnimate()
&& valType === additiveTrack.valType
&& !additiveTrack._finished) {
this._additiveTrack = additiveTrack;
var startValue = kfs[0].value;
for (var i = 0; i < kfsLen; i++) {
if (valType === VALUE_TYPE_NUMBER) {
kfs[i].additiveValue = kfs[i].value - startValue;
}
else if (valType === VALUE_TYPE_COLOR) {
kfs[i].additiveValue =
add1DArray([], kfs[i].value, startValue, -1);
}
else if (isArrayValueType(valType)) {
kfs[i].additiveValue = valType === VALUE_TYPE_1D_ARRAY
? add1DArray([], kfs[i].value, startValue, -1)
: add2DArray([], kfs[i].value, startValue, -1);
}
}
}
};
Track.prototype.step = function (target, percent) {
if (this._finished) {
return;
}
if (this._additiveTrack && this._additiveTrack._finished) {
this._additiveTrack = null;
}
var isAdditive = this._additiveTrack != null;
var valueKey = isAdditive ? 'additiveValue' : 'value';
var valType = this.valType;
var keyframes = this.keyframes;
var kfsNum = keyframes.length;
var propName = this.propName;
var isValueColor = valType === VALUE_TYPE_COLOR;
var frameIdx;
var lastFrame = this._lastFr;
var mathMin = Math.min;
var frame;
var nextFrame;
if (kfsNum === 1) {
frame = nextFrame = keyframes[0];
}
else {
if (percent < 0) {
frameIdx = 0;
}
else if (percent < this._lastFrP) {
var start = mathMin(lastFrame + 1, kfsNum - 1);
for (frameIdx = start; frameIdx >= 0; frameIdx--) {
if (keyframes[frameIdx].percent <= percent) {
break;
}
}
frameIdx = mathMin(frameIdx, kfsNum - 2);
}
else {
for (frameIdx = lastFrame; frameIdx < kfsNum; frameIdx++) {
if (keyframes[frameIdx].percent > percent) {
break;
}
}
frameIdx = mathMin(frameIdx - 1, kfsNum - 2);
}
nextFrame = keyframes[frameIdx + 1];
frame = keyframes[frameIdx];
}
if (!(frame && nextFrame)) {
return;
}
this._lastFr = frameIdx;
this._lastFrP = percent;
var interval = (nextFrame.percent - frame.percent);
var w = interval === 0 ? 1 : mathMin((percent - frame.percent) / interval, 1);
if (nextFrame.easingFunc) {
w = nextFrame.easingFunc(w);
}
var targetArr = isAdditive ? this._additiveValue
: (isValueColor ? tmpRgba : target[propName]);
if ((isArrayValueType(valType) || isValueColor) && !targetArr) {
targetArr = this._additiveValue = [];
}
if (this.discrete) {
target[propName] = w < 1 ? frame.rawValue : nextFrame.rawValue;
}
else if (isArrayValueType(valType)) {
valType === VALUE_TYPE_1D_ARRAY
? interpolate1DArray(targetArr, frame[valueKey], nextFrame[valueKey], w)
: interpolate2DArray(targetArr, frame[valueKey], nextFrame[valueKey], w);
}
else if (isGradientValueType(valType)) {
var val = frame[valueKey];
var nextVal_1 = nextFrame[valueKey];
var isLinearGradient_1 = valType === VALUE_TYPE_LINEAR_GRADIENT;
target[propName] = {
type: isLinearGradient_1 ? 'linear' : 'radial',
x: interpolateNumber(val.x, nextVal_1.x, w),
y: interpolateNumber(val.y, nextVal_1.y, w),
colorStops: map(val.colorStops, function (colorStop, idx) {
var nextColorStop = nextVal_1.colorStops[idx];
return {
offset: interpolateNumber(colorStop.offset, nextColorStop.offset, w),
color: rgba2String(interpolate1DArray([], colorStop.color, nextColorStop.color, w))
};
}),
global: nextVal_1.global
};
if (isLinearGradient_1) {
target[propName].x2 = interpolateNumber(val.x2, nextVal_1.x2, w);
target[propName].y2 = interpolateNumber(val.y2, nextVal_1.y2, w);
}
else {
target[propName].r = interpolateNumber(val.r, nextVal_1.r, w);
}
}
else if (isValueColor) {
interpolate1DArray(targetArr, frame[valueKey], nextFrame[valueKey], w);
if (!isAdditive) {
target[propName] = rgba2String(targetArr);
}
}
else {
var value = interpolateNumber(frame[valueKey], nextFrame[valueKey], w);
if (isAdditive) {
this._additiveValue = value;
}
else {
target[propName] = value;
}
}
if (isAdditive) {
this._addToTarget(target);
}
};
Track.prototype._addToTarget = function (target) {
var valType = this.valType;
var propName = this.propName;
var additiveValue = this._additiveValue;
if (valType === VALUE_TYPE_NUMBER) {
target[propName] = target[propName] + additiveValue;
}
else if (valType === VALUE_TYPE_COLOR) {
color.parse(target[propName], tmpRgba);
add1DArray(tmpRgba, tmpRgba, additiveValue, 1);
target[propName] = rgba2String(tmpRgba);
}
else if (valType === VALUE_TYPE_1D_ARRAY) {
add1DArray(target[propName], target[propName], additiveValue, 1);
}
else if (valType === VALUE_TYPE_2D_ARRAY) {
add2DArray(target[propName], target[propName], additiveValue, 1);
}
};
return Track;
}());
var Animator = (function () {
function Animator(target, loop, allowDiscreteAnimation, additiveTo) {
this._tracks = {};
this._trackKeys = [];
this._maxTime = 0;
this._started = 0;
this._clip = null;
this._target = target;
this._loop = loop;
if (loop && additiveTo) {
logError('Can\' use additive animation on looped animation.');
return;
}
this._additiveAnimators = additiveTo;
this._allowDiscrete = allowDiscreteAnimation;
}
Animator.prototype.getMaxTime = function () {
return this._maxTime;
};
Animator.prototype.getDelay = function () {
return this._delay;
};
Animator.prototype.getLoop = function () {
return this._loop;
};
Animator.prototype.getTarget = function () {
return this._target;
};
Animator.prototype.changeTarget = function (target) {
this._target = target;
};
Animator.prototype.when = function (time, props, easing) {
return this.whenWithKeys(time, props, keys(props), easing);
};
Animator.prototype.whenWithKeys = function (time, props, propNames, easing) {
var tracks = this._tracks;
for (var i = 0; i < propNames.length; i++) {
var propName = propNames[i];
var track = tracks[propName];
if (!track) {
track = tracks[propName] = new Track(propName);
var initialValue = void 0;
var additiveTrack = this._getAdditiveTrack(propName);
if (additiveTrack) {
var addtiveTrackKfs = additiveTrack.keyframes;
var lastFinalKf = addtiveTrackKfs[addtiveTrackKfs.length - 1];
initialValue = lastFinalKf && lastFinalKf.value;
if (additiveTrack.valType === VALUE_TYPE_COLOR && initialValue) {
initialValue = rgba2String(initialValue);
}
}
else {
initialValue = this._target[propName];
}
if (initialValue == null) {
continue;
}
if (time > 0) {
track.addKeyframe(0, cloneValue(initialValue), easing);
}
this._trackKeys.push(propName);
}
track.addKeyframe(time, cloneValue(props[propName]), easing);
}
this._maxTime = Math.max(this._maxTime, time);
return this;
};
Animator.prototype.pause = function () {
this._clip.pause();
this._paused = true;
};
Animator.prototype.resume = function () {
this._clip.resume();
this._paused = false;
};
Animator.prototype.isPaused = function () {
return !!this._paused;
};
Animator.prototype.duration = function (duration) {
this._maxTime = duration;
this._force = true;
return this;
};
Animator.prototype._doneCallback = function () {
this._setTracksFinished();
this._clip = null;
var doneList = this._doneCbs;
if (doneList) {
var len = doneList.length;
for (var i = 0; i < len; i++) {
doneList[i].call(this);
}
}
};
Animator.prototype._abortedCallback = function () {
this._setTracksFinished();
var animation = this.animation;
var abortedList = this._abortedCbs;
if (animation) {
animation.removeClip(this._clip);
}
this._clip = null;
if (abortedList) {
for (var i = 0; i < abortedList.length; i++) {
abortedList[i].call(this);
}
}
};
Animator.prototype._setTracksFinished = function () {
var tracks = this._tracks;
var tracksKeys = this._trackKeys;
for (var i = 0; i < tracksKeys.length; i++) {
tracks[tracksKeys[i]].setFinished();
}
};
Animator.prototype._getAdditiveTrack = function (trackName) {
var additiveTrack;
var additiveAnimators = this._additiveAnimators;
if (additiveAnimators) {
for (var i = 0; i < additiveAnimators.length; i++) {
var track = additiveAnimators[i].getTrack(trackName);
if (track) {
additiveTrack = track;
}
}
}
return additiveTrack;
};
Animator.prototype.start = function (easing) {
if (this._started > 0) {
return;
}
this._started = 1;
var self = this;
var tracks = [];
var maxTime = this._maxTime || 0;
for (var i = 0; i < this._trackKeys.length; i++) {
var propName = this._trackKeys[i];
var track = this._tracks[propName];
var additiveTrack = this._getAdditiveTrack(propName);
var kfs = track.keyframes;
var kfsNum = kfs.length;
track.prepare(maxTime, additiveTrack);
if (track.needsAnimate()) {
if (!this._allowDiscrete && track.discrete) {
var lastKf = kfs[kfsNum - 1];
if (lastKf) {
self._target[track.propName] = lastKf.rawValue;
}
track.setFinished();
}
else {
tracks.push(track);
}
}
}
if (tracks.length || this._force) {
var clip = new Clip({
life: maxTime,
loop: this._loop,
delay: this._delay || 0,
onframe: function (percent) {
self._started = 2;
var additiveAnimators = self._additiveAnimators;
if (additiveAnimators) {
var stillHasAdditiveAnimator = false;
for (var i = 0; i < additiveAnimators.length; i++) {
if (additiveAnimators[i]._clip) {
stillHasAdditiveAnimator = true;
break;
}
}
if (!stillHasAdditiveAnimator) {
self._additiveAnimators = null;
}
}
for (var i = 0; i < tracks.length; i++) {
tracks[i].step(self._target, percent);
}
var onframeList = self._onframeCbs;
if (onframeList) {
for (var i = 0; i < onframeList.length; i++) {
onframeList[i](self._target, percent);
}
}
},
ondestroy: function () {
self._doneCallback();
}
});
this._clip = clip;
if (this.animation) {
this.animation.addClip(clip);
}
if (easing) {
clip.setEasing(easing);
}
}
else {
this._doneCallback();
}
return this;
};
Animator.prototype.stop = function (forwardToLast) {
if (!this._clip) {
return;
}
var clip = this._clip;
if (forwardToLast) {
clip.onframe(1);
}
this._abortedCallback();
};
Animator.prototype.delay = function (time) {
this._delay = time;
return this;
};
Animator.prototype.during = function (cb) {
if (cb) {
if (!this._onframeCbs) {
this._onframeCbs = [];
}
this._onframeCbs.push(cb);
}
return this;
};
Animator.prototype.done = function (cb) {
if (cb) {
if (!this._doneCbs) {
this._doneCbs = [];
}
this._doneCbs.push(cb);
}
return this;
};
Animator.prototype.aborted = function (cb) {
if (cb) {
if (!this._abortedCbs) {
this._abortedCbs = [];
}
this._abortedCbs.push(cb);
}
return this;
};
Animator.prototype.getClip = function () {
return this._clip;
};
Animator.prototype.getTrack = function (propName) {
return this._tracks[propName];
};
Animator.prototype.getTracks = function () {
var _this = this;
return map(this._trackKeys, function (key) { return _this._tracks[key]; });
};
Animator.prototype.stopTracks = function (propNames, forwardToLast) {
if (!propNames.length || !this._clip) {
return true;
}
var tracks = this._tracks;
var tracksKeys = this._trackKeys;
for (var i = 0; i < propNames.length; i++) {
var track = tracks[propNames[i]];
if (track && !track.isFinished()) {
if (forwardToLast) {
track.step(this._target, 1);
}
else if (this._started === 1) {
track.step(this._target, 0);
}
track.setFinished();
}
}
var allAborted = true;
for (var i = 0; i < tracksKeys.length; i++) {
if (!tracks[tracksKeys[i]].isFinished()) {
allAborted = false;
break;
}
}
if (allAborted) {
this._abortedCallback();
}
return allAborted;
};
Animator.prototype.saveTo = function (target, trackKeys, firstOrLast) {
if (!target) {
return;
}
trackKeys = trackKeys || this._trackKeys;
for (var i = 0; i < trackKeys.length; i++) {
var propName = trackKeys[i];
var track = this._tracks[propName];
if (!track || track.isFinished()) {
continue;
}
var kfs = track.keyframes;
var kf = kfs[firstOrLast ? 0 : kfs.length - 1];
if (kf) {
target[propName] = cloneValue(kf.rawValue);
}
}
};
Animator.prototype.__changeFinalValue = function (finalProps, trackKeys) {
trackKeys = trackKeys || keys(finalProps);
for (var i = 0; i < trackKeys.length; i++) {
var propName = trackKeys[i];
var track = this._tracks[propName];
if (!track) {
continue;
}
var kfs = track.keyframes;
if (kfs.length > 1) {
var lastKf = kfs.pop();
track.addKeyframe(lastKf.time, finalProps[propName]);
track.prepare(this._maxTime, track.getAdditiveTrack());
}
}
};
return Animator;
}());
export default Animator;

38
frontend/node_modules/zrender/lib/animation/Clip.d.ts generated vendored Normal file
View File

@ -0,0 +1,38 @@
import { AnimationEasing } from './easing';
import type Animation from './Animation';
declare type OnframeCallback = (percent: number) => void;
declare type ondestroyCallback = () => void;
declare type onrestartCallback = () => void;
export declare type DeferredEventTypes = 'destroy' | 'restart';
export interface ClipProps {
life?: number;
delay?: number;
loop?: boolean;
easing?: AnimationEasing;
onframe?: OnframeCallback;
ondestroy?: ondestroyCallback;
onrestart?: onrestartCallback;
}
export default class Clip {
private _life;
private _delay;
private _inited;
private _startTime;
private _pausedTime;
private _paused;
animation: Animation;
loop: boolean;
easing: AnimationEasing;
easingFunc: (p: number) => number;
next: Clip;
prev: Clip;
onframe: OnframeCallback;
ondestroy: ondestroyCallback;
onrestart: onrestartCallback;
constructor(opts: ClipProps);
step(globalTime: number, deltaTime: number): boolean;
pause(): void;
resume(): void;
setEasing(easing: AnimationEasing): void;
}
export {};

64
frontend/node_modules/zrender/lib/animation/Clip.js generated vendored Normal file
View File

@ -0,0 +1,64 @@
import easingFuncs from './easing.js';
import { isFunction, noop } from '../core/util.js';
import { createCubicEasingFunc } from './cubicEasing.js';
var Clip = (function () {
function Clip(opts) {
this._inited = false;
this._startTime = 0;
this._pausedTime = 0;
this._paused = false;
this._life = opts.life || 1000;
this._delay = opts.delay || 0;
this.loop = opts.loop || false;
this.onframe = opts.onframe || noop;
this.ondestroy = opts.ondestroy || noop;
this.onrestart = opts.onrestart || noop;
opts.easing && this.setEasing(opts.easing);
}
Clip.prototype.step = function (globalTime, deltaTime) {
if (!this._inited) {
this._startTime = globalTime + this._delay;
this._inited = true;
}
if (this._paused) {
this._pausedTime += deltaTime;
return;
}
var life = this._life;
var elapsedTime = globalTime - this._startTime - this._pausedTime;
var percent = elapsedTime / life;
if (percent < 0) {
percent = 0;
}
percent = Math.min(percent, 1);
var easingFunc = this.easingFunc;
var schedule = easingFunc ? easingFunc(percent) : percent;
this.onframe(schedule);
if (percent === 1) {
if (this.loop) {
var remainder = elapsedTime % life;
this._startTime = globalTime - remainder;
this._pausedTime = 0;
this.onrestart();
}
else {
return true;
}
}
return false;
};
Clip.prototype.pause = function () {
this._paused = true;
};
Clip.prototype.resume = function () {
this._paused = false;
};
Clip.prototype.setEasing = function (easing) {
this.easing = easing;
this.easingFunc = isFunction(easing)
? easing
: easingFuncs[easing] || createCubicEasingFunc(easing);
};
return Clip;
}());
export default Clip;

View File

@ -0,0 +1 @@
export declare function createCubicEasingFunc(cubicEasingStr: string): (p: number) => number;

View File

@ -0,0 +1,23 @@
import { cubicAt, cubicRootAt } from '../core/curve.js';
import { trim } from '../core/util.js';
var regexp = /cubic-bezier\(([0-9,\.e ]+)\)/;
export function createCubicEasingFunc(cubicEasingStr) {
var cubic = cubicEasingStr && regexp.exec(cubicEasingStr);
if (cubic) {
var points = cubic[1].split(',');
var a_1 = +trim(points[0]);
var b_1 = +trim(points[1]);
var c_1 = +trim(points[2]);
var d_1 = +trim(points[3]);
if (isNaN(a_1 + b_1 + c_1 + d_1)) {
return;
}
var roots_1 = [];
return function (p) {
return p <= 0
? 0 : p >= 1
? 1
: cubicRootAt(0, a_1, c_1, 1, p, roots_1) && cubicAt(0, b_1, d_1, 1, roots_1[0]);
};
}
}

View File

@ -0,0 +1,36 @@
declare type easingFunc = (percent: number) => number;
export declare type AnimationEasing = keyof typeof easingFuncs | easingFunc;
declare const easingFuncs: {
linear(k: number): number;
quadraticIn(k: number): number;
quadraticOut(k: number): number;
quadraticInOut(k: number): number;
cubicIn(k: number): number;
cubicOut(k: number): number;
cubicInOut(k: number): number;
quarticIn(k: number): number;
quarticOut(k: number): number;
quarticInOut(k: number): number;
quinticIn(k: number): number;
quinticOut(k: number): number;
quinticInOut(k: number): number;
sinusoidalIn(k: number): number;
sinusoidalOut(k: number): number;
sinusoidalInOut(k: number): number;
exponentialIn(k: number): number;
exponentialOut(k: number): number;
exponentialInOut(k: number): number;
circularIn(k: number): number;
circularOut(k: number): number;
circularInOut(k: number): number;
elasticIn(k: number): number;
elasticOut(k: number): number;
elasticInOut(k: number): number;
backIn(k: number): number;
backOut(k: number): number;
backInOut(k: number): number;
bounceIn(k: number): number;
bounceOut(k: number): number;
bounceInOut(k: number): number;
};
export default easingFuncs;

195
frontend/node_modules/zrender/lib/animation/easing.js generated vendored Normal file
View File

@ -0,0 +1,195 @@
var easingFuncs = {
linear: function (k) {
return k;
},
quadraticIn: function (k) {
return k * k;
},
quadraticOut: function (k) {
return k * (2 - k);
},
quadraticInOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k;
}
return -0.5 * (--k * (k - 2) - 1);
},
cubicIn: function (k) {
return k * k * k;
},
cubicOut: function (k) {
return --k * k * k + 1;
},
cubicInOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k;
}
return 0.5 * ((k -= 2) * k * k + 2);
},
quarticIn: function (k) {
return k * k * k * k;
},
quarticOut: function (k) {
return 1 - (--k * k * k * k);
},
quarticInOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k;
}
return -0.5 * ((k -= 2) * k * k * k - 2);
},
quinticIn: function (k) {
return k * k * k * k * k;
},
quinticOut: function (k) {
return --k * k * k * k * k + 1;
},
quinticInOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k * k;
}
return 0.5 * ((k -= 2) * k * k * k * k + 2);
},
sinusoidalIn: function (k) {
return 1 - Math.cos(k * Math.PI / 2);
},
sinusoidalOut: function (k) {
return Math.sin(k * Math.PI / 2);
},
sinusoidalInOut: function (k) {
return 0.5 * (1 - Math.cos(Math.PI * k));
},
exponentialIn: function (k) {
return k === 0 ? 0 : Math.pow(1024, k - 1);
},
exponentialOut: function (k) {
return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
},
exponentialInOut: function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
if ((k *= 2) < 1) {
return 0.5 * Math.pow(1024, k - 1);
}
return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
},
circularIn: function (k) {
return 1 - Math.sqrt(1 - k * k);
},
circularOut: function (k) {
return Math.sqrt(1 - (--k * k));
},
circularInOut: function (k) {
if ((k *= 2) < 1) {
return -0.5 * (Math.sqrt(1 - k * k) - 1);
}
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
},
elasticIn: function (k) {
var s;
var a = 0.1;
var p = 0.4;
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
if (!a || a < 1) {
a = 1;
s = p / 4;
}
else {
s = p * Math.asin(1 / a) / (2 * Math.PI);
}
return -(a * Math.pow(2, 10 * (k -= 1))
* Math.sin((k - s) * (2 * Math.PI) / p));
},
elasticOut: function (k) {
var s;
var a = 0.1;
var p = 0.4;
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
if (!a || a < 1) {
a = 1;
s = p / 4;
}
else {
s = p * Math.asin(1 / a) / (2 * Math.PI);
}
return (a * Math.pow(2, -10 * k)
* Math.sin((k - s) * (2 * Math.PI) / p) + 1);
},
elasticInOut: function (k) {
var s;
var a = 0.1;
var p = 0.4;
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
if (!a || a < 1) {
a = 1;
s = p / 4;
}
else {
s = p * Math.asin(1 / a) / (2 * Math.PI);
}
if ((k *= 2) < 1) {
return -0.5 * (a * Math.pow(2, 10 * (k -= 1))
* Math.sin((k - s) * (2 * Math.PI) / p));
}
return a * Math.pow(2, -10 * (k -= 1))
* Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
},
backIn: function (k) {
var s = 1.70158;
return k * k * ((s + 1) * k - s);
},
backOut: function (k) {
var s = 1.70158;
return --k * k * ((s + 1) * k + s) + 1;
},
backInOut: function (k) {
var s = 1.70158 * 1.525;
if ((k *= 2) < 1) {
return 0.5 * (k * k * ((s + 1) * k - s));
}
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
},
bounceIn: function (k) {
return 1 - easingFuncs.bounceOut(1 - k);
},
bounceOut: function (k) {
if (k < (1 / 2.75)) {
return 7.5625 * k * k;
}
else if (k < (2 / 2.75)) {
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
}
else if (k < (2.5 / 2.75)) {
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
}
else {
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
}
},
bounceInOut: function (k) {
if (k < 0.5) {
return easingFuncs.bounceIn(k * 2) * 0.5;
}
return easingFuncs.bounceOut(k * 2 - 1) * 0.5 + 0.5;
}
};
export default easingFuncs;

View File

@ -0,0 +1,3 @@
declare type RequestAnimationFrameType = typeof window.requestAnimationFrame;
declare let requestAnimationFrame: RequestAnimationFrameType;
export default requestAnimationFrame;

View File

@ -0,0 +1,10 @@
import env from '../core/env.js';
var requestAnimationFrame;
requestAnimationFrame = (env.hasGlobalWindow
&& ((window.requestAnimationFrame && window.requestAnimationFrame.bind(window))
|| (window.msRequestAnimationFrame && window.msRequestAnimationFrame.bind(window))
|| window.mozRequestAnimationFrame
|| window.webkitRequestAnimationFrame)) || function (func) {
return setTimeout(func, 16);
};
export default requestAnimationFrame;