dara-core 1.15.4__py3-none-any.whl → 1.15.5__py3-none-any.whl
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.
- dara/core/umd/dara.core.umd.js +954 -916
- {dara_core-1.15.4.dist-info → dara_core-1.15.5.dist-info}/METADATA +10 -10
- {dara_core-1.15.4.dist-info → dara_core-1.15.5.dist-info}/RECORD +6 -6
- {dara_core-1.15.4.dist-info → dara_core-1.15.5.dist-info}/LICENSE +0 -0
- {dara_core-1.15.4.dist-info → dara_core-1.15.5.dist-info}/WHEEL +0 -0
- {dara_core-1.15.4.dist-info → dara_core-1.15.5.dist-info}/entry_points.txt +0 -0
dara/core/umd/dara.core.umd.js
CHANGED
|
@@ -33,7 +33,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
33
33
|
(function(global2, factory) {
|
|
34
34
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("@tanstack/react-query"), require("react-dom"), require("styled-components")) : typeof define === "function" && define.amd ? define(["exports", "react", "@tanstack/react-query", "react-dom", "styled-components"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory((global2.dara = global2.dara || {}, global2.dara.core = {}), global2.React, global2.ReactQuery, global2.ReactDOM, global2.styled));
|
|
35
35
|
})(this, function(exports, React, reactQuery, ReactDOM, styled) {
|
|
36
|
-
var _locks, _subscribers, _pingInterval, _socketUrl, _reconnectCount,
|
|
36
|
+
var _locks, _subscribers, _events$, _parentBus, _pingInterval, _socketUrl, _reconnectCount, _instance, _observers;
|
|
37
37
|
"use strict";
|
|
38
38
|
const _interopDefaultLegacy = (e3) => e3 && typeof e3 === "object" && "default" in e3 ? e3 : { default: e3 };
|
|
39
39
|
function _interopNamespace(e3) {
|
|
@@ -16020,11 +16020,11 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
16020
16020
|
try {
|
|
16021
16021
|
const json = yield res.json();
|
|
16022
16022
|
message = (json === null || json === void 0 ? void 0 : json.message) || (json === null || json === void 0 ? void 0 : json.detail) || fallbackMessage;
|
|
16023
|
-
} catch (
|
|
16023
|
+
} catch (_a) {
|
|
16024
16024
|
if (fallbackMessage) {
|
|
16025
16025
|
try {
|
|
16026
16026
|
message = (yield res.text()) || fallbackMessage;
|
|
16027
|
-
} catch (
|
|
16027
|
+
} catch (_b) {
|
|
16028
16028
|
}
|
|
16029
16029
|
}
|
|
16030
16030
|
}
|
|
@@ -33717,6 +33717,21 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
33717
33717
|
return "right: 3px;";
|
|
33718
33718
|
case "right":
|
|
33719
33719
|
return "left: -5px;";
|
|
33720
|
+
case "top-start":
|
|
33721
|
+
case "top-end":
|
|
33722
|
+
return "bottom: 3px;";
|
|
33723
|
+
case "bottom-start":
|
|
33724
|
+
case "bottom-end":
|
|
33725
|
+
return "top: -5px;";
|
|
33726
|
+
case "left-start":
|
|
33727
|
+
case "left-end":
|
|
33728
|
+
return "right: 3px;";
|
|
33729
|
+
case "right-start":
|
|
33730
|
+
case "right-end":
|
|
33731
|
+
return "left: -5px;";
|
|
33732
|
+
case "auto":
|
|
33733
|
+
case "auto-start":
|
|
33734
|
+
case "auto-end":
|
|
33720
33735
|
default:
|
|
33721
33736
|
return "display: none;";
|
|
33722
33737
|
}
|
|
@@ -33736,12 +33751,24 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
33736
33751
|
${(props) => {
|
|
33737
33752
|
switch (props.placement) {
|
|
33738
33753
|
case "top":
|
|
33754
|
+
case "top-start":
|
|
33755
|
+
case "top-end":
|
|
33756
|
+
return "transform: rotate(45deg);";
|
|
33739
33757
|
case "bottom":
|
|
33758
|
+
case "bottom-start":
|
|
33759
|
+
case "bottom-end":
|
|
33740
33760
|
return "transform: rotate(45deg);";
|
|
33741
33761
|
case "left":
|
|
33762
|
+
case "left-start":
|
|
33763
|
+
case "left-end":
|
|
33742
33764
|
return "transform: rotate(135deg);";
|
|
33743
33765
|
case "right":
|
|
33766
|
+
case "right-start":
|
|
33767
|
+
case "right-end":
|
|
33744
33768
|
return "transform: rotate(-45deg);";
|
|
33769
|
+
case "auto":
|
|
33770
|
+
case "auto-start":
|
|
33771
|
+
case "auto-end":
|
|
33745
33772
|
default:
|
|
33746
33773
|
return "display: none;";
|
|
33747
33774
|
}
|
|
@@ -36529,10 +36556,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
36529
36556
|
user-select: none;
|
|
36530
36557
|
|
|
36531
36558
|
overflow: hidden;
|
|
36532
|
-
|
|
36533
36559
|
display: flex;
|
|
36534
|
-
justify-content: space-between;
|
|
36535
36560
|
align-items: center;
|
|
36561
|
+
justify-content: space-between;
|
|
36562
|
+
|
|
36536
36563
|
width: 100%;
|
|
36537
36564
|
min-height: 2rem;
|
|
36538
36565
|
padding: 0.25rem 1rem;
|
|
@@ -36579,8 +36606,8 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
36579
36606
|
box-shadow: ${(props) => props.theme.shadow.light};
|
|
36580
36607
|
`;
|
|
36581
36608
|
const InnerItem = styled__default.default.span`
|
|
36582
|
-
min-width: 0;
|
|
36583
36609
|
overflow: hidden;
|
|
36610
|
+
min-width: 0;
|
|
36584
36611
|
text-overflow: ellipsis;
|
|
36585
36612
|
white-space: nowrap;
|
|
36586
36613
|
`;
|
|
@@ -50477,8 +50504,13 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50477
50504
|
return isAfter$1(parsedValue, filterValue);
|
|
50478
50505
|
case DateOperator.LT:
|
|
50479
50506
|
return isBefore$1(parsedValue, filterValue);
|
|
50507
|
+
case DateOperator.BT:
|
|
50508
|
+
if (Array.isArray(filterValue)) {
|
|
50509
|
+
return isWithinInterval$1(parsedValue, { start: filterValue[0], end: filterValue[1] });
|
|
50510
|
+
}
|
|
50511
|
+
return false;
|
|
50480
50512
|
default:
|
|
50481
|
-
return
|
|
50513
|
+
return false;
|
|
50482
50514
|
}
|
|
50483
50515
|
}
|
|
50484
50516
|
function numeric(rows, columnIds, filterValue) {
|
|
@@ -50623,6 +50655,12 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50623
50655
|
background-color: ${(props) => props.theme.colors.background};
|
|
50624
50656
|
box-shadow: ${(props) => props.theme.shadow.light};
|
|
50625
50657
|
`;
|
|
50658
|
+
const columnHeaderToString = (header) => {
|
|
50659
|
+
if (typeof header === "string") {
|
|
50660
|
+
return header;
|
|
50661
|
+
}
|
|
50662
|
+
return "";
|
|
50663
|
+
};
|
|
50626
50664
|
const OptionsMenu = ({ allColumns, allowColumnHiding, numVisibleColumns, resetResizing, setAllFilters, style }) => {
|
|
50627
50665
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
50628
50666
|
const toggleOptions = React.useCallback(() => {
|
|
@@ -50678,9 +50716,9 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
50678
50716
|
const columnToggles = React.useMemo(() => {
|
|
50679
50717
|
return {
|
|
50680
50718
|
items: allColumns.filter((column) => typeof column.Header === "string").map((column) => ({
|
|
50681
|
-
label: `${column.isVisible ? "Hide" : "Show"} ${
|
|
50719
|
+
label: `${column.isVisible ? "Hide" : "Show"} ${columnHeaderToString(column.Header)}`,
|
|
50682
50720
|
onClick: () => !(column.isVisible && numVisibleColumns === 1) ? column.toggleHidden() : null,
|
|
50683
|
-
value: `${column.isVisible ? "hide" : "show"}${
|
|
50721
|
+
value: `${column.isVisible ? "hide" : "show"}${columnHeaderToString(column.Header)}`
|
|
50684
50722
|
})),
|
|
50685
50723
|
label: "Columns"
|
|
50686
50724
|
};
|
|
@@ -55118,8 +55156,132 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
55118
55156
|
}
|
|
55119
55157
|
return response;
|
|
55120
55158
|
}
|
|
55121
|
-
const
|
|
55122
|
-
|
|
55159
|
+
const requestExtrasCtx = React.createContext({ options: {} });
|
|
55160
|
+
function useRequestExtras() {
|
|
55161
|
+
const { options } = React.useContext(requestExtrasCtx);
|
|
55162
|
+
const extras = React.useMemo(() => {
|
|
55163
|
+
return options;
|
|
55164
|
+
}, [useDeepCompare(options)]);
|
|
55165
|
+
return extras;
|
|
55166
|
+
}
|
|
55167
|
+
function RequestExtrasProvider({
|
|
55168
|
+
children,
|
|
55169
|
+
options
|
|
55170
|
+
}) {
|
|
55171
|
+
return /* @__PURE__ */ React__default.default.createElement(requestExtrasCtx.Provider, { value: { options } }, children);
|
|
55172
|
+
}
|
|
55173
|
+
function mergeRequestInits(a2, b2) {
|
|
55174
|
+
const mergedHeaders = new Headers(a2.headers);
|
|
55175
|
+
const bHeaders = new Headers(b2.headers);
|
|
55176
|
+
bHeaders.forEach((value, key) => {
|
|
55177
|
+
mergedHeaders.set(key, value);
|
|
55178
|
+
});
|
|
55179
|
+
return {
|
|
55180
|
+
...a2,
|
|
55181
|
+
...b2,
|
|
55182
|
+
headers: mergedHeaders
|
|
55183
|
+
};
|
|
55184
|
+
}
|
|
55185
|
+
function PartialRequestExtrasProvider({
|
|
55186
|
+
children,
|
|
55187
|
+
options
|
|
55188
|
+
}) {
|
|
55189
|
+
const { options: parentOptions } = React.useContext(requestExtrasCtx);
|
|
55190
|
+
const mergedInits = React.useMemo(() => mergeRequestInits(parentOptions, options), [parentOptions, options]);
|
|
55191
|
+
return /* @__PURE__ */ React__default.default.createElement(requestExtrasCtx.Provider, { value: { options: mergedInits } }, children);
|
|
55192
|
+
}
|
|
55193
|
+
var AuthenticationErrorReason = /* @__PURE__ */ ((AuthenticationErrorReason2) => {
|
|
55194
|
+
AuthenticationErrorReason2["BAD_REQUEST"] = "bad_request";
|
|
55195
|
+
AuthenticationErrorReason2["EXPIRED_TOKEN"] = "expired";
|
|
55196
|
+
AuthenticationErrorReason2["INVALID_CREDENTIALS"] = "invalid_credentials";
|
|
55197
|
+
AuthenticationErrorReason2["INVALID_TOKEN"] = "invalid_token";
|
|
55198
|
+
AuthenticationErrorReason2["OTHER"] = "other";
|
|
55199
|
+
AuthenticationErrorReason2["UNAUTHORIZED"] = "unauthorized";
|
|
55200
|
+
return AuthenticationErrorReason2;
|
|
55201
|
+
})(AuthenticationErrorReason || {});
|
|
55202
|
+
function isAuthenticationError(message) {
|
|
55203
|
+
return message !== null && message !== void 0 && typeof message === "object" && "reason" in message && Object.values(AuthenticationErrorReason).includes(message.reason);
|
|
55204
|
+
}
|
|
55205
|
+
function shouldIgnoreError(message, ignoreErrors) {
|
|
55206
|
+
return ignoreErrors && ignoreErrors.includes(message.reason);
|
|
55207
|
+
}
|
|
55208
|
+
function shouldRedirectToLogin(message) {
|
|
55209
|
+
return ["invalid_credentials", "expired"].includes(
|
|
55210
|
+
message.reason
|
|
55211
|
+
);
|
|
55212
|
+
}
|
|
55213
|
+
function useAuthConfig() {
|
|
55214
|
+
return reactQuery.useQuery(
|
|
55215
|
+
["auth-config"],
|
|
55216
|
+
async () => {
|
|
55217
|
+
const response = await request("/api/core/auth-config", {
|
|
55218
|
+
method: HTTP_METHOD.GET
|
|
55219
|
+
});
|
|
55220
|
+
return response.json();
|
|
55221
|
+
},
|
|
55222
|
+
{ refetchOnWindowFocus: false }
|
|
55223
|
+
);
|
|
55224
|
+
}
|
|
55225
|
+
async function revokeSession() {
|
|
55226
|
+
try {
|
|
55227
|
+
const response = await request("/api/auth/revoke-session", {
|
|
55228
|
+
method: HTTP_METHOD.POST
|
|
55229
|
+
});
|
|
55230
|
+
if (response.ok) {
|
|
55231
|
+
const responseData = await response.json();
|
|
55232
|
+
return responseData;
|
|
55233
|
+
}
|
|
55234
|
+
} catch (e3) {
|
|
55235
|
+
console.error("Failed to revoke session", e3);
|
|
55236
|
+
}
|
|
55237
|
+
}
|
|
55238
|
+
async function handleAuthErrors(res, toLogin = false, ignoreErrors = null) {
|
|
55239
|
+
var _a;
|
|
55240
|
+
const content = await res.clone().json();
|
|
55241
|
+
if (isAuthenticationError(content == null ? void 0 : content.detail) && !shouldIgnoreError(content == null ? void 0 : content.detail, ignoreErrors)) {
|
|
55242
|
+
localStorage.removeItem(getTokenKey());
|
|
55243
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
55244
|
+
const referrer = (_a = queryParams.get("referrer")) != null ? _a : encodeURIComponent(window.location.pathname + window.location.search);
|
|
55245
|
+
const path = toLogin || shouldRedirectToLogin(content.detail) ? `/login?referrer=${referrer}` : `/error?code=${res.status}`;
|
|
55246
|
+
window.location.href = `${window.dara.base_url}${path}`;
|
|
55247
|
+
return true;
|
|
55248
|
+
}
|
|
55249
|
+
return false;
|
|
55250
|
+
}
|
|
55251
|
+
function useUser() {
|
|
55252
|
+
const extras = useRequestExtras();
|
|
55253
|
+
return reactQuery.useQuery({
|
|
55254
|
+
queryFn: async () => {
|
|
55255
|
+
const res = await request("/api/auth/user", { method: HTTP_METHOD.GET }, extras);
|
|
55256
|
+
await handleAuthErrors(res);
|
|
55257
|
+
await validateResponse(res, "Failed to fetch user for this app");
|
|
55258
|
+
return res.json();
|
|
55259
|
+
},
|
|
55260
|
+
queryKey: ["user"],
|
|
55261
|
+
refetchOnWindowFocus: false
|
|
55262
|
+
});
|
|
55263
|
+
}
|
|
55264
|
+
async function requestSessionToken(body = {}) {
|
|
55265
|
+
const res = await request("/api/auth/session", {
|
|
55266
|
+
body: JSON.stringify(body),
|
|
55267
|
+
method: HTTP_METHOD.POST
|
|
55268
|
+
});
|
|
55269
|
+
const loggedOut = await handleAuthErrors(res, false, ["invalid_credentials"]);
|
|
55270
|
+
if (loggedOut) {
|
|
55271
|
+
return null;
|
|
55272
|
+
}
|
|
55273
|
+
await validateResponse(res, "Failed to fetch the session token");
|
|
55274
|
+
const parsedResponse = await res.json();
|
|
55275
|
+
const { token } = parsedResponse;
|
|
55276
|
+
localStorage.setItem(getTokenKey(), token);
|
|
55277
|
+
return token;
|
|
55278
|
+
}
|
|
55279
|
+
async function verifySessionToken() {
|
|
55280
|
+
const res = await request("/api/auth/verify-session", {
|
|
55281
|
+
method: HTTP_METHOD.POST
|
|
55282
|
+
});
|
|
55283
|
+
return res.ok;
|
|
55284
|
+
}
|
|
55123
55285
|
function commonjsRequire(path) {
|
|
55124
55286
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
55125
55287
|
}
|
|
@@ -55998,6 +56160,172 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
55998
56160
|
}
|
|
55999
56161
|
return identifier;
|
|
56000
56162
|
}
|
|
56163
|
+
function isPlaceholder(value) {
|
|
56164
|
+
return typeof value === "object" && "__ref" in value;
|
|
56165
|
+
}
|
|
56166
|
+
function getIdentifier(variable) {
|
|
56167
|
+
let id = `${variable.__typename}:${variable.uid}`;
|
|
56168
|
+
if ("nested" in variable && variable.nested.length > 0) {
|
|
56169
|
+
id += `:${variable.nested.join(",")}`;
|
|
56170
|
+
}
|
|
56171
|
+
if ("filters" in variable) {
|
|
56172
|
+
id += `:${hashObject(variable.filters)}`;
|
|
56173
|
+
}
|
|
56174
|
+
return id;
|
|
56175
|
+
}
|
|
56176
|
+
function getEntries(obj) {
|
|
56177
|
+
if (Array.isArray(obj)) {
|
|
56178
|
+
return obj.entries();
|
|
56179
|
+
}
|
|
56180
|
+
return Object.entries(obj);
|
|
56181
|
+
}
|
|
56182
|
+
function denormalize(obj, lookup) {
|
|
56183
|
+
if (!obj) {
|
|
56184
|
+
return obj;
|
|
56185
|
+
}
|
|
56186
|
+
if (isPlaceholder(obj)) {
|
|
56187
|
+
const referrable = lookup[obj.__ref];
|
|
56188
|
+
return denormalize(referrable, lookup);
|
|
56189
|
+
}
|
|
56190
|
+
const output = Array.isArray(obj) ? [] : {};
|
|
56191
|
+
for (const [key, val] of getEntries(obj)) {
|
|
56192
|
+
if (val !== null && typeof val === "object") {
|
|
56193
|
+
output[key] = denormalize(val, lookup);
|
|
56194
|
+
} else {
|
|
56195
|
+
output[key] = val;
|
|
56196
|
+
}
|
|
56197
|
+
}
|
|
56198
|
+
return output;
|
|
56199
|
+
}
|
|
56200
|
+
function normalizeResolvedDerivedVariable(resolved, def) {
|
|
56201
|
+
const normalizedValues = [];
|
|
56202
|
+
let lookup = {};
|
|
56203
|
+
for (const [key, val] of resolved.values.entries()) {
|
|
56204
|
+
if (isResolvedDerivedVariable(val) || isResolvedDerivedDataVariable(val)) {
|
|
56205
|
+
const { data: nestedNormalized, lookup: nestedLookup } = normalizeResolvedDerivedVariable(
|
|
56206
|
+
val,
|
|
56207
|
+
def.variables[key]
|
|
56208
|
+
);
|
|
56209
|
+
normalizedValues.push(nestedNormalized);
|
|
56210
|
+
lookup = {
|
|
56211
|
+
...lookup,
|
|
56212
|
+
...nestedLookup
|
|
56213
|
+
};
|
|
56214
|
+
} else {
|
|
56215
|
+
const varDef = def.variables[key];
|
|
56216
|
+
const identifier = getIdentifier(varDef);
|
|
56217
|
+
lookup[identifier] = val;
|
|
56218
|
+
normalizedValues.push({ __ref: identifier });
|
|
56219
|
+
}
|
|
56220
|
+
}
|
|
56221
|
+
return {
|
|
56222
|
+
data: {
|
|
56223
|
+
...resolved,
|
|
56224
|
+
values: normalizedValues
|
|
56225
|
+
},
|
|
56226
|
+
lookup
|
|
56227
|
+
};
|
|
56228
|
+
}
|
|
56229
|
+
function normalizeRequest(values, kwargsDefinition) {
|
|
56230
|
+
const data = Array.isArray(values) ? [] : {};
|
|
56231
|
+
let lookup = {};
|
|
56232
|
+
for (const [key, val] of getEntries(values)) {
|
|
56233
|
+
const kwargDef = kwargsDefinition[key];
|
|
56234
|
+
if (!kwargDef) {
|
|
56235
|
+
data[key] = val;
|
|
56236
|
+
} else if (isDerivedVariable(kwargDef) || isDerivedDataVariable(kwargDef)) {
|
|
56237
|
+
const { data: nestedData, lookup: nestedLookup } = normalizeResolvedDerivedVariable(val, kwargDef);
|
|
56238
|
+
data[key] = nestedData;
|
|
56239
|
+
lookup = {
|
|
56240
|
+
...lookup,
|
|
56241
|
+
...nestedLookup
|
|
56242
|
+
};
|
|
56243
|
+
} else if (kwargDef.constructor === Object) {
|
|
56244
|
+
const identifier = getIdentifier(kwargDef);
|
|
56245
|
+
lookup[identifier] = val === void 0 ? null : val;
|
|
56246
|
+
data[key] = { __ref: identifier };
|
|
56247
|
+
} else {
|
|
56248
|
+
data[key] = val;
|
|
56249
|
+
}
|
|
56250
|
+
}
|
|
56251
|
+
return {
|
|
56252
|
+
data,
|
|
56253
|
+
lookup
|
|
56254
|
+
};
|
|
56255
|
+
}
|
|
56256
|
+
function useActions() {
|
|
56257
|
+
const extras = useRequestExtras();
|
|
56258
|
+
return reactQuery.useQuery({
|
|
56259
|
+
queryFn: async () => {
|
|
56260
|
+
const res = await request("/api/core/actions", { method: HTTP_METHOD.GET }, extras);
|
|
56261
|
+
await handleAuthErrors(res, true);
|
|
56262
|
+
await validateResponse(res, "Failed to fetch the actions for this app");
|
|
56263
|
+
return res.json();
|
|
56264
|
+
},
|
|
56265
|
+
queryKey: ["actions"],
|
|
56266
|
+
refetchOnMount: false
|
|
56267
|
+
});
|
|
56268
|
+
}
|
|
56269
|
+
function useConfig() {
|
|
56270
|
+
const extras = useRequestExtras();
|
|
56271
|
+
return reactQuery.useQuery({
|
|
56272
|
+
queryFn: async () => {
|
|
56273
|
+
const res = await request("/api/core/config", { method: HTTP_METHOD.GET }, extras);
|
|
56274
|
+
await handleAuthErrors(res, true);
|
|
56275
|
+
await validateResponse(res, "Failed to fetch the config for this app");
|
|
56276
|
+
return res.json();
|
|
56277
|
+
},
|
|
56278
|
+
queryKey: ["config"],
|
|
56279
|
+
refetchOnMount: false
|
|
56280
|
+
});
|
|
56281
|
+
}
|
|
56282
|
+
function useComponents() {
|
|
56283
|
+
const extras = useRequestExtras();
|
|
56284
|
+
return reactQuery.useQuery({
|
|
56285
|
+
queryFn: async () => {
|
|
56286
|
+
const res = await request("/api/core/components", { method: HTTP_METHOD.GET }, extras);
|
|
56287
|
+
await handleAuthErrors(res, true);
|
|
56288
|
+
await validateResponse(res, "Failed to fetch the config for this app");
|
|
56289
|
+
return res.json();
|
|
56290
|
+
},
|
|
56291
|
+
queryKey: ["components"],
|
|
56292
|
+
refetchOnMount: false
|
|
56293
|
+
});
|
|
56294
|
+
}
|
|
56295
|
+
function useTemplate(template) {
|
|
56296
|
+
const extras = useRequestExtras();
|
|
56297
|
+
return reactQuery.useQuery({
|
|
56298
|
+
enabled: !!template,
|
|
56299
|
+
queryFn: async () => {
|
|
56300
|
+
const res = await request(`/api/core/template/${template}`, { method: HTTP_METHOD.GET }, extras);
|
|
56301
|
+
await handleAuthErrors(res, true);
|
|
56302
|
+
await validateResponse(res, "Failed to fetch the template");
|
|
56303
|
+
const { data: normalizedTemplate, lookup } = await res.json();
|
|
56304
|
+
return denormalize(normalizedTemplate, lookup);
|
|
56305
|
+
},
|
|
56306
|
+
queryKey: ["template", template],
|
|
56307
|
+
refetchOnWindowFocus: false,
|
|
56308
|
+
staleTime: Infinity
|
|
56309
|
+
});
|
|
56310
|
+
}
|
|
56311
|
+
async function fetchTaskResult(taskId, extras) {
|
|
56312
|
+
const res = await request(`/api/core/tasks/${taskId}`, { method: HTTP_METHOD.GET }, extras);
|
|
56313
|
+
await handleAuthErrors(res, true);
|
|
56314
|
+
await validateResponse(res, `Failed to fetch the result of task with id: ${taskId}`);
|
|
56315
|
+
const resJson = await res.json();
|
|
56316
|
+
if (typeof resJson === "object" && "error" in resJson) {
|
|
56317
|
+
throw new Error(resJson.error);
|
|
56318
|
+
}
|
|
56319
|
+
return resJson;
|
|
56320
|
+
}
|
|
56321
|
+
async function cancelTask(taskId, extras) {
|
|
56322
|
+
const res = await request(`/api/core/tasks/${taskId}`, { method: HTTP_METHOD.DELETE }, extras);
|
|
56323
|
+
await handleAuthErrors(res, true);
|
|
56324
|
+
await validateResponse(res, `Failed to cancel task with id: ${taskId}`);
|
|
56325
|
+
return true;
|
|
56326
|
+
}
|
|
56327
|
+
const directionCtx = React.createContext({ direction: "row" });
|
|
56328
|
+
const importersCtx = React.createContext({});
|
|
56001
56329
|
const dataRegistry = /* @__PURE__ */ new Map();
|
|
56002
56330
|
const atomRegistry = /* @__PURE__ */ new Map();
|
|
56003
56331
|
const atomFamilyRegistry = /* @__PURE__ */ new Map();
|
|
@@ -56036,40 +56364,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
56036
56364
|
return false;
|
|
56037
56365
|
}
|
|
56038
56366
|
}
|
|
56039
|
-
const requestExtrasCtx = React.createContext({ options: {} });
|
|
56040
|
-
function useRequestExtras() {
|
|
56041
|
-
const { options } = React.useContext(requestExtrasCtx);
|
|
56042
|
-
const extras = React.useMemo(() => {
|
|
56043
|
-
return options;
|
|
56044
|
-
}, [useDeepCompare(options)]);
|
|
56045
|
-
return extras;
|
|
56046
|
-
}
|
|
56047
|
-
function RequestExtrasProvider({
|
|
56048
|
-
children,
|
|
56049
|
-
options
|
|
56050
|
-
}) {
|
|
56051
|
-
return /* @__PURE__ */ React__default.default.createElement(requestExtrasCtx.Provider, { value: { options } }, children);
|
|
56052
|
-
}
|
|
56053
|
-
function mergeRequestInits(a2, b2) {
|
|
56054
|
-
const mergedHeaders = new Headers(a2.headers);
|
|
56055
|
-
const bHeaders = new Headers(b2.headers);
|
|
56056
|
-
bHeaders.forEach((value, key) => {
|
|
56057
|
-
mergedHeaders.set(key, value);
|
|
56058
|
-
});
|
|
56059
|
-
return {
|
|
56060
|
-
...a2,
|
|
56061
|
-
...b2,
|
|
56062
|
-
headers: mergedHeaders
|
|
56063
|
-
};
|
|
56064
|
-
}
|
|
56065
|
-
function PartialRequestExtrasProvider({
|
|
56066
|
-
children,
|
|
56067
|
-
options
|
|
56068
|
-
}) {
|
|
56069
|
-
const { options: parentOptions } = React.useContext(requestExtrasCtx);
|
|
56070
|
-
const mergedInits = React.useMemo(() => mergeRequestInits(parentOptions, options), [parentOptions, options]);
|
|
56071
|
-
return /* @__PURE__ */ React__default.default.createElement(requestExtrasCtx.Provider, { value: { options: mergedInits } }, children);
|
|
56072
|
-
}
|
|
56073
56367
|
const GlobalTaskCtx = React__namespace.createContext(null);
|
|
56074
56368
|
function GlobalTaskProvider({ tasks, variableTaskMap, children }) {
|
|
56075
56369
|
const tasksRef = React__namespace.useRef(tasks != null ? tasks : /* @__PURE__ */ new Set());
|
|
@@ -56136,529 +56430,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
56136
56430
|
});
|
|
56137
56431
|
const displayCtx = React.createContext({ component: null, direction: "horizontal" });
|
|
56138
56432
|
const fallbackCtx = React__namespace.createContext(null);
|
|
56139
|
-
var AuthenticationErrorReason = /* @__PURE__ */ ((AuthenticationErrorReason2) => {
|
|
56140
|
-
AuthenticationErrorReason2["BAD_REQUEST"] = "bad_request";
|
|
56141
|
-
AuthenticationErrorReason2["EXPIRED_TOKEN"] = "expired";
|
|
56142
|
-
AuthenticationErrorReason2["INVALID_CREDENTIALS"] = "invalid_credentials";
|
|
56143
|
-
AuthenticationErrorReason2["INVALID_TOKEN"] = "invalid_token";
|
|
56144
|
-
AuthenticationErrorReason2["OTHER"] = "other";
|
|
56145
|
-
AuthenticationErrorReason2["UNAUTHORIZED"] = "unauthorized";
|
|
56146
|
-
return AuthenticationErrorReason2;
|
|
56147
|
-
})(AuthenticationErrorReason || {});
|
|
56148
|
-
function isAuthenticationError(message) {
|
|
56149
|
-
return message !== null && message !== void 0 && typeof message === "object" && "reason" in message && Object.values(AuthenticationErrorReason).includes(message.reason);
|
|
56150
|
-
}
|
|
56151
|
-
function shouldIgnoreError(message, ignoreErrors) {
|
|
56152
|
-
return ignoreErrors && ignoreErrors.includes(message.reason);
|
|
56153
|
-
}
|
|
56154
|
-
function shouldRedirectToLogin(message) {
|
|
56155
|
-
return ["invalid_credentials", "expired"].includes(
|
|
56156
|
-
message.reason
|
|
56157
|
-
);
|
|
56158
|
-
}
|
|
56159
|
-
function useAuthConfig() {
|
|
56160
|
-
return reactQuery.useQuery(
|
|
56161
|
-
["auth-config"],
|
|
56162
|
-
async () => {
|
|
56163
|
-
const response = await request("/api/core/auth-config", {
|
|
56164
|
-
method: HTTP_METHOD.GET
|
|
56165
|
-
});
|
|
56166
|
-
return response.json();
|
|
56167
|
-
},
|
|
56168
|
-
{ refetchOnWindowFocus: false }
|
|
56169
|
-
);
|
|
56170
|
-
}
|
|
56171
|
-
async function revokeSession() {
|
|
56172
|
-
try {
|
|
56173
|
-
const response = await request("/api/auth/revoke-session", {
|
|
56174
|
-
method: HTTP_METHOD.POST
|
|
56175
|
-
});
|
|
56176
|
-
if (response.ok) {
|
|
56177
|
-
const responseData = await response.json();
|
|
56178
|
-
return responseData;
|
|
56179
|
-
}
|
|
56180
|
-
} catch (e3) {
|
|
56181
|
-
console.error("Failed to revoke session", e3);
|
|
56182
|
-
}
|
|
56183
|
-
}
|
|
56184
|
-
async function handleAuthErrors(res, toLogin = false, ignoreErrors = null) {
|
|
56185
|
-
var _a;
|
|
56186
|
-
const content = await res.clone().json();
|
|
56187
|
-
if (isAuthenticationError(content == null ? void 0 : content.detail) && !shouldIgnoreError(content == null ? void 0 : content.detail, ignoreErrors)) {
|
|
56188
|
-
localStorage.removeItem(getTokenKey());
|
|
56189
|
-
const queryParams = new URLSearchParams(window.location.search);
|
|
56190
|
-
const referrer = (_a = queryParams.get("referrer")) != null ? _a : encodeURIComponent(window.location.pathname + window.location.search);
|
|
56191
|
-
const path = toLogin || shouldRedirectToLogin(content.detail) ? `/login?referrer=${referrer}` : `/error?code=${res.status}`;
|
|
56192
|
-
window.location.href = `${window.dara.base_url}${path}`;
|
|
56193
|
-
return true;
|
|
56194
|
-
}
|
|
56195
|
-
return false;
|
|
56196
|
-
}
|
|
56197
|
-
function useUser() {
|
|
56198
|
-
const extras = useRequestExtras();
|
|
56199
|
-
return reactQuery.useQuery({
|
|
56200
|
-
queryFn: async () => {
|
|
56201
|
-
const res = await request("/api/auth/user", { method: HTTP_METHOD.GET }, extras);
|
|
56202
|
-
await handleAuthErrors(res);
|
|
56203
|
-
await validateResponse(res, "Failed to fetch user for this app");
|
|
56204
|
-
return res.json();
|
|
56205
|
-
},
|
|
56206
|
-
queryKey: ["user"],
|
|
56207
|
-
refetchOnWindowFocus: false
|
|
56208
|
-
});
|
|
56209
|
-
}
|
|
56210
|
-
async function requestSessionToken(body = {}) {
|
|
56211
|
-
const res = await request("/api/auth/session", {
|
|
56212
|
-
body: JSON.stringify(body),
|
|
56213
|
-
method: HTTP_METHOD.POST
|
|
56214
|
-
});
|
|
56215
|
-
const loggedOut = await handleAuthErrors(res, false, ["invalid_credentials"]);
|
|
56216
|
-
if (loggedOut) {
|
|
56217
|
-
return null;
|
|
56218
|
-
}
|
|
56219
|
-
await validateResponse(res, "Failed to fetch the session token");
|
|
56220
|
-
const parsedResponse = await res.json();
|
|
56221
|
-
const { token } = parsedResponse;
|
|
56222
|
-
localStorage.setItem(getTokenKey(), token);
|
|
56223
|
-
return token;
|
|
56224
|
-
}
|
|
56225
|
-
async function verifySessionToken() {
|
|
56226
|
-
const res = await request("/api/auth/verify-session", {
|
|
56227
|
-
method: HTTP_METHOD.POST
|
|
56228
|
-
});
|
|
56229
|
-
return res.ok;
|
|
56230
|
-
}
|
|
56231
|
-
function isPlaceholder(value) {
|
|
56232
|
-
return typeof value === "object" && "__ref" in value;
|
|
56233
|
-
}
|
|
56234
|
-
function getIdentifier(variable) {
|
|
56235
|
-
let id = `${variable.__typename}:${variable.uid}`;
|
|
56236
|
-
if ("nested" in variable && variable.nested.length > 0) {
|
|
56237
|
-
id += `:${variable.nested.join(",")}`;
|
|
56238
|
-
}
|
|
56239
|
-
if ("filters" in variable) {
|
|
56240
|
-
id += `:${hashObject(variable.filters)}`;
|
|
56241
|
-
}
|
|
56242
|
-
return id;
|
|
56243
|
-
}
|
|
56244
|
-
function getEntries(obj) {
|
|
56245
|
-
if (Array.isArray(obj)) {
|
|
56246
|
-
return obj.entries();
|
|
56247
|
-
}
|
|
56248
|
-
return Object.entries(obj);
|
|
56249
|
-
}
|
|
56250
|
-
function denormalize(obj, lookup) {
|
|
56251
|
-
if (!obj) {
|
|
56252
|
-
return obj;
|
|
56253
|
-
}
|
|
56254
|
-
if (isPlaceholder(obj)) {
|
|
56255
|
-
const referrable = lookup[obj.__ref];
|
|
56256
|
-
return denormalize(referrable, lookup);
|
|
56257
|
-
}
|
|
56258
|
-
const output = Array.isArray(obj) ? [] : {};
|
|
56259
|
-
for (const [key, val] of getEntries(obj)) {
|
|
56260
|
-
if (val !== null && typeof val === "object") {
|
|
56261
|
-
output[key] = denormalize(val, lookup);
|
|
56262
|
-
} else {
|
|
56263
|
-
output[key] = val;
|
|
56264
|
-
}
|
|
56265
|
-
}
|
|
56266
|
-
return output;
|
|
56267
|
-
}
|
|
56268
|
-
function normalizeResolvedDerivedVariable(resolved, def) {
|
|
56269
|
-
const normalizedValues = [];
|
|
56270
|
-
let lookup = {};
|
|
56271
|
-
for (const [key, val] of resolved.values.entries()) {
|
|
56272
|
-
if (isResolvedDerivedVariable(val) || isResolvedDerivedDataVariable(val)) {
|
|
56273
|
-
const { data: nestedNormalized, lookup: nestedLookup } = normalizeResolvedDerivedVariable(
|
|
56274
|
-
val,
|
|
56275
|
-
def.variables[key]
|
|
56276
|
-
);
|
|
56277
|
-
normalizedValues.push(nestedNormalized);
|
|
56278
|
-
lookup = {
|
|
56279
|
-
...lookup,
|
|
56280
|
-
...nestedLookup
|
|
56281
|
-
};
|
|
56282
|
-
} else {
|
|
56283
|
-
const varDef = def.variables[key];
|
|
56284
|
-
const identifier = getIdentifier(varDef);
|
|
56285
|
-
lookup[identifier] = val;
|
|
56286
|
-
normalizedValues.push({ __ref: identifier });
|
|
56287
|
-
}
|
|
56288
|
-
}
|
|
56289
|
-
return {
|
|
56290
|
-
data: {
|
|
56291
|
-
...resolved,
|
|
56292
|
-
values: normalizedValues
|
|
56293
|
-
},
|
|
56294
|
-
lookup
|
|
56295
|
-
};
|
|
56296
|
-
}
|
|
56297
|
-
function normalizeRequest(values, kwargsDefinition) {
|
|
56298
|
-
const data = Array.isArray(values) ? [] : {};
|
|
56299
|
-
let lookup = {};
|
|
56300
|
-
for (const [key, val] of getEntries(values)) {
|
|
56301
|
-
const kwargDef = kwargsDefinition[key];
|
|
56302
|
-
if (!kwargDef) {
|
|
56303
|
-
data[key] = val;
|
|
56304
|
-
} else if (isDerivedVariable(kwargDef) || isDerivedDataVariable(kwargDef)) {
|
|
56305
|
-
const { data: nestedData, lookup: nestedLookup } = normalizeResolvedDerivedVariable(val, kwargDef);
|
|
56306
|
-
data[key] = nestedData;
|
|
56307
|
-
lookup = {
|
|
56308
|
-
...lookup,
|
|
56309
|
-
...nestedLookup
|
|
56310
|
-
};
|
|
56311
|
-
} else if (kwargDef.constructor === Object) {
|
|
56312
|
-
const identifier = getIdentifier(kwargDef);
|
|
56313
|
-
lookup[identifier] = val === void 0 ? null : val;
|
|
56314
|
-
data[key] = { __ref: identifier };
|
|
56315
|
-
} else {
|
|
56316
|
-
data[key] = val;
|
|
56317
|
-
}
|
|
56318
|
-
}
|
|
56319
|
-
return {
|
|
56320
|
-
data,
|
|
56321
|
-
lookup
|
|
56322
|
-
};
|
|
56323
|
-
}
|
|
56324
|
-
function useActions() {
|
|
56325
|
-
const extras = useRequestExtras();
|
|
56326
|
-
return reactQuery.useQuery({
|
|
56327
|
-
queryFn: async () => {
|
|
56328
|
-
const res = await request("/api/core/actions", { method: HTTP_METHOD.GET }, extras);
|
|
56329
|
-
await handleAuthErrors(res, true);
|
|
56330
|
-
await validateResponse(res, "Failed to fetch the actions for this app");
|
|
56331
|
-
return res.json();
|
|
56332
|
-
},
|
|
56333
|
-
queryKey: ["actions"],
|
|
56334
|
-
refetchOnMount: false
|
|
56335
|
-
});
|
|
56336
|
-
}
|
|
56337
|
-
function useConfig() {
|
|
56338
|
-
const extras = useRequestExtras();
|
|
56339
|
-
return reactQuery.useQuery({
|
|
56340
|
-
queryFn: async () => {
|
|
56341
|
-
const res = await request("/api/core/config", { method: HTTP_METHOD.GET }, extras);
|
|
56342
|
-
await handleAuthErrors(res, true);
|
|
56343
|
-
await validateResponse(res, "Failed to fetch the config for this app");
|
|
56344
|
-
return res.json();
|
|
56345
|
-
},
|
|
56346
|
-
queryKey: ["config"],
|
|
56347
|
-
refetchOnMount: false
|
|
56348
|
-
});
|
|
56349
|
-
}
|
|
56350
|
-
function useComponents() {
|
|
56351
|
-
const extras = useRequestExtras();
|
|
56352
|
-
return reactQuery.useQuery({
|
|
56353
|
-
queryFn: async () => {
|
|
56354
|
-
const res = await request("/api/core/components", { method: HTTP_METHOD.GET }, extras);
|
|
56355
|
-
await handleAuthErrors(res, true);
|
|
56356
|
-
await validateResponse(res, "Failed to fetch the config for this app");
|
|
56357
|
-
return res.json();
|
|
56358
|
-
},
|
|
56359
|
-
queryKey: ["components"],
|
|
56360
|
-
refetchOnMount: false
|
|
56361
|
-
});
|
|
56362
|
-
}
|
|
56363
|
-
function useTemplate(template) {
|
|
56364
|
-
const extras = useRequestExtras();
|
|
56365
|
-
return reactQuery.useQuery({
|
|
56366
|
-
enabled: !!template,
|
|
56367
|
-
queryFn: async () => {
|
|
56368
|
-
const res = await request(`/api/core/template/${template}`, { method: HTTP_METHOD.GET }, extras);
|
|
56369
|
-
await handleAuthErrors(res, true);
|
|
56370
|
-
await validateResponse(res, "Failed to fetch the template");
|
|
56371
|
-
const { data: normalizedTemplate, lookup } = await res.json();
|
|
56372
|
-
return denormalize(normalizedTemplate, lookup);
|
|
56373
|
-
},
|
|
56374
|
-
queryKey: ["template", template],
|
|
56375
|
-
refetchOnWindowFocus: false,
|
|
56376
|
-
staleTime: Infinity
|
|
56377
|
-
});
|
|
56378
|
-
}
|
|
56379
|
-
async function fetchTaskResult(taskId, extras) {
|
|
56380
|
-
const res = await request(`/api/core/tasks/${taskId}`, { method: HTTP_METHOD.GET }, extras);
|
|
56381
|
-
await handleAuthErrors(res, true);
|
|
56382
|
-
await validateResponse(res, `Failed to fetch the result of task with id: ${taskId}`);
|
|
56383
|
-
const resJson = await res.json();
|
|
56384
|
-
if (typeof resJson === "object" && "error" in resJson) {
|
|
56385
|
-
throw new Error(resJson.error);
|
|
56386
|
-
}
|
|
56387
|
-
return resJson;
|
|
56388
|
-
}
|
|
56389
|
-
async function cancelTask(taskId, extras) {
|
|
56390
|
-
const res = await request(`/api/core/tasks/${taskId}`, { method: HTTP_METHOD.DELETE }, extras);
|
|
56391
|
-
await handleAuthErrors(res, true);
|
|
56392
|
-
await validateResponse(res, `Failed to cancel task with id: ${taskId}`);
|
|
56393
|
-
return true;
|
|
56394
|
-
}
|
|
56395
|
-
const interAttemptTimeout = 500;
|
|
56396
|
-
const maxDisconnectedTime = 1e4;
|
|
56397
|
-
const interPingInterval = 5e3;
|
|
56398
|
-
const maxAttempts = Math.round(maxDisconnectedTime / interAttemptTimeout);
|
|
56399
|
-
function isInitMessage(message) {
|
|
56400
|
-
return message.type === "init";
|
|
56401
|
-
}
|
|
56402
|
-
function isTaskNotification(message) {
|
|
56403
|
-
return message.type === "message" && "status" in message.message && "task_id" in message.message;
|
|
56404
|
-
}
|
|
56405
|
-
function isServerTriggerMessage(message) {
|
|
56406
|
-
return message.type === "message" && "data_id" in message.message;
|
|
56407
|
-
}
|
|
56408
|
-
function isServerErrorMessage(message) {
|
|
56409
|
-
return message.type === "message" && "error" in message.message;
|
|
56410
|
-
}
|
|
56411
|
-
function isVariableRequestMessage(message) {
|
|
56412
|
-
return message.type === "message" && "variable" in message.message;
|
|
56413
|
-
}
|
|
56414
|
-
function isActionMessage(message) {
|
|
56415
|
-
return message.type === "message" && "action" in message.message;
|
|
56416
|
-
}
|
|
56417
|
-
function isBackendStoreMessage(message) {
|
|
56418
|
-
return message.type === "message" && "store_uid" in message.message;
|
|
56419
|
-
}
|
|
56420
|
-
function isCustomMessage(message) {
|
|
56421
|
-
return message.type === "custom";
|
|
56422
|
-
}
|
|
56423
|
-
const pingMessage = {
|
|
56424
|
-
message: null,
|
|
56425
|
-
type: "ping"
|
|
56426
|
-
};
|
|
56427
|
-
class WebSocketClient {
|
|
56428
|
-
constructor(_socketUrl2, _token, _liveReload = false) {
|
|
56429
|
-
__publicField(this, "channel");
|
|
56430
|
-
__publicField(this, "messages$");
|
|
56431
|
-
__publicField(this, "socket");
|
|
56432
|
-
__publicField(this, "token");
|
|
56433
|
-
__publicField(this, "liveReload");
|
|
56434
|
-
__publicField(this, "closeHandler");
|
|
56435
|
-
__publicField(this, "maxAttempts");
|
|
56436
|
-
__privateAdd(this, _pingInterval, void 0);
|
|
56437
|
-
__privateAdd(this, _socketUrl, void 0);
|
|
56438
|
-
__privateAdd(this, _reconnectCount, void 0);
|
|
56439
|
-
this.token = _token;
|
|
56440
|
-
this.liveReload = _liveReload;
|
|
56441
|
-
this.messages$ = new Subject();
|
|
56442
|
-
this.closeHandler = this.onClose.bind(this);
|
|
56443
|
-
this.maxAttempts = maxAttempts;
|
|
56444
|
-
__privateSet(this, _socketUrl, _socketUrl2);
|
|
56445
|
-
__privateSet(this, _reconnectCount, 0);
|
|
56446
|
-
__privateSet(this, _pingInterval, null);
|
|
56447
|
-
this.socket = this.initialize();
|
|
56448
|
-
}
|
|
56449
|
-
initialize(isReconnect = false) {
|
|
56450
|
-
const url = new URL(__privateGet(this, _socketUrl));
|
|
56451
|
-
this.token = store.getValueSync(getTokenKey());
|
|
56452
|
-
url.searchParams.set("token", this.token);
|
|
56453
|
-
const socket = new WebSocket(url);
|
|
56454
|
-
__privateSet(this, _pingInterval, setInterval(() => {
|
|
56455
|
-
if (socket.readyState === WebSocket.OPEN) {
|
|
56456
|
-
socket.send(JSON.stringify(pingMessage));
|
|
56457
|
-
}
|
|
56458
|
-
}, interPingInterval));
|
|
56459
|
-
socket.addEventListener("error", () => {
|
|
56460
|
-
if (__privateGet(this, _pingInterval)) {
|
|
56461
|
-
clearInterval(__privateGet(this, _pingInterval));
|
|
56462
|
-
}
|
|
56463
|
-
});
|
|
56464
|
-
socket.addEventListener("message", (ev) => {
|
|
56465
|
-
const msg = JSON.parse(ev.data);
|
|
56466
|
-
this.messages$.next(msg);
|
|
56467
|
-
});
|
|
56468
|
-
this.channel = new Promise((resolve) => {
|
|
56469
|
-
const handler = (ev) => {
|
|
56470
|
-
var _a;
|
|
56471
|
-
const msg = JSON.parse(ev.data);
|
|
56472
|
-
if (msg.type === "init") {
|
|
56473
|
-
__privateSet(this, _reconnectCount, 0);
|
|
56474
|
-
this.messages$.next(msg);
|
|
56475
|
-
socket.removeEventListener("message", handler);
|
|
56476
|
-
resolve((_a = msg.message) == null ? void 0 : _a.channel);
|
|
56477
|
-
if (this.liveReload && isReconnect) {
|
|
56478
|
-
window.location.reload();
|
|
56479
|
-
}
|
|
56480
|
-
}
|
|
56481
|
-
};
|
|
56482
|
-
socket.addEventListener("message", handler);
|
|
56483
|
-
});
|
|
56484
|
-
socket.addEventListener("close", this.closeHandler);
|
|
56485
|
-
return socket;
|
|
56486
|
-
}
|
|
56487
|
-
onClose() {
|
|
56488
|
-
if (__privateGet(this, _reconnectCount) >= this.maxAttempts) {
|
|
56489
|
-
console.error("Could not reconnect the websocket to the server");
|
|
56490
|
-
const handler = () => {
|
|
56491
|
-
if (document.visibilityState === "visible") {
|
|
56492
|
-
__privateSet(this, _reconnectCount, 0);
|
|
56493
|
-
this.socket = this.initialize();
|
|
56494
|
-
document.removeEventListener("visibilitychange", handler);
|
|
56495
|
-
}
|
|
56496
|
-
};
|
|
56497
|
-
document.addEventListener("visibilitychange", handler);
|
|
56498
|
-
return;
|
|
56499
|
-
}
|
|
56500
|
-
setTimeout(() => {
|
|
56501
|
-
__privateWrapper(this, _reconnectCount)._++;
|
|
56502
|
-
this.socket = this.initialize(true);
|
|
56503
|
-
}, interAttemptTimeout);
|
|
56504
|
-
}
|
|
56505
|
-
close() {
|
|
56506
|
-
clearInterval(__privateGet(this, _pingInterval));
|
|
56507
|
-
this.socket.removeEventListener("close", this.closeHandler);
|
|
56508
|
-
this.socket.close();
|
|
56509
|
-
}
|
|
56510
|
-
getChannel() {
|
|
56511
|
-
return this.channel;
|
|
56512
|
-
}
|
|
56513
|
-
backendStoreMessages$() {
|
|
56514
|
-
return this.messages$.pipe(
|
|
56515
|
-
filter(isBackendStoreMessage),
|
|
56516
|
-
map$2((msg) => msg.message)
|
|
56517
|
-
);
|
|
56518
|
-
}
|
|
56519
|
-
channel$() {
|
|
56520
|
-
return this.messages$.pipe(
|
|
56521
|
-
filter((msg) => isInitMessage(msg)),
|
|
56522
|
-
map$2((msg) => msg.message.channel)
|
|
56523
|
-
);
|
|
56524
|
-
}
|
|
56525
|
-
taskStatusUpdates$(...task_ids) {
|
|
56526
|
-
return this.messages$.pipe(
|
|
56527
|
-
filter((msg) => isTaskNotification(msg) && task_ids.includes(msg.message.task_id)),
|
|
56528
|
-
map$2((msg) => msg.message.status)
|
|
56529
|
-
);
|
|
56530
|
-
}
|
|
56531
|
-
progressUpdates$(...task_ids) {
|
|
56532
|
-
return this.messages$.pipe(
|
|
56533
|
-
filter(
|
|
56534
|
-
(msg) => isTaskNotification(msg) && msg.message.status === "PROGRESS" && task_ids.includes(msg.message.task_id)
|
|
56535
|
-
)
|
|
56536
|
-
);
|
|
56537
|
-
}
|
|
56538
|
-
serverTriggers$(dataId) {
|
|
56539
|
-
return this.messages$.pipe(
|
|
56540
|
-
filter(isServerTriggerMessage),
|
|
56541
|
-
filter((msg) => {
|
|
56542
|
-
var _a;
|
|
56543
|
-
return ((_a = msg.message) == null ? void 0 : _a.data_id) === dataId;
|
|
56544
|
-
})
|
|
56545
|
-
);
|
|
56546
|
-
}
|
|
56547
|
-
serverErrors$() {
|
|
56548
|
-
return this.messages$.pipe(filter(isServerErrorMessage));
|
|
56549
|
-
}
|
|
56550
|
-
variableRequests$() {
|
|
56551
|
-
return this.messages$.pipe(filter(isVariableRequestMessage));
|
|
56552
|
-
}
|
|
56553
|
-
actionMessages$(executionId) {
|
|
56554
|
-
return this.messages$.pipe(
|
|
56555
|
-
filter((msg) => isActionMessage(msg) && msg.message.uid === executionId),
|
|
56556
|
-
map$2((msg) => msg.message.action)
|
|
56557
|
-
);
|
|
56558
|
-
}
|
|
56559
|
-
customMessages$() {
|
|
56560
|
-
return this.messages$.pipe(filter(isCustomMessage));
|
|
56561
|
-
}
|
|
56562
|
-
waitForTask(task_id) {
|
|
56563
|
-
return this.messages$.pipe(
|
|
56564
|
-
filter(
|
|
56565
|
-
(msg) => {
|
|
56566
|
-
var _a;
|
|
56567
|
-
return isTaskNotification(msg) && ((_a = msg.message) == null ? void 0 : _a.task_id) === task_id && msg.message.status !== "PROGRESS";
|
|
56568
|
-
}
|
|
56569
|
-
),
|
|
56570
|
-
map$2((msg) => {
|
|
56571
|
-
if (isTaskNotification(msg) && msg.message.status === "CANCELED") {
|
|
56572
|
-
throw new Error("CANCELED");
|
|
56573
|
-
}
|
|
56574
|
-
return msg;
|
|
56575
|
-
}),
|
|
56576
|
-
take(1)
|
|
56577
|
-
).toPromise();
|
|
56578
|
-
}
|
|
56579
|
-
sendVariable(value, channel) {
|
|
56580
|
-
this.sendMessage(value, channel);
|
|
56581
|
-
}
|
|
56582
|
-
sendMessage(value, channel, chunkCount) {
|
|
56583
|
-
if (this.socket.readyState === WebSocket.OPEN) {
|
|
56584
|
-
this.socket.send(
|
|
56585
|
-
JSON.stringify({
|
|
56586
|
-
channel,
|
|
56587
|
-
chunk_count: chunkCount != null ? chunkCount : null,
|
|
56588
|
-
message: value,
|
|
56589
|
-
type: "message"
|
|
56590
|
-
})
|
|
56591
|
-
);
|
|
56592
|
-
}
|
|
56593
|
-
}
|
|
56594
|
-
updateToken(newToken) {
|
|
56595
|
-
this.token = newToken;
|
|
56596
|
-
if (this.socket.readyState === WebSocket.OPEN) {
|
|
56597
|
-
this.socket.send(
|
|
56598
|
-
JSON.stringify({
|
|
56599
|
-
message: newToken,
|
|
56600
|
-
type: "token_update"
|
|
56601
|
-
})
|
|
56602
|
-
);
|
|
56603
|
-
}
|
|
56604
|
-
}
|
|
56605
|
-
sendCustomMessage(kind, data, awaitResponse = false) {
|
|
56606
|
-
if (this.socket.readyState === WebSocket.OPEN) {
|
|
56607
|
-
if (awaitResponse) {
|
|
56608
|
-
const rchan = nanoid();
|
|
56609
|
-
return new Promise((resolve) => {
|
|
56610
|
-
const subscription = this.customMessages$().pipe().subscribe({
|
|
56611
|
-
next: (msg) => {
|
|
56612
|
-
if (msg.message.__response_for === rchan) {
|
|
56613
|
-
resolve(msg);
|
|
56614
|
-
subscription.unsubscribe();
|
|
56615
|
-
}
|
|
56616
|
-
}
|
|
56617
|
-
});
|
|
56618
|
-
this.socket.send(
|
|
56619
|
-
JSON.stringify({
|
|
56620
|
-
message: {
|
|
56621
|
-
data,
|
|
56622
|
-
kind,
|
|
56623
|
-
__rchan: rchan
|
|
56624
|
-
},
|
|
56625
|
-
type: "custom"
|
|
56626
|
-
})
|
|
56627
|
-
);
|
|
56628
|
-
});
|
|
56629
|
-
}
|
|
56630
|
-
this.socket.send(
|
|
56631
|
-
JSON.stringify({
|
|
56632
|
-
message: {
|
|
56633
|
-
data,
|
|
56634
|
-
kind
|
|
56635
|
-
},
|
|
56636
|
-
type: "custom"
|
|
56637
|
-
})
|
|
56638
|
-
);
|
|
56639
|
-
return Promise.resolve(null);
|
|
56640
|
-
}
|
|
56641
|
-
}
|
|
56642
|
-
}
|
|
56643
|
-
_pingInterval = new WeakMap();
|
|
56644
|
-
_socketUrl = new WeakMap();
|
|
56645
|
-
_reconnectCount = new WeakMap();
|
|
56646
|
-
function setupWebsocket(sessionToken, liveReload) {
|
|
56647
|
-
var _a;
|
|
56648
|
-
let { host } = window.location;
|
|
56649
|
-
if ((_a = window.dara) == null ? void 0 : _a.base_url) {
|
|
56650
|
-
const baseUrl = new URL(window.dara.base_url, window.origin);
|
|
56651
|
-
let { pathname } = baseUrl;
|
|
56652
|
-
if (pathname.endsWith("/")) {
|
|
56653
|
-
pathname = pathname.slice(0, -1);
|
|
56654
|
-
}
|
|
56655
|
-
host = baseUrl.host + pathname;
|
|
56656
|
-
}
|
|
56657
|
-
const socketUrl = `${window.location.protocol === "https:" ? "wss://" : "ws://"}${host}/api/core/ws`;
|
|
56658
|
-
const url = new URL(socketUrl);
|
|
56659
|
-
url.searchParams.set("token", sessionToken);
|
|
56660
|
-
return new WebSocketClient(socketUrl, sessionToken, liveReload);
|
|
56661
|
-
}
|
|
56662
56433
|
class EventBus {
|
|
56663
56434
|
constructor(parentBus) {
|
|
56664
56435
|
__privateAdd(this, _events$, new Subject());
|
|
@@ -56691,156 +56462,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
56691
56462
|
}, [bus, onEvent]);
|
|
56692
56463
|
return /* @__PURE__ */ React__namespace.createElement(EventBusContext.Provider, { value: bus }, children);
|
|
56693
56464
|
}
|
|
56694
|
-
const _StateSynchronizer = class {
|
|
56695
|
-
constructor() {
|
|
56696
|
-
__privateAdd(this, _observers, /* @__PURE__ */ new Map());
|
|
56697
|
-
}
|
|
56698
|
-
static getInstance() {
|
|
56699
|
-
if (!__privateGet(_StateSynchronizer, _instance)) {
|
|
56700
|
-
__privateSet(_StateSynchronizer, _instance, new _StateSynchronizer());
|
|
56701
|
-
}
|
|
56702
|
-
return __privateGet(_StateSynchronizer, _instance);
|
|
56703
|
-
}
|
|
56704
|
-
register(key, defaultValue) {
|
|
56705
|
-
if (!__privateGet(this, _observers).has(key)) {
|
|
56706
|
-
__privateGet(this, _observers).set(key, new BehaviorSubject({ type: "initial", value: defaultValue }));
|
|
56707
|
-
}
|
|
56708
|
-
}
|
|
56709
|
-
isRegistered(key) {
|
|
56710
|
-
return __privateGet(this, _observers).has(key);
|
|
56711
|
-
}
|
|
56712
|
-
getCurrentState(key) {
|
|
56713
|
-
if (!this.isRegistered(key)) {
|
|
56714
|
-
return null;
|
|
56715
|
-
}
|
|
56716
|
-
return __privateGet(this, _observers).get(key).getValue();
|
|
56717
|
-
}
|
|
56718
|
-
subscribe(key, subscription) {
|
|
56719
|
-
if (!this.isRegistered(key)) {
|
|
56720
|
-
this.register(key, null);
|
|
56721
|
-
}
|
|
56722
|
-
const sub = __privateGet(this, _observers).get(key).subscribe(subscription);
|
|
56723
|
-
return () => {
|
|
56724
|
-
sub.unsubscribe();
|
|
56725
|
-
if (__privateGet(this, _observers).get(key).observers.length === 0) {
|
|
56726
|
-
__privateGet(this, _observers).delete(key);
|
|
56727
|
-
}
|
|
56728
|
-
};
|
|
56729
|
-
}
|
|
56730
|
-
notify(key, update) {
|
|
56731
|
-
if (!this.isRegistered(key)) {
|
|
56732
|
-
this.register(key, null);
|
|
56733
|
-
}
|
|
56734
|
-
__privateGet(this, _observers).get(key).next(update);
|
|
56735
|
-
}
|
|
56736
|
-
};
|
|
56737
|
-
let StateSynchronizer = _StateSynchronizer;
|
|
56738
|
-
_instance = new WeakMap();
|
|
56739
|
-
_observers = new WeakMap();
|
|
56740
|
-
__privateAdd(StateSynchronizer, _instance, void 0);
|
|
56741
|
-
function getOrRegisterPlainVariable(variable, wsClient, taskContext, extras) {
|
|
56742
|
-
const isNested = variable.nested && variable.nested.length > 0;
|
|
56743
|
-
const isDefaultDerived = isDerivedVariable(variable.default);
|
|
56744
|
-
if (!atomFamilyRegistry.has(variable.uid)) {
|
|
56745
|
-
atomFamilyRegistry.set(
|
|
56746
|
-
variable.uid,
|
|
56747
|
-
Recoil_index_10({
|
|
56748
|
-
default: isDefaultDerived ? (extrasSerializable2) => getOrRegisterDerivedVariableValue(
|
|
56749
|
-
variable.default,
|
|
56750
|
-
wsClient,
|
|
56751
|
-
taskContext,
|
|
56752
|
-
extrasSerializable2.extras
|
|
56753
|
-
) : variable.default,
|
|
56754
|
-
effects: (extrasSerializable2) => {
|
|
56755
|
-
const familySync = ({ onSet, setSelf, resetSelf, node }) => {
|
|
56756
|
-
if (!StateSynchronizer.getInstance().isRegistered(variable.uid)) {
|
|
56757
|
-
StateSynchronizer.getInstance().register(variable.uid, variable.default);
|
|
56758
|
-
} else {
|
|
56759
|
-
const currentState = StateSynchronizer.getInstance().getCurrentState(variable.uid);
|
|
56760
|
-
if (!isDefaultDerived || (currentState == null ? void 0 : currentState.type) !== "initial") {
|
|
56761
|
-
setSelf(currentState == null ? void 0 : currentState.value);
|
|
56762
|
-
}
|
|
56763
|
-
}
|
|
56764
|
-
const unsub = StateSynchronizer.getInstance().subscribe(variable.uid, (update) => {
|
|
56765
|
-
if (update.type === "initial") {
|
|
56766
|
-
return;
|
|
56767
|
-
}
|
|
56768
|
-
if (update.nodeKey === node.key) {
|
|
56769
|
-
return;
|
|
56770
|
-
}
|
|
56771
|
-
if (update.isReset) {
|
|
56772
|
-
resetSelf();
|
|
56773
|
-
} else {
|
|
56774
|
-
setSelf(update.value);
|
|
56775
|
-
}
|
|
56776
|
-
});
|
|
56777
|
-
onSet((newValue, oldValue, isReset) => {
|
|
56778
|
-
StateSynchronizer.getInstance().notify(variable.uid, {
|
|
56779
|
-
isReset,
|
|
56780
|
-
nodeKey: node.key,
|
|
56781
|
-
oldValue,
|
|
56782
|
-
type: "update",
|
|
56783
|
-
value: newValue
|
|
56784
|
-
});
|
|
56785
|
-
});
|
|
56786
|
-
return unsub;
|
|
56787
|
-
};
|
|
56788
|
-
const effects = [familySync];
|
|
56789
|
-
const storeEffect = getEffect(variable);
|
|
56790
|
-
if (storeEffect) {
|
|
56791
|
-
effects.push(storeEffect(variable, extrasSerializable2, wsClient, taskContext));
|
|
56792
|
-
} else {
|
|
56793
|
-
if (variable.persist_value || isEmbedded()) {
|
|
56794
|
-
effects.push(
|
|
56795
|
-
STORES.BrowserStore.effect(variable, extrasSerializable2, wsClient, taskContext)
|
|
56796
|
-
);
|
|
56797
|
-
}
|
|
56798
|
-
}
|
|
56799
|
-
return effects;
|
|
56800
|
-
},
|
|
56801
|
-
key: variable.uid
|
|
56802
|
-
})
|
|
56803
|
-
);
|
|
56804
|
-
}
|
|
56805
|
-
const family = atomFamilyRegistry.get(variable.uid);
|
|
56806
|
-
const extrasSerializable = new RequestExtrasSerializable(extras);
|
|
56807
|
-
const atomInstance = family(extrasSerializable);
|
|
56808
|
-
if (!atomFamilyMembersRegistry.has(family)) {
|
|
56809
|
-
atomFamilyMembersRegistry.set(family, /* @__PURE__ */ new Map());
|
|
56810
|
-
}
|
|
56811
|
-
atomFamilyMembersRegistry.get(family).set(extrasSerializable.toJSON(), atomInstance);
|
|
56812
|
-
if (isNested) {
|
|
56813
|
-
const key = getRegistryKey(variable, "selector");
|
|
56814
|
-
if (!selectorFamilyRegistry.has(key)) {
|
|
56815
|
-
selectorFamilyRegistry.set(
|
|
56816
|
-
key,
|
|
56817
|
-
Recoil_index_11({
|
|
56818
|
-
get: (currentExtras) => ({ get: get2 }) => {
|
|
56819
|
-
const variableValue = get2(family(currentExtras));
|
|
56820
|
-
return resolveNested(
|
|
56821
|
-
variableValue,
|
|
56822
|
-
variable.nested.map((n2) => String(n2))
|
|
56823
|
-
);
|
|
56824
|
-
},
|
|
56825
|
-
key,
|
|
56826
|
-
set: (currentExtras) => ({ set: set2 }, newValue) => {
|
|
56827
|
-
set2(
|
|
56828
|
-
family(currentExtras),
|
|
56829
|
-
(v2) => setNested(
|
|
56830
|
-
v2,
|
|
56831
|
-
variable.nested.map((n2) => String(n2)),
|
|
56832
|
-
newValue
|
|
56833
|
-
)
|
|
56834
|
-
);
|
|
56835
|
-
}
|
|
56836
|
-
})
|
|
56837
|
-
);
|
|
56838
|
-
}
|
|
56839
|
-
const selectorFamilyInstance = selectorFamilyRegistry.get(key);
|
|
56840
|
-
return selectorFamilyInstance(extrasSerializable);
|
|
56841
|
-
}
|
|
56842
|
-
return atomInstance;
|
|
56843
|
-
}
|
|
56844
56465
|
function err(message) {
|
|
56845
56466
|
const error = new Error(message);
|
|
56846
56467
|
if (error.stack === void 0) {
|
|
@@ -57520,6 +57141,273 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
57520
57141
|
function useUrlVariable(variable) {
|
|
57521
57142
|
return Recoil_index_22(getOrRegisterUrlVariable(variable));
|
|
57522
57143
|
}
|
|
57144
|
+
const interAttemptTimeout = 500;
|
|
57145
|
+
const maxDisconnectedTime = 1e4;
|
|
57146
|
+
const interPingInterval = 5e3;
|
|
57147
|
+
const maxAttempts = Math.round(maxDisconnectedTime / interAttemptTimeout);
|
|
57148
|
+
function isInitMessage(message) {
|
|
57149
|
+
return message.type === "init";
|
|
57150
|
+
}
|
|
57151
|
+
function isTaskNotification(message) {
|
|
57152
|
+
return message.type === "message" && "status" in message.message && "task_id" in message.message;
|
|
57153
|
+
}
|
|
57154
|
+
function isServerTriggerMessage(message) {
|
|
57155
|
+
return message.type === "message" && "data_id" in message.message;
|
|
57156
|
+
}
|
|
57157
|
+
function isServerErrorMessage(message) {
|
|
57158
|
+
return message.type === "message" && "error" in message.message;
|
|
57159
|
+
}
|
|
57160
|
+
function isVariableRequestMessage(message) {
|
|
57161
|
+
return message.type === "message" && "variable" in message.message;
|
|
57162
|
+
}
|
|
57163
|
+
function isActionMessage(message) {
|
|
57164
|
+
return message.type === "message" && "action" in message.message;
|
|
57165
|
+
}
|
|
57166
|
+
function isBackendStoreMessage(message) {
|
|
57167
|
+
return message.type === "message" && "store_uid" in message.message;
|
|
57168
|
+
}
|
|
57169
|
+
function isCustomMessage(message) {
|
|
57170
|
+
return message.type === "custom";
|
|
57171
|
+
}
|
|
57172
|
+
const pingMessage = {
|
|
57173
|
+
message: null,
|
|
57174
|
+
type: "ping"
|
|
57175
|
+
};
|
|
57176
|
+
class WebSocketClient {
|
|
57177
|
+
constructor(_socketUrl2, _token, _liveReload = false) {
|
|
57178
|
+
__publicField(this, "channel");
|
|
57179
|
+
__publicField(this, "messages$");
|
|
57180
|
+
__publicField(this, "socket");
|
|
57181
|
+
__publicField(this, "token");
|
|
57182
|
+
__publicField(this, "liveReload");
|
|
57183
|
+
__publicField(this, "closeHandler");
|
|
57184
|
+
__publicField(this, "maxAttempts");
|
|
57185
|
+
__privateAdd(this, _pingInterval, void 0);
|
|
57186
|
+
__privateAdd(this, _socketUrl, void 0);
|
|
57187
|
+
__privateAdd(this, _reconnectCount, void 0);
|
|
57188
|
+
this.token = _token;
|
|
57189
|
+
this.liveReload = _liveReload;
|
|
57190
|
+
this.messages$ = new Subject();
|
|
57191
|
+
this.closeHandler = this.onClose.bind(this);
|
|
57192
|
+
this.maxAttempts = maxAttempts;
|
|
57193
|
+
__privateSet(this, _socketUrl, _socketUrl2);
|
|
57194
|
+
__privateSet(this, _reconnectCount, 0);
|
|
57195
|
+
__privateSet(this, _pingInterval, null);
|
|
57196
|
+
this.socket = this.initialize();
|
|
57197
|
+
}
|
|
57198
|
+
initialize(isReconnect = false) {
|
|
57199
|
+
const url = new URL(__privateGet(this, _socketUrl));
|
|
57200
|
+
this.token = store.getValueSync(getTokenKey());
|
|
57201
|
+
url.searchParams.set("token", this.token);
|
|
57202
|
+
const socket = new WebSocket(url);
|
|
57203
|
+
__privateSet(this, _pingInterval, setInterval(() => {
|
|
57204
|
+
if (socket.readyState === WebSocket.OPEN) {
|
|
57205
|
+
socket.send(JSON.stringify(pingMessage));
|
|
57206
|
+
}
|
|
57207
|
+
}, interPingInterval));
|
|
57208
|
+
socket.addEventListener("error", () => {
|
|
57209
|
+
if (__privateGet(this, _pingInterval)) {
|
|
57210
|
+
clearInterval(__privateGet(this, _pingInterval));
|
|
57211
|
+
}
|
|
57212
|
+
});
|
|
57213
|
+
socket.addEventListener("message", (ev) => {
|
|
57214
|
+
const msg = JSON.parse(ev.data);
|
|
57215
|
+
this.messages$.next(msg);
|
|
57216
|
+
});
|
|
57217
|
+
this.channel = new Promise((resolve) => {
|
|
57218
|
+
const handler = (ev) => {
|
|
57219
|
+
var _a;
|
|
57220
|
+
const msg = JSON.parse(ev.data);
|
|
57221
|
+
if (msg.type === "init") {
|
|
57222
|
+
__privateSet(this, _reconnectCount, 0);
|
|
57223
|
+
this.messages$.next(msg);
|
|
57224
|
+
socket.removeEventListener("message", handler);
|
|
57225
|
+
resolve((_a = msg.message) == null ? void 0 : _a.channel);
|
|
57226
|
+
if (this.liveReload && isReconnect) {
|
|
57227
|
+
window.location.reload();
|
|
57228
|
+
}
|
|
57229
|
+
}
|
|
57230
|
+
};
|
|
57231
|
+
socket.addEventListener("message", handler);
|
|
57232
|
+
});
|
|
57233
|
+
socket.addEventListener("close", this.closeHandler);
|
|
57234
|
+
return socket;
|
|
57235
|
+
}
|
|
57236
|
+
onClose() {
|
|
57237
|
+
if (__privateGet(this, _reconnectCount) >= this.maxAttempts) {
|
|
57238
|
+
console.error("Could not reconnect the websocket to the server");
|
|
57239
|
+
const handler = () => {
|
|
57240
|
+
if (document.visibilityState === "visible") {
|
|
57241
|
+
__privateSet(this, _reconnectCount, 0);
|
|
57242
|
+
this.socket = this.initialize();
|
|
57243
|
+
document.removeEventListener("visibilitychange", handler);
|
|
57244
|
+
}
|
|
57245
|
+
};
|
|
57246
|
+
document.addEventListener("visibilitychange", handler);
|
|
57247
|
+
return;
|
|
57248
|
+
}
|
|
57249
|
+
setTimeout(() => {
|
|
57250
|
+
__privateWrapper(this, _reconnectCount)._++;
|
|
57251
|
+
this.socket = this.initialize(true);
|
|
57252
|
+
}, interAttemptTimeout);
|
|
57253
|
+
}
|
|
57254
|
+
close() {
|
|
57255
|
+
clearInterval(__privateGet(this, _pingInterval));
|
|
57256
|
+
this.socket.removeEventListener("close", this.closeHandler);
|
|
57257
|
+
this.socket.close();
|
|
57258
|
+
}
|
|
57259
|
+
getChannel() {
|
|
57260
|
+
return this.channel;
|
|
57261
|
+
}
|
|
57262
|
+
backendStoreMessages$() {
|
|
57263
|
+
return this.messages$.pipe(
|
|
57264
|
+
filter(isBackendStoreMessage),
|
|
57265
|
+
map$2((msg) => msg.message)
|
|
57266
|
+
);
|
|
57267
|
+
}
|
|
57268
|
+
channel$() {
|
|
57269
|
+
return this.messages$.pipe(
|
|
57270
|
+
filter((msg) => isInitMessage(msg)),
|
|
57271
|
+
map$2((msg) => msg.message.channel)
|
|
57272
|
+
);
|
|
57273
|
+
}
|
|
57274
|
+
taskStatusUpdates$(...task_ids) {
|
|
57275
|
+
return this.messages$.pipe(
|
|
57276
|
+
filter((msg) => isTaskNotification(msg) && task_ids.includes(msg.message.task_id)),
|
|
57277
|
+
map$2((msg) => msg.message.status)
|
|
57278
|
+
);
|
|
57279
|
+
}
|
|
57280
|
+
progressUpdates$(...task_ids) {
|
|
57281
|
+
return this.messages$.pipe(
|
|
57282
|
+
filter(
|
|
57283
|
+
(msg) => isTaskNotification(msg) && msg.message.status === "PROGRESS" && task_ids.includes(msg.message.task_id)
|
|
57284
|
+
)
|
|
57285
|
+
);
|
|
57286
|
+
}
|
|
57287
|
+
serverTriggers$(dataId) {
|
|
57288
|
+
return this.messages$.pipe(
|
|
57289
|
+
filter(isServerTriggerMessage),
|
|
57290
|
+
filter((msg) => {
|
|
57291
|
+
var _a;
|
|
57292
|
+
return ((_a = msg.message) == null ? void 0 : _a.data_id) === dataId;
|
|
57293
|
+
})
|
|
57294
|
+
);
|
|
57295
|
+
}
|
|
57296
|
+
serverErrors$() {
|
|
57297
|
+
return this.messages$.pipe(filter(isServerErrorMessage));
|
|
57298
|
+
}
|
|
57299
|
+
variableRequests$() {
|
|
57300
|
+
return this.messages$.pipe(filter(isVariableRequestMessage));
|
|
57301
|
+
}
|
|
57302
|
+
actionMessages$(executionId) {
|
|
57303
|
+
return this.messages$.pipe(
|
|
57304
|
+
filter((msg) => isActionMessage(msg) && msg.message.uid === executionId),
|
|
57305
|
+
map$2((msg) => msg.message.action)
|
|
57306
|
+
);
|
|
57307
|
+
}
|
|
57308
|
+
customMessages$() {
|
|
57309
|
+
return this.messages$.pipe(filter(isCustomMessage));
|
|
57310
|
+
}
|
|
57311
|
+
waitForTask(task_id) {
|
|
57312
|
+
return this.messages$.pipe(
|
|
57313
|
+
filter(
|
|
57314
|
+
(msg) => {
|
|
57315
|
+
var _a;
|
|
57316
|
+
return isTaskNotification(msg) && ((_a = msg.message) == null ? void 0 : _a.task_id) === task_id && msg.message.status !== "PROGRESS";
|
|
57317
|
+
}
|
|
57318
|
+
),
|
|
57319
|
+
map$2((msg) => {
|
|
57320
|
+
if (isTaskNotification(msg) && msg.message.status === "CANCELED") {
|
|
57321
|
+
throw new Error("CANCELED");
|
|
57322
|
+
}
|
|
57323
|
+
return msg;
|
|
57324
|
+
}),
|
|
57325
|
+
take(1)
|
|
57326
|
+
).toPromise();
|
|
57327
|
+
}
|
|
57328
|
+
sendVariable(value, channel) {
|
|
57329
|
+
this.sendMessage(value, channel);
|
|
57330
|
+
}
|
|
57331
|
+
sendMessage(value, channel, chunkCount) {
|
|
57332
|
+
if (this.socket.readyState === WebSocket.OPEN) {
|
|
57333
|
+
this.socket.send(
|
|
57334
|
+
JSON.stringify({
|
|
57335
|
+
channel,
|
|
57336
|
+
chunk_count: chunkCount != null ? chunkCount : null,
|
|
57337
|
+
message: value,
|
|
57338
|
+
type: "message"
|
|
57339
|
+
})
|
|
57340
|
+
);
|
|
57341
|
+
}
|
|
57342
|
+
}
|
|
57343
|
+
updateToken(newToken) {
|
|
57344
|
+
this.token = newToken;
|
|
57345
|
+
if (this.socket.readyState === WebSocket.OPEN) {
|
|
57346
|
+
this.socket.send(
|
|
57347
|
+
JSON.stringify({
|
|
57348
|
+
message: newToken,
|
|
57349
|
+
type: "token_update"
|
|
57350
|
+
})
|
|
57351
|
+
);
|
|
57352
|
+
}
|
|
57353
|
+
}
|
|
57354
|
+
sendCustomMessage(kind, data, awaitResponse = false) {
|
|
57355
|
+
if (this.socket.readyState === WebSocket.OPEN) {
|
|
57356
|
+
if (awaitResponse) {
|
|
57357
|
+
const rchan = nanoid();
|
|
57358
|
+
return new Promise((resolve) => {
|
|
57359
|
+
const subscription = this.customMessages$().pipe().subscribe({
|
|
57360
|
+
next: (msg) => {
|
|
57361
|
+
if (msg.message.__response_for === rchan) {
|
|
57362
|
+
resolve(msg);
|
|
57363
|
+
subscription.unsubscribe();
|
|
57364
|
+
}
|
|
57365
|
+
}
|
|
57366
|
+
});
|
|
57367
|
+
this.socket.send(
|
|
57368
|
+
JSON.stringify({
|
|
57369
|
+
message: {
|
|
57370
|
+
data,
|
|
57371
|
+
kind,
|
|
57372
|
+
__rchan: rchan
|
|
57373
|
+
},
|
|
57374
|
+
type: "custom"
|
|
57375
|
+
})
|
|
57376
|
+
);
|
|
57377
|
+
});
|
|
57378
|
+
}
|
|
57379
|
+
this.socket.send(
|
|
57380
|
+
JSON.stringify({
|
|
57381
|
+
message: {
|
|
57382
|
+
data,
|
|
57383
|
+
kind
|
|
57384
|
+
},
|
|
57385
|
+
type: "custom"
|
|
57386
|
+
})
|
|
57387
|
+
);
|
|
57388
|
+
return Promise.resolve(null);
|
|
57389
|
+
}
|
|
57390
|
+
}
|
|
57391
|
+
}
|
|
57392
|
+
_pingInterval = new WeakMap();
|
|
57393
|
+
_socketUrl = new WeakMap();
|
|
57394
|
+
_reconnectCount = new WeakMap();
|
|
57395
|
+
function setupWebsocket(sessionToken, liveReload) {
|
|
57396
|
+
var _a;
|
|
57397
|
+
let { host } = window.location;
|
|
57398
|
+
if ((_a = window.dara) == null ? void 0 : _a.base_url) {
|
|
57399
|
+
const baseUrl = new URL(window.dara.base_url, window.origin);
|
|
57400
|
+
let { pathname } = baseUrl;
|
|
57401
|
+
if (pathname.endsWith("/")) {
|
|
57402
|
+
pathname = pathname.slice(0, -1);
|
|
57403
|
+
}
|
|
57404
|
+
host = baseUrl.host + pathname;
|
|
57405
|
+
}
|
|
57406
|
+
const socketUrl = `${window.location.protocol === "https:" ? "wss://" : "ws://"}${host}/api/core/ws`;
|
|
57407
|
+
const url = new URL(socketUrl);
|
|
57408
|
+
url.searchParams.set("token", sessionToken);
|
|
57409
|
+
return new WebSocketClient(socketUrl, sessionToken, liveReload);
|
|
57410
|
+
}
|
|
57523
57411
|
function combineFilters(combinator, queries) {
|
|
57524
57412
|
const validQueries = queries.filter(Boolean);
|
|
57525
57413
|
if (validQueries.length === 0) {
|
|
@@ -58284,6 +58172,188 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
58284
58172
|
function StoreProviders({ children }) {
|
|
58285
58173
|
return /* @__PURE__ */ React__namespace.createElement(BackendStoreSync, null, /* @__PURE__ */ React__namespace.createElement(BrowserStoreSync, null, children));
|
|
58286
58174
|
}
|
|
58175
|
+
const _StateSynchronizer = class {
|
|
58176
|
+
constructor() {
|
|
58177
|
+
__privateAdd(this, _observers, /* @__PURE__ */ new Map());
|
|
58178
|
+
}
|
|
58179
|
+
static getInstance() {
|
|
58180
|
+
if (!__privateGet(_StateSynchronizer, _instance)) {
|
|
58181
|
+
__privateSet(_StateSynchronizer, _instance, new _StateSynchronizer());
|
|
58182
|
+
}
|
|
58183
|
+
return __privateGet(_StateSynchronizer, _instance);
|
|
58184
|
+
}
|
|
58185
|
+
register(key, defaultValue) {
|
|
58186
|
+
if (!__privateGet(this, _observers).has(key)) {
|
|
58187
|
+
__privateGet(this, _observers).set(key, new BehaviorSubject({ type: "initial", value: defaultValue }));
|
|
58188
|
+
}
|
|
58189
|
+
}
|
|
58190
|
+
isRegistered(key) {
|
|
58191
|
+
return __privateGet(this, _observers).has(key);
|
|
58192
|
+
}
|
|
58193
|
+
getCurrentState(key) {
|
|
58194
|
+
if (!this.isRegistered(key)) {
|
|
58195
|
+
return null;
|
|
58196
|
+
}
|
|
58197
|
+
return __privateGet(this, _observers).get(key).getValue();
|
|
58198
|
+
}
|
|
58199
|
+
subscribe(key, subscription) {
|
|
58200
|
+
if (!this.isRegistered(key)) {
|
|
58201
|
+
this.register(key, null);
|
|
58202
|
+
}
|
|
58203
|
+
const sub = __privateGet(this, _observers).get(key).subscribe(subscription);
|
|
58204
|
+
return () => {
|
|
58205
|
+
sub.unsubscribe();
|
|
58206
|
+
if (__privateGet(this, _observers).get(key).observers.length === 0) {
|
|
58207
|
+
__privateGet(this, _observers).delete(key);
|
|
58208
|
+
}
|
|
58209
|
+
};
|
|
58210
|
+
}
|
|
58211
|
+
notify(key, update) {
|
|
58212
|
+
if (!this.isRegistered(key)) {
|
|
58213
|
+
this.register(key, null);
|
|
58214
|
+
}
|
|
58215
|
+
__privateGet(this, _observers).get(key).next(update);
|
|
58216
|
+
}
|
|
58217
|
+
};
|
|
58218
|
+
let StateSynchronizer = _StateSynchronizer;
|
|
58219
|
+
_instance = new WeakMap();
|
|
58220
|
+
_observers = new WeakMap();
|
|
58221
|
+
__privateAdd(StateSynchronizer, _instance, void 0);
|
|
58222
|
+
function getOrRegisterPlainVariable(variable, wsClient, taskContext, extras) {
|
|
58223
|
+
const isNested = variable.nested && variable.nested.length > 0;
|
|
58224
|
+
const isDefaultDerived = isDerivedVariable(variable.default);
|
|
58225
|
+
if (!atomFamilyRegistry.has(variable.uid)) {
|
|
58226
|
+
atomFamilyRegistry.set(
|
|
58227
|
+
variable.uid,
|
|
58228
|
+
Recoil_index_10({
|
|
58229
|
+
default: isDefaultDerived ? (extrasSerializable2) => getOrRegisterDerivedVariableValue(
|
|
58230
|
+
variable.default,
|
|
58231
|
+
wsClient,
|
|
58232
|
+
taskContext,
|
|
58233
|
+
extrasSerializable2.extras
|
|
58234
|
+
) : variable.default,
|
|
58235
|
+
effects: (extrasSerializable2) => {
|
|
58236
|
+
const familySync = ({ onSet, setSelf, resetSelf, node }) => {
|
|
58237
|
+
if (!StateSynchronizer.getInstance().isRegistered(variable.uid)) {
|
|
58238
|
+
StateSynchronizer.getInstance().register(variable.uid, variable.default);
|
|
58239
|
+
} else {
|
|
58240
|
+
const currentState = StateSynchronizer.getInstance().getCurrentState(variable.uid);
|
|
58241
|
+
if (!isDefaultDerived || (currentState == null ? void 0 : currentState.type) !== "initial") {
|
|
58242
|
+
setSelf(currentState == null ? void 0 : currentState.value);
|
|
58243
|
+
}
|
|
58244
|
+
}
|
|
58245
|
+
const unsub = StateSynchronizer.getInstance().subscribe(variable.uid, (update) => {
|
|
58246
|
+
if (update.type === "initial") {
|
|
58247
|
+
return;
|
|
58248
|
+
}
|
|
58249
|
+
if (update.nodeKey === node.key) {
|
|
58250
|
+
return;
|
|
58251
|
+
}
|
|
58252
|
+
if (update.isReset) {
|
|
58253
|
+
resetSelf();
|
|
58254
|
+
} else {
|
|
58255
|
+
setSelf(update.value);
|
|
58256
|
+
}
|
|
58257
|
+
});
|
|
58258
|
+
onSet((newValue, oldValue, isReset) => {
|
|
58259
|
+
StateSynchronizer.getInstance().notify(variable.uid, {
|
|
58260
|
+
isReset,
|
|
58261
|
+
nodeKey: node.key,
|
|
58262
|
+
oldValue,
|
|
58263
|
+
type: "update",
|
|
58264
|
+
value: newValue
|
|
58265
|
+
});
|
|
58266
|
+
});
|
|
58267
|
+
return unsub;
|
|
58268
|
+
};
|
|
58269
|
+
const effects = [familySync];
|
|
58270
|
+
const storeEffect = getEffect(variable);
|
|
58271
|
+
if (storeEffect) {
|
|
58272
|
+
effects.push(storeEffect(variable, extrasSerializable2, wsClient, taskContext));
|
|
58273
|
+
} else {
|
|
58274
|
+
if (variable.persist_value || isEmbedded()) {
|
|
58275
|
+
effects.push(
|
|
58276
|
+
STORES.BrowserStore.effect(variable, extrasSerializable2, wsClient, taskContext)
|
|
58277
|
+
);
|
|
58278
|
+
}
|
|
58279
|
+
}
|
|
58280
|
+
return effects;
|
|
58281
|
+
},
|
|
58282
|
+
key: variable.uid
|
|
58283
|
+
})
|
|
58284
|
+
);
|
|
58285
|
+
}
|
|
58286
|
+
const family = atomFamilyRegistry.get(variable.uid);
|
|
58287
|
+
const extrasSerializable = new RequestExtrasSerializable(extras);
|
|
58288
|
+
const atomInstance = family(extrasSerializable);
|
|
58289
|
+
if (!atomFamilyMembersRegistry.has(family)) {
|
|
58290
|
+
atomFamilyMembersRegistry.set(family, /* @__PURE__ */ new Map());
|
|
58291
|
+
}
|
|
58292
|
+
atomFamilyMembersRegistry.get(family).set(extrasSerializable.toJSON(), atomInstance);
|
|
58293
|
+
if (isNested) {
|
|
58294
|
+
const key = getRegistryKey(variable, "selector");
|
|
58295
|
+
if (!selectorFamilyRegistry.has(key)) {
|
|
58296
|
+
selectorFamilyRegistry.set(
|
|
58297
|
+
key,
|
|
58298
|
+
Recoil_index_11({
|
|
58299
|
+
get: (currentExtras) => ({ get: get2 }) => {
|
|
58300
|
+
const variableValue = get2(family(currentExtras));
|
|
58301
|
+
return resolveNested(
|
|
58302
|
+
variableValue,
|
|
58303
|
+
variable.nested.map((n2) => String(n2))
|
|
58304
|
+
);
|
|
58305
|
+
},
|
|
58306
|
+
key,
|
|
58307
|
+
set: (currentExtras) => ({ set: set2 }, newValue) => {
|
|
58308
|
+
set2(
|
|
58309
|
+
family(currentExtras),
|
|
58310
|
+
(v2) => setNested(
|
|
58311
|
+
v2,
|
|
58312
|
+
variable.nested.map((n2) => String(n2)),
|
|
58313
|
+
newValue
|
|
58314
|
+
)
|
|
58315
|
+
);
|
|
58316
|
+
}
|
|
58317
|
+
})
|
|
58318
|
+
);
|
|
58319
|
+
}
|
|
58320
|
+
const selectorFamilyInstance = selectorFamilyRegistry.get(key);
|
|
58321
|
+
return selectorFamilyInstance(extrasSerializable);
|
|
58322
|
+
}
|
|
58323
|
+
return atomInstance;
|
|
58324
|
+
}
|
|
58325
|
+
function useDeferLoadable(loadable) {
|
|
58326
|
+
const { suspend } = React.useContext(fallbackCtx);
|
|
58327
|
+
const [availableState, setAvailableState] = React.useState(() => loadable.getValue());
|
|
58328
|
+
const timerId = React.useRef(null);
|
|
58329
|
+
const isFirstRender = React.useRef(true);
|
|
58330
|
+
const [showFallback, setShowFallback] = React.useState(false);
|
|
58331
|
+
React.useEffect(() => {
|
|
58332
|
+
if (isFirstRender.current) {
|
|
58333
|
+
isFirstRender.current = false;
|
|
58334
|
+
return;
|
|
58335
|
+
}
|
|
58336
|
+
if (loadable.state === "loading" && typeof suspend === "number") {
|
|
58337
|
+
timerId.current = setTimeout(() => {
|
|
58338
|
+
setShowFallback(true);
|
|
58339
|
+
}, suspend);
|
|
58340
|
+
}
|
|
58341
|
+
return () => {
|
|
58342
|
+
clearTimeout(timerId.current);
|
|
58343
|
+
};
|
|
58344
|
+
}, [loadable.state, suspend]);
|
|
58345
|
+
React.useEffect(() => {
|
|
58346
|
+
if (loadable.state === "hasValue") {
|
|
58347
|
+
clearTimeout(timerId.current);
|
|
58348
|
+
setShowFallback(false);
|
|
58349
|
+
setAvailableState(loadable.valueOrThrow());
|
|
58350
|
+
}
|
|
58351
|
+
}, [loadable]);
|
|
58352
|
+
if (suspend === true || showFallback) {
|
|
58353
|
+
return loadable.getValue();
|
|
58354
|
+
}
|
|
58355
|
+
return availableState;
|
|
58356
|
+
}
|
|
58287
58357
|
function warnUpdateOnDerivedState() {
|
|
58288
58358
|
console.warn("You tried to call update on variable with derived state, this is a noop and will be ignored.");
|
|
58289
58359
|
}
|
|
@@ -58340,171 +58410,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
58340
58410
|
const deferred = useDeferLoadable(loadable);
|
|
58341
58411
|
return [deferred, setLoadable];
|
|
58342
58412
|
}
|
|
58343
|
-
function useDataVariable(variable) {
|
|
58344
|
-
const extras = useRequestExtras();
|
|
58345
|
-
const { client: wsClient } = React.useContext(websocketCtx);
|
|
58346
|
-
if (isDataVariable(variable)) {
|
|
58347
|
-
registerDataVariable(variable);
|
|
58348
|
-
const serverTriggers$ = React.useMemo(() => wsClient.serverTriggers$(variable.uid), []);
|
|
58349
|
-
const [serverTriggerCounter, setServerTriggerCounter] = React.useState(0);
|
|
58350
|
-
React.useEffect(() => {
|
|
58351
|
-
const sub = serverTriggers$.subscribe(() => setServerTriggerCounter((c2) => c2 + 1));
|
|
58352
|
-
return () => sub.unsubscribe();
|
|
58353
|
-
}, [serverTriggers$]);
|
|
58354
|
-
const fetchDataVariable2 = useFetchDataVariable(variable, serverTriggerCounter);
|
|
58355
|
-
return fetchDataVariable2;
|
|
58356
|
-
}
|
|
58357
|
-
const variablesContext = React.useContext(variablesCtx);
|
|
58358
|
-
variablesContext.variables.current.add(variable.uid);
|
|
58359
|
-
React.useEffect(() => {
|
|
58360
|
-
return () => {
|
|
58361
|
-
variablesContext.variables.current.delete(variable.uid);
|
|
58362
|
-
};
|
|
58363
|
-
}, []);
|
|
58364
|
-
const taskContext = useTaskContext();
|
|
58365
|
-
const dvSelector = useDerivedVariable(variable, wsClient, taskContext, extras);
|
|
58366
|
-
const dvLoadable = Recoil_index_21(dvSelector);
|
|
58367
|
-
const [dvValue, setDvValue] = React.useState(dvLoadable.toPromise());
|
|
58368
|
-
React.useEffect(() => {
|
|
58369
|
-
if (dvLoadable.state === "loading") {
|
|
58370
|
-
setDvValue(dvLoadable.toPromise());
|
|
58371
|
-
}
|
|
58372
|
-
}, [dvLoadable]);
|
|
58373
|
-
const fetchDerivedDataVariable2 = useFetchDerivedDataVariable(variable, taskContext, wsClient, dvValue);
|
|
58374
|
-
return fetchDerivedDataVariable2;
|
|
58375
|
-
}
|
|
58376
|
-
function useAnyVariable(variable) {
|
|
58377
|
-
if (isDataVariable(variable) || isDerivedDataVariable(variable)) {
|
|
58378
|
-
const getData2 = useDataVariable(variable);
|
|
58379
|
-
const { data, refetch } = reactQuery.useQuery({
|
|
58380
|
-
cacheTime: 1,
|
|
58381
|
-
queryFn: async () => {
|
|
58382
|
-
const dataResponse = await getData2();
|
|
58383
|
-
return dataResponse.data;
|
|
58384
|
-
},
|
|
58385
|
-
queryKey: ["any-variable-data", variable.uid],
|
|
58386
|
-
refetchOnWindowFocus: false,
|
|
58387
|
-
suspense: true
|
|
58388
|
-
});
|
|
58389
|
-
React.useEffect(() => {
|
|
58390
|
-
refetch();
|
|
58391
|
-
}, [getData2]);
|
|
58392
|
-
return data;
|
|
58393
|
-
}
|
|
58394
|
-
return useVariable(variable)[0];
|
|
58395
|
-
}
|
|
58396
|
-
function getVariableValue(variable, shouldFetchVariable = false, ctx) {
|
|
58397
|
-
const resolved = resolveVariable(
|
|
58398
|
-
variable,
|
|
58399
|
-
ctx.client,
|
|
58400
|
-
ctx.taskContext,
|
|
58401
|
-
ctx.extras,
|
|
58402
|
-
(v2) => ctx.snapshot.getLoadable(v2).getValue()
|
|
58403
|
-
);
|
|
58404
|
-
if (!shouldFetchVariable || !isDerivedVariable(variable) && !isDataVariable(variable) && !isDerivedDataVariable(variable)) {
|
|
58405
|
-
return resolved;
|
|
58406
|
-
}
|
|
58407
|
-
if (!isResolvedDerivedVariable(resolved) && !isResolvedDataVariable(resolved) && !isResolvedDerivedDataVariable(resolved)) {
|
|
58408
|
-
return resolved;
|
|
58409
|
-
}
|
|
58410
|
-
if (isResolvedDataVariable(resolved)) {
|
|
58411
|
-
return fetchDataVariable(resolved.uid, ctx.extras, resolved.filters);
|
|
58412
|
-
}
|
|
58413
|
-
return fetchDerivedVariable({
|
|
58414
|
-
cache: variable.cache,
|
|
58415
|
-
extras: ctx.extras,
|
|
58416
|
-
force: false,
|
|
58417
|
-
selectorKey: resolved.uid,
|
|
58418
|
-
values: normalizeRequest(
|
|
58419
|
-
formatDerivedVariableRequest(resolved.values),
|
|
58420
|
-
variable.variables
|
|
58421
|
-
),
|
|
58422
|
-
variableUid: resolved.uid,
|
|
58423
|
-
wsClient: ctx.client
|
|
58424
|
-
}).then((resp) => {
|
|
58425
|
-
if (isTaskResponse$1(resp)) {
|
|
58426
|
-
throw new Error("Task DerivedVariables are not supported in this context");
|
|
58427
|
-
}
|
|
58428
|
-
if (isDerivedDataVariable(variable)) {
|
|
58429
|
-
return ctx.client.getChannel().then(
|
|
58430
|
-
(chan) => fetchDerivedDataVariable(variable.uid, ctx.extras, resp.cache_key, chan, variable.filters)
|
|
58431
|
-
);
|
|
58432
|
-
}
|
|
58433
|
-
return resp.value;
|
|
58434
|
-
});
|
|
58435
|
-
}
|
|
58436
|
-
function useVariableValue(variable, shouldFetchVariable = false) {
|
|
58437
|
-
const taskContext = useTaskContext();
|
|
58438
|
-
const { client } = React.useContext(websocketCtx);
|
|
58439
|
-
const { search } = useLocation();
|
|
58440
|
-
const extras = useRequestExtras();
|
|
58441
|
-
if (!isVariable(variable)) {
|
|
58442
|
-
return () => variable;
|
|
58443
|
-
}
|
|
58444
|
-
return Recoil_index_31(
|
|
58445
|
-
({ snapshot }) => {
|
|
58446
|
-
return () => {
|
|
58447
|
-
return getVariableValue(variable, shouldFetchVariable, {
|
|
58448
|
-
client,
|
|
58449
|
-
extras,
|
|
58450
|
-
search,
|
|
58451
|
-
snapshot,
|
|
58452
|
-
taskContext
|
|
58453
|
-
});
|
|
58454
|
-
};
|
|
58455
|
-
},
|
|
58456
|
-
[variable.uid, useDeepCompare(taskContext), client, search, extras]
|
|
58457
|
-
);
|
|
58458
|
-
}
|
|
58459
|
-
function resolveValue(value, force) {
|
|
58460
|
-
if (isResolvedDerivedVariable(value) || isResolvedDerivedDataVariable(value)) {
|
|
58461
|
-
const { deps, ...rest } = value;
|
|
58462
|
-
const resolvedValues = value.values.map((v2) => resolveValue(v2, force));
|
|
58463
|
-
return {
|
|
58464
|
-
...rest,
|
|
58465
|
-
force,
|
|
58466
|
-
values: resolvedValues
|
|
58467
|
-
};
|
|
58468
|
-
}
|
|
58469
|
-
if (typeof value === "function") {
|
|
58470
|
-
return resolveValue(value(), force);
|
|
58471
|
-
}
|
|
58472
|
-
return value;
|
|
58473
|
-
}
|
|
58474
|
-
function useRefreshSelector() {
|
|
58475
|
-
return Recoil_index_31(({ refresh }) => {
|
|
58476
|
-
return (key, extras) => {
|
|
58477
|
-
var _a;
|
|
58478
|
-
const family = selectorFamilyRegistry.get(key);
|
|
58479
|
-
if (family) {
|
|
58480
|
-
const selector2 = (_a = selectorFamilyMembersRegistry.get(family)) == null ? void 0 : _a.get(extras);
|
|
58481
|
-
if (selector2) {
|
|
58482
|
-
refresh(selector2);
|
|
58483
|
-
}
|
|
58484
|
-
}
|
|
58485
|
-
};
|
|
58486
|
-
});
|
|
58487
|
-
}
|
|
58488
|
-
function useVariableState() {
|
|
58489
|
-
const extras = useRequestExtras();
|
|
58490
|
-
const { client } = React.useContext(websocketCtx);
|
|
58491
|
-
const taskCtx = useTaskContext();
|
|
58492
|
-
return Recoil_index_31(({ snapshot }) => {
|
|
58493
|
-
return (variable) => {
|
|
58494
|
-
if (!isRegistered(variable)) {
|
|
58495
|
-
return "__NOT_REGISTERED__";
|
|
58496
|
-
}
|
|
58497
|
-
const resolvedVariable = resolveVariable(
|
|
58498
|
-
variable,
|
|
58499
|
-
client,
|
|
58500
|
-
taskCtx,
|
|
58501
|
-
extras,
|
|
58502
|
-
(v2) => snapshot.getLoadable(v2).getValue()
|
|
58503
|
-
);
|
|
58504
|
-
return resolvedVariable;
|
|
58505
|
-
};
|
|
58506
|
-
}, []);
|
|
58507
|
-
}
|
|
58508
58413
|
function useActionRegistry() {
|
|
58509
58414
|
const { actionRegistry: actions } = React.useContext(registriesCtx);
|
|
58510
58415
|
const get2 = React.useCallback(
|
|
@@ -58730,38 +58635,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
|
|
|
58730
58635
|
}
|
|
58731
58636
|
return callback;
|
|
58732
58637
|
}
|
|
58733
|
-
function useDeferLoadable(loadable) {
|
|
58734
|
-
const { suspend } = React.useContext(fallbackCtx);
|
|
58735
|
-
const [availableState, setAvailableState] = React.useState(() => loadable.getValue());
|
|
58736
|
-
const timerId = React.useRef(null);
|
|
58737
|
-
const isFirstRender = React.useRef(true);
|
|
58738
|
-
const [showFallback, setShowFallback] = React.useState(false);
|
|
58739
|
-
React.useEffect(() => {
|
|
58740
|
-
if (isFirstRender.current) {
|
|
58741
|
-
isFirstRender.current = false;
|
|
58742
|
-
return;
|
|
58743
|
-
}
|
|
58744
|
-
if (loadable.state === "loading" && typeof suspend === "number") {
|
|
58745
|
-
timerId.current = setTimeout(() => {
|
|
58746
|
-
setShowFallback(true);
|
|
58747
|
-
}, suspend);
|
|
58748
|
-
}
|
|
58749
|
-
return () => {
|
|
58750
|
-
clearTimeout(timerId.current);
|
|
58751
|
-
};
|
|
58752
|
-
}, [loadable.state, suspend]);
|
|
58753
|
-
React.useEffect(() => {
|
|
58754
|
-
if (loadable.state === "hasValue") {
|
|
58755
|
-
clearTimeout(timerId.current);
|
|
58756
|
-
setShowFallback(false);
|
|
58757
|
-
setAvailableState(loadable.valueOrThrow());
|
|
58758
|
-
}
|
|
58759
|
-
}, [loadable]);
|
|
58760
|
-
if (suspend === true || showFallback) {
|
|
58761
|
-
return loadable.getValue();
|
|
58762
|
-
}
|
|
58763
|
-
return availableState;
|
|
58764
|
-
}
|
|
58765
58638
|
function useComponentRegistry(maxRetries = 5) {
|
|
58766
58639
|
const { componentRegistry: components, refetchComponents } = React.useContext(registriesCtx);
|
|
58767
58640
|
const extras = useRequestExtras();
|
|
@@ -58921,7 +58794,7 @@ Inferred class string: "${iconClasses}."`
|
|
|
58921
58794
|
}
|
|
58922
58795
|
try {
|
|
58923
58796
|
return JSON.parse(val);
|
|
58924
|
-
} catch
|
|
58797
|
+
} catch {
|
|
58925
58798
|
return val;
|
|
58926
58799
|
}
|
|
58927
58800
|
}, []);
|
|
@@ -59498,6 +59371,171 @@ Inferred class string: "${iconClasses}."`
|
|
|
59498
59371
|
const [styles2, css2] = parseRawCss((_a = props.config) == null ? void 0 : _a.raw_css);
|
|
59499
59372
|
return /* @__PURE__ */ React__default.default.createElement(ErrorDisplayWrapper, { $rawCss: css2, style: styles2 }, /* @__PURE__ */ React__default.default.createElement(ContentWrapper, null, /* @__PURE__ */ React__default.default.createElement(ErrorContent, null, /* @__PURE__ */ React__default.default.createElement(ErrorTitle$1, null, /* @__PURE__ */ React__default.default.createElement(IconWrapper, null, /* @__PURE__ */ React__default.default.createElement(ErrorIcon, { "aria-hidden": true, className: "fa-solid fa-circle-xmark fa-lg" })), (_c = (_b = props == null ? void 0 : props.config) == null ? void 0 : _b.title) != null ? _c : "Error"), /* @__PURE__ */ React__default.default.createElement(ErrorText$1, null, (_e2 = (_d = props == null ? void 0 : props.config) == null ? void 0 : _d.description) != null ? _e2 : "Try again or contact the application owner."))), props.resetErrorBoundary && /* @__PURE__ */ React__default.default.createElement(RetryButton, { onClick: () => props.resetErrorBoundary(props.error), type: "button" }, /* @__PURE__ */ React__default.default.createElement("i", { "aria-hidden": true, className: "fa-solid fa-rotate fa-xl" })));
|
|
59500
59373
|
}
|
|
59374
|
+
function useDataVariable(variable) {
|
|
59375
|
+
const extras = useRequestExtras();
|
|
59376
|
+
const { client: wsClient } = React.useContext(websocketCtx);
|
|
59377
|
+
if (isDataVariable(variable)) {
|
|
59378
|
+
registerDataVariable(variable);
|
|
59379
|
+
const serverTriggers$ = React.useMemo(() => wsClient.serverTriggers$(variable.uid), []);
|
|
59380
|
+
const [serverTriggerCounter, setServerTriggerCounter] = React.useState(0);
|
|
59381
|
+
React.useEffect(() => {
|
|
59382
|
+
const sub = serverTriggers$.subscribe(() => setServerTriggerCounter((c2) => c2 + 1));
|
|
59383
|
+
return () => sub.unsubscribe();
|
|
59384
|
+
}, [serverTriggers$]);
|
|
59385
|
+
const fetchDataVariable2 = useFetchDataVariable(variable, serverTriggerCounter);
|
|
59386
|
+
return fetchDataVariable2;
|
|
59387
|
+
}
|
|
59388
|
+
const variablesContext = React.useContext(variablesCtx);
|
|
59389
|
+
variablesContext.variables.current.add(variable.uid);
|
|
59390
|
+
React.useEffect(() => {
|
|
59391
|
+
return () => {
|
|
59392
|
+
variablesContext.variables.current.delete(variable.uid);
|
|
59393
|
+
};
|
|
59394
|
+
}, []);
|
|
59395
|
+
const taskContext = useTaskContext();
|
|
59396
|
+
const dvSelector = useDerivedVariable(variable, wsClient, taskContext, extras);
|
|
59397
|
+
const dvLoadable = Recoil_index_21(dvSelector);
|
|
59398
|
+
const [dvValue, setDvValue] = React.useState(dvLoadable.toPromise());
|
|
59399
|
+
React.useEffect(() => {
|
|
59400
|
+
if (dvLoadable.state === "loading") {
|
|
59401
|
+
setDvValue(dvLoadable.toPromise());
|
|
59402
|
+
}
|
|
59403
|
+
}, [dvLoadable]);
|
|
59404
|
+
const fetchDerivedDataVariable2 = useFetchDerivedDataVariable(variable, taskContext, wsClient, dvValue);
|
|
59405
|
+
return fetchDerivedDataVariable2;
|
|
59406
|
+
}
|
|
59407
|
+
function useAnyVariable(variable) {
|
|
59408
|
+
if (isDataVariable(variable) || isDerivedDataVariable(variable)) {
|
|
59409
|
+
const getData2 = useDataVariable(variable);
|
|
59410
|
+
const { data, refetch } = reactQuery.useQuery({
|
|
59411
|
+
cacheTime: 1,
|
|
59412
|
+
queryFn: async () => {
|
|
59413
|
+
const dataResponse = await getData2();
|
|
59414
|
+
return dataResponse.data;
|
|
59415
|
+
},
|
|
59416
|
+
queryKey: ["any-variable-data", variable.uid],
|
|
59417
|
+
refetchOnWindowFocus: false,
|
|
59418
|
+
suspense: true
|
|
59419
|
+
});
|
|
59420
|
+
React.useEffect(() => {
|
|
59421
|
+
refetch();
|
|
59422
|
+
}, [getData2]);
|
|
59423
|
+
return data;
|
|
59424
|
+
}
|
|
59425
|
+
return useVariable(variable)[0];
|
|
59426
|
+
}
|
|
59427
|
+
function getVariableValue(variable, shouldFetchVariable = false, ctx) {
|
|
59428
|
+
const resolved = resolveVariable(
|
|
59429
|
+
variable,
|
|
59430
|
+
ctx.client,
|
|
59431
|
+
ctx.taskContext,
|
|
59432
|
+
ctx.extras,
|
|
59433
|
+
(v2) => ctx.snapshot.getLoadable(v2).getValue()
|
|
59434
|
+
);
|
|
59435
|
+
if (!shouldFetchVariable || !isDerivedVariable(variable) && !isDataVariable(variable) && !isDerivedDataVariable(variable)) {
|
|
59436
|
+
return resolved;
|
|
59437
|
+
}
|
|
59438
|
+
if (!isResolvedDerivedVariable(resolved) && !isResolvedDataVariable(resolved) && !isResolvedDerivedDataVariable(resolved)) {
|
|
59439
|
+
return resolved;
|
|
59440
|
+
}
|
|
59441
|
+
if (isResolvedDataVariable(resolved)) {
|
|
59442
|
+
return fetchDataVariable(resolved.uid, ctx.extras, resolved.filters);
|
|
59443
|
+
}
|
|
59444
|
+
return fetchDerivedVariable({
|
|
59445
|
+
cache: variable.cache,
|
|
59446
|
+
extras: ctx.extras,
|
|
59447
|
+
force: false,
|
|
59448
|
+
selectorKey: resolved.uid,
|
|
59449
|
+
values: normalizeRequest(
|
|
59450
|
+
formatDerivedVariableRequest(resolved.values),
|
|
59451
|
+
variable.variables
|
|
59452
|
+
),
|
|
59453
|
+
variableUid: resolved.uid,
|
|
59454
|
+
wsClient: ctx.client
|
|
59455
|
+
}).then((resp) => {
|
|
59456
|
+
if (isTaskResponse$1(resp)) {
|
|
59457
|
+
throw new Error("Task DerivedVariables are not supported in this context");
|
|
59458
|
+
}
|
|
59459
|
+
if (isDerivedDataVariable(variable)) {
|
|
59460
|
+
return ctx.client.getChannel().then(
|
|
59461
|
+
(chan) => fetchDerivedDataVariable(variable.uid, ctx.extras, resp.cache_key, chan, variable.filters)
|
|
59462
|
+
);
|
|
59463
|
+
}
|
|
59464
|
+
return resp.value;
|
|
59465
|
+
});
|
|
59466
|
+
}
|
|
59467
|
+
function useVariableValue(variable, shouldFetchVariable = false) {
|
|
59468
|
+
const taskContext = useTaskContext();
|
|
59469
|
+
const { client } = React.useContext(websocketCtx);
|
|
59470
|
+
const { search } = useLocation();
|
|
59471
|
+
const extras = useRequestExtras();
|
|
59472
|
+
if (!isVariable(variable)) {
|
|
59473
|
+
return () => variable;
|
|
59474
|
+
}
|
|
59475
|
+
return Recoil_index_31(
|
|
59476
|
+
({ snapshot }) => {
|
|
59477
|
+
return () => {
|
|
59478
|
+
return getVariableValue(variable, shouldFetchVariable, {
|
|
59479
|
+
client,
|
|
59480
|
+
extras,
|
|
59481
|
+
search,
|
|
59482
|
+
snapshot,
|
|
59483
|
+
taskContext
|
|
59484
|
+
});
|
|
59485
|
+
};
|
|
59486
|
+
},
|
|
59487
|
+
[variable.uid, useDeepCompare(taskContext), client, search, extras]
|
|
59488
|
+
);
|
|
59489
|
+
}
|
|
59490
|
+
function resolveValue(value, force) {
|
|
59491
|
+
if (isResolvedDerivedVariable(value) || isResolvedDerivedDataVariable(value)) {
|
|
59492
|
+
const { deps, ...rest } = value;
|
|
59493
|
+
const resolvedValues = value.values.map((v2) => resolveValue(v2, force));
|
|
59494
|
+
return {
|
|
59495
|
+
...rest,
|
|
59496
|
+
force,
|
|
59497
|
+
values: resolvedValues
|
|
59498
|
+
};
|
|
59499
|
+
}
|
|
59500
|
+
if (typeof value === "function") {
|
|
59501
|
+
return resolveValue(value(), force);
|
|
59502
|
+
}
|
|
59503
|
+
return value;
|
|
59504
|
+
}
|
|
59505
|
+
function useRefreshSelector() {
|
|
59506
|
+
return Recoil_index_31(({ refresh }) => {
|
|
59507
|
+
return (key, extras) => {
|
|
59508
|
+
var _a;
|
|
59509
|
+
const family = selectorFamilyRegistry.get(key);
|
|
59510
|
+
if (family) {
|
|
59511
|
+
const selector2 = (_a = selectorFamilyMembersRegistry.get(family)) == null ? void 0 : _a.get(extras);
|
|
59512
|
+
if (selector2) {
|
|
59513
|
+
refresh(selector2);
|
|
59514
|
+
}
|
|
59515
|
+
}
|
|
59516
|
+
};
|
|
59517
|
+
});
|
|
59518
|
+
}
|
|
59519
|
+
function useVariableState() {
|
|
59520
|
+
const extras = useRequestExtras();
|
|
59521
|
+
const { client } = React.useContext(websocketCtx);
|
|
59522
|
+
const taskCtx = useTaskContext();
|
|
59523
|
+
return Recoil_index_31(({ snapshot }) => {
|
|
59524
|
+
return (variable) => {
|
|
59525
|
+
if (!isRegistered(variable)) {
|
|
59526
|
+
return "__NOT_REGISTERED__";
|
|
59527
|
+
}
|
|
59528
|
+
const resolvedVariable = resolveVariable(
|
|
59529
|
+
variable,
|
|
59530
|
+
client,
|
|
59531
|
+
taskCtx,
|
|
59532
|
+
extras,
|
|
59533
|
+
(v2) => snapshot.getLoadable(v2).getValue()
|
|
59534
|
+
);
|
|
59535
|
+
return resolvedVariable;
|
|
59536
|
+
};
|
|
59537
|
+
}, []);
|
|
59538
|
+
}
|
|
59501
59539
|
function isTaskResponse(response) {
|
|
59502
59540
|
return response && typeof response === "object" && "task_id" in response;
|
|
59503
59541
|
}
|