@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.
Files changed (66) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/admin/tabs/userData/roles/graph/RoleGraph.ts +2 -1
  3. package/appcontainer/AppContainerModel.ts +2 -1
  4. package/build/types/core/XH.d.ts +13 -0
  5. package/build/types/core/types/Types.d.ts +10 -0
  6. package/build/types/utils/js/LangUtils.d.ts +2 -3
  7. package/build/types/utils/js/index.d.ts +0 -2
  8. package/build/types/utils/{js → log}/LogUtils.d.ts +28 -11
  9. package/build/types/utils/log/index.d.ts +1 -0
  10. package/build/types/utils/version/index.d.ts +1 -0
  11. package/cmp/ag-grid/AgGrid.ts +1 -1
  12. package/cmp/chart/Chart.ts +2 -1
  13. package/cmp/chart/impl/ChartContextMenuItems.ts +1 -1
  14. package/cmp/grid/columns/Column.ts +2 -1
  15. package/cmp/grid/helpers/GridCountLabel.ts +2 -1
  16. package/cmp/grid/impl/ColumnWidthCalculator.ts +2 -1
  17. package/cmp/grid/impl/Utils.ts +2 -1
  18. package/cmp/relativetimestamp/RelativeTimestamp.ts +2 -1
  19. package/cmp/treemap/TreeMap.ts +2 -1
  20. package/core/HoistBase.ts +2 -3
  21. package/core/HoistBaseDecorators.ts +2 -1
  22. package/core/HoistComponent.ts +9 -6
  23. package/core/XH.ts +20 -0
  24. package/core/exception/ExceptionHandler.ts +3 -2
  25. package/core/load/LoadSupport.ts +3 -2
  26. package/core/persist/PersistenceProvider.ts +2 -1
  27. package/core/types/Types.ts +6 -0
  28. package/data/filter/Utils.ts +2 -1
  29. package/data/impl/RecordSet.ts +2 -1
  30. package/desktop/cmp/button/grid/ColAutosizeButton.ts +2 -1
  31. package/desktop/cmp/button/grid/ColChooserButton.ts +2 -1
  32. package/desktop/cmp/button/grid/ExpandToLevelButton.ts +2 -1
  33. package/desktop/cmp/button/grid/ExportButton.ts +2 -1
  34. package/desktop/cmp/button/panel/ModalToggleButton.ts +2 -1
  35. package/desktop/cmp/button/zoneGrid/ZoneMapperButton.ts +2 -1
  36. package/desktop/cmp/dash/container/impl/DashContainerUtils.ts +4 -3
  37. package/desktop/cmp/form/FormField.ts +2 -1
  38. package/desktop/cmp/grid/editors/BooleanEditor.ts +1 -1
  39. package/desktop/cmp/panel/Panel.ts +1 -1
  40. package/desktop/hooks/UseContextMenu.ts +1 -1
  41. package/inspector/instances/InstancesModel.ts +2 -2
  42. package/kit/ag-grid/index.ts +3 -2
  43. package/kit/highcharts/index.ts +3 -2
  44. package/mobile/cmp/button/grid/ColAutosizeButton.ts +2 -1
  45. package/mobile/cmp/button/grid/ColChooserButton.ts +2 -1
  46. package/mobile/cmp/button/grid/ExpandCollapseButton.ts +2 -1
  47. package/mobile/cmp/button/grid/ExpandToLevelButton.ts +2 -1
  48. package/mobile/cmp/button/zoneGrid/ZoneMapperButton.ts +2 -1
  49. package/mobile/cmp/panel/Panel.ts +1 -1
  50. package/mobx/overrides.ts +1 -1
  51. package/package.json +1 -1
  52. package/security/BaseOAuthClient.ts +2 -1
  53. package/security/msal/MsalClient.ts +2 -1
  54. package/svc/ChangelogService.ts +1 -1
  55. package/svc/EnvironmentService.ts +2 -1
  56. package/svc/FetchService.ts +1 -1
  57. package/tsconfig.tsbuildinfo +1 -1
  58. package/utils/async/Timer.ts +2 -1
  59. package/utils/js/Decorators.ts +1 -1
  60. package/utils/js/LangUtils.ts +3 -4
  61. package/utils/js/index.ts +0 -2
  62. package/utils/{js → log}/LogUtils.ts +85 -16
  63. package/utils/log/index.ts +8 -0
  64. package/utils/version/index.ts +8 -0
  65. /package/build/types/utils/{js → version}/VersionUtils.d.ts +0 -0
  66. /package/utils/{js → version}/VersionUtils.ts +0 -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.
@@ -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 labelling log message. */
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
- logWarn(warn, opts.source);
200
+ console.warn(warn, opts.source);
202
201
  _seenWarnings[warn] = true;
203
202
  }
204
203
  }
package/utils/js/index.ts CHANGED
@@ -7,7 +7,5 @@
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
- export * from './VersionUtils';
@@ -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 {intersperse} from './LangUtils';
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
- /** Object identifying the source of log statement. Typically, a javascript class */
12
- export type LogSource = string | {displayName: string} | {constructor: {name: string}};
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
- type LogLevel = 'error' | 'warn' | 'info' | 'debug';
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'));
@@ -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';
@@ -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 './VersionUtils';
File without changes