Skip to content

Commit c7987f9

Browse files
ggbond2077QIQI03
authored andcommitted
- fix: table performance
- feat: resource dropdown support search - feat: branding - fix: scanner comp adapt oppo - fix: chrome86 link issue - fix: input validate ref self
1 parent f5f999b commit c7987f9

Some content is hidden

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

66 files changed

+548
-288
lines changed

client/packages/openblocks-comps/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "openblocks-comps",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"type": "module",
55
"license": "MIT",
66
"dependencies": {
77
"@types/react": "17",
88
"@types/react-dom": "17",
9+
"big.js": "^6.2.1",
910
"openblocks-cli": "workspace:^",
1011
"openblocks-sdk": "workspace:^",
1112
"react": "17",

client/packages/openblocks-comps/src/comps/chartComp/chartConstants.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ScatterChartConfig } from "./chartConfigs/scatterChartConfig";
1515
import { SeriesListComp } from "./seriesComp";
1616
import { EChartsOption } from "echarts";
1717
import { i18nObjs, trans } from "i18n/comps";
18+
import { JSONValue } from "openblocks";
1819

1920
export const ChartTypeOptions = [
2021
{
@@ -183,7 +184,18 @@ export const noDataPieChartConfig = {
183184
export type ChartSize = { w: number; h: number };
184185

185186
export const getDataKeys = (data: Array<JSONObject>) => {
186-
return data && data[0] ? Object.keys(data[0]) : [];
187+
if (!data) {
188+
return [];
189+
}
190+
const dataKeys: Array<string> = [];
191+
data.slice(0, 50).forEach((d) => {
192+
Object.keys(d).forEach((key) => {
193+
if (!dataKeys.includes(key)) {
194+
dataKeys.push(key);
195+
}
196+
});
197+
});
198+
return dataKeys;
187199
};
188200

189201
const ChartOptionMap = {

client/packages/openblocks-comps/src/comps/chartComp/chartUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { EChartsOption } from "echarts";
1010
import _ from "lodash";
1111
import { chartColorPalette, isNumeric, JSONObject } from "openblocks-sdk";
1212
import { calcXYConfig } from "comps/chartComp/chartConfigs/cartesianAxisConfig";
13+
import Big from "big.js";
1314

1415
export function transformData(
1516
originData: JSONObject[],
@@ -38,7 +39,8 @@ export function transformData(
3839
if (key === xAxis) {
3940
return;
4041
} else if (isNumeric(cur[key])) {
41-
prev[groupValue][key] += Number(cur[key]);
42+
const bigNum = Big(cur[key]);
43+
prev[groupValue][key] = bigNum.add(prev[groupValue][key]).toNumber();
4244
} else {
4345
prev[groupValue][key] += 1;
4446
}

client/packages/openblocks-core/lib/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ReactNode } from "react";
22

33
declare type EvalMethods = Record<string, Record<string, Function>>;
44
declare type CodeType = undefined | "JSON" | "Function";
5+
declare type CodeFunction = (args?: Record<string, unknown>, runInHost?: boolean) => any;
56

67
declare type NodeToValue<NodeT> = NodeT extends Node<infer ValueType> ? ValueType : never;
78
declare type FetchInfo = {
@@ -284,7 +285,7 @@ declare class WrapNode<T> extends AbstractNode<T> {
284285
dependValues(): Record<string, unknown>;
285286
}
286287

287-
declare type WrapContextFn<T> = (params: Record<string, unknown>) => T;
288+
declare type WrapContextFn<T> = (params?: Record<string, unknown>) => T;
288289
declare function wrapContext<T>(node: Node<T>): Node<WrapContextFn<T>>;
289290

290291
/**
@@ -760,6 +761,7 @@ export {
760761
BroadcastAction,
761762
CachedNode,
762763
ChangeValueAction,
764+
CodeFunction,
763765
CodeNode,
764766
CodeNodeOptions,
765767
CodeType,

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

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,19 +1497,13 @@ var RelaxedJsonParser = /** @class */ (function (_super) {
14971497
};
14981498
return RelaxedJsonParser;
14991499
}(DefaultParser));
1500-
function mergeContext(context, args) {
1501-
if (!args) {
1502-
return context;
1503-
}
1504-
return Object.assign(Object.assign({}, args), context);
1505-
}
15061500
function evalFunction(unevaledValue, context, methods, isAsync) {
15071501
try {
15081502
return new ValueAndMsg(function (args, runInHost) {
15091503
if (runInHost === void 0) { runInHost = false; }
15101504
return evalFunc(unevaledValue.startsWith("return")
15111505
? unevaledValue + "\n"
1512-
: "return function(){'use strict'; " + unevaledValue + "\n}()", mergeContext(context, args), methods, { disableLimit: runInHost }, isAsync);
1506+
: "return function(){'use strict'; " + unevaledValue + "\n}()", args ? __assign(__assign({}, context), args) : context, methods, { disableLimit: runInHost }, isAsync);
15131507
});
15141508
}
15151509
catch (err) {
@@ -2897,17 +2891,19 @@ var WrapContextNode = /** @class */ (function (_super) {
28972891
};
28982892
WrapContextNode.prototype.justEval = function (exposingNodes, methods) {
28992893
var _this = this;
2900-
var paramNodes = {};
29012894
return function (params) {
2902-
Object.entries(params).forEach(function (_a) {
2903-
var paramName = _a[0], value = _a[1];
2904-
// node remains unchanged if value doesn't change, to keep the cache valid
2905-
var paramNode = paramNodes[paramName];
2906-
if (!paramNode || value !== paramNode.value) {
2907-
paramNodes[paramName] = fromValueWithCache(value); // requires cache
2908-
}
2909-
});
2910-
return _this.child.evaluate(__assign(__assign({}, exposingNodes), paramNodes), methods);
2895+
var nodes;
2896+
if (params) {
2897+
nodes = __assign({}, exposingNodes);
2898+
Object.entries(params).forEach(function (_a) {
2899+
var key = _a[0], value = _a[1];
2900+
nodes[key] = fromValueWithCache(value);
2901+
});
2902+
}
2903+
else {
2904+
nodes = exposingNodes;
2905+
}
2906+
return _this.child.evaluate(nodes, methods);
29112907
};
29122908
};
29132909
WrapContextNode.prototype.getChildren = function () {

client/packages/openblocks-core/src/eval/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export * from "./wrapContextNodeV2";
1111
export { transformWrapper } from "./utils/codeNodeUtils";
1212
export { evalPerfUtil } from "./utils/perfUtils";
1313

14-
export type { EvalMethods, CodeType } from "./types/evalTypes";
14+
export type { EvalMethods, CodeType, CodeFunction } from "./types/evalTypes";
1515
export { ValueAndMsg } from "./types/valueAndMsg";
1616
export { relaxedJSONToJSON } from "./utils/relaxedJson";
1717
export { getDynamicStringSegments, isDynamicSegment } from "./utils/segmentUtils";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export type EvalMethods = Record<string, Record<string, Function>>;
22

33
export type CodeType = undefined | "JSON" | "Function";
4+
5+
export type CodeFunction = (args?: Record<string, unknown>, runInHost?: boolean) => any;

client/packages/openblocks-core/src/eval/utils/evaluate.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ describe("deps", () => {
2929
expect(depsD.has(context.data)).toBe(true);
3030
expect(depsD.has(context.str)).toBe(true);
3131
expect(depsD.has(context.i)).toBe(false);
32+
33+
expect(filterDepends("{{new Date().toLocaleString()}}", context)).toStrictEqual(new Map());
3234
});
3335
});
3436

client/packages/openblocks-core/src/eval/utils/string2Fn.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import _ from "lodash";
33
import { getErrorMessage } from "./nodeUtils";
44
import { evalFunc, evalScript } from "./evalScript";
55
import { getDynamicStringSegments, isDynamicSegment } from "./segmentUtils";
6-
import { CodeType, EvalMethods } from "../types/evalTypes";
6+
import { CodeFunction, CodeType, EvalMethods } from "../types/evalTypes";
77
import { relaxedJSONToJSON } from "./relaxedJson";
88

99
export type Fn = (context: Record<string, unknown>) => ValueAndMsg<unknown>;
@@ -154,26 +154,19 @@ class RelaxedJsonParser extends DefaultParser {
154154
}
155155
}
156156

157-
function mergeContext(context: Record<string, unknown>, args?: Record<string, unknown>) {
158-
if (!args) {
159-
return context;
160-
}
161-
return Object.assign(Object.assign({}, args), context);
162-
}
163-
164157
export function evalFunction(
165158
unevaledValue: string,
166159
context: Record<string, unknown>,
167160
methods?: EvalMethods,
168161
isAsync?: boolean
169-
): ValueAndMsg<Function> {
162+
): ValueAndMsg<CodeFunction> {
170163
try {
171164
return new ValueAndMsg((args?: Record<string, unknown>, runInHost: boolean = false) =>
172165
evalFunc(
173166
unevaledValue.startsWith("return")
174167
? unevaledValue + "\n"
175168
: "return function(){'use strict'; " + unevaledValue + "\n}()",
176-
mergeContext(context, args),
169+
args ? { ...context, ...args } : context,
177170
methods,
178171
{ disableLimit: runInHost },
179172
isAsync

client/packages/openblocks-core/src/eval/wrapContextNode.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ it("context test", () => {
1010
const c1Value = c1.evaluate();
1111
expect(c1Value({ v1: 10, v2: 10 }).xx).toStrictEqual("11 30");
1212
expect(c1Value({ v1: 11, v2: 11 }).xx).toStrictEqual("11 32");
13+
expect(c1Value({ v1: 11 }).xx).toStrictEqual("11 NaN");
14+
expect(c1Value().xx).toStrictEqual("11 NaN");
1315
});
1416

1517
it("context test 2", () => {
@@ -21,4 +23,6 @@ it("context test 2", () => {
2123
const c1Value = c1.evaluate();
2224
expect(c1Value({ i: 1 }).xx).toStrictEqual(1);
2325
expect(c1Value({ i: 1 }).yy).toStrictEqual("a1");
26+
expect(c1Value({}).yy).toStrictEqual("a");
27+
expect(c1Value().yy).toStrictEqual("a");
2428
});

0 commit comments

Comments
 (0)