dtable-statistic 5.0.48-alpha.16 → 5.0.48-alpha.18
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.js
CHANGED
|
@@ -12,6 +12,7 @@ var _calc = _interopRequireDefault(require("./calc.worker"));
|
|
|
12
12
|
var _resultCacheManager = require("./result-cache-manager");
|
|
13
13
|
var _threadManager = _interopRequireDefault(require("./thread-manager"));
|
|
14
14
|
var _lodashEs = require("lodash-es");
|
|
15
|
+
var _hasReactElement = require("../hasReactElement");
|
|
15
16
|
function uuid() {
|
|
16
17
|
return Math.random().toString(36).slice(2, 9);
|
|
17
18
|
}
|
|
@@ -21,6 +22,10 @@ async function calcViewRowsWithWorker(view, table, value, username, userId, user
|
|
|
21
22
|
if (cachedRows) {
|
|
22
23
|
return cachedRows;
|
|
23
24
|
}
|
|
25
|
+
if (!_resultCacheManager.cachedBase) {
|
|
26
|
+
(0, _hasReactElement.containsReactElementSymbol)(value);
|
|
27
|
+
(0, _resultCacheManager.initCachedBase)(value);
|
|
28
|
+
}
|
|
24
29
|
const clonedTable = (0, _lodashEs.cloneDeep)(table);
|
|
25
30
|
// Symbol can't passed to workers
|
|
26
31
|
clonedTable.columns = clonedTable.columns.map(c => {
|
|
@@ -36,7 +41,7 @@ async function calcViewRowsWithWorker(view, table, value, username, userId, user
|
|
|
36
41
|
return [];
|
|
37
42
|
}
|
|
38
43
|
const calcWorker = Comlink.wrap(worker);
|
|
39
|
-
const rows = await calcWorker.getViewRows(view, clonedTable,
|
|
44
|
+
const rows = await calcWorker.getViewRows(view, clonedTable, _resultCacheManager.cachedBase, username, userId, userDepartmentIdsMap);
|
|
40
45
|
_resultCacheManager.viewRowsCacheManager.set(key, rows);
|
|
41
46
|
_threadManager.default.removeThread(workerId);
|
|
42
47
|
return rows;
|
|
@@ -47,6 +52,10 @@ async function calcFormulaResultsWithWorker(table, rows, value, formulaColumns,
|
|
|
47
52
|
if (cachedResults) {
|
|
48
53
|
return cachedResults;
|
|
49
54
|
}
|
|
55
|
+
if (!_resultCacheManager.cachedBase) {
|
|
56
|
+
(0, _hasReactElement.containsReactElementSymbol)(value);
|
|
57
|
+
(0, _resultCacheManager.initCachedBase)(value);
|
|
58
|
+
}
|
|
50
59
|
const clonedTable = (0, _lodashEs.cloneDeep)(table);
|
|
51
60
|
// Symbol can't passed to workers
|
|
52
61
|
clonedTable.columns = clonedTable.columns.map(c => {
|
|
@@ -62,7 +71,7 @@ async function calcFormulaResultsWithWorker(table, rows, value, formulaColumns,
|
|
|
62
71
|
return [];
|
|
63
72
|
}
|
|
64
73
|
const calcWorker = Comlink.wrap(worker);
|
|
65
|
-
const results = await calcWorker.getTableFormulaResults(clonedTable, rows,
|
|
74
|
+
const results = await calcWorker.getTableFormulaResults(clonedTable, rows, _resultCacheManager.cachedBase, formulaColumns, username, userId, userDepartmentIdsMap);
|
|
66
75
|
_resultCacheManager.formulaResultsCacheManager.set(key, results);
|
|
67
76
|
_threadManager.default.removeThread(workerId);
|
|
68
77
|
return results;
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.cachedBase = void 0;
|
|
7
|
+
exports.clearCachedBase = clearCachedBase;
|
|
8
|
+
exports.formulaResultsCacheManager = void 0;
|
|
9
|
+
exports.initCachedBase = initCachedBase;
|
|
10
|
+
exports.viewRowsCacheManager = void 0;
|
|
11
|
+
var _lodashEs = require("lodash-es");
|
|
7
12
|
class ResultCacheManager {
|
|
8
13
|
constructor() {
|
|
9
14
|
this.cache = new Map();
|
|
@@ -19,4 +24,30 @@ class ResultCacheManager {
|
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
const viewRowsCacheManager = exports.viewRowsCacheManager = new ResultCacheManager();
|
|
22
|
-
const formulaResultsCacheManager = exports.formulaResultsCacheManager = new ResultCacheManager();
|
|
27
|
+
const formulaResultsCacheManager = exports.formulaResultsCacheManager = new ResultCacheManager();
|
|
28
|
+
let cachedBase = exports.cachedBase = null;
|
|
29
|
+
function initCachedBase(value) {
|
|
30
|
+
// don't clone rows cause they are really big
|
|
31
|
+
const tableIdRowMap = {};
|
|
32
|
+
value.tables.forEach(t => {
|
|
33
|
+
tableIdRowMap[t._id] = t === null || t === void 0 ? void 0 : t.rows;
|
|
34
|
+
t.rows && delete t.rows;
|
|
35
|
+
});
|
|
36
|
+
const clonedBase = (0, _lodashEs.cloneDeep)(value);
|
|
37
|
+
clonedBase.tables.forEach(t => {
|
|
38
|
+
// delete symbols
|
|
39
|
+
t.columns = t.columns.map(c => {
|
|
40
|
+
delete c.editor;
|
|
41
|
+
delete c.formatter;
|
|
42
|
+
return c;
|
|
43
|
+
});
|
|
44
|
+
t.rows = tableIdRowMap[t._id];
|
|
45
|
+
});
|
|
46
|
+
value.tables.forEach(t => {
|
|
47
|
+
t.rows = tableIdRowMap[t._id];
|
|
48
|
+
});
|
|
49
|
+
exports.cachedBase = cachedBase = clonedBase;
|
|
50
|
+
}
|
|
51
|
+
function clearCachedBase() {
|
|
52
|
+
exports.cachedBase = cachedBase = null;
|
|
53
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.containsReactElementSymbol = containsReactElementSymbol;
|
|
7
|
+
const REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
8
|
+
function containsReactElementSymbol(obj) {
|
|
9
|
+
let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
10
|
+
if (obj === null || typeof obj !== 'object') {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Check if the current object is a React element
|
|
15
|
+
if (obj.$$typeof === REACT_ELEMENT_TYPE) {
|
|
16
|
+
console.log('Parent object containing Symbol(react.element):', parent);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Recursively check all properties of the object
|
|
21
|
+
for (let key in obj) {
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
23
|
+
if (containsReactElementSymbol(obj[key], obj)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Check symbol properties as well
|
|
30
|
+
const symbolProperties = Object.getOwnPropertySymbols(obj);
|
|
31
|
+
for (let symbol of symbolProperties) {
|
|
32
|
+
if (containsReactElementSymbol(obj[symbol], obj)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
package/es/utils/test.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|