@xh/hoist 59.3.1 → 59.4.0
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 +30 -2
- package/admin/differ/DifferModel.ts +5 -7
- package/appcontainer/AppContainerModel.ts +8 -10
- package/appcontainer/AppStateModel.ts +3 -2
- package/appcontainer/PageStateModel.ts +1 -2
- package/appcontainer/SizingModeModel.ts +2 -2
- package/cmp/ag-grid/AgGrid.ts +4 -3
- package/cmp/ag-grid/AgGridModel.ts +8 -9
- package/cmp/chart/Chart.ts +4 -3
- package/cmp/dataview/DataViewModel.ts +2 -2
- package/cmp/filter/FilterChooserModel.ts +5 -5
- package/cmp/grid/Grid.ts +2 -2
- package/cmp/grid/GridContextMenu.ts +2 -2
- package/cmp/grid/GridModel.ts +13 -21
- package/cmp/grid/Types.ts +6 -5
- package/cmp/grid/columns/Column.ts +12 -12
- package/cmp/grid/columns/ColumnGroup.ts +17 -6
- package/cmp/grid/helpers/GridCountLabel.ts +5 -4
- package/cmp/grid/impl/ColumnWidthCalculator.ts +3 -3
- package/cmp/grid/impl/GridPersistenceModel.ts +11 -4
- package/cmp/grid/renderers/MultiFieldRenderer.ts +28 -22
- package/cmp/grouping/GroupingChooserModel.ts +2 -2
- package/cmp/tab/TabContainerModel.ts +2 -2
- package/cmp/zoneGrid/ZoneGridModel.ts +52 -36
- package/cmp/zoneGrid/impl/ZoneGridPersistenceModel.ts +10 -4
- package/core/HoistBase.ts +44 -5
- package/core/XH.ts +3 -3
- package/core/elem.ts +2 -2
- package/core/impl/InstallServices.ts +2 -8
- package/core/load/LoadSupport.ts +3 -3
- package/core/model/HoistModel.ts +1 -1
- package/data/Store.ts +1 -1
- package/data/UrlStore.ts +3 -3
- package/data/filter/CompoundFilter.ts +5 -3
- package/data/filter/FieldFilter.ts +4 -3
- package/data/filter/Filter.ts +2 -3
- package/data/filter/FunctionFilter.ts +2 -1
- package/data/impl/RecordSet.ts +5 -5
- package/desktop/appcontainer/ToastSource.ts +1 -1
- package/desktop/cmp/rest/Actions.ts +15 -9
- package/desktop/cmp/treemap/TreeMap.ts +4 -8
- package/package.json +1 -1
- package/svc/AutoRefreshService.ts +3 -3
- package/svc/EnvironmentService.ts +1 -1
- package/svc/FetchService.ts +5 -5
- package/svc/GridAutosizeService.ts +4 -7
- package/svc/TrackService.ts +6 -6
- package/svc/WebSocketService.ts +14 -15
- package/utils/async/AsyncUtils.ts +3 -2
- package/utils/async/Timer.ts +32 -19
- package/utils/js/BrowserUtils.ts +8 -8
- package/utils/js/LangUtils.ts +10 -9
- package/utils/js/LogUtils.ts +66 -26
- package/utils/react/LayoutPropUtils.ts +3 -3
package/utils/js/LogUtils.ts
CHANGED
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2023 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
+
import {Some} from '@xh/hoist/core';
|
|
7
8
|
import {castArray, isString} from 'lodash';
|
|
9
|
+
import {intersperse} from './LangUtils';
|
|
10
|
+
|
|
11
|
+
export type LogSource = string | {displayName: string} | {constructor: {name: string}};
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
14
|
+
* Time and log execution of a function to `console.info()`.
|
|
11
15
|
*
|
|
12
16
|
* This method will log the provided message(s) with timing information in a single message *after*
|
|
13
17
|
* the tracked function returns.
|
|
@@ -20,61 +24,78 @@ import {castArray, isString} from 'lodash';
|
|
|
20
24
|
* @param fn - function to execute
|
|
21
25
|
* @param source - class, function or string to label the source of the message
|
|
22
26
|
*/
|
|
23
|
-
export function withInfo<T>(msgs:
|
|
27
|
+
export function withInfo<T>(msgs: Some<unknown>, fn: () => T, source?: LogSource): T {
|
|
24
28
|
return loggedDo(msgs, fn, source, 'info');
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
|
-
*
|
|
32
|
+
* Time and log execution of a function to `console.debug()`.
|
|
29
33
|
* @see withInfo
|
|
30
34
|
*/
|
|
31
|
-
export function withDebug<T>(msgs:
|
|
35
|
+
export function withDebug<T>(msgs: Some<unknown>, fn: () => T, source?: LogSource): T {
|
|
32
36
|
return loggedDo(msgs, fn, source, 'debug');
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
40
|
+
* Write to `console.log()` with standardized formatting and source info.
|
|
38
41
|
* @param msgs - message(s) to output
|
|
39
42
|
* @param source - class, function or string to label the source of the message
|
|
40
43
|
*/
|
|
41
|
-
export function logInfo(msgs:
|
|
44
|
+
export function logInfo(msgs: Some<unknown>, source?: LogSource) {
|
|
42
45
|
return loggedDo(msgs, null, source, 'info');
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
49
|
+
* Write to `console.debug()` with standardized formatting and source info.
|
|
50
|
+
* @param msgs - message(s) to output
|
|
51
|
+
* @param source - class, function or string to label the source of the message
|
|
48
52
|
*/
|
|
49
|
-
export function logDebug(msgs:
|
|
53
|
+
export function logDebug(msgs: Some<unknown>, source?: LogSource) {
|
|
50
54
|
return loggedDo(msgs, null, source, 'debug');
|
|
51
55
|
}
|
|
52
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Write to `console.error()` with standardized formatting and source info.
|
|
59
|
+
* @param msgs - message(s) to output
|
|
60
|
+
* @param source - class, function or string to label the source of the message
|
|
61
|
+
*/
|
|
62
|
+
export function logError(msgs: Some<unknown>, source?: LogSource) {
|
|
63
|
+
return loggedDo(msgs, null, source, 'error');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Write to `console.warn()` with standardized formatting and source info.
|
|
68
|
+
* @param msgs - message(s) to output
|
|
69
|
+
* @param source - class, function or string to label the source of the message
|
|
70
|
+
*/
|
|
71
|
+
export function logWarn(msgs: Some<unknown>, source?: LogSource) {
|
|
72
|
+
return loggedDo(msgs, null, source, 'warn');
|
|
73
|
+
}
|
|
74
|
+
|
|
53
75
|
//----------------------------------
|
|
54
76
|
// Implementation
|
|
55
77
|
//----------------------------------
|
|
56
|
-
function loggedDo(
|
|
57
|
-
|
|
58
|
-
msgs = castArray(
|
|
59
|
-
const msg = msgs.join(' | ');
|
|
78
|
+
function loggedDo<T>(messages: Some<unknown>, fn: () => T, source: LogSource, level: LogLevel) {
|
|
79
|
+
let src = parseSource(source);
|
|
80
|
+
let msgs = castArray(messages);
|
|
60
81
|
|
|
61
82
|
// Support simple message only.
|
|
62
83
|
if (!fn) {
|
|
63
|
-
writeLog(
|
|
84
|
+
writeLog(msgs, src, level);
|
|
64
85
|
return;
|
|
65
86
|
}
|
|
66
87
|
|
|
67
88
|
// Otherwise, wrap the call to the provided fn.
|
|
68
|
-
let start, ret;
|
|
89
|
+
let start: number, ret: T;
|
|
69
90
|
const logCompletion = () => {
|
|
70
91
|
const elapsed = Date.now() - start;
|
|
71
|
-
writeLog(`${
|
|
92
|
+
writeLog([...msgs, `${elapsed}ms`], src, level);
|
|
72
93
|
},
|
|
73
94
|
logException = e => {
|
|
74
95
|
const elapsed = Date.now() - start;
|
|
75
96
|
writeLog(
|
|
76
|
-
|
|
77
|
-
|
|
97
|
+
[...msgs, `failed - ${e.message ?? e.name ?? 'Unknown error'}`, `${elapsed}ms`, e],
|
|
98
|
+
src,
|
|
78
99
|
level
|
|
79
100
|
);
|
|
80
101
|
};
|
|
@@ -96,14 +117,33 @@ function loggedDo(msgs, fn, source, level) {
|
|
|
96
117
|
return ret;
|
|
97
118
|
}
|
|
98
119
|
|
|
99
|
-
function parseSource(source) {
|
|
120
|
+
function parseSource(source: LogSource): string {
|
|
121
|
+
if (!source) return null;
|
|
100
122
|
if (isString(source)) return source;
|
|
101
|
-
if (source
|
|
102
|
-
if (source
|
|
103
|
-
return
|
|
123
|
+
if (source['displayName']) return source['displayName'];
|
|
124
|
+
if (source.constructor) return source.constructor.name;
|
|
125
|
+
return null;
|
|
104
126
|
}
|
|
105
127
|
|
|
106
|
-
function writeLog(
|
|
107
|
-
if (
|
|
108
|
-
|
|
128
|
+
function writeLog(msgs: unknown[], src: string, level: LogLevel) {
|
|
129
|
+
if (src) msgs = [`[${src}]`, ...msgs];
|
|
130
|
+
|
|
131
|
+
msgs = intersperse(msgs, '|');
|
|
132
|
+
|
|
133
|
+
switch (level) {
|
|
134
|
+
case 'error':
|
|
135
|
+
console.error(...msgs);
|
|
136
|
+
break;
|
|
137
|
+
case 'warn':
|
|
138
|
+
console.warn(...msgs);
|
|
139
|
+
break;
|
|
140
|
+
case 'debug':
|
|
141
|
+
console.debug(...msgs);
|
|
142
|
+
break;
|
|
143
|
+
case 'info':
|
|
144
|
+
console.log(...msgs);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
109
147
|
}
|
|
148
|
+
|
|
149
|
+
type LogLevel = 'error' | 'warn' | 'info' | 'debug';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2023 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {HoistProps, LayoutProps
|
|
7
|
+
import {HoistProps, LayoutProps} from '@xh/hoist/core';
|
|
8
8
|
import {forOwn, isEmpty, isNumber, isString, isNil, omit, pick} from 'lodash';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -40,9 +40,9 @@ import {forOwn, isEmpty, isNumber, isString, isNil, omit, pick} from 'lodash';
|
|
|
40
40
|
* that afforded by the underlying flexbox styles. In particular, it accepts flex and sizing props
|
|
41
41
|
* as raw numbers rather than strings.
|
|
42
42
|
*/
|
|
43
|
-
export function getLayoutProps(props:
|
|
43
|
+
export function getLayoutProps(props: HoistProps): LayoutProps {
|
|
44
44
|
// Harvest all keys of interest
|
|
45
|
-
const ret: LayoutProps = pick(props, allKeys);
|
|
45
|
+
const ret: LayoutProps = pick(props, allKeys) as LayoutProps;
|
|
46
46
|
|
|
47
47
|
// flexXXX: convert raw number to string
|
|
48
48
|
const flexConfig = pick(ret, flexKeys);
|