@trackunit/react-core-contexts-test 0.1.233 → 0.1.235

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.cjs.js CHANGED
@@ -37,3 +37,4 @@ exports.trackunitProviders = index.trackunitProviders;
37
37
  exports.useDebugger = index.useDebugger;
38
38
  exports.useIsFirstRender = index.useIsFirstRender;
39
39
  exports.validateIrisApp = index.validateIrisApp;
40
+ exports.waitForRenderTanstackRouterQuirk = index.waitForRenderTanstackRouterQuirk;
package/index.cjs2.js CHANGED
@@ -348,7 +348,11 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
348
348
  route.options.component = entry.component;
349
349
  }
350
350
  else {
351
- route.options.component = () => (jsxRuntime.jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() }));
351
+ route.update({
352
+ component: () => {
353
+ return (jsxRuntime.jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() }));
354
+ },
355
+ });
352
356
  }
353
357
  }
354
358
  });
@@ -362,7 +366,9 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
362
366
  const childRoute = reactRouter.createRoute({
363
367
  path: "/",
364
368
  getParentRoute: () => localRootRoute,
365
- component: () => (jsxRuntime.jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() })),
369
+ component: () => {
370
+ return (jsxRuntime.jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() }));
371
+ },
366
372
  });
367
373
  localRootRoute.addChildren([childRoute]);
368
374
  }
@@ -390,7 +396,7 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
390
396
  }, [rootRoute]);
391
397
  const context = React.useMemo(() => (Object.assign({ hasAccessTo: () => __awaiter(void 0, void 0, void 0, function* () { return true; }), isAuthenticated: true, client, defaultUserRoute: "/" }, ((selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context) || {}))), [client, selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context]);
392
398
  const ErrorComponent = ({ error }) => {
393
- return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error && error instanceof Error ? error.message : error] });
399
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error instanceof Error ? error.message : error] });
394
400
  };
395
401
  return jsxRuntime.jsx(reactRouter.RouterProvider, { context: context, defaultErrorComponent: ErrorComponent, router: router });
396
402
  };
@@ -435,6 +441,18 @@ const flushPromisesInAct = (waitTimeInMS = 0) => {
435
441
  });
436
442
  });
437
443
  };
444
+ /**
445
+ * This is a temp hack to work around a Tanstack Router quirk.
446
+ * This will wait for the render to finish before resolving the promise.
447
+ *
448
+ * @param rerender - The rerender function.
449
+ */
450
+ const waitForRenderTanstackRouterQuirk = (rerender) => __awaiter(void 0, void 0, void 0, function* () {
451
+ return yield react$1.act(() => __awaiter(void 0, void 0, void 0, function* () {
452
+ rerender();
453
+ yield flushPromises();
454
+ }));
455
+ });
438
456
 
439
457
  /**
440
458
  * This builder allows you to enable trackunit providers using the builder pattern, and then call 1 of either:
@@ -923,7 +941,8 @@ const useDebugger = (propsToWatch, id) => {
923
941
  const prevPropsRef = React.useRef(propsToWatch);
924
942
  const uniqueId = React.useMemo(() => {
925
943
  var _a;
926
- let stackId = id;
944
+ // eslint-disable-next-line local-rules/no-typescript-assertion
945
+ let stackId = id || (propsToWatch && propsToWatch.id);
927
946
  const stack = new Error().stack;
928
947
  if (!stackId && stack) {
929
948
  const stackLines = stack.split("\n");
@@ -936,7 +955,7 @@ const useDebugger = (propsToWatch, id) => {
936
955
  }
937
956
  }
938
957
  return stackId || "unknown-id";
939
- }, [id]);
958
+ }, [id, propsToWatch]);
940
959
  const isFirstRender = useIsFirstRender();
941
960
  // eslint-disable-next-line no-console
942
961
  console.log(isFirstRender ? "First-render" : "Re-render", uniqueId, window.location.pathname);
@@ -996,8 +1015,6 @@ const Debugger = ({ id, logPropsChanges, stop, children, }) => {
996
1015
  ((_g = (_f = new Error().stack) === null || _f === void 0 ? void 0 : _f.split("\n")[2]) === null || _g === void 0 ? void 0 : _g.trim()) ||
997
1016
  "unknown-id";
998
1017
  useDebugger(logPropsChanges || {}, id);
999
- // eslint-disable-next-line no-console
1000
- console.log(`${uniqueId} Debugger is rendering`);
1001
1018
  React.useEffect(() => {
1002
1019
  // eslint-disable-next-line no-console
1003
1020
  console.log(`${uniqueId} Debugger is mounting`);
@@ -1168,3 +1185,4 @@ exports.trackunitProviders = trackunitProviders;
1168
1185
  exports.useDebugger = useDebugger;
1169
1186
  exports.useIsFirstRender = useIsFirstRender;
1170
1187
  exports.validateIrisApp = validateIrisApp;
1188
+ exports.waitForRenderTanstackRouterQuirk = waitForRenderTanstackRouterQuirk;
package/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- export { D as Debugger, T as TrackunitProvidersMockBuilder, i as doNothing, f as flushPromises, k as flushPromisesInAct, m as mockAnalyticsContext, b as mockAssetSortingContext, c as mockCurrentUserContext, d as mockEnvironmentContext, e as mockOemBrandingContext, g as mockToastContext, h as mockUserSubscriptionContext, q as queryFor, j as queryForHook, t as trackunitProviders, a as useDebugger, u as useIsFirstRender, v as validateIrisApp } from './index.esm2.js';
1
+ export { D as Debugger, T as TrackunitProvidersMockBuilder, i as doNothing, f as flushPromises, k as flushPromisesInAct, m as mockAnalyticsContext, b as mockAssetSortingContext, c as mockCurrentUserContext, d as mockEnvironmentContext, e as mockOemBrandingContext, g as mockToastContext, h as mockUserSubscriptionContext, q as queryFor, j as queryForHook, t as trackunitProviders, a as useDebugger, u as useIsFirstRender, v as validateIrisApp, w as waitForRenderTanstackRouterQuirk } from './index.esm2.js';
2
2
  import 'react/jsx-runtime';
3
3
  import '@testing-library/react';
4
4
  import '@trackunit/react-core-hooks';
package/index.esm2.js CHANGED
@@ -341,7 +341,11 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
341
341
  route.options.component = entry.component;
342
342
  }
343
343
  else {
344
- route.options.component = () => (jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() }));
344
+ route.update({
345
+ component: () => {
346
+ return (jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() }));
347
+ },
348
+ });
345
349
  }
346
350
  }
347
351
  });
@@ -355,7 +359,9 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
355
359
  const childRoute = createRoute({
356
360
  path: "/",
357
361
  getParentRoute: () => localRootRoute,
358
- component: () => (jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() })),
362
+ component: () => {
363
+ return (jsx(TestRenderChildren, { addTestRootContainer: addTestRootContainer, children: getChildren() }));
364
+ },
359
365
  });
360
366
  localRootRoute.addChildren([childRoute]);
361
367
  }
@@ -383,7 +389,7 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
383
389
  }, [rootRoute]);
384
390
  const context = useMemo(() => (Object.assign({ hasAccessTo: () => __awaiter(void 0, void 0, void 0, function* () { return true; }), isAuthenticated: true, client, defaultUserRoute: "/" }, ((selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context) || {}))), [client, selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context]);
385
391
  const ErrorComponent = ({ error }) => {
386
- return jsxs(Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error && error instanceof Error ? error.message : error] });
392
+ return jsxs(Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error instanceof Error ? error.message : error] });
387
393
  };
388
394
  return jsx(RouterProvider, { context: context, defaultErrorComponent: ErrorComponent, router: router });
389
395
  };
@@ -428,6 +434,18 @@ const flushPromisesInAct = (waitTimeInMS = 0) => {
428
434
  });
429
435
  });
430
436
  };
437
+ /**
438
+ * This is a temp hack to work around a Tanstack Router quirk.
439
+ * This will wait for the render to finish before resolving the promise.
440
+ *
441
+ * @param rerender - The rerender function.
442
+ */
443
+ const waitForRenderTanstackRouterQuirk = (rerender) => __awaiter(void 0, void 0, void 0, function* () {
444
+ return yield act(() => __awaiter(void 0, void 0, void 0, function* () {
445
+ rerender();
446
+ yield flushPromises();
447
+ }));
448
+ });
431
449
 
432
450
  /**
433
451
  * This builder allows you to enable trackunit providers using the builder pattern, and then call 1 of either:
@@ -916,7 +934,8 @@ const useDebugger = (propsToWatch, id) => {
916
934
  const prevPropsRef = useRef(propsToWatch);
917
935
  const uniqueId = useMemo(() => {
918
936
  var _a;
919
- let stackId = id;
937
+ // eslint-disable-next-line local-rules/no-typescript-assertion
938
+ let stackId = id || (propsToWatch && propsToWatch.id);
920
939
  const stack = new Error().stack;
921
940
  if (!stackId && stack) {
922
941
  const stackLines = stack.split("\n");
@@ -929,7 +948,7 @@ const useDebugger = (propsToWatch, id) => {
929
948
  }
930
949
  }
931
950
  return stackId || "unknown-id";
932
- }, [id]);
951
+ }, [id, propsToWatch]);
933
952
  const isFirstRender = useIsFirstRender();
934
953
  // eslint-disable-next-line no-console
935
954
  console.log(isFirstRender ? "First-render" : "Re-render", uniqueId, window.location.pathname);
@@ -989,8 +1008,6 @@ const Debugger = ({ id, logPropsChanges, stop, children, }) => {
989
1008
  ((_g = (_f = new Error().stack) === null || _f === void 0 ? void 0 : _f.split("\n")[2]) === null || _g === void 0 ? void 0 : _g.trim()) ||
990
1009
  "unknown-id";
991
1010
  useDebugger(logPropsChanges || {}, id);
992
- // eslint-disable-next-line no-console
993
- console.log(`${uniqueId} Debugger is rendering`);
994
1011
  useEffect(() => {
995
1012
  // eslint-disable-next-line no-console
996
1013
  console.log(`${uniqueId} Debugger is mounting`);
@@ -1142,4 +1159,4 @@ const validateIrisApp = (irisApp) => __awaiter(void 0, void 0, void 0, function*
1142
1159
  return null;
1143
1160
  });
1144
1161
 
1145
- export { Debugger as D, TrackunitProvidersMockBuilder as T, __awaiter as _, useDebugger as a, mockAssetSortingContext as b, mockCurrentUserContext as c, mockEnvironmentContext as d, mockOemBrandingContext as e, flushPromises as f, mockToastContext as g, mockUserSubscriptionContext as h, doNothing as i, queryForHook as j, flushPromisesInAct as k, mockAnalyticsContext as m, queryFor as q, trackunitProviders as t, useIsFirstRender as u, validateIrisApp as v };
1162
+ export { Debugger as D, TrackunitProvidersMockBuilder as T, __awaiter as _, useDebugger as a, mockAssetSortingContext as b, mockCurrentUserContext as c, mockEnvironmentContext as d, mockOemBrandingContext as e, flushPromises as f, mockToastContext as g, mockUserSubscriptionContext as h, doNothing as i, queryForHook as j, flushPromisesInAct as k, mockAnalyticsContext as m, queryFor as q, trackunitProviders as t, useIsFirstRender as u, validateIrisApp as v, waitForRenderTanstackRouterQuirk as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts-test",
3
- "version": "0.1.233",
3
+ "version": "0.1.235",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -14,7 +14,7 @@
14
14
  "@trackunit/react-core-hooks": "*",
15
15
  "lodash": "4.17.21",
16
16
  "graphql": "^15.8.0",
17
- "@tanstack/react-router": "1.31.6",
17
+ "@tanstack/react-router": "1.40.0",
18
18
  "@trackunit/shared-utils": "*"
19
19
  },
20
20
  "module": "./index.esm.js",
@@ -14,3 +14,10 @@ export declare const flushPromises: (waitTimeInMS?: number) => Promise<unknown>;
14
14
  * @returns {Promise<void>} - Returns a promise that resolves after the wait time.
15
15
  */
16
16
  export declare const flushPromisesInAct: (waitTimeInMS?: number) => Promise<unknown>;
17
+ /**
18
+ * This is a temp hack to work around a Tanstack Router quirk.
19
+ * This will wait for the render to finish before resolving the promise.
20
+ *
21
+ * @param rerender - The rerender function.
22
+ */
23
+ export declare const waitForRenderTanstackRouterQuirk: (rerender: () => void) => Promise<void>;