@xh/hoist 76.0.0-SNAPSHOT.1758209096583 → 76.0.0-SNAPSHOT.1758212424281

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/admin/tabs/userData/roles/graph/RoleGraph.ts +2 -1
  3. package/build/types/core/XH.d.ts +13 -0
  4. package/build/types/utils/js/LangUtils.d.ts +2 -2
  5. package/build/types/utils/js/index.d.ts +0 -1
  6. package/build/types/utils/{js → log}/LogUtils.d.ts +29 -2
  7. package/build/types/utils/log/index.d.ts +1 -0
  8. package/cmp/ag-grid/AgGrid.ts +1 -1
  9. package/cmp/chart/Chart.ts +2 -1
  10. package/cmp/chart/impl/ChartContextMenuItems.ts +1 -1
  11. package/cmp/grid/columns/Column.ts +2 -1
  12. package/cmp/grid/helpers/GridCountLabel.ts +2 -1
  13. package/cmp/grid/impl/ColumnWidthCalculator.ts +2 -1
  14. package/cmp/grid/impl/Utils.ts +2 -1
  15. package/cmp/relativetimestamp/RelativeTimestamp.ts +2 -1
  16. package/cmp/treemap/TreeMap.ts +2 -1
  17. package/core/HoistBase.ts +2 -3
  18. package/core/HoistBaseDecorators.ts +2 -1
  19. package/core/HoistComponent.ts +9 -6
  20. package/core/XH.ts +19 -0
  21. package/core/exception/ExceptionHandler.ts +3 -2
  22. package/core/load/LoadSupport.ts +3 -2
  23. package/core/persist/PersistenceProvider.ts +2 -1
  24. package/data/filter/Utils.ts +2 -1
  25. package/data/impl/RecordSet.ts +2 -1
  26. package/desktop/cmp/button/grid/ColAutosizeButton.ts +2 -1
  27. package/desktop/cmp/button/grid/ColChooserButton.ts +2 -1
  28. package/desktop/cmp/button/grid/ExpandToLevelButton.ts +2 -1
  29. package/desktop/cmp/button/grid/ExportButton.ts +2 -1
  30. package/desktop/cmp/button/panel/ModalToggleButton.ts +2 -1
  31. package/desktop/cmp/button/zoneGrid/ZoneMapperButton.ts +2 -1
  32. package/desktop/cmp/dash/container/impl/DashContainerUtils.ts +4 -3
  33. package/desktop/cmp/form/FormField.ts +2 -1
  34. package/desktop/cmp/grid/editors/BooleanEditor.ts +1 -1
  35. package/desktop/cmp/panel/Panel.ts +1 -1
  36. package/desktop/hooks/UseContextMenu.ts +1 -1
  37. package/inspector/instances/InstancesModel.ts +2 -2
  38. package/kit/ag-grid/index.ts +3 -2
  39. package/kit/highcharts/index.ts +3 -2
  40. package/mobile/cmp/button/grid/ColAutosizeButton.ts +2 -1
  41. package/mobile/cmp/button/grid/ColChooserButton.ts +2 -1
  42. package/mobile/cmp/button/grid/ExpandCollapseButton.ts +2 -1
  43. package/mobile/cmp/button/grid/ExpandToLevelButton.ts +2 -1
  44. package/mobile/cmp/button/zoneGrid/ZoneMapperButton.ts +2 -1
  45. package/mobile/cmp/panel/Panel.ts +1 -1
  46. package/mobx/overrides.ts +1 -1
  47. package/package.json +1 -1
  48. package/security/BaseOAuthClient.ts +2 -1
  49. package/security/msal/MsalClient.ts +2 -1
  50. package/svc/FetchService.ts +1 -1
  51. package/tsconfig.tsbuildinfo +1 -1
  52. package/utils/async/Timer.ts +2 -1
  53. package/utils/js/Decorators.ts +1 -1
  54. package/utils/js/LangUtils.ts +3 -3
  55. package/utils/js/index.ts +0 -1
  56. package/utils/{js → log}/LogUtils.ts +79 -12
  57. package/utils/log/index.ts +8 -0
@@ -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 {logError, logWarn, throwIf} from '@xh/hoist/utils/js';
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
  /**
@@ -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 './LogUtils';
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.
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import {PlainObject, Thunkable} from '@xh/hoist/core';
8
8
  import {Exception} from '@xh/hoist/core/exception/Exception';
9
- import {LogSource, logWarn} from '@xh/hoist/utils/js/LogUtils';
9
+ import {type LogSource} from '@xh/hoist/utils/log';
10
10
  import {
11
11
  flatMap,
12
12
  forOwn,
@@ -170,7 +170,7 @@ export interface APIWarnOptions {
170
170
  /** An additional message. Can contain suggestions for alternatives. */
171
171
  msg?: string;
172
172
 
173
- /** Source of message for labelling log message. */
173
+ /** Source of message for labeling log message. */
174
174
  source?: LogSource;
175
175
  }
176
176
 
@@ -198,7 +198,7 @@ export function apiDeprecated(name: string, opts: APIWarnOptions = {}) {
198
198
  msg = opts.msg ?? '',
199
199
  warn = `The use of '${name}' has been deprecated and will be removed in ${v}. ${msg}`;
200
200
  if (!_seenWarnings[warn]) {
201
- logWarn(warn, opts.source);
201
+ console.warn(warn, opts.source);
202
202
  _seenWarnings[warn] = true;
203
203
  }
204
204
  }
package/utils/js/index.ts CHANGED
@@ -7,7 +7,6 @@
7
7
  export * from './HtmlUtils';
8
8
  export * from './LangUtils';
9
9
  export * from './Decorators';
10
- export * from './LogUtils';
11
10
  export * from './DomUtils';
12
11
  export * from './TestUtils';
13
12
  export * from './VersionUtils';
@@ -6,11 +6,66 @@
6
6
  */
7
7
  import {Some} from '@xh/hoist/core';
8
8
  import {castArray, isString} from 'lodash';
9
- import {intersperse} from './LangUtils';
9
+ import store from 'store2';
10
+ import {intersperse} from '../js/LangUtils';
11
+
12
+ /**
13
+ * Utility functions providing managed, structured logging to Hoist apps.
14
+ *
15
+ * Essentially a wrapper around the browser console supporting logging levels, timing, and
16
+ * miscellaneous Hoist display conventions.
17
+ *
18
+ * Objects extending `HoistBase` need not import these functions directly, as they are available
19
+ * via delegates on `HoistBase`.
20
+ *
21
+ * Hoist sets its minimum severity level to 'info' by default. This prevents performance or
22
+ * memory impacts that might result from verbose debug logging. This can be adjusted by calling
23
+ * XH.logLevel from the console.
24
+ */
25
+
26
+ /** Severity Level for log statement */
27
+ export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
10
28
 
11
29
  /** Object identifying the source of log statement. Typically, a javascript class */
12
30
  export type LogSource = string | {displayName: string} | {constructor: {name: string}};
13
31
 
32
+ /**
33
+ * Current minimum severity for Hoist log utils (default 'info').
34
+ * Messages logged via managed Hoist log utils with lower severity will be ignored.
35
+ *
36
+ * @internal - use public `XH.logLevel`.
37
+ */
38
+ export function getLogLevel() {
39
+ try {
40
+ return _logLevel;
41
+ } catch (e) {
42
+ return 'info';
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Set the minimum severity for Hoist log utils until the page is refreshed. Optionally persist
48
+ * this adjustment to sessionStorage to maintain for the lifetime of the browser tab.
49
+ *
50
+ * @internal - use public `XH.setLogLevel()`.
51
+ */
52
+ export function setLogLevel(level: LogLevel, persistInSessionStorage: boolean = false) {
53
+ level = level.toLowerCase() as LogLevel;
54
+
55
+ const validLevels = ['error', 'warn', 'info', 'debug'];
56
+ if (!validLevels.includes(level)) {
57
+ console.error(`Ignored invalid log level '${level}' - must be one of ${validLevels}`);
58
+ return;
59
+ }
60
+ _logLevel = level;
61
+ if (persistInSessionStorage) {
62
+ store.session.set('xhLogLevel', level);
63
+ }
64
+ if (level != 'info') {
65
+ console.warn(`Client logging set to level '${level}'.`);
66
+ }
67
+ }
68
+
14
69
  /**
15
70
  * Time and log execution of a function to `console.info()`.
16
71
  *
@@ -73,19 +128,16 @@ export function logWarn(msgs: Some<unknown>, source?: LogSource) {
73
128
  return loggedDo(msgs, null, source, 'warn');
74
129
  }
75
130
 
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
131
  //----------------------------------
86
132
  // Implementation
87
133
  //----------------------------------
88
- function loggedDo<T>(messages: Some<unknown>, fn: () => T, source: LogSource, level: LogLevel) {
134
+ function loggedDo<T>(messages: Some<unknown>, fn: () => T, source: LogSource, level: LogLevel): T {
135
+ const _severity: Record<LogLevel, number> = {error: 3, warn: 2, info: 1, debug: 0};
136
+
137
+ if (_severity[level] < _severity[getLogLevel()]) {
138
+ return fn?.();
139
+ }
140
+
89
141
  let src = parseSource(source);
90
142
  let msgs = castArray(messages);
91
143
 
@@ -148,4 +200,19 @@ function writeLog(msgs: unknown[], src: string, level: LogLevel) {
148
200
  }
149
201
  }
150
202
 
151
- type LogLevel = 'error' | 'warn' | 'info' | 'debug';
203
+ /** Parse a LogSource in to a canonical string label. */
204
+ function parseSource(source: LogSource): string {
205
+ if (!source) return null;
206
+ if (isString(source)) return source;
207
+ if (source['displayName']) return source['displayName'];
208
+ if (source.constructor) return source.constructor.name;
209
+ return null;
210
+ }
211
+
212
+ //----------------------------------------------------------------
213
+ // Initialization + Level/Severity support.
214
+ // Initialize during parsing to make available immediately.
215
+ //----------------------------------------------------------------
216
+ let _logLevel: LogLevel = 'info';
217
+
218
+ setLogLevel(store.session.get('xhLogLevel', 'info'));
@@ -0,0 +1,8 @@
1
+ /*
2
+ * This file belongs to Hoist, an application development toolkit
3
+ * developed by Extremely Heavy Industries (www.xh.io | info@xh.io)
4
+ *
5
+ * Copyright © 2025 Extremely Heavy Industries Inc.
6
+ */
7
+
8
+ export * from './LogUtils';