@makeswift/runtime 0.28.8-canary.16 → 0.28.8-canary.18

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 (90) hide show
  1. package/dist/cjs/api/graphql-api-client.js +1 -1
  2. package/dist/cjs/api/rest-api-client.js +1 -1
  3. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  4. package/dist/cjs/client/index.js +1 -1
  5. package/dist/cjs/prop-controllers/instances.js.map +1 -1
  6. package/dist/cjs/runtimes/react/components/Element.js +18 -8
  7. package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
  8. package/dist/cjs/runtimes/react/components/ElementRegistration.js +28 -9
  9. package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
  10. package/dist/cjs/runtimes/react/components/control-instances-context.js +38 -0
  11. package/dist/cjs/runtimes/react/components/control-instances-context.js.map +1 -0
  12. package/dist/cjs/runtimes/react/hooks/use-control-instances.js +2 -13
  13. package/dist/cjs/runtimes/react/hooks/use-control-instances.js.map +1 -1
  14. package/dist/cjs/runtimes/react/hooks/use-disable-register-element.js +3 -3
  15. package/dist/cjs/runtimes/react/hooks/use-disable-register-element.js.map +1 -1
  16. package/dist/cjs/state/actions/internal/read-write-action-types.js +1 -0
  17. package/dist/cjs/state/actions/internal/read-write-action-types.js.map +1 -1
  18. package/dist/cjs/state/actions/internal/read-write-actions.js +55 -0
  19. package/dist/cjs/state/actions/internal/read-write-actions.js.map +1 -1
  20. package/dist/cjs/state/middleware/read-write/prop-controller-handles.js +0 -38
  21. package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -1
  22. package/dist/cjs/state/store.js +2 -0
  23. package/dist/cjs/state/store.js.map +1 -1
  24. package/dist/cjs/state/unified-state.js.map +1 -1
  25. package/dist/cjs/testing/element-data.js +4 -4
  26. package/dist/cjs/testing/element-data.js.map +1 -1
  27. package/dist/cjs/testing/read-write-state.js +32 -0
  28. package/dist/cjs/testing/read-write-state.js.map +1 -0
  29. package/dist/esm/api/graphql-api-client.js +1 -1
  30. package/dist/esm/api/rest-api-client.js +1 -1
  31. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  32. package/dist/esm/client/index.js +1 -1
  33. package/dist/esm/prop-controllers/instances.js.map +1 -1
  34. package/dist/esm/runtimes/react/components/Element.js +18 -8
  35. package/dist/esm/runtimes/react/components/Element.js.map +1 -1
  36. package/dist/esm/runtimes/react/components/ElementRegistration.js +34 -11
  37. package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
  38. package/dist/esm/runtimes/react/components/control-instances-context.js +13 -0
  39. package/dist/esm/runtimes/react/components/control-instances-context.js.map +1 -0
  40. package/dist/esm/runtimes/react/hooks/use-control-instances.js +1 -12
  41. package/dist/esm/runtimes/react/hooks/use-control-instances.js.map +1 -1
  42. package/dist/esm/runtimes/react/hooks/use-disable-register-element.js +2 -2
  43. package/dist/esm/runtimes/react/hooks/use-disable-register-element.js.map +1 -1
  44. package/dist/esm/state/actions/internal/read-write-action-types.js +1 -0
  45. package/dist/esm/state/actions/internal/read-write-action-types.js.map +1 -1
  46. package/dist/esm/state/actions/internal/read-write-actions.js +42 -0
  47. package/dist/esm/state/actions/internal/read-write-actions.js.map +1 -1
  48. package/dist/esm/state/middleware/read-write/prop-controller-handles.js +1 -44
  49. package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -1
  50. package/dist/esm/state/store.js +2 -0
  51. package/dist/esm/state/store.js.map +1 -1
  52. package/dist/esm/state/unified-state.js.map +1 -1
  53. package/dist/esm/testing/element-data.js +4 -4
  54. package/dist/esm/testing/element-data.js.map +1 -1
  55. package/dist/esm/testing/read-write-state.js +8 -0
  56. package/dist/esm/testing/read-write-state.js.map +1 -0
  57. package/dist/types/controls/__tests__/slot.test.d.ts +3 -0
  58. package/dist/types/controls/__tests__/slot.test.d.ts.map +1 -0
  59. package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  60. package/dist/types/prop-controllers/instances.d.ts +2 -2
  61. package/dist/types/prop-controllers/instances.d.ts.map +1 -1
  62. package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
  63. package/dist/types/runtimes/react/components/ElementRegistration.d.ts +3 -3
  64. package/dist/types/runtimes/react/components/ElementRegistration.d.ts.map +1 -1
  65. package/dist/types/runtimes/react/components/__tests__/element-registration.test.d.ts +3 -0
  66. package/dist/types/runtimes/react/components/__tests__/element-registration.test.d.ts.map +1 -0
  67. package/dist/types/runtimes/react/components/control-instances-context.d.ts +9 -0
  68. package/dist/types/runtimes/react/components/control-instances-context.d.ts.map +1 -0
  69. package/dist/types/runtimes/react/hooks/use-control-instances.d.ts +1 -2
  70. package/dist/types/runtimes/react/hooks/use-control-instances.d.ts.map +1 -1
  71. package/dist/types/runtimes/react/hooks/use-disable-register-element.d.ts +1 -1
  72. package/dist/types/runtimes/react/hooks/use-disable-register-element.d.ts.map +1 -1
  73. package/dist/types/slate/InlineModePlugin/index.d.ts +1 -1
  74. package/dist/types/state/actions/index.d.ts +1 -0
  75. package/dist/types/state/actions/index.d.ts.map +1 -1
  76. package/dist/types/state/actions/internal/action-types.d.ts +1 -0
  77. package/dist/types/state/actions/internal/action-types.d.ts.map +1 -1
  78. package/dist/types/state/actions/internal/read-write-action-types.d.ts +1 -0
  79. package/dist/types/state/actions/internal/read-write-action-types.d.ts.map +1 -1
  80. package/dist/types/state/actions/internal/read-write-actions.d.ts +15 -1
  81. package/dist/types/state/actions/internal/read-write-actions.d.ts.map +1 -1
  82. package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -1
  83. package/dist/types/state/store.d.ts.map +1 -1
  84. package/dist/types/state/unified-state.d.ts +1 -0
  85. package/dist/types/state/unified-state.d.ts.map +1 -1
  86. package/dist/types/testing/element-data.d.ts +9 -5
  87. package/dist/types/testing/element-data.d.ts.map +1 -1
  88. package/dist/types/testing/read-write-state.d.ts +3 -0
  89. package/dist/types/testing/read-write-state.d.ts.map +1 -0
  90. package/package.json +3 -3
@@ -27,7 +27,7 @@ class MakeswiftGraphQLApiClient {
27
27
  graphqlClient;
28
28
  constructor({ endpoint }) {
29
29
  this.graphqlClient = new import_client.GraphQLClient(endpoint, {
30
- "makeswift-runtime-version": "0.28.8-canary.16"
30
+ "makeswift-runtime-version": "0.28.8-canary.18"
31
31
  });
32
32
  }
33
33
  async createTableRecord(tableId, columns) {
@@ -147,7 +147,7 @@ class MakeswiftRestAPIClient {
147
147
  const requestHeaders = new Headers({
148
148
  "x-api-key": this.apiKey,
149
149
  "makeswift-site-api-key": this.apiKey,
150
- "makeswift-runtime-version": "0.28.8-canary.16"
150
+ "makeswift-runtime-version": "0.28.8-canary.18"
151
151
  });
152
152
  if (siteVersion?.token) {
153
153
  requestUrl.searchParams.set("version", siteVersion.version);
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
28
28
  return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
29
29
  }
30
30
  return import_request_response.ApiResponse.json({
31
- version: "0.28.8-canary.16",
31
+ version: "0.28.8-canary.18",
32
32
  interactionMode: true,
33
33
  clientSideNavigation: false,
34
34
  elementFromPoint: false,
@@ -689,7 +689,7 @@ Received "${apiKey}" instead.`
689
689
  headers: {
690
690
  "x-api-key": this.apiKey,
691
691
  "makeswift-site-api-key": this.apiKey,
692
- "makeswift-runtime-version": "0.28.8-canary.16",
692
+ "makeswift-runtime-version": "0.28.8-canary.18",
693
693
  "content-type": "application/json"
694
694
  },
695
695
  body: JSON.stringify({ token }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prop-controllers/instances.ts"],"sourcesContent":["import { type Descriptor, isLegacyDescriptor } from './descriptors'\nimport { Types as PropControllerTypes } from '@makeswift/prop-controllers'\n\nimport {\n type BoxDisplayModel,\n type ControlInstanceArgs,\n type ControlMessage,\n type InstanceType,\n ControlInstance,\n DefaultControlInstance,\n} from '@makeswift/controls'\n\nexport type PropControllerMessage = ControlMessage\n\nexport const TableFormFieldsMessageType = {\n TABLE_FORM_LAYOUT_CHANGE: 'TABLE_FORM_LAYOUT_CHANGE',\n TABLE_FORM_FIELD_LAYOUT_CHANGE: 'TABLE_FORM_FIELD_LAYOUT_CHANGE',\n} as const\n\ntype TableLayoutTableFormFieldsMessage = {\n type: typeof TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE\n payload: { layout: BoxDisplayModel }\n}\n\ntype TableFieldLayoutTableFormFieldsMessage = {\n type: typeof TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE\n payload: { layout: BoxDisplayModel; index: number }\n}\n\nexport type TableFormFieldsMessage =\n | TableLayoutTableFormFieldsMessage\n | TableFieldLayoutTableFormFieldsMessage\n\nexport class TableFormFieldsPropController extends ControlInstance<TableFormFieldsMessage> {\n recv = () => {}\n\n isCompositeProp(): boolean {\n return false\n }\n\n children(): ControlInstance[] {\n return []\n }\n\n child(_key: string): ControlInstance | undefined {\n return undefined\n }\n\n resolvesToRenderableNode(): boolean {\n return false\n }\n\n tableFormLayoutChange(payload: { layout: BoxDisplayModel }) {\n this.sendMessage({ type: TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE, payload })\n }\n\n tableFormFieldLayoutChange(payload: { layout: BoxDisplayModel; index: number }) {\n this.sendMessage({ type: TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE, payload })\n }\n}\n\ntype DescriptorPropController<T extends Descriptor> = T extends {\n type: typeof PropControllerTypes.TableFormFields\n}\n ? TableFormFieldsPropController\n : InstanceType<T>\n\nexport type DescriptorsPropControllers<T extends Record<string, Descriptor>> = {\n [K in keyof T]: undefined extends T[K]\n ? DescriptorPropController<Exclude<T[K], undefined>>\n : DescriptorPropController<T[K]>\n}\n\nexport type AnyPropController = ControlInstance<any> | TableFormFieldsPropController\n\nexport function createPropController({\n descriptor,\n ...args\n}: {\n descriptor: Descriptor\n} & ControlInstanceArgs): AnyPropController {\n if (!isLegacyDescriptor(descriptor)) {\n return descriptor.createInstance(args)\n }\n\n switch (descriptor.type) {\n case PropControllerTypes.TableFormFields:\n return new TableFormFieldsPropController(args)\n\n default:\n return new DefaultControlInstance(args)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAoD;AACpD,8BAA6C;AAE7C,sBAOO;AAIA,MAAM,6BAA6B;AAAA,EACxC,0BAA0B;AAAA,EAC1B,gCAAgC;AAClC;AAgBO,MAAM,sCAAsC,gCAAwC;AAAA,EACzF,OAAO,MAAM;AAAA,EAAC;AAAA,EAEd,kBAA2B;AACzB,WAAO;AAAA,EACT;AAAA,EAEA,WAA8B;AAC5B,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,MAAM,MAA2C;AAC/C,WAAO;AAAA,EACT;AAAA,EAEA,2BAAoC;AAClC,WAAO;AAAA,EACT;AAAA,EAEA,sBAAsB,SAAsC;AAC1D,SAAK,YAAY,EAAE,MAAM,2BAA2B,0BAA0B,QAAQ,CAAC;AAAA,EACzF;AAAA,EAEA,2BAA2B,SAAqD;AAC9E,SAAK,YAAY,EAAE,MAAM,2BAA2B,gCAAgC,QAAQ,CAAC;AAAA,EAC/F;AACF;AAgBO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,GAAG;AACL,GAE4C;AAC1C,MAAI,KAAC,uCAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,eAAe,IAAI;AAAA,EACvC;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,wBAAAA,MAAoB;AACvB,aAAO,IAAI,8BAA8B,IAAI;AAAA,IAE/C;AACE,aAAO,IAAI,uCAAuB,IAAI;AAAA,EAC1C;AACF;","names":["PropControllerTypes"]}
1
+ {"version":3,"sources":["../../../src/prop-controllers/instances.ts"],"sourcesContent":["import { type Descriptor, isLegacyDescriptor } from './descriptors'\nimport { Types as PropControllerTypes } from '@makeswift/prop-controllers'\n\nimport {\n type BoxDisplayModel,\n type ControlInstanceArgs,\n type ControlMessage,\n type InstanceType,\n type AnyControlInstance,\n ControlInstance,\n DefaultControlInstance,\n} from '@makeswift/controls'\n\nexport type PropControllerMessage = ControlMessage\n\nexport const TableFormFieldsMessageType = {\n TABLE_FORM_LAYOUT_CHANGE: 'TABLE_FORM_LAYOUT_CHANGE',\n TABLE_FORM_FIELD_LAYOUT_CHANGE: 'TABLE_FORM_FIELD_LAYOUT_CHANGE',\n} as const\n\ntype TableLayoutTableFormFieldsMessage = {\n type: typeof TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE\n payload: { layout: BoxDisplayModel }\n}\n\ntype TableFieldLayoutTableFormFieldsMessage = {\n type: typeof TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE\n payload: { layout: BoxDisplayModel; index: number }\n}\n\nexport type TableFormFieldsMessage =\n | TableLayoutTableFormFieldsMessage\n | TableFieldLayoutTableFormFieldsMessage\n\nexport class TableFormFieldsPropController extends ControlInstance<TableFormFieldsMessage> {\n recv = () => {}\n\n isCompositeProp(): boolean {\n return false\n }\n\n children(): ControlInstance[] {\n return []\n }\n\n child(_key: string): ControlInstance | undefined {\n return undefined\n }\n\n resolvesToRenderableNode(): boolean {\n return false\n }\n\n tableFormLayoutChange(payload: { layout: BoxDisplayModel }) {\n this.sendMessage({ type: TableFormFieldsMessageType.TABLE_FORM_LAYOUT_CHANGE, payload })\n }\n\n tableFormFieldLayoutChange(payload: { layout: BoxDisplayModel; index: number }) {\n this.sendMessage({ type: TableFormFieldsMessageType.TABLE_FORM_FIELD_LAYOUT_CHANGE, payload })\n }\n}\n\ntype DescriptorPropController<T extends Descriptor> = T extends {\n type: typeof PropControllerTypes.TableFormFields\n}\n ? TableFormFieldsPropController\n : InstanceType<T>\n\nexport type DescriptorsPropControllers<T extends Record<string, Descriptor>> = {\n [K in keyof T]: undefined extends T[K]\n ? DescriptorPropController<Exclude<T[K], undefined>>\n : DescriptorPropController<T[K]>\n}\n\nexport type AnyPropController = AnyControlInstance | TableFormFieldsPropController\n\nexport function createPropController({\n descriptor,\n ...args\n}: {\n descriptor: Descriptor\n} & ControlInstanceArgs): AnyPropController {\n if (!isLegacyDescriptor(descriptor)) {\n return descriptor.createInstance(args)\n }\n\n switch (descriptor.type) {\n case PropControllerTypes.TableFormFields:\n return new TableFormFieldsPropController(args)\n\n default:\n return new DefaultControlInstance(args)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAoD;AACpD,8BAA6C;AAE7C,sBAQO;AAIA,MAAM,6BAA6B;AAAA,EACxC,0BAA0B;AAAA,EAC1B,gCAAgC;AAClC;AAgBO,MAAM,sCAAsC,gCAAwC;AAAA,EACzF,OAAO,MAAM;AAAA,EAAC;AAAA,EAEd,kBAA2B;AACzB,WAAO;AAAA,EACT;AAAA,EAEA,WAA8B;AAC5B,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,MAAM,MAA2C;AAC/C,WAAO;AAAA,EACT;AAAA,EAEA,2BAAoC;AAClC,WAAO;AAAA,EACT;AAAA,EAEA,sBAAsB,SAAsC;AAC1D,SAAK,YAAY,EAAE,MAAM,2BAA2B,0BAA0B,QAAQ,CAAC;AAAA,EACzF;AAAA,EAEA,2BAA2B,SAAqD;AAC9E,SAAK,YAAY,EAAE,MAAM,2BAA2B,gCAAgC,QAAQ,CAAC;AAAA,EAC/F;AACF;AAgBO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,GAAG;AACL,GAE4C;AAC1C,MAAI,KAAC,uCAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,eAAe,IAAI;AAAA,EACvC;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,wBAAAA,MAAoB;AACvB,aAAO,IAAI,8BAA8B,IAAI;AAAA,IAE/C;AACE,aAAO,IAAI,uCAAuB,IAAI;AAAA,EAC1C;AACF;","names":["PropControllerTypes"]}
@@ -38,6 +38,7 @@ var import_read_only_state = require("../../../state/read-only-state");
38
38
  var import_FallbackComponent = require("../../../components/shared/FallbackComponent");
39
39
  var import_ErrorBoundary = require("../../../components/shared/ErrorBoundary");
40
40
  var import_use_is_read_only = require("../hooks/use-is-read-only");
41
+ var import_use_disable_register_element = require("../hooks/use-disable-register-element");
41
42
  var import_element_imperative_handle = require("../element-imperative-handle");
42
43
  var import_find_dom_node = require("../find-dom-node");
43
44
  var import_ElementReference = require("./ElementReference");
@@ -57,15 +58,24 @@ const Element = (0, import_react.memo)(
57
58
  imperativeHandleRef.current.callback(() => current);
58
59
  }, []);
59
60
  (0, import_react.useImperativeHandle)(ref, () => imperativeHandleRef.current, []);
60
- const ElementRegistration = (0, import_use_is_read_only.useIsReadOnly)() ? NoOp : BuilderElementRegistration;
61
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ElementRegistration, { componentHandle: imperativeHandleRef.current, elementKey: element.key, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_find_dom_node.FindDomNode, { ref: findDomNodeCallbackRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ErrorBoundary.ErrorBoundary, { FallbackComponent: ErrorFallback, children: (0, import_read_only_state.isElementReference)(element) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
62
- import_ElementReference.ElementReference,
61
+ const isRegisterElementDisabled = (0, import_use_disable_register_element.useIsRegisterElementDisabled)();
62
+ const ElementRegistration = (0, import_use_is_read_only.useIsReadOnly)() || isRegisterElementDisabled ? NoOp : BuilderElementRegistration;
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
+ ElementRegistration,
63
65
  {
64
- ref: elementCallbackRef,
65
- elementReference: element
66
- },
67
- element.key
68
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ElementData.ElementData, { ref: elementCallbackRef, elementData: element }, element.key) }) }) });
66
+ componentHandle: imperativeHandleRef.current,
67
+ elementKey: element.key,
68
+ componentType: element.type,
69
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_find_dom_node.FindDomNode, { ref: findDomNodeCallbackRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ErrorBoundary.ErrorBoundary, { FallbackComponent: ErrorFallback, children: (0, import_read_only_state.isElementReference)(element) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
+ import_ElementReference.ElementReference,
71
+ {
72
+ ref: elementCallbackRef,
73
+ elementReference: element
74
+ },
75
+ element.key
76
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ElementData.ElementData, { ref: elementCallbackRef, elementData: element }, element.key) }) })
77
+ }
78
+ );
69
79
  })
70
80
  );
71
81
  function NoOp({ children }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/Element.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ReactNode,\n type Ref,\n type PropsWithChildren,\n forwardRef,\n memo,\n useCallback,\n useImperativeHandle,\n useRef,\n lazy,\n} from 'react'\n\nimport {\n isElementReference,\n type Element as ElementDataOrRef,\n} from '../../../state/read-only-state'\n\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ErrorBoundary } from '../../../components/shared/ErrorBoundary'\n\nimport { useIsReadOnly } from '../hooks/use-is-read-only'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { FindDomNode } from '../find-dom-node'\n\nimport { ElementReference } from './ElementReference'\nimport { ElementData } from './ElementData'\n\nconst BuilderElementRegistration = lazy(() => import('./ElementRegistration'))\n\ntype Props = {\n element: ElementDataOrRef\n}\n\nexport const Element = memo(\n forwardRef(function Element(\n { element }: Props,\n ref: Ref<ElementImperativeHandle>,\n ): ReactNode | null {\n const useFindDomNodeRef = useRef(true)\n const imperativeHandleRef = useRef(new ElementImperativeHandle())\n\n const findDomNodeCallbackRef = useCallback((current: (() => Element | Text | null) | null) => {\n if (useFindDomNodeRef.current === true) {\n imperativeHandleRef.current.callback(() => current?.() ?? null)\n }\n }, [])\n\n const elementCallbackRef = useCallback((current: unknown | null) => {\n useFindDomNodeRef.current = false\n\n imperativeHandleRef.current.callback(() => current)\n }, [])\n\n useImperativeHandle(ref, () => imperativeHandleRef.current, [])\n\n const ElementRegistration = useIsReadOnly() ? NoOp : BuilderElementRegistration\n\n return (\n <ElementRegistration componentHandle={imperativeHandleRef.current} elementKey={element.key}>\n <FindDomNode ref={findDomNodeCallbackRef}>\n <ErrorBoundary FallbackComponent={ErrorFallback}>\n {isElementReference(element) ? (\n <ElementReference\n key={element.key}\n ref={elementCallbackRef}\n elementReference={element}\n />\n ) : (\n <ElementData key={element.key} ref={elementCallbackRef} elementData={element} />\n )}\n </ErrorBoundary>\n </FindDomNode>\n </ElementRegistration>\n )\n }),\n)\n\nfunction NoOp({ children }: PropsWithChildren) {\n return children\n}\n\nfunction ErrorFallback() {\n return <FallbackComponent text={`Error rendering component`} />\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgEc;AA9Dd,mBAUO;AAEP,6BAGO;AAEP,+BAAkC;AAClC,2BAA8B;AAE9B,8BAA8B;AAC9B,uCAAwC;AACxC,2BAA4B;AAE5B,8BAAiC;AACjC,yBAA4B;AAE5B,MAAM,iCAA6B,mBAAK,MAAM,6CAAO,uBAAuB,GAAC;AAMtE,MAAM,cAAU;AAAA,MACrB,yBAAW,SAASA,SAClB,EAAE,QAAQ,GACV,KACkB;AAClB,UAAM,wBAAoB,qBAAO,IAAI;AACrC,UAAM,0BAAsB,qBAAO,IAAI,yDAAwB,CAAC;AAEhE,UAAM,6BAAyB,0BAAY,CAAC,YAAkD;AAC5F,UAAI,kBAAkB,YAAY,MAAM;AACtC,4BAAoB,QAAQ,SAAS,MAAM,UAAU,KAAK,IAAI;AAAA,MAChE;AAAA,IACF,GAAG,CAAC,CAAC;AAEL,UAAM,yBAAqB,0BAAY,CAAC,YAA4B;AAClE,wBAAkB,UAAU;AAE5B,0BAAoB,QAAQ,SAAS,MAAM,OAAO;AAAA,IACpD,GAAG,CAAC,CAAC;AAEL,0CAAoB,KAAK,MAAM,oBAAoB,SAAS,CAAC,CAAC;AAE9D,UAAM,0BAAsB,uCAAc,IAAI,OAAO;AAErD,WACE,4CAAC,uBAAoB,iBAAiB,oBAAoB,SAAS,YAAY,QAAQ,KACrF,sDAAC,oCAAY,KAAK,wBAChB,sDAAC,sCAAc,mBAAmB,eAC/B,yDAAmB,OAAO,IACzB;AAAA,MAAC;AAAA;AAAA,QAEC,KAAK;AAAA,QACL,kBAAkB;AAAA;AAAA,MAFb,QAAQ;AAAA,IAGf,IAEA,4CAAC,kCAA8B,KAAK,oBAAoB,aAAa,WAAnD,QAAQ,GAAoD,GAElF,GACF,GACF;AAAA,EAEJ,CAAC;AACH;AAEA,SAAS,KAAK,EAAE,SAAS,GAAsB;AAC7C,SAAO;AACT;AAEA,SAAS,gBAAgB;AACvB,SAAO,4CAAC,8CAAkB,MAAM,6BAA6B;AAC/D;","names":["Element"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/Element.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ReactNode,\n type Ref,\n type PropsWithChildren,\n forwardRef,\n memo,\n useCallback,\n useImperativeHandle,\n useRef,\n lazy,\n} from 'react'\n\nimport {\n isElementReference,\n type Element as ElementDataOrRef,\n} from '../../../state/read-only-state'\n\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ErrorBoundary } from '../../../components/shared/ErrorBoundary'\n\nimport { useIsReadOnly } from '../hooks/use-is-read-only'\nimport { useIsRegisterElementDisabled } from '../hooks/use-disable-register-element'\n\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { FindDomNode } from '../find-dom-node'\n\nimport { ElementReference } from './ElementReference'\nimport { ElementData } from './ElementData'\n\nconst BuilderElementRegistration = lazy(() => import('./ElementRegistration'))\n\ntype Props = {\n element: ElementDataOrRef\n}\n\nexport const Element = memo(\n forwardRef(function Element(\n { element }: Props,\n ref: Ref<ElementImperativeHandle>,\n ): ReactNode | null {\n const useFindDomNodeRef = useRef(true)\n const imperativeHandleRef = useRef(new ElementImperativeHandle())\n\n const findDomNodeCallbackRef = useCallback((current: (() => Element | Text | null) | null) => {\n if (useFindDomNodeRef.current === true) {\n imperativeHandleRef.current.callback(() => current?.() ?? null)\n }\n }, [])\n\n const elementCallbackRef = useCallback((current: unknown | null) => {\n useFindDomNodeRef.current = false\n\n imperativeHandleRef.current.callback(() => current)\n }, [])\n\n useImperativeHandle(ref, () => imperativeHandleRef.current, [])\n\n const isRegisterElementDisabled = useIsRegisterElementDisabled()\n const ElementRegistration =\n useIsReadOnly() || isRegisterElementDisabled ? NoOp : BuilderElementRegistration\n\n return (\n <ElementRegistration\n componentHandle={imperativeHandleRef.current}\n elementKey={element.key}\n componentType={element.type}\n >\n <FindDomNode ref={findDomNodeCallbackRef}>\n <ErrorBoundary FallbackComponent={ErrorFallback}>\n {isElementReference(element) ? (\n <ElementReference\n key={element.key}\n ref={elementCallbackRef}\n elementReference={element}\n />\n ) : (\n <ElementData key={element.key} ref={elementCallbackRef} elementData={element} />\n )}\n </ErrorBoundary>\n </FindDomNode>\n </ElementRegistration>\n )\n }),\n)\n\nfunction NoOp({ children }: PropsWithChildren) {\n return children\n}\n\nfunction ErrorFallback() {\n return <FallbackComponent text={`Error rendering component`} />\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwEc;AAtEd,mBAUO;AAEP,6BAGO;AAEP,+BAAkC;AAClC,2BAA8B;AAE9B,8BAA8B;AAC9B,0CAA6C;AAE7C,uCAAwC;AACxC,2BAA4B;AAE5B,8BAAiC;AACjC,yBAA4B;AAE5B,MAAM,iCAA6B,mBAAK,MAAM,6CAAO,uBAAuB,GAAC;AAMtE,MAAM,cAAU;AAAA,MACrB,yBAAW,SAASA,SAClB,EAAE,QAAQ,GACV,KACkB;AAClB,UAAM,wBAAoB,qBAAO,IAAI;AACrC,UAAM,0BAAsB,qBAAO,IAAI,yDAAwB,CAAC;AAEhE,UAAM,6BAAyB,0BAAY,CAAC,YAAkD;AAC5F,UAAI,kBAAkB,YAAY,MAAM;AACtC,4BAAoB,QAAQ,SAAS,MAAM,UAAU,KAAK,IAAI;AAAA,MAChE;AAAA,IACF,GAAG,CAAC,CAAC;AAEL,UAAM,yBAAqB,0BAAY,CAAC,YAA4B;AAClE,wBAAkB,UAAU;AAE5B,0BAAoB,QAAQ,SAAS,MAAM,OAAO;AAAA,IACpD,GAAG,CAAC,CAAC;AAEL,0CAAoB,KAAK,MAAM,oBAAoB,SAAS,CAAC,CAAC;AAE9D,UAAM,gCAA4B,kEAA6B;AAC/D,UAAM,0BACJ,uCAAc,KAAK,4BAA4B,OAAO;AAExD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,iBAAiB,oBAAoB;AAAA,QACrC,YAAY,QAAQ;AAAA,QACpB,eAAe,QAAQ;AAAA,QAEvB,sDAAC,oCAAY,KAAK,wBAChB,sDAAC,sCAAc,mBAAmB,eAC/B,yDAAmB,OAAO,IACzB;AAAA,UAAC;AAAA;AAAA,YAEC,KAAK;AAAA,YACL,kBAAkB;AAAA;AAAA,UAFb,QAAQ;AAAA,QAGf,IAEA,4CAAC,kCAA8B,KAAK,oBAAoB,aAAa,WAAnD,QAAQ,GAAoD,GAElF,GACF;AAAA;AAAA,IACF;AAAA,EAEJ,CAAC;AACH;AAEA,SAAS,KAAK,EAAE,SAAS,GAAsB;AAC7C,SAAO;AACT;AAEA,SAAS,gBAAgB;AACvB,SAAO,4CAAC,8CAAkB,MAAM,6BAA6B;AAC/D;","names":["Element"]}
@@ -25,30 +25,49 @@ __export(ElementRegistration_exports, {
25
25
  module.exports = __toCommonJS(ElementRegistration_exports);
26
26
  var import_jsx_runtime = require("react/jsx-runtime");
27
27
  var import_react = require("react");
28
+ var import_read_write_actions = require("../../../state/actions/internal/read-write-actions");
29
+ var import_actions = require("../../../state/builder-api/actions");
28
30
  var import_use_dispatch = require("../hooks/use-dispatch");
29
31
  var import_use_document_context = require("../hooks/use-document-context");
30
- var import_use_disable_register_element = require("../hooks/use-disable-register-element");
31
- var import_actions = require("../../../state/builder-api/actions");
32
- var import_read_write_actions = require("../../../state/actions/internal/read-write-actions");
32
+ var import_control_instances_context = require("./control-instances-context");
33
33
  const ElementRegistration = (0, import_react.memo)(function ElementRegistration2({
34
34
  elementKey,
35
+ componentType,
35
36
  componentHandle,
36
37
  children
37
38
  }) {
38
39
  const dispatch = (0, import_use_dispatch.useDispatch)();
39
40
  const documentKey = (0, import_use_document_context.useDocumentKey)();
40
- const isRegisterElementDisabled = (0, import_use_disable_register_element.useDisableRegisterElement)();
41
+ const controlInstancesContext = (0, import_react.useMemo)(
42
+ () => ({
43
+ elementKey,
44
+ instances: documentKey ? dispatch((0, import_read_write_actions.createPropControllers)({ documentKey, elementKey, componentType })) : null
45
+ }),
46
+ [dispatch, documentKey, elementKey, componentType]
47
+ );
48
+ const controlInstances = controlInstancesContext?.instances;
49
+ (0, import_react.useEffect)(() => {
50
+ if (controlInstances == null)
51
+ return;
52
+ componentHandle.setPropControllers(controlInstances);
53
+ return () => componentHandle.setPropControllers(null);
54
+ }, [controlInstances, componentHandle]);
55
+ (0, import_react.useEffect)(() => {
56
+ if (documentKey == null || controlInstances == null)
57
+ return;
58
+ return dispatch((0, import_read_write_actions.registerPropControllersEffect)(documentKey, elementKey, controlInstances));
59
+ }, [dispatch, documentKey, elementKey, controlInstances]);
41
60
  (0, import_react.useEffect)(() => {
42
- if (documentKey == null || isRegisterElementDisabled)
61
+ if (documentKey == null)
43
62
  return;
44
63
  return dispatch((0, import_read_write_actions.registerComponentHandleEffect)(documentKey, elementKey, componentHandle));
45
- }, [dispatch, documentKey, elementKey, isRegisterElementDisabled]);
64
+ }, [dispatch, documentKey, elementKey, componentHandle]);
46
65
  (0, import_react.useEffect)(() => {
47
- if (documentKey == null || isRegisterElementDisabled)
66
+ if (documentKey == null)
48
67
  return;
49
68
  return dispatch((0, import_actions.mountComponentEffect)(documentKey, elementKey));
50
- }, [dispatch, documentKey, elementKey, isRegisterElementDisabled]);
51
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
69
+ }, [dispatch, documentKey, elementKey]);
70
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_control_instances_context.ControlInstancesProvider, { value: controlInstancesContext, children });
52
71
  });
53
72
  var ElementRegistration_default = ElementRegistration;
54
73
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementRegistration.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, memo, useEffect } from 'react'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { useDispatch } from '../hooks/use-dispatch'\nimport { useDocumentKey } from '../hooks/use-document-context'\nimport { useDisableRegisterElement } from '../hooks/use-disable-register-element'\nimport { mountComponentEffect } from '../../../state/builder-api/actions'\nimport { registerComponentHandleEffect } from '../../../state/actions/internal/read-write-actions'\n\ntype RegisterChildrenAsElementProps = {\n elementKey: string\n componentHandle: ElementImperativeHandle\n children?: ReactNode\n}\n\nexport const ElementRegistration = memo(function ElementRegistration({\n elementKey,\n componentHandle,\n children,\n}: RegisterChildrenAsElementProps): ReactNode {\n const dispatch = useDispatch()\n const documentKey = useDocumentKey()\n\n const isRegisterElementDisabled = useDisableRegisterElement()\n\n useEffect(() => {\n if (documentKey == null || isRegisterElementDisabled) return\n\n return dispatch(registerComponentHandleEffect(documentKey, elementKey, componentHandle))\n }, [dispatch, documentKey, elementKey, isRegisterElementDisabled])\n\n useEffect(() => {\n if (documentKey == null || isRegisterElementDisabled) return\n\n return dispatch(mountComponentEffect(documentKey, elementKey))\n }, [dispatch, documentKey, elementKey, isRegisterElementDisabled])\n\n return <>{children}</>\n})\n\nexport default ElementRegistration\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsCS;AApCT,mBAA2C;AAE3C,0BAA4B;AAC5B,kCAA+B;AAC/B,0CAA0C;AAC1C,qBAAqC;AACrC,gCAA8C;AAQvC,MAAM,0BAAsB,mBAAK,SAASA,qBAAoB;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AACF,GAA8C;AAC5C,QAAM,eAAW,iCAAY;AAC7B,QAAM,kBAAc,4CAAe;AAEnC,QAAM,gCAA4B,+DAA0B;AAE5D,8BAAU,MAAM;AACd,QAAI,eAAe,QAAQ;AAA2B;AAEtD,WAAO,aAAS,yDAA8B,aAAa,YAAY,eAAe,CAAC;AAAA,EACzF,GAAG,CAAC,UAAU,aAAa,YAAY,yBAAyB,CAAC;AAEjE,8BAAU,MAAM;AACd,QAAI,eAAe,QAAQ;AAA2B;AAEtD,WAAO,aAAS,qCAAqB,aAAa,UAAU,CAAC;AAAA,EAC/D,GAAG,CAAC,UAAU,aAAa,YAAY,yBAAyB,CAAC;AAEjE,SAAO,2EAAG,UAAS;AACrB,CAAC;AAED,IAAO,8BAAQ;","names":["ElementRegistration"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementRegistration.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, memo, useMemo, useEffect } from 'react'\n\nimport {\n createPropControllers,\n registerComponentHandleEffect,\n registerPropControllersEffect,\n} from '../../../state/actions/internal/read-write-actions'\nimport { mountComponentEffect } from '../../../state/builder-api/actions'\n\nimport { useDispatch } from '../hooks/use-dispatch'\nimport { useDocumentKey } from '../hooks/use-document-context'\n\nimport { ElementImperativeHandle } from '../element-imperative-handle'\n\nimport { ControlInstancesProvider } from './control-instances-context'\n\nexport const ElementRegistration = memo(function ElementRegistration({\n elementKey,\n componentType,\n componentHandle,\n children,\n}: {\n elementKey: string\n componentHandle: ElementImperativeHandle\n componentType: string\n children?: ReactNode\n}): ReactNode {\n const dispatch = useDispatch()\n const documentKey = useDocumentKey()\n\n // Create control instances on first render and make them available down the React tree\n // through `ControlInstancesProvider`\n const controlInstancesContext = useMemo(\n () => ({\n elementKey,\n instances: documentKey\n ? dispatch(createPropControllers({ documentKey, elementKey, componentType }))\n : null,\n }),\n [dispatch, documentKey, elementKey, componentType],\n )\n\n const controlInstances = controlInstancesContext?.instances\n\n // Set control instances into the corresponding component handle\n useEffect(() => {\n if (controlInstances == null) return\n\n componentHandle.setPropControllers(controlInstances)\n return () => componentHandle.setPropControllers(null)\n }, [controlInstances, componentHandle])\n\n // Register the control instances and component handle in the state\n useEffect(() => {\n if (documentKey == null || controlInstances == null) return\n\n return dispatch(registerPropControllersEffect(documentKey, elementKey, controlInstances))\n }, [dispatch, documentKey, elementKey, controlInstances])\n\n useEffect(() => {\n if (documentKey == null) return\n\n return dispatch(registerComponentHandleEffect(documentKey, elementKey, componentHandle))\n }, [dispatch, documentKey, elementKey, componentHandle])\n\n // Register the element with to the builder\n useEffect(() => {\n if (documentKey == null) return\n\n return dispatch(mountComponentEffect(documentKey, elementKey))\n }, [dispatch, documentKey, elementKey])\n\n return (\n <ControlInstancesProvider value={controlInstancesContext}>{children}</ControlInstancesProvider>\n )\n})\n\nexport default ElementRegistration\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2EI;AAzEJ,mBAAoD;AAEpD,gCAIO;AACP,qBAAqC;AAErC,0BAA4B;AAC5B,kCAA+B;AAI/B,uCAAyC;AAElC,MAAM,0BAAsB,mBAAK,SAASA,qBAAoB;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKc;AACZ,QAAM,eAAW,iCAAY;AAC7B,QAAM,kBAAc,4CAAe;AAInC,QAAM,8BAA0B;AAAA,IAC9B,OAAO;AAAA,MACL;AAAA,MACA,WAAW,cACP,aAAS,iDAAsB,EAAE,aAAa,YAAY,cAAc,CAAC,CAAC,IAC1E;AAAA,IACN;AAAA,IACA,CAAC,UAAU,aAAa,YAAY,aAAa;AAAA,EACnD;AAEA,QAAM,mBAAmB,yBAAyB;AAGlD,8BAAU,MAAM;AACd,QAAI,oBAAoB;AAAM;AAE9B,oBAAgB,mBAAmB,gBAAgB;AACnD,WAAO,MAAM,gBAAgB,mBAAmB,IAAI;AAAA,EACtD,GAAG,CAAC,kBAAkB,eAAe,CAAC;AAGtC,8BAAU,MAAM;AACd,QAAI,eAAe,QAAQ,oBAAoB;AAAM;AAErD,WAAO,aAAS,yDAA8B,aAAa,YAAY,gBAAgB,CAAC;AAAA,EAC1F,GAAG,CAAC,UAAU,aAAa,YAAY,gBAAgB,CAAC;AAExD,8BAAU,MAAM;AACd,QAAI,eAAe;AAAM;AAEzB,WAAO,aAAS,yDAA8B,aAAa,YAAY,eAAe,CAAC;AAAA,EACzF,GAAG,CAAC,UAAU,aAAa,YAAY,eAAe,CAAC;AAGvD,8BAAU,MAAM;AACd,QAAI,eAAe;AAAM;AAEzB,WAAO,aAAS,qCAAqB,aAAa,UAAU,CAAC;AAAA,EAC/D,GAAG,CAAC,UAAU,aAAa,UAAU,CAAC;AAEtC,SACE,4CAAC,6DAAyB,OAAO,yBAA0B,UAAS;AAExE,CAAC;AAED,IAAO,8BAAQ;","names":["ElementRegistration"]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var control_instances_context_exports = {};
21
+ __export(control_instances_context_exports, {
22
+ ControlInstancesProvider: () => ControlInstancesProvider,
23
+ useControlInstances: () => useControlInstances
24
+ });
25
+ module.exports = __toCommonJS(control_instances_context_exports);
26
+ var import_react = require("react");
27
+ const ControlInstancesContext = (0, import_react.createContext)(null);
28
+ const ControlInstancesProvider = ControlInstancesContext.Provider;
29
+ function useControlInstances(elementKey) {
30
+ const cx = (0, import_react.useContext)(ControlInstancesContext);
31
+ return cx && cx.elementKey === elementKey ? cx.instances : null;
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ ControlInstancesProvider,
36
+ useControlInstances
37
+ });
38
+ //# sourceMappingURL=control-instances-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/control-instances-context.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useContext } from 'react'\n\nimport { ControlInstance } from '@makeswift/controls'\n\ntype Context = {\n elementKey: string\n instances: Record<string, ControlInstance> | null\n}\n\nconst ControlInstancesContext = createContext<Context | null>(null)\n\nexport const ControlInstancesProvider = ControlInstancesContext.Provider\n\nexport function useControlInstances(elementKey: string): Context['instances'] | null {\n const cx = useContext(ControlInstancesContext)\n return cx && cx.elementKey === elementKey ? cx.instances : null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0C;AAS1C,MAAM,8BAA0B,4BAA8B,IAAI;AAE3D,MAAM,2BAA2B,wBAAwB;AAEzD,SAAS,oBAAoB,YAAiD;AACnF,QAAM,SAAK,yBAAW,uBAAuB;AAC7C,SAAO,MAAM,GAAG,eAAe,aAAa,GAAG,YAAY;AAC7D;","names":[]}
@@ -18,21 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var use_control_instances_exports = {};
20
20
  __export(use_control_instances_exports, {
21
- useControlInstances: () => useControlInstances
21
+ useControlInstances: () => import_control_instances_context.useControlInstances
22
22
  });
23
23
  module.exports = __toCommonJS(use_control_instances_exports);
24
- var import_read_write_state = require("../../../state/read-write-state");
25
- var import_unified_state = require("../../../state/unified-state");
26
- var import_use_document_context = require("./use-document-context");
27
- var import_use_selector = require("./use-selector");
28
- function useControlInstances(elementKey) {
29
- const documentKey = (0, import_use_document_context.useDocumentKey)();
30
- return (0, import_use_selector.useSelector)((state) => {
31
- if (documentKey == null || !(0, import_unified_state.isReadWriteState)(state))
32
- return null;
33
- return (0, import_read_write_state.getPropControllers)(state, { documentKey, elementKey });
34
- });
35
- }
24
+ var import_control_instances_context = require("../components/control-instances-context");
36
25
  // Annotate the CommonJS export names for ESM import in node:
37
26
  0 && (module.exports = {
38
27
  useControlInstances
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-control-instances.ts"],"sourcesContent":["import { ControlInstance } from '@makeswift/controls'\n\nimport { getPropControllers } from '../../../state/read-write-state'\nimport { isReadWriteState } from '../../../state/unified-state'\nimport { useDocumentKey } from './use-document-context'\nimport { useSelector } from './use-selector'\n\nexport function useControlInstances(elementKey: string): Record<string, ControlInstance> | null {\n const documentKey = useDocumentKey()\n\n return useSelector(state => {\n if (documentKey == null || !isReadWriteState(state)) return null\n\n return getPropControllers(state, { documentKey, elementKey })\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAAmC;AACnC,2BAAiC;AACjC,kCAA+B;AAC/B,0BAA4B;AAErB,SAAS,oBAAoB,YAA4D;AAC9F,QAAM,kBAAc,4CAAe;AAEnC,aAAO,iCAAY,WAAS;AAC1B,QAAI,eAAe,QAAQ,KAAC,uCAAiB,KAAK;AAAG,aAAO;AAE5D,eAAO,4CAAmB,OAAO,EAAE,aAAa,WAAW,CAAC;AAAA,EAC9D,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-control-instances.ts"],"sourcesContent":["export { useControlInstances } from '../components/control-instances-context'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAoC;","names":[]}
@@ -19,17 +19,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var use_disable_register_element_exports = {};
20
20
  __export(use_disable_register_element_exports, {
21
21
  DisableRegisterElement: () => DisableRegisterElement,
22
- useDisableRegisterElement: () => useDisableRegisterElement
22
+ useIsRegisterElementDisabled: () => useIsRegisterElementDisabled
23
23
  });
24
24
  module.exports = __toCommonJS(use_disable_register_element_exports);
25
25
  var import_react = require("react");
26
26
  const DisableRegisterElement = (0, import_react.createContext)(false);
27
- function useDisableRegisterElement() {
27
+ function useIsRegisterElementDisabled() {
28
28
  return (0, import_react.useContext)(DisableRegisterElement);
29
29
  }
30
30
  // Annotate the CommonJS export names for ESM import in node:
31
31
  0 && (module.exports = {
32
32
  DisableRegisterElement,
33
- useDisableRegisterElement
33
+ useIsRegisterElementDisabled
34
34
  });
35
35
  //# sourceMappingURL=use-disable-register-element.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-disable-register-element.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nexport const DisableRegisterElement = createContext(false)\n\nexport function useDisableRegisterElement() {\n return useContext(DisableRegisterElement)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAEnC,MAAM,6BAAyB,4BAAc,KAAK;AAElD,SAAS,4BAA4B;AAC1C,aAAO,yBAAW,sBAAsB;AAC1C;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-disable-register-element.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\n\nexport const DisableRegisterElement = createContext(false)\n\nexport function useIsRegisterElementDisabled() {\n return useContext(DisableRegisterElement)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAEnC,MAAM,6BAAyB,4BAAc,KAAK;AAElD,SAAS,+BAA+B;AAC7C,aAAO,yBAAW,sBAAsB;AAC1C;","names":[]}
@@ -22,6 +22,7 @@ __export(read_write_action_types_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(read_write_action_types_exports);
24
24
  const ReadWriteActionTypes = {
25
+ FLUSH_ACTION_BUFFER: "FLUSH_ACTION_BUFFER",
25
26
  CHANGE_ELEMENT_TREE: "CHANGE_ELEMENT_TREE",
26
27
  REGISTER_COMPONENT_HANDLE: "REGISTER_COMPONENT_HANDLE",
27
28
  UNREGISTER_COMPONENT_HANDLE: "UNREGISTER_COMPONENT_HANDLE",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/state/actions/internal/read-write-action-types.ts"],"sourcesContent":["export const ReadWriteActionTypes = {\n CHANGE_ELEMENT_TREE: 'CHANGE_ELEMENT_TREE',\n\n REGISTER_COMPONENT_HANDLE: 'REGISTER_COMPONENT_HANDLE',\n UNREGISTER_COMPONENT_HANDLE: 'UNREGISTER_COMPONENT_HANDLE',\n\n REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\n REGISTER_PROP_CONTROLLERS_HANDLE: 'REGISTER_PROP_CONTROLLERS_HANDLE',\n UNREGISTER_PROP_CONTROLLERS_HANDLE: 'UNREGISTER_PROP_CONTROLLERS_HANDLE',\n\n REGISTER_MEASURABLE: 'REGISTER_MEASURABLE',\n UNREGISTER_MEASURABLE: 'UNREGISTER_MEASURABLE',\n\n UPDATE_API_CLIENT_CACHE: 'UPDATE_API_CLIENT_CACHE',\n CLEAR_API_CLIENT_CACHE: 'CLEAR_API_CLIENT_CACHE',\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,uBAAuB;AAAA,EAClC,qBAAqB;AAAA,EAErB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAE7B,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,kCAAkC;AAAA,EAClC,oCAAoC;AAAA,EAEpC,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EAEvB,yBAAyB;AAAA,EACzB,wBAAwB;AAC1B;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/state/actions/internal/read-write-action-types.ts"],"sourcesContent":["export const ReadWriteActionTypes = {\n FLUSH_ACTION_BUFFER: 'FLUSH_ACTION_BUFFER',\n\n CHANGE_ELEMENT_TREE: 'CHANGE_ELEMENT_TREE',\n\n REGISTER_COMPONENT_HANDLE: 'REGISTER_COMPONENT_HANDLE',\n UNREGISTER_COMPONENT_HANDLE: 'UNREGISTER_COMPONENT_HANDLE',\n\n REGISTER_PROP_CONTROLLERS: 'REGISTER_PROP_CONTROLLERS',\n UNREGISTER_PROP_CONTROLLERS: 'UNREGISTER_PROP_CONTROLLERS',\n REGISTER_PROP_CONTROLLERS_HANDLE: 'REGISTER_PROP_CONTROLLERS_HANDLE',\n UNREGISTER_PROP_CONTROLLERS_HANDLE: 'UNREGISTER_PROP_CONTROLLERS_HANDLE',\n\n REGISTER_MEASURABLE: 'REGISTER_MEASURABLE',\n UNREGISTER_MEASURABLE: 'UNREGISTER_MEASURABLE',\n\n UPDATE_API_CLIENT_CACHE: 'UPDATE_API_CLIENT_CACHE',\n CLEAR_API_CLIENT_CACHE: 'CLEAR_API_CLIENT_CACHE',\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,uBAAuB;AAAA,EAClC,qBAAqB;AAAA,EAErB,qBAAqB;AAAA,EAErB,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAE7B,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,kCAAkC;AAAA,EAClC,oCAAoC;AAAA,EAEpC,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EAEvB,yBAAyB;AAAA,EACzB,wBAAwB;AAC1B;","names":[]}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,16 +17,27 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var read_write_actions_exports = {};
20
30
  __export(read_write_actions_exports, {
21
31
  changeElementTree: () => changeElementTree,
22
32
  clearAPIClientCache: () => clearAPIClientCache,
33
+ createPropControllers: () => createPropControllers,
34
+ flushActionBuffer: () => flushActionBuffer,
23
35
  registerComponentHandle: () => registerComponentHandle,
24
36
  registerComponentHandleEffect: () => registerComponentHandleEffect,
25
37
  registerMeasurable: () => registerMeasurable,
26
38
  registerMeasurableEffect: () => registerMeasurableEffect,
27
39
  registerPropControllers: () => registerPropControllers,
40
+ registerPropControllersEffect: () => registerPropControllersEffect,
28
41
  registerPropControllersHandle: () => registerPropControllersHandle,
29
42
  unregisterComponentHandle: () => unregisterComponentHandle,
30
43
  unregisterMeasurable: () => unregisterMeasurable,
@@ -33,7 +46,13 @@ __export(read_write_actions_exports, {
33
46
  updateAPIClientCache: () => updateAPIClientCache
34
47
  });
35
48
  module.exports = __toCommonJS(read_write_actions_exports);
49
+ var import_instances = require("../../../prop-controllers/instances");
50
+ var Builder = __toESM(require("../../builder-api/actions"));
51
+ var import_read_only_state = require("../../read-only-state");
36
52
  var import_read_write_action_types = require("./read-write-action-types");
53
+ function flushActionBuffer() {
54
+ return { type: import_read_write_action_types.ReadWriteActionTypes.FLUSH_ACTION_BUFFER };
55
+ }
37
56
  function changeElementTree(payload) {
38
57
  return {
39
58
  type: import_read_write_action_types.ReadWriteActionTypes.CHANGE_ELEMENT_TREE,
@@ -84,6 +103,14 @@ function unregisterPropControllers(documentKey, elementKey) {
84
103
  payload: { documentKey, elementKey }
85
104
  };
86
105
  }
106
+ function registerPropControllersEffect(documentKey, elementKey, propControllers) {
107
+ return (dispatch) => {
108
+ dispatch(registerPropControllers(documentKey, elementKey, propControllers));
109
+ return () => {
110
+ dispatch(unregisterPropControllers(documentKey, elementKey));
111
+ };
112
+ };
113
+ }
87
114
  function registerMeasurable(documentKey, elementKey, measurable) {
88
115
  return {
89
116
  type: import_read_write_action_types.ReadWriteActionTypes.REGISTER_MEASURABLE,
@@ -107,15 +134,43 @@ function updateAPIClientCache(payload) {
107
134
  function clearAPIClientCache() {
108
135
  return { type: import_read_write_action_types.ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE };
109
136
  }
137
+ function createPropControllers({
138
+ documentKey,
139
+ elementKey,
140
+ componentType
141
+ }) {
142
+ return (dispatch, getState) => {
143
+ const descriptors = (0, import_read_only_state.getComponentPropControllerDescriptors)(getState(), componentType);
144
+ if (descriptors == null)
145
+ return null;
146
+ const propControllers = Object.entries(descriptors).reduce(
147
+ (acc, [propName, descriptor]) => {
148
+ const propController = (0, import_instances.createPropController)({
149
+ descriptor,
150
+ instanceKey: { elementKey, propPath: propName },
151
+ sendMessage: (message) => dispatch(
152
+ Builder.messageBuilderPropController(documentKey, elementKey, propName, message)
153
+ )
154
+ });
155
+ return { ...acc, [propName]: propController };
156
+ },
157
+ {}
158
+ );
159
+ return propControllers;
160
+ };
161
+ }
110
162
  // Annotate the CommonJS export names for ESM import in node:
111
163
  0 && (module.exports = {
112
164
  changeElementTree,
113
165
  clearAPIClientCache,
166
+ createPropControllers,
167
+ flushActionBuffer,
114
168
  registerComponentHandle,
115
169
  registerComponentHandleEffect,
116
170
  registerMeasurable,
117
171
  registerMeasurableEffect,
118
172
  registerPropControllers,
173
+ registerPropControllersEffect,
119
174
  registerPropControllersHandle,
120
175
  unregisterComponentHandle,
121
176
  unregisterMeasurable,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/state/actions/internal/read-write-actions.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport { ElementImperativeHandle } from '../../../runtimes/react/element-imperative-handle'\n\nimport { type DescriptorsByComponentType } from '../../modules/prop-controller-descriptors'\nimport { type Measurable } from '../../modules/read-write/box-models'\nimport { type PropControllersHandle } from '../../modules/read-write/prop-controllers'\n\nimport { type DocumentPayload } from '../../shared-api'\nimport { type SerializedState as APIClientCache } from '../../api-client/state'\n\nimport { ReadWriteActionTypes } from './read-write-action-types'\n\ntype ChangeElementTreeAction = {\n type: typeof ReadWriteActionTypes.CHANGE_ELEMENT_TREE\n payload: {\n oldDocument: DocumentPayload\n newDocument: DocumentPayload\n descriptors: DescriptorsByComponentType\n operation: Operation\n }\n}\n\ntype RegisterComponentHandleAction = {\n type: typeof ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string; componentHandle: ElementImperativeHandle }\n}\n\ntype UnregisterComponentHandleAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersHandleAction = {\n type: typeof ReadWriteActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string; handle: PropControllersHandle }\n}\n\ntype UnregisterPropControllersHandleAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersAction = {\n type: typeof ReadWriteActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterMeasurableAction = {\n type: typeof ReadWriteActionTypes.REGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string; measurable: Measurable }\n}\n\ntype UnregisterMeasurableAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UpdateAPIClientCache = {\n type: typeof ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE\n payload: APIClientCache\n}\n\ntype ClearAPIClientCache = {\n type: typeof ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE\n}\n\nexport type ReadWriteAction =\n | ChangeElementTreeAction\n | RegisterComponentHandleAction\n | UnregisterComponentHandleAction\n | RegisterPropControllersHandleAction\n | UnregisterPropControllersHandleAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | RegisterMeasurableAction\n | UnregisterMeasurableAction\n | UpdateAPIClientCache\n | ClearAPIClientCache\n\nexport function changeElementTree(\n payload: ChangeElementTreeAction['payload'],\n): ChangeElementTreeAction {\n return {\n type: ReadWriteActionTypes.CHANGE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function registerComponentHandle(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): RegisterComponentHandleAction {\n return {\n type: ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey, componentHandle },\n }\n}\n\nexport function unregisterComponentHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterComponentHandleAction {\n return {\n type: ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerComponentHandleEffect(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): ThunkAction<() => void, unknown, unknown, ReadWriteAction> {\n return dispatch => {\n dispatch(registerComponentHandle(documentKey, elementKey, componentHandle))\n\n return () => {\n dispatch(unregisterComponentHandle(documentKey, elementKey))\n }\n }\n}\n\nexport function registerPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllersHandle,\n): RegisterPropControllersHandleAction {\n return {\n type: ReadWriteActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey, handle },\n }\n}\n\nexport function unregisterPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersHandleAction {\n return {\n type: ReadWriteActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllers(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): RegisterPropControllersAction {\n return {\n type: ReadWriteActionTypes.REGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey, propControllers },\n }\n}\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return {\n type: ReadWriteActionTypes.UNREGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerMeasurable(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): RegisterMeasurableAction {\n return {\n type: ReadWriteActionTypes.REGISTER_MEASURABLE,\n payload: { documentKey, elementKey, measurable },\n }\n}\n\nexport function unregisterMeasurable(\n documentKey: string,\n elementKey: string,\n): UnregisterMeasurableAction {\n return { type: ReadWriteActionTypes.UNREGISTER_MEASURABLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerMeasurableEffect(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): ThunkAction<() => void, unknown, unknown, ReadWriteAction> {\n return dispatch => {\n dispatch(registerMeasurable(documentKey, elementKey, measurable))\n\n return () => {\n dispatch(unregisterMeasurable(documentKey, elementKey))\n }\n }\n}\n\nexport function updateAPIClientCache(payload: APIClientCache): UpdateAPIClientCache {\n return { type: ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE, payload }\n}\n\nexport function clearAPIClientCache(): ClearAPIClientCache {\n return { type: ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,qCAAqC;AA8E9B,SAAS,kBACd,SACyB;AACzB,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B;AAAA,EACF;AACF;AAEO,SAAS,wBACd,aACA,YACA,iBAC+B;AAC/B,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,gBAAgB;AAAA,EACtD;AACF;AAEO,SAAS,0BACd,aACA,YACiC;AACjC,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEO,SAAS,8BACd,aACA,YACA,iBAC4D;AAC5D,SAAO,cAAY;AACjB,aAAS,wBAAwB,aAAa,YAAY,eAAe,CAAC;AAE1E,WAAO,MAAM;AACX,eAAS,0BAA0B,aAAa,UAAU,CAAC;AAAA,IAC7D;AAAA,EACF;AACF;AAEO,SAAS,8BACd,aACA,YACA,QACqC;AACrC,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,OAAO;AAAA,EAC7C;AACF;AAEO,SAAS,gCACd,aACA,YACuC;AACvC,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEO,SAAS,wBACd,aACA,YACA,iBAC+B;AAC/B,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,gBAAgB;AAAA,EACtD;AACF;AAEO,SAAS,0BACd,aACA,YACiC;AACjC,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEO,SAAS,mBACd,aACA,YACA,YAC0B;AAC1B,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,WAAW;AAAA,EACjD;AACF;AAEO,SAAS,qBACd,aACA,YAC4B;AAC5B,SAAO,EAAE,MAAM,oDAAqB,uBAAuB,SAAS,EAAE,aAAa,WAAW,EAAE;AAClG;AAEO,SAAS,yBACd,aACA,YACA,YAC4D;AAC5D,SAAO,cAAY;AACjB,aAAS,mBAAmB,aAAa,YAAY,UAAU,CAAC;AAEhE,WAAO,MAAM;AACX,eAAS,qBAAqB,aAAa,UAAU,CAAC;AAAA,IACxD;AAAA,EACF;AACF;AAEO,SAAS,qBAAqB,SAA+C;AAClF,SAAO,EAAE,MAAM,oDAAqB,yBAAyB,QAAQ;AACvE;AAEO,SAAS,sBAA2C;AACzD,SAAO,EAAE,MAAM,oDAAqB,uBAAuB;AAC7D;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/state/actions/internal/read-write-actions.ts"],"sourcesContent":["import { type Operation } from 'ot-json0'\nimport { type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport { ElementImperativeHandle } from '../../../runtimes/react/element-imperative-handle'\n\nimport { type DescriptorsByComponentType } from '../../modules/prop-controller-descriptors'\nimport { type Measurable } from '../../modules/read-write/box-models'\nimport { type PropControllersHandle } from '../../modules/read-write/prop-controllers'\n\nimport { createPropController } from '../../../prop-controllers/instances'\n\nimport { type Action } from '../../actions'\nimport * as Builder from '../../builder-api/actions'\n\nimport { type DocumentPayload } from '../../shared-api'\nimport { type SerializedState as APIClientCache } from '../../api-client/state'\nimport { getComponentPropControllerDescriptors } from '../../read-only-state'\nimport { type State } from '../../unified-state'\n\nimport { ReadWriteActionTypes } from './read-write-action-types'\n\ntype FlushActionBufferAction = {\n type: typeof ReadWriteActionTypes.FLUSH_ACTION_BUFFER\n}\n\ntype ChangeElementTreeAction = {\n type: typeof ReadWriteActionTypes.CHANGE_ELEMENT_TREE\n payload: {\n oldDocument: DocumentPayload\n newDocument: DocumentPayload\n descriptors: DescriptorsByComponentType\n operation: Operation\n }\n}\n\ntype RegisterComponentHandleAction = {\n type: typeof ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string; componentHandle: ElementImperativeHandle }\n}\n\ntype UnregisterComponentHandleAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersHandleAction = {\n type: typeof ReadWriteActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string; handle: PropControllersHandle }\n}\n\ntype UnregisterPropControllersHandleAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterPropControllersAction = {\n type: typeof ReadWriteActionTypes.REGISTER_PROP_CONTROLLERS\n payload: {\n documentKey: string\n elementKey: string\n propControllers: Record<string, ControlInstance>\n }\n}\n\ntype UnregisterPropControllersAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_PROP_CONTROLLERS\n payload: { documentKey: string; elementKey: string }\n}\n\ntype RegisterMeasurableAction = {\n type: typeof ReadWriteActionTypes.REGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string; measurable: Measurable }\n}\n\ntype UnregisterMeasurableAction = {\n type: typeof ReadWriteActionTypes.UNREGISTER_MEASURABLE\n payload: { documentKey: string; elementKey: string }\n}\n\ntype UpdateAPIClientCache = {\n type: typeof ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE\n payload: APIClientCache\n}\n\ntype ClearAPIClientCache = {\n type: typeof ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE\n}\n\nexport type ReadWriteAction =\n | FlushActionBufferAction\n | ChangeElementTreeAction\n | RegisterComponentHandleAction\n | UnregisterComponentHandleAction\n | RegisterPropControllersHandleAction\n | UnregisterPropControllersHandleAction\n | RegisterPropControllersAction\n | UnregisterPropControllersAction\n | RegisterMeasurableAction\n | UnregisterMeasurableAction\n | UpdateAPIClientCache\n | ClearAPIClientCache\n\nexport function flushActionBuffer() {\n return { type: ReadWriteActionTypes.FLUSH_ACTION_BUFFER }\n}\n\nexport function changeElementTree(\n payload: ChangeElementTreeAction['payload'],\n): ChangeElementTreeAction {\n return {\n type: ReadWriteActionTypes.CHANGE_ELEMENT_TREE,\n payload,\n }\n}\n\nexport function registerComponentHandle(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): RegisterComponentHandleAction {\n return {\n type: ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey, componentHandle },\n }\n}\n\nexport function unregisterComponentHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterComponentHandleAction {\n return {\n type: ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerComponentHandleEffect(\n documentKey: string,\n elementKey: string,\n componentHandle: ElementImperativeHandle,\n): ThunkAction<() => void, unknown, unknown, ReadWriteAction> {\n return dispatch => {\n dispatch(registerComponentHandle(documentKey, elementKey, componentHandle))\n\n return () => {\n dispatch(unregisterComponentHandle(documentKey, elementKey))\n }\n }\n}\n\nexport function registerPropControllersHandle(\n documentKey: string,\n elementKey: string,\n handle: PropControllersHandle,\n): RegisterPropControllersHandleAction {\n return {\n type: ReadWriteActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey, handle },\n }\n}\n\nexport function unregisterPropControllersHandle(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersHandleAction {\n return {\n type: ReadWriteActionTypes.UNREGISTER_PROP_CONTROLLERS_HANDLE,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllers(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): RegisterPropControllersAction {\n return {\n type: ReadWriteActionTypes.REGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey, propControllers },\n }\n}\n\nexport function unregisterPropControllers(\n documentKey: string,\n elementKey: string,\n): UnregisterPropControllersAction {\n return {\n type: ReadWriteActionTypes.UNREGISTER_PROP_CONTROLLERS,\n payload: { documentKey, elementKey },\n }\n}\n\nexport function registerPropControllersEffect(\n documentKey: string,\n elementKey: string,\n propControllers: Record<string, ControlInstance>,\n): ThunkAction<() => void, unknown, unknown, ReadWriteAction> {\n return dispatch => {\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return () => {\n dispatch(unregisterPropControllers(documentKey, elementKey))\n }\n }\n}\n\nexport function registerMeasurable(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): RegisterMeasurableAction {\n return {\n type: ReadWriteActionTypes.REGISTER_MEASURABLE,\n payload: { documentKey, elementKey, measurable },\n }\n}\n\nexport function unregisterMeasurable(\n documentKey: string,\n elementKey: string,\n): UnregisterMeasurableAction {\n return { type: ReadWriteActionTypes.UNREGISTER_MEASURABLE, payload: { documentKey, elementKey } }\n}\n\nexport function registerMeasurableEffect(\n documentKey: string,\n elementKey: string,\n measurable: Measurable,\n): ThunkAction<() => void, unknown, unknown, ReadWriteAction> {\n return dispatch => {\n dispatch(registerMeasurable(documentKey, elementKey, measurable))\n\n return () => {\n dispatch(unregisterMeasurable(documentKey, elementKey))\n }\n }\n}\n\nexport function updateAPIClientCache(payload: APIClientCache): UpdateAPIClientCache {\n return { type: ReadWriteActionTypes.UPDATE_API_CLIENT_CACHE, payload }\n}\n\nexport function clearAPIClientCache(): ClearAPIClientCache {\n return { type: ReadWriteActionTypes.CLEAR_API_CLIENT_CACHE }\n}\n\nexport function createPropControllers({\n documentKey,\n elementKey,\n componentType,\n}: {\n documentKey: string\n elementKey: string\n componentType: string\n}): ThunkAction<Record<string, ControlInstance> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = getComponentPropControllerDescriptors(getState(), componentType)\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce(\n (acc, [propName, descriptor]) => {\n const propController = createPropController({\n descriptor,\n instanceKey: { elementKey, propPath: propName },\n sendMessage: message =>\n dispatch(\n Builder.messageBuilderPropController(documentKey, elementKey, propName, message),\n ),\n }) as ControlInstance\n\n return { ...acc, [propName]: propController }\n },\n {} as Record<string, ControlInstance>,\n )\n\n return propControllers\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,uBAAqC;AAGrC,cAAyB;AAIzB,6BAAsD;AAGtD,qCAAqC;AAmF9B,SAAS,oBAAoB;AAClC,SAAO,EAAE,MAAM,oDAAqB,oBAAoB;AAC1D;AAEO,SAAS,kBACd,SACyB;AACzB,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B;AAAA,EACF;AACF;AAEO,SAAS,wBACd,aACA,YACA,iBAC+B;AAC/B,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,gBAAgB;AAAA,EACtD;AACF;AAEO,SAAS,0BACd,aACA,YACiC;AACjC,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEO,SAAS,8BACd,aACA,YACA,iBAC4D;AAC5D,SAAO,cAAY;AACjB,aAAS,wBAAwB,aAAa,YAAY,eAAe,CAAC;AAE1E,WAAO,MAAM;AACX,eAAS,0BAA0B,aAAa,UAAU,CAAC;AAAA,IAC7D;AAAA,EACF;AACF;AAEO,SAAS,8BACd,aACA,YACA,QACqC;AACrC,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,OAAO;AAAA,EAC7C;AACF;AAEO,SAAS,gCACd,aACA,YACuC;AACvC,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEO,SAAS,wBACd,aACA,YACA,iBAC+B;AAC/B,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,gBAAgB;AAAA,EACtD;AACF;AAEO,SAAS,0BACd,aACA,YACiC;AACjC,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,WAAW;AAAA,EACrC;AACF;AAEO,SAAS,8BACd,aACA,YACA,iBAC4D;AAC5D,SAAO,cAAY;AACjB,aAAS,wBAAwB,aAAa,YAAY,eAAe,CAAC;AAE1E,WAAO,MAAM;AACX,eAAS,0BAA0B,aAAa,UAAU,CAAC;AAAA,IAC7D;AAAA,EACF;AACF;AAEO,SAAS,mBACd,aACA,YACA,YAC0B;AAC1B,SAAO;AAAA,IACL,MAAM,oDAAqB;AAAA,IAC3B,SAAS,EAAE,aAAa,YAAY,WAAW;AAAA,EACjD;AACF;AAEO,SAAS,qBACd,aACA,YAC4B;AAC5B,SAAO,EAAE,MAAM,oDAAqB,uBAAuB,SAAS,EAAE,aAAa,WAAW,EAAE;AAClG;AAEO,SAAS,yBACd,aACA,YACA,YAC4D;AAC5D,SAAO,cAAY;AACjB,aAAS,mBAAmB,aAAa,YAAY,UAAU,CAAC;AAEhE,WAAO,MAAM;AACX,eAAS,qBAAqB,aAAa,UAAU,CAAC;AAAA,IACxD;AAAA,EACF;AACF;AAEO,SAAS,qBAAqB,SAA+C;AAClF,SAAO,EAAE,MAAM,oDAAqB,yBAAyB,QAAQ;AACvE;AAEO,SAAS,sBAA2C;AACzD,SAAO,EAAE,MAAM,oDAAqB,uBAAuB;AAC7D;AAEO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,GAIgF;AAC9E,SAAO,CAAC,UAAU,aAAa;AAC7B,UAAM,kBAAc,8DAAsC,SAAS,GAAG,aAAa;AACnF,QAAI,eAAe;AAAM,aAAO;AAEhC,UAAM,kBAAkB,OAAO,QAAQ,WAAW,EAAE;AAAA,MAClD,CAAC,KAAK,CAAC,UAAU,UAAU,MAAM;AAC/B,cAAM,qBAAiB,uCAAqB;AAAA,UAC1C;AAAA,UACA,aAAa,EAAE,YAAY,UAAU,SAAS;AAAA,UAC9C,aAAa,aACX;AAAA,YACE,QAAQ,6BAA6B,aAAa,YAAY,UAAU,OAAO;AAAA,UACjF;AAAA,QACJ,CAAC;AAED,eAAO,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,eAAe;AAAA,MAC9C;AAAA,MACA,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -32,40 +32,12 @@ __export(prop_controller_handles_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(prop_controller_handles_exports);
34
34
  var PropControllers = __toESM(require("../../modules/read-write/prop-controllers"));
35
- var Builder = __toESM(require("../../builder-api/actions"));
36
35
  var import_read_write_action_types = require("../../actions/internal/read-write-action-types");
37
36
  var import_toolkit2 = require("../../toolkit");
38
- var import_instances = require("../../../prop-controllers/instances");
39
37
  var import_host_api = require("../../host-api");
40
38
  var ReadOnlyState = __toESM(require("../../read-only-state"));
41
39
  var import_read_write_state = require("../../read-write-state");
42
40
  var import_read_write_actions = require("../../actions/internal/read-write-actions");
43
- function createAndRegisterPropControllers(documentKey, elementKey) {
44
- return (dispatch, getState) => {
45
- const descriptors = ReadOnlyState.getElementPropControllerDescriptors(
46
- getState(),
47
- documentKey,
48
- elementKey
49
- );
50
- if (descriptors == null)
51
- return null;
52
- const propControllers = Object.entries(descriptors).reduce(
53
- (acc, [propName, descriptor]) => {
54
- const propController = (0, import_instances.createPropController)({
55
- descriptor,
56
- instanceKey: { elementKey, propPath: propName },
57
- sendMessage: (message) => dispatch(
58
- Builder.messageBuilderPropController(documentKey, elementKey, propName, message)
59
- )
60
- });
61
- return { ...acc, [propName]: propController };
62
- },
63
- {}
64
- );
65
- dispatch((0, import_read_write_actions.registerPropControllers)(documentKey, elementKey, propControllers));
66
- return propControllers;
67
- };
68
- }
69
41
  function propControllerHandlesMiddleware() {
70
42
  return (0, import_toolkit2.actionMiddleware)(({ dispatch, getState }) => (next) => {
71
43
  return (action) => {
@@ -73,23 +45,13 @@ function propControllerHandlesMiddleware() {
73
45
  case import_read_write_action_types.ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {
74
46
  const { documentKey, elementKey, componentHandle } = action.payload;
75
47
  const element = ReadOnlyState.getElement(getState(), documentKey, elementKey);
76
- const propControllers = dispatch(
77
- createAndRegisterPropControllers(documentKey, elementKey)
78
- );
79
48
  if (element != null && !ReadOnlyState.isElementReference(element) && PropControllers.isPropControllersHandle(componentHandle)) {
80
49
  dispatch((0, import_read_write_actions.registerPropControllersHandle)(documentKey, elementKey, componentHandle));
81
- componentHandle.setPropControllers(propControllers);
82
50
  }
83
51
  break;
84
52
  }
85
53
  case import_read_write_action_types.ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {
86
54
  const { documentKey, elementKey } = action.payload;
87
- const handle = (0, import_read_write_state.getPropControllersHandle)(getState(), {
88
- documentKey,
89
- elementKey
90
- });
91
- handle?.setPropControllers(null);
92
- dispatch((0, import_read_write_actions.unregisterPropControllers)(documentKey, elementKey));
93
55
  dispatch((0, import_read_write_actions.unregisterPropControllersHandle)(documentKey, elementKey));
94
56
  break;
95
57
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/state/middleware/read-write/prop-controller-handles.ts"],"sourcesContent":["import { type Middleware, type ThunkAction } from '@reduxjs/toolkit'\n\nimport { ControlInstance } from '@makeswift/controls'\n\nimport * as PropControllers from '../../modules/read-write/prop-controllers'\n\nimport { type Action } from '../../actions'\n\nimport * as Builder from '../../builder-api/actions'\n\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\n\nimport { actionMiddleware } from '../../toolkit'\n\nimport { createPropController } from '../../../prop-controllers/instances'\nimport { HostActionTypes } from '../../host-api'\n\nimport * as ReadOnlyState from '../../read-only-state'\nimport {\n type State,\n type Dispatch,\n getPropControllersHandle,\n getPropController,\n} from '../../read-write-state'\n\nimport {\n registerPropControllers,\n registerPropControllersHandle,\n unregisterPropControllers,\n unregisterPropControllersHandle,\n} from '../../actions/internal/read-write-actions'\n\nfunction createAndRegisterPropControllers(\n documentKey: string,\n elementKey: string,\n): ThunkAction<Record<string, ControlInstance> | null, State, unknown, Action> {\n return (dispatch, getState) => {\n const descriptors = ReadOnlyState.getElementPropControllerDescriptors(\n getState(),\n documentKey,\n elementKey,\n )\n\n if (descriptors == null) return null\n\n const propControllers = Object.entries(descriptors).reduce(\n (acc, [propName, descriptor]) => {\n const propController = createPropController({\n descriptor,\n instanceKey: { elementKey, propPath: propName },\n sendMessage: message =>\n dispatch(\n Builder.messageBuilderPropController(documentKey, elementKey, propName, message),\n ),\n }) as ControlInstance\n\n return { ...acc, [propName]: propController }\n },\n {} as Record<string, ControlInstance>,\n )\n\n dispatch(registerPropControllers(documentKey, elementKey, propControllers))\n\n return propControllers\n }\n}\n\nexport function propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReadOnlyState.getElement(getState(), documentKey, elementKey)\n const propControllers = dispatch(\n createAndRegisterPropControllers(documentKey, elementKey),\n )\n\n if (\n element != null &&\n !ReadOnlyState.isElementReference(element) &&\n PropControllers.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n componentHandle.setPropControllers(propControllers)\n }\n\n break\n }\n\n case ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n const handle = getPropControllersHandle(getState(), {\n documentKey,\n elementKey,\n })\n\n handle?.setPropControllers(null)\n\n dispatch(unregisterPropControllers(documentKey, elementKey))\n dispatch(unregisterPropControllersHandle(documentKey, elementKey))\n\n break\n }\n\n case HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const { documentKey, elementKey, propName, message } = action.payload\n const propController = getPropController(getState(), {\n documentKey,\n elementKey,\n propName,\n })\n\n if (propController) propController.recv(message)\n }\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAAiC;AAIjC,cAAyB;AAEzB,qCAAqC;AAErC,IAAAA,kBAAiC;AAEjC,uBAAqC;AACrC,sBAAgC;AAEhC,oBAA+B;AAC/B,8BAKO;AAEP,gCAKO;AAEP,SAAS,iCACP,aACA,YAC6E;AAC7E,SAAO,CAAC,UAAU,aAAa;AAC7B,UAAM,cAAc,cAAc;AAAA,MAChC,SAAS;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAEA,QAAI,eAAe;AAAM,aAAO;AAEhC,UAAM,kBAAkB,OAAO,QAAQ,WAAW,EAAE;AAAA,MAClD,CAAC,KAAK,CAAC,UAAU,UAAU,MAAM;AAC/B,cAAM,qBAAiB,uCAAqB;AAAA,UAC1C;AAAA,UACA,aAAa,EAAE,YAAY,UAAU,SAAS;AAAA,UAC9C,aAAa,aACX;AAAA,YACE,QAAQ,6BAA6B,aAAa,YAAY,UAAU,OAAO;AAAA,UACjF;AAAA,QACJ,CAAC;AAED,eAAO,EAAE,GAAG,KAAK,CAAC,QAAQ,GAAG,eAAe;AAAA,MAC9C;AAAA,MACA,CAAC;AAAA,IACH;AAEA,iBAAS,mDAAwB,aAAa,YAAY,eAAe,CAAC;AAE1E,WAAO;AAAA,EACT;AACF;AAEO,SAAS,kCAAyE;AACvF,aAAO,kCAAiB,CAAC,EAAE,UAAU,SAAS,MAAM,UAAQ;AAC1D,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,oDAAqB,2BAA2B;AACnD,gBAAM,EAAE,aAAa,YAAY,gBAAgB,IAAI,OAAO;AAC5D,gBAAM,UAAU,cAAc,WAAW,SAAS,GAAG,aAAa,UAAU;AAC5E,gBAAM,kBAAkB;AAAA,YACtB,iCAAiC,aAAa,UAAU;AAAA,UAC1D;AAEA,cACE,WAAW,QACX,CAAC,cAAc,mBAAmB,OAAO,KACzC,gBAAgB,wBAAwB,eAAe,GACvD;AACA,yBAAS,yDAA8B,aAAa,YAAY,eAAe,CAAC;AAChF,4BAAgB,mBAAmB,eAAe;AAAA,UACpD;AAEA;AAAA,QACF;AAAA,QAEA,KAAK,oDAAqB,6BAA6B;AACrD,gBAAM,EAAE,aAAa,WAAW,IAAI,OAAO;AAC3C,gBAAM,aAAS,kDAAyB,SAAS,GAAG;AAAA,YAClD;AAAA,YACA;AAAA,UACF,CAAC;AAED,kBAAQ,mBAAmB,IAAI;AAE/B,uBAAS,qDAA0B,aAAa,UAAU,CAAC;AAC3D,uBAAS,2DAAgC,aAAa,UAAU,CAAC;AAEjE;AAAA,QACF;AAAA,QAEA,KAAK,gCAAgB,8BAA8B;AACjD,gBAAM,EAAE,aAAa,YAAY,UAAU,QAAQ,IAAI,OAAO;AAC9D,gBAAM,qBAAiB,2CAAkB,SAAS,GAAG;AAAA,YACnD;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAED,cAAI;AAAgB,2BAAe,KAAK,OAAO;AAAA,QACjD;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
1
+ {"version":3,"sources":["../../../../../src/state/middleware/read-write/prop-controller-handles.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport * as PropControllers from '../../modules/read-write/prop-controllers'\n\nimport { type Action } from '../../actions'\n\nimport { ReadWriteActionTypes } from '../../actions/internal/read-write-action-types'\n\nimport { actionMiddleware } from '../../toolkit'\nimport { HostActionTypes } from '../../host-api'\n\nimport * as ReadOnlyState from '../../read-only-state'\n\nimport { type State, type Dispatch, getPropController } from '../../read-write-state'\n\nimport {\n registerPropControllersHandle,\n unregisterPropControllersHandle,\n} from '../../actions/internal/read-write-actions'\n\nexport function propControllerHandlesMiddleware(): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n switch (action.type) {\n case ReadWriteActionTypes.REGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey, componentHandle } = action.payload\n const element = ReadOnlyState.getElement(getState(), documentKey, elementKey)\n\n if (\n element != null &&\n !ReadOnlyState.isElementReference(element) &&\n PropControllers.isPropControllersHandle(componentHandle)\n ) {\n dispatch(registerPropControllersHandle(documentKey, elementKey, componentHandle))\n }\n\n break\n }\n\n case ReadWriteActionTypes.UNREGISTER_COMPONENT_HANDLE: {\n const { documentKey, elementKey } = action.payload\n dispatch(unregisterPropControllersHandle(documentKey, elementKey))\n break\n }\n\n case HostActionTypes.MESSAGE_HOST_PROP_CONTROLLER: {\n const { documentKey, elementKey, propName, message } = action.payload\n const propController = getPropController(getState(), {\n documentKey,\n elementKey,\n propName,\n })\n\n if (propController) propController.recv(message)\n }\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAiC;AAIjC,qCAAqC;AAErC,IAAAA,kBAAiC;AACjC,sBAAgC;AAEhC,oBAA+B;AAE/B,8BAA6D;AAE7D,gCAGO;AAEA,SAAS,kCAAyE;AACvF,aAAO,kCAAiB,CAAC,EAAE,UAAU,SAAS,MAAM,UAAQ;AAC1D,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,oDAAqB,2BAA2B;AACnD,gBAAM,EAAE,aAAa,YAAY,gBAAgB,IAAI,OAAO;AAC5D,gBAAM,UAAU,cAAc,WAAW,SAAS,GAAG,aAAa,UAAU;AAE5E,cACE,WAAW,QACX,CAAC,cAAc,mBAAmB,OAAO,KACzC,gBAAgB,wBAAwB,eAAe,GACvD;AACA,yBAAS,yDAA8B,aAAa,YAAY,eAAe,CAAC;AAAA,UAClF;AAEA;AAAA,QACF;AAAA,QAEA,KAAK,oDAAqB,6BAA6B;AACrD,gBAAM,EAAE,aAAa,WAAW,IAAI,OAAO;AAC3C,uBAAS,2DAAgC,aAAa,UAAU,CAAC;AACjE;AAAA,QACF;AAAA,QAEA,KAAK,gCAAgB,8BAA8B;AACjD,gBAAM,EAAE,aAAa,YAAY,UAAU,QAAQ,IAAI,OAAO;AAC9D,gBAAM,qBAAiB,2CAAkB,SAAS,GAAG;AAAA,YACnD;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAED,cAAI;AAAgB,2BAAe,KAAK,OAAO;AAAA,QACjD;AAAA,MACF;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
@@ -41,6 +41,7 @@ var Breakpoints = __toESM(require("./modules/breakpoints"));
41
41
  var import_read_only_element_tree = require("./middleware/read-only-element-tree");
42
42
  var import_makeswift_api_client_sync = require("./middleware/makeswift-api-client-sync");
43
43
  var import_breakpoint_watch = require("./mixins/breakpoint-watch");
44
+ var import_read_write_actions = require("./actions/internal/read-write-actions");
44
45
  var ReadOnlyState = __toESM(require("./read-only-state"));
45
46
  const configureStore = ({
46
47
  name,
@@ -153,6 +154,7 @@ function configureReadWriteStore({
153
154
  readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy });
154
155
  const dispatch = store.dispatch;
155
156
  const builderProxyCleanup = dispatch(setupBuilderProxy(builderProxy));
157
+ dispatch((0, import_read_write_actions.flushActionBuffer)());
156
158
  readWriteCleanup = () => {
157
159
  readWriteMiddlewareRef.current = null;
158
160
  builderProxyCleanup();