Skip to content

Commit eee0de4

Browse files
committed
feat: query support cancel previous
feat: google sheets query support delete data fix: id source detail fix: memoized return undefined if found cyclic fix: idsouce fix: clientSecret not required
1 parent bd08918 commit eee0de4

File tree

41 files changed

+1023
-878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1023
-878
lines changed

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"react-virtualized@^9.22.3": "patch:react-virtualized@npm%3A9.22.3#./.yarn/patches/react-virtualized-npm-9.22.3-0fff3cbf64.patch"
7272
},
7373
"dependencies": {
74+
"antd-mobile": "^5.28.0",
7475
"chalk": "4",
7576
"number-precision": "^1.6.0",
7677
"react-player": "^2.11.0",

client/packages/openblocks-core/lib/index.cjs

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -106,49 +106,40 @@ function __spreadArray(to, from, pack) {
106106
return to.concat(ar || Array.prototype.slice.call(from));
107107
}
108108

109-
function getCache(obj, fnName) {
109+
function isEqualArgs(args, cacheArgs, equals) {
110+
if (!cacheArgs) {
111+
return false;
112+
}
113+
if (args.length === 0 && cacheArgs.length === 0) {
114+
return true;
115+
}
116+
return (args.length === cacheArgs.length &&
117+
cacheArgs.every(function (arg, index) { var _a, _b; return (_b = (_a = equals === null || equals === void 0 ? void 0 : equals[index]) === null || _a === void 0 ? void 0 : _a.call(equals, arg, args[index])) !== null && _b !== void 0 ? _b : arg === args[index]; }));
118+
}
119+
function getCacheResult(thisObj, fnName, args, equals) {
110120
var _a;
111-
return (_a = obj === null || obj === void 0 ? void 0 : obj.__cache) === null || _a === void 0 ? void 0 : _a[fnName];
121+
var cache = (_a = thisObj === null || thisObj === void 0 ? void 0 : thisObj.__cache) === null || _a === void 0 ? void 0 : _a[fnName];
122+
if (cache && isEqualArgs(args, cache.args, equals)) {
123+
return cache.result;
124+
}
112125
}
113-
function createCache(obj, fnName, args) {
114-
if (!obj.__cache) {
115-
obj.__cache = {};
126+
function cache(fn, args, thisObj, fnName, equals) {
127+
var result = getCacheResult(thisObj, fnName, args, equals);
128+
if (result) {
129+
return result.value;
116130
}
117-
obj.__cache[fnName] = {
131+
var cache = {
118132
id: Symbol("id"),
119133
args: args,
120-
isInProgress: true,
121134
time: Date.now(),
122135
};
123-
return getCache(obj, fnName);
124-
}
125-
function genCache(fn, args, thisObj, fnName) {
126-
var cache = createCache(thisObj, fnName, args);
127-
var value = fn.apply(thisObj, args);
128-
cache.isInProgress = false;
129-
cache.value = value;
130-
}
131-
function read(thisObj, fnName) {
132-
var cache = getCache(thisObj, fnName);
133-
return cache && cache.value;
134-
}
135-
function hitCache(args, thisObj, fnName, equals) {
136-
var cache = getCache(thisObj, fnName);
137-
if (!cache || !cache.args)
138-
return false;
139-
if (args.length === 0 && cache.args.length === 0)
140-
return true;
141-
return cache.args.every(function (arg, index) { var _a, _b; return (_b = (_a = equals === null || equals === void 0 ? void 0 : equals[index]) === null || _a === void 0 ? void 0 : _a.call(equals, arg, args[index])) !== null && _b !== void 0 ? _b : arg === args[index]; });
142-
}
143-
function isCyclic(thisObj, fnName) {
144-
var cache = getCache(thisObj, fnName);
145-
return cache && cache.isInProgress;
146-
}
147-
function cache(fn, args, thisObj, fnName, equals) {
148-
if (!hitCache(args, thisObj, fnName, equals) && !isCyclic(thisObj, fnName)) {
149-
genCache(fn, args, thisObj, fnName);
136+
if (!thisObj.__cache) {
137+
thisObj.__cache = {};
150138
}
151-
return read(thisObj, fnName);
139+
thisObj.__cache[fnName] = cache;
140+
var value = fn.apply(thisObj, args);
141+
cache.result = { value: value };
142+
return value;
152143
}
153144
function memoized(equals) {
154145
return function (target, fnName, descriptor) {
@@ -1436,6 +1427,7 @@ var DefaultParser = /** @class */ (function () {
14361427
function evalJson(unevaledValue, context) {
14371428
return new RelaxedJsonParser(unevaledValue, context).parse();
14381429
}
1430+
// this will also be used in node-service
14391431
var RelaxedJsonParser = /** @class */ (function (_super) {
14401432
__extends(RelaxedJsonParser, _super);
14411433
function RelaxedJsonParser(unevaledValue, context) {
@@ -7547,6 +7539,7 @@ exports.FetchCheckNode = FetchCheckNode;
75477539
exports.FunctionNode = FunctionNode;
75487540
exports.MultiBaseComp = MultiBaseComp;
75497541
exports.RecordNode = RecordNode;
7542+
exports.RelaxedJsonParser = RelaxedJsonParser;
75507543
exports.SimpleAbstractComp = SimpleAbstractComp;
75517544
exports.SimpleComp = SimpleComp;
75527545
exports.SimpleNode = SimpleNode;

0 commit comments

Comments
 (0)