@fileverse-dev/fortune-core 1.1.5-live-query-2 → 1.1.5-live-query-3
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/es/animate.d.ts +14 -0
- package/es/animate.js +52 -0
- package/es/canvas.js +43 -9
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/lib/animate.d.ts +14 -0
- package/lib/animate.js +59 -0
- package/lib/canvas.js +43 -9
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/package.json +1 -1
package/es/animate.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class CellFadeAnimator {
|
|
2
|
+
private durationMs;
|
|
3
|
+
private active;
|
|
4
|
+
private raf;
|
|
5
|
+
private onTick;
|
|
6
|
+
constructor(durationMs?: number);
|
|
7
|
+
markChanged(sheetId: string, r: number, c: number): void;
|
|
8
|
+
alpha(sheetId: string, r: number, c: number): number;
|
|
9
|
+
setOnTick(cb: (() => void) | null): void;
|
|
10
|
+
private ensureTicking;
|
|
11
|
+
}
|
|
12
|
+
export declare const cellFadeAnimator: CellFadeAnimator;
|
|
13
|
+
export declare function markCellChanged(sheetId: string, r: number, c: number): void;
|
|
14
|
+
export {};
|
package/es/animate.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var CellFadeAnimator = function () {
|
|
2
|
+
function CellFadeAnimator(durationMs) {
|
|
3
|
+
if (durationMs === void 0) {
|
|
4
|
+
durationMs = 350;
|
|
5
|
+
}
|
|
6
|
+
this.durationMs = durationMs;
|
|
7
|
+
this.active = new Map();
|
|
8
|
+
this.raf = null;
|
|
9
|
+
this.onTick = null;
|
|
10
|
+
this.durationMs = durationMs;
|
|
11
|
+
}
|
|
12
|
+
CellFadeAnimator.prototype.markChanged = function (sheetId, r, c) {
|
|
13
|
+
this.active.set("".concat(sheetId, ":").concat(r, ":").concat(c), {
|
|
14
|
+
start: performance.now(),
|
|
15
|
+
dur: this.durationMs
|
|
16
|
+
});
|
|
17
|
+
this.ensureTicking();
|
|
18
|
+
};
|
|
19
|
+
CellFadeAnimator.prototype.alpha = function (sheetId, r, c) {
|
|
20
|
+
var it = this.active.get("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
21
|
+
if (!it) return 1;
|
|
22
|
+
var t = Math.min(1, (performance.now() - it.start) / it.dur);
|
|
23
|
+
if (t >= 1) {
|
|
24
|
+
this.active.delete("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
return Math.max(0.05, 1 - Math.pow(1 - t, 3));
|
|
28
|
+
};
|
|
29
|
+
CellFadeAnimator.prototype.setOnTick = function (cb) {
|
|
30
|
+
this.onTick = cb;
|
|
31
|
+
this.ensureTicking();
|
|
32
|
+
};
|
|
33
|
+
CellFadeAnimator.prototype.ensureTicking = function () {
|
|
34
|
+
var _this = this;
|
|
35
|
+
if (this.raf !== null) return;
|
|
36
|
+
if (this.active.size === 0 && !this.onTick) return;
|
|
37
|
+
var _loop = function loop() {
|
|
38
|
+
var _a;
|
|
39
|
+
_this.raf = null;
|
|
40
|
+
if (_this.active.size > 0) (_a = _this.onTick) === null || _a === void 0 ? void 0 : _a.call(_this);
|
|
41
|
+
if (_this.active.size > 0 || _this.onTick) {
|
|
42
|
+
_this.raf = requestAnimationFrame(_loop);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
this.raf = requestAnimationFrame(_loop);
|
|
46
|
+
};
|
|
47
|
+
return CellFadeAnimator;
|
|
48
|
+
}();
|
|
49
|
+
export var cellFadeAnimator = new CellFadeAnimator(4000);
|
|
50
|
+
export function markCellChanged(sheetId, r, c) {
|
|
51
|
+
cellFadeAnimator.markChanged(sheetId, r, c);
|
|
52
|
+
}
|
package/es/canvas.js
CHANGED
|
@@ -6,6 +6,7 @@ import { isInlineStringCell } from "./modules/inline-string";
|
|
|
6
6
|
import { getSheetIndex, indexToColumnChar } from "./utils";
|
|
7
7
|
import { getBorderInfoComputeRange } from "./modules/border";
|
|
8
8
|
import { checkCF, getComputeMap, validateCellData } from "./modules";
|
|
9
|
+
import { cellFadeAnimator } from "./animate";
|
|
9
10
|
export var defaultStyle = {
|
|
10
11
|
fillStyle: "#000000",
|
|
11
12
|
textBaseline: "middle",
|
|
@@ -760,7 +761,16 @@ var Canvas = function () {
|
|
|
760
761
|
var horizonAlignPos = startX + 4 + offsetLeft;
|
|
761
762
|
var verticalAlignPos = endY + offsetTop - 2;
|
|
762
763
|
renderCtx.textBaseline = "bottom";
|
|
763
|
-
|
|
764
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
765
|
+
var a = cellFadeAnimator.alpha(sheetId, r, c);
|
|
766
|
+
if (a < 0.999) {
|
|
767
|
+
renderCtx.save();
|
|
768
|
+
renderCtx.globalAlpha = a;
|
|
769
|
+
renderCtx.fillText(_.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
770
|
+
renderCtx.restore();
|
|
771
|
+
} else {
|
|
772
|
+
renderCtx.fillText(_.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
773
|
+
}
|
|
764
774
|
}
|
|
765
775
|
if ((_d = (_c = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r]) === null || _c === void 0 ? void 0 : _c[c]) === null || _d === void 0 ? void 0 : _d.ps) {
|
|
766
776
|
var ps_w = 12 * this.sheetCtx.zoomRatio;
|
|
@@ -1065,10 +1075,22 @@ var Canvas = function () {
|
|
|
1065
1075
|
if (((_j = (_h = (_g = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _g === void 0 ? void 0 : _g.fa) === null || _h === void 0 ? void 0 : _h.indexOf("[Red]")) !== null && _j !== void 0 ? _j : -1) > -1 && ((_k = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _k === void 0 ? void 0 : _k.t) === "n" && (cell === null || cell === void 0 ? void 0 : cell.v) < 0) {
|
|
1066
1076
|
renderCtx.fillStyle = "#ff0000";
|
|
1067
1077
|
}
|
|
1068
|
-
this.
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1078
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
1079
|
+
var a = cellFadeAnimator.alpha(sheetId, r, c);
|
|
1080
|
+
if (a < 0.999) {
|
|
1081
|
+
renderCtx.save();
|
|
1082
|
+
renderCtx.globalAlpha = a;
|
|
1083
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1084
|
+
pos_x: pos_x,
|
|
1085
|
+
pos_y: pos_y
|
|
1086
|
+
});
|
|
1087
|
+
renderCtx.restore();
|
|
1088
|
+
} else {
|
|
1089
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1090
|
+
pos_x: pos_x,
|
|
1091
|
+
pos_y: pos_y
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1072
1094
|
renderCtx.restore();
|
|
1073
1095
|
}
|
|
1074
1096
|
if (cellOverflow_bd_r_render) {
|
|
@@ -1150,10 +1172,22 @@ var Canvas = function () {
|
|
|
1150
1172
|
if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor) {
|
|
1151
1173
|
renderCtx.fillStyle = checksCF.textColor;
|
|
1152
1174
|
}
|
|
1153
|
-
this.
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1175
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
1176
|
+
var a = cellFadeAnimator.alpha(sheetId, r, c);
|
|
1177
|
+
if (a < 0.999) {
|
|
1178
|
+
renderCtx.save();
|
|
1179
|
+
renderCtx.globalAlpha = a;
|
|
1180
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1181
|
+
pos_x: pos_x,
|
|
1182
|
+
pos_y: pos_y
|
|
1183
|
+
});
|
|
1184
|
+
renderCtx.restore();
|
|
1185
|
+
} else {
|
|
1186
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1187
|
+
pos_x: pos_x,
|
|
1188
|
+
pos_y: pos_y
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1157
1191
|
renderCtx.restore();
|
|
1158
1192
|
};
|
|
1159
1193
|
Canvas.prototype.cellOverflow_trace = function (r, curC, traceC, traceDir, horizonAlign, textMetrics) {
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/lib/animate.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class CellFadeAnimator {
|
|
2
|
+
private durationMs;
|
|
3
|
+
private active;
|
|
4
|
+
private raf;
|
|
5
|
+
private onTick;
|
|
6
|
+
constructor(durationMs?: number);
|
|
7
|
+
markChanged(sheetId: string, r: number, c: number): void;
|
|
8
|
+
alpha(sheetId: string, r: number, c: number): number;
|
|
9
|
+
setOnTick(cb: (() => void) | null): void;
|
|
10
|
+
private ensureTicking;
|
|
11
|
+
}
|
|
12
|
+
export declare const cellFadeAnimator: CellFadeAnimator;
|
|
13
|
+
export declare function markCellChanged(sheetId: string, r: number, c: number): void;
|
|
14
|
+
export {};
|
package/lib/animate.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cellFadeAnimator = void 0;
|
|
7
|
+
exports.markCellChanged = markCellChanged;
|
|
8
|
+
var CellFadeAnimator = function () {
|
|
9
|
+
function CellFadeAnimator(durationMs) {
|
|
10
|
+
if (durationMs === void 0) {
|
|
11
|
+
durationMs = 350;
|
|
12
|
+
}
|
|
13
|
+
this.durationMs = durationMs;
|
|
14
|
+
this.active = new Map();
|
|
15
|
+
this.raf = null;
|
|
16
|
+
this.onTick = null;
|
|
17
|
+
this.durationMs = durationMs;
|
|
18
|
+
}
|
|
19
|
+
CellFadeAnimator.prototype.markChanged = function (sheetId, r, c) {
|
|
20
|
+
this.active.set("".concat(sheetId, ":").concat(r, ":").concat(c), {
|
|
21
|
+
start: performance.now(),
|
|
22
|
+
dur: this.durationMs
|
|
23
|
+
});
|
|
24
|
+
this.ensureTicking();
|
|
25
|
+
};
|
|
26
|
+
CellFadeAnimator.prototype.alpha = function (sheetId, r, c) {
|
|
27
|
+
var it = this.active.get("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
28
|
+
if (!it) return 1;
|
|
29
|
+
var t = Math.min(1, (performance.now() - it.start) / it.dur);
|
|
30
|
+
if (t >= 1) {
|
|
31
|
+
this.active.delete("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
return Math.max(0.05, 1 - Math.pow(1 - t, 3));
|
|
35
|
+
};
|
|
36
|
+
CellFadeAnimator.prototype.setOnTick = function (cb) {
|
|
37
|
+
this.onTick = cb;
|
|
38
|
+
this.ensureTicking();
|
|
39
|
+
};
|
|
40
|
+
CellFadeAnimator.prototype.ensureTicking = function () {
|
|
41
|
+
var _this = this;
|
|
42
|
+
if (this.raf !== null) return;
|
|
43
|
+
if (this.active.size === 0 && !this.onTick) return;
|
|
44
|
+
var _loop = function loop() {
|
|
45
|
+
var _a;
|
|
46
|
+
_this.raf = null;
|
|
47
|
+
if (_this.active.size > 0) (_a = _this.onTick) === null || _a === void 0 ? void 0 : _a.call(_this);
|
|
48
|
+
if (_this.active.size > 0 || _this.onTick) {
|
|
49
|
+
_this.raf = requestAnimationFrame(_loop);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
this.raf = requestAnimationFrame(_loop);
|
|
53
|
+
};
|
|
54
|
+
return CellFadeAnimator;
|
|
55
|
+
}();
|
|
56
|
+
var cellFadeAnimator = exports.cellFadeAnimator = new CellFadeAnimator(4000);
|
|
57
|
+
function markCellChanged(sheetId, r, c) {
|
|
58
|
+
cellFadeAnimator.markChanged(sheetId, r, c);
|
|
59
|
+
}
|
package/lib/canvas.js
CHANGED
|
@@ -12,6 +12,7 @@ var _inlineString = require("./modules/inline-string");
|
|
|
12
12
|
var _utils = require("./utils");
|
|
13
13
|
var _border = require("./modules/border");
|
|
14
14
|
var _modules = require("./modules");
|
|
15
|
+
var _animate = require("./animate");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
var defaultStyle = exports.defaultStyle = {
|
|
17
18
|
fillStyle: "#000000",
|
|
@@ -767,7 +768,16 @@ var Canvas = exports.Canvas = function () {
|
|
|
767
768
|
var horizonAlignPos = startX + 4 + offsetLeft;
|
|
768
769
|
var verticalAlignPos = endY + offsetTop - 2;
|
|
769
770
|
renderCtx.textBaseline = "bottom";
|
|
770
|
-
|
|
771
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
772
|
+
var a = _animate.cellFadeAnimator.alpha(sheetId, r, c);
|
|
773
|
+
if (a < 0.999) {
|
|
774
|
+
renderCtx.save();
|
|
775
|
+
renderCtx.globalAlpha = a;
|
|
776
|
+
renderCtx.fillText(_lodash.default.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
777
|
+
renderCtx.restore();
|
|
778
|
+
} else {
|
|
779
|
+
renderCtx.fillText(_lodash.default.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
780
|
+
}
|
|
771
781
|
}
|
|
772
782
|
if ((_d = (_c = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r]) === null || _c === void 0 ? void 0 : _c[c]) === null || _d === void 0 ? void 0 : _d.ps) {
|
|
773
783
|
var ps_w = 12 * this.sheetCtx.zoomRatio;
|
|
@@ -1072,10 +1082,22 @@ var Canvas = exports.Canvas = function () {
|
|
|
1072
1082
|
if (((_j = (_h = (_g = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _g === void 0 ? void 0 : _g.fa) === null || _h === void 0 ? void 0 : _h.indexOf("[Red]")) !== null && _j !== void 0 ? _j : -1) > -1 && ((_k = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _k === void 0 ? void 0 : _k.t) === "n" && (cell === null || cell === void 0 ? void 0 : cell.v) < 0) {
|
|
1073
1083
|
renderCtx.fillStyle = "#ff0000";
|
|
1074
1084
|
}
|
|
1075
|
-
this.
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1085
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
1086
|
+
var a = _animate.cellFadeAnimator.alpha(sheetId, r, c);
|
|
1087
|
+
if (a < 0.999) {
|
|
1088
|
+
renderCtx.save();
|
|
1089
|
+
renderCtx.globalAlpha = a;
|
|
1090
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1091
|
+
pos_x: pos_x,
|
|
1092
|
+
pos_y: pos_y
|
|
1093
|
+
});
|
|
1094
|
+
renderCtx.restore();
|
|
1095
|
+
} else {
|
|
1096
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1097
|
+
pos_x: pos_x,
|
|
1098
|
+
pos_y: pos_y
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1079
1101
|
renderCtx.restore();
|
|
1080
1102
|
}
|
|
1081
1103
|
if (cellOverflow_bd_r_render) {
|
|
@@ -1157,10 +1179,22 @@ var Canvas = exports.Canvas = function () {
|
|
|
1157
1179
|
if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor) {
|
|
1158
1180
|
renderCtx.fillStyle = checksCF.textColor;
|
|
1159
1181
|
}
|
|
1160
|
-
this.
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1182
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
1183
|
+
var a = _animate.cellFadeAnimator.alpha(sheetId, r, c);
|
|
1184
|
+
if (a < 0.999) {
|
|
1185
|
+
renderCtx.save();
|
|
1186
|
+
renderCtx.globalAlpha = a;
|
|
1187
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1188
|
+
pos_x: pos_x,
|
|
1189
|
+
pos_y: pos_y
|
|
1190
|
+
});
|
|
1191
|
+
renderCtx.restore();
|
|
1192
|
+
} else {
|
|
1193
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1194
|
+
pos_x: pos_x,
|
|
1195
|
+
pos_y: pos_y
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1164
1198
|
renderCtx.restore();
|
|
1165
1199
|
};
|
|
1166
1200
|
Canvas.prototype.cellOverflow_trace = function (r, curC, traceC, traceDir, horizonAlign, textMetrics) {
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -106,4 +106,16 @@ Object.keys(_types).forEach(function (key) {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
|
+
var _animate = require("./animate");
|
|
110
|
+
Object.keys(_animate).forEach(function (key) {
|
|
111
|
+
if (key === "default" || key === "__esModule") return;
|
|
112
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
113
|
+
if (key in exports && exports[key] === _animate[key]) return;
|
|
114
|
+
Object.defineProperty(exports, key, {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function get() {
|
|
117
|
+
return _animate[key];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
109
121
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|