Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 531c053

Browse files
Merge pull request #1167 from lowcoder-org/js-query-dependencies-fix
fix js query to mark ready for itself as dependency
2 parents 0d2bf6a + 7ca6172 commit 531c053

File tree

6 files changed

+247
-231
lines changed

6 files changed

+247
-231
lines changed

‎client/packages/lowcoder-core/lib/index.cjs‎

Lines changed: 121 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -9,120 +9,118 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
99

1010
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
1111

12-
/******************************************************************************
13-
Copyright (c) Microsoft Corporation.
14-
15-
Permission to use, copy, modify, and/or distribute this software for any
16-
purpose with or without fee is hereby granted.
17-
18-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
19-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
20-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
21-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24-
PERFORMANCE OF THIS SOFTWARE.
25-
***************************************************************************** */
26-
/* global Reflect, Promise, SuppressedError, Symbol */
27-
28-
// https://github.com/microsoft/tslib
29-
30-
var extendStatics = function(d, b) {
31-
extendStatics = Object.setPrototypeOf ||
32-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
34-
return extendStatics(d, b);
35-
};
36-
37-
function __extends(d, b) {
38-
if (typeof b !== "function" && b !== null)
39-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
40-
extendStatics(d, b);
41-
function __() { this.constructor = d; }
42-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
43-
}
44-
45-
var __assign = function() {
46-
__assign = Object.assign || function __assign(t) {
47-
for (var s, i = 1, n = arguments.length; i < n; i++) {
48-
s = arguments[i];
49-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
50-
}
51-
return t;
52-
};
53-
return __assign.apply(this, arguments);
54-
};
55-
56-
function __rest(s, e) {
57-
var t = {};
58-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
59-
t[p] = s[p];
60-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
61-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
62-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
63-
t[p[i]] = s[p[i]];
64-
}
65-
return t;
66-
}
67-
68-
function __decorate(decorators, target, key, desc) {
69-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
70-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
71-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
72-
return c > 3 && r && Object.defineProperty(target, key, r), r;
73-
}
74-
75-
function __awaiter(thisArg, _arguments, P, generator) {
76-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
77-
return new (P || (P = Promise))(function (resolve, reject) {
78-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
79-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
80-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
81-
step((generator = generator.apply(thisArg, _arguments || [])).next());
82-
});
83-
}
84-
85-
function __generator(thisArg, body) {
86-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
87-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
88-
function verb(n) { return function (v) { return step([n, v]); }; }
89-
function step(op) {
90-
if (f) throw new TypeError("Generator is already executing.");
91-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
92-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
93-
if (y = 0, t) op = [op[0] & 2, t.value];
94-
switch (op[0]) {
95-
case 0: case 1: t = op; break;
96-
case 4: _.label++; return { value: op[1], done: false };
97-
case 5: _.label++; y = op[1]; op = [0]; continue;
98-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
99-
default:
100-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
101-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
102-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
103-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
104-
if (t[2]) _.ops.pop();
105-
_.trys.pop(); continue;
106-
}
107-
op = body.call(thisArg, _);
108-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
109-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
110-
}
111-
}
112-
113-
function __spreadArray(to, from, pack) {
114-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
115-
if (ar || !(i in from)) {
116-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
117-
ar[i] = from[i];
118-
}
119-
}
120-
return to.concat(ar || Array.prototype.slice.call(from));
121-
}
122-
123-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
124-
var e = new Error(message);
125-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
12+
/******************************************************************************
13+
Copyright (c) Microsoft Corporation.
14+
15+
Permission to use, copy, modify, and/or distribute this software for any
16+
purpose with or without fee is hereby granted.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
19+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
20+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
21+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24+
PERFORMANCE OF THIS SOFTWARE.
25+
***************************************************************************** */
26+
/* global Reflect, Promise, SuppressedError, Symbol */
27+
28+
var extendStatics = function(d, b) {
29+
extendStatics = Object.setPrototypeOf ||
30+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
32+
return extendStatics(d, b);
33+
};
34+
35+
function __extends(d, b) {
36+
if (typeof b !== "function" && b !== null)
37+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
38+
extendStatics(d, b);
39+
function __() { this.constructor = d; }
40+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
41+
}
42+
43+
var __assign = function() {
44+
__assign = Object.assign || function __assign(t) {
45+
for (var s, i = 1, n = arguments.length; i < n; i++) {
46+
s = arguments[i];
47+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
48+
}
49+
return t;
50+
};
51+
return __assign.apply(this, arguments);
52+
};
53+
54+
function __rest(s, e) {
55+
var t = {};
56+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
57+
t[p] = s[p];
58+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
59+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
60+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
61+
t[p[i]] = s[p[i]];
62+
}
63+
return t;
64+
}
65+
66+
function __decorate(decorators, target, key, desc) {
67+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
68+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
69+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
70+
return c > 3 && r && Object.defineProperty(target, key, r), r;
71+
}
72+
73+
function __awaiter(thisArg, _arguments, P, generator) {
74+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
75+
return new (P || (P = Promise))(function (resolve, reject) {
76+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
77+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
78+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
79+
step((generator = generator.apply(thisArg, _arguments || [])).next());
80+
});
81+
}
82+
83+
function __generator(thisArg, body) {
84+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
85+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
86+
function verb(n) { return function (v) { return step([n, v]); }; }
87+
function step(op) {
88+
if (f) throw new TypeError("Generator is already executing.");
89+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
90+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
91+
if (y = 0, t) op = [op[0] & 2, t.value];
92+
switch (op[0]) {
93+
case 0: case 1: t = op; break;
94+
case 4: _.label++; return { value: op[1], done: false };
95+
case 5: _.label++; y = op[1]; op = [0]; continue;
96+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
97+
default:
98+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
99+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
100+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
101+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
102+
if (t[2]) _.ops.pop();
103+
_.trys.pop(); continue;
104+
}
105+
op = body.call(thisArg, _);
106+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
107+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
108+
}
109+
}
110+
111+
function __spreadArray(to, from, pack) {
112+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
113+
if (ar || !(i in from)) {
114+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
115+
ar[i] = from[i];
116+
}
117+
}
118+
return to.concat(ar || Array.prototype.slice.call(from));
119+
}
120+
121+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
122+
var e = new Error(message);
123+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
126124
};
127125

128126
function isEqualArgs(args, cacheArgs, equals) {
@@ -1780,12 +1778,21 @@ var CodeNode = /** @class */ (function (_super) {
17801778
var isFetching_1 = false;
17811779
var ready_1 = true;
17821780
topDepends.forEach(function (paths, depend) {
1781+
var pathsArr = Array.from(paths);
17831782
var value = depend.evaluate(exposingNodes);
17841783
if ((options === null || options === void 0 ? void 0 : options.ignoreManualDepReadyStatus) &&
17851784
___default["default"].has(value, TRIGGER_TYPE_FIELD) &&
17861785
value.triggerType === "manual") {
17871786
return;
17881787
}
1788+
// if query is dependent on itself, mark as ready
1789+
if ((pathsArr === null || pathsArr === void 0 ? void 0 : pathsArr[0]) === (options === null || options === void 0 ? void 0 : options.queryName))
1790+
return;
1791+
// wait for lazy loaded comps to load before executing query on page load
1792+
if (!Object.keys(value).length && paths.size) {
1793+
isFetching_1 = true;
1794+
ready_1 = false;
1795+
}
17891796
if (___default["default"].has(value, IS_FETCHING_FIELD)) {
17901797
isFetching_1 = isFetching_1 || value.isFetching === true;
17911798
}

‎client/packages/lowcoder-core/lib/index.d.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="react" />
22
import * as react from 'react';
3-
import { ReactNode } from 'react';
3+
import React,{ ReactNode } from 'react';
44
import * as react_jsx_runtime from 'react/jsx-runtime';
55

66
type EvalMethods = Record<string, Record<string, Function>>;
@@ -32,6 +32,7 @@ type RecordOptionalNodeToValue<T> = {
3232
};
3333
interface FetchInfoOptions {
3434
ignoreManualDepReadyStatus?: boolean;
35+
queryName?: string;
3536
}
3637
/**
3738
* the base structure for evaluate

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /