@leankylin-sheet/core 4.0.58 → 4.0.60

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.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import _, { isPlainObject, pick } from 'lodash';
1
+ import _, { isPlainObject, uniqBy, pick } from 'lodash';
2
2
  import numeral from 'numeral';
3
3
  import dayjs from 'dayjs';
4
4
  import { Parser, ERROR_REF } from '@leankylin-sheet/formula-parser';
@@ -46539,21 +46539,42 @@ function copySheet(ctx, sheetId, hooks) {
46539
46539
  (_hooks$onCopySheet = hooks.onCopySheet) === null || _hooks$onCopySheet === void 0 ? void 0 : _hooks$onCopySheet.call(hooks, sheetId, copyId);
46540
46540
  }
46541
46541
  function calculateSheetFromula(ctx, id) {
46542
+ console.time("calcTime:".concat(id));
46542
46543
  var index$1 = getSheetIndex(ctx, id);
46544
+ var luckysheetfile = ctx.luckysheetfile;
46545
+ var file = luckysheetfile[index$1];
46546
+ var calcChain = file.calcChain;
46547
+ if (_.isNil(calcChain)) {
46548
+ calcChain = [];
46549
+ }
46543
46550
  if (!ctx.luckysheetfile[index$1].data) return;
46544
46551
  for (var r = 0; r < ctx.luckysheetfile[index$1].data.length; r += 1) {
46545
46552
  for (var c = 0; c < ctx.luckysheetfile[index$1].data[r].length; c += 1) {
46546
- var _ctx$luckysheetfile$i, _ctx$luckysheetfile$i2;
46547
- if (!((_ctx$luckysheetfile$i = ctx.luckysheetfile[index$1].data[r][c]) === null || _ctx$luckysheetfile$i === void 0 ? void 0 : _ctx$luckysheetfile$i.f)) {
46553
+ var cell = ctx.luckysheetfile[index$1].data[r][c];
46554
+ if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
46555
+ continue;
46556
+ }
46557
+ var cc = {
46558
+ r: r,
46559
+ c: c,
46560
+ id: id
46561
+ };
46562
+ calcChain.push(cc);
46563
+ var result = execfunction(ctx, cell === null || cell === void 0 ? void 0 : cell.f, r, c, id, undefined, true);
46564
+ var newV = result[1];
46565
+ if (newV === cell.v) {
46548
46566
  continue;
46549
46567
  }
46550
- var result = execfunction(ctx, (_ctx$luckysheetfile$i2 = ctx.luckysheetfile[index$1].data[r][c]) === null || _ctx$luckysheetfile$i2 === void 0 ? void 0 : _ctx$luckysheetfile$i2.f, r, c, id);
46551
46568
  setCellValue$1(ctx, r, c, result[1], null, {
46552
46569
  id: id
46553
46570
  });
46554
- insertUpdateFunctionGroup(ctx, r, c, id);
46555
46571
  }
46556
46572
  }
46573
+ file.calcChain = uniqBy(calcChain, function (item) {
46574
+ return item.r + item.c + item.id;
46575
+ });
46576
+ ctx.luckysheetfile = luckysheetfile;
46577
+ console.timeEnd("calcTime:".concat(id));
46557
46578
  }
46558
46579
 
46559
46580
  function storeSheetParam(ctx) {
package/dist/index.js CHANGED
@@ -46549,21 +46549,42 @@ function copySheet(ctx, sheetId, hooks) {
46549
46549
  (_hooks$onCopySheet = hooks.onCopySheet) === null || _hooks$onCopySheet === void 0 ? void 0 : _hooks$onCopySheet.call(hooks, sheetId, copyId);
46550
46550
  }
46551
46551
  function calculateSheetFromula(ctx, id) {
46552
+ console.time("calcTime:".concat(id));
46552
46553
  var index$1 = getSheetIndex(ctx, id);
46554
+ var luckysheetfile = ctx.luckysheetfile;
46555
+ var file = luckysheetfile[index$1];
46556
+ var calcChain = file.calcChain;
46557
+ if (___default['default'].isNil(calcChain)) {
46558
+ calcChain = [];
46559
+ }
46553
46560
  if (!ctx.luckysheetfile[index$1].data) return;
46554
46561
  for (var r = 0; r < ctx.luckysheetfile[index$1].data.length; r += 1) {
46555
46562
  for (var c = 0; c < ctx.luckysheetfile[index$1].data[r].length; c += 1) {
46556
- var _ctx$luckysheetfile$i, _ctx$luckysheetfile$i2;
46557
- if (!((_ctx$luckysheetfile$i = ctx.luckysheetfile[index$1].data[r][c]) === null || _ctx$luckysheetfile$i === void 0 ? void 0 : _ctx$luckysheetfile$i.f)) {
46563
+ var cell = ctx.luckysheetfile[index$1].data[r][c];
46564
+ if (!(cell === null || cell === void 0 ? void 0 : cell.f)) {
46565
+ continue;
46566
+ }
46567
+ var cc = {
46568
+ r: r,
46569
+ c: c,
46570
+ id: id
46571
+ };
46572
+ calcChain.push(cc);
46573
+ var result = execfunction(ctx, cell === null || cell === void 0 ? void 0 : cell.f, r, c, id, undefined, true);
46574
+ var newV = result[1];
46575
+ if (newV === cell.v) {
46558
46576
  continue;
46559
46577
  }
46560
- var result = execfunction(ctx, (_ctx$luckysheetfile$i2 = ctx.luckysheetfile[index$1].data[r][c]) === null || _ctx$luckysheetfile$i2 === void 0 ? void 0 : _ctx$luckysheetfile$i2.f, r, c, id);
46561
46578
  setCellValue$1(ctx, r, c, result[1], null, {
46562
46579
  id: id
46563
46580
  });
46564
- insertUpdateFunctionGroup(ctx, r, c, id);
46565
46581
  }
46566
46582
  }
46583
+ file.calcChain = _.uniqBy(calcChain, function (item) {
46584
+ return item.r + item.c + item.id;
46585
+ });
46586
+ ctx.luckysheetfile = luckysheetfile;
46587
+ console.timeEnd("calcTime:".concat(id));
46567
46588
  }
46568
46589
 
46569
46590
  function storeSheetParam(ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/core",
3
- "version": "4.0.58",
3
+ "version": "4.0.60",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "build": "father-build"
14
14
  },
15
15
  "dependencies": {
16
- "@leankylin-sheet/formula-parser": "4.0.58",
16
+ "@leankylin-sheet/formula-parser": "4.0.60",
17
17
  "dayjs": "^1.11.0",
18
18
  "immer": "^9.0.12",
19
19
  "lodash": "^4.17.21",