@contember/react-binding 2.2.0-alpha.20 → 2.2.0-alpha.22

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 (55) hide show
  1. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.cjs +4 -2
  2. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.cjs.map +1 -1
  3. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.js +4 -2
  4. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
  5. package/dist/development/src/accessorPropagation/useEntity.cjs +2 -4
  6. package/dist/development/src/accessorPropagation/useEntity.cjs.map +1 -1
  7. package/dist/development/src/accessorPropagation/useEntity.js +2 -4
  8. package/dist/development/src/accessorPropagation/useEntity.js.map +1 -1
  9. package/dist/development/src/accessorPropagation/useEntityList.cjs +2 -4
  10. package/dist/development/src/accessorPropagation/useEntityList.cjs.map +1 -1
  11. package/dist/development/src/accessorPropagation/useEntityList.js +2 -4
  12. package/dist/development/src/accessorPropagation/useEntityList.js.map +1 -1
  13. package/dist/development/src/accessorPropagation/useField.cjs +2 -4
  14. package/dist/development/src/accessorPropagation/useField.cjs.map +1 -1
  15. package/dist/development/src/accessorPropagation/useField.js +2 -4
  16. package/dist/development/src/accessorPropagation/useField.js.map +1 -1
  17. package/dist/development/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.cjs +33 -0
  18. package/dist/development/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.cjs.map +1 -0
  19. package/dist/development/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.js +33 -0
  20. package/dist/development/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.js.map +1 -0
  21. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.cjs +4 -2
  22. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.cjs.map +1 -1
  23. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.js +4 -2
  24. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
  25. package/dist/production/src/accessorPropagation/useEntity.cjs +2 -4
  26. package/dist/production/src/accessorPropagation/useEntity.cjs.map +1 -1
  27. package/dist/production/src/accessorPropagation/useEntity.js +2 -4
  28. package/dist/production/src/accessorPropagation/useEntity.js.map +1 -1
  29. package/dist/production/src/accessorPropagation/useEntityList.cjs +2 -4
  30. package/dist/production/src/accessorPropagation/useEntityList.cjs.map +1 -1
  31. package/dist/production/src/accessorPropagation/useEntityList.js +2 -4
  32. package/dist/production/src/accessorPropagation/useEntityList.js.map +1 -1
  33. package/dist/production/src/accessorPropagation/useField.cjs +2 -4
  34. package/dist/production/src/accessorPropagation/useField.cjs.map +1 -1
  35. package/dist/production/src/accessorPropagation/useField.js +2 -4
  36. package/dist/production/src/accessorPropagation/useField.js.map +1 -1
  37. package/dist/production/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.cjs +33 -0
  38. package/dist/production/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.cjs.map +1 -0
  39. package/dist/production/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.js +33 -0
  40. package/dist/production/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.js.map +1 -0
  41. package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts +1 -0
  42. package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts.map +1 -1
  43. package/dist/types/accessorPropagation/useEntity.d.ts.map +1 -1
  44. package/dist/types/accessorPropagation/useEntityList.d.ts.map +1 -1
  45. package/dist/types/accessorPropagation/useField.d.ts.map +1 -1
  46. package/dist/types/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.d.ts +7 -0
  47. package/dist/types/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.d.ts.map +1 -0
  48. package/dist/types/tsconfig.tsbuildinfo +1 -1
  49. package/package.json +7 -7
  50. package/src/accessorPropagation/useAccessorUpdateSubscription.ts +8 -2
  51. package/src/accessorPropagation/useEntity.ts +2 -4
  52. package/src/accessorPropagation/useEntityList.ts +2 -4
  53. package/src/accessorPropagation/useField.ts +2 -4
  54. package/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.ts +38 -0
  55. package/tests/cases/unit/core/nestedHasOneReconnect.test.tsx +280 -0
@@ -1 +1 @@
1
- {"version":3,"file":"useEntityList.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/useEntityList.ts"],"sourcesContent":["import { useConstantLengthInvariant, useConstantValueInvariant } from '@contember/react-utils'\nimport { useCallback } from 'react'\nimport { useEntityKey, useGetEntityByKey } from './index.js'\nimport type { EntityListAccessor } from '@contember/binding'\nimport { useOnConnectionUpdate } from '../entityEvents/index.js'\nimport type { SugaredRelativeEntityList } from '@contember/binding'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription.js'\nimport { useDesugaredRelativeEntityList } from './useDesugaredRelativeEntityList.js'\n\nfunction useEntityList(sugaredRelativeEntityList: string | SugaredRelativeEntityList): EntityListAccessor\nfunction useEntityList(\n\tsugaredRelativeEntityList: string | SugaredRelativeEntityList | undefined,\n): EntityListAccessor | undefined\nfunction useEntityList(\n\tsugaredRelativeEntityList: string | SugaredRelativeEntityList | undefined,\n): EntityListAccessor | undefined {\n\tconst relativeEntityList = useDesugaredRelativeEntityList(sugaredRelativeEntityList)\n\tuseConstantValueInvariant(\n\t\t!!relativeEntityList,\n\t\t'useEntityList: cannot alternate between providing and omitting the argument.',\n\t)\n\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst getEntityList = useCallback(() => {\n\t\tconst parent = getEntityByKey(entityKey)\n\t\treturn parent.getEntityList(relativeEntityList!)\n\t}, [entityKey, getEntityByKey, relativeEntityList])\n\n\tif (relativeEntityList) {\n\t\tuseConstantLengthInvariant(\n\t\t\trelativeEntityList.hasOneRelationPath,\n\t\t\t'Cannot change the length of the hasOneRelation path!',\n\t\t)\n\t\tconst [entityList, { update }] = useAccessorUpdateSubscription(getEntityList)\n\n\t\tif (relativeEntityList.hasOneRelationPath.length) {\n\t\t\tuseOnConnectionUpdate(relativeEntityList.hasOneRelationPath[0].field, update)\n\t\t}\n\n\t\treturn entityList\n\t}\n\treturn undefined\n}\n\nexport { useEntityList }\n"],"names":["useDesugaredRelativeEntityList","useConstantValueInvariant","useEntityKey","useGetEntityByKey","useCallback","useConstantLengthInvariant","useAccessorUpdateSubscription","useOnConnectionUpdate"],"mappings":";;;;;;;;;AAaA,SAAS,cACR,2BACiC;AACjC,QAAM,qBAAqBA,+BAAAA,+BAA+B,yBAAyB;AACnFC,aAAAA;AAAAA,IACC,CAAC,CAAC;AAAA,IACF;AAAA,EAAA;AAGD,QAAM,YAAYC,aAAAA,aAAA;AAClB,QAAM,iBAAiBC,kBAAAA,kBAAA;AACvB,QAAM,gBAAgBC,MAAAA,YAAY,MAAM;AACvC,UAAM,SAAS,eAAe,SAAS;AACvC,WAAO,OAAO,cAAc,kBAAmB;AAAA,EAChD,GAAG,CAAC,WAAW,gBAAgB,kBAAkB,CAAC;AAElD,MAAI,oBAAoB;AACvBC,eAAAA;AAAAA,MACC,mBAAmB;AAAA,MACnB;AAAA,IAAA;AAED,UAAM,CAAC,YAAY,EAAE,QAAQ,IAAIC,8BAAAA,8BAA8B,aAAa;AAE5E,QAAI,mBAAmB,mBAAmB,QAAQ;AACjDC,4BAAAA,sBAAsB,mBAAmB,mBAAmB,CAAC,EAAE,OAAO,MAAM;AAAA,IAC7E;AAEA,WAAO;AAAA,EACR;AACA,SAAO;AACR;;"}
1
+ {"version":3,"file":"useEntityList.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/useEntityList.ts"],"sourcesContent":["import { useConstantLengthInvariant, useConstantValueInvariant } from '@contember/react-utils'\nimport { useCallback } from 'react'\nimport { useEntityKey, useGetEntityByKey } from './index.js'\nimport type { EntityListAccessor } from '@contember/binding'\nimport type { SugaredRelativeEntityList } from '@contember/binding'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription.js'\nimport { useOnHasOneRelationPathConnectionUpdate } from './useOnHasOneRelationPathConnectionUpdate.js'\nimport { useDesugaredRelativeEntityList } from './useDesugaredRelativeEntityList.js'\n\nfunction useEntityList(sugaredRelativeEntityList: string | SugaredRelativeEntityList): EntityListAccessor\nfunction useEntityList(\n\tsugaredRelativeEntityList: string | SugaredRelativeEntityList | undefined,\n): EntityListAccessor | undefined\nfunction useEntityList(\n\tsugaredRelativeEntityList: string | SugaredRelativeEntityList | undefined,\n): EntityListAccessor | undefined {\n\tconst relativeEntityList = useDesugaredRelativeEntityList(sugaredRelativeEntityList)\n\tuseConstantValueInvariant(\n\t\t!!relativeEntityList,\n\t\t'useEntityList: cannot alternate between providing and omitting the argument.',\n\t)\n\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst getEntityList = useCallback(() => {\n\t\tconst parent = getEntityByKey(entityKey)\n\t\treturn parent.getEntityList(relativeEntityList!)\n\t}, [entityKey, getEntityByKey, relativeEntityList])\n\n\tif (relativeEntityList) {\n\t\tuseConstantLengthInvariant(\n\t\t\trelativeEntityList.hasOneRelationPath,\n\t\t\t'Cannot change the length of the hasOneRelation path!',\n\t\t)\n\t\tconst [entityList, { update }] = useAccessorUpdateSubscription(getEntityList)\n\n\t\tuseOnHasOneRelationPathConnectionUpdate(relativeEntityList.hasOneRelationPath, update)\n\n\t\treturn entityList\n\t}\n\treturn undefined\n}\n\nexport { useEntityList }\n"],"names":["useDesugaredRelativeEntityList","useConstantValueInvariant","useEntityKey","useGetEntityByKey","useCallback","useConstantLengthInvariant","useAccessorUpdateSubscription","useOnHasOneRelationPathConnectionUpdate"],"mappings":";;;;;;;;;AAaA,SAAS,cACR,2BACiC;AACjC,QAAM,qBAAqBA,+BAAAA,+BAA+B,yBAAyB;AACnFC,aAAAA;AAAAA,IACC,CAAC,CAAC;AAAA,IACF;AAAA,EAAA;AAGD,QAAM,YAAYC,aAAAA,aAAA;AAClB,QAAM,iBAAiBC,kBAAAA,kBAAA;AACvB,QAAM,gBAAgBC,MAAAA,YAAY,MAAM;AACvC,UAAM,SAAS,eAAe,SAAS;AACvC,WAAO,OAAO,cAAc,kBAAmB;AAAA,EAChD,GAAG,CAAC,WAAW,gBAAgB,kBAAkB,CAAC;AAElD,MAAI,oBAAoB;AACvBC,eAAAA;AAAAA,MACC,mBAAmB;AAAA,MACnB;AAAA,IAAA;AAED,UAAM,CAAC,YAAY,EAAE,QAAQ,IAAIC,8BAAAA,8BAA8B,aAAa;AAE5EC,oFAAwC,mBAAmB,oBAAoB,MAAM;AAErF,WAAO;AAAA,EACR;AACA,SAAO;AACR;;"}
@@ -1,10 +1,10 @@
1
1
  import { useConstantValueInvariant, useConstantLengthInvariant } from "@contember/react-utils";
2
2
  import { useCallback } from "react";
3
3
  import { useAccessorUpdateSubscription } from "./useAccessorUpdateSubscription.js";
4
+ import { useOnHasOneRelationPathConnectionUpdate } from "./useOnHasOneRelationPathConnectionUpdate.js";
4
5
  import { useDesugaredRelativeEntityList } from "./useDesugaredRelativeEntityList.js";
5
6
  import { useEntityKey } from "./useEntityKey.js";
6
7
  import { useGetEntityByKey } from "./useGetEntityByKey.js";
7
- import { useOnConnectionUpdate } from "../entityEvents/useOnConnectionUpdate.js";
8
8
  function useEntityList(sugaredRelativeEntityList) {
9
9
  const relativeEntityList = useDesugaredRelativeEntityList(sugaredRelativeEntityList);
10
10
  useConstantValueInvariant(
@@ -23,9 +23,7 @@ function useEntityList(sugaredRelativeEntityList) {
23
23
  "Cannot change the length of the hasOneRelation path!"
24
24
  );
25
25
  const [entityList, { update }] = useAccessorUpdateSubscription(getEntityList);
26
- if (relativeEntityList.hasOneRelationPath.length) {
27
- useOnConnectionUpdate(relativeEntityList.hasOneRelationPath[0].field, update);
28
- }
26
+ useOnHasOneRelationPathConnectionUpdate(relativeEntityList.hasOneRelationPath, update);
29
27
  return entityList;
30
28
  }
31
29
  return void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"useEntityList.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/useEntityList.ts"],"sourcesContent":["import { useConstantLengthInvariant, useConstantValueInvariant } from '@contember/react-utils'\nimport { useCallback } from 'react'\nimport { useEntityKey, useGetEntityByKey } from './index.js'\nimport type { EntityListAccessor } from '@contember/binding'\nimport { useOnConnectionUpdate } from '../entityEvents/index.js'\nimport type { SugaredRelativeEntityList } from '@contember/binding'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription.js'\nimport { useDesugaredRelativeEntityList } from './useDesugaredRelativeEntityList.js'\n\nfunction useEntityList(sugaredRelativeEntityList: string | SugaredRelativeEntityList): EntityListAccessor\nfunction useEntityList(\n\tsugaredRelativeEntityList: string | SugaredRelativeEntityList | undefined,\n): EntityListAccessor | undefined\nfunction useEntityList(\n\tsugaredRelativeEntityList: string | SugaredRelativeEntityList | undefined,\n): EntityListAccessor | undefined {\n\tconst relativeEntityList = useDesugaredRelativeEntityList(sugaredRelativeEntityList)\n\tuseConstantValueInvariant(\n\t\t!!relativeEntityList,\n\t\t'useEntityList: cannot alternate between providing and omitting the argument.',\n\t)\n\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst getEntityList = useCallback(() => {\n\t\tconst parent = getEntityByKey(entityKey)\n\t\treturn parent.getEntityList(relativeEntityList!)\n\t}, [entityKey, getEntityByKey, relativeEntityList])\n\n\tif (relativeEntityList) {\n\t\tuseConstantLengthInvariant(\n\t\t\trelativeEntityList.hasOneRelationPath,\n\t\t\t'Cannot change the length of the hasOneRelation path!',\n\t\t)\n\t\tconst [entityList, { update }] = useAccessorUpdateSubscription(getEntityList)\n\n\t\tif (relativeEntityList.hasOneRelationPath.length) {\n\t\t\tuseOnConnectionUpdate(relativeEntityList.hasOneRelationPath[0].field, update)\n\t\t}\n\n\t\treturn entityList\n\t}\n\treturn undefined\n}\n\nexport { useEntityList }\n"],"names":[],"mappings":";;;;;;;AAaA,SAAS,cACR,2BACiC;AACjC,QAAM,qBAAqB,+BAA+B,yBAAyB;AACnF;AAAA,IACC,CAAC,CAAC;AAAA,IACF;AAAA,EAAA;AAGD,QAAM,YAAY,aAAA;AAClB,QAAM,iBAAiB,kBAAA;AACvB,QAAM,gBAAgB,YAAY,MAAM;AACvC,UAAM,SAAS,eAAe,SAAS;AACvC,WAAO,OAAO,cAAc,kBAAmB;AAAA,EAChD,GAAG,CAAC,WAAW,gBAAgB,kBAAkB,CAAC;AAElD,MAAI,oBAAoB;AACvB;AAAA,MACC,mBAAmB;AAAA,MACnB;AAAA,IAAA;AAED,UAAM,CAAC,YAAY,EAAE,QAAQ,IAAI,8BAA8B,aAAa;AAE5E,QAAI,mBAAmB,mBAAmB,QAAQ;AACjD,4BAAsB,mBAAmB,mBAAmB,CAAC,EAAE,OAAO,MAAM;AAAA,IAC7E;AAEA,WAAO;AAAA,EACR;AACA,SAAO;AACR;"}
1
+ {"version":3,"file":"useEntityList.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/useEntityList.ts"],"sourcesContent":["import { useConstantLengthInvariant, useConstantValueInvariant } from '@contember/react-utils'\nimport { useCallback } from 'react'\nimport { useEntityKey, useGetEntityByKey } from './index.js'\nimport type { EntityListAccessor } from '@contember/binding'\nimport type { SugaredRelativeEntityList } from '@contember/binding'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription.js'\nimport { useOnHasOneRelationPathConnectionUpdate } from './useOnHasOneRelationPathConnectionUpdate.js'\nimport { useDesugaredRelativeEntityList } from './useDesugaredRelativeEntityList.js'\n\nfunction useEntityList(sugaredRelativeEntityList: string | SugaredRelativeEntityList): EntityListAccessor\nfunction useEntityList(\n\tsugaredRelativeEntityList: string | SugaredRelativeEntityList | undefined,\n): EntityListAccessor | undefined\nfunction useEntityList(\n\tsugaredRelativeEntityList: string | SugaredRelativeEntityList | undefined,\n): EntityListAccessor | undefined {\n\tconst relativeEntityList = useDesugaredRelativeEntityList(sugaredRelativeEntityList)\n\tuseConstantValueInvariant(\n\t\t!!relativeEntityList,\n\t\t'useEntityList: cannot alternate between providing and omitting the argument.',\n\t)\n\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst getEntityList = useCallback(() => {\n\t\tconst parent = getEntityByKey(entityKey)\n\t\treturn parent.getEntityList(relativeEntityList!)\n\t}, [entityKey, getEntityByKey, relativeEntityList])\n\n\tif (relativeEntityList) {\n\t\tuseConstantLengthInvariant(\n\t\t\trelativeEntityList.hasOneRelationPath,\n\t\t\t'Cannot change the length of the hasOneRelation path!',\n\t\t)\n\t\tconst [entityList, { update }] = useAccessorUpdateSubscription(getEntityList)\n\n\t\tuseOnHasOneRelationPathConnectionUpdate(relativeEntityList.hasOneRelationPath, update)\n\n\t\treturn entityList\n\t}\n\treturn undefined\n}\n\nexport { useEntityList }\n"],"names":[],"mappings":";;;;;;;AAaA,SAAS,cACR,2BACiC;AACjC,QAAM,qBAAqB,+BAA+B,yBAAyB;AACnF;AAAA,IACC,CAAC,CAAC;AAAA,IACF;AAAA,EAAA;AAGD,QAAM,YAAY,aAAA;AAClB,QAAM,iBAAiB,kBAAA;AACvB,QAAM,gBAAgB,YAAY,MAAM;AACvC,UAAM,SAAS,eAAe,SAAS;AACvC,WAAO,OAAO,cAAc,kBAAmB;AAAA,EAChD,GAAG,CAAC,WAAW,gBAAgB,kBAAkB,CAAC;AAElD,MAAI,oBAAoB;AACvB;AAAA,MACC,mBAAmB;AAAA,MACnB;AAAA,IAAA;AAED,UAAM,CAAC,YAAY,EAAE,QAAQ,IAAI,8BAA8B,aAAa;AAE5E,4CAAwC,mBAAmB,oBAAoB,MAAM;AAErF,WAAO;AAAA,EACR;AACA,SAAO;AACR;"}
@@ -3,10 +3,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const reactUtils = require("@contember/react-utils");
4
4
  const React = require("react");
5
5
  const useAccessorUpdateSubscription = require("./useAccessorUpdateSubscription.cjs");
6
+ const useOnHasOneRelationPathConnectionUpdate = require("./useOnHasOneRelationPathConnectionUpdate.cjs");
6
7
  const useDesugaredRelativeSingleField = require("./useDesugaredRelativeSingleField.cjs");
7
8
  const useEntityKey = require("./useEntityKey.cjs");
8
9
  const useGetEntityByKey = require("./useGetEntityByKey.cjs");
9
- const useOnConnectionUpdate = require("../entityEvents/useOnConnectionUpdate.cjs");
10
10
  function useField(sugaredRelativeSingleField) {
11
11
  const relativeSingleField = useDesugaredRelativeSingleField.useDesugaredRelativeSingleField(sugaredRelativeSingleField);
12
12
  reactUtils.useConstantValueInvariant(
@@ -25,9 +25,7 @@ function useField(sugaredRelativeSingleField) {
25
25
  "Cannot change the length of the hasOneRelation path!"
26
26
  );
27
27
  const [field, { update }] = useAccessorUpdateSubscription.useAccessorUpdateSubscription(getField);
28
- if (relativeSingleField.hasOneRelationPath.length) {
29
- useOnConnectionUpdate.useOnConnectionUpdate(relativeSingleField.hasOneRelationPath[0].field, update);
30
- }
28
+ useOnHasOneRelationPathConnectionUpdate.useOnHasOneRelationPathConnectionUpdate(relativeSingleField.hasOneRelationPath, update);
31
29
  return field;
32
30
  }
33
31
  return void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"useField.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/useField.ts"],"sourcesContent":["import { useConstantLengthInvariant, useConstantValueInvariant } from '@contember/react-utils'\nimport { useCallback } from 'react'\nimport { useEntityKey, useGetEntityByKey } from './index.js'\nimport type { FieldAccessor } from '@contember/binding'\nimport { useOnConnectionUpdate } from '../entityEvents/index.js'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription.js'\nimport { useDesugaredRelativeSingleField } from './useDesugaredRelativeSingleField.js'\n\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField,\n): FieldAccessor<Value>\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField | undefined,\n): FieldAccessor<Value> | undefined\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField | undefined,\n): FieldAccessor<Value> | undefined {\n\tconst relativeSingleField = useDesugaredRelativeSingleField(sugaredRelativeSingleField)\n\tuseConstantValueInvariant(\n\t\t!!relativeSingleField,\n\t\t'useField: cannot alternate between providing and omitting the argument.',\n\t)\n\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst getField = useCallback(() => {\n\t\tconst parent = getEntityByKey(entityKey)\n\t\treturn parent.getField<Value>(relativeSingleField!)\n\t}, [entityKey, getEntityByKey, relativeSingleField])\n\n\tif (relativeSingleField) {\n\t\tuseConstantLengthInvariant(\n\t\t\trelativeSingleField.hasOneRelationPath,\n\t\t\t'Cannot change the length of the hasOneRelation path!',\n\t\t)\n\t\tconst [field, { update }] = useAccessorUpdateSubscription(getField)\n\n\t\tif (relativeSingleField.hasOneRelationPath.length) {\n\t\t\tuseOnConnectionUpdate(relativeSingleField.hasOneRelationPath[0].field, update)\n\t\t}\n\n\t\treturn field\n\t}\n\treturn undefined\n}\n\nexport { useField }\n"],"names":["useDesugaredRelativeSingleField","useConstantValueInvariant","useEntityKey","useGetEntityByKey","useCallback","useConstantLengthInvariant","useAccessorUpdateSubscription","useOnConnectionUpdate"],"mappings":";;;;;;;;;AAeA,SAAS,SACR,4BACmC;AACnC,QAAM,sBAAsBA,gCAAAA,gCAAgC,0BAA0B;AACtFC,aAAAA;AAAAA,IACC,CAAC,CAAC;AAAA,IACF;AAAA,EAAA;AAGD,QAAM,YAAYC,aAAAA,aAAA;AAClB,QAAM,iBAAiBC,kBAAAA,kBAAA;AACvB,QAAM,WAAWC,MAAAA,YAAY,MAAM;AAClC,UAAM,SAAS,eAAe,SAAS;AACvC,WAAO,OAAO,SAAgB,mBAAoB;AAAA,EACnD,GAAG,CAAC,WAAW,gBAAgB,mBAAmB,CAAC;AAEnD,MAAI,qBAAqB;AACxBC,eAAAA;AAAAA,MACC,oBAAoB;AAAA,MACpB;AAAA,IAAA;AAED,UAAM,CAAC,OAAO,EAAE,QAAQ,IAAIC,8BAAAA,8BAA8B,QAAQ;AAElE,QAAI,oBAAoB,mBAAmB,QAAQ;AAClDC,4BAAAA,sBAAsB,oBAAoB,mBAAmB,CAAC,EAAE,OAAO,MAAM;AAAA,IAC9E;AAEA,WAAO;AAAA,EACR;AACA,SAAO;AACR;;"}
1
+ {"version":3,"file":"useField.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/useField.ts"],"sourcesContent":["import { useConstantLengthInvariant, useConstantValueInvariant } from '@contember/react-utils'\nimport { useCallback } from 'react'\nimport { useEntityKey, useGetEntityByKey } from './index.js'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription.js'\nimport { useOnHasOneRelationPathConnectionUpdate } from './useOnHasOneRelationPathConnectionUpdate.js'\nimport { useDesugaredRelativeSingleField } from './useDesugaredRelativeSingleField.js'\n\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField,\n): FieldAccessor<Value>\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField | undefined,\n): FieldAccessor<Value> | undefined\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField | undefined,\n): FieldAccessor<Value> | undefined {\n\tconst relativeSingleField = useDesugaredRelativeSingleField(sugaredRelativeSingleField)\n\tuseConstantValueInvariant(\n\t\t!!relativeSingleField,\n\t\t'useField: cannot alternate between providing and omitting the argument.',\n\t)\n\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst getField = useCallback(() => {\n\t\tconst parent = getEntityByKey(entityKey)\n\t\treturn parent.getField<Value>(relativeSingleField!)\n\t}, [entityKey, getEntityByKey, relativeSingleField])\n\n\tif (relativeSingleField) {\n\t\tuseConstantLengthInvariant(\n\t\t\trelativeSingleField.hasOneRelationPath,\n\t\t\t'Cannot change the length of the hasOneRelation path!',\n\t\t)\n\t\tconst [field, { update }] = useAccessorUpdateSubscription(getField)\n\n\t\tuseOnHasOneRelationPathConnectionUpdate(relativeSingleField.hasOneRelationPath, update)\n\n\t\treturn field\n\t}\n\treturn undefined\n}\n\nexport { useField }\n"],"names":["useDesugaredRelativeSingleField","useConstantValueInvariant","useEntityKey","useGetEntityByKey","useCallback","useConstantLengthInvariant","useAccessorUpdateSubscription","useOnHasOneRelationPathConnectionUpdate"],"mappings":";;;;;;;;;AAeA,SAAS,SACR,4BACmC;AACnC,QAAM,sBAAsBA,gCAAAA,gCAAgC,0BAA0B;AACtFC,aAAAA;AAAAA,IACC,CAAC,CAAC;AAAA,IACF;AAAA,EAAA;AAGD,QAAM,YAAYC,aAAAA,aAAA;AAClB,QAAM,iBAAiBC,kBAAAA,kBAAA;AACvB,QAAM,WAAWC,MAAAA,YAAY,MAAM;AAClC,UAAM,SAAS,eAAe,SAAS;AACvC,WAAO,OAAO,SAAgB,mBAAoB;AAAA,EACnD,GAAG,CAAC,WAAW,gBAAgB,mBAAmB,CAAC;AAEnD,MAAI,qBAAqB;AACxBC,eAAAA;AAAAA,MACC,oBAAoB;AAAA,MACpB;AAAA,IAAA;AAED,UAAM,CAAC,OAAO,EAAE,QAAQ,IAAIC,8BAAAA,8BAA8B,QAAQ;AAElEC,oFAAwC,oBAAoB,oBAAoB,MAAM;AAEtF,WAAO;AAAA,EACR;AACA,SAAO;AACR;;"}
@@ -1,10 +1,10 @@
1
1
  import { useConstantValueInvariant, useConstantLengthInvariant } from "@contember/react-utils";
2
2
  import { useCallback } from "react";
3
3
  import { useAccessorUpdateSubscription } from "./useAccessorUpdateSubscription.js";
4
+ import { useOnHasOneRelationPathConnectionUpdate } from "./useOnHasOneRelationPathConnectionUpdate.js";
4
5
  import { useDesugaredRelativeSingleField } from "./useDesugaredRelativeSingleField.js";
5
6
  import { useEntityKey } from "./useEntityKey.js";
6
7
  import { useGetEntityByKey } from "./useGetEntityByKey.js";
7
- import { useOnConnectionUpdate } from "../entityEvents/useOnConnectionUpdate.js";
8
8
  function useField(sugaredRelativeSingleField) {
9
9
  const relativeSingleField = useDesugaredRelativeSingleField(sugaredRelativeSingleField);
10
10
  useConstantValueInvariant(
@@ -23,9 +23,7 @@ function useField(sugaredRelativeSingleField) {
23
23
  "Cannot change the length of the hasOneRelation path!"
24
24
  );
25
25
  const [field, { update }] = useAccessorUpdateSubscription(getField);
26
- if (relativeSingleField.hasOneRelationPath.length) {
27
- useOnConnectionUpdate(relativeSingleField.hasOneRelationPath[0].field, update);
28
- }
26
+ useOnHasOneRelationPathConnectionUpdate(relativeSingleField.hasOneRelationPath, update);
29
27
  return field;
30
28
  }
31
29
  return void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"useField.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/useField.ts"],"sourcesContent":["import { useConstantLengthInvariant, useConstantValueInvariant } from '@contember/react-utils'\nimport { useCallback } from 'react'\nimport { useEntityKey, useGetEntityByKey } from './index.js'\nimport type { FieldAccessor } from '@contember/binding'\nimport { useOnConnectionUpdate } from '../entityEvents/index.js'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription.js'\nimport { useDesugaredRelativeSingleField } from './useDesugaredRelativeSingleField.js'\n\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField,\n): FieldAccessor<Value>\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField | undefined,\n): FieldAccessor<Value> | undefined\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField | undefined,\n): FieldAccessor<Value> | undefined {\n\tconst relativeSingleField = useDesugaredRelativeSingleField(sugaredRelativeSingleField)\n\tuseConstantValueInvariant(\n\t\t!!relativeSingleField,\n\t\t'useField: cannot alternate between providing and omitting the argument.',\n\t)\n\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst getField = useCallback(() => {\n\t\tconst parent = getEntityByKey(entityKey)\n\t\treturn parent.getField<Value>(relativeSingleField!)\n\t}, [entityKey, getEntityByKey, relativeSingleField])\n\n\tif (relativeSingleField) {\n\t\tuseConstantLengthInvariant(\n\t\t\trelativeSingleField.hasOneRelationPath,\n\t\t\t'Cannot change the length of the hasOneRelation path!',\n\t\t)\n\t\tconst [field, { update }] = useAccessorUpdateSubscription(getField)\n\n\t\tif (relativeSingleField.hasOneRelationPath.length) {\n\t\t\tuseOnConnectionUpdate(relativeSingleField.hasOneRelationPath[0].field, update)\n\t\t}\n\n\t\treturn field\n\t}\n\treturn undefined\n}\n\nexport { useField }\n"],"names":[],"mappings":";;;;;;;AAeA,SAAS,SACR,4BACmC;AACnC,QAAM,sBAAsB,gCAAgC,0BAA0B;AACtF;AAAA,IACC,CAAC,CAAC;AAAA,IACF;AAAA,EAAA;AAGD,QAAM,YAAY,aAAA;AAClB,QAAM,iBAAiB,kBAAA;AACvB,QAAM,WAAW,YAAY,MAAM;AAClC,UAAM,SAAS,eAAe,SAAS;AACvC,WAAO,OAAO,SAAgB,mBAAoB;AAAA,EACnD,GAAG,CAAC,WAAW,gBAAgB,mBAAmB,CAAC;AAEnD,MAAI,qBAAqB;AACxB;AAAA,MACC,oBAAoB;AAAA,MACpB;AAAA,IAAA;AAED,UAAM,CAAC,OAAO,EAAE,QAAQ,IAAI,8BAA8B,QAAQ;AAElE,QAAI,oBAAoB,mBAAmB,QAAQ;AAClD,4BAAsB,oBAAoB,mBAAmB,CAAC,EAAE,OAAO,MAAM;AAAA,IAC9E;AAEA,WAAO;AAAA,EACR;AACA,SAAO;AACR;"}
1
+ {"version":3,"file":"useField.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/useField.ts"],"sourcesContent":["import { useConstantLengthInvariant, useConstantValueInvariant } from '@contember/react-utils'\nimport { useCallback } from 'react'\nimport { useEntityKey, useGetEntityByKey } from './index.js'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\nimport { useAccessorUpdateSubscription } from './useAccessorUpdateSubscription.js'\nimport { useOnHasOneRelationPathConnectionUpdate } from './useOnHasOneRelationPathConnectionUpdate.js'\nimport { useDesugaredRelativeSingleField } from './useDesugaredRelativeSingleField.js'\n\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField,\n): FieldAccessor<Value>\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField | undefined,\n): FieldAccessor<Value> | undefined\nfunction useField<Value extends FieldValue = FieldValue>(\n\tsugaredRelativeSingleField: string | SugaredRelativeSingleField | undefined,\n): FieldAccessor<Value> | undefined {\n\tconst relativeSingleField = useDesugaredRelativeSingleField(sugaredRelativeSingleField)\n\tuseConstantValueInvariant(\n\t\t!!relativeSingleField,\n\t\t'useField: cannot alternate between providing and omitting the argument.',\n\t)\n\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst getField = useCallback(() => {\n\t\tconst parent = getEntityByKey(entityKey)\n\t\treturn parent.getField<Value>(relativeSingleField!)\n\t}, [entityKey, getEntityByKey, relativeSingleField])\n\n\tif (relativeSingleField) {\n\t\tuseConstantLengthInvariant(\n\t\t\trelativeSingleField.hasOneRelationPath,\n\t\t\t'Cannot change the length of the hasOneRelation path!',\n\t\t)\n\t\tconst [field, { update }] = useAccessorUpdateSubscription(getField)\n\n\t\tuseOnHasOneRelationPathConnectionUpdate(relativeSingleField.hasOneRelationPath, update)\n\n\t\treturn field\n\t}\n\treturn undefined\n}\n\nexport { useField }\n"],"names":[],"mappings":";;;;;;;AAeA,SAAS,SACR,4BACmC;AACnC,QAAM,sBAAsB,gCAAgC,0BAA0B;AACtF;AAAA,IACC,CAAC,CAAC;AAAA,IACF;AAAA,EAAA;AAGD,QAAM,YAAY,aAAA;AAClB,QAAM,iBAAiB,kBAAA;AACvB,QAAM,WAAW,YAAY,MAAM;AAClC,UAAM,SAAS,eAAe,SAAS;AACvC,WAAO,OAAO,SAAgB,mBAAoB;AAAA,EACnD,GAAG,CAAC,WAAW,gBAAgB,mBAAmB,CAAC;AAEnD,MAAI,qBAAqB;AACxB;AAAA,MACC,oBAAoB;AAAA,MACpB;AAAA,IAAA;AAED,UAAM,CAAC,OAAO,EAAE,QAAQ,IAAI,8BAA8B,QAAQ;AAElE,4CAAwC,oBAAoB,oBAAoB,MAAM;AAEtF,WAAO;AAAA,EACR;AACA,SAAO;AACR;"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const reactUtils = require("@contember/react-utils");
4
+ const React = require("react");
5
+ const useEntityKey = require("./useEntityKey.cjs");
6
+ const useGetEntityByKey = require("./useGetEntityByKey.cjs");
7
+ const useOnHasOneRelationPathConnectionUpdate = (hasOneRelationPath, update) => {
8
+ const entityKey = useEntityKey.useEntityKey();
9
+ const getEntityByKey = useGetEntityByKey.useGetEntityByKey();
10
+ const hopParentGetters = [];
11
+ if (hasOneRelationPath.length > 0) {
12
+ let hopParent = getEntityByKey(entityKey);
13
+ for (const [index, hop] of hasOneRelationPath.entries()) {
14
+ hopParentGetters.push(hopParent.getAccessor);
15
+ if (index < hasOneRelationPath.length - 1) {
16
+ hopParent = hopParent.getEntity({ hasOneRelationPath: [hop] });
17
+ }
18
+ }
19
+ }
20
+ const stableHopParentGetters = reactUtils.useObjectMemo(hopParentGetters);
21
+ React.useEffect(() => {
22
+ const unsubscribers = stableHopParentGetters.map(
23
+ (getHopParent, index) => getHopParent().addEventListener({ type: "connectionUpdate", key: hasOneRelationPath[index].field }, update)
24
+ );
25
+ return () => {
26
+ for (const unsubscribe of unsubscribers) {
27
+ unsubscribe();
28
+ }
29
+ };
30
+ }, [hasOneRelationPath, stableHopParentGetters, update]);
31
+ };
32
+ exports.useOnHasOneRelationPathConnectionUpdate = useOnHasOneRelationPathConnectionUpdate;
33
+ //# sourceMappingURL=useOnHasOneRelationPathConnectionUpdate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnHasOneRelationPathConnectionUpdate.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.ts"],"sourcesContent":["import type { EntityAccessor, HasOneRelation } from '@contember/binding'\nimport { useObjectMemo } from '@contember/react-utils'\nimport { useEffect } from 'react'\nimport { useEntityKey } from './useEntityKey.js'\nimport { useGetEntityByKey } from './useGetEntityByKey.js'\n\n/**\n * Calls `update` when any has-one relation along the path is reconnected, not only the first one.\n * Each hop is watched on the entity it currently hangs off, so the listeners move once an earlier hop is reconnected.\n */\nexport const useOnHasOneRelationPathConnectionUpdate = (hasOneRelationPath: HasOneRelation[], update: () => void): void => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\n\t// A getter is stable per entity realm, so this array changes exactly when a hop resolves to another entity.\n\tconst hopParentGetters: EntityAccessor.GetEntityAccessor[] = []\n\tif (hasOneRelationPath.length > 0) {\n\t\tlet hopParent = getEntityByKey(entityKey)\n\t\tfor (const [index, hop] of hasOneRelationPath.entries()) {\n\t\t\thopParentGetters.push(hopParent.getAccessor)\n\t\t\tif (index < hasOneRelationPath.length - 1) {\n\t\t\t\thopParent = hopParent.getEntity({ hasOneRelationPath: [hop] })\n\t\t\t}\n\t\t}\n\t}\n\tconst stableHopParentGetters = useObjectMemo(hopParentGetters)\n\n\tuseEffect(() => {\n\t\tconst unsubscribers = stableHopParentGetters.map((getHopParent, index) =>\n\t\t\tgetHopParent().addEventListener({ type: 'connectionUpdate', key: hasOneRelationPath[index].field }, update)\n\t\t)\n\t\treturn () => {\n\t\t\tfor (const unsubscribe of unsubscribers) {\n\t\t\t\tunsubscribe()\n\t\t\t}\n\t\t}\n\t}, [hasOneRelationPath, stableHopParentGetters, update])\n}\n"],"names":["useEntityKey","useGetEntityByKey","useObjectMemo","useEffect"],"mappings":";;;;;;AAUO,MAAM,0CAA0C,CAAC,oBAAsC,WAA6B;AAC1H,QAAM,YAAYA,aAAAA,aAAA;AAClB,QAAM,iBAAiBC,kBAAAA,kBAAA;AAGvB,QAAM,mBAAuD,CAAA;AAC7D,MAAI,mBAAmB,SAAS,GAAG;AAClC,QAAI,YAAY,eAAe,SAAS;AACxC,eAAW,CAAC,OAAO,GAAG,KAAK,mBAAmB,WAAW;AACxD,uBAAiB,KAAK,UAAU,WAAW;AAC3C,UAAI,QAAQ,mBAAmB,SAAS,GAAG;AAC1C,oBAAY,UAAU,UAAU,EAAE,oBAAoB,CAAC,GAAG,GAAG;AAAA,MAC9D;AAAA,IACD;AAAA,EACD;AACA,QAAM,yBAAyBC,WAAAA,cAAc,gBAAgB;AAE7DC,QAAAA,UAAU,MAAM;AACf,UAAM,gBAAgB,uBAAuB;AAAA,MAAI,CAAC,cAAc,UAC/D,aAAA,EAAe,iBAAiB,EAAE,MAAM,oBAAoB,KAAK,mBAAmB,KAAK,EAAE,MAAA,GAAS,MAAM;AAAA,IAAA;AAE3G,WAAO,MAAM;AACZ,iBAAW,eAAe,eAAe;AACxC,oBAAA;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,CAAC,oBAAoB,wBAAwB,MAAM,CAAC;AACxD;;"}
@@ -0,0 +1,33 @@
1
+ import { useObjectMemo } from "@contember/react-utils";
2
+ import { useEffect } from "react";
3
+ import { useEntityKey } from "./useEntityKey.js";
4
+ import { useGetEntityByKey } from "./useGetEntityByKey.js";
5
+ const useOnHasOneRelationPathConnectionUpdate = (hasOneRelationPath, update) => {
6
+ const entityKey = useEntityKey();
7
+ const getEntityByKey = useGetEntityByKey();
8
+ const hopParentGetters = [];
9
+ if (hasOneRelationPath.length > 0) {
10
+ let hopParent = getEntityByKey(entityKey);
11
+ for (const [index, hop] of hasOneRelationPath.entries()) {
12
+ hopParentGetters.push(hopParent.getAccessor);
13
+ if (index < hasOneRelationPath.length - 1) {
14
+ hopParent = hopParent.getEntity({ hasOneRelationPath: [hop] });
15
+ }
16
+ }
17
+ }
18
+ const stableHopParentGetters = useObjectMemo(hopParentGetters);
19
+ useEffect(() => {
20
+ const unsubscribers = stableHopParentGetters.map(
21
+ (getHopParent, index) => getHopParent().addEventListener({ type: "connectionUpdate", key: hasOneRelationPath[index].field }, update)
22
+ );
23
+ return () => {
24
+ for (const unsubscribe of unsubscribers) {
25
+ unsubscribe();
26
+ }
27
+ };
28
+ }, [hasOneRelationPath, stableHopParentGetters, update]);
29
+ };
30
+ export {
31
+ useOnHasOneRelationPathConnectionUpdate
32
+ };
33
+ //# sourceMappingURL=useOnHasOneRelationPathConnectionUpdate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnHasOneRelationPathConnectionUpdate.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.ts"],"sourcesContent":["import type { EntityAccessor, HasOneRelation } from '@contember/binding'\nimport { useObjectMemo } from '@contember/react-utils'\nimport { useEffect } from 'react'\nimport { useEntityKey } from './useEntityKey.js'\nimport { useGetEntityByKey } from './useGetEntityByKey.js'\n\n/**\n * Calls `update` when any has-one relation along the path is reconnected, not only the first one.\n * Each hop is watched on the entity it currently hangs off, so the listeners move once an earlier hop is reconnected.\n */\nexport const useOnHasOneRelationPathConnectionUpdate = (hasOneRelationPath: HasOneRelation[], update: () => void): void => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\n\t// A getter is stable per entity realm, so this array changes exactly when a hop resolves to another entity.\n\tconst hopParentGetters: EntityAccessor.GetEntityAccessor[] = []\n\tif (hasOneRelationPath.length > 0) {\n\t\tlet hopParent = getEntityByKey(entityKey)\n\t\tfor (const [index, hop] of hasOneRelationPath.entries()) {\n\t\t\thopParentGetters.push(hopParent.getAccessor)\n\t\t\tif (index < hasOneRelationPath.length - 1) {\n\t\t\t\thopParent = hopParent.getEntity({ hasOneRelationPath: [hop] })\n\t\t\t}\n\t\t}\n\t}\n\tconst stableHopParentGetters = useObjectMemo(hopParentGetters)\n\n\tuseEffect(() => {\n\t\tconst unsubscribers = stableHopParentGetters.map((getHopParent, index) =>\n\t\t\tgetHopParent().addEventListener({ type: 'connectionUpdate', key: hasOneRelationPath[index].field }, update)\n\t\t)\n\t\treturn () => {\n\t\t\tfor (const unsubscribe of unsubscribers) {\n\t\t\t\tunsubscribe()\n\t\t\t}\n\t\t}\n\t}, [hasOneRelationPath, stableHopParentGetters, update])\n}\n"],"names":[],"mappings":";;;;AAUO,MAAM,0CAA0C,CAAC,oBAAsC,WAA6B;AAC1H,QAAM,YAAY,aAAA;AAClB,QAAM,iBAAiB,kBAAA;AAGvB,QAAM,mBAAuD,CAAA;AAC7D,MAAI,mBAAmB,SAAS,GAAG;AAClC,QAAI,YAAY,eAAe,SAAS;AACxC,eAAW,CAAC,OAAO,GAAG,KAAK,mBAAmB,WAAW;AACxD,uBAAiB,KAAK,UAAU,WAAW;AAC3C,UAAI,QAAQ,mBAAmB,SAAS,GAAG;AAC1C,oBAAY,UAAU,UAAU,EAAE,oBAAoB,CAAC,GAAG,GAAG;AAAA,MAC9D;AAAA,IACD;AAAA,EACD;AACA,QAAM,yBAAyB,cAAc,gBAAgB;AAE7D,YAAU,MAAM;AACf,UAAM,gBAAgB,uBAAuB;AAAA,MAAI,CAAC,cAAc,UAC/D,aAAA,EAAe,iBAAiB,EAAE,MAAM,oBAAoB,KAAK,mBAAmB,KAAK,EAAE,MAAA,GAAS,MAAM;AAAA,IAAA;AAE3G,WAAO,MAAM;AACZ,iBAAW,eAAe,eAAe;AACxC,oBAAA;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,CAAC,oBAAoB,wBAAwB,MAAM,CAAC;AACxD;"}
@@ -5,6 +5,7 @@ export declare const useAccessorUpdateSubscription: <Accessor extends {
5
5
  addEventListener: (event: {
6
6
  type: 'update';
7
7
  }, cb: (accessor: Accessor) => void) => () => void;
8
+ getAccessor: () => Accessor;
8
9
  }>(getAccessor: () => Accessor) => [Accessor, {
9
10
  update: () => void;
10
11
  }];
@@ -1 +1 @@
1
- {"version":3,"file":"useAccessorUpdateSubscription.d.ts","sourceRoot":"","sources":["../../../src/accessorPropagation/useAccessorUpdateSubscription.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,6BAA6B,GACzC,QAAQ,SAAS;IAChB,gBAAgB,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;CAC7F,eACa,MAAM,QAAQ,KAAG,CAAC,QAAQ,EAAE;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CA+BhE,CAAA"}
1
+ {"version":3,"file":"useAccessorUpdateSubscription.d.ts","sourceRoot":"","sources":["../../../src/accessorPropagation/useAccessorUpdateSubscription.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,6BAA6B,GACzC,QAAQ,SAAS;IAChB,gBAAgB,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;IAC7F,WAAW,EAAE,MAAM,QAAQ,CAAA;CAC3B,eACa,MAAM,QAAQ,KAAG,CAAC,QAAQ,EAAE;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAoChE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useEntity.d.ts","sourceRoot":"","sources":["../../../src/accessorPropagation/useEntity.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAIrE,iBAAS,SAAS,IAAI,cAAc,CAAA;AACpC,iBAAS,SAAS,CAAC,2BAA2B,EAAE,MAAM,GAAG,2BAA2B,GAAG,cAAc,CAAA;AACrG,iBAAS,SAAS,CACjB,2BAA2B,EAAE,MAAM,GAAG,2BAA2B,GAAG,SAAS,GAC3E,cAAc,GAAG,SAAS,CAAA;AAmC7B,OAAO,EAAE,SAAS,EAAE,CAAA"}
1
+ {"version":3,"file":"useEntity.d.ts","sourceRoot":"","sources":["../../../src/accessorPropagation/useEntity.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAKrE,iBAAS,SAAS,IAAI,cAAc,CAAA;AACpC,iBAAS,SAAS,CAAC,2BAA2B,EAAE,MAAM,GAAG,2BAA2B,GAAG,cAAc,CAAA;AACrG,iBAAS,SAAS,CACjB,2BAA2B,EAAE,MAAM,GAAG,2BAA2B,GAAG,SAAS,GAC3E,cAAc,GAAG,SAAS,CAAA;AAiC7B,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useEntityList.d.ts","sourceRoot":"","sources":["../../../src/accessorPropagation/useEntityList.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAInE,iBAAS,aAAa,CAAC,yBAAyB,EAAE,MAAM,GAAG,yBAAyB,GAAG,kBAAkB,CAAA;AACzG,iBAAS,aAAa,CACrB,yBAAyB,EAAE,MAAM,GAAG,yBAAyB,GAAG,SAAS,GACvE,kBAAkB,GAAG,SAAS,CAAA;AAiCjC,OAAO,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"useEntityList.d.ts","sourceRoot":"","sources":["../../../src/accessorPropagation/useEntityList.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAKnE,iBAAS,aAAa,CAAC,yBAAyB,EAAE,MAAM,GAAG,yBAAyB,GAAG,kBAAkB,CAAA;AACzG,iBAAS,aAAa,CACrB,yBAAyB,EAAE,MAAM,GAAG,yBAAyB,GAAG,SAAS,GACvE,kBAAkB,GAAG,SAAS,CAAA;AA+BjC,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useField.d.ts","sourceRoot":"","sources":["../../../src/accessorPropagation/useField.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAIhF,iBAAS,QAAQ,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EACtD,0BAA0B,EAAE,MAAM,GAAG,0BAA0B,GAC7D,aAAa,CAAC,KAAK,CAAC,CAAA;AACvB,iBAAS,QAAQ,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EACtD,0BAA0B,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS,GACzE,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;AAiCnC,OAAO,EAAE,QAAQ,EAAE,CAAA"}
1
+ {"version":3,"file":"useField.d.ts","sourceRoot":"","sources":["../../../src/accessorPropagation/useField.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAKhF,iBAAS,QAAQ,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EACtD,0BAA0B,EAAE,MAAM,GAAG,0BAA0B,GAC7D,aAAa,CAAC,KAAK,CAAC,CAAA;AACvB,iBAAS,QAAQ,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU,EACtD,0BAA0B,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS,GACzE,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;AA+BnC,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { HasOneRelation } from '@contember/binding';
2
+ /**
3
+ * Calls `update` when any has-one relation along the path is reconnected, not only the first one.
4
+ * Each hop is watched on the entity it currently hangs off, so the listeners move once an earlier hop is reconnected.
5
+ */
6
+ export declare const useOnHasOneRelationPathConnectionUpdate: (hasOneRelationPath: HasOneRelation[], update: () => void) => void;
7
+ //# sourceMappingURL=useOnHasOneRelationPathConnectionUpdate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnHasOneRelationPathConnectionUpdate.d.ts","sourceRoot":"","sources":["../../../src/accessorPropagation/useOnHasOneRelationPathConnectionUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAMxE;;;GAGG;AACH,eAAO,MAAM,uCAAuC,uBAAwB,cAAc,EAAE,UAAU,MAAM,IAAI,KAAG,IA2BlH,CAAA"}