@trackunit/react-core-contexts-test 0.1.118 → 0.1.119

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/index.esm2.js CHANGED
@@ -1,219 +1,29 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
+ import * as testUtils from 'react-dom/test-utils';
2
3
  import * as React from 'react';
3
4
  import React__default, { useRef, useMemo, useEffect } from 'react';
4
- import { AssetSortByProperty, SortOrder } from '@trackunit/react-core-contexts-api';
5
- import * as testUtils from 'react-dom/test-utils';
6
5
  import ReactDOM from 'react-dom';
7
6
  import * as ReactDOMClient from 'react-dom/client';
8
7
  import require$$0 from 'util';
9
8
  import { EnvironmentContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider, GlobalSelectionProvider, FilterBarProvider, AssetSortingProvider, CurrentUserPreferenceProvider } from '@trackunit/react-core-hooks';
10
9
  import { MemoryRouter } from 'react-router-dom';
10
+ import { AssetSortByProperty, SortOrder } from '@trackunit/react-core-contexts-api';
11
11
 
12
12
  function _mergeNamespaces(n, m) {
13
- m.forEach(function (e) {
14
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
15
- if (k !== 'default' && !(k in n)) {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
13
+ m.forEach(function (e) {
14
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default' && !(k in n)) {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
20
22
  });
21
- }
22
23
  });
23
- });
24
- return Object.freeze(n);
24
+ return Object.freeze(n);
25
25
  }
26
26
 
27
- /**
28
- * Logs props that have changed.
29
- * Use this for debugging which props force a component to re-render.
30
- * This is a hook version of the class component lifecycle method `componentDidUpdate`.
31
- * ALWAYS wrap in your own object.
32
- *
33
- * @param id optional id to use for logging or it will guess the id from the stack trace
34
- * @param propsToWatch all the props to watch for changes
35
- * @example
36
- * const propsToWatch = { foo: props.foo, bar: props.bar };
37
- * useDebugger({ id: "MyComponent", propsToWatch });
38
- */
39
- const useDebugger = ({ id, propsToWatch, }) => {
40
- const prevPropsRef = useRef(propsToWatch);
41
- const uniqueId = useMemo(() => {
42
- var _a;
43
- return id || ((_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n")[2].trim()) || "unknown-id";
44
- }, [id]);
45
- useEffect(() => {
46
- const changedProps = Object.entries(propsToWatch || {}).reduce((result, [key, value]) => {
47
- if (prevPropsRef.current && prevPropsRef.current[key] !== value) {
48
- result[key + ""] = [prevPropsRef.current[key], value];
49
- }
50
- return result;
51
- }, {});
52
- if (Object.keys(changedProps).length > 0) {
53
- // eslint-disable-next-line no-console
54
- Object.keys(changedProps).forEach(changedProp => {
55
- // eslint-disable-next-line no-console
56
- console.log(`${uniqueId} changed property: ${changedProp}`);
57
- // JSON stringify is used to avoid console.table from logging the object reference
58
- const result = JSON.parse(JSON.stringify(changedProps[changedProp]));
59
- const result0 = result[0];
60
- const result1 = result[1];
61
- result0 &&
62
- Object.keys(result0).forEach(prop => {
63
- result0[prop] = JSON.stringify(result0[prop]);
64
- });
65
- result1 &&
66
- Object.keys(result1).forEach(prop => {
67
- result1[prop] = JSON.stringify(result1[prop]);
68
- });
69
- // eslint-disable-next-line no-console
70
- console.table([result0, result1]);
71
- });
72
- // eslint-disable-next-line no-console
73
- console.dir(changedProps);
74
- }
75
- prevPropsRef.current = propsToWatch;
76
- }, [propsToWatch, uniqueId]);
77
- };
78
- /**
79
- * Debugger component for debugging state changes and re-renders.
80
- *
81
- * This component will log when it is mounted, re-renders or unmounted.
82
- * It will also log when any of its props change.
83
- *
84
- * @param id optional id to use for logging
85
- * @param stop if true, will stop execution and open debugger
86
- * @param logPropsChanges optional object with props to watch for changes
87
- * @param children the children to render
88
- */
89
- const Debugger = ({ id, logPropsChanges, stop, children, }) => {
90
- var _a, _b, _c, _d, _e, _f;
91
- const uniqueId = id ||
92
- (
93
- // @ts-ignore
94
- (_e = (_d = (_c = (_b = (_a = React__default["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"]) === null || _a === void 0 ? void 0 : _a.ReactCurrentOwner) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c._debugOwner) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.name) ||
95
- ((_f = new Error().stack) === null || _f === void 0 ? void 0 : _f.split("\n")[2].trim()) ||
96
- "unknown-id";
97
- useDebugger({ id: uniqueId, propsToWatch: logPropsChanges || {} });
98
- // eslint-disable-next-line no-console
99
- console.log(`${uniqueId} Debugger is rendering`);
100
- useEffect(() => {
101
- // eslint-disable-next-line no-console
102
- console.log(`${uniqueId} Debugger is mounting`);
103
- return () => {
104
- // eslint-disable-next-line no-console
105
- console.log(`${uniqueId} Debugger is unmounting`);
106
- };
107
- // eslint-disable-next-line react-hooks/exhaustive-deps
108
- }, []);
109
- if (stop === true) {
110
- // eslint-disable-next-line no-debugger
111
- debugger;
112
- }
113
- return jsx("div", { className: "Debugger", children: children });
114
- };
115
-
116
- /**
117
- * Do nothing
118
- */
119
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
- const doNothing = () => {
121
- /* Do nothing */
122
- };
123
-
124
- const mockAnalyticsContext = {
125
- logEvent: doNothing,
126
- logError: doNothing,
127
- logPageView: doNothing,
128
- setUserProperty: doNothing,
129
- };
130
-
131
- const mockAssetSortingContext = {
132
- setSortBy: doNothing,
133
- sortingState: {
134
- sortBy: AssetSortByProperty.Criticality,
135
- order: SortOrder.Desc,
136
- },
137
- };
138
-
139
- /**
140
- * Mocks the current user context
141
- *
142
- * @returns {ICurrentUserContext} - Returns the mocked current user context
143
- */
144
- const mockCurrentUserContext = {
145
- userName: "",
146
- userRole: "",
147
- customerId: 12345,
148
- userId: 154312,
149
- tasUserId: "751ea227-f199-4d00-925f-a608312c5e45",
150
- email: "",
151
- name: "",
152
- accountId: "",
153
- assumedUser: null,
154
- jobTitle: "",
155
- isAuthenticated: true,
156
- isVerified: true,
157
- isTrackunitUser: false,
158
- isAssuming: false,
159
- isAccountOwner: true,
160
- subscriptionPackage: "EXPAND_FLEET_OWNER",
161
- };
162
-
163
- const mockEnvironmentContext = {
164
- auth: {
165
- url: "",
166
- clientId: "",
167
- issuer: "",
168
- },
169
- managerClassicUrl: "https://sso.trackunit.com",
170
- googleMapsApiKey: "",
171
- amplitudeApiKey: "",
172
- amplitudeApiEndpoint: "",
173
- graphqlPublicUrl: "",
174
- graphqlManagerUrl: "",
175
- graphqlManagerImageUploadUrl: "",
176
- graphqlReportUrl: "",
177
- buildVersion: "",
178
- commitNumber: 0,
179
- buildDate: "",
180
- irisAppSdkServerUrl: "",
181
- publicUrl: "",
182
- isDev: true,
183
- environment: "",
184
- sentryDsn: "",
185
- sessionId: "",
186
- tracingHeaders: {
187
- "X-TrackunitAppVersion": "",
188
- "session-id": "",
189
- },
190
- trackunitRestApiUrl: "",
191
- hubspotRequestAppAccessFormId: "",
192
- };
193
-
194
- const mockOemBrandingContext = {
195
- getAllBrandingDetails: doNothing,
196
- getOemBranding: doNothing,
197
- getOemImage: doNothing,
198
- };
199
-
200
- const mockToastContext = {
201
- addToast: doNothing,
202
- setIsManifestError: doNothing,
203
- };
204
-
205
- /**
206
- * This is a mock for the UserSubscriptionContext.
207
- *
208
- * @returns { IUserSubscriptionContext }- mock for the UserSubscriptionContext
209
- */
210
- const mockUserSubscriptionContext = {
211
- numberOfDaysWithAccessToHistoricalData: 30,
212
- numberOfDaysWithAccessToHistoricalInsights: 30,
213
- features: [],
214
- packageType: "EXPAND_FLEET_OWNER",
215
- };
216
-
217
27
  /******************************************************************************
218
28
  Copyright (c) Microsoft Corporation.
219
29
 
@@ -2636,11 +2446,11 @@ var _default$2i = format;
2636
2446
  default_1 = build.default = _default$2i;
2637
2447
 
2638
2448
  var index = /*#__PURE__*/_mergeNamespaces({
2639
- __proto__: null,
2640
- get DEFAULT_OPTIONS () { return DEFAULT_OPTIONS_1; },
2641
- format: format_1,
2642
- get plugins () { return plugins_1; },
2643
- get default () { return default_1; }
2449
+ __proto__: null,
2450
+ get DEFAULT_OPTIONS () { return DEFAULT_OPTIONS_1; },
2451
+ format: format_1,
2452
+ get plugins () { return plugins_1; },
2453
+ get default () { return default_1; }
2644
2454
  }, [build]);
2645
2455
 
2646
2456
  /**
@@ -16035,85 +15845,85 @@ const screen = typeof document !== 'undefined' && document.body // eslint-disabl
16035
15845
  }, initialValue);
16036
15846
 
16037
15847
  var dom_esm = /*#__PURE__*/Object.freeze({
16038
- __proto__: null,
16039
- prettyFormat: index,
16040
- buildQueries: buildQueries,
16041
- configure: configure,
16042
- createEvent: createEvent,
16043
- findAllByAltText: findAllByAltText,
16044
- findAllByDisplayValue: findAllByDisplayValue,
16045
- findAllByLabelText: findAllByLabelText,
16046
- findAllByPlaceholderText: findAllByPlaceholderText,
16047
- findAllByRole: findAllByRole,
16048
- findAllByTestId: findAllByTestId,
16049
- findAllByText: findAllByText,
16050
- findAllByTitle: findAllByTitle,
16051
- findByAltText: findByAltText,
16052
- findByDisplayValue: findByDisplayValue,
16053
- findByLabelText: findByLabelText,
16054
- findByPlaceholderText: findByPlaceholderText,
16055
- findByRole: findByRole,
16056
- findByTestId: findByTestId,
16057
- findByText: findByText,
16058
- findByTitle: findByTitle,
16059
- fireEvent: fireEvent,
16060
- getAllByAltText: getAllByAltText,
16061
- getAllByDisplayValue: getAllByDisplayValue,
16062
- getAllByLabelText: getAllByLabelTextWithSuggestions,
16063
- getAllByPlaceholderText: getAllByPlaceholderText,
16064
- getAllByRole: getAllByRole,
16065
- getAllByTestId: getAllByTestId,
16066
- getAllByText: getAllByText,
16067
- getAllByTitle: getAllByTitle,
16068
- getByAltText: getByAltText,
16069
- getByDisplayValue: getByDisplayValue,
16070
- getByLabelText: getByLabelTextWithSuggestions,
16071
- getByPlaceholderText: getByPlaceholderText,
16072
- getByRole: getByRole,
16073
- getByTestId: getByTestId,
16074
- getByText: getByText,
16075
- getByTitle: getByTitle,
16076
- getConfig: getConfig,
16077
- getDefaultNormalizer: getDefaultNormalizer,
16078
- getElementError: getElementError,
16079
- getMultipleElementsFoundError: getMultipleElementsFoundError,
16080
- getNodeText: getNodeText,
16081
- getQueriesForElement: getQueriesForElement,
16082
- getRoles: getRoles,
16083
- getSuggestedQuery: getSuggestedQuery,
16084
- isInaccessible: isInaccessible,
16085
- logDOM: logDOM,
16086
- logRoles: logRoles,
16087
- makeFindQuery: makeFindQuery,
16088
- makeGetAllQuery: makeGetAllQuery,
16089
- makeSingleQuery: makeSingleQuery,
16090
- prettyDOM: prettyDOM,
16091
- queries: queries,
16092
- queryAllByAltText: queryAllByAltTextWithSuggestions,
16093
- queryAllByAttribute: queryAllByAttribute,
16094
- queryAllByDisplayValue: queryAllByDisplayValueWithSuggestions,
16095
- queryAllByLabelText: queryAllByLabelTextWithSuggestions,
16096
- queryAllByPlaceholderText: queryAllByPlaceholderTextWithSuggestions,
16097
- queryAllByRole: queryAllByRoleWithSuggestions,
16098
- queryAllByTestId: queryAllByTestIdWithSuggestions,
16099
- queryAllByText: queryAllByTextWithSuggestions,
16100
- queryAllByTitle: queryAllByTitleWithSuggestions,
16101
- queryByAltText: queryByAltText,
16102
- queryByAttribute: queryByAttribute,
16103
- queryByDisplayValue: queryByDisplayValue,
16104
- queryByLabelText: queryByLabelText,
16105
- queryByPlaceholderText: queryByPlaceholderText,
16106
- queryByRole: queryByRole,
16107
- queryByTestId: queryByTestId,
16108
- queryByText: queryByText,
16109
- queryByTitle: queryByTitle,
16110
- queryHelpers: queryHelpers,
16111
- screen: screen,
16112
- waitFor: waitForWrapper,
16113
- waitForElementToBeRemoved: waitForElementToBeRemoved,
16114
- within: getQueriesForElement,
16115
- wrapAllByQueryWithSuggestion: wrapAllByQueryWithSuggestion,
16116
- wrapSingleQueryWithSuggestion: wrapSingleQueryWithSuggestion
15848
+ __proto__: null,
15849
+ prettyFormat: index,
15850
+ buildQueries: buildQueries,
15851
+ configure: configure,
15852
+ createEvent: createEvent,
15853
+ findAllByAltText: findAllByAltText,
15854
+ findAllByDisplayValue: findAllByDisplayValue,
15855
+ findAllByLabelText: findAllByLabelText,
15856
+ findAllByPlaceholderText: findAllByPlaceholderText,
15857
+ findAllByRole: findAllByRole,
15858
+ findAllByTestId: findAllByTestId,
15859
+ findAllByText: findAllByText,
15860
+ findAllByTitle: findAllByTitle,
15861
+ findByAltText: findByAltText,
15862
+ findByDisplayValue: findByDisplayValue,
15863
+ findByLabelText: findByLabelText,
15864
+ findByPlaceholderText: findByPlaceholderText,
15865
+ findByRole: findByRole,
15866
+ findByTestId: findByTestId,
15867
+ findByText: findByText,
15868
+ findByTitle: findByTitle,
15869
+ fireEvent: fireEvent,
15870
+ getAllByAltText: getAllByAltText,
15871
+ getAllByDisplayValue: getAllByDisplayValue,
15872
+ getAllByLabelText: getAllByLabelTextWithSuggestions,
15873
+ getAllByPlaceholderText: getAllByPlaceholderText,
15874
+ getAllByRole: getAllByRole,
15875
+ getAllByTestId: getAllByTestId,
15876
+ getAllByText: getAllByText,
15877
+ getAllByTitle: getAllByTitle,
15878
+ getByAltText: getByAltText,
15879
+ getByDisplayValue: getByDisplayValue,
15880
+ getByLabelText: getByLabelTextWithSuggestions,
15881
+ getByPlaceholderText: getByPlaceholderText,
15882
+ getByRole: getByRole,
15883
+ getByTestId: getByTestId,
15884
+ getByText: getByText,
15885
+ getByTitle: getByTitle,
15886
+ getConfig: getConfig,
15887
+ getDefaultNormalizer: getDefaultNormalizer,
15888
+ getElementError: getElementError,
15889
+ getMultipleElementsFoundError: getMultipleElementsFoundError,
15890
+ getNodeText: getNodeText,
15891
+ getQueriesForElement: getQueriesForElement,
15892
+ getRoles: getRoles,
15893
+ getSuggestedQuery: getSuggestedQuery,
15894
+ isInaccessible: isInaccessible,
15895
+ logDOM: logDOM,
15896
+ logRoles: logRoles,
15897
+ makeFindQuery: makeFindQuery,
15898
+ makeGetAllQuery: makeGetAllQuery,
15899
+ makeSingleQuery: makeSingleQuery,
15900
+ prettyDOM: prettyDOM,
15901
+ queries: queries,
15902
+ queryAllByAltText: queryAllByAltTextWithSuggestions,
15903
+ queryAllByAttribute: queryAllByAttribute,
15904
+ queryAllByDisplayValue: queryAllByDisplayValueWithSuggestions,
15905
+ queryAllByLabelText: queryAllByLabelTextWithSuggestions,
15906
+ queryAllByPlaceholderText: queryAllByPlaceholderTextWithSuggestions,
15907
+ queryAllByRole: queryAllByRoleWithSuggestions,
15908
+ queryAllByTestId: queryAllByTestIdWithSuggestions,
15909
+ queryAllByText: queryAllByTextWithSuggestions,
15910
+ queryAllByTitle: queryAllByTitleWithSuggestions,
15911
+ queryByAltText: queryByAltText,
15912
+ queryByAttribute: queryByAttribute,
15913
+ queryByDisplayValue: queryByDisplayValue,
15914
+ queryByLabelText: queryByLabelText,
15915
+ queryByPlaceholderText: queryByPlaceholderText,
15916
+ queryByRole: queryByRole,
15917
+ queryByTestId: queryByTestId,
15918
+ queryByText: queryByText,
15919
+ queryByTitle: queryByTitle,
15920
+ queryHelpers: queryHelpers,
15921
+ screen: screen,
15922
+ waitFor: waitForWrapper,
15923
+ waitForElementToBeRemoved: waitForElementToBeRemoved,
15924
+ within: getQueriesForElement,
15925
+ wrapAllByQueryWithSuggestion: wrapAllByQueryWithSuggestion,
15926
+ wrapSingleQueryWithSuggestion: wrapSingleQueryWithSuggestion
16117
15927
  });
16118
15928
 
16119
15929
  const domAct = testUtils.act;
@@ -43451,6 +43261,53 @@ function ApolloMockedProviderWithError(props) {
43451
43261
  return (jsx(MockedProvider, Object.assign({}, otherProps, { link: link, defaultOptions: Object.assign(Object.assign({}, defaultOptions), { watchQuery: { fetchPolicy: "no-cache" } }) })));
43452
43262
  }
43453
43263
 
43264
+ /**
43265
+ * Do nothing
43266
+ */
43267
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43268
+ const doNothing = () => {
43269
+ /* Do nothing */
43270
+ };
43271
+
43272
+ const mockAnalyticsContext = {
43273
+ logEvent: doNothing,
43274
+ logError: doNothing,
43275
+ logPageView: doNothing,
43276
+ setUserProperty: doNothing,
43277
+ };
43278
+
43279
+ const mockAssetSortingContext = {
43280
+ setSortBy: doNothing,
43281
+ sortingState: {
43282
+ sortBy: AssetSortByProperty.Criticality,
43283
+ order: SortOrder.Desc,
43284
+ },
43285
+ };
43286
+
43287
+ /**
43288
+ * Mocks the current user context
43289
+ *
43290
+ * @returns {ICurrentUserContext} - Returns the mocked current user context
43291
+ */
43292
+ const mockCurrentUserContext = {
43293
+ userName: "",
43294
+ userRole: "",
43295
+ customerId: 12345,
43296
+ userId: 154312,
43297
+ tasUserId: "751ea227-f199-4d00-925f-a608312c5e45",
43298
+ email: "",
43299
+ name: "",
43300
+ accountId: "",
43301
+ assumedUser: null,
43302
+ jobTitle: "",
43303
+ isAuthenticated: true,
43304
+ isVerified: true,
43305
+ isTrackunitUser: false,
43306
+ isAssuming: false,
43307
+ isAccountOwner: true,
43308
+ subscriptionPackage: "EXPAND_FLEET_OWNER",
43309
+ };
43310
+
43454
43311
  /**
43455
43312
  * Mocks the current user context
43456
43313
  *
@@ -43465,6 +43322,60 @@ const mockCurrentUserPreferenceContext = {
43465
43322
  setSystemOfMeasurement: doNothing,
43466
43323
  };
43467
43324
 
43325
+ const mockEnvironmentContext = {
43326
+ auth: {
43327
+ url: "",
43328
+ clientId: "",
43329
+ issuer: "",
43330
+ },
43331
+ managerClassicUrl: "https://sso.trackunit.com",
43332
+ googleMapsApiKey: "",
43333
+ amplitudeApiKey: "",
43334
+ amplitudeApiEndpoint: "",
43335
+ graphqlPublicUrl: "",
43336
+ graphqlManagerUrl: "",
43337
+ graphqlManagerImageUploadUrl: "",
43338
+ graphqlReportUrl: "",
43339
+ buildVersion: "",
43340
+ commitNumber: 0,
43341
+ buildDate: "",
43342
+ irisAppSdkServerUrl: "",
43343
+ publicUrl: "",
43344
+ isDev: true,
43345
+ environment: "",
43346
+ sentryDsn: "",
43347
+ sessionId: "",
43348
+ tracingHeaders: {
43349
+ "X-TrackunitAppVersion": "",
43350
+ "session-id": "",
43351
+ },
43352
+ trackunitRestApiUrl: "",
43353
+ hubspotRequestAppAccessFormId: "",
43354
+ };
43355
+
43356
+ const mockOemBrandingContext = {
43357
+ getAllBrandingDetails: doNothing,
43358
+ getOemBranding: doNothing,
43359
+ getOemImage: doNothing,
43360
+ };
43361
+
43362
+ const mockToastContext = {
43363
+ addToast: doNothing,
43364
+ setIsManifestError: doNothing,
43365
+ };
43366
+
43367
+ /**
43368
+ * This is a mock for the UserSubscriptionContext.
43369
+ *
43370
+ * @returns { IUserSubscriptionContext }- mock for the UserSubscriptionContext
43371
+ */
43372
+ const mockUserSubscriptionContext = {
43373
+ numberOfDaysWithAccessToHistoricalData: 30,
43374
+ numberOfDaysWithAccessToHistoricalInsights: 30,
43375
+ features: [],
43376
+ packageType: "EXPAND_FLEET_OWNER",
43377
+ };
43378
+
43468
43379
  /**
43469
43380
  * Flushes all promises in the queue.
43470
43381
  * This is useful when testing async code.
@@ -43958,6 +43869,95 @@ class TrackunitProvidersMockBuilder {
43958
43869
  */
43959
43870
  const trackunitProviders = () => new TrackunitProvidersMockBuilder();
43960
43871
 
43872
+ /**
43873
+ * Logs props that have changed.
43874
+ * Use this for debugging which props force a component to re-render.
43875
+ * This is a hook version of the class component lifecycle method `componentDidUpdate`.
43876
+ * ALWAYS wrap in your own object.
43877
+ *
43878
+ * @param id optional id to use for logging or it will guess the id from the stack trace
43879
+ * @param propsToWatch all the props to watch for changes
43880
+ * @example
43881
+ * const propsToWatch = { foo: props.foo, bar: props.bar };
43882
+ * useDebugger({ id: "MyComponent", propsToWatch });
43883
+ */
43884
+ const useDebugger = ({ id, propsToWatch, }) => {
43885
+ const prevPropsRef = useRef(propsToWatch);
43886
+ const uniqueId = useMemo(() => {
43887
+ var _a;
43888
+ return id || ((_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n")[2].trim()) || "unknown-id";
43889
+ }, [id]);
43890
+ useEffect(() => {
43891
+ const changedProps = Object.entries(propsToWatch || {}).reduce((result, [key, value]) => {
43892
+ if (prevPropsRef.current && prevPropsRef.current[key] !== value) {
43893
+ result[key + ""] = [prevPropsRef.current[key], value];
43894
+ }
43895
+ return result;
43896
+ }, {});
43897
+ if (Object.keys(changedProps).length > 0) {
43898
+ // eslint-disable-next-line no-console
43899
+ Object.keys(changedProps).forEach(changedProp => {
43900
+ // eslint-disable-next-line no-console
43901
+ console.log(`${uniqueId} changed property: ${changedProp}`);
43902
+ // JSON stringify is used to avoid console.table from logging the object reference
43903
+ const result = JSON.parse(JSON.stringify(changedProps[changedProp]));
43904
+ const result0 = result[0];
43905
+ const result1 = result[1];
43906
+ result0 &&
43907
+ Object.keys(result0).forEach(prop => {
43908
+ result0[prop] = JSON.stringify(result0[prop]);
43909
+ });
43910
+ result1 &&
43911
+ Object.keys(result1).forEach(prop => {
43912
+ result1[prop] = JSON.stringify(result1[prop]);
43913
+ });
43914
+ // eslint-disable-next-line no-console
43915
+ console.table([result0, result1]);
43916
+ });
43917
+ // eslint-disable-next-line no-console
43918
+ console.dir(changedProps);
43919
+ }
43920
+ prevPropsRef.current = propsToWatch;
43921
+ }, [propsToWatch, uniqueId]);
43922
+ };
43923
+ /**
43924
+ * Debugger component for debugging state changes and re-renders.
43925
+ *
43926
+ * This component will log when it is mounted, re-renders or unmounted.
43927
+ * It will also log when any of its props change.
43928
+ *
43929
+ * @param id optional id to use for logging
43930
+ * @param stop if true, will stop execution and open debugger
43931
+ * @param logPropsChanges optional object with props to watch for changes
43932
+ * @param children the children to render
43933
+ */
43934
+ const Debugger = ({ id, logPropsChanges, stop, children, }) => {
43935
+ var _a, _b, _c, _d, _e, _f;
43936
+ const uniqueId = id ||
43937
+ (
43938
+ // @ts-ignore
43939
+ (_e = (_d = (_c = (_b = (_a = React__default["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"]) === null || _a === void 0 ? void 0 : _a.ReactCurrentOwner) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c._debugOwner) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.name) ||
43940
+ ((_f = new Error().stack) === null || _f === void 0 ? void 0 : _f.split("\n")[2].trim()) ||
43941
+ "unknown-id";
43942
+ useDebugger({ id: uniqueId, propsToWatch: logPropsChanges || {} });
43943
+ // eslint-disable-next-line no-console
43944
+ console.log(`${uniqueId} Debugger is rendering`);
43945
+ useEffect(() => {
43946
+ // eslint-disable-next-line no-console
43947
+ console.log(`${uniqueId} Debugger is mounting`);
43948
+ return () => {
43949
+ // eslint-disable-next-line no-console
43950
+ console.log(`${uniqueId} Debugger is unmounting`);
43951
+ };
43952
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43953
+ }, []);
43954
+ if (stop === true) {
43955
+ // eslint-disable-next-line no-debugger
43956
+ debugger;
43957
+ }
43958
+ return jsx("div", { className: "Debugger", children: children });
43959
+ };
43960
+
43961
43961
  /**
43962
43962
  *
43963
43963
  * @param document Document that represents the specific GQL query / mutation schema.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts-test",
3
- "version": "0.1.118",
3
+ "version": "0.1.119",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -10,8 +10,8 @@
10
10
  "main": "./index.cjs.js",
11
11
  "dependencies": {
12
12
  "@apollo/client": "3.7.10",
13
- "@trackunit/react-core-contexts-api": "0.2.62",
14
- "@trackunit/react-core-hooks": "0.2.103",
13
+ "@trackunit/react-core-contexts-api": "0.2.63",
14
+ "@trackunit/react-core-hooks": "0.2.104",
15
15
  "graphql": "15.8.0",
16
16
  "lodash": "4.17.21",
17
17
  "react": "18.2.0",
package/src/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./TrackunitProvidersMockBuilder";
1
2
  export * from "./debugger";
2
3
  export * from "./mocks/mockAnalyticsContext";
3
4
  export * from "./mocks/mockAssetSortingContext";
@@ -6,7 +7,6 @@ export * from "./mocks/mockEnvironmentContext";
6
7
  export * from "./mocks/mockOemBrandingContext";
7
8
  export * from "./mocks/mockToastContext";
8
9
  export * from "./mocks/mockUserSubscriptionContext";
9
- export * from "./TrackunitProvidersMockBuilder";
10
10
  export * from "./utils/doNothing";
11
11
  export * from "./utils/queryFor";
12
12
  export * from "./utils/validateIrisApp";