@trackunit/react-core-contexts-test 1.0.5 → 1.0.7

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.
Files changed (3) hide show
  1. package/index.cjs.js +11 -17
  2. package/index.esm.js +11 -17
  3. package/package.json +4 -4
package/index.cjs.js CHANGED
@@ -301,16 +301,14 @@ const TestRenderChildren = ({ addTestRootContainer, children }) => {
301
301
  * @returns {React.ReactElement} children component wrapped in a test root container
302
302
  */
303
303
  const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute, children, }) => {
304
- var _a, _b;
305
304
  const client = react.useApolloClient();
306
305
  // The current version of createMemoryHistory seem to have issues when NOT ending on / so adding a # will not effect what url is rendered but it seems to work
307
306
  const memoryHistory = React.useRef(reactRouter.createMemoryHistory({
308
- initialEntries: (_b = (_a = selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.initialEntries) === null || _a === void 0 ? void 0 : _a.map(entry => entry.path + "#")) !== null && _b !== void 0 ? _b : ["/#"],
307
+ initialEntries: selectedRouterProps?.initialEntries?.map(entry => entry.path + "#") ?? ["/#"],
309
308
  initialIndex: 0,
310
309
  }));
311
310
  const getChildren = React.useCallback(() => children, [children]);
312
311
  const router = React.useMemo(() => {
313
- var _a, _b;
314
312
  let localRootRoute = rootRoute;
315
313
  if (!localRootRoute) {
316
314
  const route = reactRouter.createRootRoute({ component: RootRouteDebugger });
@@ -339,8 +337,8 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
339
337
  // This ensures / is not redirecting to default home route
340
338
  pathsToRoute["/"].options.beforeLoad = () => { };
341
339
  }
342
- if ((((_a = selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.initialEntries) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0) {
343
- (_b = selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.initialEntries) === null || _b === void 0 ? void 0 : _b.forEach(entry => {
340
+ if ((selectedRouterProps?.initialEntries?.length || 0) > 0) {
341
+ selectedRouterProps?.initialEntries?.forEach(entry => {
344
342
  const route = pathsToRoute[entry.route];
345
343
  if (route) {
346
344
  if (entry.component) {
@@ -398,8 +396,8 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
398
396
  isAuthenticated: true,
399
397
  client,
400
398
  defaultUserRoute: "/",
401
- ...((selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context) || {}),
402
- }), [client, selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context]);
399
+ ...(selectedRouterProps?.context || {}),
400
+ }), [client, selectedRouterProps?.context]);
403
401
  const ErrorComponent = ({ error }) => {
404
402
  return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error instanceof Error ? error.message : error] });
405
403
  };
@@ -654,14 +652,13 @@ class TrackunitProvidersMockBuilder {
654
652
  * @returns { TrackunitProvidersMockBuilder } - The builder.
655
653
  */
656
654
  userSubscription(userSubscription) {
657
- var _a;
658
655
  //TODO DONT SUPPORT THE WIERD WAY OF PASSING FEATURES
659
- const featuresConverted = ((_a = userSubscription.features) === null || _a === void 0 ? void 0 : _a.map(f => {
656
+ const featuresConverted = userSubscription.features?.map(f => {
660
657
  if (typeof f === "string") {
661
658
  return { id: f, name: f };
662
659
  }
663
660
  return f;
664
- })) || [];
661
+ }) || [];
665
662
  this.selectedUserSubscriptionContext = {
666
663
  ...mockUserSubscriptionContext,
667
664
  ...omit(userSubscription, "features"),
@@ -957,7 +954,6 @@ const useIsFirstRender = () => {
957
954
  const useDebugger = (propsToWatch, id) => {
958
955
  const prevPropsRef = React.useRef(propsToWatch);
959
956
  const uniqueId = React.useMemo(() => {
960
- var _a;
961
957
  // eslint-disable-next-line local-rules/no-typescript-assertion
962
958
  let stackId = id || (propsToWatch && propsToWatch.id);
963
959
  const stack = new Error().stack;
@@ -965,8 +961,8 @@ const useDebugger = (propsToWatch, id) => {
965
961
  const stackLines = stack.split("\n");
966
962
  for (let i = 0; i < stackLines.length; i++) {
967
963
  const stackLine = stackLines[i];
968
- if (stackLine === null || stackLine === void 0 ? void 0 : stackLine.includes("useDebugger")) {
969
- stackId = (_a = stackLines[i + 1]) === null || _a === void 0 ? void 0 : _a.trim().split(" ")[1];
964
+ if (stackLine?.includes("useDebugger")) {
965
+ stackId = stackLines[i + 1]?.trim().split(" ")[1];
970
966
  break;
971
967
  }
972
968
  }
@@ -1024,12 +1020,10 @@ const useDebugger = (propsToWatch, id) => {
1024
1020
  * @param children the children to render
1025
1021
  */
1026
1022
  const Debugger = ({ id, logPropsChanges, stop, children, }) => {
1027
- var _a, _b, _c, _d, _e, _f, _g;
1028
1023
  const uniqueId = id ||
1029
- (
1030
1024
  // @ts-ignore
1031
- (_e = (_d = (_c = (_b = (_a = React["__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) ||
1032
- ((_g = (_f = new Error().stack) === null || _f === void 0 ? void 0 : _f.split("\n")[2]) === null || _g === void 0 ? void 0 : _g.trim()) ||
1025
+ React["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"]?.ReactCurrentOwner?.current?._debugOwner?.type?.name ||
1026
+ new Error().stack?.split("\n")[2]?.trim() ||
1033
1027
  "unknown-id";
1034
1028
  useDebugger(logPropsChanges || {}, id);
1035
1029
  React.useEffect(() => {
package/index.esm.js CHANGED
@@ -299,16 +299,14 @@ const TestRenderChildren = ({ addTestRootContainer, children }) => {
299
299
  * @returns {React.ReactElement} children component wrapped in a test root container
300
300
  */
301
301
  const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute, children, }) => {
302
- var _a, _b;
303
302
  const client = useApolloClient();
304
303
  // The current version of createMemoryHistory seem to have issues when NOT ending on / so adding a # will not effect what url is rendered but it seems to work
305
304
  const memoryHistory = useRef(createMemoryHistory({
306
- initialEntries: (_b = (_a = selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.initialEntries) === null || _a === void 0 ? void 0 : _a.map(entry => entry.path + "#")) !== null && _b !== void 0 ? _b : ["/#"],
305
+ initialEntries: selectedRouterProps?.initialEntries?.map(entry => entry.path + "#") ?? ["/#"],
307
306
  initialIndex: 0,
308
307
  }));
309
308
  const getChildren = useCallback(() => children, [children]);
310
309
  const router = useMemo(() => {
311
- var _a, _b;
312
310
  let localRootRoute = rootRoute;
313
311
  if (!localRootRoute) {
314
312
  const route = createRootRoute({ component: RootRouteDebugger });
@@ -337,8 +335,8 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
337
335
  // This ensures / is not redirecting to default home route
338
336
  pathsToRoute["/"].options.beforeLoad = () => { };
339
337
  }
340
- if ((((_a = selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.initialEntries) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0) {
341
- (_b = selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.initialEntries) === null || _b === void 0 ? void 0 : _b.forEach(entry => {
338
+ if ((selectedRouterProps?.initialEntries?.length || 0) > 0) {
339
+ selectedRouterProps?.initialEntries?.forEach(entry => {
342
340
  const route = pathsToRoute[entry.route];
343
341
  if (route) {
344
342
  if (entry.component) {
@@ -396,8 +394,8 @@ const RouterContainer = ({ addTestRootContainer, selectedRouterProps, rootRoute,
396
394
  isAuthenticated: true,
397
395
  client,
398
396
  defaultUserRoute: "/",
399
- ...((selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context) || {}),
400
- }), [client, selectedRouterProps === null || selectedRouterProps === void 0 ? void 0 : selectedRouterProps.context]);
397
+ ...(selectedRouterProps?.context || {}),
398
+ }), [client, selectedRouterProps?.context]);
401
399
  const ErrorComponent = ({ error }) => {
402
400
  return jsxs(Fragment, { children: ["UNCAUGHT ERROR IN TEST: ", error instanceof Error ? error.message : error] });
403
401
  };
@@ -652,14 +650,13 @@ class TrackunitProvidersMockBuilder {
652
650
  * @returns { TrackunitProvidersMockBuilder } - The builder.
653
651
  */
654
652
  userSubscription(userSubscription) {
655
- var _a;
656
653
  //TODO DONT SUPPORT THE WIERD WAY OF PASSING FEATURES
657
- const featuresConverted = ((_a = userSubscription.features) === null || _a === void 0 ? void 0 : _a.map(f => {
654
+ const featuresConverted = userSubscription.features?.map(f => {
658
655
  if (typeof f === "string") {
659
656
  return { id: f, name: f };
660
657
  }
661
658
  return f;
662
- })) || [];
659
+ }) || [];
663
660
  this.selectedUserSubscriptionContext = {
664
661
  ...mockUserSubscriptionContext,
665
662
  ...omit(userSubscription, "features"),
@@ -955,7 +952,6 @@ const useIsFirstRender = () => {
955
952
  const useDebugger = (propsToWatch, id) => {
956
953
  const prevPropsRef = useRef(propsToWatch);
957
954
  const uniqueId = useMemo(() => {
958
- var _a;
959
955
  // eslint-disable-next-line local-rules/no-typescript-assertion
960
956
  let stackId = id || (propsToWatch && propsToWatch.id);
961
957
  const stack = new Error().stack;
@@ -963,8 +959,8 @@ const useDebugger = (propsToWatch, id) => {
963
959
  const stackLines = stack.split("\n");
964
960
  for (let i = 0; i < stackLines.length; i++) {
965
961
  const stackLine = stackLines[i];
966
- if (stackLine === null || stackLine === void 0 ? void 0 : stackLine.includes("useDebugger")) {
967
- stackId = (_a = stackLines[i + 1]) === null || _a === void 0 ? void 0 : _a.trim().split(" ")[1];
962
+ if (stackLine?.includes("useDebugger")) {
963
+ stackId = stackLines[i + 1]?.trim().split(" ")[1];
968
964
  break;
969
965
  }
970
966
  }
@@ -1022,12 +1018,10 @@ const useDebugger = (propsToWatch, id) => {
1022
1018
  * @param children the children to render
1023
1019
  */
1024
1020
  const Debugger = ({ id, logPropsChanges, stop, children, }) => {
1025
- var _a, _b, _c, _d, _e, _f, _g;
1026
1021
  const uniqueId = id ||
1027
- (
1028
1022
  // @ts-ignore
1029
- (_e = (_d = (_c = (_b = (_a = React["__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) ||
1030
- ((_g = (_f = new Error().stack) === null || _f === void 0 ? void 0 : _f.split("\n")[2]) === null || _g === void 0 ? void 0 : _g.trim()) ||
1023
+ React["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"]?.ReactCurrentOwner?.current?._debugOwner?.type?.name ||
1024
+ new Error().stack?.split("\n")[2]?.trim() ||
1031
1025
  "unknown-id";
1032
1026
  useDebugger(logPropsChanges || {}, id);
1033
1027
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts-test",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -13,9 +13,9 @@
13
13
  "lodash": "4.17.21",
14
14
  "graphql": "^16.9.0",
15
15
  "@tanstack/react-router": "1.47.1",
16
- "@trackunit/react-core-contexts-api": "^1.0.5",
17
- "@trackunit/react-core-hooks": "^1.0.5",
18
- "@trackunit/shared-utils": "^1.0.3"
16
+ "@trackunit/react-core-contexts-api": "^1.0.7",
17
+ "@trackunit/react-core-hooks": "^1.0.7",
18
+ "@trackunit/shared-utils": "^1.1.1"
19
19
  },
20
20
  "module": "./index.esm.js",
21
21
  "main": "./index.cjs.js",