From d706700faa750d9a55ea283580b19542149bddec Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Wed, 17 Sep 2025 16:20:46 -0400 Subject: [PATCH 01/12] fix log imports in core files --- core/HoistComponent.ts | 3 ++- core/exception/ExceptionHandler.ts | 3 ++- core/load/LoadSupport.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/HoistComponent.ts b/core/HoistComponent.ts index 073048351..1b086ea52 100644 --- a/core/HoistComponent.ts +++ b/core/HoistComponent.ts @@ -25,7 +25,8 @@ import { formatSelector, HoistModel } from './model'; -import {logError, throwIf, warnIf, withDefault} from '@xh/hoist/utils/js'; +import {throwIf, warnIf, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/js/LogUtils'; import {getLayoutProps, useOnMount, useOnUnmount} from '@xh/hoist/utils/react'; import classNames from 'classnames'; import {isFunction, isPlainObject, isObject} from 'lodash'; diff --git a/core/exception/ExceptionHandler.ts b/core/exception/ExceptionHandler.ts index c48c60d40..a0b1c0085 100644 --- a/core/exception/ExceptionHandler.ts +++ b/core/exception/ExceptionHandler.ts @@ -6,7 +6,8 @@ */ import {Exception} from './Exception'; import {fragment, span} from '@xh/hoist/cmp/layout'; -import {logDebug, logError, logWarn, stripTags} from '@xh/hoist/utils/js'; +import {stripTags} from '@xh/hoist/utils/js'; +import {logDebug, logError, logWarn} from '@xh/hoist/utils/js/LogUtils'; import {Icon} from '@xh/hoist/icon'; import {forOwn, has, isArray, isNil, isObject, omitBy, pick, set} from 'lodash'; import {HoistException, PlainObject, XH} from '../'; diff --git a/core/load/LoadSupport.ts b/core/load/LoadSupport.ts index 8d10552f4..995c46bb9 100644 --- a/core/load/LoadSupport.ts +++ b/core/load/LoadSupport.ts @@ -14,7 +14,8 @@ import { } from '../'; import {LoadSpec, Loadable} from './'; import {makeObservable, observable, runInAction} from '@xh/hoist/mobx'; -import {logDebug, logError, throwIf} from '@xh/hoist/utils/js'; +import {throwIf} from '@xh/hoist/utils/js'; +import {logDebug, logError} from '@xh/hoist/utils/js/LogUtils'; import {isPlainObject, pull} from 'lodash'; /** From 5a9b3cce39d2786ecac061b97a303183bf7d40cd Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Wed, 17 Sep 2025 18:16:36 -0400 Subject: [PATCH 02/12] move log fns to utils/log/ --- admin/tabs/userData/roles/graph/RoleGraph.ts | 3 ++- cmp/ag-grid/AgGrid.ts | 2 +- cmp/chart/Chart.ts | 3 ++- cmp/chart/impl/ChartContextMenuItems.ts | 2 +- cmp/grid/columns/Column.ts | 3 ++- cmp/grid/helpers/GridCountLabel.ts | 3 ++- cmp/grid/impl/ColumnWidthCalculator.ts | 3 ++- cmp/grid/impl/Utils.ts | 2 +- cmp/relativetimestamp/RelativeTimestamp.ts | 3 ++- cmp/treemap/TreeMap.ts | 3 ++- core/HoistBase.ts | 12 ++---------- core/HoistBaseDecorators.ts | 3 ++- core/HoistComponent.ts | 2 +- core/XH.ts | 2 +- core/exception/ExceptionHandler.ts | 2 +- core/load/LoadSupport.ts | 2 +- core/persist/PersistenceProvider.ts | 3 ++- data/filter/Utils.ts | 2 +- data/impl/RecordSet.ts | 3 ++- desktop/cmp/button/grid/ColAutosizeButton.ts | 3 ++- desktop/cmp/button/grid/ColChooserButton.ts | 3 ++- desktop/cmp/button/grid/ExpandToLevelButton.ts | 3 ++- desktop/cmp/button/grid/ExportButton.ts | 3 ++- desktop/cmp/button/panel/ModalToggleButton.ts | 3 ++- desktop/cmp/button/zoneGrid/ZoneMapperButton.ts | 3 ++- .../cmp/dash/container/impl/DashContainerUtils.ts | 3 ++- desktop/cmp/form/FormField.ts | 3 ++- desktop/cmp/grid/editors/BooleanEditor.ts | 2 +- desktop/cmp/panel/Panel.ts | 2 +- desktop/hooks/UseContextMenu.ts | 2 +- kit/ag-grid/index.ts | 3 ++- kit/highcharts/index.ts | 3 ++- mobile/cmp/button/grid/ColAutosizeButton.ts | 3 ++- mobile/cmp/button/grid/ColChooserButton.ts | 3 ++- mobile/cmp/button/grid/ExpandCollapseButton.ts | 3 ++- mobile/cmp/button/grid/ExpandToLevelButton.ts | 3 ++- mobile/cmp/button/zoneGrid/ZoneMapperButton.ts | 3 ++- mobile/cmp/panel/Panel.ts | 2 +- mobx/overrides.ts | 2 +- security/BaseOAuthClient.ts | 3 ++- security/msal/MsalClient.ts | 3 ++- utils/async/Timer.ts | 3 ++- utils/js/Decorators.ts | 2 +- utils/js/LangUtils.ts | 2 +- utils/js/index.ts | 1 - utils/{js => log}/LogUtils.ts | 2 +- utils/log/index.ts | 8 ++++++++ 47 files changed, 82 insertions(+), 55 deletions(-) rename utils/{js => log}/LogUtils.ts (99%) create mode 100644 utils/log/index.ts diff --git a/admin/tabs/userData/roles/graph/RoleGraph.ts b/admin/tabs/userData/roles/graph/RoleGraph.ts index 302c55b49..a391fb62f 100644 --- a/admin/tabs/userData/roles/graph/RoleGraph.ts +++ b/admin/tabs/userData/roles/graph/RoleGraph.ts @@ -14,7 +14,8 @@ import {panel} from '@xh/hoist/desktop/cmp/panel'; import {toolbar} from '@xh/hoist/desktop/cmp/toolbar'; import {Icon} from '@xh/hoist/icon'; import {Highcharts} from '@xh/hoist/kit/highcharts'; -import {logError, pluralize} from '@xh/hoist/utils/js'; +import {pluralize} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; import {isEmpty} from 'lodash'; import {RoleModel} from '../RoleModel'; import {RoleGraphModel} from './RoleGraphModel'; diff --git a/cmp/ag-grid/AgGrid.ts b/cmp/ag-grid/AgGrid.ts index 6d2cd0be3..6fbd645ac 100644 --- a/cmp/ag-grid/AgGrid.ts +++ b/cmp/ag-grid/AgGrid.ts @@ -18,7 +18,7 @@ import { XH } from '@xh/hoist/core'; import {AgGridReact, GridOptions} from '@xh/hoist/kit/ag-grid'; -import {logError} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; import {splitLayoutProps} from '@xh/hoist/utils/react'; import classNames from 'classnames'; import {isNil} from 'lodash'; diff --git a/cmp/chart/Chart.ts b/cmp/chart/Chart.ts index 78f240610..8922f96fd 100644 --- a/cmp/chart/Chart.ts +++ b/cmp/chart/Chart.ts @@ -21,7 +21,8 @@ import { import {useContextMenu} from '@xh/hoist/dynamics/desktop'; import {Highcharts} from '@xh/hoist/kit/highcharts'; import {runInAction} from '@xh/hoist/mobx'; -import {logError, mergeDeep} from '@xh/hoist/utils/js'; +import {mergeDeep} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; import { createObservableRef, getLayoutProps, diff --git a/cmp/chart/impl/ChartContextMenuItems.ts b/cmp/chart/impl/ChartContextMenuItems.ts index 0458d1dfe..ece3903a0 100644 --- a/cmp/chart/impl/ChartContextMenuItems.ts +++ b/cmp/chart/impl/ChartContextMenuItems.ts @@ -5,7 +5,7 @@ * Copyright © 2025 Extremely Heavy Industries Inc. */ import type {ChartMenuContext, ChartMenuToken} from '@xh/hoist/cmp/chart/Types'; -import {logWarn} from '@xh/hoist/utils/js'; +import {logWarn} from '@xh/hoist/utils/log'; import {cloneDeep, isEmpty, isString} from 'lodash'; import {ChartModel} from '@xh/hoist/cmp/chart'; import {isMenuItem, type MenuItem, type MenuItemLike} from '@xh/hoist/core'; diff --git a/cmp/grid/columns/Column.ts b/cmp/grid/columns/Column.ts index ca878ece4..449c7bd4b 100644 --- a/cmp/grid/columns/Column.ts +++ b/cmp/grid/columns/Column.ts @@ -15,7 +15,8 @@ import { RecordActionSpec, StoreRecord } from '@xh/hoist/data'; -import {logDebug, logWarn, throwIf, warnIf, withDefault} from '@xh/hoist/utils/js'; +import {logDebug, logWarn} from '@xh/hoist/utils/log'; +import {throwIf, warnIf, withDefault} from '@xh/hoist/utils/js'; import classNames from 'classnames'; import { castArray, diff --git a/cmp/grid/helpers/GridCountLabel.ts b/cmp/grid/helpers/GridCountLabel.ts index 5be21dca7..1b1efc4c1 100644 --- a/cmp/grid/helpers/GridCountLabel.ts +++ b/cmp/grid/helpers/GridCountLabel.ts @@ -7,7 +7,8 @@ import {box} from '@xh/hoist/cmp/layout'; import {BoxProps, hoistCmp, HoistProps, useContextModel} from '@xh/hoist/core'; import {fmtNumber} from '@xh/hoist/format'; -import {logError, pluralize, singularize, withDefault} from '@xh/hoist/utils/js'; +import {pluralize, singularize, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; import {GridModel} from '../GridModel'; export interface GridCountLabelProps extends HoistProps, BoxProps { diff --git a/cmp/grid/impl/ColumnWidthCalculator.ts b/cmp/grid/impl/ColumnWidthCalculator.ts index 98774587e..4576d34a3 100644 --- a/cmp/grid/impl/ColumnWidthCalculator.ts +++ b/cmp/grid/impl/ColumnWidthCalculator.ts @@ -9,7 +9,8 @@ import {GridAutosizeOptions} from '@xh/hoist/cmp/grid/GridAutosizeOptions'; import {XH} from '@xh/hoist/core'; import {CompoundFilter, FieldFilter, Filter, StoreRecord} from '@xh/hoist/data'; import {forEachAsync} from '@xh/hoist/utils/async'; -import {logWarn, stripTags} from '@xh/hoist/utils/js'; +import {logWarn} from '@xh/hoist/utils/log'; +import {stripTags} from '@xh/hoist/utils/js'; import { forOwn, groupBy, diff --git a/cmp/grid/impl/Utils.ts b/cmp/grid/impl/Utils.ts index bf5c6a3f4..1f6f565e2 100644 --- a/cmp/grid/impl/Utils.ts +++ b/cmp/grid/impl/Utils.ts @@ -6,7 +6,7 @@ */ import {Column, ColumnGroup, ColumnRenderer, GroupRowRenderer} from '@xh/hoist/cmp/grid'; import {HeaderClassParams} from '@xh/hoist/kit/ag-grid'; -import {logWarn} from '@xh/hoist/utils/js'; +import {logWarn} from '@xh/hoist/utils/log'; import {castArray, isFunction} from 'lodash'; /** @internal */ diff --git a/cmp/relativetimestamp/RelativeTimestamp.ts b/cmp/relativetimestamp/RelativeTimestamp.ts index 38bc63cd0..ef04aa8a2 100644 --- a/cmp/relativetimestamp/RelativeTimestamp.ts +++ b/cmp/relativetimestamp/RelativeTimestamp.ts @@ -21,7 +21,8 @@ import {fmtCompactDate, fmtDateTime} from '@xh/hoist/format'; import {action, computed, makeObservable, observable} from '@xh/hoist/mobx'; import {Timer} from '@xh/hoist/utils/async'; import {DAYS, HOURS, LocalDate, SECONDS} from '@xh/hoist/utils/datetime'; -import {apiDeprecated, logWarn, withDefault} from '@xh/hoist/utils/js'; +import {logWarn} from '@xh/hoist/utils/log'; +import {apiDeprecated, withDefault} from '@xh/hoist/utils/js'; interface RelativeTimestampProps extends HoistProps, BoxProps, RelativeTimestampOptions { /** diff --git a/cmp/treemap/TreeMap.ts b/cmp/treemap/TreeMap.ts index f948aa366..63625d3f3 100644 --- a/cmp/treemap/TreeMap.ts +++ b/cmp/treemap/TreeMap.ts @@ -21,7 +21,8 @@ import {errorMessage} from '@xh/hoist/cmp/error'; import {mask} from '@xh/hoist/cmp/mask'; import {Highcharts} from '@xh/hoist/kit/highcharts'; import {wait} from '@xh/hoist/promise'; -import {logError, logWithDebug} from '@xh/hoist/utils/js'; +import {logWithDebug} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; import { createObservableRef, getLayoutProps, diff --git a/core/HoistBase.ts b/core/HoistBase.ts index 88dcd9ec3..ae7a4255c 100644 --- a/core/HoistBase.ts +++ b/core/HoistBase.ts @@ -13,16 +13,8 @@ import { runInAction, when as mobxWhen } from '@xh/hoist/mobx'; -import { - getOrCreate, - logDebug, - logError, - logInfo, - logWarn, - throwIf, - withDebug, - withInfo -} from '@xh/hoist/utils/js'; +import {getOrCreate, throwIf} from '@xh/hoist/utils/js'; +import {logDebug, logError, logInfo, logWarn, withDebug, withInfo} from '@xh/hoist/utils/log'; import { debounce as lodashDebounce, isFunction, diff --git a/core/HoistBaseDecorators.ts b/core/HoistBaseDecorators.ts index 711f70045..4dac55d5d 100644 --- a/core/HoistBaseDecorators.ts +++ b/core/HoistBaseDecorators.ts @@ -6,7 +6,8 @@ */ import {wait} from '@xh/hoist/promise'; import {observable} from 'mobx'; -import {logError, throwIf} from '../utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {throwIf} from '../utils/js'; import {HoistBaseClass, PersistableState, PersistenceProvider, PersistOptions} from './'; /** diff --git a/core/HoistComponent.ts b/core/HoistComponent.ts index 1b086ea52..e80477ec0 100644 --- a/core/HoistComponent.ts +++ b/core/HoistComponent.ts @@ -26,7 +26,7 @@ import { HoistModel } from './model'; import {throwIf, warnIf, withDefault} from '@xh/hoist/utils/js'; -import {logError} from '@xh/hoist/utils/js/LogUtils'; +import {logError} from '@xh/hoist/utils/log'; import {getLayoutProps, useOnMount, useOnUnmount} from '@xh/hoist/utils/react'; import classNames from 'classnames'; import {isFunction, isPlainObject, isObject} from 'lodash'; diff --git a/core/XH.ts b/core/XH.ts index c6a1a306c..c93fcbbfa 100644 --- a/core/XH.ts +++ b/core/XH.ts @@ -31,7 +31,7 @@ import { WebSocketService, ClientHealthService } from '@xh/hoist/svc'; -import {getLogLevel, setLogLevel, LogLevel} from '@xh/hoist/utils/js/LogUtils'; +import {getLogLevel, setLogLevel, type LogLevel} from '@xh/hoist/utils/log'; import {camelCase, flatten, isString, uniqueId} from 'lodash'; import {Router, State} from 'router5'; import {CancelFn} from 'router5/types/types/base'; diff --git a/core/exception/ExceptionHandler.ts b/core/exception/ExceptionHandler.ts index a0b1c0085..577facd8c 100644 --- a/core/exception/ExceptionHandler.ts +++ b/core/exception/ExceptionHandler.ts @@ -7,7 +7,7 @@ import {Exception} from './Exception'; import {fragment, span} from '@xh/hoist/cmp/layout'; import {stripTags} from '@xh/hoist/utils/js'; -import {logDebug, logError, logWarn} from '@xh/hoist/utils/js/LogUtils'; +import {logDebug, logError, logWarn} from '@xh/hoist/utils/log'; import {Icon} from '@xh/hoist/icon'; import {forOwn, has, isArray, isNil, isObject, omitBy, pick, set} from 'lodash'; import {HoistException, PlainObject, XH} from '../'; diff --git a/core/load/LoadSupport.ts b/core/load/LoadSupport.ts index 995c46bb9..38e9251e1 100644 --- a/core/load/LoadSupport.ts +++ b/core/load/LoadSupport.ts @@ -15,7 +15,7 @@ import { import {LoadSpec, Loadable} from './'; import {makeObservable, observable, runInAction} from '@xh/hoist/mobx'; import {throwIf} from '@xh/hoist/utils/js'; -import {logDebug, logError} from '@xh/hoist/utils/js/LogUtils'; +import {logDebug, logError} from '@xh/hoist/utils/log'; import {isPlainObject, pull} from 'lodash'; /** diff --git a/core/persist/PersistenceProvider.ts b/core/persist/PersistenceProvider.ts index d693024cb..8a613f88e 100644 --- a/core/persist/PersistenceProvider.ts +++ b/core/persist/PersistenceProvider.ts @@ -6,7 +6,8 @@ */ import {olderThan} from '@xh/hoist/utils/datetime'; -import {logDebug, logError, throwIf} from '@xh/hoist/utils/js'; +import {logDebug, logError} from '@xh/hoist/utils/log'; +import {throwIf} from '@xh/hoist/utils/js'; import { cloneDeep, compact, diff --git a/data/filter/Utils.ts b/data/filter/Utils.ts index b8246f186..bae4f1eda 100644 --- a/data/filter/Utils.ts +++ b/data/filter/Utils.ts @@ -7,7 +7,7 @@ import {Some} from '@xh/hoist/core'; import {CompoundFilter, FunctionFilter} from '@xh/hoist/data'; -import {logError} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; import {castArray, flatMap, groupBy, isArray, isFunction} from 'lodash'; import {FieldFilter} from './FieldFilter'; import {Filter} from './Filter'; diff --git a/data/impl/RecordSet.ts b/data/impl/RecordSet.ts index 7d732269c..d92664cd5 100644 --- a/data/impl/RecordSet.ts +++ b/data/impl/RecordSet.ts @@ -6,7 +6,8 @@ */ import equal from 'fast-deep-equal'; -import {logWarn, throwIf} from '@xh/hoist/utils/js'; +import {logWarn} from '@xh/hoist/utils/log'; +import {throwIf} from '@xh/hoist/utils/js'; import {maxBy, isNil} from 'lodash'; import {StoreRecord, StoreRecordId} from '../StoreRecord'; import {Store} from '../Store'; diff --git a/desktop/cmp/button/grid/ColAutosizeButton.ts b/desktop/cmp/button/grid/ColAutosizeButton.ts index 18a0564d5..78d746dd0 100644 --- a/desktop/cmp/button/grid/ColAutosizeButton.ts +++ b/desktop/cmp/button/grid/ColAutosizeButton.ts @@ -8,7 +8,8 @@ import {GridAutosizeOptions, GridModel} from '@xh/hoist/cmp/grid'; import {hoistCmp, useContextModel} from '@xh/hoist/core'; import '@xh/hoist/desktop/register'; import {Icon} from '@xh/hoist/icon'; -import {logError, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {withDefault} from '@xh/hoist/utils/js'; import {button, ButtonProps} from '../Button'; export interface ColAutosizeButtonProps extends ButtonProps { diff --git a/desktop/cmp/button/grid/ColChooserButton.ts b/desktop/cmp/button/grid/ColChooserButton.ts index cbb467443..04e369e78 100644 --- a/desktop/cmp/button/grid/ColChooserButton.ts +++ b/desktop/cmp/button/grid/ColChooserButton.ts @@ -12,7 +12,8 @@ import {ColChooserModel} from '@xh/hoist/desktop/cmp/grid/impl/colchooser/ColCho import '@xh/hoist/desktop/register'; import {Icon} from '@xh/hoist/icon'; import {popover, Position} from '@xh/hoist/kit/blueprint'; -import {logError, stopPropagation, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {stopPropagation, withDefault} from '@xh/hoist/utils/js'; import {button, ButtonProps} from '../Button'; export interface ColChooserButtonProps extends ButtonProps { diff --git a/desktop/cmp/button/grid/ExpandToLevelButton.ts b/desktop/cmp/button/grid/ExpandToLevelButton.ts index 7d70f6c79..cd2afb3a5 100644 --- a/desktop/cmp/button/grid/ExpandToLevelButton.ts +++ b/desktop/cmp/button/grid/ExpandToLevelButton.ts @@ -11,7 +11,8 @@ import '@xh/hoist/desktop/register'; import {Icon} from '@xh/hoist/icon'; import {menu, popover, Position} from '@xh/hoist/kit/blueprint'; import {parseMenuItems} from '@xh/hoist/utils/impl'; -import {logError, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {withDefault} from '@xh/hoist/utils/js'; import {ReactNode} from 'react'; import {button, ButtonProps} from '../Button'; diff --git a/desktop/cmp/button/grid/ExportButton.ts b/desktop/cmp/button/grid/ExportButton.ts index 7c0def2fe..909683773 100644 --- a/desktop/cmp/button/grid/ExportButton.ts +++ b/desktop/cmp/button/grid/ExportButton.ts @@ -9,7 +9,8 @@ import {hoistCmp, useContextModel} from '@xh/hoist/core'; import '@xh/hoist/desktop/register'; import {Icon} from '@xh/hoist/icon'; import {ExportOptions} from '@xh/hoist/svc'; -import {logError, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {withDefault} from '@xh/hoist/utils/js'; import {button, ButtonProps} from '../Button'; export interface ExportButtonProps extends ButtonProps { diff --git a/desktop/cmp/button/panel/ModalToggleButton.ts b/desktop/cmp/button/panel/ModalToggleButton.ts index e30d94f2b..9c35f7098 100644 --- a/desktop/cmp/button/panel/ModalToggleButton.ts +++ b/desktop/cmp/button/panel/ModalToggleButton.ts @@ -9,7 +9,8 @@ import {button, ButtonProps} from '@xh/hoist/desktop/cmp/button/Button'; import {PanelModel} from '@xh/hoist/desktop/cmp/panel'; import '@xh/hoist/desktop/register'; import {Icon} from '@xh/hoist/icon'; -import {logError, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {withDefault} from '@xh/hoist/utils/js'; export interface ModalToggleButtonProps extends ButtonProps { panelModel?: PanelModel; diff --git a/desktop/cmp/button/zoneGrid/ZoneMapperButton.ts b/desktop/cmp/button/zoneGrid/ZoneMapperButton.ts index 302d3c432..cee51438c 100644 --- a/desktop/cmp/button/zoneGrid/ZoneMapperButton.ts +++ b/desktop/cmp/button/zoneGrid/ZoneMapperButton.ts @@ -12,7 +12,8 @@ import {ZoneMapperModel} from '@xh/hoist/cmp/zoneGrid/impl/ZoneMapperModel'; import {zoneMapper} from '@xh/hoist/desktop/cmp/zoneGrid/impl/ZoneMapper'; import {Icon} from '@xh/hoist/icon'; import {popover, Position} from '@xh/hoist/kit/blueprint'; -import {logError, stopPropagation, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {stopPropagation, withDefault} from '@xh/hoist/utils/js'; import {button, ButtonProps} from '../Button'; export interface ZoneMapperButtonProps extends ButtonProps { diff --git a/desktop/cmp/dash/container/impl/DashContainerUtils.ts b/desktop/cmp/dash/container/impl/DashContainerUtils.ts index 797b4fcb8..2438e3378 100644 --- a/desktop/cmp/dash/container/impl/DashContainerUtils.ts +++ b/desktop/cmp/dash/container/impl/DashContainerUtils.ts @@ -7,7 +7,8 @@ import {PlainObject} from '@xh/hoist/core'; import {DashContainerModel} from '@xh/hoist/desktop/cmp/dash'; import {serializeIcon} from '@xh/hoist/icon'; -import {logDebug, throwIf} from '@xh/hoist/utils/js'; +import {logDebug} from '@xh/hoist/utils/log'; +import {throwIf} from '@xh/hoist/utils/js'; import {isArray, isEmpty, isFinite, isNil, isPlainObject, isString, round} from 'lodash'; import {DashContainerViewSpec} from '../DashContainerViewSpec'; import GoldenLayout, {ContentItem} from 'golden-layout'; diff --git a/desktop/cmp/form/FormField.ts b/desktop/cmp/form/FormField.ts index d1c345bf2..bb21aa8ba 100644 --- a/desktop/cmp/form/FormField.ts +++ b/desktop/cmp/form/FormField.ts @@ -23,7 +23,8 @@ import {fmtDate, fmtDateTime, fmtJson, fmtNumber} from '@xh/hoist/format'; import {Icon} from '@xh/hoist/icon'; import {tooltip} from '@xh/hoist/kit/blueprint'; import {isLocalDate} from '@xh/hoist/utils/datetime'; -import {errorIf, getTestId, logWarn, TEST_ID, throwIf, withDefault} from '@xh/hoist/utils/js'; +import {logWarn} from '@xh/hoist/utils/log'; +import {errorIf, getTestId, TEST_ID, throwIf, withDefault} from '@xh/hoist/utils/js'; import {getLayoutProps, getReactElementName, useOnMount, useOnUnmount} from '@xh/hoist/utils/react'; import classNames from 'classnames'; import {isBoolean, isDate, isEmpty, isFinite, isNil, isUndefined, kebabCase} from 'lodash'; diff --git a/desktop/cmp/grid/editors/BooleanEditor.ts b/desktop/cmp/grid/editors/BooleanEditor.ts index 937f7e839..4b0f678bf 100644 --- a/desktop/cmp/grid/editors/BooleanEditor.ts +++ b/desktop/cmp/grid/editors/BooleanEditor.ts @@ -12,7 +12,7 @@ import '@xh/hoist/desktop/register'; import {EditorProps} from './EditorProps'; import './Editors.scss'; import {useInlineEditorModel} from './impl/InlineEditorModel'; -import {logWarn} from '@xh/hoist/utils/js'; +import {logWarn} from '@xh/hoist/utils/log'; export interface BooleanEditorProps extends EditorProps { /** diff --git a/desktop/cmp/panel/Panel.ts b/desktop/cmp/panel/Panel.ts index 216dc0130..0702fbb5a 100644 --- a/desktop/cmp/panel/Panel.ts +++ b/desktop/cmp/panel/Panel.ts @@ -24,7 +24,7 @@ import {toolbar} from '@xh/hoist/desktop/cmp/toolbar'; import {useContextMenu, useHotkeys} from '@xh/hoist/desktop/hooks'; import '@xh/hoist/desktop/register'; import {HotkeyConfig} from '@xh/hoist/kit/blueprint'; -import {logWarn} from '@xh/hoist/utils/js'; +import {logWarn} from '@xh/hoist/utils/log'; import {splitLayoutProps} from '@xh/hoist/utils/react'; import {castArray, omitBy} from 'lodash'; import {Children, isValidElement, ReactElement, ReactNode, useLayoutEffect, useRef} from 'react'; diff --git a/desktop/hooks/UseContextMenu.ts b/desktop/hooks/UseContextMenu.ts index 647d299c8..a247d5e91 100644 --- a/desktop/hooks/UseContextMenu.ts +++ b/desktop/hooks/UseContextMenu.ts @@ -7,7 +7,7 @@ import type {ContextMenuSpec} from '@xh/hoist/core'; import {contextMenu} from '@xh/hoist/desktop/cmp/contextmenu/ContextMenu'; import {showContextMenu} from '@xh/hoist/kit/blueprint'; -import {logError} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; import {isArray, isEmpty, isFunction, isUndefined} from 'lodash'; import {cloneElement, isValidElement, MouseEvent, ReactElement} from 'react'; diff --git a/kit/ag-grid/index.ts b/kit/ag-grid/index.ts index 596c9aaf8..67d752860 100644 --- a/kit/ag-grid/index.ts +++ b/kit/ag-grid/index.ts @@ -5,7 +5,8 @@ * Copyright © 2025 Extremely Heavy Industries Inc. */ -import {checkVersion, logError} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {checkVersion} from '@xh/hoist/utils/js'; /** * The exports below are ag-Grid components provided at runtime by applications. diff --git a/kit/highcharts/index.ts b/kit/highcharts/index.ts index 9c0616881..647c50eca 100644 --- a/kit/highcharts/index.ts +++ b/kit/highcharts/index.ts @@ -5,7 +5,8 @@ * Copyright © 2025 Extremely Heavy Industries Inc. */ -import {checkVersion, logError} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {checkVersion} from '@xh/hoist/utils/js'; export let Highcharts = null; diff --git a/mobile/cmp/button/grid/ColAutosizeButton.ts b/mobile/cmp/button/grid/ColAutosizeButton.ts index e3dc4d38c..5989513bc 100644 --- a/mobile/cmp/button/grid/ColAutosizeButton.ts +++ b/mobile/cmp/button/grid/ColAutosizeButton.ts @@ -10,7 +10,8 @@ import {hoistCmp, useContextModel} from '@xh/hoist/core'; import {Icon} from '@xh/hoist/icon'; import {button, ButtonProps} from '@xh/hoist/mobile/cmp/button'; import '@xh/hoist/mobile/register'; -import {logError, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {withDefault} from '@xh/hoist/utils/js'; export interface ColAutosizeButtonProps extends ButtonProps { /** GridModel to which this button should bind. Will find nearest in context if not provided. */ diff --git a/mobile/cmp/button/grid/ColChooserButton.ts b/mobile/cmp/button/grid/ColChooserButton.ts index fb4785c84..3ebd6a090 100644 --- a/mobile/cmp/button/grid/ColChooserButton.ts +++ b/mobile/cmp/button/grid/ColChooserButton.ts @@ -9,7 +9,8 @@ import {hoistCmp, useContextModel} from '@xh/hoist/core'; import {Icon} from '@xh/hoist/icon'; import {button, ButtonProps} from '@xh/hoist/mobile/cmp/button'; import '@xh/hoist/mobile/register'; -import {logError, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {withDefault} from '@xh/hoist/utils/js'; export interface ColChooserButtonProps extends ButtonProps { /** GridModel to which this button should bind. Will find nearest in context if not provided. */ diff --git a/mobile/cmp/button/grid/ExpandCollapseButton.ts b/mobile/cmp/button/grid/ExpandCollapseButton.ts index a35042780..bcba80f09 100644 --- a/mobile/cmp/button/grid/ExpandCollapseButton.ts +++ b/mobile/cmp/button/grid/ExpandCollapseButton.ts @@ -9,7 +9,8 @@ import {hoistCmp, useContextModel} from '@xh/hoist/core'; import {Icon} from '@xh/hoist/icon'; import {button, ButtonProps} from '@xh/hoist/mobile/cmp/button'; import '@xh/hoist/mobile/register'; -import {logError, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {withDefault} from '@xh/hoist/utils/js'; import {isEmpty} from 'lodash'; export interface ExpandCollapseButtonProps extends ButtonProps { diff --git a/mobile/cmp/button/grid/ExpandToLevelButton.ts b/mobile/cmp/button/grid/ExpandToLevelButton.ts index ce139e74f..e236f5527 100644 --- a/mobile/cmp/button/grid/ExpandToLevelButton.ts +++ b/mobile/cmp/button/grid/ExpandToLevelButton.ts @@ -8,7 +8,8 @@ import {GridModel} from '@xh/hoist/cmp/grid'; import {hoistCmp, MenuItemLike, useContextModel} from '@xh/hoist/core'; import {Icon} from '@xh/hoist/icon'; import '@xh/hoist/mobile/register'; -import {logError, withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {withDefault} from '@xh/hoist/utils/js'; import {menuButton, MenuButtonProps} from '../../menu'; export interface ExpandToLevelButtonProps extends MenuButtonProps { diff --git a/mobile/cmp/button/zoneGrid/ZoneMapperButton.ts b/mobile/cmp/button/zoneGrid/ZoneMapperButton.ts index 7d6177732..8661336c5 100644 --- a/mobile/cmp/button/zoneGrid/ZoneMapperButton.ts +++ b/mobile/cmp/button/zoneGrid/ZoneMapperButton.ts @@ -7,7 +7,8 @@ import {hoistCmp, useContextModel} from '@xh/hoist/core'; import {Icon} from '@xh/hoist/icon'; import {button, ButtonProps} from '@xh/hoist/mobile/cmp/button'; -import {logError, withDefault} from '@xh/hoist/utils/js'; +import {withDefault} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; import {ZoneGridModel} from '@xh/hoist/cmp/zoneGrid'; import '@xh/hoist/mobile/register'; diff --git a/mobile/cmp/panel/Panel.ts b/mobile/cmp/panel/Panel.ts index 1342e1a4a..748d0a9b0 100644 --- a/mobile/cmp/panel/Panel.ts +++ b/mobile/cmp/panel/Panel.ts @@ -25,7 +25,7 @@ import {omitBy} from 'lodash'; import {isValidElement, ReactNode, ReactElement} from 'react'; import {panelHeader} from './impl/PanelHeader'; import './Panel.scss'; -import {logWarn} from '@xh/hoist/utils/js'; +import {logWarn} from '@xh/hoist/utils/log'; export interface PanelProps extends HoistProps, Omit { /** A toolbar to be docked at the bottom of the panel. */ diff --git a/mobx/overrides.ts b/mobx/overrides.ts index cfb6a6993..6dfc1a3b7 100644 --- a/mobx/overrides.ts +++ b/mobx/overrides.ts @@ -13,7 +13,7 @@ import { observable, runInAction } from 'mobx'; -import {logError} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; /** * An enhanced version of the native mobx makeObservable. diff --git a/security/BaseOAuthClient.ts b/security/BaseOAuthClient.ts index e1796b002..85c83ca8b 100644 --- a/security/BaseOAuthClient.ts +++ b/security/BaseOAuthClient.ts @@ -13,7 +13,8 @@ import {Token} from '@xh/hoist/security/Token'; import {AccessTokenSpec, TokenMap} from './Types'; import {Timer} from '@xh/hoist/utils/async'; import {MINUTES, olderThan, ONE_MINUTE, SECONDS} from '@xh/hoist/utils/datetime'; -import {isJSON, logError, throwIf} from '@xh/hoist/utils/js'; +import {logError} from '@xh/hoist/utils/log'; +import {isJSON, throwIf} from '@xh/hoist/utils/js'; import {compact, find, forEach, head, isEmpty, isObject, keys, map, pickBy, union} from 'lodash'; import ShortUniqueId from 'short-unique-id'; diff --git a/security/msal/MsalClient.ts b/security/msal/MsalClient.ts index 5839b396b..602120028 100644 --- a/security/msal/MsalClient.ts +++ b/security/msal/MsalClient.ts @@ -17,7 +17,8 @@ import { } from '@azure/msal-browser'; import {AppState, PlainObject, XH} from '@xh/hoist/core'; import {Token} from '@xh/hoist/security/Token'; -import {logDebug, logError, logInfo, logWarn, mergeDeep, throwIf} from '@xh/hoist/utils/js'; +import {mergeDeep, throwIf} from '@xh/hoist/utils/js'; +import {logDebug, logError, logInfo, logWarn} from '@xh/hoist/utils/log'; import {withFormattedTimestamps} from '@xh/hoist/format'; import {flatMap, union, uniq} from 'lodash'; import {BaseOAuthClient, BaseOAuthClientConfig} from '../BaseOAuthClient'; diff --git a/utils/async/Timer.ts b/utils/async/Timer.ts index 7be0c1f9f..8d32dc6a0 100644 --- a/utils/async/Timer.ts +++ b/utils/async/Timer.ts @@ -7,7 +7,8 @@ import {XH} from '@xh/hoist/core'; import {wait} from '@xh/hoist/promise'; import {MILLISECONDS, MINUTES, olderThan} from '@xh/hoist/utils/datetime'; -import {logError, logWarn, throwIf} from '@xh/hoist/utils/js'; +import {throwIf} from '@xh/hoist/utils/js'; +import {logError, logWarn} from '@xh/hoist/utils/log'; import {isBoolean, isFinite, isFunction, isNil, isString, pull} from 'lodash'; /** diff --git a/utils/js/Decorators.ts b/utils/js/Decorators.ts index d66448302..747a8b411 100644 --- a/utils/js/Decorators.ts +++ b/utils/js/Decorators.ts @@ -7,7 +7,7 @@ import {XH} from '@xh/hoist/core'; import {debounce, isFunction} from 'lodash'; import {getOrCreate, throwIf, warnIf} from './LangUtils'; -import {withDebug, withInfo} from './LogUtils'; +import {withDebug, withInfo} from '../log/LogUtils'; /** * Decorates a class method so that it is debounced by the specified duration. diff --git a/utils/js/LangUtils.ts b/utils/js/LangUtils.ts index 89873e81b..8ebd3fdd6 100644 --- a/utils/js/LangUtils.ts +++ b/utils/js/LangUtils.ts @@ -6,7 +6,7 @@ */ import {PlainObject, Thunkable} from '@xh/hoist/core'; import {Exception} from '@xh/hoist/core/exception/Exception'; -import {LogSource, logWarn, logError} from '@xh/hoist/utils/js/LogUtils'; +import {type LogSource, logWarn, logError} from '@xh/hoist/utils/log'; import { flatMap, forOwn, diff --git a/utils/js/index.ts b/utils/js/index.ts index c70ced627..fe0ec3b81 100644 --- a/utils/js/index.ts +++ b/utils/js/index.ts @@ -7,7 +7,6 @@ export * from './HtmlUtils'; export * from './LangUtils'; export * from './Decorators'; -export * from './LogUtils'; export * from './DomUtils'; export * from './TestUtils'; export * from './VersionUtils'; diff --git a/utils/js/LogUtils.ts b/utils/log/LogUtils.ts similarity index 99% rename from utils/js/LogUtils.ts rename to utils/log/LogUtils.ts index 78bd6a793..6b580a1b3 100644 --- a/utils/js/LogUtils.ts +++ b/utils/log/LogUtils.ts @@ -7,7 +7,7 @@ import {Some} from '@xh/hoist/core'; import {castArray, isString} from 'lodash'; import store from 'store2'; -import {intersperse} from './LangUtils'; +import {intersperse} from '../js/LangUtils'; /** * Utility functions providing managed, structured logging to Hoist apps. diff --git a/utils/log/index.ts b/utils/log/index.ts new file mode 100644 index 000000000..7bf3b1908 --- /dev/null +++ b/utils/log/index.ts @@ -0,0 +1,8 @@ +/* + * This file belongs to Hoist, an application development toolkit + * developed by Extremely Heavy Industries (www.xh.io | info@xh.io) + * + * Copyright © 2025 Extremely Heavy Industries Inc. + */ + +export * from './LogUtils'; From 35bc447ea750aef319d8b9dac6009604de77562d Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Wed, 17 Sep 2025 18:38:52 -0400 Subject: [PATCH 03/12] Import with /log/LogUtils --- core/HoistBase.ts | 9 ++++++++- mobx/overrides.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/HoistBase.ts b/core/HoistBase.ts index ae7a4255c..08ebe3b6e 100644 --- a/core/HoistBase.ts +++ b/core/HoistBase.ts @@ -14,7 +14,14 @@ import { when as mobxWhen } from '@xh/hoist/mobx'; import {getOrCreate, throwIf} from '@xh/hoist/utils/js'; -import {logDebug, logError, logInfo, logWarn, withDebug, withInfo} from '@xh/hoist/utils/log'; +import { + logDebug, + logError, + logInfo, + logWarn, + withDebug, + withInfo +} from '@xh/hoist/utils/log/LogUtils'; import { debounce as lodashDebounce, isFunction, diff --git a/mobx/overrides.ts b/mobx/overrides.ts index 6dfc1a3b7..36c2b985d 100644 --- a/mobx/overrides.ts +++ b/mobx/overrides.ts @@ -13,7 +13,7 @@ import { observable, runInAction } from 'mobx'; -import {logError} from '@xh/hoist/utils/log'; +import {logError} from '@xh/hoist/utils/log/LogUtils'; /** * An enhanced version of the native mobx makeObservable. From c47f5ae45cff32242f694036f8b7dc0c8dfe4168 Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Wed, 17 Sep 2025 19:03:31 -0400 Subject: [PATCH 04/12] use console. in LangUtils.ts --- utils/js/LangUtils.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/js/LangUtils.ts b/utils/js/LangUtils.ts index 8ebd3fdd6..b4b26157a 100644 --- a/utils/js/LangUtils.ts +++ b/utils/js/LangUtils.ts @@ -6,7 +6,7 @@ */ import {PlainObject, Thunkable} from '@xh/hoist/core'; import {Exception} from '@xh/hoist/core/exception/Exception'; -import {type LogSource, logWarn, logError} from '@xh/hoist/utils/log'; +import {type LogSource} from '@xh/hoist/utils/log'; import { flatMap, forOwn, @@ -131,7 +131,7 @@ export function throwIf(condition: any, message: unknown) { */ export function warnIf(condition: any, message: any) { if (condition) { - logWarn(message); + console.warn(message); } } @@ -140,7 +140,7 @@ export function warnIf(condition: any, message: any) { */ export function errorIf(condition: any, message: any) { if (condition) { - logError(message); + console.error(message); } } @@ -170,7 +170,7 @@ export interface APIWarnOptions { /** An additional message. Can contain suggestions for alternatives. */ msg?: string; - /** Source of message for labelling log message. */ + /** Source of message for labeling log message. */ source?: LogSource; } @@ -198,7 +198,7 @@ export function apiDeprecated(name: string, opts: APIWarnOptions = {}) { msg = opts.msg ?? '', warn = `The use of '${name}' has been deprecated and will be removed in ${v}. ${msg}`; if (!_seenWarnings[warn]) { - logWarn(warn, opts.source); + console.warn(warn, opts.source); _seenWarnings[warn] = true; } } From 4abd5da8c619fbf7428681a4278b45cb8b3b0b07 Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Thu, 18 Sep 2025 10:41:47 -0400 Subject: [PATCH 05/12] put try/catch in getLogLevel method --- utils/log/LogUtils.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/utils/log/LogUtils.ts b/utils/log/LogUtils.ts index 6b580a1b3..e39644ea8 100644 --- a/utils/log/LogUtils.ts +++ b/utils/log/LogUtils.ts @@ -36,7 +36,11 @@ export type LogSource = string | {displayName: string} | {constructor: {name: st * @internal - use public `XH.logLevel`. */ export function getLogLevel() { - return _logLevel; + try { + return _logLevel; + } catch (e) { + return 'info'; + } } /** @@ -128,7 +132,9 @@ export function logWarn(msgs: Some, source?: LogSource) { // Implementation //---------------------------------- function loggedDo(messages: Some, fn: () => T, source: LogSource, level: LogLevel): T { - if (_severity[level] < _severity[_logLevel]) { + const _severity: Record = {error: 3, warn: 2, info: 1, debug: 0}; + + if (_severity[level] < _severity[getLogLevel()]) { return fn?.(); } @@ -208,6 +214,5 @@ function parseSource(source: LogSource): string { // Initialize during parsing to make available immediately. //---------------------------------------------------------------- let _logLevel: LogLevel = 'info'; -const _severity: Record = {error: 3, warn: 2, info: 1, debug: 0}; setLogLevel(store.session.get('xhLogLevel', 'info')); From 2c8776de25417cd03b5d4cc30722b9ac3ff333ea Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Thu, 18 Sep 2025 12:16:19 -0400 Subject: [PATCH 06/12] import checkVersion from VersionUtils directly --- kit/ag-grid/index.ts | 2 +- kit/highcharts/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kit/ag-grid/index.ts b/kit/ag-grid/index.ts index 67d752860..9670d3103 100644 --- a/kit/ag-grid/index.ts +++ b/kit/ag-grid/index.ts @@ -6,7 +6,7 @@ */ import {logError} from '@xh/hoist/utils/log'; -import {checkVersion} from '@xh/hoist/utils/js'; +import {checkVersion} from '@xh/hoist/utils/js/VersionUtils'; /** * The exports below are ag-Grid components provided at runtime by applications. diff --git a/kit/highcharts/index.ts b/kit/highcharts/index.ts index 647c50eca..83917bc4e 100644 --- a/kit/highcharts/index.ts +++ b/kit/highcharts/index.ts @@ -6,7 +6,7 @@ */ import {logError} from '@xh/hoist/utils/log'; -import {checkVersion} from '@xh/hoist/utils/js'; +import {checkVersion} from '@xh/hoist/utils/js/VersionUtils'; export let Highcharts = null; From c8cf50fbe77c10b979abb0a19fd255f1f91d6217 Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Thu, 18 Sep 2025 12:58:23 -0400 Subject: [PATCH 07/12] Move VersionUtils.ts into own package because imported at very low level --- CHANGELOG.md | 4 +++- appcontainer/AppContainerModel.ts | 3 ++- kit/ag-grid/index.ts | 2 +- kit/highcharts/index.ts | 2 +- svc/ChangelogService.ts | 2 +- svc/EnvironmentService.ts | 3 ++- utils/js/index.ts | 1 - utils/{js => version}/VersionUtils.ts | 0 utils/version/index.ts | 8 ++++++++ 9 files changed, 18 insertions(+), 7 deletions(-) rename utils/{js => version}/VersionUtils.ts (100%) create mode 100644 utils/version/index.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d926345..717d3a227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,10 @@ ## 76.0.0-SNAPSHOT - unreleased ### 💥 Breaking Changes (upgrade difficulty: 🟢 LOW - upgrade to Hoist Core, change to Tab constructor) -* The constructor for `TabModel` has changed to take its owning container as a second argument. +* The constructor for `TabModel` has changed to take its owning container as a second argument. (Most applications do not create `TabModels` directly, but it is possible.) +* `checkVersion` and related methods' import path has changed. Update imports from + `@xh/hoist/utils/js/VersionUtils` to `@xh/hoist/utils/version`; (Unlikely to affect most apps.) ### 🎁 New Features diff --git a/appcontainer/AppContainerModel.ts b/appcontainer/AppContainerModel.ts index 0d22e7d1f..f02fcc385 100644 --- a/appcontainer/AppContainerModel.ts +++ b/appcontainer/AppContainerModel.ts @@ -40,7 +40,8 @@ import { TrackService, WebSocketService } from '@xh/hoist/svc'; -import {checkMinVersion, createSingleton, throwIf} from '@xh/hoist/utils/js'; +import {checkMinVersion} from '@xh/hoist/utils/version'; +import {createSingleton, throwIf} from '@xh/hoist/utils/js'; import {compact, isEmpty} from 'lodash'; import {AboutDialogModel} from './AboutDialogModel'; import {BannerSourceModel} from './BannerSourceModel'; diff --git a/kit/ag-grid/index.ts b/kit/ag-grid/index.ts index 9670d3103..9fc9786e1 100644 --- a/kit/ag-grid/index.ts +++ b/kit/ag-grid/index.ts @@ -6,7 +6,7 @@ */ import {logError} from '@xh/hoist/utils/log'; -import {checkVersion} from '@xh/hoist/utils/js/VersionUtils'; +import {checkVersion} from '@xh/hoist/utils/version'; /** * The exports below are ag-Grid components provided at runtime by applications. diff --git a/kit/highcharts/index.ts b/kit/highcharts/index.ts index 83917bc4e..4c42df8a4 100644 --- a/kit/highcharts/index.ts +++ b/kit/highcharts/index.ts @@ -6,7 +6,7 @@ */ import {logError} from '@xh/hoist/utils/log'; -import {checkVersion} from '@xh/hoist/utils/js/VersionUtils'; +import {checkVersion} from '@xh/hoist/utils/version'; export let Highcharts = null; diff --git a/svc/ChangelogService.ts b/svc/ChangelogService.ts index d20c47b6f..ce34c305d 100644 --- a/svc/ChangelogService.ts +++ b/svc/ChangelogService.ts @@ -8,7 +8,7 @@ import {HoistService, XH} from '@xh/hoist/core'; // @ts-ignore import jsonFromMarkdown from '@xh/app-changelog.json'; import {action, makeObservable, observable} from '@xh/hoist/mobx'; -import {checkMinVersion} from '@xh/hoist/utils/js'; +import {checkMinVersion} from '@xh/hoist/utils/version'; import {isEmpty, forOwn, includes} from 'lodash'; /** diff --git a/svc/EnvironmentService.ts b/svc/EnvironmentService.ts index d8dffbe87..988aeea19 100644 --- a/svc/EnvironmentService.ts +++ b/svc/EnvironmentService.ts @@ -11,7 +11,8 @@ import {action, makeObservable, observable} from '@xh/hoist/mobx'; import hoistPkg from '@xh/hoist/package.json'; import {Timer} from '@xh/hoist/utils/async'; import {MINUTES, SECONDS} from '@xh/hoist/utils/datetime'; -import {checkMaxVersion, checkMinVersion, deepFreeze} from '@xh/hoist/utils/js'; +import {checkMaxVersion, checkMinVersion} from '@xh/hoist/utils/version'; +import {deepFreeze} from '@xh/hoist/utils/js'; import {defaults, isFinite} from 'lodash'; import mobxPkg from 'mobx/package.json'; import {version as reactVersion} from 'react'; diff --git a/utils/js/index.ts b/utils/js/index.ts index fe0ec3b81..102615834 100644 --- a/utils/js/index.ts +++ b/utils/js/index.ts @@ -9,4 +9,3 @@ export * from './LangUtils'; export * from './Decorators'; export * from './DomUtils'; export * from './TestUtils'; -export * from './VersionUtils'; diff --git a/utils/js/VersionUtils.ts b/utils/version/VersionUtils.ts similarity index 100% rename from utils/js/VersionUtils.ts rename to utils/version/VersionUtils.ts diff --git a/utils/version/index.ts b/utils/version/index.ts new file mode 100644 index 000000000..bcb7841da --- /dev/null +++ b/utils/version/index.ts @@ -0,0 +1,8 @@ +/* + * This file belongs to Hoist, an application development toolkit + * developed by Extremely Heavy Industries (www.xh.io | info@xh.io) + * + * Copyright © 2025 Extremely Heavy Industries Inc. + */ + +export * from './VersionUtils'; From 68ce443bda35d5811418351e606883cfb178a837 Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Thu, 18 Sep 2025 13:04:43 -0400 Subject: [PATCH 08/12] Reduce risk of circular dependency errors by removing interdependencies of LogUtils.ts and LangUtils.ts --- core/XH.ts | 3 ++- core/types/Types.ts | 6 ++++++ utils/js/LangUtils.ts | 3 +-- utils/log/LogUtils.ts | 20 +++++++++++--------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/core/XH.ts b/core/XH.ts index c93fcbbfa..4b582f076 100644 --- a/core/XH.ts +++ b/core/XH.ts @@ -31,7 +31,8 @@ import { WebSocketService, ClientHealthService } from '@xh/hoist/svc'; -import {getLogLevel, setLogLevel, type LogLevel} from '@xh/hoist/utils/log'; +import type {LogLevel} from './types/Types'; +import {getLogLevel, setLogLevel} from '@xh/hoist/utils/log'; import {camelCase, flatten, isString, uniqueId} from 'lodash'; import {Router, State} from 'router5'; import {CancelFn} from 'router5/types/types/base'; diff --git a/core/types/Types.ts b/core/types/Types.ts index 835727d48..48f7fb401 100644 --- a/core/types/Types.ts +++ b/core/types/Types.ts @@ -86,3 +86,9 @@ export type PageState = * The page is in the process of being unloaded by the browser (this is a terminal state x_x). */ | 'terminated'; + +/** Severity Level for log statement */ +export type LogLevel = 'error' | 'warn' | 'info' | 'debug'; + +/** Object identifying the source of log statement. Typically, a javascript class */ +export type LogSource = string | {displayName: string} | {constructor: {name: string}}; diff --git a/utils/js/LangUtils.ts b/utils/js/LangUtils.ts index b4b26157a..f9b2b3f13 100644 --- a/utils/js/LangUtils.ts +++ b/utils/js/LangUtils.ts @@ -4,9 +4,8 @@ * * Copyright © 2025 Extremely Heavy Industries Inc. */ -import {PlainObject, Thunkable} from '@xh/hoist/core'; +import type {PlainObject, Thunkable, LogSource} from '@xh/hoist/core'; import {Exception} from '@xh/hoist/core/exception/Exception'; -import {type LogSource} from '@xh/hoist/utils/log'; import { flatMap, forOwn, diff --git a/utils/log/LogUtils.ts b/utils/log/LogUtils.ts index e39644ea8..9adf25dc1 100644 --- a/utils/log/LogUtils.ts +++ b/utils/log/LogUtils.ts @@ -4,10 +4,9 @@ * * Copyright © 2025 Extremely Heavy Industries Inc. */ -import {Some} from '@xh/hoist/core'; -import {castArray, isString} from 'lodash'; +import type {Some, LogLevel, LogSource} from '@xh/hoist/core'; +import {castArray, flatMap, isString} from 'lodash'; import store from 'store2'; -import {intersperse} from '../js/LangUtils'; /** * Utility functions providing managed, structured logging to Hoist apps. @@ -23,12 +22,6 @@ import {intersperse} from '../js/LangUtils'; * XH.logLevel from the console. */ -/** Severity Level for log statement */ -export type LogLevel = 'error' | 'warn' | 'info' | 'debug'; - -/** Object identifying the source of log statement. Typically, a javascript class */ -export type LogSource = string | {displayName: string} | {constructor: {name: string}}; - /** * Current minimum severity for Hoist log utils (default 'info'). * Messages logged via managed Hoist log utils with lower severity will be ignored. @@ -209,6 +202,15 @@ function parseSource(source: LogSource): string { return null; } +/** + * Intersperse a separator between each item in an array. + * Same method as in LangUtils, but duplicated here to avoid circular dependency. + */ +function intersperse(arr: T[], separator: T): T[] { + return flatMap(arr, (it, idx) => { + return idx > 0 ? [separator, it] : [it]; + }); +} //---------------------------------------------------------------- // Initialization + Level/Severity support. // Initialize during parsing to make available immediately. From e822dc40bee4addc54199d2288b579fd258ed6c8 Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Thu, 18 Sep 2025 13:33:51 -0400 Subject: [PATCH 09/12] use shorter path --- core/HoistBase.ts | 9 +-------- mobx/overrides.ts | 2 +- utils/js/Decorators.ts | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/core/HoistBase.ts b/core/HoistBase.ts index 08ebe3b6e..ae7a4255c 100644 --- a/core/HoistBase.ts +++ b/core/HoistBase.ts @@ -14,14 +14,7 @@ import { when as mobxWhen } from '@xh/hoist/mobx'; import {getOrCreate, throwIf} from '@xh/hoist/utils/js'; -import { - logDebug, - logError, - logInfo, - logWarn, - withDebug, - withInfo -} from '@xh/hoist/utils/log/LogUtils'; +import {logDebug, logError, logInfo, logWarn, withDebug, withInfo} from '@xh/hoist/utils/log'; import { debounce as lodashDebounce, isFunction, diff --git a/mobx/overrides.ts b/mobx/overrides.ts index 36c2b985d..6dfc1a3b7 100644 --- a/mobx/overrides.ts +++ b/mobx/overrides.ts @@ -13,7 +13,7 @@ import { observable, runInAction } from 'mobx'; -import {logError} from '@xh/hoist/utils/log/LogUtils'; +import {logError} from '@xh/hoist/utils/log'; /** * An enhanced version of the native mobx makeObservable. diff --git a/utils/js/Decorators.ts b/utils/js/Decorators.ts index 747a8b411..714795c45 100644 --- a/utils/js/Decorators.ts +++ b/utils/js/Decorators.ts @@ -7,7 +7,7 @@ import {XH} from '@xh/hoist/core'; import {debounce, isFunction} from 'lodash'; import {getOrCreate, throwIf, warnIf} from './LangUtils'; -import {withDebug, withInfo} from '../log/LogUtils'; +import {withDebug, withInfo} from '../log'; /** * Decorates a class method so that it is debounced by the specified duration. From ab867f949a1bef1d210fc5bc90b43e5a2a504c99 Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Thu, 18 Sep 2025 14:30:40 -0400 Subject: [PATCH 10/12] Restore use of logMethods in LangUtils.ts --- utils/js/LangUtils.ts | 7 ++++--- utils/log/LogUtils.ts | 9 ++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/utils/js/LangUtils.ts b/utils/js/LangUtils.ts index f9b2b3f13..63348ee6e 100644 --- a/utils/js/LangUtils.ts +++ b/utils/js/LangUtils.ts @@ -6,6 +6,7 @@ */ import type {PlainObject, Thunkable, LogSource} from '@xh/hoist/core'; import {Exception} from '@xh/hoist/core/exception/Exception'; +import {logWarn, logError} from '@xh/hoist/utils/log'; import { flatMap, forOwn, @@ -130,7 +131,7 @@ export function throwIf(condition: any, message: unknown) { */ export function warnIf(condition: any, message: any) { if (condition) { - console.warn(message); + logWarn(message); } } @@ -139,7 +140,7 @@ export function warnIf(condition: any, message: any) { */ export function errorIf(condition: any, message: any) { if (condition) { - console.error(message); + logError(message); } } @@ -197,7 +198,7 @@ export function apiDeprecated(name: string, opts: APIWarnOptions = {}) { msg = opts.msg ?? '', warn = `The use of '${name}' has been deprecated and will be removed in ${v}. ${msg}`; if (!_seenWarnings[warn]) { - console.warn(warn, opts.source); + logWarn(warn, opts.source); _seenWarnings[warn] = true; } } diff --git a/utils/log/LogUtils.ts b/utils/log/LogUtils.ts index 9adf25dc1..bf6c65ca6 100644 --- a/utils/log/LogUtils.ts +++ b/utils/log/LogUtils.ts @@ -29,11 +29,7 @@ import store from 'store2'; * @internal - use public `XH.logLevel`. */ export function getLogLevel() { - try { - return _logLevel; - } catch (e) { - return 'info'; - } + return _logLevel; } /** @@ -125,8 +121,6 @@ export function logWarn(msgs: Some, source?: LogSource) { // Implementation //---------------------------------- function loggedDo(messages: Some, fn: () => T, source: LogSource, level: LogLevel): T { - const _severity: Record = {error: 3, warn: 2, info: 1, debug: 0}; - if (_severity[level] < _severity[getLogLevel()]) { return fn?.(); } @@ -216,5 +210,6 @@ function intersperse(arr: T[], separator: T): T[] { // Initialize during parsing to make available immediately. //---------------------------------------------------------------- let _logLevel: LogLevel = 'info'; +const _severity: Record = {error: 3, warn: 2, info: 1, debug: 0}; setLogLevel(store.session.get('xhLogLevel', 'info')); From b38857adb0dc9835dab90534273a02416003074e Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Thu, 18 Sep 2025 15:17:38 -0400 Subject: [PATCH 11/12] Mention log methods path chang in CHANGELOG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 717d3a227..5a77e280b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,9 @@ * The constructor for `TabModel` has changed to take its owning container as a second argument. (Most applications do not create `TabModels` directly, but it is possible.) * `checkVersion` and related methods' import path has changed. Update imports from - `@xh/hoist/utils/js/VersionUtils` to `@xh/hoist/utils/version`; (Unlikely to affect most apps.) + `@xh/hoist/utils/js/VersionUtils` to `@xh/hoist/utils/version` (Unlikely to affect most apps). +* `logDebug, logWarn, logError` and related methods' import path has changed. Update imports from + `@xh/hoist/utils/js` to `@xh/hoist/utils/log`. ### 🎁 New Features From 7a7aa39f573644b88e786995ed39de4bd679aa3e Mon Sep 17 00:00:00 2001 From: Colin Rudd Date: Thu, 18 Sep 2025 15:55:50 -0400 Subject: [PATCH 12/12] Use full path for import --- utils/js/Decorators.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/js/Decorators.ts b/utils/js/Decorators.ts index 714795c45..c0835b6bd 100644 --- a/utils/js/Decorators.ts +++ b/utils/js/Decorators.ts @@ -4,10 +4,10 @@ * * Copyright © 2025 Extremely Heavy Industries Inc. */ -import {XH} from '@xh/hoist/core'; import {debounce, isFunction} from 'lodash'; +import {XH} from '@xh/hoist/core'; +import {withDebug, withInfo} from '@xh/hoist/utils/log'; import {getOrCreate, throwIf, warnIf} from './LangUtils'; -import {withDebug, withInfo} from '../log'; /** * Decorates a class method so that it is debounced by the specified duration.