@xh/hoist 71.0.0-SNAPSHOT.1735658425894 → 71.0.0-SNAPSHOT.1735827810197
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 +1 -0
- package/build/types/core/model/HoistModel.d.ts +1 -1
- package/build/types/svc/FetchService.d.ts +7 -4
- package/cmp/relativetimestamp/RelativeTimestamp.ts +3 -4
- package/core/model/HoistModel.ts +5 -11
- package/desktop/cmp/input/NumberInput.ts +1 -2
- package/mobile/cmp/input/NumberInput.ts +1 -2
- package/mobile/cmp/popover/Popover.ts +2 -0
- package/package.json +1 -1
- package/svc/FetchService.ts +13 -8
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
relying on third-party cookies.
|
|
34
34
|
* Updated sorting on grouped grids to place ungrouped items at the bottom.
|
|
35
35
|
* `DashCanvas` views can now be resized left and up in addition to right and down.
|
|
36
|
+
* `FetchService.autoGenCorrelationIds` now supports a functional form for per-request behavior.
|
|
36
37
|
|
|
37
38
|
### 🐞 Bug Fixes
|
|
38
39
|
|
|
@@ -49,7 +49,7 @@ export declare abstract class HoistModel extends HoistBase implements Loadable {
|
|
|
49
49
|
config: unknown;
|
|
50
50
|
static get isHoistModel(): boolean;
|
|
51
51
|
get isHoistModel(): boolean;
|
|
52
|
-
_componentProps:
|
|
52
|
+
_componentProps: any;
|
|
53
53
|
_modelLookup: any;
|
|
54
54
|
_created: number;
|
|
55
55
|
constructor();
|
|
@@ -9,8 +9,8 @@ import { IStringifyOptions } from 'qs';
|
|
|
9
9
|
* the most common use-cases. The Fetch API will be called with CORS enabled, credentials
|
|
10
10
|
* included, and redirects followed.
|
|
11
11
|
*
|
|
12
|
-
* Set {@link autoGenCorrelationIds}
|
|
13
|
-
* Correlation IDs for
|
|
12
|
+
* Set {@link autoGenCorrelationIds} on this service to enable auto-generation of UUID
|
|
13
|
+
* Correlation IDs for requests issued by this service. Can also be set on a per-request basis
|
|
14
14
|
* via {@link FetchOptions.correlationId}.
|
|
15
15
|
*
|
|
16
16
|
* Custom headers can be set on a request via {@link FetchOptions.headers}. Default headers for all
|
|
@@ -28,8 +28,11 @@ export declare class FetchService extends HoistService {
|
|
|
28
28
|
private autoAborters;
|
|
29
29
|
private _defaultHeaders;
|
|
30
30
|
private _interceptors;
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Should hoist auto-generate a Correlation ID for a request when not otherwise specified?
|
|
33
|
+
* Set to `true` or a dynamic per-request function to enable. Default false.
|
|
34
|
+
*/
|
|
35
|
+
autoGenCorrelationIds: boolean | ((opts: FetchOptions) => boolean);
|
|
33
36
|
/**
|
|
34
37
|
* Method for generating Correlation ID's. Defaults to a 16 character random string with
|
|
35
38
|
* an extremely low probability of collisions. Applications may customize
|
|
@@ -134,17 +134,16 @@ class RelativeTimestampLocalModel extends HoistModel {
|
|
|
134
134
|
constructor() {
|
|
135
135
|
super();
|
|
136
136
|
makeObservable(this);
|
|
137
|
+
}
|
|
137
138
|
|
|
139
|
+
override onLinked() {
|
|
140
|
+
this.model = this.lookupModel('*');
|
|
138
141
|
this.addReaction({
|
|
139
142
|
track: () => [this.timestamp, this.options],
|
|
140
143
|
run: () => this.refreshDisplay()
|
|
141
144
|
});
|
|
142
145
|
}
|
|
143
146
|
|
|
144
|
-
override onLinked() {
|
|
145
|
-
this.model = this.lookupModel('*');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
147
|
@action
|
|
149
148
|
private refreshDisplay() {
|
|
150
149
|
this.display = getRelativeTimestamp(this.timestamp, this.options);
|
package/core/model/HoistModel.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2025 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {action, makeObservable, observable} from '@xh/hoist/mobx';
|
|
7
|
+
import {action, computed, comparer, makeObservable, observable} from '@xh/hoist/mobx';
|
|
8
8
|
import {warnIf} from '@xh/hoist/utils/js';
|
|
9
|
-
import {
|
|
9
|
+
import {isFunction} from 'lodash';
|
|
10
10
|
import {DefaultHoistProps, HoistBase, LoadSpecConfig, managed, PlainObject} from '../';
|
|
11
11
|
import {instanceManager} from '../impl/InstanceManager';
|
|
12
12
|
import {Loadable, LoadSpec, LoadSupport} from '../load';
|
|
@@ -67,8 +67,7 @@ export abstract class HoistModel extends HoistBase implements Loadable {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// Internal State
|
|
70
|
-
@observable
|
|
71
|
-
_componentProps = {};
|
|
70
|
+
@observable.ref _componentProps = null;
|
|
72
71
|
_modelLookup = null;
|
|
73
72
|
_created = Date.now();
|
|
74
73
|
|
|
@@ -136,6 +135,7 @@ export abstract class HoistModel extends HoistBase implements Loadable {
|
|
|
136
135
|
* Observability is based on a shallow computation for each prop (i.e. a reference
|
|
137
136
|
* change in any particular prop will trigger observers to be notified).
|
|
138
137
|
*/
|
|
138
|
+
@computed({equals: comparer.shallow})
|
|
139
139
|
get componentProps(): DefaultHoistProps {
|
|
140
140
|
return this._componentProps;
|
|
141
141
|
}
|
|
@@ -187,13 +187,7 @@ export abstract class HoistModel extends HoistBase implements Loadable {
|
|
|
187
187
|
/** @internal */
|
|
188
188
|
@action
|
|
189
189
|
setComponentProps(newProps) {
|
|
190
|
-
|
|
191
|
-
Object.assign(props, newProps);
|
|
192
|
-
forOwn(props, (v, k) => {
|
|
193
|
-
if (!has(newProps, k)) {
|
|
194
|
-
delete props[k];
|
|
195
|
-
}
|
|
196
|
-
});
|
|
190
|
+
this._componentProps = newProps;
|
|
197
191
|
}
|
|
198
192
|
|
|
199
193
|
/** @internal */
|
|
@@ -124,8 +124,7 @@ export const [NumberInput, numberInput] = hoistCmp.withFactory<NumberInputProps>
|
|
|
124
124
|
class NumberInputModel extends HoistInputModel {
|
|
125
125
|
override xhImpl = true;
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
super();
|
|
127
|
+
override onLinked() {
|
|
129
128
|
throwIf(Math.log10(this.scaleFactor) % 1 !== 0, 'scaleFactor must be a factor of 10');
|
|
130
129
|
}
|
|
131
130
|
|
|
@@ -92,8 +92,7 @@ class NumberInputModel extends HoistInputModel {
|
|
|
92
92
|
|
|
93
93
|
static shorthandValidator = /((\.\d+)|(\d+(\.\d+)?))([kmb])\b/i;
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
super();
|
|
95
|
+
override onLinked() {
|
|
97
96
|
throwIf(Math.log10(this.scaleFactor) % 1 !== 0, 'scaleFactor must be a factor of 10');
|
|
98
97
|
}
|
|
99
98
|
|
|
@@ -167,7 +167,9 @@ class PopoverModel extends HoistModel {
|
|
|
167
167
|
constructor() {
|
|
168
168
|
super();
|
|
169
169
|
makeObservable(this);
|
|
170
|
+
}
|
|
170
171
|
|
|
172
|
+
override onLinked() {
|
|
171
173
|
// Popovers are automatically closed on app route changes to avoid navigating the
|
|
172
174
|
// app underneath the popover in an unsettling way. (i.e. via browser back button)
|
|
173
175
|
this.addReaction({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "71.0.0-SNAPSHOT.
|
|
3
|
+
"version": "71.0.0-SNAPSHOT.1735827810197",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|
package/svc/FetchService.ts
CHANGED
|
@@ -28,8 +28,8 @@ import ShortUniqueId from 'short-unique-id';
|
|
|
28
28
|
* the most common use-cases. The Fetch API will be called with CORS enabled, credentials
|
|
29
29
|
* included, and redirects followed.
|
|
30
30
|
*
|
|
31
|
-
* Set {@link autoGenCorrelationIds}
|
|
32
|
-
* Correlation IDs for
|
|
31
|
+
* Set {@link autoGenCorrelationIds} on this service to enable auto-generation of UUID
|
|
32
|
+
* Correlation IDs for requests issued by this service. Can also be set on a per-request basis
|
|
33
33
|
* via {@link FetchOptions.correlationId}.
|
|
34
34
|
*
|
|
35
35
|
* Custom headers can be set on a request via {@link FetchOptions.headers}. Default headers for all
|
|
@@ -52,8 +52,11 @@ export class FetchService extends HoistService {
|
|
|
52
52
|
//-----------------------------------
|
|
53
53
|
// Public properties, Getters/Setters
|
|
54
54
|
//------------------------------------
|
|
55
|
-
/**
|
|
56
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Should hoist auto-generate a Correlation ID for a request when not otherwise specified?
|
|
57
|
+
* Set to `true` or a dynamic per-request function to enable. Default false.
|
|
58
|
+
*/
|
|
59
|
+
autoGenCorrelationIds: boolean | ((opts: FetchOptions) => boolean) = false;
|
|
57
60
|
|
|
58
61
|
/**
|
|
59
62
|
* Method for generating Correlation ID's. Defaults to a 16 character random string with
|
|
@@ -253,10 +256,12 @@ export class FetchService extends HoistService {
|
|
|
253
256
|
|
|
254
257
|
// Resolve convenience options for Correlation ID to server-ready string
|
|
255
258
|
private withCorrelationId(opts: FetchOptions): FetchOptions {
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (
|
|
259
|
+
const cid = opts.correlationId,
|
|
260
|
+
autoCid = this.autoGenCorrelationIds;
|
|
261
|
+
|
|
262
|
+
if (isString(cid)) return opts;
|
|
263
|
+
if (cid === false || cid === null) return omit(opts, 'correlationId');
|
|
264
|
+
if (cid === true || autoCid === true || (isFunction(autoCid) && autoCid(opts))) {
|
|
260
265
|
return {...opts, correlationId: this.genCorrelationId()};
|
|
261
266
|
}
|
|
262
267
|
return opts;
|