@contember/react-binding 2.0.0-alpha.24 → 2.0.0-alpha.25

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 (76) hide show
  1. package/dist/development/index.cjs +5 -0
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +5 -0
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/accessorPropagation/EntityKeyContext.cjs.map +1 -1
  6. package/dist/development/src/accessorPropagation/EntityKeyContext.js.map +1 -1
  7. package/dist/development/src/accessorPropagation/EnvironmentContext.cjs +12 -8
  8. package/dist/development/src/accessorPropagation/EnvironmentContext.cjs.map +1 -1
  9. package/dist/development/src/accessorPropagation/EnvironmentContext.js +12 -8
  10. package/dist/development/src/accessorPropagation/EnvironmentContext.js.map +1 -1
  11. package/dist/development/src/accessorPropagation/useEntityListSubTreeLoader.cjs +27 -12
  12. package/dist/development/src/accessorPropagation/useEntityListSubTreeLoader.cjs.map +1 -1
  13. package/dist/development/src/accessorPropagation/useEntityListSubTreeLoader.js +27 -12
  14. package/dist/development/src/accessorPropagation/useEntityListSubTreeLoader.js.map +1 -1
  15. package/dist/development/src/accessorPropagation/useEntitySubTreeLoader.cjs +33 -15
  16. package/dist/development/src/accessorPropagation/useEntitySubTreeLoader.cjs.map +1 -1
  17. package/dist/development/src/accessorPropagation/useEntitySubTreeLoader.js +33 -15
  18. package/dist/development/src/accessorPropagation/useEntitySubTreeLoader.js.map +1 -1
  19. package/dist/development/src/helperComponents/RecursionTerminator.cjs +55 -0
  20. package/dist/development/src/helperComponents/RecursionTerminator.cjs.map +1 -0
  21. package/dist/development/src/helperComponents/RecursionTerminator.js +55 -0
  22. package/dist/development/src/helperComponents/RecursionTerminator.js.map +1 -0
  23. package/dist/development/src/helperComponents/RecursionTerminatorPortal.cjs +39 -0
  24. package/dist/development/src/helperComponents/RecursionTerminatorPortal.cjs.map +1 -0
  25. package/dist/development/src/helperComponents/RecursionTerminatorPortal.js +39 -0
  26. package/dist/development/src/helperComponents/RecursionTerminatorPortal.js.map +1 -0
  27. package/dist/production/index.cjs +5 -0
  28. package/dist/production/index.cjs.map +1 -1
  29. package/dist/production/index.js +5 -0
  30. package/dist/production/index.js.map +1 -1
  31. package/dist/production/src/accessorPropagation/EntityKeyContext.cjs.map +1 -1
  32. package/dist/production/src/accessorPropagation/EntityKeyContext.js.map +1 -1
  33. package/dist/production/src/accessorPropagation/EnvironmentContext.cjs +8 -4
  34. package/dist/production/src/accessorPropagation/EnvironmentContext.cjs.map +1 -1
  35. package/dist/production/src/accessorPropagation/EnvironmentContext.js +8 -4
  36. package/dist/production/src/accessorPropagation/EnvironmentContext.js.map +1 -1
  37. package/dist/production/src/accessorPropagation/useEntityListSubTreeLoader.cjs +27 -12
  38. package/dist/production/src/accessorPropagation/useEntityListSubTreeLoader.cjs.map +1 -1
  39. package/dist/production/src/accessorPropagation/useEntityListSubTreeLoader.js +27 -12
  40. package/dist/production/src/accessorPropagation/useEntityListSubTreeLoader.js.map +1 -1
  41. package/dist/production/src/accessorPropagation/useEntitySubTreeLoader.cjs +33 -15
  42. package/dist/production/src/accessorPropagation/useEntitySubTreeLoader.cjs.map +1 -1
  43. package/dist/production/src/accessorPropagation/useEntitySubTreeLoader.js +33 -15
  44. package/dist/production/src/accessorPropagation/useEntitySubTreeLoader.js.map +1 -1
  45. package/dist/production/src/helperComponents/RecursionTerminator.cjs +55 -0
  46. package/dist/production/src/helperComponents/RecursionTerminator.cjs.map +1 -0
  47. package/dist/production/src/helperComponents/RecursionTerminator.js +55 -0
  48. package/dist/production/src/helperComponents/RecursionTerminator.js.map +1 -0
  49. package/dist/production/src/helperComponents/RecursionTerminatorPortal.cjs +35 -0
  50. package/dist/production/src/helperComponents/RecursionTerminatorPortal.cjs.map +1 -0
  51. package/dist/production/src/helperComponents/RecursionTerminatorPortal.js +35 -0
  52. package/dist/production/src/helperComponents/RecursionTerminatorPortal.js.map +1 -0
  53. package/dist/types/accessorPropagation/EntityKeyContext.d.ts +1 -1
  54. package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
  55. package/dist/types/accessorPropagation/EnvironmentContext.d.ts +4 -3
  56. package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
  57. package/dist/types/accessorPropagation/useEntityListSubTreeLoader.d.ts +9 -1
  58. package/dist/types/accessorPropagation/useEntityListSubTreeLoader.d.ts.map +1 -1
  59. package/dist/types/accessorPropagation/useEntitySubTreeLoader.d.ts +9 -1
  60. package/dist/types/accessorPropagation/useEntitySubTreeLoader.d.ts.map +1 -1
  61. package/dist/types/helperComponents/RecursionTerminator.d.ts +22 -0
  62. package/dist/types/helperComponents/RecursionTerminator.d.ts.map +1 -0
  63. package/dist/types/helperComponents/RecursionTerminatorPortal.d.ts +3 -0
  64. package/dist/types/helperComponents/RecursionTerminatorPortal.d.ts.map +1 -0
  65. package/dist/types/helperComponents/index.d.ts +2 -0
  66. package/dist/types/helperComponents/index.d.ts.map +1 -1
  67. package/dist/types/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +7 -8
  69. package/src/accessorPropagation/EntityKeyContext.ts +1 -1
  70. package/src/accessorPropagation/EnvironmentContext.tsx +14 -9
  71. package/src/accessorPropagation/useEntityListSubTreeLoader.ts +41 -12
  72. package/src/accessorPropagation/useEntitySubTreeLoader.ts +49 -16
  73. package/src/helperComponents/RecursionTerminator.tsx +73 -0
  74. package/src/helperComponents/RecursionTerminatorPortal.tsx +35 -0
  75. package/src/helperComponents/index.ts +2 -0
  76. package/src/tsconfig.json +0 -1
@@ -1,6 +1,8 @@
1
1
  import { useState, useRef, useEffect, createElement, useCallback } from "react";
2
2
  import { useExtendTree } from "./useExtendTree.js";
3
+ import { useObjectMemo } from "@contember/react-utils";
3
4
  import { EntitySubTree } from "../coreComponents/EntitySubTree.js";
5
+ const emptyObject = {};
4
6
  const useEntitySubTreeLoader = (entity, children, state) => {
5
7
  const [displayedState, setDisplayedState] = useState({
6
8
  state: "initial",
@@ -12,17 +14,19 @@ const useEntitySubTreeLoader = (entity, children, state) => {
12
14
  const currentlyLoading = useRef();
13
15
  const extendTree = useExtendTree();
14
16
  const [reloadTrigger, setReloadTrigger] = useState(null);
17
+ const memoizedEntity = useObjectMemo(entity ?? emptyObject);
18
+ const resolvedEntity = entity ? memoizedEntity : void 0;
15
19
  useEffect(() => {
16
20
  (async () => {
17
- if (!entity) {
21
+ if (!resolvedEntity) {
18
22
  return;
19
23
  }
20
24
  currentlyLoading.current = {
21
- entity,
25
+ entity: resolvedEntity,
22
26
  state
23
27
  };
24
28
  setDisplayedState((it) => {
25
- if (it.state === "initial" || it.state === "loading") {
29
+ if (it.state === "initial" || it.state === "loading" || it.state === "failed") {
26
30
  return {
27
31
  ...it,
28
32
  isLoading: true,
@@ -38,29 +42,43 @@ const useEntitySubTreeLoader = (entity, children, state) => {
38
42
  });
39
43
  const newTreeRootId = await extendTree(
40
44
  createElement(EntitySubTree, {
41
- ...entity,
45
+ ...resolvedEntity,
42
46
  children
43
47
  }),
44
- { force: reloadTrigger !== null }
48
+ {
49
+ force: reloadTrigger !== null,
50
+ onError: (e) => {
51
+ console.error(e);
52
+ currentlyLoading.current = void 0;
53
+ setDisplayedState({
54
+ state: "failed",
55
+ error: e,
56
+ entity: void 0,
57
+ treeRootId: void 0,
58
+ customState: void 0,
59
+ isLoading: false
60
+ });
61
+ }
62
+ }
45
63
  );
46
- if (currentlyLoading.current?.entity !== entity || currentlyLoading.current?.state !== state) {
47
- return;
48
- }
49
- currentlyLoading.current = void 0;
50
64
  if (newTreeRootId) {
65
+ currentlyLoading.current = void 0;
51
66
  setDisplayedState({
52
- entity,
53
- treeRootId: newTreeRootId,
54
67
  state: "loaded",
68
+ entity: resolvedEntity,
69
+ treeRootId: newTreeRootId,
55
70
  customState: state,
56
71
  isLoading: false
57
72
  });
58
73
  }
59
74
  })();
60
- }, [extendTree, entity, children, state, reloadTrigger]);
61
- return [displayedState, {
62
- reload: useCallback(() => setReloadTrigger({}), [])
63
- }];
75
+ }, [extendTree, resolvedEntity, children, state, reloadTrigger]);
76
+ return [
77
+ displayedState,
78
+ {
79
+ reload: useCallback(() => setReloadTrigger({}), [])
80
+ }
81
+ ];
64
82
  };
65
83
  export {
66
84
  useEntitySubTreeLoader
@@ -1 +1 @@
1
- {"version":3,"file":"useEntitySubTreeLoader.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/useEntitySubTreeLoader.ts"],"sourcesContent":["import { createElement, ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport { SugaredQualifiedSingleEntity, TreeRootId } from '@contember/binding'\nimport { useExtendTree } from './useExtendTree'\nimport { EntitySubTree } from '../coreComponents'\n\nexport type UseEntitySubTreeLoaderStateInitial = {\n\tstate: 'initial'\n\tentity: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: false\n}\n\nexport type UseEntitySubTreeLoaderStateLoading = {\n\tstate: 'loading'\n\tentity: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: true\n}\n\nexport type UseEntitySubTreeLoaderStateRefreshing<State> = {\n\tstate: 'refreshing'\n\tentity: SugaredQualifiedSingleEntity\n\ttreeRootId: TreeRootId | undefined\n\tcustomState: State\n\tisLoading: true\n}\n\n\nexport type UseEntitySubTreeLoaderStateLoaded<State> = {\n\tstate: 'loaded'\n\tentity: SugaredQualifiedSingleEntity\n\ttreeRootId: TreeRootId | undefined\n\tcustomState: State\n\tisLoading: false\n}\n\n\nexport type UseEntitySubTreeLoaderState<State> =\n\t| UseEntitySubTreeLoaderStateInitial\n\t| UseEntitySubTreeLoaderStateLoading\n\t| UseEntitySubTreeLoaderStateRefreshing<State>\n\t| UseEntitySubTreeLoaderStateLoaded<State>\n\nexport type EntityListSubTreeLoaderState = UseEntitySubTreeLoaderState<any>['state']\n\nexport type UseEntitySubTreeLoaderStateMethods = {\n\treload: () => void\n}\n\nexport const useEntitySubTreeLoader = <State>(entity: SugaredQualifiedSingleEntity | undefined, children: ReactNode, state?: State): [UseEntitySubTreeLoaderState<State>, UseEntitySubTreeLoaderStateMethods] => {\n\tconst [displayedState, setDisplayedState] = useState<UseEntitySubTreeLoaderState<State>>({\n\t\tstate: 'initial',\n\t\tisLoading: false,\n\t\tentity: undefined,\n\t\ttreeRootId: undefined,\n\t\tcustomState: undefined,\n\t})\n\tconst currentlyLoading = useRef<{\n\t\tentity: SugaredQualifiedSingleEntity\n\t\tstate?: State\n\t}>()\n\n\tconst extendTree = useExtendTree()\n\tconst [reloadTrigger, setReloadTrigger] = useState<object | null>(null)\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (!entity) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tcurrentlyLoading.current = {\n\t\t\t\tentity,\n\t\t\t\tstate,\n\t\t\t}\n\n\t\t\tsetDisplayedState(it => {\n\t\t\t\tif (it.state === 'initial' || it.state === 'loading') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...it,\n\t\t\t\t\t\tisLoading: true,\n\t\t\t\t\t\tstate: 'loading',\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...it,\n\t\t\t\t\t\tisLoading: true,\n\t\t\t\t\t\tstate: 'refreshing',\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tconst newTreeRootId = await extendTree(\n\t\t\t\tcreateElement(EntitySubTree, {\n\t\t\t\t\t...entity,\n\t\t\t\t\tchildren,\n\t\t\t\t}),\n\t\t\t\t{ force: reloadTrigger !== null },\n\t\t\t)\n\t\t\tif (currentlyLoading.current?.entity !== entity || currentlyLoading.current?.state !== state) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcurrentlyLoading.current = undefined\n\t\t\tif (newTreeRootId) {\n\t\t\t\tsetDisplayedState({\n\t\t\t\t\tentity: entity,\n\t\t\t\t\ttreeRootId: newTreeRootId,\n\t\t\t\t\tstate: 'loaded',\n\t\t\t\t\tcustomState: state as State,\n\t\t\t\t\tisLoading: false,\n\t\t\t\t})\n\t\t\t}\n\t\t})()\n\t}, [extendTree, entity, children, state, reloadTrigger])\n\n\treturn [displayedState, {\n\t\treload: useCallback(() => setReloadTrigger({}), []),\n\t}]\n}\n"],"names":[],"mappings":";;;AAmDO,MAAM,yBAAyB,CAAQ,QAAkD,UAAqB,UAA4F;AAChN,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAA6C;AAAA,IACxF,OAAO;AAAA,IACP,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,aAAa;AAAA,EAAA,CACb;AACD,QAAM,mBAAmB;AAKzB,QAAM,aAAa;AACnB,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAwB,IAAI;AAEtE,YAAU,MAAM;AACf,KAAC,YAAY;AACZ,UAAI,CAAC,QAAQ;AACZ;AAAA,MACD;AAEA,uBAAiB,UAAU;AAAA,QAC1B;AAAA,QACA;AAAA,MAAA;AAGD,wBAAkB,CAAM,OAAA;AACvB,YAAI,GAAG,UAAU,aAAa,GAAG,UAAU,WAAW;AAC9C,iBAAA;AAAA,YACN,GAAG;AAAA,YACH,WAAW;AAAA,YACX,OAAO;AAAA,UAAA;AAAA,QACR,OACM;AACC,iBAAA;AAAA,YACN,GAAG;AAAA,YACH,WAAW;AAAA,YACX,OAAO;AAAA,UAAA;AAAA,QAET;AAAA,MAAA,CACA;AAED,YAAM,gBAAgB,MAAM;AAAA,QAC3B,cAAc,eAAe;AAAA,UAC5B,GAAG;AAAA,UACH;AAAA,QAAA,CACA;AAAA,QACD,EAAE,OAAO,kBAAkB,KAAK;AAAA,MAAA;AAEjC,UAAI,iBAAiB,SAAS,WAAW,UAAU,iBAAiB,SAAS,UAAU,OAAO;AAC7F;AAAA,MACD;AACA,uBAAiB,UAAU;AAC3B,UAAI,eAAe;AACA,0BAAA;AAAA,UACjB;AAAA,UACA,YAAY;AAAA,UACZ,OAAO;AAAA,UACP,aAAa;AAAA,UACb,WAAW;AAAA,QAAA,CACX;AAAA,MACF;AAAA,IAAA;EACE,GACD,CAAC,YAAY,QAAQ,UAAU,OAAO,aAAa,CAAC;AAEvD,SAAO,CAAC,gBAAgB;AAAA,IACvB,QAAQ,YAAY,MAAM,iBAAiB,CAAE,CAAA,GAAG,CAAA,CAAE;AAAA,EAAA,CAClD;AACF;"}
1
+ {"version":3,"file":"useEntitySubTreeLoader.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/useEntitySubTreeLoader.ts"],"sourcesContent":["import { createElement, ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport { SugaredQualifiedSingleEntity, TreeRootId } from '@contember/binding'\nimport { useExtendTree } from './useExtendTree'\nimport { EntitySubTree } from '../coreComponents'\nimport { useObjectMemo } from '@contember/react-utils'\n\nexport type UseEntitySubTreeLoaderStateInitial = {\n\tstate: 'initial'\n\tentity: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: false\n}\n\nexport type UseEntitySubTreeLoaderStateLoading = {\n\tstate: 'loading'\n\tentity: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: true\n}\n\nexport type UseEntitySubTreeLoaderStateRefreshing<State> = {\n\tstate: 'refreshing'\n\tentity: SugaredQualifiedSingleEntity\n\ttreeRootId: TreeRootId | undefined\n\tcustomState: State\n\tisLoading: true\n}\n\n\nexport type UseEntitySubTreeLoaderStateLoaded<State> = {\n\tstate: 'loaded'\n\tentity: SugaredQualifiedSingleEntity\n\ttreeRootId: TreeRootId | undefined\n\tcustomState: State\n\tisLoading: false\n}\n\nexport type UseEntitySubTreeLoaderStateFailed = {\n\tstate: 'failed'\n\terror: unknown\n\tentity: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: false\n}\n\n\nexport type UseEntitySubTreeLoaderState<State> =\n\t| UseEntitySubTreeLoaderStateInitial\n\t| UseEntitySubTreeLoaderStateLoading\n\t| UseEntitySubTreeLoaderStateRefreshing<State>\n\t| UseEntitySubTreeLoaderStateLoaded<State>\n\t| UseEntitySubTreeLoaderStateFailed\n\nexport type EntityListSubTreeLoaderState = UseEntitySubTreeLoaderState<any>['state']\n\nexport type UseEntitySubTreeLoaderStateMethods = {\n\treload: () => void\n}\n\nconst emptyObject = {} as SugaredQualifiedSingleEntity\n\nexport const useEntitySubTreeLoader = <State>(entity: SugaredQualifiedSingleEntity | undefined, children: ReactNode, state?: State): [UseEntitySubTreeLoaderState<State>, UseEntitySubTreeLoaderStateMethods] => {\n\tconst [displayedState, setDisplayedState] = useState<UseEntitySubTreeLoaderState<State>>({\n\t\tstate: 'initial',\n\t\tisLoading: false,\n\t\tentity: undefined,\n\t\ttreeRootId: undefined,\n\t\tcustomState: undefined,\n\t})\n\tconst currentlyLoading = useRef<{\n\t\tentity: SugaredQualifiedSingleEntity\n\t\tstate?: State\n\t}>()\n\n\tconst extendTree = useExtendTree()\n\tconst [reloadTrigger, setReloadTrigger] = useState<object | null>(null)\n\tconst memoizedEntity = useObjectMemo(entity ?? emptyObject)\n\tconst resolvedEntity = entity ? memoizedEntity : undefined\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (!resolvedEntity) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tcurrentlyLoading.current = {\n\t\t\t\tentity: resolvedEntity,\n\t\t\t\tstate,\n\t\t\t}\n\n\t\t\tsetDisplayedState(it => {\n\t\t\t\tif (it.state === 'initial' || it.state === 'loading' || it.state === 'failed') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...it,\n\t\t\t\t\t\tisLoading: true,\n\t\t\t\t\t\tstate: 'loading',\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...it,\n\t\t\t\t\t\tisLoading: true,\n\t\t\t\t\t\tstate: 'refreshing',\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tconst newTreeRootId = await extendTree(\n\t\t\t\tcreateElement(EntitySubTree, {\n\t\t\t\t\t...resolvedEntity,\n\t\t\t\t\tchildren,\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\tforce: reloadTrigger !== null,\n\t\t\t\t\tonError: e => {\n\t\t\t\t\t\tconsole.error(e)\n\n\t\t\t\t\t\tcurrentlyLoading.current = undefined\n\n\t\t\t\t\t\tsetDisplayedState({\n\t\t\t\t\t\t\tstate: 'failed',\n\t\t\t\t\t\t\terror: e,\n\t\t\t\t\t\t\tentity: undefined,\n\t\t\t\t\t\t\ttreeRootId: undefined,\n\t\t\t\t\t\t\tcustomState: undefined,\n\t\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\n\n\t\t\tif (newTreeRootId) {\n\t\t\t\tcurrentlyLoading.current = undefined\n\t\t\t\tsetDisplayedState({\n\t\t\t\t\tstate: 'loaded',\n\t\t\t\t\tentity: resolvedEntity,\n\t\t\t\t\ttreeRootId: newTreeRootId,\n\t\t\t\t\tcustomState: state as State,\n\t\t\t\t\tisLoading: false,\n\t\t\t\t})\n\t\t\t}\n\t\t})()\n\t}, [extendTree, resolvedEntity, children, state, reloadTrigger])\n\n\treturn [\n\t\tdisplayedState,\n\t\t{\n\t\t\treload: useCallback(() => setReloadTrigger({}), []),\n\t\t},\n\t]\n}\n"],"names":[],"mappings":";;;;AA8DA,MAAM,cAAc,CAAA;AAEb,MAAM,yBAAyB,CAAQ,QAAkD,UAAqB,UAA4F;AAChN,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAA6C;AAAA,IACxF,OAAO;AAAA,IACP,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,aAAa;AAAA,EAAA,CACb;AACD,QAAM,mBAAmB;AAKzB,QAAM,aAAa;AACnB,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAwB,IAAI;AAChE,QAAA,iBAAiB,cAAc,UAAU,WAAW;AACpD,QAAA,iBAAiB,SAAS,iBAAiB;AAEjD,YAAU,MAAM;AACf,KAAC,YAAY;AACZ,UAAI,CAAC,gBAAgB;AACpB;AAAA,MACD;AAEA,uBAAiB,UAAU;AAAA,QAC1B,QAAQ;AAAA,QACR;AAAA,MAAA;AAGD,wBAAkB,CAAM,OAAA;AACnB,YAAA,GAAG,UAAU,aAAa,GAAG,UAAU,aAAa,GAAG,UAAU,UAAU;AACvE,iBAAA;AAAA,YACN,GAAG;AAAA,YACH,WAAW;AAAA,YACX,OAAO;AAAA,UAAA;AAAA,QACR,OACM;AACC,iBAAA;AAAA,YACN,GAAG;AAAA,YACH,WAAW;AAAA,YACX,OAAO;AAAA,UAAA;AAAA,QAET;AAAA,MAAA,CACA;AAED,YAAM,gBAAgB,MAAM;AAAA,QAC3B,cAAc,eAAe;AAAA,UAC5B,GAAG;AAAA,UACH;AAAA,QAAA,CACA;AAAA,QACD;AAAA,UACC,OAAO,kBAAkB;AAAA,UACzB,SAAS,CAAK,MAAA;AACb,oBAAQ,MAAM,CAAC;AAEf,6BAAiB,UAAU;AAET,8BAAA;AAAA,cACjB,OAAO;AAAA,cACP,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,YAAY;AAAA,cACZ,aAAa;AAAA,cACb,WAAW;AAAA,YAAA,CACX;AAAA,UACF;AAAA,QACD;AAAA,MAAA;AAID,UAAI,eAAe;AAClB,yBAAiB,UAAU;AACT,0BAAA;AAAA,UACjB,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,YAAY;AAAA,UACZ,aAAa;AAAA,UACb,WAAW;AAAA,QAAA,CACX;AAAA,MACF;AAAA,IAAA;EACE,GACD,CAAC,YAAY,gBAAgB,UAAU,OAAO,aAAa,CAAC;AAExD,SAAA;AAAA,IACN;AAAA,IACA;AAAA,MACC,QAAQ,YAAY,MAAM,iBAAiB,CAAE,CAAA,GAAG,CAAA,CAAE;AAAA,IACnD;AAAA,EAAA;AAEF;"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const binding = require("@contember/binding");
4
+ const React = require("react");
5
+ const Component = require("../coreComponents/Component.cjs");
6
+ const recursionTerminatorEnvironmentExtension = binding.Environment.createExtension((options) => {
7
+ return options;
8
+ });
9
+ const RecursionTerminator = Component.Component(({ field, children }, env) => {
10
+ const isRecursion = React.useMemo(() => {
11
+ return recursionDetector(field, env);
12
+ }, [field, env]);
13
+ return !isRecursion ? children : null;
14
+ }, ({ field, children }, env) => {
15
+ const isRecursion = recursionDetector(field, env);
16
+ return !isRecursion ? children : null;
17
+ });
18
+ const recursionDetector = (field, env) => {
19
+ const firstPathItem = getFirstPathItem(field);
20
+ if (!firstPathItem) {
21
+ return false;
22
+ }
23
+ const shouldTerminate = env.getExtension(recursionTerminatorEnvironmentExtension)?.shouldTerminate;
24
+ const shouldTerminateResult = shouldTerminate?.({ node: env.getSubTreeNode(), field: firstPathItem, environment: env });
25
+ if (shouldTerminateResult !== void 0) {
26
+ return shouldTerminateResult;
27
+ }
28
+ const node = env.getSubTreeNode();
29
+ const otherSide = node.type === "entity-list" || node.type === "entity" ? node.field.ownedBy ?? node.field.inversedBy : void 0;
30
+ if (!otherSide) {
31
+ return false;
32
+ }
33
+ if (!firstPathItem) {
34
+ return false;
35
+ }
36
+ return otherSide === firstPathItem;
37
+ };
38
+ const getFirstPathItem = (field) => {
39
+ if (typeof field.field === "string") {
40
+ return field.field.match(binding.TokenRegExps.identifier)?.[0];
41
+ }
42
+ const getFromHasOne = (relation) => {
43
+ if (Array.isArray(relation)) {
44
+ return relation?.[0].field;
45
+ }
46
+ return relation?.field;
47
+ };
48
+ if (field.kind === "hasMany") {
49
+ return getFromHasOne(field.field.hasOneRelationPath) ?? field.field.hasManyRelation.field;
50
+ }
51
+ return getFromHasOne(field.field);
52
+ };
53
+ exports.RecursionTerminator = RecursionTerminator;
54
+ exports.recursionTerminatorEnvironmentExtension = recursionTerminatorEnvironmentExtension;
55
+ //# sourceMappingURL=RecursionTerminator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecursionTerminator.cjs","sources":["../../../../../packages/react-binding/src/helperComponents/RecursionTerminator.tsx"],"sourcesContent":["import {\n\tEnvironment,\n\tSugarableHasOneRelation,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tTokenRegExps,\n} from '@contember/binding'\nimport { ReactNode, useMemo } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface RecursionTerminatorOptions {\n\tshouldTerminate?: (args: { node: Environment.AnyNode; field: string; environment: Environment }) => boolean | undefined\n}\n\nexport const recursionTerminatorEnvironmentExtension = Environment.createExtension((options: RecursionTerminatorOptions | undefined) => {\n\treturn options\n})\n\nexport interface RecursionTerminatorProps {\n\tfield:\n\t\t| { kind: 'hasOne'; field: SugaredRelativeSingleEntity['field'] }\n\t\t| { kind: 'hasMany'; field: SugaredRelativeEntityList['field'] }\n\tchildren: ReactNode\n}\n\nexport const RecursionTerminator = Component<RecursionTerminatorProps>(({ field, children }, env) => {\n\tconst isRecursion = useMemo(() => {\n\t\treturn recursionDetector(field, env)\n\t}, [field, env])\n\n\treturn !isRecursion ? children : null\n}, ({ field, children }, env) => {\n\tconst isRecursion = recursionDetector(field, env)\n\treturn !isRecursion ? children : null\n})\n\nconst recursionDetector = (field: RecursionTerminatorProps['field'], env: Environment) => {\n\tconst firstPathItem = getFirstPathItem(field)\n\tif (!firstPathItem) {\n\t\treturn false\n\t}\n\tconst shouldTerminate = env.getExtension(recursionTerminatorEnvironmentExtension)?.shouldTerminate\n\tconst shouldTerminateResult = shouldTerminate?.({ node: env.getSubTreeNode(), field: firstPathItem, environment: env })\n\tif (shouldTerminateResult !== undefined) {\n\t\treturn shouldTerminateResult\n\t}\n\n\tconst node = env.getSubTreeNode()\n\tconst otherSide = node.type === 'entity-list' || node.type === 'entity' ? (node.field.ownedBy ?? node.field.inversedBy) : undefined\n\tif (!otherSide) {\n\t\treturn false\n\t}\n\tif (!firstPathItem) {\n\t\treturn false\n\t}\n\treturn otherSide === firstPathItem\n}\n\nconst getFirstPathItem = (field: RecursionTerminatorProps['field']) => {\n\tif (typeof field.field === 'string') {\n\t\treturn field.field.match(TokenRegExps.identifier)?.[0]\n\t}\n\tconst getFromHasOne = (relation: SugarableHasOneRelation[] | SugarableHasOneRelation | undefined) => {\n\t\tif (Array.isArray(relation)) {\n\t\t\treturn relation?.[0].field\n\t\t}\n\t\treturn relation?.field\n\t}\n\tif (field.kind === 'hasMany') {\n\t\treturn getFromHasOne(field.field.hasOneRelationPath) ?? field.field.hasManyRelation.field\n\t}\n\treturn getFromHasOne(field.field)\n}\n"],"names":["Environment","Component","useMemo","TokenRegExps"],"mappings":";;;;;AAcO,MAAM,0CAA0CA,QAAA,YAAY,gBAAgB,CAAC,YAAoD;AAChI,SAAA;AACR,CAAC;AASM,MAAM,sBAAsBC,UAAoC,UAAA,CAAC,EAAE,OAAO,SAAA,GAAY,QAAQ;AAC9F,QAAA,cAAcC,MAAAA,QAAQ,MAAM;AAC1B,WAAA,kBAAkB,OAAO,GAAG;AAAA,EAAA,GACjC,CAAC,OAAO,GAAG,CAAC;AAER,SAAA,CAAC,cAAc,WAAW;AAClC,GAAG,CAAC,EAAE,OAAO,SAAA,GAAY,QAAQ;AAC1B,QAAA,cAAc,kBAAkB,OAAO,GAAG;AACzC,SAAA,CAAC,cAAc,WAAW;AAClC,CAAC;AAED,MAAM,oBAAoB,CAAC,OAA0C,QAAqB;AACnF,QAAA,gBAAgB,iBAAiB,KAAK;AAC5C,MAAI,CAAC,eAAe;AACZ,WAAA;AAAA,EACR;AACA,QAAM,kBAAkB,IAAI,aAAa,uCAAuC,GAAG;AAC7E,QAAA,wBAAwB,kBAAkB,EAAE,MAAM,IAAI,kBAAkB,OAAO,eAAe,aAAa,IAAK,CAAA;AACtH,MAAI,0BAA0B,QAAW;AACjC,WAAA;AAAA,EACR;AAEM,QAAA,OAAO,IAAI;AACjB,QAAM,YAAY,KAAK,SAAS,iBAAiB,KAAK,SAAS,WAAY,KAAK,MAAM,WAAW,KAAK,MAAM,aAAc;AAC1H,MAAI,CAAC,WAAW;AACR,WAAA;AAAA,EACR;AACA,MAAI,CAAC,eAAe;AACZ,WAAA;AAAA,EACR;AACA,SAAO,cAAc;AACtB;AAEA,MAAM,mBAAmB,CAAC,UAA6C;AAClE,MAAA,OAAO,MAAM,UAAU,UAAU;AACpC,WAAO,MAAM,MAAM,MAAMC,QAAa,aAAA,UAAU,IAAI,CAAC;AAAA,EACtD;AACM,QAAA,gBAAgB,CAAC,aAA8E;AAChG,QAAA,MAAM,QAAQ,QAAQ,GAAG;AACrB,aAAA,WAAW,CAAC,EAAE;AAAA,IACtB;AACA,WAAO,UAAU;AAAA,EAAA;AAEd,MAAA,MAAM,SAAS,WAAW;AAC7B,WAAO,cAAc,MAAM,MAAM,kBAAkB,KAAK,MAAM,MAAM,gBAAgB;AAAA,EACrF;AACO,SAAA,cAAc,MAAM,KAAK;AACjC;;;"}
@@ -0,0 +1,55 @@
1
+ import { Environment, TokenRegExps } from "@contember/binding";
2
+ import { useMemo } from "react";
3
+ import { Component } from "../coreComponents/Component.js";
4
+ const recursionTerminatorEnvironmentExtension = Environment.createExtension((options) => {
5
+ return options;
6
+ });
7
+ const RecursionTerminator = Component(({ field, children }, env) => {
8
+ const isRecursion = useMemo(() => {
9
+ return recursionDetector(field, env);
10
+ }, [field, env]);
11
+ return !isRecursion ? children : null;
12
+ }, ({ field, children }, env) => {
13
+ const isRecursion = recursionDetector(field, env);
14
+ return !isRecursion ? children : null;
15
+ });
16
+ const recursionDetector = (field, env) => {
17
+ const firstPathItem = getFirstPathItem(field);
18
+ if (!firstPathItem) {
19
+ return false;
20
+ }
21
+ const shouldTerminate = env.getExtension(recursionTerminatorEnvironmentExtension)?.shouldTerminate;
22
+ const shouldTerminateResult = shouldTerminate?.({ node: env.getSubTreeNode(), field: firstPathItem, environment: env });
23
+ if (shouldTerminateResult !== void 0) {
24
+ return shouldTerminateResult;
25
+ }
26
+ const node = env.getSubTreeNode();
27
+ const otherSide = node.type === "entity-list" || node.type === "entity" ? node.field.ownedBy ?? node.field.inversedBy : void 0;
28
+ if (!otherSide) {
29
+ return false;
30
+ }
31
+ if (!firstPathItem) {
32
+ return false;
33
+ }
34
+ return otherSide === firstPathItem;
35
+ };
36
+ const getFirstPathItem = (field) => {
37
+ if (typeof field.field === "string") {
38
+ return field.field.match(TokenRegExps.identifier)?.[0];
39
+ }
40
+ const getFromHasOne = (relation) => {
41
+ if (Array.isArray(relation)) {
42
+ return relation?.[0].field;
43
+ }
44
+ return relation?.field;
45
+ };
46
+ if (field.kind === "hasMany") {
47
+ return getFromHasOne(field.field.hasOneRelationPath) ?? field.field.hasManyRelation.field;
48
+ }
49
+ return getFromHasOne(field.field);
50
+ };
51
+ export {
52
+ RecursionTerminator,
53
+ recursionTerminatorEnvironmentExtension
54
+ };
55
+ //# sourceMappingURL=RecursionTerminator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecursionTerminator.js","sources":["../../../../../packages/react-binding/src/helperComponents/RecursionTerminator.tsx"],"sourcesContent":["import {\n\tEnvironment,\n\tSugarableHasOneRelation,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tTokenRegExps,\n} from '@contember/binding'\nimport { ReactNode, useMemo } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface RecursionTerminatorOptions {\n\tshouldTerminate?: (args: { node: Environment.AnyNode; field: string; environment: Environment }) => boolean | undefined\n}\n\nexport const recursionTerminatorEnvironmentExtension = Environment.createExtension((options: RecursionTerminatorOptions | undefined) => {\n\treturn options\n})\n\nexport interface RecursionTerminatorProps {\n\tfield:\n\t\t| { kind: 'hasOne'; field: SugaredRelativeSingleEntity['field'] }\n\t\t| { kind: 'hasMany'; field: SugaredRelativeEntityList['field'] }\n\tchildren: ReactNode\n}\n\nexport const RecursionTerminator = Component<RecursionTerminatorProps>(({ field, children }, env) => {\n\tconst isRecursion = useMemo(() => {\n\t\treturn recursionDetector(field, env)\n\t}, [field, env])\n\n\treturn !isRecursion ? children : null\n}, ({ field, children }, env) => {\n\tconst isRecursion = recursionDetector(field, env)\n\treturn !isRecursion ? children : null\n})\n\nconst recursionDetector = (field: RecursionTerminatorProps['field'], env: Environment) => {\n\tconst firstPathItem = getFirstPathItem(field)\n\tif (!firstPathItem) {\n\t\treturn false\n\t}\n\tconst shouldTerminate = env.getExtension(recursionTerminatorEnvironmentExtension)?.shouldTerminate\n\tconst shouldTerminateResult = shouldTerminate?.({ node: env.getSubTreeNode(), field: firstPathItem, environment: env })\n\tif (shouldTerminateResult !== undefined) {\n\t\treturn shouldTerminateResult\n\t}\n\n\tconst node = env.getSubTreeNode()\n\tconst otherSide = node.type === 'entity-list' || node.type === 'entity' ? (node.field.ownedBy ?? node.field.inversedBy) : undefined\n\tif (!otherSide) {\n\t\treturn false\n\t}\n\tif (!firstPathItem) {\n\t\treturn false\n\t}\n\treturn otherSide === firstPathItem\n}\n\nconst getFirstPathItem = (field: RecursionTerminatorProps['field']) => {\n\tif (typeof field.field === 'string') {\n\t\treturn field.field.match(TokenRegExps.identifier)?.[0]\n\t}\n\tconst getFromHasOne = (relation: SugarableHasOneRelation[] | SugarableHasOneRelation | undefined) => {\n\t\tif (Array.isArray(relation)) {\n\t\t\treturn relation?.[0].field\n\t\t}\n\t\treturn relation?.field\n\t}\n\tif (field.kind === 'hasMany') {\n\t\treturn getFromHasOne(field.field.hasOneRelationPath) ?? field.field.hasManyRelation.field\n\t}\n\treturn getFromHasOne(field.field)\n}\n"],"names":[],"mappings":";;;AAcO,MAAM,0CAA0C,YAAY,gBAAgB,CAAC,YAAoD;AAChI,SAAA;AACR,CAAC;AASM,MAAM,sBAAsB,UAAoC,CAAC,EAAE,OAAO,SAAA,GAAY,QAAQ;AAC9F,QAAA,cAAc,QAAQ,MAAM;AAC1B,WAAA,kBAAkB,OAAO,GAAG;AAAA,EAAA,GACjC,CAAC,OAAO,GAAG,CAAC;AAER,SAAA,CAAC,cAAc,WAAW;AAClC,GAAG,CAAC,EAAE,OAAO,SAAA,GAAY,QAAQ;AAC1B,QAAA,cAAc,kBAAkB,OAAO,GAAG;AACzC,SAAA,CAAC,cAAc,WAAW;AAClC,CAAC;AAED,MAAM,oBAAoB,CAAC,OAA0C,QAAqB;AACnF,QAAA,gBAAgB,iBAAiB,KAAK;AAC5C,MAAI,CAAC,eAAe;AACZ,WAAA;AAAA,EACR;AACA,QAAM,kBAAkB,IAAI,aAAa,uCAAuC,GAAG;AAC7E,QAAA,wBAAwB,kBAAkB,EAAE,MAAM,IAAI,kBAAkB,OAAO,eAAe,aAAa,IAAK,CAAA;AACtH,MAAI,0BAA0B,QAAW;AACjC,WAAA;AAAA,EACR;AAEM,QAAA,OAAO,IAAI;AACjB,QAAM,YAAY,KAAK,SAAS,iBAAiB,KAAK,SAAS,WAAY,KAAK,MAAM,WAAW,KAAK,MAAM,aAAc;AAC1H,MAAI,CAAC,WAAW;AACR,WAAA;AAAA,EACR;AACA,MAAI,CAAC,eAAe;AACZ,WAAA;AAAA,EACR;AACA,SAAO,cAAc;AACtB;AAEA,MAAM,mBAAmB,CAAC,UAA6C;AAClE,MAAA,OAAO,MAAM,UAAU,UAAU;AACpC,WAAO,MAAM,MAAM,MAAM,aAAa,UAAU,IAAI,CAAC;AAAA,EACtD;AACM,QAAA,gBAAgB,CAAC,aAA8E;AAChG,QAAA,MAAM,QAAQ,QAAQ,GAAG;AACrB,aAAA,WAAW,CAAC,EAAE;AAAA,IACtB;AACA,WAAO,UAAU;AAAA,EAAA;AAEd,MAAA,MAAM,SAAS,WAAW;AAC7B,WAAO,cAAc,MAAM,MAAM,kBAAkB,KAAK,MAAM,MAAM,gBAAgB;AAAA,EACrF;AACO,SAAA,cAAc,MAAM,KAAK;AACjC;"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxDevRuntime = require("react/jsx-dev-runtime");
4
+ const binding = require("@contember/binding");
5
+ const RecursionTerminator = require("./RecursionTerminator.cjs");
6
+ const Component = require("../coreComponents/Component.cjs");
7
+ const EnvironmentContext = require("../accessorPropagation/EnvironmentContext.cjs");
8
+ const RecursionTerminatorPortal = Component.Component(({ field, children }) => {
9
+ return /* @__PURE__ */ jsxDevRuntime.jsxDEV(EnvironmentContext.EnvironmentMiddleware, { args: [field], create: createEnvWithExtension, children }, void 0, false, {
10
+ fileName: "/home/runner/work/contember/contember/packages/react-binding/src/helperComponents/RecursionTerminatorPortal.tsx",
11
+ lineNumber: 7,
12
+ columnNumber: 9
13
+ }, void 0);
14
+ });
15
+ const createEnvWithExtension = (env, [{ field, kind }]) => {
16
+ const envForField = kind === "hasOne" ? binding.TreeNodeEnvironmentFactory.createEnvironmentForEntity(env, { field }) : binding.TreeNodeEnvironmentFactory.createEnvironmentForEntityList(env, { field });
17
+ const parentNode = envForField.getSubTreeNode();
18
+ if (!(parentNode.type === "entity-list" || parentNode.type === "entity")) {
19
+ throw new binding.BindingError();
20
+ }
21
+ return env.withExtension(RecursionTerminator.recursionTerminatorEnvironmentExtension, {
22
+ shouldTerminate: (args) => {
23
+ if (args.environment.getParent().getSubTreeNode() !== env.getSubTreeNode()) {
24
+ return void 0;
25
+ }
26
+ const currentNode = args.node;
27
+ if (currentNode.type !== "subtree-entity" || currentNode.entity.name !== parentNode.field.targetEntity) {
28
+ return void 0;
29
+ }
30
+ const inverseField = parentNode.field.inversedBy ?? parentNode.field.ownedBy;
31
+ if (!inverseField) {
32
+ return false;
33
+ }
34
+ return args.field === inverseField;
35
+ }
36
+ });
37
+ };
38
+ exports.RecursionTerminatorPortal = RecursionTerminatorPortal;
39
+ //# sourceMappingURL=RecursionTerminatorPortal.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecursionTerminatorPortal.cjs","sources":["../../../../../packages/react-binding/src/helperComponents/RecursionTerminatorPortal.tsx"],"sourcesContent":["import { BindingError, Environment, TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { Component } from '../coreComponents'\nimport { recursionTerminatorEnvironmentExtension, RecursionTerminatorProps } from './RecursionTerminator'\nimport { EnvironmentMiddleware } from '../accessorPropagation'\n\nexport const RecursionTerminatorPortal = Component<RecursionTerminatorProps>(({ field, children }) => {\n\treturn <EnvironmentMiddleware args={[field]} create={createEnvWithExtension} >{children}</EnvironmentMiddleware>\n})\n\nconst createEnvWithExtension = (env: Environment, [{ field, kind }]: [field: RecursionTerminatorProps['field']]) => {\n\tconst envForField = kind === 'hasOne'\n\t\t? TreeNodeEnvironmentFactory.createEnvironmentForEntity(env, { field })\n\t\t: TreeNodeEnvironmentFactory.createEnvironmentForEntityList(env, { field })\n\n\tconst parentNode = envForField.getSubTreeNode()\n\tif (!(parentNode.type === 'entity-list' || parentNode.type === 'entity')) {\n\t\tthrow new BindingError()\n\t}\n\treturn env.withExtension(recursionTerminatorEnvironmentExtension, {\n\t\tshouldTerminate: args => {\n\t\t\tif (args.environment.getParent().getSubTreeNode() !== env.getSubTreeNode()) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tconst currentNode = args.node\n\t\t\tif (currentNode.type !== 'subtree-entity' || currentNode.entity.name !== parentNode.field.targetEntity) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tconst inverseField = parentNode.field.inversedBy ?? parentNode.field.ownedBy\n\t\t\tif (!inverseField) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn args.field === inverseField\n\t\t},\n\t})\n}\n"],"names":["Component","jsxDEV","EnvironmentMiddleware","this","TreeNodeEnvironmentFactory","BindingError","recursionTerminatorEnvironmentExtension"],"mappings":";;;;;;;AAKO,MAAM,4BAA4BA,UAAAA,UAAoC,CAAC,EAAE,OAAO,eAAe;AAC9F,SAAAC,qCAACC,mBAAAA,yBAAsB,MAAM,CAAC,KAAK,GAAG,QAAQ,wBAA0B,SAAxE,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAiF,GAAAC,MAAA;AACzF,CAAC;AAED,MAAM,yBAAyB,CAAC,KAAkB,CAAC,EAAE,OAAO,KAAM,CAAA,MAAkD;AACnH,QAAM,cAAc,SAAS,WAC1BC,QAAAA,2BAA2B,2BAA2B,KAAK,EAAE,MAAM,CAAC,IACpEA,QAA2B,2BAAA,+BAA+B,KAAK,EAAE,MAAO,CAAA;AAErE,QAAA,aAAa,YAAY;AAC/B,MAAI,EAAE,WAAW,SAAS,iBAAiB,WAAW,SAAS,WAAW;AACzE,UAAM,IAAIC,QAAa,aAAA;AAAA,EACxB;AACO,SAAA,IAAI,cAAcC,6DAAyC;AAAA,IACjE,iBAAiB,CAAQ,SAAA;AACpB,UAAA,KAAK,YAAY,UAAU,EAAE,qBAAqB,IAAI,kBAAkB;AACpE,eAAA;AAAA,MACR;AACA,YAAM,cAAc,KAAK;AACrB,UAAA,YAAY,SAAS,oBAAoB,YAAY,OAAO,SAAS,WAAW,MAAM,cAAc;AAChG,eAAA;AAAA,MACR;AACA,YAAM,eAAe,WAAW,MAAM,cAAc,WAAW,MAAM;AACrE,UAAI,CAAC,cAAc;AACX,eAAA;AAAA,MACR;AACA,aAAO,KAAK,UAAU;AAAA,IACvB;AAAA,EAAA,CACA;AACF;;"}
@@ -0,0 +1,39 @@
1
+ import { jsxDEV } from "react/jsx-dev-runtime";
2
+ import { TreeNodeEnvironmentFactory, BindingError } from "@contember/binding";
3
+ import { recursionTerminatorEnvironmentExtension } from "./RecursionTerminator.js";
4
+ import { Component } from "../coreComponents/Component.js";
5
+ import { EnvironmentMiddleware } from "../accessorPropagation/EnvironmentContext.js";
6
+ const RecursionTerminatorPortal = Component(({ field, children }) => {
7
+ return /* @__PURE__ */ jsxDEV(EnvironmentMiddleware, { args: [field], create: createEnvWithExtension, children }, void 0, false, {
8
+ fileName: "/home/runner/work/contember/contember/packages/react-binding/src/helperComponents/RecursionTerminatorPortal.tsx",
9
+ lineNumber: 7,
10
+ columnNumber: 9
11
+ }, void 0);
12
+ });
13
+ const createEnvWithExtension = (env, [{ field, kind }]) => {
14
+ const envForField = kind === "hasOne" ? TreeNodeEnvironmentFactory.createEnvironmentForEntity(env, { field }) : TreeNodeEnvironmentFactory.createEnvironmentForEntityList(env, { field });
15
+ const parentNode = envForField.getSubTreeNode();
16
+ if (!(parentNode.type === "entity-list" || parentNode.type === "entity")) {
17
+ throw new BindingError();
18
+ }
19
+ return env.withExtension(recursionTerminatorEnvironmentExtension, {
20
+ shouldTerminate: (args) => {
21
+ if (args.environment.getParent().getSubTreeNode() !== env.getSubTreeNode()) {
22
+ return void 0;
23
+ }
24
+ const currentNode = args.node;
25
+ if (currentNode.type !== "subtree-entity" || currentNode.entity.name !== parentNode.field.targetEntity) {
26
+ return void 0;
27
+ }
28
+ const inverseField = parentNode.field.inversedBy ?? parentNode.field.ownedBy;
29
+ if (!inverseField) {
30
+ return false;
31
+ }
32
+ return args.field === inverseField;
33
+ }
34
+ });
35
+ };
36
+ export {
37
+ RecursionTerminatorPortal
38
+ };
39
+ //# sourceMappingURL=RecursionTerminatorPortal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecursionTerminatorPortal.js","sources":["../../../../../packages/react-binding/src/helperComponents/RecursionTerminatorPortal.tsx"],"sourcesContent":["import { BindingError, Environment, TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { Component } from '../coreComponents'\nimport { recursionTerminatorEnvironmentExtension, RecursionTerminatorProps } from './RecursionTerminator'\nimport { EnvironmentMiddleware } from '../accessorPropagation'\n\nexport const RecursionTerminatorPortal = Component<RecursionTerminatorProps>(({ field, children }) => {\n\treturn <EnvironmentMiddleware args={[field]} create={createEnvWithExtension} >{children}</EnvironmentMiddleware>\n})\n\nconst createEnvWithExtension = (env: Environment, [{ field, kind }]: [field: RecursionTerminatorProps['field']]) => {\n\tconst envForField = kind === 'hasOne'\n\t\t? TreeNodeEnvironmentFactory.createEnvironmentForEntity(env, { field })\n\t\t: TreeNodeEnvironmentFactory.createEnvironmentForEntityList(env, { field })\n\n\tconst parentNode = envForField.getSubTreeNode()\n\tif (!(parentNode.type === 'entity-list' || parentNode.type === 'entity')) {\n\t\tthrow new BindingError()\n\t}\n\treturn env.withExtension(recursionTerminatorEnvironmentExtension, {\n\t\tshouldTerminate: args => {\n\t\t\tif (args.environment.getParent().getSubTreeNode() !== env.getSubTreeNode()) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tconst currentNode = args.node\n\t\t\tif (currentNode.type !== 'subtree-entity' || currentNode.entity.name !== parentNode.field.targetEntity) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tconst inverseField = parentNode.field.inversedBy ?? parentNode.field.ownedBy\n\t\t\tif (!inverseField) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn args.field === inverseField\n\t\t},\n\t})\n}\n"],"names":["this"],"mappings":";;;;;AAKO,MAAM,4BAA4B,UAAoC,CAAC,EAAE,OAAO,eAAe;AAC9F,SAAA,uBAAC,yBAAsB,MAAM,CAAC,KAAK,GAAG,QAAQ,wBAA0B,SAAxE,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAiF,GAAAA,MAAA;AACzF,CAAC;AAED,MAAM,yBAAyB,CAAC,KAAkB,CAAC,EAAE,OAAO,KAAM,CAAA,MAAkD;AACnH,QAAM,cAAc,SAAS,WAC1B,2BAA2B,2BAA2B,KAAK,EAAE,MAAM,CAAC,IACpE,2BAA2B,+BAA+B,KAAK,EAAE,MAAO,CAAA;AAErE,QAAA,aAAa,YAAY;AAC/B,MAAI,EAAE,WAAW,SAAS,iBAAiB,WAAW,SAAS,WAAW;AACzE,UAAM,IAAI,aAAa;AAAA,EACxB;AACO,SAAA,IAAI,cAAc,yCAAyC;AAAA,IACjE,iBAAiB,CAAQ,SAAA;AACpB,UAAA,KAAK,YAAY,UAAU,EAAE,qBAAqB,IAAI,kBAAkB;AACpE,eAAA;AAAA,MACR;AACA,YAAM,cAAc,KAAK;AACrB,UAAA,YAAY,SAAS,oBAAoB,YAAY,OAAO,SAAS,WAAW,MAAM,cAAc;AAChG,eAAA;AAAA,MACR;AACA,YAAM,eAAe,WAAW,MAAM,cAAc,WAAW,MAAM;AACrE,UAAI,CAAC,cAAc;AACX,eAAA;AAAA,MACR;AACA,aAAO,KAAK,UAAU;AAAA,IACvB;AAAA,EAAA,CACA;AACF;"}
@@ -63,6 +63,8 @@ const EntityView = require("./src/helperComponents/EntityView.cjs");
63
63
  const If = require("./src/helperComponents/If.cjs");
64
64
  const FieldView = require("./src/helperComponents/FieldView.cjs");
65
65
  const LabelMiddleware = require("./src/helperComponents/LabelMiddleware.cjs");
66
+ const RecursionTerminator = require("./src/helperComponents/RecursionTerminator.cjs");
67
+ const RecursionTerminatorPortal = require("./src/helperComponents/RecursionTerminatorPortal.cjs");
66
68
  const StaticRender = require("./src/helperComponents/StaticRender.cjs");
67
69
  const SugaredField = require("./src/helperComponents/SugaredField.cjs");
68
70
  const Variable = require("./src/helperComponents/Variable.cjs");
@@ -133,6 +135,9 @@ exports.FieldView = FieldView.FieldView;
133
135
  exports.LabelMiddlewareContext = LabelMiddleware.LabelMiddlewareContext;
134
136
  exports.LabelMiddlewareProvider = LabelMiddleware.LabelMiddlewareProvider;
135
137
  exports.useLabelMiddleware = LabelMiddleware.useLabelMiddleware;
138
+ exports.RecursionTerminator = RecursionTerminator.RecursionTerminator;
139
+ exports.recursionTerminatorEnvironmentExtension = RecursionTerminator.recursionTerminatorEnvironmentExtension;
140
+ exports.RecursionTerminatorPortal = RecursionTerminatorPortal.RecursionTerminatorPortal;
136
141
  exports.StaticRender = StaticRender.StaticRender;
137
142
  exports.SugaredField = SugaredField.SugaredField;
138
143
  exports.Variable = Variable.Variable;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -61,6 +61,8 @@ import { EntityView } from "./src/helperComponents/EntityView.js";
61
61
  import { If } from "./src/helperComponents/If.js";
62
62
  import { FieldView } from "./src/helperComponents/FieldView.js";
63
63
  import { LabelMiddlewareContext, LabelMiddlewareProvider, useLabelMiddleware } from "./src/helperComponents/LabelMiddleware.js";
64
+ import { RecursionTerminator, recursionTerminatorEnvironmentExtension } from "./src/helperComponents/RecursionTerminator.js";
65
+ import { RecursionTerminatorPortal } from "./src/helperComponents/RecursionTerminatorPortal.js";
64
66
  import { StaticRender } from "./src/helperComponents/StaticRender.js";
65
67
  import { SugaredField } from "./src/helperComponents/SugaredField.js";
66
68
  import { Variable } from "./src/helperComponents/Variable.js";
@@ -93,12 +95,15 @@ export {
93
95
  MarkerTreeGenerator,
94
96
  MutationStateContext,
95
97
  ParentEntity,
98
+ RecursionTerminator,
99
+ RecursionTerminatorPortal,
96
100
  SetOrderFieldOnCreate,
97
101
  StaticRender,
98
102
  SugaredField,
99
103
  TreeRootIdProvider,
100
104
  Variable,
101
105
  addEntityAtIndex,
106
+ recursionTerminatorEnvironmentExtension,
102
107
  repairEntitiesOrder,
103
108
  sortEntities,
104
109
  useAccessorTreeState,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"EntityKeyContext.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/EntityKeyContext.ts"],"sourcesContent":["import { EntityAccessor } from '@contember/binding-common'\nimport { createContext } from 'react'\n\nexport const EntityKeyContext = createContext<undefined | string | (() => EntityAccessor)>(undefined)\nEntityKeyContext.displayName = 'EntityKeyContext'\n"],"names":["createContext"],"mappings":";;;AAGa,MAAA,mBAAmBA,MAAAA,cAA2D,MAAS;AACpG,iBAAiB,cAAc;;"}
1
+ {"version":3,"file":"EntityKeyContext.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/EntityKeyContext.ts"],"sourcesContent":["import { EntityAccessor } from '@contember/binding'\nimport { createContext } from 'react'\n\nexport const EntityKeyContext = createContext<undefined | string | (() => EntityAccessor)>(undefined)\nEntityKeyContext.displayName = 'EntityKeyContext'\n"],"names":["createContext"],"mappings":";;;AAGa,MAAA,mBAAmBA,MAAAA,cAA2D,MAAS;AACpG,iBAAiB,cAAc;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"EntityKeyContext.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/EntityKeyContext.ts"],"sourcesContent":["import { EntityAccessor } from '@contember/binding-common'\nimport { createContext } from 'react'\n\nexport const EntityKeyContext = createContext<undefined | string | (() => EntityAccessor)>(undefined)\nEntityKeyContext.displayName = 'EntityKeyContext'\n"],"names":[],"mappings":";AAGa,MAAA,mBAAmB,cAA2D,MAAS;AACpG,iBAAiB,cAAc;"}
1
+ {"version":3,"file":"EntityKeyContext.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/EntityKeyContext.ts"],"sourcesContent":["import { EntityAccessor } from '@contember/binding'\nimport { createContext } from 'react'\n\nexport const EntityKeyContext = createContext<undefined | string | (() => EntityAccessor)>(undefined)\nEntityKeyContext.displayName = 'EntityKeyContext'\n"],"names":[],"mappings":";AAGa,MAAA,mBAAmB,cAA2D,MAAS;AACpG,iBAAiB,cAAc;"}
@@ -8,17 +8,21 @@ const Component = require("../coreComponents/Component.cjs");
8
8
  const EnvironmentContext = React.createContext(binding.Environment.create());
9
9
  EnvironmentContext.displayName = "EnvironmentContext";
10
10
  const EnvironmentMiddleware = Component.Component(
11
- ({ children, create }) => {
11
+ ({ children, create, args }) => {
12
12
  const env = useEnvironment.useEnvironment();
13
- const envWithExtension = React.useMemo(() => create(env), [env, create]);
13
+ const envWithExtension = React.useMemo(
14
+ () => create(env, args ?? []),
15
+ // eslint-disable-next-line react-hooks/exhaustive-deps
16
+ [env, create, ...args ?? []]
17
+ );
14
18
  return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentContext.Provider, { value: envWithExtension, children });
15
19
  },
16
20
  {
17
21
  staticRender: ({ children }) => {
18
22
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
19
23
  },
20
- generateEnvironment: ({ create }, env) => {
21
- return create(env);
24
+ generateEnvironment: ({ create, args }, env) => {
25
+ return create(env, args ?? []);
22
26
  }
23
27
  }
24
28
  );
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentContext.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/EnvironmentContext.tsx"],"sourcesContent":["import { createContext, ReactNode, useCallback, useMemo } from 'react'\nimport { Environment } from '@contember/binding'\nimport { useEnvironment } from './useEnvironment'\nimport { Component } from '../coreComponents'\n\nexport const EnvironmentContext = createContext<Environment>(Environment.create())\nEnvironmentContext.displayName = 'EnvironmentContext'\n\nexport interface EnvironmentMiddlewareProps {\n\tchildren: ReactNode\n\tcreate: (env: Environment) => Environment\n}\n\nexport const EnvironmentMiddleware = Component(\n\t({ children, create }: EnvironmentMiddlewareProps) => {\n\t\tconst env = useEnvironment()\n\t\tconst envWithExtension = useMemo(() => create(env), [env, create])\n\n\t\treturn <EnvironmentContext.Provider value={envWithExtension}>{children}</EnvironmentContext.Provider>\n\t},\n\t{\n\t\tstaticRender: ({ children }) => {\n\t\t\treturn <>{children}</>\n\t\t},\n\t\tgenerateEnvironment: ({ create }, env) => {\n\t\t\treturn create(env)\n\t\t},\n\t},\n)\n\nexport interface EnvironmentWithExtensionProps<S, R> {\n\tchildren: ReactNode\n\textension: Environment.Extension<S, R>\n\tstate: S\n}\n\nexport const EnvironmentExtensionProvider: <S, R>(props: EnvironmentWithExtensionProps<S, R>) => ReactNode = Component(\n\t({ children, extension, state }) => {\n\t\tconst create = useCallback((env: Environment) => env.withExtension(extension, state), [extension, state])\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n\t({ children, extension, state }) => {\n\t\tconst create = (env: Environment) => env.withExtension(extension, state)\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n)\n"],"names":["createContext","Environment","Component","useEnvironment","useMemo","useCallback","jsx"],"mappings":";;;;;;;AAKO,MAAM,qBAAqBA,MAAA,cAA2BC,oBAAY,QAAQ;AACjF,mBAAmB,cAAc;AAO1B,MAAM,wBAAwBC,UAAA;AAAA,EACpC,CAAC,EAAE,UAAU,aAAyC;AACrD,UAAM,MAAMC,eAAAA;AACN,UAAA,mBAAmBC,cAAQ,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,MAAM,CAAC;AAEjE,0CAAQ,mBAAmB,UAAnB,EAA4B,OAAO,kBAAmB,SAAS,CAAA;AAAA,EACxE;AAAA,EACA;AAAA,IACC,cAAc,CAAC,EAAE,eAAe;AAC/B,mEAAU,SAAS,CAAA;AAAA,IACpB;AAAA,IACA,qBAAqB,CAAC,EAAE,UAAU,QAAQ;AACzC,aAAO,OAAO,GAAG;AAAA,IAClB;AAAA,EACD;AACD;AAQO,MAAM,+BAAgGF,UAAA;AAAA,EAC5G,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,UAAM,SAASG,MAAAA,YAAY,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,CAAC;AACjG,WAAAC,2BAAA,IAAC,uBAAsB,EAAA,QAAiB,SAAS,CAAA;AAAA,EACzD;AAAA,EACA,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,UAAM,SAAS,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK;AAChE,WAAAA,2BAAA,IAAC,uBAAsB,EAAA,QAAiB,SAAS,CAAA;AAAA,EACzD;AACD;;;;"}
1
+ {"version":3,"file":"EnvironmentContext.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/EnvironmentContext.tsx"],"sourcesContent":["import { ComponentType, createContext, ReactNode, useCallback, useMemo } from 'react'\nimport { Environment } from '@contember/binding'\nimport { useEnvironment } from './useEnvironment'\nimport { Component } from '../coreComponents'\n\nexport const EnvironmentContext = createContext<Environment>(Environment.create())\nEnvironmentContext.displayName = 'EnvironmentContext'\n\nexport interface EnvironmentMiddlewareProps<T extends unknown[]> {\n\tchildren: ReactNode\n\tcreate: (env: Environment, args: T) => Environment\n\targs?: T\n}\n\nexport const EnvironmentMiddleware = Component<EnvironmentMiddlewareProps<unknown[]>>(\n\t({ children, create, args }) => {\n\t\tconst env = useEnvironment()\n\t\tconst envWithExtension = useMemo(\n\t\t\t() => create(env, args ?? []),\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[env, create, ...(args ?? [])],\n\t\t)\n\n\t\treturn <EnvironmentContext.Provider value={envWithExtension}>{children}</EnvironmentContext.Provider>\n\t},\n\t{\n\t\tstaticRender: ({ children }) => {\n\t\t\treturn <>{children}</>\n\t\t},\n\t\tgenerateEnvironment: ({ create, args }, env) => {\n\t\t\treturn create(env, args ?? [])\n\t\t},\n\t},\n) as <T extends unknown[]>(props: EnvironmentMiddlewareProps<T>) => ReactNode\n\nexport interface EnvironmentWithExtensionProps<S, R> {\n\tchildren: ReactNode\n\textension: Environment.Extension<S, R>\n\tstate: S\n}\n\nexport const EnvironmentExtensionProvider: <S, R>(props: EnvironmentWithExtensionProps<S, R>) => ReactNode = Component(\n\t({ children, extension, state }) => {\n\t\tconst create = useCallback((env: Environment) => env.withExtension(extension, state), [extension, state])\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n\t({ children, extension, state }) => {\n\t\tconst create = (env: Environment) => env.withExtension(extension, state)\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n)\n"],"names":["createContext","Environment","Component","useEnvironment","useMemo","useCallback","jsx"],"mappings":";;;;;;;AAKO,MAAM,qBAAqBA,MAAA,cAA2BC,oBAAY,QAAQ;AACjF,mBAAmB,cAAc;AAQ1B,MAAM,wBAAwBC,UAAA;AAAA,EACpC,CAAC,EAAE,UAAU,QAAQ,WAAW;AAC/B,UAAM,MAAMC,eAAAA;AACZ,UAAM,mBAAmBC,MAAA;AAAA,MACxB,MAAM,OAAO,KAAK,QAAQ,EAAE;AAAA;AAAA,MAE5B,CAAC,KAAK,QAAQ,GAAI,QAAQ,CAAA,CAAG;AAAA,IAAA;AAG9B,0CAAQ,mBAAmB,UAAnB,EAA4B,OAAO,kBAAmB,SAAS,CAAA;AAAA,EACxE;AAAA,EACA;AAAA,IACC,cAAc,CAAC,EAAE,eAAe;AAC/B,mEAAU,SAAS,CAAA;AAAA,IACpB;AAAA,IACA,qBAAqB,CAAC,EAAE,QAAQ,KAAA,GAAQ,QAAQ;AAC/C,aAAO,OAAO,KAAK,QAAQ,CAAE,CAAA;AAAA,IAC9B;AAAA,EACD;AACD;AAQO,MAAM,+BAAgGF,UAAA;AAAA,EAC5G,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,UAAM,SAASG,MAAAA,YAAY,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,CAAC;AACjG,WAAAC,2BAAA,IAAC,uBAAsB,EAAA,QAAiB,SAAS,CAAA;AAAA,EACzD;AAAA,EACA,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,UAAM,SAAS,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK;AAChE,WAAAA,2BAAA,IAAC,uBAAsB,EAAA,QAAiB,SAAS,CAAA;AAAA,EACzD;AACD;;;;"}
@@ -6,17 +6,21 @@ import { Component } from "../coreComponents/Component.js";
6
6
  const EnvironmentContext = createContext(Environment.create());
7
7
  EnvironmentContext.displayName = "EnvironmentContext";
8
8
  const EnvironmentMiddleware = Component(
9
- ({ children, create }) => {
9
+ ({ children, create, args }) => {
10
10
  const env = useEnvironment();
11
- const envWithExtension = useMemo(() => create(env), [env, create]);
11
+ const envWithExtension = useMemo(
12
+ () => create(env, args ?? []),
13
+ // eslint-disable-next-line react-hooks/exhaustive-deps
14
+ [env, create, ...args ?? []]
15
+ );
12
16
  return /* @__PURE__ */ jsx(EnvironmentContext.Provider, { value: envWithExtension, children });
13
17
  },
14
18
  {
15
19
  staticRender: ({ children }) => {
16
20
  return /* @__PURE__ */ jsx(Fragment, { children });
17
21
  },
18
- generateEnvironment: ({ create }, env) => {
19
- return create(env);
22
+ generateEnvironment: ({ create, args }, env) => {
23
+ return create(env, args ?? []);
20
24
  }
21
25
  }
22
26
  );
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentContext.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/EnvironmentContext.tsx"],"sourcesContent":["import { createContext, ReactNode, useCallback, useMemo } from 'react'\nimport { Environment } from '@contember/binding'\nimport { useEnvironment } from './useEnvironment'\nimport { Component } from '../coreComponents'\n\nexport const EnvironmentContext = createContext<Environment>(Environment.create())\nEnvironmentContext.displayName = 'EnvironmentContext'\n\nexport interface EnvironmentMiddlewareProps {\n\tchildren: ReactNode\n\tcreate: (env: Environment) => Environment\n}\n\nexport const EnvironmentMiddleware = Component(\n\t({ children, create }: EnvironmentMiddlewareProps) => {\n\t\tconst env = useEnvironment()\n\t\tconst envWithExtension = useMemo(() => create(env), [env, create])\n\n\t\treturn <EnvironmentContext.Provider value={envWithExtension}>{children}</EnvironmentContext.Provider>\n\t},\n\t{\n\t\tstaticRender: ({ children }) => {\n\t\t\treturn <>{children}</>\n\t\t},\n\t\tgenerateEnvironment: ({ create }, env) => {\n\t\t\treturn create(env)\n\t\t},\n\t},\n)\n\nexport interface EnvironmentWithExtensionProps<S, R> {\n\tchildren: ReactNode\n\textension: Environment.Extension<S, R>\n\tstate: S\n}\n\nexport const EnvironmentExtensionProvider: <S, R>(props: EnvironmentWithExtensionProps<S, R>) => ReactNode = Component(\n\t({ children, extension, state }) => {\n\t\tconst create = useCallback((env: Environment) => env.withExtension(extension, state), [extension, state])\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n\t({ children, extension, state }) => {\n\t\tconst create = (env: Environment) => env.withExtension(extension, state)\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n)\n"],"names":[],"mappings":";;;;;AAKO,MAAM,qBAAqB,cAA2B,YAAY,QAAQ;AACjF,mBAAmB,cAAc;AAO1B,MAAM,wBAAwB;AAAA,EACpC,CAAC,EAAE,UAAU,aAAyC;AACrD,UAAM,MAAM;AACN,UAAA,mBAAmB,QAAQ,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,MAAM,CAAC;AAEjE,+BAAQ,mBAAmB,UAAnB,EAA4B,OAAO,kBAAmB,SAAS,CAAA;AAAA,EACxE;AAAA,EACA;AAAA,IACC,cAAc,CAAC,EAAE,eAAe;AAC/B,6CAAU,SAAS,CAAA;AAAA,IACpB;AAAA,IACA,qBAAqB,CAAC,EAAE,UAAU,QAAQ;AACzC,aAAO,OAAO,GAAG;AAAA,IAClB;AAAA,EACD;AACD;AAQO,MAAM,+BAAgG;AAAA,EAC5G,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,UAAM,SAAS,YAAY,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,CAAC;AACjG,WAAA,oBAAC,uBAAsB,EAAA,QAAiB,SAAS,CAAA;AAAA,EACzD;AAAA,EACA,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,UAAM,SAAS,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK;AAChE,WAAA,oBAAC,uBAAsB,EAAA,QAAiB,SAAS,CAAA;AAAA,EACzD;AACD;"}
1
+ {"version":3,"file":"EnvironmentContext.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/EnvironmentContext.tsx"],"sourcesContent":["import { ComponentType, createContext, ReactNode, useCallback, useMemo } from 'react'\nimport { Environment } from '@contember/binding'\nimport { useEnvironment } from './useEnvironment'\nimport { Component } from '../coreComponents'\n\nexport const EnvironmentContext = createContext<Environment>(Environment.create())\nEnvironmentContext.displayName = 'EnvironmentContext'\n\nexport interface EnvironmentMiddlewareProps<T extends unknown[]> {\n\tchildren: ReactNode\n\tcreate: (env: Environment, args: T) => Environment\n\targs?: T\n}\n\nexport const EnvironmentMiddleware = Component<EnvironmentMiddlewareProps<unknown[]>>(\n\t({ children, create, args }) => {\n\t\tconst env = useEnvironment()\n\t\tconst envWithExtension = useMemo(\n\t\t\t() => create(env, args ?? []),\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t\t[env, create, ...(args ?? [])],\n\t\t)\n\n\t\treturn <EnvironmentContext.Provider value={envWithExtension}>{children}</EnvironmentContext.Provider>\n\t},\n\t{\n\t\tstaticRender: ({ children }) => {\n\t\t\treturn <>{children}</>\n\t\t},\n\t\tgenerateEnvironment: ({ create, args }, env) => {\n\t\t\treturn create(env, args ?? [])\n\t\t},\n\t},\n) as <T extends unknown[]>(props: EnvironmentMiddlewareProps<T>) => ReactNode\n\nexport interface EnvironmentWithExtensionProps<S, R> {\n\tchildren: ReactNode\n\textension: Environment.Extension<S, R>\n\tstate: S\n}\n\nexport const EnvironmentExtensionProvider: <S, R>(props: EnvironmentWithExtensionProps<S, R>) => ReactNode = Component(\n\t({ children, extension, state }) => {\n\t\tconst create = useCallback((env: Environment) => env.withExtension(extension, state), [extension, state])\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n\t({ children, extension, state }) => {\n\t\tconst create = (env: Environment) => env.withExtension(extension, state)\n\t\treturn <EnvironmentMiddleware create={create}>{children}</EnvironmentMiddleware>\n\t},\n)\n"],"names":[],"mappings":";;;;;AAKO,MAAM,qBAAqB,cAA2B,YAAY,QAAQ;AACjF,mBAAmB,cAAc;AAQ1B,MAAM,wBAAwB;AAAA,EACpC,CAAC,EAAE,UAAU,QAAQ,WAAW;AAC/B,UAAM,MAAM;AACZ,UAAM,mBAAmB;AAAA,MACxB,MAAM,OAAO,KAAK,QAAQ,EAAE;AAAA;AAAA,MAE5B,CAAC,KAAK,QAAQ,GAAI,QAAQ,CAAA,CAAG;AAAA,IAAA;AAG9B,+BAAQ,mBAAmB,UAAnB,EAA4B,OAAO,kBAAmB,SAAS,CAAA;AAAA,EACxE;AAAA,EACA;AAAA,IACC,cAAc,CAAC,EAAE,eAAe;AAC/B,6CAAU,SAAS,CAAA;AAAA,IACpB;AAAA,IACA,qBAAqB,CAAC,EAAE,QAAQ,KAAA,GAAQ,QAAQ;AAC/C,aAAO,OAAO,KAAK,QAAQ,CAAE,CAAA;AAAA,IAC9B;AAAA,EACD;AACD;AAQO,MAAM,+BAAgG;AAAA,EAC5G,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,UAAM,SAAS,YAAY,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,CAAC;AACjG,WAAA,oBAAC,uBAAsB,EAAA,QAAiB,SAAS,CAAA;AAAA,EACzD;AAAA,EACA,CAAC,EAAE,UAAU,WAAW,YAAY;AACnC,UAAM,SAAS,CAAC,QAAqB,IAAI,cAAc,WAAW,KAAK;AAChE,WAAA,oBAAC,uBAAsB,EAAA,QAAiB,SAAS,CAAA;AAAA,EACzD;AACD;"}
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const useExtendTree = require("./useExtendTree.cjs");
5
+ const reactUtils = require("@contember/react-utils");
5
6
  const EntityListSubTree = require("../coreComponents/EntityListSubTree.cjs");
7
+ const emptyObject = {};
6
8
  const useEntityListSubTreeLoader = (entities, children, state) => {
7
9
  const [displayedState, setDisplayedState] = React.useState({
8
10
  state: "initial",
@@ -14,17 +16,19 @@ const useEntityListSubTreeLoader = (entities, children, state) => {
14
16
  const currentlyLoading = React.useRef();
15
17
  const extendTree = useExtendTree.useExtendTree();
16
18
  const [reloadTrigger, setReloadTrigger] = React.useState(null);
19
+ const memoizedEntities = reactUtils.useObjectMemo(entities ?? emptyObject);
20
+ const resolvedEntities = entities ? memoizedEntities : void 0;
17
21
  React.useEffect(() => {
18
22
  (async () => {
19
- if (!entities) {
23
+ if (!resolvedEntities) {
20
24
  return;
21
25
  }
22
26
  currentlyLoading.current = {
23
- entities,
27
+ entities: resolvedEntities,
24
28
  state
25
29
  };
26
30
  setDisplayedState((it) => {
27
- if (it.state === "initial" || it.state === "loading") {
31
+ if (it.state === "initial" || it.state === "loading" || it.state === "failed") {
28
32
  return {
29
33
  ...it,
30
34
  isLoading: true,
@@ -40,26 +44,37 @@ const useEntityListSubTreeLoader = (entities, children, state) => {
40
44
  });
41
45
  const newTreeRootId = await extendTree(
42
46
  React.createElement(EntityListSubTree.EntityListSubTree, {
43
- ...entities,
47
+ ...resolvedEntities,
44
48
  children
45
49
  }),
46
- { force: reloadTrigger !== null }
50
+ {
51
+ force: reloadTrigger !== null,
52
+ onError: (e) => {
53
+ console.error(e);
54
+ currentlyLoading.current = void 0;
55
+ setDisplayedState({
56
+ state: "failed",
57
+ error: e,
58
+ entities: void 0,
59
+ treeRootId: void 0,
60
+ customState: void 0,
61
+ isLoading: false
62
+ });
63
+ }
64
+ }
47
65
  );
48
- if (currentlyLoading.current?.entities !== entities || currentlyLoading.current?.state !== state) {
49
- return;
50
- }
51
- currentlyLoading.current = void 0;
52
66
  if (newTreeRootId) {
67
+ currentlyLoading.current = void 0;
53
68
  setDisplayedState({
54
- entities,
55
- treeRootId: newTreeRootId,
56
69
  state: "loaded",
70
+ entities: resolvedEntities,
71
+ treeRootId: newTreeRootId,
57
72
  customState: state,
58
73
  isLoading: false
59
74
  });
60
75
  }
61
76
  })();
62
- }, [extendTree, entities, children, state, reloadTrigger]);
77
+ }, [extendTree, resolvedEntities, children, state, reloadTrigger]);
63
78
  return [
64
79
  displayedState,
65
80
  {
@@ -1 +1 @@
1
- {"version":3,"file":"useEntityListSubTreeLoader.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/useEntityListSubTreeLoader.ts"],"sourcesContent":["import { createElement, ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport { SugaredQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { useExtendTree } from './useExtendTree'\nimport { EntityListSubTree } from '../coreComponents'\nimport { useEnvironment } from './useEnvironment'\n\nexport type UseEntityListSubTreeLoaderStateInitial = {\n\tstate: 'initial'\n\tentities: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: false\n}\n\nexport type UseEntityListSubTreeLoaderStateLoading = {\n\tstate: 'loading'\n\tentities: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: true\n}\n\nexport type UseEntityListSubTreeLoaderStateRefreshing<State> = {\n\tstate: 'refreshing'\n\tentities: SugaredQualifiedEntityList\n\ttreeRootId: TreeRootId | undefined\n\tcustomState: State\n\tisLoading: true\n}\n\n\nexport type UseEntityListSubTreeLoaderStateLoaded<State> = {\n\tstate: 'loaded'\n\tentities: SugaredQualifiedEntityList\n\ttreeRootId: TreeRootId | undefined\n\tcustomState: State\n\tisLoading: false\n}\n\n\nexport type UseEntityListSubTreeLoaderState<State> =\n\t| UseEntityListSubTreeLoaderStateInitial\n\t| UseEntityListSubTreeLoaderStateLoading\n\t| UseEntityListSubTreeLoaderStateRefreshing<State>\n\t| UseEntityListSubTreeLoaderStateLoaded<State>\n\nexport type UseEntityListSubTreeLoaderStateMethods = {\n\treload: () => void\n}\n\nexport const useEntityListSubTreeLoader = <State>(entities: SugaredQualifiedEntityList | undefined, children: ReactNode, state?: State): [UseEntityListSubTreeLoaderState<State>, UseEntityListSubTreeLoaderStateMethods] => {\n\tconst [displayedState, setDisplayedState] = useState<UseEntityListSubTreeLoaderState<State>>({\n\t\tstate: 'initial',\n\t\tisLoading: false,\n\t\tentities: undefined,\n\t\ttreeRootId: undefined,\n\t\tcustomState: undefined,\n\t})\n\tconst currentlyLoading = useRef<{\n\t\tentities: SugaredQualifiedEntityList\n\t\tstate?: State\n\t}>()\n\n\tconst extendTree = useExtendTree()\n\tconst [reloadTrigger, setReloadTrigger] = useState<object | null>(null)\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (!entities) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tcurrentlyLoading.current = {\n\t\t\t\tentities,\n\t\t\t\tstate,\n\t\t\t}\n\n\t\t\tsetDisplayedState(it => {\n\t\t\t\tif (it.state === 'initial' || it.state === 'loading') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...it,\n\t\t\t\t\t\tisLoading: true,\n\t\t\t\t\t\tstate: 'loading',\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...it,\n\t\t\t\t\t\tisLoading: true,\n\t\t\t\t\t\tstate: 'refreshing',\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tconst newTreeRootId = await extendTree(\n\t\t\t\tcreateElement(EntityListSubTree, {\n\t\t\t\t\t...entities,\n\t\t\t\t\tchildren,\n\t\t\t\t}),\n\t\t\t\t{ force: reloadTrigger !== null },\n\t\t\t)\n\t\t\tif (currentlyLoading.current?.entities !== entities || currentlyLoading.current?.state !== state) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcurrentlyLoading.current = undefined\n\t\t\tif (newTreeRootId) {\n\t\t\t\tsetDisplayedState({\n\t\t\t\t\tentities: entities,\n\t\t\t\t\ttreeRootId: newTreeRootId,\n\t\t\t\t\tstate: 'loaded',\n\t\t\t\t\tcustomState: state as State,\n\t\t\t\t\tisLoading: false,\n\t\t\t\t})\n\t\t\t}\n\t\t})()\n\t}, [extendTree, entities, children, state, reloadTrigger])\n\n\treturn [\n\t\tdisplayedState,\n\t\t{\n\t\t\treload: useCallback(() => setReloadTrigger({}), []),\n\t\t},\n\t]\n}\n"],"names":["useState","useRef","useExtendTree","useEffect","createElement","EntityListSubTree","useCallback"],"mappings":";;;;;AAkDO,MAAM,6BAA6B,CAAQ,UAAkD,UAAqB,UAAoG;AAC5N,QAAM,CAAC,gBAAgB,iBAAiB,IAAIA,eAAiD;AAAA,IAC5F,OAAO;AAAA,IACP,WAAW;AAAA,IACX,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,aAAa;AAAA,EAAA,CACb;AACD,QAAM,mBAAmBC,MAAAA;AAKzB,QAAM,aAAaC,cAAAA;AACnB,QAAM,CAAC,eAAe,gBAAgB,IAAIF,eAAwB,IAAI;AAEtEG,QAAAA,UAAU,MAAM;AACf,KAAC,YAAY;AACZ,UAAI,CAAC,UAAU;AACd;AAAA,MACD;AAEA,uBAAiB,UAAU;AAAA,QAC1B;AAAA,QACA;AAAA,MAAA;AAGD,wBAAkB,CAAM,OAAA;AACvB,YAAI,GAAG,UAAU,aAAa,GAAG,UAAU,WAAW;AAC9C,iBAAA;AAAA,YACN,GAAG;AAAA,YACH,WAAW;AAAA,YACX,OAAO;AAAA,UAAA;AAAA,QACR,OACM;AACC,iBAAA;AAAA,YACN,GAAG;AAAA,YACH,WAAW;AAAA,YACX,OAAO;AAAA,UAAA;AAAA,QAET;AAAA,MAAA,CACA;AAED,YAAM,gBAAgB,MAAM;AAAA,QAC3BC,MAAAA,cAAcC,kBAAAA,mBAAmB;AAAA,UAChC,GAAG;AAAA,UACH;AAAA,QAAA,CACA;AAAA,QACD,EAAE,OAAO,kBAAkB,KAAK;AAAA,MAAA;AAEjC,UAAI,iBAAiB,SAAS,aAAa,YAAY,iBAAiB,SAAS,UAAU,OAAO;AACjG;AAAA,MACD;AACA,uBAAiB,UAAU;AAC3B,UAAI,eAAe;AACA,0BAAA;AAAA,UACjB;AAAA,UACA,YAAY;AAAA,UACZ,OAAO;AAAA,UACP,aAAa;AAAA,UACb,WAAW;AAAA,QAAA,CACX;AAAA,MACF;AAAA,IAAA;EACE,GACD,CAAC,YAAY,UAAU,UAAU,OAAO,aAAa,CAAC;AAElD,SAAA;AAAA,IACN;AAAA,IACA;AAAA,MACC,QAAQC,MAAAA,YAAY,MAAM,iBAAiB,CAAE,CAAA,GAAG,CAAA,CAAE;AAAA,IACnD;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"useEntityListSubTreeLoader.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/useEntityListSubTreeLoader.ts"],"sourcesContent":["import { createElement, ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport { SugaredQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { useExtendTree } from './useExtendTree'\nimport { EntityListSubTree } from '../coreComponents'\nimport { useEnvironment } from './useEnvironment'\nimport { useObjectMemo } from '@contember/react-utils'\n\nexport type UseEntityListSubTreeLoaderStateInitial = {\n\tstate: 'initial'\n\tentities: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: false\n}\n\nexport type UseEntityListSubTreeLoaderStateLoading = {\n\tstate: 'loading'\n\tentities: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: true\n}\n\nexport type UseEntityListSubTreeLoaderStateRefreshing<State> = {\n\tstate: 'refreshing'\n\tentities: SugaredQualifiedEntityList\n\ttreeRootId: TreeRootId | undefined\n\tcustomState: State\n\tisLoading: true\n}\n\n\nexport type UseEntityListSubTreeLoaderStateLoaded<State> = {\n\tstate: 'loaded'\n\tentities: SugaredQualifiedEntityList\n\ttreeRootId: TreeRootId | undefined\n\tcustomState: State\n\tisLoading: false\n}\n\nexport type UseEntityListSubTreeLoaderStateFailed = {\n\tstate: 'failed'\n\terror: unknown\n\tentities: undefined\n\ttreeRootId: undefined\n\tcustomState: undefined\n\tisLoading: false\n}\n\n\nexport type UseEntityListSubTreeLoaderState<State> =\n\t| UseEntityListSubTreeLoaderStateInitial\n\t| UseEntityListSubTreeLoaderStateLoading\n\t| UseEntityListSubTreeLoaderStateRefreshing<State>\n\t| UseEntityListSubTreeLoaderStateLoaded<State>\n\t| UseEntityListSubTreeLoaderStateFailed\n\nexport type UseEntityListSubTreeLoaderStateMethods = {\n\treload: () => void\n}\n\nconst emptyObject = {} as SugaredQualifiedEntityList\n\nexport const useEntityListSubTreeLoader = <State>(entities: SugaredQualifiedEntityList | undefined, children: ReactNode, state?: State): [UseEntityListSubTreeLoaderState<State>, UseEntityListSubTreeLoaderStateMethods] => {\n\tconst [displayedState, setDisplayedState] = useState<UseEntityListSubTreeLoaderState<State>>({\n\t\tstate: 'initial',\n\t\tisLoading: false,\n\t\tentities: undefined,\n\t\ttreeRootId: undefined,\n\t\tcustomState: undefined,\n\t})\n\tconst currentlyLoading = useRef<{\n\t\tentities: SugaredQualifiedEntityList\n\t\tstate?: State\n\t}>()\n\n\tconst extendTree = useExtendTree()\n\tconst [reloadTrigger, setReloadTrigger] = useState<object | null>(null)\n\tconst memoizedEntities = useObjectMemo(entities ?? emptyObject)\n\tconst resolvedEntities = entities ? memoizedEntities : undefined\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (!resolvedEntities) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tcurrentlyLoading.current = {\n\t\t\t\tentities: resolvedEntities,\n\t\t\t\tstate,\n\t\t\t}\n\n\t\t\tsetDisplayedState(it => {\n\t\t\t\tif (it.state === 'initial' || it.state === 'loading' || it.state === 'failed') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...it,\n\t\t\t\t\t\tisLoading: true,\n\t\t\t\t\t\tstate: 'loading',\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...it,\n\t\t\t\t\t\tisLoading: true,\n\t\t\t\t\t\tstate: 'refreshing',\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\n\t\t\tconst newTreeRootId = await extendTree(\n\t\t\t\tcreateElement(EntityListSubTree, {\n\t\t\t\t\t...resolvedEntities,\n\t\t\t\t\tchildren,\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\tforce: reloadTrigger !== null,\n\t\t\t\t\tonError: e => {\n\t\t\t\t\t\tconsole.error(e)\n\n\t\t\t\t\t\tcurrentlyLoading.current = undefined\n\n\t\t\t\t\t\tsetDisplayedState({\n\t\t\t\t\t\t\tstate: 'failed',\n\t\t\t\t\t\t\terror: e,\n\t\t\t\t\t\t\tentities: undefined,\n\t\t\t\t\t\t\ttreeRootId: undefined,\n\t\t\t\t\t\t\tcustomState: undefined,\n\t\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tif (newTreeRootId) {\n\t\t\t\tcurrentlyLoading.current = undefined\n\t\t\t\tsetDisplayedState({\n\t\t\t\t\tstate: 'loaded',\n\t\t\t\t\tentities: resolvedEntities,\n\t\t\t\t\ttreeRootId: newTreeRootId,\n\t\t\t\t\tcustomState: state as State,\n\t\t\t\t\tisLoading: false,\n\t\t\t\t})\n\t\t\t}\n\t\t})()\n\t}, [extendTree, resolvedEntities, children, state, reloadTrigger])\n\n\treturn [\n\t\tdisplayedState,\n\t\t{\n\t\t\treload: useCallback(() => setReloadTrigger({}), []),\n\t\t},\n\t]\n}\n"],"names":["useState","useRef","useExtendTree","useObjectMemo","useEffect","createElement","EntityListSubTree","useCallback"],"mappings":";;;;;;AA6DA,MAAM,cAAc,CAAA;AAEb,MAAM,6BAA6B,CAAQ,UAAkD,UAAqB,UAAoG;AAC5N,QAAM,CAAC,gBAAgB,iBAAiB,IAAIA,eAAiD;AAAA,IAC5F,OAAO;AAAA,IACP,WAAW;AAAA,IACX,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,aAAa;AAAA,EAAA,CACb;AACD,QAAM,mBAAmBC,MAAAA;AAKzB,QAAM,aAAaC,cAAAA;AACnB,QAAM,CAAC,eAAe,gBAAgB,IAAIF,eAAwB,IAAI;AAChE,QAAA,mBAAmBG,WAAAA,cAAc,YAAY,WAAW;AACxD,QAAA,mBAAmB,WAAW,mBAAmB;AAEvDC,QAAAA,UAAU,MAAM;AACf,KAAC,YAAY;AACZ,UAAI,CAAC,kBAAkB;AACtB;AAAA,MACD;AAEA,uBAAiB,UAAU;AAAA,QAC1B,UAAU;AAAA,QACV;AAAA,MAAA;AAGD,wBAAkB,CAAM,OAAA;AACnB,YAAA,GAAG,UAAU,aAAa,GAAG,UAAU,aAAa,GAAG,UAAU,UAAU;AACvE,iBAAA;AAAA,YACN,GAAG;AAAA,YACH,WAAW;AAAA,YACX,OAAO;AAAA,UAAA;AAAA,QACR,OACM;AACC,iBAAA;AAAA,YACN,GAAG;AAAA,YACH,WAAW;AAAA,YACX,OAAO;AAAA,UAAA;AAAA,QAET;AAAA,MAAA,CACA;AAED,YAAM,gBAAgB,MAAM;AAAA,QAC3BC,MAAAA,cAAcC,kBAAAA,mBAAmB;AAAA,UAChC,GAAG;AAAA,UACH;AAAA,QAAA,CACA;AAAA,QACD;AAAA,UACC,OAAO,kBAAkB;AAAA,UACzB,SAAS,CAAK,MAAA;AACb,oBAAQ,MAAM,CAAC;AAEf,6BAAiB,UAAU;AAET,8BAAA;AAAA,cACjB,OAAO;AAAA,cACP,OAAO;AAAA,cACP,UAAU;AAAA,cACV,YAAY;AAAA,cACZ,aAAa;AAAA,cACb,WAAW;AAAA,YAAA,CACX;AAAA,UACF;AAAA,QACD;AAAA,MAAA;AAGD,UAAI,eAAe;AAClB,yBAAiB,UAAU;AACT,0BAAA;AAAA,UACjB,OAAO;AAAA,UACP,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,aAAa;AAAA,UACb,WAAW;AAAA,QAAA,CACX;AAAA,MACF;AAAA,IAAA;EACE,GACD,CAAC,YAAY,kBAAkB,UAAU,OAAO,aAAa,CAAC;AAE1D,SAAA;AAAA,IACN;AAAA,IACA;AAAA,MACC,QAAQC,MAAAA,YAAY,MAAM,iBAAiB,CAAE,CAAA,GAAG,CAAA,CAAE;AAAA,IACnD;AAAA,EAAA;AAEF;;"}