@xh/hoist 76.0.0-SNAPSHOT.1758211176948 → 76.0.0-SNAPSHOT.1758215282397
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.
- package/CHANGELOG.md +7 -1
- package/admin/tabs/userData/roles/graph/RoleGraph.ts +2 -1
- package/appcontainer/AppContainerModel.ts +2 -1
- package/build/types/core/XH.d.ts +13 -0
- package/build/types/core/types/Types.d.ts +10 -0
- package/build/types/utils/js/LangUtils.d.ts +2 -3
- package/build/types/utils/js/index.d.ts +0 -2
- package/build/types/utils/{js → log}/LogUtils.d.ts +28 -11
- package/build/types/utils/log/index.d.ts +1 -0
- package/build/types/utils/version/index.d.ts +1 -0
- package/cmp/ag-grid/AgGrid.ts +1 -1
- package/cmp/chart/Chart.ts +2 -1
- package/cmp/chart/impl/ChartContextMenuItems.ts +1 -1
- package/cmp/grid/columns/Column.ts +2 -1
- package/cmp/grid/helpers/GridCountLabel.ts +2 -1
- package/cmp/grid/impl/ColumnWidthCalculator.ts +2 -1
- package/cmp/grid/impl/Utils.ts +2 -1
- package/cmp/relativetimestamp/RelativeTimestamp.ts +2 -1
- package/cmp/treemap/TreeMap.ts +2 -1
- package/core/HoistBase.ts +2 -3
- package/core/HoistBaseDecorators.ts +2 -1
- package/core/HoistComponent.ts +9 -6
- package/core/XH.ts +20 -0
- package/core/exception/ExceptionHandler.ts +3 -2
- package/core/load/LoadSupport.ts +3 -2
- package/core/persist/PersistenceProvider.ts +2 -1
- package/core/types/Types.ts +6 -0
- package/data/filter/Utils.ts +2 -1
- package/data/impl/RecordSet.ts +2 -1
- package/desktop/cmp/button/grid/ColAutosizeButton.ts +2 -1
- package/desktop/cmp/button/grid/ColChooserButton.ts +2 -1
- package/desktop/cmp/button/grid/ExpandToLevelButton.ts +2 -1
- package/desktop/cmp/button/grid/ExportButton.ts +2 -1
- package/desktop/cmp/button/panel/ModalToggleButton.ts +2 -1
- package/desktop/cmp/button/zoneGrid/ZoneMapperButton.ts +2 -1
- package/desktop/cmp/dash/container/impl/DashContainerUtils.ts +4 -3
- package/desktop/cmp/form/FormField.ts +2 -1
- package/desktop/cmp/grid/editors/BooleanEditor.ts +1 -1
- package/desktop/cmp/panel/Panel.ts +1 -1
- package/desktop/hooks/UseContextMenu.ts +1 -1
- package/inspector/instances/InstancesModel.ts +2 -2
- package/kit/ag-grid/index.ts +3 -2
- package/kit/highcharts/index.ts +3 -2
- package/mobile/cmp/button/grid/ColAutosizeButton.ts +2 -1
- package/mobile/cmp/button/grid/ColChooserButton.ts +2 -1
- package/mobile/cmp/button/grid/ExpandCollapseButton.ts +2 -1
- package/mobile/cmp/button/grid/ExpandToLevelButton.ts +2 -1
- package/mobile/cmp/button/zoneGrid/ZoneMapperButton.ts +2 -1
- package/mobile/cmp/panel/Panel.ts +1 -1
- package/mobx/overrides.ts +1 -1
- package/package.json +1 -1
- package/security/BaseOAuthClient.ts +2 -1
- package/security/msal/MsalClient.ts +2 -1
- package/svc/ChangelogService.ts +1 -1
- package/svc/EnvironmentService.ts +2 -1
- package/svc/FetchService.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/utils/async/Timer.ts +2 -1
- package/utils/js/Decorators.ts +1 -1
- package/utils/js/LangUtils.ts +3 -4
- package/utils/js/index.ts +0 -2
- package/utils/{js → log}/LogUtils.ts +85 -16
- package/utils/log/index.ts +8 -0
- package/utils/version/index.ts +8 -0
- /package/build/types/utils/{js → version}/VersionUtils.d.ts +0 -0
- /package/utils/{js → version}/VersionUtils.ts +0 -0
package/utils/async/Timer.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import {XH} from '@xh/hoist/core';
|
|
8
8
|
import {wait} from '@xh/hoist/promise';
|
|
9
9
|
import {MILLISECONDS, MINUTES, olderThan} from '@xh/hoist/utils/datetime';
|
|
10
|
-
import {
|
|
10
|
+
import {throwIf} from '@xh/hoist/utils/js';
|
|
11
|
+
import {logError, logWarn} from '@xh/hoist/utils/log';
|
|
11
12
|
import {isBoolean, isFinite, isFunction, isNil, isString, pull} from 'lodash';
|
|
12
13
|
|
|
13
14
|
/**
|
package/utils/js/Decorators.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {XH} from '@xh/hoist/core';
|
|
8
8
|
import {debounce, isFunction} from 'lodash';
|
|
9
9
|
import {getOrCreate, throwIf, warnIf} from './LangUtils';
|
|
10
|
-
import {withDebug, withInfo} from '
|
|
10
|
+
import {withDebug, withInfo} from '../log/LogUtils';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Decorates a class method so that it is debounced by the specified duration.
|
package/utils/js/LangUtils.ts
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2025 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {PlainObject, Thunkable} from '@xh/hoist/core';
|
|
7
|
+
import type {PlainObject, Thunkable, LogSource} from '@xh/hoist/core';
|
|
8
8
|
import {Exception} from '@xh/hoist/core/exception/Exception';
|
|
9
|
-
import {LogSource, logWarn} from '@xh/hoist/utils/js/LogUtils';
|
|
10
9
|
import {
|
|
11
10
|
flatMap,
|
|
12
11
|
forOwn,
|
|
@@ -170,7 +169,7 @@ export interface APIWarnOptions {
|
|
|
170
169
|
/** An additional message. Can contain suggestions for alternatives. */
|
|
171
170
|
msg?: string;
|
|
172
171
|
|
|
173
|
-
/** Source of message for
|
|
172
|
+
/** Source of message for labeling log message. */
|
|
174
173
|
source?: LogSource;
|
|
175
174
|
}
|
|
176
175
|
|
|
@@ -198,7 +197,7 @@ export function apiDeprecated(name: string, opts: APIWarnOptions = {}) {
|
|
|
198
197
|
msg = opts.msg ?? '',
|
|
199
198
|
warn = `The use of '${name}' has been deprecated and will be removed in ${v}. ${msg}`;
|
|
200
199
|
if (!_seenWarnings[warn]) {
|
|
201
|
-
|
|
200
|
+
console.warn(warn, opts.source);
|
|
202
201
|
_seenWarnings[warn] = true;
|
|
203
202
|
}
|
|
204
203
|
}
|
package/utils/js/index.ts
CHANGED
|
@@ -4,12 +4,60 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2025 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {Some} from '@xh/hoist/core';
|
|
8
|
-
import {castArray, isString} from 'lodash';
|
|
9
|
-
import
|
|
7
|
+
import type {Some, LogLevel, LogSource} from '@xh/hoist/core';
|
|
8
|
+
import {castArray, flatMap, isString} from 'lodash';
|
|
9
|
+
import store from 'store2';
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Utility functions providing managed, structured logging to Hoist apps.
|
|
13
|
+
*
|
|
14
|
+
* Essentially a wrapper around the browser console supporting logging levels, timing, and
|
|
15
|
+
* miscellaneous Hoist display conventions.
|
|
16
|
+
*
|
|
17
|
+
* Objects extending `HoistBase` need not import these functions directly, as they are available
|
|
18
|
+
* via delegates on `HoistBase`.
|
|
19
|
+
*
|
|
20
|
+
* Hoist sets its minimum severity level to 'info' by default. This prevents performance or
|
|
21
|
+
* memory impacts that might result from verbose debug logging. This can be adjusted by calling
|
|
22
|
+
* XH.logLevel from the console.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Current minimum severity for Hoist log utils (default 'info').
|
|
27
|
+
* Messages logged via managed Hoist log utils with lower severity will be ignored.
|
|
28
|
+
*
|
|
29
|
+
* @internal - use public `XH.logLevel`.
|
|
30
|
+
*/
|
|
31
|
+
export function getLogLevel() {
|
|
32
|
+
try {
|
|
33
|
+
return _logLevel;
|
|
34
|
+
} catch (e) {
|
|
35
|
+
return 'info';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Set the minimum severity for Hoist log utils until the page is refreshed. Optionally persist
|
|
41
|
+
* this adjustment to sessionStorage to maintain for the lifetime of the browser tab.
|
|
42
|
+
*
|
|
43
|
+
* @internal - use public `XH.setLogLevel()`.
|
|
44
|
+
*/
|
|
45
|
+
export function setLogLevel(level: LogLevel, persistInSessionStorage: boolean = false) {
|
|
46
|
+
level = level.toLowerCase() as LogLevel;
|
|
47
|
+
|
|
48
|
+
const validLevels = ['error', 'warn', 'info', 'debug'];
|
|
49
|
+
if (!validLevels.includes(level)) {
|
|
50
|
+
console.error(`Ignored invalid log level '${level}' - must be one of ${validLevels}`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
_logLevel = level;
|
|
54
|
+
if (persistInSessionStorage) {
|
|
55
|
+
store.session.set('xhLogLevel', level);
|
|
56
|
+
}
|
|
57
|
+
if (level != 'info') {
|
|
58
|
+
console.warn(`Client logging set to level '${level}'.`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
13
61
|
|
|
14
62
|
/**
|
|
15
63
|
* Time and log execution of a function to `console.info()`.
|
|
@@ -73,19 +121,16 @@ export function logWarn(msgs: Some<unknown>, source?: LogSource) {
|
|
|
73
121
|
return loggedDo(msgs, null, source, 'warn');
|
|
74
122
|
}
|
|
75
123
|
|
|
76
|
-
/** Parse a LogSource in to a canonical string label. */
|
|
77
|
-
export function parseSource(source: LogSource): string {
|
|
78
|
-
if (!source) return null;
|
|
79
|
-
if (isString(source)) return source;
|
|
80
|
-
if (source['displayName']) return source['displayName'];
|
|
81
|
-
if (source.constructor) return source.constructor.name;
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
124
|
//----------------------------------
|
|
86
125
|
// Implementation
|
|
87
126
|
//----------------------------------
|
|
88
|
-
function loggedDo<T>(messages: Some<unknown>, fn: () => T, source: LogSource, level: LogLevel) {
|
|
127
|
+
function loggedDo<T>(messages: Some<unknown>, fn: () => T, source: LogSource, level: LogLevel): T {
|
|
128
|
+
const _severity: Record<LogLevel, number> = {error: 3, warn: 2, info: 1, debug: 0};
|
|
129
|
+
|
|
130
|
+
if (_severity[level] < _severity[getLogLevel()]) {
|
|
131
|
+
return fn?.();
|
|
132
|
+
}
|
|
133
|
+
|
|
89
134
|
let src = parseSource(source);
|
|
90
135
|
let msgs = castArray(messages);
|
|
91
136
|
|
|
@@ -148,4 +193,28 @@ function writeLog(msgs: unknown[], src: string, level: LogLevel) {
|
|
|
148
193
|
}
|
|
149
194
|
}
|
|
150
195
|
|
|
151
|
-
|
|
196
|
+
/** Parse a LogSource in to a canonical string label. */
|
|
197
|
+
function parseSource(source: LogSource): string {
|
|
198
|
+
if (!source) return null;
|
|
199
|
+
if (isString(source)) return source;
|
|
200
|
+
if (source['displayName']) return source['displayName'];
|
|
201
|
+
if (source.constructor) return source.constructor.name;
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Intersperse a separator between each item in an array.
|
|
207
|
+
* Same method as in LangUtils, but duplicated here to avoid circular dependency.
|
|
208
|
+
*/
|
|
209
|
+
function intersperse<T>(arr: T[], separator: T): T[] {
|
|
210
|
+
return flatMap(arr, (it, idx) => {
|
|
211
|
+
return idx > 0 ? [separator, it] : [it];
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
//----------------------------------------------------------------
|
|
215
|
+
// Initialization + Level/Severity support.
|
|
216
|
+
// Initialize during parsing to make available immediately.
|
|
217
|
+
//----------------------------------------------------------------
|
|
218
|
+
let _logLevel: LogLevel = 'info';
|
|
219
|
+
|
|
220
|
+
setLogLevel(store.session.get('xhLogLevel', 'info'));
|
|
File without changes
|
|
File without changes
|