asab_webui_shell 27.2.9 → 27.2.10-beta.2
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.
|
@@ -10,6 +10,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _axios = _interopRequireDefault(require("axios"));
|
|
12
12
|
var _asab_webui_components = require("asab_webui_components");
|
|
13
|
+
var _jsonParseWithBigInt2 = require("../utils/jsonParseWithBigInt");
|
|
13
14
|
var _Header = _interopRequireDefault(require("./Header"));
|
|
14
15
|
var _Sidebar = _interopRequireDefault(require("./Sidebar"));
|
|
15
16
|
var _ToastContainer = _interopRequireDefault(require("./Toast/ToastContainer.js"));
|
|
@@ -74,6 +75,22 @@ class Application extends _react.Component {
|
|
|
74
75
|
// The application can provide a list of keys that should be automatically parsed as BigInt, when received from the server in Axios call
|
|
75
76
|
// This is important to preserve 64bit numbers from the server such as IP addresses, timestamps etc.
|
|
76
77
|
this.JSONParseBigInt = new Set(props === null || props === void 0 ? void 0 : props.bigint);
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
Prevent JSON.stringify from throwing on BigInt values (including inside React's
|
|
81
|
+
own dev-mode error handling). BigInt has no native JSON representation so it is
|
|
82
|
+
serialized as a decimal string.
|
|
83
|
+
*/
|
|
84
|
+
if (typeof BigInt !== "undefined" && typeof BigInt.prototype.toJSON !== "function") {
|
|
85
|
+
Object.defineProperty(BigInt.prototype, "toJSON", {
|
|
86
|
+
value() {
|
|
87
|
+
return this.toString();
|
|
88
|
+
},
|
|
89
|
+
enumerable: false,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true
|
|
92
|
+
});
|
|
93
|
+
}
|
|
77
94
|
this._handleKeyUp = this._handleKeyUp.bind(this);
|
|
78
95
|
// Clear print-ready timeout handler
|
|
79
96
|
this._clearPrintReadyTimeout = this._clearPrintReadyTimeout.bind(this);
|
|
@@ -333,6 +350,10 @@ class Application extends _react.Component {
|
|
|
333
350
|
});
|
|
334
351
|
return axios;
|
|
335
352
|
}
|
|
353
|
+
jsonParseWithBigInt(source) {
|
|
354
|
+
// Use the internal function to parse the JSON with BigInt
|
|
355
|
+
return (0, _jsonParseWithBigInt2.jsonParseWithBigInt)(source, this.JSONParseBigInt);
|
|
356
|
+
}
|
|
336
357
|
|
|
337
358
|
// Internal method for generating random UID's
|
|
338
359
|
_generateUID() {
|
|
@@ -435,6 +456,7 @@ class Application extends _react.Component {
|
|
|
435
456
|
this.setState(prevState => ({
|
|
436
457
|
printReadyIndicators: prevState.printReadyIndicators + 1
|
|
437
458
|
}));
|
|
459
|
+
console.log('print-ready', document.body.getAttribute('print-ready'), 'push');
|
|
438
460
|
}
|
|
439
461
|
popPrintReadyIndicator() {
|
|
440
462
|
this.setState(prevState => {
|
|
@@ -446,6 +468,7 @@ class Application extends _react.Component {
|
|
|
446
468
|
printReadyIndicators: Math.max(nextValue, 0)
|
|
447
469
|
};
|
|
448
470
|
});
|
|
471
|
+
console.log('print-ready', document.body.getAttribute('print-ready'), 'pop');
|
|
449
472
|
}
|
|
450
473
|
registerService(service) {
|
|
451
474
|
if (service.Name in this.Services) {
|
|
@@ -496,11 +519,13 @@ class Application extends _react.Component {
|
|
|
496
519
|
if (this.state.printReadyIndicators === 0) {
|
|
497
520
|
document.body.setAttribute('print-ready', 'true');
|
|
498
521
|
this._printReadyTimeout = null;
|
|
522
|
+
console.log('print-ready', document.body.getAttribute('print-ready'), 'set true');
|
|
499
523
|
}
|
|
500
524
|
}, 1500); // Add 1500ms delay to ensure that the print-ready attribute is set after the last print-ready indicator is popped
|
|
501
525
|
} else {
|
|
502
526
|
this._clearPrintReadyTimeout();
|
|
503
527
|
document.body.setAttribute('print-ready', 'false');
|
|
528
|
+
console.log('print-ready', document.body.getAttribute('print-ready'), 'set false');
|
|
504
529
|
}
|
|
505
530
|
}
|
|
506
531
|
componentWillUnmount() {
|
|
@@ -513,6 +538,7 @@ class Application extends _react.Component {
|
|
|
513
538
|
}
|
|
514
539
|
this._clearPrintReadyTimeout();
|
|
515
540
|
document.body.removeAttribute('print-ready');
|
|
541
|
+
console.log('print-ready', document.body.getAttribute('print-ready'), 'unmount removed');
|
|
516
542
|
}
|
|
517
543
|
_clearPrintReadyTimeout() {
|
|
518
544
|
if (this._printReadyTimeout !== null) {
|
|
@@ -547,6 +573,7 @@ class Application extends _react.Component {
|
|
|
547
573
|
if (this.SplashscreenRequestors.size == 0) {
|
|
548
574
|
var splashscreen = document.getElementById('app-splashscreen'); // See public/index.html
|
|
549
575
|
splashscreen === null || splashscreen === void 0 || splashscreen.classList.add("d-none");
|
|
576
|
+
console.log('print-ready', document.body.getAttribute('print-ready'), 'splash last removed, pop');
|
|
550
577
|
// Decrement print-ready indicator value if no splash screen requestors are present
|
|
551
578
|
this.popPrintReadyIndicator();
|
|
552
579
|
}
|
|
@@ -36,15 +36,18 @@ function UnauthorizedAccessScreen(props) {
|
|
|
36
36
|
if (!isAuthorized) {
|
|
37
37
|
document.body.setAttribute('print-ready', 'true');
|
|
38
38
|
document.body.setAttribute('print-unauthorized', 'true');
|
|
39
|
+
console.log('print-ready', document.body.getAttribute('print-ready'), 'UnauthorizedAccessScreen set true');
|
|
39
40
|
} else {
|
|
40
41
|
document.body.removeAttribute('print-ready');
|
|
41
42
|
document.body.removeAttribute('print-unauthorized');
|
|
43
|
+
console.log('print-ready', document.body.getAttribute('print-ready'), 'UnauthorizedAccessScreen cleared');
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
// Cleanup function to remove the attributes when the component unmounts
|
|
45
47
|
return () => {
|
|
46
48
|
document.body.removeAttribute('print-ready');
|
|
47
49
|
document.body.removeAttribute('print-unauthorized');
|
|
50
|
+
console.log('print-ready', document.body.getAttribute('print-ready'), 'UnauthorizedAccessScreen cleanup');
|
|
48
51
|
};
|
|
49
52
|
}, [isAuthorized]);
|
|
50
53
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.jsonParseWithBigInt = jsonParseWithBigInt;
|
|
7
|
+
/**
|
|
8
|
+
* Safely parses a JSON string, converting numeric values to BigInt for
|
|
9
|
+
* explicitly configured keys to avoid JavaScript's Number precision loss
|
|
10
|
+
* above Number.MAX_SAFE_INTEGER.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} source - Raw JSON string to parse.
|
|
13
|
+
* @param {Set<string>} bigIntKeys - Set of JSON keys whose values should be
|
|
14
|
+
* converted to BigInt. Each key is the leaf property name as it appears
|
|
15
|
+
* in the JSON (e.g. "h", "related.events").
|
|
16
|
+
*
|
|
17
|
+
* Supported value shapes for a configured key:
|
|
18
|
+
* - Scalar number: BigInt via context.source (no precision loss)
|
|
19
|
+
* - Array of numbers: each element converted via context.source
|
|
20
|
+
*/
|
|
21
|
+
function jsonParseWithBigInt(source, bigIntKeys) {
|
|
22
|
+
if (typeof source !== 'string') {
|
|
23
|
+
return source;
|
|
24
|
+
}
|
|
25
|
+
if (!(bigIntKeys !== null && bigIntKeys !== void 0 && bigIntKeys.size)) {
|
|
26
|
+
return JSON.parse(source);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
Bottom-up reviver order means array *elements* are visited before the
|
|
31
|
+
parent named key. It collect each numeric element's original source text
|
|
32
|
+
in a WeakMap keyed by the array reference, then convert them when the
|
|
33
|
+
named key is finally visited.
|
|
34
|
+
*/
|
|
35
|
+
var pending = new WeakMap();
|
|
36
|
+
return JSON.parse(source, function (key, value, context) {
|
|
37
|
+
// Inside an array: stash the raw source text for numeric elements.
|
|
38
|
+
if (Array.isArray(this) && typeof value === 'number' && (context === null || context === void 0 ? void 0 : context.source) != undefined) {
|
|
39
|
+
if (!pending.has(this)) {
|
|
40
|
+
pending.set(this, []);
|
|
41
|
+
}
|
|
42
|
+
pending.get(this).push({
|
|
43
|
+
index: Number(key),
|
|
44
|
+
src: context.source
|
|
45
|
+
});
|
|
46
|
+
return value; // will be replaced when the named key is visited
|
|
47
|
+
}
|
|
48
|
+
if (!bigIntKeys.has(key)) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
// Scalar number: use context.source to preserve exact digits.
|
|
53
|
+
if (typeof value === 'number' && (context === null || context === void 0 ? void 0 : context.source) != undefined) {
|
|
54
|
+
return BigInt(context.source);
|
|
55
|
+
}
|
|
56
|
+
/*
|
|
57
|
+
Array of numbers: apply the stashed sources. Convert on a copy and return it only if
|
|
58
|
+
all elements are converted successfully. This prevents mixed arrays on failure.
|
|
59
|
+
*/
|
|
60
|
+
if (Array.isArray(value)) {
|
|
61
|
+
var convertedArray = [...value];
|
|
62
|
+
var numericSources = pending.get(value) || [];
|
|
63
|
+
numericSources.forEach(_ref => {
|
|
64
|
+
var {
|
|
65
|
+
index,
|
|
66
|
+
src
|
|
67
|
+
} = _ref;
|
|
68
|
+
convertedArray[index] = BigInt(src);
|
|
69
|
+
});
|
|
70
|
+
return convertedArray;
|
|
71
|
+
}
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error("Error converting to BigInt:", e, "key:", key, "value:", value);
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
});
|
|
77
|
+
}
|