Skip to content

Commit b278eb0

Browse files
authored
Merge pull request lowcoder-org#280 from lvhuichao/develop
PR 02.23
2 parents 1264a8e + 9d60c64 commit b278eb0

File tree

286 files changed

+5564
-2433
lines changed

Some content is hidden

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

286 files changed

+5564
-2433
lines changed

client/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.5
1+
1.1.6

client/config/test/jest.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const globals = {};
66
buildVars.forEach(({ name, defaultValue }) => {
77
globals[name] = process.env[name] || defaultValue;
88
});
9-
const isEE = process.env.REACT_APP_EDITION === "enterprise";
9+
const edition = process.env.REACT_APP_EDITION;
10+
const isEEGlobal = edition === "enterprise-global";
11+
const isEE = edition === "enterprise" || isEEGlobal;
1012
const dirname = currentDirName(import.meta.url);
1113

1214
export default {

client/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"scripts": {
1313
"start": "yarn workspace openblocks start",
1414
"start:ee": "REACT_APP_EDITION=enterprise yarn workspace openblocks start",
15+
"start:ee-global": "REACT_APP_EDITION=enterprise-global yarn workspace openblocks start",
1516
"build": "yarn node ./scripts/build.js",
1617
"test": "jest",
1718
"prepare": "yarn workspace openblocks prepare",
@@ -71,6 +72,7 @@
7172
"react-virtualized@^9.22.3": "patch:react-virtualized@npm%3A9.22.3#./.yarn/patches/react-virtualized-npm-9.22.3-0fff3cbf64.patch"
7273
},
7374
"dependencies": {
75+
"antd-mobile": "^5.28.0",
7476
"chalk": "4",
7577
"number-precision": "^1.6.0",
7678
"react-player": "^2.11.0",

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

Lines changed: 63 additions & 59 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) {
@@ -1049,23 +1040,24 @@ var loglevel = {exports: {}};
10491040

10501041
var log = loglevel.exports;
10511042

1052-
// global variables black list, forbidden to use
1053-
var blacklist = new Set([
1043+
// global variables black list, forbidden to use in for jsQuery/jsAction
1044+
var functionBlacklist = new Set([
10541045
"top",
10551046
"parent",
10561047
"document",
10571048
"location",
10581049
"chrome",
1059-
"setTimeout",
10601050
"fetch",
1061-
"setInterval",
1062-
"clearInterval",
1063-
"setImmediate",
10641051
"XMLHttpRequest",
10651052
"importScripts",
10661053
"Navigator",
10671054
"MutationObserver",
10681055
]);
1056+
var expressionBlacklist = new Set(__spreadArray(__spreadArray([], Array.from(functionBlacklist.values()), true), [
1057+
"setTimeout",
1058+
"setInterval",
1059+
"setImmediate",
1060+
], false));
10691061
var globalVarNames = new Set(["window", "globalThis", "self", "global"]);
10701062
function createBlackHole() {
10711063
return new Proxy(function () {
@@ -1087,12 +1079,14 @@ function createBlackHole() {
10871079
},
10881080
});
10891081
}
1090-
function createMockWindow() {
1091-
var win = new Proxy({}, {
1082+
function createMockWindow(base, blacklist) {
1083+
if (blacklist === void 0) { blacklist = expressionBlacklist; }
1084+
var win = new Proxy(Object.assign({}, base), {
10921085
has: function () {
10931086
return true;
10941087
},
10951088
set: function (target, p, newValue) {
1089+
console.info("set:", p, newValue);
10961090
return Reflect.set(target, p, newValue);
10971091
},
10981092
get: function (target, p) {
@@ -1102,19 +1096,11 @@ function createMockWindow() {
11021096
if (globalVarNames.has(p)) {
11031097
return win;
11041098
}
1105-
if (typeof p === "string" && blacklist.has(p)) {
1099+
if (typeof p === "string" && (blacklist === null || blacklist === void 0 ? void 0 : blacklist.has(p))) {
11061100
log.log("[Sandbox] access ".concat(String(p), " on mock window, return mock object"));
11071101
return createBlackHole();
11081102
}
1109-
var ret = Reflect.get(window, p);
1110-
if (typeof ret === "function" && !ret.prototype) {
1111-
return ret.bind(window);
1112-
}
1113-
// get DOM element by id, serializing may cause error
1114-
if (isDomElement(ret)) {
1115-
return undefined;
1116-
}
1117-
return ret;
1103+
return getPropertyFromNativeWindow(p);
11181104
},
11191105
});
11201106
return win;
@@ -1126,12 +1112,26 @@ function clearMockWindow() {
11261112
function isDomElement(obj) {
11271113
return obj instanceof Element || obj instanceof HTMLCollection;
11281114
}
1115+
function getPropertyFromNativeWindow(prop) {
1116+
var ret = Reflect.get(window, prop);
1117+
if (typeof ret === "function" && !ret.prototype) {
1118+
return ret.bind(window);
1119+
}
1120+
// get DOM element by id, serializing may cause error
1121+
if (isDomElement(ret)) {
1122+
return undefined;
1123+
}
1124+
return ret;
1125+
}
11291126
function proxySandbox(context, methods, options) {
1130-
var _a = (options || {}).disableLimit, disableLimit = _a === void 0 ? false : _a;
1127+
var _a = options || {}, _b = _a.disableLimit, disableLimit = _b === void 0 ? false : _b, _c = _a.scope, scope = _c === void 0 ? "expression" : _c;
11311128
var isProtectedVar = function (key) {
11321129
return key in context || key in (methods || {}) || globalVarNames.has(key);
11331130
};
11341131
var cache = {};
1132+
if (scope === "function") {
1133+
mockWindow = createMockWindow(mockWindow, functionBlacklist);
1134+
}
11351135
return new Proxy(mockWindow, {
11361136
has: function (target, p) {
11371137
// proxy all variables
@@ -1163,7 +1163,7 @@ function proxySandbox(context, methods, options) {
11631163
return value;
11641164
}
11651165
if (disableLimit) {
1166-
return Reflect.get(window, p);
1166+
return getPropertyFromNativeWindow(p);
11671167
}
11681168
return Reflect.get(target, p, receiver);
11691169
},
@@ -1427,6 +1427,7 @@ var DefaultParser = /** @class */ (function () {
14271427
function evalJson(unevaledValue, context) {
14281428
return new RelaxedJsonParser(unevaledValue, context).parse();
14291429
}
1430+
// this will also be used in node-service
14301431
var RelaxedJsonParser = /** @class */ (function (_super) {
14311432
__extends(RelaxedJsonParser, _super);
14321433
function RelaxedJsonParser(unevaledValue, context) {
@@ -1503,11 +1504,12 @@ var RelaxedJsonParser = /** @class */ (function (_super) {
15031504
}(DefaultParser));
15041505
function evalFunction(unevaledValue, context, methods, isAsync) {
15051506
try {
1506-
return new ValueAndMsg(function (args, runInHost) {
1507+
return new ValueAndMsg(function (args, runInHost, scope) {
15071508
if (runInHost === void 0) { runInHost = false; }
1509+
if (scope === void 0) { scope = "function"; }
15081510
return evalFunc(unevaledValue.startsWith("return")
15091511
? unevaledValue + "\n"
1510-
: "return ".concat(isAsync ? "async " : "", "function(){'use strict'; ").concat(unevaledValue, "\n}()"), args ? __assign(__assign({}, context), args) : context, methods, { disableLimit: runInHost }, isAsync);
1512+
: "return ".concat(isAsync ? "async " : "", "function(){'use strict'; ").concat(unevaledValue, "\n}()"), args ? __assign(__assign({}, context), args) : context, methods, { disableLimit: runInHost, scope: scope }, isAsync);
15111513
});
15121514
}
15131515
catch (err) {
@@ -3209,8 +3211,8 @@ function updateNodesV2Action(value) {
32093211
value: value,
32103212
};
32113213
}
3212-
function wrapActionExtraInfo(action, extraCompInfos) {
3213-
return __assign(__assign({}, action), { extraInfo: { compInfos: extraCompInfos } });
3214+
function wrapActionExtraInfo(action, extraInfos) {
3215+
return __assign(__assign({}, action), { extraInfo: __assign(__assign({}, action.extraInfo), extraInfos) });
32143216
}
32153217
function deferAction(action) {
32163218
return __assign(__assign({}, action), { priority: "defer" });
@@ -7537,6 +7539,7 @@ exports.FetchCheckNode = FetchCheckNode;
75377539
exports.FunctionNode = FunctionNode;
75387540
exports.MultiBaseComp = MultiBaseComp;
75397541
exports.RecordNode = RecordNode;
7542+
exports.RelaxedJsonParser = RelaxedJsonParser;
75407543
exports.SimpleAbstractComp = SimpleAbstractComp;
75417544
exports.SimpleComp = SimpleComp;
75427545
exports.SimpleNode = SimpleNode;
@@ -7558,6 +7561,7 @@ exports.evalFunc = evalFunc;
75587561
exports.evalFunctionResult = evalFunctionResult;
75597562
exports.evalNodeOrMinor = evalNodeOrMinor;
75607563
exports.evalPerfUtil = evalPerfUtil;
7564+
exports.evalScript = evalScript;
75617565
exports.evalStyle = evalStyle;
75627566
exports.executeQueryAction = executeQueryAction;
75637567
exports.fromRecord = fromRecord;

0 commit comments

Comments
 (0)