@fileverse-dev/fortune-core 1.1.10 → 1.1.11-patch-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/es/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export * from "./locale";
8
8
  export * from "./modules";
9
9
  export * from "./utils";
10
10
  export * from "./types";
11
+ export * from "./animate";
package/es/index.js CHANGED
@@ -7,4 +7,5 @@ export * from "./events";
7
7
  export * from "./locale";
8
8
  export * from "./modules";
9
9
  export * from "./utils";
10
- export * from "./types";
10
+ export * from "./types";
11
+ export * from "./animate";
package/es/types.d.ts CHANGED
@@ -144,6 +144,18 @@ export type ConditionRulesProps = {
144
144
  repeatValue: string;
145
145
  projectValue: string;
146
146
  };
147
+ export type LiveQueryData = {
148
+ data: {
149
+ row: number;
150
+ column: number;
151
+ function: string;
152
+ value: any;
153
+ id: string;
154
+ name: string;
155
+ subSheetId: string;
156
+ };
157
+ cellData: Cell;
158
+ };
147
159
  export type Sheet = {
148
160
  name: string;
149
161
  config?: SheetConfig;
@@ -205,6 +217,7 @@ export type Sheet = {
205
217
  column_focus: number;
206
218
  };
207
219
  };
220
+ liveQueryList?: Record<string, LiveQueryData>;
208
221
  };
209
222
  export type CommentBox = {
210
223
  r: number;
@@ -0,0 +1,14 @@
1
+ declare class CellFadeAnimator {
2
+ private durationMs;
3
+ private active;
4
+ private animationFrameId;
5
+ private onTick;
6
+ constructor(durationMs?: number);
7
+ markChanged(sheetId: string, r: number, c: number): void;
8
+ getOpacity(sheetId: string, r: number, c: number): number;
9
+ setOnTick(repaintFn: (() => 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,60 @@
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.animationFrameId = 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.getOpacity = function (sheetId, r, c) {
27
+ var activeCellAnimationData = this.active.get("".concat(sheetId, ":").concat(r, ":").concat(c));
28
+ if (!activeCellAnimationData) return 1;
29
+ var animationProgress = Math.min(1, (performance.now() - activeCellAnimationData.start) / activeCellAnimationData.dur);
30
+ if (animationProgress >= 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 - animationProgress, 3));
35
+ };
36
+ CellFadeAnimator.prototype.setOnTick = function (repaintFn) {
37
+ this.onTick = repaintFn;
38
+ this.ensureTicking();
39
+ };
40
+ CellFadeAnimator.prototype.ensureTicking = function () {
41
+ var _this = this;
42
+ if (this.animationFrameId !== null) return;
43
+ if (this.active.size === 0) return;
44
+ var _loop = function loop() {
45
+ var _a;
46
+ _this.animationFrameId = null;
47
+ if (_this.active.size === 0) {
48
+ return;
49
+ }
50
+ (_a = _this.onTick) === null || _a === void 0 ? void 0 : _a.call(_this);
51
+ _this.animationFrameId = requestAnimationFrame(_loop);
52
+ };
53
+ this.animationFrameId = requestAnimationFrame(_loop);
54
+ };
55
+ return CellFadeAnimator;
56
+ }();
57
+ var cellFadeAnimator = exports.cellFadeAnimator = new CellFadeAnimator(4000);
58
+ function markCellChanged(sheetId, r, c) {
59
+ cellFadeAnimator.markChanged(sheetId, r, c);
60
+ }
@@ -68,4 +68,5 @@ export declare function getSheetWithLatestCelldata(ctx: Context, options?: Commo
68
68
  column_focus: number;
69
69
  } | undefined;
70
70
  } | undefined;
71
+ liveQueryList?: Record<string, import("../types").LiveQueryData> | undefined;
71
72
  };
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
- renderCtx.fillText(_lodash.default.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
771
+ var sheetId = this.sheetCtx.currentSheetId;
772
+ var opacity = _animate.cellFadeAnimator.getOpacity(sheetId, r, c);
773
+ if (opacity < 0.999) {
774
+ renderCtx.save();
775
+ renderCtx.globalAlpha = opacity;
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.cellTextRender(textInfo, renderCtx, {
1076
- pos_x: pos_x,
1077
- pos_y: pos_y
1078
- });
1085
+ var sheetId = this.sheetCtx.currentSheetId;
1086
+ var opacity = _animate.cellFadeAnimator.getOpacity(sheetId, r, c);
1087
+ if (opacity < 0.999) {
1088
+ renderCtx.save();
1089
+ renderCtx.globalAlpha = opacity;
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.cellTextRender(textInfo, renderCtx, {
1161
- pos_x: pos_x,
1162
- pos_y: pos_y
1163
- });
1182
+ var sheetId = this.sheetCtx.currentSheetId;
1183
+ var opacity = _animate.cellFadeAnimator.getOpacity(sheetId, r, c);
1184
+ if (opacity < 0.999) {
1185
+ renderCtx.save();
1186
+ renderCtx.globalAlpha = opacity;
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) {