@makeswift/runtime 0.28.0-canary.2 → 0.28.0

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 (111) hide show
  1. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  2. package/dist/cjs/builder/serialization/control-serialization.js +10 -7
  3. package/dist/cjs/builder/serialization/control-serialization.js.map +1 -1
  4. package/dist/cjs/client/index.js +5 -4
  5. package/dist/cjs/client/index.js.map +1 -1
  6. package/dist/cjs/global.d.js.map +1 -1
  7. package/dist/cjs/next/components/tests/controls/style-control/fixtures.js +38 -2
  8. package/dist/cjs/next/components/tests/controls/style-control/fixtures.js.map +1 -1
  9. package/dist/cjs/next/fetch.js +30 -0
  10. package/dist/cjs/next/fetch.js.map +1 -0
  11. package/dist/cjs/next/index.js +5 -2
  12. package/dist/cjs/next/index.js.map +1 -1
  13. package/dist/cjs/next/runtime.js +2 -5
  14. package/dist/cjs/next/runtime.js.map +1 -1
  15. package/dist/cjs/runtimes/react/components/GoogleFontLink.js +1 -2
  16. package/dist/cjs/runtimes/react/components/GoogleFontLink.js.map +1 -1
  17. package/dist/cjs/runtimes/react/components/MakeswiftFonts.js +33 -0
  18. package/dist/cjs/runtimes/react/components/MakeswiftFonts.js.map +1 -0
  19. package/dist/cjs/runtimes/react/controls/style.js +3 -1
  20. package/dist/cjs/runtimes/react/controls/style.js.map +1 -1
  21. package/dist/cjs/state/builder-api/actions.js +2 -2
  22. package/dist/cjs/state/builder-api/actions.js.map +1 -1
  23. package/dist/cjs/state/builder-api/api.js +17 -0
  24. package/dist/cjs/state/builder-api/api.js.map +1 -0
  25. package/dist/cjs/state/builder-api/message-channel.js +35 -31
  26. package/dist/cjs/state/builder-api/message-channel.js.map +1 -1
  27. package/dist/cjs/state/builder-api/navigation-listener.js +90 -0
  28. package/dist/cjs/state/builder-api/navigation-listener.js.map +1 -0
  29. package/dist/cjs/state/builder-api/proxy.js +19 -9
  30. package/dist/cjs/state/builder-api/proxy.js.map +1 -1
  31. package/dist/cjs/state/middleware/read-write/builder-api/index.js +3 -0
  32. package/dist/cjs/state/middleware/read-write/builder-api/index.js.map +1 -1
  33. package/dist/cjs/state/read-write-state.js +1 -1
  34. package/dist/cjs/state/read-write-state.js.map +1 -1
  35. package/dist/cjs/state/store.js +2 -2
  36. package/dist/cjs/state/store.js.map +1 -1
  37. package/dist/cjs/unstable-framework-support/index.js +3 -0
  38. package/dist/cjs/unstable-framework-support/index.js.map +1 -1
  39. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  40. package/dist/esm/builder/serialization/control-serialization.js +12 -8
  41. package/dist/esm/builder/serialization/control-serialization.js.map +1 -1
  42. package/dist/esm/client/index.js +5 -4
  43. package/dist/esm/client/index.js.map +1 -1
  44. package/dist/esm/global.d.js.map +1 -1
  45. package/dist/esm/next/components/tests/controls/style-control/fixtures.js +35 -1
  46. package/dist/esm/next/components/tests/controls/style-control/fixtures.js.map +1 -1
  47. package/dist/esm/next/fetch.js +6 -0
  48. package/dist/esm/next/fetch.js.map +1 -0
  49. package/dist/esm/next/index.js +3 -1
  50. package/dist/esm/next/index.js.map +1 -1
  51. package/dist/esm/next/runtime.js +2 -5
  52. package/dist/esm/next/runtime.js.map +1 -1
  53. package/dist/esm/runtimes/react/components/GoogleFontLink.js +1 -2
  54. package/dist/esm/runtimes/react/components/GoogleFontLink.js.map +1 -1
  55. package/dist/esm/runtimes/react/components/MakeswiftFonts.js +9 -0
  56. package/dist/esm/runtimes/react/components/MakeswiftFonts.js.map +1 -0
  57. package/dist/esm/runtimes/react/controls/style.js +3 -1
  58. package/dist/esm/runtimes/react/controls/style.js.map +1 -1
  59. package/dist/esm/state/builder-api/actions.js +2 -2
  60. package/dist/esm/state/builder-api/actions.js.map +1 -1
  61. package/dist/esm/state/builder-api/api.js +1 -0
  62. package/dist/esm/state/builder-api/api.js.map +1 -0
  63. package/dist/esm/state/builder-api/message-channel.js +35 -31
  64. package/dist/esm/state/builder-api/message-channel.js.map +1 -1
  65. package/dist/esm/state/builder-api/navigation-listener.js +66 -0
  66. package/dist/esm/state/builder-api/navigation-listener.js.map +1 -0
  67. package/dist/esm/state/builder-api/proxy.js +20 -10
  68. package/dist/esm/state/builder-api/proxy.js.map +1 -1
  69. package/dist/esm/state/middleware/read-write/builder-api/index.js +3 -0
  70. package/dist/esm/state/middleware/read-write/builder-api/index.js.map +1 -1
  71. package/dist/esm/state/read-write-state.js +1 -1
  72. package/dist/esm/state/read-write-state.js.map +1 -1
  73. package/dist/esm/state/store.js +2 -2
  74. package/dist/esm/state/store.js.map +1 -1
  75. package/dist/esm/unstable-framework-support/index.js +2 -0
  76. package/dist/esm/unstable-framework-support/index.js.map +1 -1
  77. package/dist/types/builder/serialization/control-serialization.d.ts +10 -6
  78. package/dist/types/builder/serialization/control-serialization.d.ts.map +1 -1
  79. package/dist/types/client/index.d.ts +3 -0
  80. package/dist/types/client/index.d.ts.map +1 -1
  81. package/dist/types/next/components/tests/controls/style-control/fixtures.d.ts +2 -0
  82. package/dist/types/next/components/tests/controls/style-control/fixtures.d.ts.map +1 -1
  83. package/dist/types/next/fetch.d.ts +3 -0
  84. package/dist/types/next/fetch.d.ts.map +1 -0
  85. package/dist/types/next/index.d.ts +1 -0
  86. package/dist/types/next/index.d.ts.map +1 -1
  87. package/dist/types/next/runtime.d.ts.map +1 -1
  88. package/dist/types/runtimes/react/components/GoogleFontLink.d.ts.map +1 -1
  89. package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts +7 -0
  90. package/dist/types/runtimes/react/components/MakeswiftFonts.d.ts.map +1 -0
  91. package/dist/types/runtimes/react/controls/style.d.ts.map +1 -1
  92. package/dist/types/state/__tests__/fixtures/serialized-descriptors-from-builder.d.ts +5 -0
  93. package/dist/types/state/__tests__/fixtures/serialized-descriptors-from-builder.d.ts.map +1 -0
  94. package/dist/types/state/builder-api/actions.d.ts +3 -7
  95. package/dist/types/state/builder-api/actions.d.ts.map +1 -1
  96. package/dist/types/state/builder-api/api.d.ts +8 -0
  97. package/dist/types/state/builder-api/api.d.ts.map +1 -0
  98. package/dist/types/state/builder-api/message-channel.d.ts +3 -6
  99. package/dist/types/state/builder-api/message-channel.d.ts.map +1 -1
  100. package/dist/types/state/builder-api/navigation-listener.d.ts +6 -0
  101. package/dist/types/state/builder-api/navigation-listener.d.ts.map +1 -0
  102. package/dist/types/state/builder-api/proxy.d.ts +4 -3
  103. package/dist/types/state/builder-api/proxy.d.ts.map +1 -1
  104. package/dist/types/state/middleware/read-write/builder-api/index.d.ts.map +1 -1
  105. package/dist/types/state/read-write-state.d.ts +1 -1
  106. package/dist/types/state/read-write-state.d.ts.map +1 -1
  107. package/dist/types/unstable-framework-support/index.d.ts +1 -0
  108. package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
  109. package/package.json +1 -1
  110. package/dist/types/state/__tests__/fixtures/serialized-descriptors-from-db.d.ts +0 -7
  111. package/dist/types/state/__tests__/fixtures/serialized-descriptors-from-db.d.ts.map +0 -1
@@ -24,21 +24,34 @@ module.exports = __toCommonJS(proxy_exports);
24
24
  var import_host_api = require("../host-api");
25
25
  var import_actions = require("./actions");
26
26
  var import_message_channel = require("./message-channel");
27
+ var import_navigation_listener = require("./navigation-listener");
27
28
  class BuilderAPIProxy {
28
29
  messageChannel;
29
30
  constructor({ appOrigin }) {
30
31
  this.messageChannel = new import_message_channel.MessageChannel({ appOrigin });
31
32
  }
33
+ handleHostNavigate(event) {
34
+ this.execute({ type: import_actions.BuilderActionTypes.HANDLE_HOST_NAVIGATE, payload: event });
35
+ }
32
36
  // low-level, action-based API
33
37
  setup({ onHostAction }) {
34
- this.messageChannel.setup((event) => {
35
- const action = event.data;
36
- if (!(0, import_host_api.isHostAction)(action)) {
37
- console.warn("Unexpected host action", action);
38
- return;
38
+ const channelCleanup = this.messageChannel.setup({
39
+ onMessage: (event) => {
40
+ const action = event.data;
41
+ if (!(0, import_host_api.isHostAction)(action)) {
42
+ console.warn("Unexpected host action", action);
43
+ return;
44
+ }
45
+ onHostAction(action);
39
46
  }
40
- onHostAction(action);
41
47
  });
48
+ const navigationListenerCleanup = (0, import_navigation_listener.setupNavigationListener)(
49
+ (event) => this.handleHostNavigate(event)
50
+ );
51
+ return () => {
52
+ channelCleanup();
53
+ navigationListenerCleanup();
54
+ };
42
55
  }
43
56
  execute(action) {
44
57
  if ((0, import_actions.hasTransferables)(action)) {
@@ -51,9 +64,6 @@ class BuilderAPIProxy {
51
64
  dispatchBuffered() {
52
65
  this.messageChannel.dispatchBuffered();
53
66
  }
54
- teardown() {
55
- this.messageChannel.teardown();
56
- }
57
67
  }
58
68
  // Annotate the CommonJS export names for ESM import in node:
59
69
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/state/builder-api/proxy.ts"],"sourcesContent":["import { type HostAction, isHostAction } from '../host-api'\n\nimport { type BuilderAction, hasTransferables } from './actions'\nimport { MessageChannel } from './message-channel'\n\nexport class BuilderAPIProxy {\n private messageChannel: MessageChannel\n\n constructor({ appOrigin }: { appOrigin: string }) {\n this.messageChannel = new MessageChannel({ appOrigin })\n }\n\n // low-level, action-based API\n\n setup({ onHostAction }: { onHostAction: (action: HostAction) => void }): void {\n this.messageChannel.setup((event: MessageEvent) => {\n const action = event.data\n\n if (!isHostAction(action)) {\n console.warn('Unexpected host action', action)\n return\n }\n\n onHostAction(action)\n })\n }\n\n execute(action: BuilderAction): void {\n if (hasTransferables(action)) {\n const { transferables, ...forwardedAction } = action\n this.messageChannel.postMessage(forwardedAction, transferables)\n return\n }\n\n this.messageChannel.postMessage(action)\n }\n\n dispatchBuffered(): void {\n this.messageChannel.dispatchBuffered()\n }\n\n teardown(): void {\n this.messageChannel.teardown()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8C;AAE9C,qBAAqD;AACrD,6BAA+B;AAExB,MAAM,gBAAgB;AAAA,EACnB;AAAA,EAER,YAAY,EAAE,UAAU,GAA0B;AAChD,SAAK,iBAAiB,IAAI,sCAAe,EAAE,UAAU,CAAC;AAAA,EACxD;AAAA;AAAA,EAIA,MAAM,EAAE,aAAa,GAAyD;AAC5E,SAAK,eAAe,MAAM,CAAC,UAAwB;AACjD,YAAM,SAAS,MAAM;AAErB,UAAI,KAAC,8BAAa,MAAM,GAAG;AACzB,gBAAQ,KAAK,0BAA0B,MAAM;AAC7C;AAAA,MACF;AAEA,mBAAa,MAAM;AAAA,IACrB,CAAC;AAAA,EACH;AAAA,EAEA,QAAQ,QAA6B;AACnC,YAAI,iCAAiB,MAAM,GAAG;AAC5B,YAAM,EAAE,eAAe,GAAG,gBAAgB,IAAI;AAC9C,WAAK,eAAe,YAAY,iBAAiB,aAAa;AAC9D;AAAA,IACF;AAEA,SAAK,eAAe,YAAY,MAAM;AAAA,EACxC;AAAA,EAEA,mBAAyB;AACvB,SAAK,eAAe,iBAAiB;AAAA,EACvC;AAAA,EAEA,WAAiB;AACf,SAAK,eAAe,SAAS;AAAA,EAC/B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/state/builder-api/proxy.ts"],"sourcesContent":["import { type HostAction, isHostAction } from '../host-api'\n\nimport { type BuilderAction, BuilderActionTypes, hasTransferables } from './actions'\nimport { MessageChannel } from './message-channel'\nimport { setupNavigationListener } from './navigation-listener'\nimport { type BuilderApi, type HostNavigationEvent } from './api'\n\nexport class BuilderAPIProxy implements BuilderApi {\n private messageChannel: MessageChannel\n\n constructor({ appOrigin }: { appOrigin: string }) {\n this.messageChannel = new MessageChannel({ appOrigin })\n }\n\n handleHostNavigate(event: HostNavigationEvent) {\n this.execute({ type: BuilderActionTypes.HANDLE_HOST_NAVIGATE, payload: event })\n }\n\n // low-level, action-based API\n\n setup({ onHostAction }: { onHostAction: (action: HostAction) => void }): VoidFunction {\n const channelCleanup = this.messageChannel.setup({\n onMessage: (event: MessageEvent) => {\n const action = event.data\n\n if (!isHostAction(action)) {\n console.warn('Unexpected host action', action)\n return\n }\n\n onHostAction(action)\n },\n })\n\n const navigationListenerCleanup = setupNavigationListener(event =>\n this.handleHostNavigate(event),\n )\n\n return () => {\n channelCleanup()\n navigationListenerCleanup()\n }\n }\n\n execute(action: BuilderAction): void {\n if (hasTransferables(action)) {\n const { transferables, ...forwardedAction } = action\n this.messageChannel.postMessage(forwardedAction, transferables)\n return\n }\n\n this.messageChannel.postMessage(action)\n }\n\n dispatchBuffered(): void {\n this.messageChannel.dispatchBuffered()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8C;AAE9C,qBAAyE;AACzE,6BAA+B;AAC/B,iCAAwC;AAGjC,MAAM,gBAAsC;AAAA,EACzC;AAAA,EAER,YAAY,EAAE,UAAU,GAA0B;AAChD,SAAK,iBAAiB,IAAI,sCAAe,EAAE,UAAU,CAAC;AAAA,EACxD;AAAA,EAEA,mBAAmB,OAA4B;AAC7C,SAAK,QAAQ,EAAE,MAAM,kCAAmB,sBAAsB,SAAS,MAAM,CAAC;AAAA,EAChF;AAAA;AAAA,EAIA,MAAM,EAAE,aAAa,GAAiE;AACpF,UAAM,iBAAiB,KAAK,eAAe,MAAM;AAAA,MAC/C,WAAW,CAAC,UAAwB;AAClC,cAAM,SAAS,MAAM;AAErB,YAAI,KAAC,8BAAa,MAAM,GAAG;AACzB,kBAAQ,KAAK,0BAA0B,MAAM;AAC7C;AAAA,QACF;AAEA,qBAAa,MAAM;AAAA,MACrB;AAAA,IACF,CAAC;AAED,UAAM,gCAA4B;AAAA,MAAwB,WACxD,KAAK,mBAAmB,KAAK;AAAA,IAC/B;AAEA,WAAO,MAAM;AACX,qBAAe;AACf,gCAA0B;AAAA,IAC5B;AAAA,EACF;AAAA,EAEA,QAAQ,QAA6B;AACnC,YAAI,iCAAiB,MAAM,GAAG;AAC5B,YAAM,EAAE,eAAe,GAAG,gBAAgB,IAAI;AAC9C,WAAK,eAAe,YAAY,iBAAiB,aAAa;AAC9D;AAAA,IACF;AAEA,SAAK,eAAe,YAAY,MAAM;AAAA,EACxC;AAAA,EAEA,mBAAyB;AACvB,SAAK,eAAe,iBAAiB;AAAA,EACvC;AACF;","names":[]}
@@ -59,10 +59,13 @@ function builderAPIMiddleware(builderProxy) {
59
59
  window.getSelection()?.removeAllRanges();
60
60
  break;
61
61
  case import_host_api.HostActionTypes.INIT:
62
+ cleanUp();
62
63
  cleanUp = dispatch((0, import_initialize_connection.initializeBuilderConnection)(builderProxy));
63
64
  break;
64
65
  case import_host_api.HostActionTypes.CLEAN_UP:
65
66
  cleanUp();
67
+ cleanUp = () => {
68
+ };
66
69
  break;
67
70
  }
68
71
  return next(action);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/state/middleware/read-write/builder-api/index.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { type Action } from '../../../actions'\n\nimport { BuilderActionTypes } from '../../../builder-api/actions'\n\nimport { actionMiddleware } from '../../../toolkit'\n\nimport { type BuilderAPIProxy } from '../../../builder-api/proxy'\nimport { HostActionTypes } from '../../../host-api'\n\nimport { type State, type Dispatch } from '../../../read-write-state'\nimport { initializeBuilderConnection } from './initialize-connection'\n\nexport function builderAPIMiddleware(\n builderProxy: BuilderAPIProxy,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n if (typeof window === 'undefined') return (action: Action) => next(action)\n\n let cleanUp = () => {}\n return (action: Action) => {\n switch (action.type) {\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case BuilderActionTypes.MOUNT_COMPONENT:\n case BuilderActionTypes.UNMOUNT_COMPONENT:\n case BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case BuilderActionTypes.HANDLE_WHEEL:\n case BuilderActionTypes.HANDLE_POINTER_MOVE:\n case BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:\n case BuilderActionTypes.SET_LOCALE:\n case BuilderActionTypes.SET_BREAKPOINTS:\n case BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.REGISTER_BUILDER_COMPONENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:\n builderProxy.execute(action)\n break\n\n case HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case HostActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case HostActionTypes.SET_BUILDER_EDIT_MODE:\n window.getSelection()?.removeAllRanges()\n break\n\n case HostActionTypes.INIT:\n // dispatched by the parent window after establishing the connection\n cleanUp = dispatch(initializeBuilderConnection(builderProxy))\n break\n\n case HostActionTypes.CLEAN_UP:\n // dispatched by the parent window on disconnect\n cleanUp()\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAAA,kBAAmC;AAEnC,IAAAC,kBAAiC;AAGjC,sBAAgC;AAGhC,mCAA4C;AAErC,SAAS,qBACd,cACuC;AACvC,aAAO,kCAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,QAAI,OAAO,WAAW;AAAa,aAAO,CAAC,WAAmB,KAAK,MAAM;AAEzE,QAAI,UAAU,MAAM;AAAA,IAAC;AACrB,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AACtB,uBAAa,QAAQ,MAAM;AAC3B;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,YAAY,OAAO,QAAQ;AAC3D;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,aAAa,OAAO,QAAQ;AAC5D;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,aAAa,GAAG,gBAAgB;AACvC;AAAA,QAEF,KAAK,gCAAgB;AAEnB,oBAAU,aAAS,0DAA4B,YAAY,CAAC;AAC5D;AAAA,QAEF,KAAK,gCAAgB;AAEnB,kBAAQ;AACR;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_actions","import_toolkit"]}
1
+ {"version":3,"sources":["../../../../../../src/state/middleware/read-write/builder-api/index.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { type Action } from '../../../actions'\n\nimport { BuilderActionTypes } from '../../../builder-api/actions'\n\nimport { actionMiddleware } from '../../../toolkit'\n\nimport { type BuilderAPIProxy } from '../../../builder-api/proxy'\nimport { HostActionTypes } from '../../../host-api'\n\nimport { type State, type Dispatch } from '../../../read-write-state'\nimport { initializeBuilderConnection } from './initialize-connection'\n\nexport function builderAPIMiddleware(\n builderProxy: BuilderAPIProxy,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(({ dispatch }) => next => {\n if (typeof window === 'undefined') return (action: Action) => next(action)\n\n let cleanUp = () => {}\n return (action: Action) => {\n switch (action.type) {\n case BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS:\n case BuilderActionTypes.MOUNT_COMPONENT:\n case BuilderActionTypes.UNMOUNT_COMPONENT:\n case BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE:\n case BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER:\n case BuilderActionTypes.HANDLE_WHEEL:\n case BuilderActionTypes.HANDLE_POINTER_MOVE:\n case BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE:\n case BuilderActionTypes.SET_LOCALE:\n case BuilderActionTypes.SET_BREAKPOINTS:\n case BuilderActionTypes.REGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT:\n case BuilderActionTypes.REGISTER_BUILDER_COMPONENT:\n case BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT:\n builderProxy.execute(action)\n break\n\n case HostActionTypes.CHANGE_DOCUMENT_ELEMENT_SCROLL_TOP:\n window.document.documentElement.scrollTop = action.payload.scrollTop\n break\n\n case HostActionTypes.SCROLL_DOCUMENT_ELEMENT:\n window.document.documentElement.scrollTop += action.payload.scrollTopDelta\n break\n\n case HostActionTypes.SET_BUILDER_EDIT_MODE:\n window.getSelection()?.removeAllRanges()\n break\n\n case HostActionTypes.INIT:\n // dispatched by the parent window after establishing the connection\n // and in response to host's client-side navigation\n cleanUp() // cleanup existing connection setup, if any\n cleanUp = dispatch(initializeBuilderConnection(builderProxy))\n break\n\n case HostActionTypes.CLEAN_UP:\n // dispatched by the parent window on disconnect\n cleanUp()\n cleanUp = () => {}\n break\n }\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAAA,kBAAmC;AAEnC,IAAAC,kBAAiC;AAGjC,sBAAgC;AAGhC,mCAA4C;AAErC,SAAS,qBACd,cACuC;AACvC,aAAO,kCAAiB,CAAC,EAAE,SAAS,MAAM,UAAQ;AAChD,QAAI,OAAO,WAAW;AAAa,aAAO,CAAC,WAAmB,KAAK,MAAM;AAEzE,QAAI,UAAU,MAAM;AAAA,IAAC;AACrB,WAAO,CAAC,WAAmB;AACzB,cAAQ,OAAO,MAAM;AAAA,QACnB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AAAA,QACxB,KAAK,mCAAmB;AACtB,uBAAa,QAAQ,MAAM;AAC3B;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,YAAY,OAAO,QAAQ;AAC3D;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,SAAS,gBAAgB,aAAa,OAAO,QAAQ;AAC5D;AAAA,QAEF,KAAK,gCAAgB;AACnB,iBAAO,aAAa,GAAG,gBAAgB;AACvC;AAAA,QAEF,KAAK,gCAAgB;AAGnB,kBAAQ;AACR,oBAAU,aAAS,0DAA4B,YAAY,CAAC;AAC5D;AAAA,QAEF,KAAK,gCAAgB;AAEnB,kBAAQ;AACR,oBAAU,MAAM;AAAA,UAAC;AACjB;AAAA,MACJ;AAEA,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_actions","import_toolkit"]}
@@ -106,7 +106,7 @@ function getElementImperativeHandlesContainingElement(state, element) {
106
106
  }
107
107
  function setupBuilderProxy(builderProxy) {
108
108
  return (dispatch) => {
109
- builderProxy.setup({ onHostAction: (action) => dispatch(action) });
109
+ return builderProxy.setup({ onHostAction: (action) => dispatch(action) });
110
110
  };
111
111
  }
112
112
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state/read-write-state.ts"],"sourcesContent":["import { combineReducers, type ThunkAction, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as Documents from './modules/read-write/read-write-documents'\nimport * as BoxModels from './modules/read-write/box-models'\nimport * as Pointer from './modules/read-write/pointer'\nimport * as ElementImperativeHandles from './modules/read-write/element-imperative-handles'\n\nimport { type Action } from './actions'\n\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nimport { BuilderAPIProxy } from './builder-api/proxy'\nimport * as ReadOnlyState from './read-only-state'\n\nexport type { Operation } from './modules/read-write/read-write-documents'\nexport type { BoxModelHandle } from './modules/read-write/box-models'\nexport { createBox, getBox, parse } from './modules/read-write/box-models'\n\nconst reducers = {\n ...ReadOnlyState.reducers,\n documents: Documents.reducer,\n boxModels: BoxModels.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n}\n\nexport function createRootReducer() {\n return combineReducers(reducers)\n}\n\nexport type State = Omit<ReadOnlyState.State, 'documents'> & {\n documents: Documents.State\n boxModels: BoxModels.State\n pointer: Pointer.State\n elementImperativeHandles: ElementImperativeHandles.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocuments(state: State): Documents.State {\n return Documents.getDocuments(getDocumentsStateSlice(state))\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nexport function getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nexport function getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n\nexport function setupBuilderProxy(\n builderProxy: BuilderAPIProxy,\n): ThunkAction<void, State, unknown, Action> {\n return dispatch => {\n builderProxy.setup({ onHostAction: action => dispatch(action) })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsE;AAEtE,gBAA2B;AAC3B,gBAA2B;AAC3B,cAAyB;AACzB,+BAA0C;AAO1C,oBAA+B;AAI/B,wBAAyC;AAEzC,MAAM,WAAW;AAAA,EACf,GAAG,cAAc;AAAA,EACjB,WAAW,UAAU;AAAA,EACrB,WAAW,UAAU;AAAA,EACrB,SAAS,QAAQ;AAAA,EACjB,0BAA0B,yBAAyB;AACrD;AAEO,SAAS,oBAAoB;AAClC,aAAO,gCAAgB,QAAQ;AACjC;AAWA,SAAS,uBAAuB,OAA+B;AAC7D,SAAO,MAAM;AACf;AAEO,SAAS,aAAa,OA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esContent":["import { combineReducers, type ThunkAction, type ThunkDispatch } from '@reduxjs/toolkit'\n\nimport * as Documents from './modules/read-write/read-write-documents'\nimport * as BoxModels from './modules/read-write/box-models'\nimport * as Pointer from './modules/read-write/pointer'\nimport * as ElementImperativeHandles from './modules/read-write/element-imperative-handles'\n\nimport { type Action } from './actions'\n\nimport { ElementImperativeHandle } from '../runtimes/react/element-imperative-handle'\n\nimport { BuilderAPIProxy } from './builder-api/proxy'\nimport * as ReadOnlyState from './read-only-state'\n\nexport type { Operation } from './modules/read-write/read-write-documents'\nexport type { BoxModelHandle } from './modules/read-write/box-models'\nexport { createBox, getBox, parse } from './modules/read-write/box-models'\n\nconst reducers = {\n ...ReadOnlyState.reducers,\n documents: Documents.reducer,\n boxModels: BoxModels.reducer,\n pointer: Pointer.reducer,\n elementImperativeHandles: ElementImperativeHandles.reducer,\n}\n\nexport function createRootReducer() {\n return combineReducers(reducers)\n}\n\nexport type State = Omit<ReadOnlyState.State, 'documents'> & {\n documents: Documents.State\n boxModels: BoxModels.State\n pointer: Pointer.State\n elementImperativeHandles: ElementImperativeHandles.State\n}\n\nexport type Dispatch = ThunkDispatch<State, unknown, Action>\n\nfunction getDocumentsStateSlice(state: State): Documents.State {\n return state.documents\n}\n\nexport function getDocuments(state: State): Documents.State {\n return Documents.getDocuments(getDocumentsStateSlice(state))\n}\n\nexport function getDocument(state: State, documentKey: string): Documents.Document | null {\n return Documents.getDocument(getDocumentsStateSlice(state), documentKey)\n}\n\nfunction getBoxModelsStateSlice(state: State): BoxModels.State {\n return state.boxModels\n}\n\nexport function getMeasurables(state: State): Map<string, Map<string, BoxModels.Measurable>> {\n return BoxModels.getMeasurables(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModels(state: State): Map<string, Map<string, BoxModels.BoxModel>> {\n return BoxModels.getBoxModels(getBoxModelsStateSlice(state))\n}\n\nexport function getBoxModel(\n state: State,\n documentKey: string,\n elementKey: string,\n): BoxModels.BoxModel | null {\n return BoxModels.getBoxModel(getBoxModelsStateSlice(state), documentKey, elementKey)\n}\n\nexport function getPointer(state: State): Pointer.Point | null {\n return Pointer.getPointer(state.pointer)\n}\n\nexport function getElementImperativeHandles(\n state: State,\n): Map<string, Map<string, ElementImperativeHandle>> {\n return ElementImperativeHandles.getElementImperativeHandles(state.elementImperativeHandles)\n}\n\nexport function getElementImperativeHandlesContainingElement(\n state: State,\n element: Element,\n): Map<string, Map<string, ElementImperativeHandle>> {\n const elementImperativeHandles = getElementImperativeHandles(state)\n const filteredElementImperativeHandles = new Map<string, Map<string, ElementImperativeHandle>>()\n\n for (const [documentKey, byElementKey] of elementImperativeHandles) {\n const filteredByElementKey = new Map<string, ElementImperativeHandle>()\n\n for (const [elementKey, elementImperativeHandle] of byElementKey) {\n const handleElement = elementImperativeHandle.getDomNode()\n\n if (handleElement?.contains(element)) {\n filteredByElementKey.set(elementKey, elementImperativeHandle)\n }\n }\n\n if (filteredByElementKey.size > 0) {\n filteredElementImperativeHandles.set(documentKey, filteredByElementKey)\n }\n }\n\n return filteredElementImperativeHandles\n}\n\nexport function setupBuilderProxy(\n builderProxy: BuilderAPIProxy,\n): ThunkAction<VoidFunction, State, unknown, Action> {\n return dispatch => {\n return builderProxy.setup({ onHostAction: action => dispatch(action) })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAsE;AAEtE,gBAA2B;AAC3B,gBAA2B;AAC3B,cAAyB;AACzB,+BAA0C;AAO1C,oBAA+B;AAI/B,wBAAyC;AAEzC,MAAM,WAAW;AAAA,EACf,GAAG,cAAc;AAAA,EACjB,WAAW,UAAU;AAAA,EACrB,WAAW,UAAU;AAAA,EACrB,SAAS,QAAQ;AAAA,EACjB,0BAA0B,yBAAyB;AACrD;AAEO,SAAS,oBAAoB;AAClC,aAAO,gCAAgB,QAAQ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M,EAAE,CAAC;AAAA,EACxE;AACF;","names":[]}
@@ -114,10 +114,10 @@ function configureStore({
114
114
  const builderProxy = new BuilderAPIProxy({ appOrigin });
115
115
  readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy });
116
116
  const dispatch = store.dispatch;
117
- dispatch(setupBuilderProxy(builderProxy));
117
+ const builderProxyCleanup = dispatch(setupBuilderProxy(builderProxy));
118
118
  readWriteCleanup = () => {
119
119
  readWriteMiddlewareRef.current = null;
120
- builderProxy.teardown();
120
+ builderProxyCleanup();
121
121
  };
122
122
  })();
123
123
  try {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state/store.ts"],"sourcesContent":["import {\n type Middleware,\n type StoreEnhancer,\n type MiddlewareAPI,\n configureStore as configureReduxStore,\n combineReducers,\n compose,\n} from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../api/client'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\nimport { BuilderActionTypes } from './builder-api/actions'\nimport { HostActionTypes } from './host-api'\n\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { readOnlyElementTreeMiddleware } from './middleware/read-only-element-tree'\n\nimport { type Action } from './actions'\nimport { type State as ReadWriteState } from './read-write-state'\nimport * as ReadOnlyState from './read-only-state'\n\nimport {\n type State,\n type Dispatch,\n type ReadOnlyReducer,\n type ReadWriteDispatch,\n} from './unified-state'\nimport { makeswiftApiClientSyncMiddleware } from './middleware/makeswift-api-client-sync'\n\ntype ReadWriteMiddleware = ReturnType<\n typeof import('./middleware/read-write').createReadWriteMiddleware\n>\n\ntype ReadWriteMiddlewareRef = {\n current: ReadWriteMiddleware | null\n}\n\nexport function conditionalReadWriteMiddleware(\n middlewareRef: ReadWriteMiddlewareRef,\n): Middleware<Dispatch, State, Dispatch> {\n let readWriteActionBuffer: Action[] = []\n let middlewares: ReadWriteMiddleware | null = null\n let enhancedDispatch: Dispatch | null = null\n\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n const state = getState()\n\n if (middlewareRef.current == null) {\n if (!state.isReadOnly) {\n // because switching to the read-write state is an asynchronous operation,\n // we need to buffer all actions dispatched after the isReadOnly state is\n // set to false but before the read-write middleware is installed\n readWriteActionBuffer.push(action)\n }\n\n return next(action)\n }\n\n if (state.isReadOnly) {\n console.error('Read-write state mismatch', {\n isReadOnly: state.isReadOnly,\n middlewareRef: middlewareRef.current,\n siteVersion: state.siteVersion,\n })\n }\n\n // build and cache the enhanced dispatch chain when read-write middleware is installed\n if (enhancedDispatch == null || middlewares !== middlewareRef.current) {\n middlewares = middlewareRef.current\n\n const middlewareApi = { dispatch, getState } as MiddlewareAPI<\n ReadWriteDispatch,\n ReadWriteState\n >\n\n enhancedDispatch = compose<Dispatch>(...middlewares.map(mw => mw(middlewareApi)))(next)\n }\n\n // dispatch buffered actions, if any\n if (readWriteActionBuffer.length > 0) {\n const readWriteActions = [...readWriteActionBuffer]\n readWriteActionBuffer = []\n\n // Note that we're rerunning the actions through the entire middleware chain,\n // including the read-only middleware and the reducers, some of which have\n // already processed these actions once. This is safe to do because actions that\n // are run as part of page initialization are idempotent.\n for (const bufferedAction of readWriteActions) {\n enhancedDispatch(bufferedAction)\n }\n }\n\n return enhancedDispatch(action)\n }\n })\n}\n\ninterface ReadWriteStateMixin {\n loadReadWriteState: ({ isReadOnly }: { isReadOnly: boolean }) => Promise<() => void>\n}\n\nfunction withReadWriteState(\n loadReadWriteState: ReadWriteStateMixin['loadReadWriteState'],\n): StoreEnhancer<ReadWriteStateMixin> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n loadReadWriteState,\n })\n}\n\nexport function configureStore({\n name,\n appOrigin,\n hostApiClient,\n preloadedState,\n breakpoints,\n}: {\n name: string\n appOrigin: string\n hostApiClient: MakeswiftHostApiClient\n preloadedState: Partial<State> | null\n breakpoints?: Breakpoints.State\n}) {\n const readWriteMiddlewareRef: ReadWriteMiddlewareRef = {\n current: null,\n }\n\n let refCount = 0\n let readWriteCleanup: (() => void) | null = null\n let readWriteSetupPromise: Promise<void> | null = null\n\n const loadReadWriteState = async (): Promise<void> => {\n if (readWriteCleanup != null) {\n return\n }\n\n if (readWriteSetupPromise != null) {\n await readWriteSetupPromise\n return\n }\n\n readWriteSetupPromise = (async () => {\n // import all the modules needed for read-write mode before proceeding with\n // the setup to avoid race conditions when `setup` is called concurrently\n // in two different page regions\n const { BuilderAPIProxy } = await import('./builder-api/proxy')\n const { createRootReducer, setupBuilderProxy } = await import('./read-write-state')\n const { createReadWriteMiddleware } = await import('./middleware/read-write')\n\n // IMPORTANT: only synchronous code after this point\n\n // with all modules imported, check if another concurrent setup already\n // initialized the read-write middleware\n if (readWriteMiddlewareRef.current != null) {\n return\n }\n\n store.replaceReducer(createRootReducer() as ReadOnlyReducer)\n\n const builderProxy = new BuilderAPIProxy({ appOrigin })\n readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy })\n\n const dispatch = store.dispatch as ReadWriteDispatch\n dispatch(setupBuilderProxy(builderProxy))\n\n readWriteCleanup = () => {\n readWriteMiddlewareRef.current = null\n builderProxy.teardown()\n }\n })()\n\n try {\n await readWriteSetupPromise\n } finally {\n readWriteSetupPromise = null\n }\n }\n\n const store = configureReduxStore({\n reducer: combineReducers(ReadOnlyState.reducers),\n\n preloadedState: {\n ...preloadedState,\n breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat([\n readOnlyElementTreeMiddleware(),\n makeswiftApiClientSyncMiddleware(hostApiClient),\n conditionalReadWriteMiddleware(readWriteMiddlewareRef),\n ]),\n\n enhancers: getDefaultEnhancers =>\n getDefaultEnhancers().concat(\n withReadWriteState(async ({ isReadOnly }) => {\n if (isReadOnly) {\n if (refCount > 0) {\n console.error('Read-write state mismatch', {\n isReadOnly,\n refCount,\n })\n }\n\n return () => {}\n }\n\n await loadReadWriteState()\n refCount += 1\n\n let didCleanup = false\n return () => {\n if (didCleanup) {\n return\n }\n\n didCleanup = true\n refCount -= 1\n if (refCount === 0 && readWriteCleanup != null) {\n readWriteCleanup()\n readWriteCleanup = null\n }\n }\n }),\n ),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n actionsDenylist: [\n HostActionTypes.BUILDER_POINTER_MOVE,\n BuilderActionTypes.HANDLE_POINTER_MOVE,\n BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n\n return store\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOO;AAIP,IAAAA,kBAAoE;AACpE,qBAAmC;AACnC,sBAAgC;AAEhC,kBAA6B;AAE7B,oCAA8C;AAI9C,oBAA+B;AAQ/B,uCAAiD;AAU1C,SAAS,+BACd,eACuC;AACvC,MAAI,wBAAkC,CAAC;AACvC,MAAI,cAA0C;AAC9C,MAAI,mBAAoC;AAExC,aAAO,kCAAiB,CAAC,EAAE,UAAU,SAAS,MAAM,UAAQ;AAC1D,WAAO,CAAC,WAAmB;AACzB,YAAM,QAAQ,SAAS;AAEvB,UAAI,cAAc,WAAW,MAAM;AACjC,YAAI,CAAC,MAAM,YAAY;AAIrB,gCAAsB,KAAK,MAAM;AAAA,QACnC;AAEA,eAAO,KAAK,MAAM;AAAA,MACpB;AAEA,UAAI,MAAM,YAAY;AACpB,gBAAQ,MAAM,6BAA6B;AAAA,UACzC,YAAY,MAAM;AAAA,UAClB,eAAe,cAAc;AAAA,UAC7B,aAAa,MAAM;AAAA,QACrB,CAAC;AAAA,MACH;AAGA,UAAI,oBAAoB,QAAQ,gBAAgB,cAAc,SAAS;AACrE,sBAAc,cAAc;AAE5B,cAAM,gBAAgB,EAAE,UAAU,SAAS;AAK3C,+BAAmB,wBAAkB,GAAG,YAAY,IAAI,QAAM,GAAG,aAAa,CAAC,CAAC,EAA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AI;AACF,YAAM;AAAA,IACR,UAAE;AACA,8BAAwB;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,YAAQ,eAAAC,gBAAoB;AAAA,IAChC,aAAS,gCAAgB,cAAc,QAAQ;AAAA,IAE/C,gBAAgB;AAAA,MACd,GAAG;AAAA,MACH,aAAa,YAAY,gBAAgB,eAAe,gBAAgB,WAAW;AAAA,IACrF;AAAA,IAEA,YAAY,0BACV,qBAAqB,iCAAiB,EAAE,OAAO;AAAA,UAC7C,6DAA8B;AAAA,UAC9B,mEAAiC,aAAa;AAAA,MAC9C,+BAA+B,sBAAsB;AAAA,IACvD,CAAC;AAAA,IAEH,WAAW,yBACT,oBAAoB,EAAE;AAAA,MACpB,mBAAmB,OAAO,EAAE,WAAW,MAAM;AAC3C,YAAI,YAAY;AACd,cAAI,WAAW,GAAG;AAChB,oBAAQ,MAAM,6BAA6B;AAAA,cACzC;AAAA,cACA;AAAA,YACF,CAAC;AAAA,UACH;AAEA,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AAEA,cAAM,mBAAmB;AACzB,oBAAY;AAEZ,YAAI,aAAa;AACjB,eAAO,MAAM;AACX,cAAI,YAAY;AACd;AAAA,UACF;AAEA,uBAAa;AACb,sBAAY;AACZ,cAAI,aAAa,KAAK,oBAAoB,MAAM;AAC9C,6BAAiB;AACjB,+BAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAEF,cAAU,gCAAe;AAAA,MACvB,MAAM,GAAG,IAAI,MAAK,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MAC1C,iBAAiB;AAAA,QACf,gCAAgB;AAAA,QAChB,kCAAmB;AAAA,QACnB,kCAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;","names":["import_toolkit","configureReduxStore"]}
1
+ {"version":3,"sources":["../../../src/state/store.ts"],"sourcesContent":["import {\n type Middleware,\n type StoreEnhancer,\n type MiddlewareAPI,\n configureStore as configureReduxStore,\n combineReducers,\n compose,\n} from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../api/client'\n\nimport { actionMiddleware, middlewareOptions, devToolsConfig } from './toolkit'\nimport { BuilderActionTypes } from './builder-api/actions'\nimport { HostActionTypes } from './host-api'\n\nimport * as Breakpoints from './modules/breakpoints'\n\nimport { readOnlyElementTreeMiddleware } from './middleware/read-only-element-tree'\n\nimport { type Action } from './actions'\nimport { type State as ReadWriteState } from './read-write-state'\nimport * as ReadOnlyState from './read-only-state'\n\nimport {\n type State,\n type Dispatch,\n type ReadOnlyReducer,\n type ReadWriteDispatch,\n} from './unified-state'\nimport { makeswiftApiClientSyncMiddleware } from './middleware/makeswift-api-client-sync'\n\ntype ReadWriteMiddleware = ReturnType<\n typeof import('./middleware/read-write').createReadWriteMiddleware\n>\n\ntype ReadWriteMiddlewareRef = {\n current: ReadWriteMiddleware | null\n}\n\nexport function conditionalReadWriteMiddleware(\n middlewareRef: ReadWriteMiddlewareRef,\n): Middleware<Dispatch, State, Dispatch> {\n let readWriteActionBuffer: Action[] = []\n let middlewares: ReadWriteMiddleware | null = null\n let enhancedDispatch: Dispatch | null = null\n\n return actionMiddleware(({ dispatch, getState }) => next => {\n return (action: Action) => {\n const state = getState()\n\n if (middlewareRef.current == null) {\n if (!state.isReadOnly) {\n // because switching to the read-write state is an asynchronous operation,\n // we need to buffer all actions dispatched after the isReadOnly state is\n // set to false but before the read-write middleware is installed\n readWriteActionBuffer.push(action)\n }\n\n return next(action)\n }\n\n if (state.isReadOnly) {\n console.error('Read-write state mismatch', {\n isReadOnly: state.isReadOnly,\n middlewareRef: middlewareRef.current,\n siteVersion: state.siteVersion,\n })\n }\n\n // build and cache the enhanced dispatch chain when read-write middleware is installed\n if (enhancedDispatch == null || middlewares !== middlewareRef.current) {\n middlewares = middlewareRef.current\n\n const middlewareApi = { dispatch, getState } as MiddlewareAPI<\n ReadWriteDispatch,\n ReadWriteState\n >\n\n enhancedDispatch = compose<Dispatch>(...middlewares.map(mw => mw(middlewareApi)))(next)\n }\n\n // dispatch buffered actions, if any\n if (readWriteActionBuffer.length > 0) {\n const readWriteActions = [...readWriteActionBuffer]\n readWriteActionBuffer = []\n\n // Note that we're rerunning the actions through the entire middleware chain,\n // including the read-only middleware and the reducers, some of which have\n // already processed these actions once. This is safe to do because actions that\n // are run as part of page initialization are idempotent.\n for (const bufferedAction of readWriteActions) {\n enhancedDispatch(bufferedAction)\n }\n }\n\n return enhancedDispatch(action)\n }\n })\n}\n\ninterface ReadWriteStateMixin {\n loadReadWriteState: ({ isReadOnly }: { isReadOnly: boolean }) => Promise<() => void>\n}\n\nfunction withReadWriteState(\n loadReadWriteState: ReadWriteStateMixin['loadReadWriteState'],\n): StoreEnhancer<ReadWriteStateMixin> {\n return next => (reducer, preloadedState?) => ({\n ...next(reducer, preloadedState),\n loadReadWriteState,\n })\n}\n\nexport function configureStore({\n name,\n appOrigin,\n hostApiClient,\n preloadedState,\n breakpoints,\n}: {\n name: string\n appOrigin: string\n hostApiClient: MakeswiftHostApiClient\n preloadedState: Partial<State> | null\n breakpoints?: Breakpoints.State\n}) {\n const readWriteMiddlewareRef: ReadWriteMiddlewareRef = {\n current: null,\n }\n\n let refCount = 0\n let readWriteCleanup: (() => void) | null = null\n let readWriteSetupPromise: Promise<void> | null = null\n\n const loadReadWriteState = async (): Promise<void> => {\n if (readWriteCleanup != null) {\n return\n }\n\n if (readWriteSetupPromise != null) {\n await readWriteSetupPromise\n return\n }\n\n readWriteSetupPromise = (async () => {\n // import all the modules needed for read-write mode before proceeding with\n // the setup to avoid race conditions when `setup` is called concurrently\n // in two different page regions\n const { BuilderAPIProxy } = await import('./builder-api/proxy')\n const { createRootReducer, setupBuilderProxy } = await import('./read-write-state')\n const { createReadWriteMiddleware } = await import('./middleware/read-write')\n\n // IMPORTANT: only synchronous code after this point\n\n // with all modules imported, check if another concurrent setup already\n // initialized the read-write middleware\n if (readWriteMiddlewareRef.current != null) {\n return\n }\n\n store.replaceReducer(createRootReducer() as ReadOnlyReducer)\n\n const builderProxy = new BuilderAPIProxy({ appOrigin })\n readWriteMiddlewareRef.current = createReadWriteMiddleware({ builderProxy })\n\n const dispatch = store.dispatch as ReadWriteDispatch\n const builderProxyCleanup = dispatch(setupBuilderProxy(builderProxy))\n\n readWriteCleanup = () => {\n readWriteMiddlewareRef.current = null\n builderProxyCleanup()\n }\n })()\n\n try {\n await readWriteSetupPromise\n } finally {\n readWriteSetupPromise = null\n }\n }\n\n const store = configureReduxStore({\n reducer: combineReducers(ReadOnlyState.reducers),\n\n preloadedState: {\n ...preloadedState,\n breakpoints: Breakpoints.getInitialState(breakpoints ?? preloadedState?.breakpoints),\n },\n\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware(middlewareOptions).concat([\n readOnlyElementTreeMiddleware(),\n makeswiftApiClientSyncMiddleware(hostApiClient),\n conditionalReadWriteMiddleware(readWriteMiddlewareRef),\n ]),\n\n enhancers: getDefaultEnhancers =>\n getDefaultEnhancers().concat(\n withReadWriteState(async ({ isReadOnly }) => {\n if (isReadOnly) {\n if (refCount > 0) {\n console.error('Read-write state mismatch', {\n isReadOnly,\n refCount,\n })\n }\n\n return () => {}\n }\n\n await loadReadWriteState()\n refCount += 1\n\n let didCleanup = false\n return () => {\n if (didCleanup) {\n return\n }\n\n didCleanup = true\n refCount -= 1\n if (refCount === 0 && readWriteCleanup != null) {\n readWriteCleanup()\n readWriteCleanup = null\n }\n }\n }),\n ),\n\n devTools: devToolsConfig({\n name: `${name} (${new Date().toISOString()})`,\n actionsDenylist: [\n HostActionTypes.BUILDER_POINTER_MOVE,\n BuilderActionTypes.HANDLE_POINTER_MOVE,\n BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE,\n ],\n }),\n })\n\n return store\n}\n\nexport type Store = ReturnType<typeof configureStore>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOO;A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AE;AAAA,MACpB,mBAAmB,OAAO,EAAE,WAAW,MAAM;AAC3C,YAAI,YAAY;AACd,cAAI,WAAW,GAAG;AAChB,oBAAQ,MAAM,6BAA6B;AAAA,cACzC;AAAA,cACA;AAAA,YACF,CAAC;AAAA,UACH;AAEA,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AAEA,cAAM,mBAAmB;AACzB,oBAAY;AAEZ,YAAI,aAAa;AACjB,eAAO,MAAM;AACX,cAAI,YAAY;AACd;AAAA,UACF;AAEA,uBAAa;AACb,sBAAY;AACZ,cAAI,aAAa,KAAK,oBAAoB,MAAM;AAC9C,6BAAiB;AACjB,+BAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAEF,cAAU,gCAAe;AAAA,MACvB,MAAM,GAAG,IAAI,MAAK,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,MAC1C,iBAAiB;AAAA,QACf,gCAAgB;AAAA,QAChB,kCAAmB;AAAA,QACnB,kCAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;","names":["import_toolkit","configureReduxStore"]}
@@ -26,6 +26,7 @@ __export(unstable_framework_support_exports, {
26
26
  MAKESWIFT_SITE_VERSION_COOKIE: () => import_preview.MAKESWIFT_SITE_VERSION_COOKIE,
27
27
  MakeswiftClient: () => import_client.MakeswiftClient,
28
28
  MakeswiftComponent: () => import_MakeswiftComponent.MakeswiftComponent,
29
+ MakeswiftFonts: () => import_MakeswiftFonts.MakeswiftFonts,
29
30
  Page: () => import_page.Page,
30
31
  REDIRECT_SEARCH_PARAM: () => import_redirect_live.REDIRECT_SEARCH_PARAM,
31
32
  ReactRuntime: () => import_react_runtime.ReactRuntime,
@@ -60,6 +61,7 @@ var import_page = require("../runtimes/react/components/page");
60
61
  var import_RuntimeProvider = require("../runtimes/react/components/RuntimeProvider");
61
62
  var import_Slot = require("../runtimes/react/components/Slot");
62
63
  var import_GoogleFontLink = require("../runtimes/react/components/GoogleFontLink");
64
+ var import_MakeswiftFonts = require("../runtimes/react/components/MakeswiftFonts");
63
65
  var import_root_style_registry = require("../runtimes/react/root-style-registry");
64
66
  var import_react_runtime = require("../runtimes/react/react-runtime");
65
67
  // Annotate the CommonJS export names for ESM import in node:
@@ -72,6 +74,7 @@ var import_react_runtime = require("../runtimes/react/react-runtime");
72
74
  MAKESWIFT_SITE_VERSION_COOKIE,
73
75
  MakeswiftClient,
74
76
  MakeswiftComponent,
77
+ MakeswiftFonts,
75
78
  Page,
76
79
  REDIRECT_SEARCH_PARAM,
77
80
  ReactRuntime,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport { type ApiHandlerUserConfig, createApiHandler } from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n FrameworkContext,\n DefaultHead,\n DefaultHeadSnippet,\n DefaultImage,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\n\nexport { GoogleFontLink } from '../runtimes/react/components/GoogleFontLink'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime } from '../runtimes/react/react-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKO;AAEP,yBAA4D;AAC5D,qBAAwD;AACxD,2BAA2D;AAC3D,mCAA6C;AAC7C,qBAA4D;AAE5D,oBAAgC;AAIhC,+BAKO;AAEP,gCAAmC;AACnC,kBAAqB;AACrB,6BAAgC;AAChC,kBAAqB;AAErB,4BAA+B;AAE/B,iCAMO;AAEP,2BAA6B;","names":[]}
1
+ {"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport { type ApiHandlerUserConfig, createApiHandler } from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n FrameworkContext,\n DefaultHead,\n DefaultHeadSnippet,\n DefaultImage,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\n\nexport { GoogleFontLink } from '../runtimes/react/components/GoogleFontLink'\nexport { MakeswiftFonts } from '../runtimes/react/components/MakeswiftFonts'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime } from '../runtimes/react/react-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKO;AAEP,yBAA4D;AAC5D,qBAAwD;AACxD,2BAA2D;AAC3D,mCAA6C;AAC7C,qBAA4D;AAE5D,oBAAgC;AAIhC,+BAKO;AAEP,gCAAmC;AACnC,kBAAqB;AACrB,6BAAgC;AAChC,kBAAqB;AAErB,4BAA+B;AAC/B,4BAA+B;AAE/B,iCAMO;AAEP,2BAA6B;","names":[]}
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
8
8
  return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
9
9
  }
10
10
  return ApiResponse.json({
11
- version: "0.28.0-canary.2",
11
+ version: "0.28.0",
12
12
  interactionMode: true,
13
13
  clientSideNavigation: false,
14
14
  elementFromPoint: false,
@@ -1,5 +1,6 @@
1
1
  import {
2
- ShapeV2Definition
2
+ ShapeV2Definition,
3
+ deserializeObject
3
4
  } from "@makeswift/controls";
4
5
  import {
5
6
  CheckboxDefinition,
@@ -84,7 +85,7 @@ function serializeListControl(control) {
84
85
  function deserializeListControl(serializedControl) {
85
86
  const { type, getItemLabel } = serializedControl.options;
86
87
  const deserializedType = deserializeControl(type);
87
- const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel);
88
+ const deserializedGetItemLabel = isSerializedFunction(getItemLabel) ? deserializeFunction(getItemLabel) : getItemLabel;
88
89
  return {
89
90
  ...serializedControl,
90
91
  options: {
@@ -104,7 +105,7 @@ function serializeTypeaheadControl(control) {
104
105
  }
105
106
  function deserializeTypeaheadControl(serializedControl) {
106
107
  const { getItems } = serializedControl.options;
107
- const deserializedGetItems = getItems && deserializeFunction(getItems);
108
+ const deserializedGetItems = isSerializedFunction(getItems) ? deserializeFunction(getItems) : getItems;
108
109
  return {
109
110
  ...serializedControl,
110
111
  options: { ...serializedControl.options, getItems: deserializedGetItems }
@@ -376,12 +377,14 @@ function deserializeLegacyControl(serializedControl) {
376
377
  return serializedControl;
377
378
  }
378
379
  }
379
- function deserializeControl(serializedControl) {
380
+ function deserializeControl(serializedControl, options) {
380
381
  if (isSerializedLegacyControl(serializedControl)) {
381
- return deserializeLegacyControl(serializedControl);
382
+ const record = options?.plugins ? deserializeObject(serializedControl, options?.plugins) : serializedControl;
383
+ return deserializeLegacyControl(record);
382
384
  }
385
+ const plugins = [functionDeserializationPlugin, ...options?.plugins ?? []];
383
386
  return deserializeUnifiedControlDef(
384
- deserializeRecord(serializedControl, [functionDeserializationPlugin])
387
+ deserializeRecord(serializedControl, plugins)
385
388
  );
386
389
  }
387
390
  function deserializeUnifiedControlDef(record) {
@@ -424,7 +427,8 @@ function serializeControls(controls) {
424
427
  );
425
428
  }
426
429
  function deserializeControls(serializedControls, {
427
- onError
430
+ onError,
431
+ plugins
428
432
  } = {}) {
429
433
  return Object.entries(serializedControls).reduce(
430
434
  (deserializedControls, [key, serializedControl]) => {
@@ -434,7 +438,7 @@ function deserializeControls(serializedControls, {
434
438
  `Expected serialized control data, got ${JSON.stringify(serializedControl)}`
435
439
  );
436
440
  }
437
- const deserializedControl = deserializeControl(serializedControl);
441
+ const deserializedControl = deserializeControl(serializedControl, { plugins });
438
442
  return { ...deserializedControls, [key]: deserializedControl };
439
443
  } catch (err) {
440
444
  const error = err instanceof Error ? new Error(`Could not deserialize control for "${key}": ${err.message}`, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/builder/serialization/control-serialization.ts"],"sourcesContent":["import {\n GapData,\n GapX,\n GapYDescriptor,\n GapYPropControllerData,\n ResponsiveLengthOptions,\n ResponsiveLengthPropControllerData,\n ResponsiveIconRadioGroup,\n ResponsiveNumber,\n ResponsiveSelect,\n type Descriptor,\n type PropDef,\n type OptionsType,\n} from '@makeswift/prop-controllers'\n\nimport {\n type Data,\n type Device,\n ControlDefinition as UnifiedControlDefinition,\n type SerializedRecord,\n type RichTextValue as RichTextControlValue,\n ShapeV2Definition,\n} from '@makeswift/controls'\n\nimport {\n CheckboxDefinition,\n ColorDefinition,\n ComboboxDefinition,\n FontDefinition,\n GroupDefinition,\n IconRadioGroupDefinition,\n ImageDefinition,\n LinkDefinition,\n ListDefinition,\n NumberDefinition,\n RichTextV1Definition,\n RichTextV2Definition,\n SelectDefinition,\n ShapeDefinition,\n SlotDefinition,\n StyleDefinition,\n StyleV2Definition,\n TextAreaDefinition,\n TextInputDefinition,\n unstable_TypographyDefinition,\n} from '../../controls'\n\nimport {\n PanelDescriptor as PanelControl,\n PanelDescriptorType as PanelControlType,\n PanelDescriptorValueType as PanelControlValueType,\n Descriptor as ControlDefinition,\n} from '../../prop-controllers/descriptors'\n\nimport {\n DELETED_PROP_CONTROLLER_TYPES,\n ListDescriptor as ListControl,\n ListOptions as ListControlConfig,\n ListValue as ListControlValue,\n ShapeDescriptor as ShapeControl,\n ShapeValue as ShapeControlValue,\n TypeaheadDescriptor as TypeaheadControl,\n TypeaheadOptions as TypeaheadControlConfig,\n TypeaheadValue as TypeaheadControlValue,\n RichTextDescriptor as RichTextControl,\n} from '../../prop-controllers/deleted'\n\nimport {\n DeserializedFunction,\n deserializeFunction,\n isSerializedFunction,\n SerializedFunction,\n serializeFunction,\n} from './function-serialization'\n\nimport {\n LinkData,\n DateDescriptor as DateControl,\n DatePropControllerData,\n Types as PropControllerTypes,\n ImageDescriptor as ImageControl,\n ImageData as ImageControlValue,\n LinkDescriptor as LinkControl,\n LinkPropControllerData,\n ResponsiveLengthDescriptor,\n NumberOptions,\n NumberPropControllerData,\n NumberDescriptor,\n ResponsiveColorPropControllerData,\n ResponsiveColorDescriptor,\n CheckboxPropControllerData,\n CheckboxDescriptor as CheckboxControl,\n TextStyleDescriptor as TextStyleControl,\n TextStylePropControllerData,\n TextInputDescriptor as TextInputControl,\n} from '@makeswift/prop-controllers'\n\nimport { type LegacyDescriptor, isLegacyDescriptor } from '../../prop-controllers/descriptors'\nimport { deserializeRecord, type DeserializedRecord } from '@makeswift/controls'\nimport {\n ClientMessagePortSerializationVisitor,\n functionDeserializationPlugin,\n} from '../../controls/visitors/message-port-serializer'\n\ntype SerializedShapeControlConfig<T extends Record<string, SerializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: SerializedPanelControlValueType<T[K]> }\n}\n\ntype SerializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Shape\n options: SerializedShapeControlConfig<U>\n}\n\nfunction serializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, PanelControl>,\n>(\n control: ShapeControl<T, U>,\n): [\n SerializedShapeControl<\n T,\n { [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>> }\n >,\n Transferable[],\n] {\n const { type } = control.options\n const transferables: Transferable[] = []\n const serializedType = {} as {\n [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n const [serializedControl, serializedControlTransferables] = serializeControl(control)\n\n serializedType[key as keyof typeof type] = serializedControl as SerializedPanelControl\n transferables.push(...serializedControlTransferables)\n })\n\n // @ts-expect-error: preset types are incompatible\n return [{ ...control, options: { ...control.options, type: serializedType } }, transferables]\n}\n\ntype DeserializedShapeControlConfig<T extends Record<string, DeserializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: DeserializedPanelControlValueType<T[K]> }\n}\n\ntype DeserializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, DeserializedPanelControl>,\n> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Shape\n options: DeserializedShapeControlConfig<U>\n}\n\nfunction deserializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n>(\n control: SerializedShapeControl<T, U>,\n): DeserializedShapeControl<\n T,\n { [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>> }\n> {\n const { type } = control.options\n const deserializedType = {} as {\n [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n deserializedType[key as keyof typeof type] = deserializeControl(\n control,\n ) as DeserializedPanelControl\n })\n\n // @ts-expect-error: preset types are incompatible\n return { ...control, options: { ...control.options, type: deserializedType } }\n}\n\ntype SerializedListControlConfig<T extends Data> = {\n type: SerializedPanelControl<T>\n label?: string\n getItemLabel?: SerializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype SerializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.List\n options: SerializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction serializeListControl<T extends Data>(\n control: ListControl<ListControlValue<T>>,\n): [SerializedListControl<ListControlValue<T>>, Transferable[]] {\n const { type, getItemLabel } = control.options\n const transferables: Transferable[] = []\n\n const [serializedType, serializedTypeTransferables] = serializeControl(type)\n const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel)\n\n transferables.push(...serializedTypeTransferables)\n if (serializedGetItemLabel != null) transferables.push(serializedGetItemLabel)\n\n return [\n {\n ...control,\n options: {\n ...control.options,\n type: serializedType as SerializedPanelControl,\n getItemLabel: serializedGetItemLabel,\n },\n },\n transferables,\n ]\n}\n\ntype DeserializedListControlConfig<T extends Data> = {\n type: DeserializedPanelControl<T>\n label?: string\n getItemLabel?: DeserializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype DeserializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.List\n options: DeserializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction deserializeListControl<T extends Data>(\n serializedControl: SerializedListControl<ListControlValue<T>>,\n): DeserializedListControl<ListControlValue<T>> {\n const { type, getItemLabel } = serializedControl.options\n\n const deserializedType = deserializeControl(type) as DeserializedPanelControl\n const deserializedGetItemLabel = getItemLabel && deserializeFunction(getItemLabel)\n\n return {\n ...serializedControl,\n options: {\n ...serializedControl.options,\n type: deserializedType,\n getItemLabel: deserializedGetItemLabel,\n },\n }\n}\n\ntype SerializedTypeaheadControlConfig<T extends Data> = {\n getItems: SerializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype SerializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Typeahead\n options: SerializedTypeaheadControlConfig<T['value']>\n}\n\nfunction serializeTypeaheadControl<T extends Data>(\n control: TypeaheadControl<TypeaheadControlValue<T>>,\n): [SerializedTypeaheadControl<TypeaheadControlValue<T>>, Transferable[]] {\n const { getItems } = control.options\n\n const serializedGetItems = getItems && serializeFunction(getItems)\n\n return [\n { ...control, options: { ...control.options, getItems: serializedGetItems } },\n serializedGetItems == null ? [] : [serializedGetItems],\n ]\n}\n\ntype DeserializedTypeaheadControlConfig<T extends Data> = {\n getItems: DeserializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype DeserializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Typeahead\n options: DeserializedTypeaheadControlConfig<T['value']>\n}\n\nfunction deserializeTypeaheadControl<T extends Data>(\n serializedControl: SerializedTypeaheadControl<TypeaheadControlValue<T>>,\n): DeserializedTypeaheadControl<TypeaheadControlValue<T>> {\n const { getItems } = serializedControl.options\n\n const deserializedGetItems = getItems && deserializeFunction(getItems)\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItems: deserializedGetItems },\n }\n}\n\ntype SerializedConfig<T> =\n | T\n | SerializedFunction<(props: Record<string, unknown>, deviceMode: Device) => T>\n\nexport type DeserializedConfig<T> =\n | T\n | DeserializedFunction<(props: Record<string, unknown>, deviceMode: Device) => T>\n\ntype SerializedControlDef<P extends PropDef> = Descriptor<P> & {\n options: SerializedConfig<OptionsType<P>>\n}\n\nfunction serializeControlDef<P extends PropDef>(\n control: Descriptor<P>,\n): [SerializedControlDef<P>, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\nexport type DeserializedControlDef<P extends PropDef> = Descriptor<P> & {\n options: DeserializedConfig<OptionsType<P>>\n}\n\nfunction deserializeControlDef<P extends PropDef>(\n serializedControl: SerializedControlDef<P>,\n): DeserializedControlDef<P> {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype GapYControlConfig = {\n preset?: GapYPropControllerData\n label?: string\n defaultValue?: GapData\n min?: number\n max?: number\n step?: number\n hidden?: boolean\n}\n\ntype SerializedGapYControl<_T = GapYPropControllerData> = {\n type: typeof PropControllerTypes.GapY\n options: SerializedConfig<GapYControlConfig>\n}\n\nfunction serializeGapYControl(control: GapYDescriptor): [SerializedGapYControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedGapYControl<_T = GapYPropControllerData> = {\n type: typeof PropControllerTypes.GapY\n options: DeserializedConfig<GapYControlConfig>\n}\n\nfunction deserializeGapYControl(serializedControl: SerializedGapYControl): DeserializedGapYControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype CheckboxControlConfig = {\n preset?: CheckboxPropControllerData\n label: string\n hidden?: boolean\n}\n\ntype SerializedCheckboxControl<_T = CheckboxPropControllerData> = {\n type: typeof PropControllerTypes.Checkbox\n options: SerializedConfig<CheckboxControlConfig>\n}\n\nfunction serializeCheckboxControl(\n control: CheckboxControl,\n): [SerializedCheckboxControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedCheckboxControl<_T = CheckboxPropControllerData> = {\n type: typeof PropControllerTypes.Checkbox\n options: DeserializedConfig<CheckboxControlConfig>\n}\n\nfunction deserializeCheckboxControl(\n serializedControl: SerializedCheckboxControl,\n): DeserializedCheckboxControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype ResponsiveColorControlConfig = { label?: string; placeholder?: string; hidden?: boolean }\n\ntype SerializedResponsiveColorControl<_T = ResponsiveColorPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveColor\n options: SerializedConfig<ResponsiveColorControlConfig>\n}\n\nfunction serializeResponsiveColorControl(\n control: ResponsiveColorDescriptor,\n): [SerializedResponsiveColorControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedResponsiveColorControl<_T = ResponsiveColorPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveColor\n options: DeserializedConfig<ResponsiveColorControlConfig>\n}\n\nfunction deserializeResponsiveColorControl(\n serializedControl: SerializedResponsiveColorControl,\n): DeserializedResponsiveColorControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\ntype SerializedNumberControl<_T = NumberPropControllerData> = {\n type: typeof PropControllerTypes.Number\n options: SerializedConfig<NumberOptions>\n}\n\nfunction serializeNumberControl(\n control: NumberDescriptor,\n): [SerializedNumberControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedNumberControl<_T = NumberPropControllerData> = {\n type: typeof PropControllerTypes.Number\n options: DeserializedConfig<NumberOptions>\n}\n\nfunction deserializeNumberControl(\n serializedControl: SerializedNumberControl,\n): DeserializedNumberControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype DateControlConfig = { preset?: DatePropControllerData }\n\ntype SerializedDateControl<_T = DatePropControllerData> = {\n type: typeof PropControllerTypes.Date\n options: SerializedConfig<DateControlConfig>\n}\n\nfunction serializeDateControl(control: DateControl): [SerializedDateControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedDateControl<_T = DatePropControllerData> = {\n type: typeof PropControllerTypes.Date\n options: DeserializedConfig<DateControlConfig>\n}\n\nfunction deserializeDateControl(serializedControl: SerializedDateControl): DeserializedDateControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype LinkControlConfig = {\n preset?: LinkPropControllerData\n label?: string\n defaultValue?: LinkPropControllerData\n options?: { value: LinkData['type']; label: string }[]\n hidden?: boolean\n}\n\ntype SerializedLinkControl<_T = LinkPropControllerData> = {\n type: typeof PropControllerTypes.Link\n options: SerializedConfig<LinkControlConfig>\n}\n\nfunction serializeLinkControl(control: LinkControl): [SerializedLinkControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedLinkControl<_T = LinkPropControllerData> = {\n type: typeof PropControllerTypes.Link\n options: DeserializedConfig<LinkControlConfig>\n}\n\nfunction deserializeLinkControl(serializedControl: SerializedLinkControl): DeserializedLinkControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype TextInputControlConfig = { label?: string; placeholder?: string; hidden?: boolean }\n\ntype TextInputControlValue = string\n\ntype SerializedTextInputControl<_T = TextInputControlValue> = {\n type: typeof PropControllerTypes.TextInput\n options: SerializedConfig<TextInputControlConfig>\n}\n\nfunction serializeTextInputControl(\n control: TextInputControl,\n): [SerializedTextInputControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedTextInputControl<_T = TextInputControlValue> = {\n type: typeof PropControllerTypes.TextInput\n options: DeserializedConfig<TextInputControlConfig>\n}\n\nfunction deserializeTextInputControl(\n serializedControl: SerializedTextInputControl,\n): DeserializedTextInputControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype SerializedResponsiveLengthControl<_T = ResponsiveLengthPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveLength\n options: SerializedConfig<ResponsiveLengthOptions>\n}\n\nfunction serializeResponsiveLengthControl(\n control: ResponsiveLengthDescriptor,\n): [SerializedResponsiveLengthControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedResponsiveLengthControl<_T = ResponsiveLengthPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveLength\n options: DeserializedConfig<ResponsiveLengthOptions>\n}\n\nfunction deserializeResponsiveLengthControl(\n serializedControl: SerializedResponsiveLengthControl,\n): DeserializedResponsiveLengthControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype SerializedTextStyleControl<_T = TextStylePropControllerData> = {\n type: typeof PropControllerTypes.TextStyle\n options: SerializedConfig<TextStyleControlConfig>\n}\n\nfunction serializeTextStyleControl(\n control: TextStyleControl,\n): [SerializedTextStyleControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype TextStyleControlConfig = {\n preset?: TextStylePropControllerData\n label?: string\n hidden?: boolean\n}\n\ntype DeserializedTextStyleControl<_T = TextStylePropControllerData> = {\n type: typeof PropControllerTypes.TextStyle\n options: DeserializedConfig<TextStyleControlConfig>\n}\n\nfunction deserializeTextStyleControl(\n serializedControl: SerializedTextStyleControl,\n): DeserializedTextStyleControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype ImageControlConfig = { label?: string; hidden?: boolean }\n\ntype SerializedImageControl<_T = ImageControlValue> = {\n type: typeof PropControllerTypes.Image\n options: SerializedConfig<ImageControlConfig>\n}\n\nfunction serializeImageControl(control: ImageControl): [SerializedImageControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedImageControl<_T = ImageControlValue> = {\n type: typeof PropControllerTypes.Image\n options: DeserializedConfig<ImageControlConfig>\n}\n\nfunction deserializeImageControl(\n serializedControl: SerializedImageControl,\n): DeserializedImageControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype RichTextControlConfig = { preset?: RichTextControlValue }\n\ntype SerializedRichTextControl<_T = RichTextControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.RichText\n options: SerializedConfig<RichTextControlConfig>\n}\n\nfunction serializeRichTextControl(\n control: RichTextControl,\n): [SerializedRichTextControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedRichTextControl<_T = RichTextControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.RichText\n options: DeserializedConfig<RichTextControlConfig>\n}\n\nfunction deserializeRichTextControl(\n serializedControl: SerializedRichTextControl,\n): DeserializedRichTextControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\nexport type SerializedLegacyControl<T extends Data = Data> =\n | Exclude<\n LegacyDescriptor<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | Descriptor<typeof GapX>\n | GapYDescriptor<T>\n | Descriptor<typeof ResponsiveNumber>\n | CheckboxControl<T>\n | ResponsiveColorDescriptor<T>\n | NumberDescriptor<T>\n | Descriptor<typeof ResponsiveIconRadioGroup>\n | Descriptor<typeof ResponsiveSelect>\n | ResponsiveLengthDescriptor<T>\n | DateControl<T>\n | LinkControl<T>\n | TextInputControl<T>\n | TextStyleControl<T>\n | ImageControl<T>\n | RichTextControl<T>\n >\n | SerializedListControl<T extends ListControlValue ? T : ListControlValue>\n | SerializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | SerializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | SerializedControlDef<typeof GapX>\n | SerializedGapYControl<T>\n | SerializedControlDef<typeof ResponsiveNumber>\n | SerializedCheckboxControl<T>\n | SerializedResponsiveColorControl<T>\n | SerializedNumberControl<T>\n | SerializedControlDef<typeof ResponsiveIconRadioGroup>\n | SerializedControlDef<typeof ResponsiveSelect>\n | SerializedResponsiveLengthControl<T>\n | SerializedDateControl<T>\n | SerializedLinkControl<T>\n | SerializedTextInputControl<T>\n | SerializedTextStyleControl<T>\n | SerializedImageControl<T>\n | SerializedRichTextControl<T>\n\nexport type SerializedControl<T extends Data = Data> = SerializedLegacyControl<T> | SerializedRecord\n\ntype SerializedPanelControl<T extends Data = Data> = Extract<\n SerializedControl<T>,\n { type: PanelControlType }\n>\n\ntype SerializedPanelControlValueType<T extends SerializedPanelControl> =\n T extends SerializedPanelControl<infer U> ? U : never\n\nexport type DeserializedLegacyControl<T extends Data = Data> =\n | Exclude<\n LegacyDescriptor<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | Descriptor<typeof GapX>\n | GapYDescriptor<T>\n | Descriptor<typeof ResponsiveNumber>\n | CheckboxControl<T>\n | ResponsiveColorDescriptor<T>\n | NumberDescriptor<T>\n | Descriptor<typeof ResponsiveIconRadioGroup>\n | Descriptor<typeof ResponsiveSelect>\n | ResponsiveLengthDescriptor<T>\n | DateControl<T>\n | LinkControl<T>\n | TextInputControl<T>\n | TextStyleControl<T>\n | ImageControl<T>\n | RichTextControl<T>\n >\n | DeserializedListControl<T extends ListControlValue ? T : ListControlValue>\n | DeserializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | DeserializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | DeserializedControlDef<typeof GapX>\n | DeserializedGapYControl<T>\n | DeserializedControlDef<typeof ResponsiveNumber>\n | DeserializedCheckboxControl<T>\n | DeserializedResponsiveColorControl<T>\n | DeserializedNumberControl<T>\n | DeserializedControlDef<typeof ResponsiveIconRadioGroup>\n | DeserializedControlDef<typeof ResponsiveSelect>\n | DeserializedResponsiveLengthControl<T>\n | DeserializedDateControl<T>\n | DeserializedLinkControl<T>\n | DeserializedTextInputControl<T>\n | DeserializedTextStyleControl<T>\n | DeserializedImageControl<T>\n | DeserializedRichTextControl<T>\n\nexport type DeserializedControl<T extends Data = Data> =\n | DeserializedLegacyControl<T>\n | UnifiedControlDefinition\n\nexport type DeserializedPanelControl<T extends Data = Data> = Extract<\n DeserializedControl<T>,\n { type: PanelControlType }\n>\n\ntype DeserializedPanelControlValueType<T extends DeserializedPanelControl> =\n T extends DeserializedPanelControl<infer U> ? U : never\n\nexport function serializeControl<T extends Data>(\n control: ControlDefinition<T>,\n): [SerializedControl<T>, Transferable[]] {\n if (isLegacyDescriptor(control)) {\n return serializeLegacyControl(control)\n }\n\n const messagePortVisitor = new ClientMessagePortSerializationVisitor()\n const serializedControl = control.accept(messagePortVisitor)\n return [serializedControl, messagePortVisitor.getTransferables()]\n}\n\nexport function isSerializedControl(control: unknown): control is SerializedControl {\n return (\n control != null &&\n typeof control === 'object' &&\n 'type' in control &&\n typeof control.type === 'string'\n )\n}\n\nfunction serializeLegacyControl<T extends Data>(\n control: LegacyDescriptor<T>,\n): [SerializedControl<T>, Transferable[]] {\n switch (control.type) {\n case PropControllerTypes.Checkbox:\n return serializeCheckboxControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.List:\n return serializeListControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.Shape:\n return serializeShapeControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.Typeahead:\n return serializeTypeaheadControl(control) as [SerializedControl<T>, Transferable[]]\n\n case PropControllerTypes.GapX:\n return serializeControlDef<typeof GapX>(control)\n\n case PropControllerTypes.GapY:\n return serializeGapYControl(control)\n\n case PropControllerTypes.ResponsiveColor:\n return serializeResponsiveColorControl(control)\n\n case PropControllerTypes.ResponsiveNumber:\n return serializeControlDef<typeof ResponsiveNumber>(control)\n\n case PropControllerTypes.Number:\n return serializeNumberControl(control)\n\n case PropControllerTypes.ResponsiveIconRadioGroup:\n return serializeControlDef<typeof ResponsiveIconRadioGroup>(control)\n\n case PropControllerTypes.ResponsiveSelect:\n return serializeControlDef<typeof ResponsiveSelect>(control)\n\n case PropControllerTypes.ResponsiveLength:\n return serializeResponsiveLengthControl(control)\n\n case PropControllerTypes.Date:\n return serializeDateControl(control)\n\n case PropControllerTypes.Link:\n return serializeLinkControl(control)\n\n case PropControllerTypes.TextInput:\n return serializeTextInputControl(control)\n\n case PropControllerTypes.TextStyle:\n return serializeTextStyleControl(control)\n\n case PropControllerTypes.Image:\n return serializeImageControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return serializeRichTextControl(control)\n\n default:\n return [control, []]\n }\n}\n\nfunction isSerializedLegacyControl<T extends Data>(\n control: SerializedControl<T>,\n): control is SerializedLegacyControl<T> {\n return 'options' in control\n}\n\nexport function deserializeLegacyControl<T extends Data>(\n serializedControl: SerializedLegacyControl<T>,\n): DeserializedControl<T> {\n switch (serializedControl.type) {\n case PropControllerTypes.Checkbox:\n return deserializeCheckboxControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.List:\n return deserializeListControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.Shape:\n return deserializeShapeControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.Typeahead:\n return deserializeTypeaheadControl(serializedControl)\n\n case PropControllerTypes.GapX:\n return deserializeControlDef<typeof GapX>(serializedControl)\n\n case PropControllerTypes.GapY:\n return deserializeGapYControl(serializedControl)\n\n case PropControllerTypes.ResponsiveColor:\n return deserializeResponsiveColorControl(serializedControl)\n\n case PropControllerTypes.ResponsiveNumber:\n return deserializeControlDef<typeof ResponsiveNumber>(serializedControl)\n\n case PropControllerTypes.Number:\n return deserializeNumberControl(serializedControl)\n\n case PropControllerTypes.ResponsiveIconRadioGroup:\n return deserializeControlDef<typeof ResponsiveIconRadioGroup>(serializedControl)\n\n case PropControllerTypes.ResponsiveSelect:\n return deserializeControlDef<typeof ResponsiveSelect>(serializedControl)\n\n case PropControllerTypes.ResponsiveLength:\n return deserializeResponsiveLengthControl(serializedControl)\n\n case PropControllerTypes.Date:\n return deserializeDateControl(serializedControl)\n\n case PropControllerTypes.Link:\n return deserializeLinkControl(serializedControl)\n\n case PropControllerTypes.TextInput:\n return deserializeTextInputControl(serializedControl)\n\n case PropControllerTypes.TextStyle:\n return deserializeTextStyleControl(serializedControl)\n\n case PropControllerTypes.Image:\n return deserializeImageControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return deserializeRichTextControl(serializedControl)\n\n default:\n return serializedControl\n }\n}\n\nexport function deserializeControl<T extends Data>(\n serializedControl: SerializedControl<T>,\n): DeserializedControl<T> {\n if (isSerializedLegacyControl(serializedControl)) {\n return deserializeLegacyControl(serializedControl)\n }\n\n return deserializeUnifiedControlDef(\n deserializeRecord(serializedControl, [functionDeserializationPlugin])\n )\n}\n\nexport function deserializeUnifiedControlDef(record: DeserializedRecord): UnifiedControlDefinition {\n type DeserializeMethod = (data: DeserializedRecord) => UnifiedControlDefinition\n const deserializeMethod: Record<string, DeserializeMethod> = {\n [CheckboxDefinition.type]: CheckboxDefinition.deserialize,\n [ColorDefinition.type]: ColorDefinition.deserialize,\n [ComboboxDefinition.type]: ComboboxDefinition.deserialize,\n [FontDefinition.type]: FontDefinition.deserialize,\n [GroupDefinition.type]: record =>\n GroupDefinition.deserialize(record, deserializeUnifiedControlDef),\n [IconRadioGroupDefinition.type]: IconRadioGroupDefinition.deserialize,\n [ImageDefinition.type]: ImageDefinition.deserialize,\n [LinkDefinition.type]: LinkDefinition.deserialize,\n [ListDefinition.type]: record =>\n ListDefinition.deserialize(record, deserializeUnifiedControlDef),\n [NumberDefinition.type]: NumberDefinition.deserialize,\n [RichTextV1Definition.type]: RichTextV1Definition.deserialize,\n [RichTextV2Definition.type]: record =>\n RichTextV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [SelectDefinition.type]: SelectDefinition.deserialize,\n [ShapeDefinition.type]: record =>\n ShapeDefinition.deserialize(record, deserializeUnifiedControlDef),\n [ShapeV2Definition.type]: record =>\n ShapeV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [SlotDefinition.type]: SlotDefinition.deserialize,\n [StyleDefinition.type]: StyleDefinition.deserialize,\n [StyleV2Definition.type]: record =>\n StyleV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [TextAreaDefinition.type]: TextAreaDefinition.deserialize,\n [TextInputDefinition.type]: TextInputDefinition.deserialize,\n [unstable_TypographyDefinition.type]: unstable_TypographyDefinition.deserialize,\n } as const\n\n const deserialize = deserializeMethod[record.type] ?? null\n if (deserialize == null) {\n throw new Error(`Unknown control type: ${record.type}`)\n }\n\n return deserialize(record)\n}\n\nexport function serializeControls(\n controls: Record<string, ControlDefinition>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport function deserializeControls(\n serializedControls: Record<string, unknown>,\n {\n onError,\n }: { onError?: (err: Error, context: { key: string; serializedControl: unknown }) => void } = {},\n): Record<string, DeserializedControl> {\n return Object.entries(serializedControls).reduce(\n (deserializedControls, [key, serializedControl]) => {\n try {\n if (!isSerializedControl(serializedControl)) {\n throw new Error(\n `Expected serialized control data, got ${JSON.stringify(serializedControl)}`,\n )\n }\n const deserializedControl = deserializeControl(serializedControl)\n return { ...deserializedControls, [key]: deserializedControl }\n } catch (err: unknown) {\n const error =\n err instanceof Error\n ? new Error(`Could not deserialize control for \"${key}\": ${err.message}`, {\n cause: err,\n })\n : new Error(`Could not deserialize control for \"${key}\", unknown error: ${err}`)\n\n onError?.(error, { key, serializedControl })\n\n return deserializedControls\n }\n },\n {} as Record<string, DeserializedControl>,\n )\n}\n"],"mappings":"AAeA;AAAA,EAME;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP;AAAA,EACE;AAAA,OAUK;AAEP;AAAA,EAEE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP;AAAA,EAIE,SAAS;AAAA,OAgBJ;AAEP,SAAgC,0BAA0B;AAC1D,SAAS,yBAAkD;AAC3D;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAeP,SAAS,sBAIP,SAOA;AACA,QAAM,EAAE,KAAK,IAAI,QAAQ;AACzB,QAAM,gBAA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CAAC,GAC1D;AACrC,SAAO,OAAO,QAAQ,kBAAkB,EAAE;AAAA,IACxC,CAAC,sBAAsB,CAAC,KAAK,iBAAiB,MAAM;AAClD,UAAI;AACF,YAAI,CAAC,oBAAoB,iBAAiB,GAAG;AAC3C,gBAAM,IAAI;AAAA,YACR,yCAAyC,KAAK,UAAU,iBAAiB,CAAC;AAAA,UAC5E;AAAA,QACF;AACA,cAAM,sBAAsB,mBAAmB,iBAAiB;AAChE,eAAO,EAAE,GAAG,sBAAsB,CAAC,GAAG,GAAG,oBAAoB;AAAA,MAC/D,SAAS,KAAc;AACrB,cAAM,QACJ,eAAe,QACX,IAAI,MAAM,sCAAsC,GAAG,MAAM,IAAI,OAAO,IAAI;AAAA,UACtE,OAAO;AAAA,QACT,CAAC,IACD,IAAI,MAAM,sCAAsC,GAAG,qBAAqB,GAAG,EAAE;AAEnF,kBAAU,OAAO,EAAE,KAAK,kBAAkB,CAAC;AAE3C,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":["control","record"]}
1
+ {"version":3,"sources":["../../../../src/builder/serialization/control-serialization.ts"],"sourcesContent":["import {\n GapData,\n GapX,\n GapYDescriptor,\n GapYPropControllerData,\n ResponsiveLengthOptions,\n ResponsiveLengthPropControllerData,\n ResponsiveIconRadioGroup,\n ResponsiveNumber,\n ResponsiveSelect,\n type Descriptor,\n type PropDef,\n type OptionsType,\n} from '@makeswift/prop-controllers'\n\nimport {\n type Data,\n type Device,\n ControlDefinition as UnifiedControlDefinition,\n type SerializedRecord,\n type RichTextValue as RichTextControlValue,\n ShapeV2Definition,\n DeserializationPlugin,\n deserializeObject,\n} from '@makeswift/controls'\n\nimport {\n CheckboxDefinition,\n ColorDefinition,\n ComboboxDefinition,\n FontDefinition,\n GroupDefinition,\n IconRadioGroupDefinition,\n ImageDefinition,\n LinkDefinition,\n ListDefinition,\n NumberDefinition,\n RichTextV1Definition,\n RichTextV2Definition,\n SelectDefinition,\n ShapeDefinition,\n SlotDefinition,\n StyleDefinition,\n StyleV2Definition,\n TextAreaDefinition,\n TextInputDefinition,\n unstable_TypographyDefinition,\n} from '../../controls'\n\nimport {\n PanelDescriptor as PanelControl,\n PanelDescriptorType as PanelControlType,\n PanelDescriptorValueType as PanelControlValueType,\n Descriptor as ControlDefinition,\n} from '../../prop-controllers/descriptors'\n\nimport {\n DELETED_PROP_CONTROLLER_TYPES,\n ListDescriptor as ListControl,\n ListOptions as ListControlConfig,\n ListValue as ListControlValue,\n ShapeDescriptor as ShapeControl,\n ShapeValue as ShapeControlValue,\n TypeaheadDescriptor as TypeaheadControl,\n TypeaheadOptions as TypeaheadControlConfig,\n TypeaheadValue as TypeaheadControlValue,\n RichTextDescriptor as RichTextControl,\n} from '../../prop-controllers/deleted'\n\nimport {\n DeserializedFunction,\n deserializeFunction,\n isSerializedFunction,\n SerializedFunction,\n serializeFunction,\n} from './function-serialization'\n\nimport {\n LinkData,\n DateDescriptor as DateControl,\n DatePropControllerData,\n Types as PropControllerTypes,\n ImageDescriptor as ImageControl,\n ImageData as ImageControlValue,\n LinkDescriptor as LinkControl,\n LinkPropControllerData,\n ResponsiveLengthDescriptor,\n NumberOptions,\n NumberPropControllerData,\n NumberDescriptor,\n ResponsiveColorPropControllerData,\n ResponsiveColorDescriptor,\n CheckboxPropControllerData,\n CheckboxDescriptor as CheckboxControl,\n TextStyleDescriptor as TextStyleControl,\n TextStylePropControllerData,\n TextInputDescriptor as TextInputControl,\n} from '@makeswift/prop-controllers'\n\nimport { type LegacyDescriptor, isLegacyDescriptor } from '../../prop-controllers/descriptors'\nimport { deserializeRecord, type DeserializedRecord } from '@makeswift/controls'\nimport {\n ClientMessagePortSerializationVisitor,\n functionDeserializationPlugin,\n} from '../../controls/visitors/message-port-serializer'\n\ntype SerializedShapeControlConfig<T extends Record<string, SerializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: SerializedPanelControlValueType<T[K]> }\n}\n\ntype SerializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Shape\n options: SerializedShapeControlConfig<U>\n}\n\nfunction serializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, PanelControl>,\n>(\n control: ShapeControl<T, U>,\n): [\n SerializedShapeControl<\n T,\n { [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>> }\n >,\n Transferable[],\n] {\n const { type } = control.options\n const transferables: Transferable[] = []\n const serializedType = {} as {\n [K in keyof U]: SerializedPanelControl<PanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n const [serializedControl, serializedControlTransferables] = serializeControl(control)\n\n serializedType[key as keyof typeof type] = serializedControl as SerializedPanelControl\n transferables.push(...serializedControlTransferables)\n })\n\n // @ts-expect-error: preset types are incompatible\n return [{ ...control, options: { ...control.options, type: serializedType } }, transferables]\n}\n\ntype DeserializedShapeControlConfig<T extends Record<string, DeserializedPanelControl>> = {\n type: T\n preset?: { [K in keyof T]?: DeserializedPanelControlValueType<T[K]> }\n}\n\ntype DeserializedShapeControl<\n _T extends Record<string, Data>,\n U extends Record<string, DeserializedPanelControl>,\n> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Shape\n options: DeserializedShapeControlConfig<U>\n}\n\nfunction deserializeShapeControl<\n T extends Record<string, Data>,\n U extends Record<string, SerializedPanelControl>,\n>(\n control: SerializedShapeControl<T, U>,\n): DeserializedShapeControl<\n T,\n { [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>> }\n> {\n const { type } = control.options\n const deserializedType = {} as {\n [K in keyof U]: DeserializedPanelControl<SerializedPanelControlValueType<U[K]>>\n }\n\n Object.entries(type).forEach(([key, control]) => {\n deserializedType[key as keyof typeof type] = deserializeControl(\n control,\n ) as DeserializedPanelControl\n })\n\n // @ts-expect-error: preset types are incompatible\n return { ...control, options: { ...control.options, type: deserializedType } }\n}\n\ntype SerializedListControlConfig<T extends Data> = {\n type: SerializedPanelControl<T>\n label?: string\n getItemLabel?: SerializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\nexport type SerializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.List\n options: SerializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction serializeListControl<T extends Data>(\n control: ListControl<ListControlValue<T>>,\n): [SerializedListControl<ListControlValue<T>>, Transferable[]] {\n const { type, getItemLabel } = control.options\n const transferables: Transferable[] = []\n\n const [serializedType, serializedTypeTransferables] = serializeControl(type)\n const serializedGetItemLabel = getItemLabel && serializeFunction(getItemLabel)\n\n transferables.push(...serializedTypeTransferables)\n if (serializedGetItemLabel != null) transferables.push(serializedGetItemLabel)\n\n return [\n {\n ...control,\n options: {\n ...control.options,\n type: serializedType as SerializedPanelControl,\n getItemLabel: serializedGetItemLabel,\n },\n },\n transferables,\n ]\n}\n\ntype DeserializedListControlConfig<T extends Data> = {\n type: DeserializedPanelControl<T>\n label?: string\n getItemLabel?: DeserializedFunction<Exclude<ListControlConfig<T>['getItemLabel'], undefined>>\n preset?: ListControlValue<T>\n defaultValue?: ListControlValue<T>\n}\n\ntype DeserializedListControl<T extends ListControlValue = ListControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.List\n options: DeserializedListControlConfig<T extends ListControlValue<infer U> ? U : never>\n}\n\nfunction deserializeListControl<T extends Data>(\n serializedControl: SerializedListControl<ListControlValue<T>>,\n): DeserializedListControl<ListControlValue<T>> {\n const { type, getItemLabel } = serializedControl.options\n\n const deserializedType = deserializeControl(type) as DeserializedPanelControl\n const deserializedGetItemLabel = isSerializedFunction(getItemLabel) ? deserializeFunction(getItemLabel) : getItemLabel\n\n return {\n ...serializedControl,\n options: {\n ...serializedControl.options,\n type: deserializedType,\n getItemLabel: deserializedGetItemLabel,\n },\n }\n}\n\ntype SerializedTypeaheadControlConfig<T extends Data> = {\n getItems: SerializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\nexport type SerializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Typeahead\n options: SerializedTypeaheadControlConfig<T['value']>\n}\n\nfunction serializeTypeaheadControl<T extends Data>(\n control: TypeaheadControl<TypeaheadControlValue<T>>,\n): [SerializedTypeaheadControl<TypeaheadControlValue<T>>, Transferable[]] {\n const { getItems } = control.options\n\n const serializedGetItems = getItems && serializeFunction(getItems)\n\n return [\n { ...control, options: { ...control.options, getItems: serializedGetItems } },\n serializedGetItems == null ? [] : [serializedGetItems],\n ]\n}\n\ntype DeserializedTypeaheadControlConfig<T extends Data> = {\n getItems: DeserializedFunction<TypeaheadControlConfig<T>['getItems']>\n label?: string\n preset?: TypeaheadControlValue<T>\n defaultValue?: TypeaheadControlValue<T>\n}\n\ntype DeserializedTypeaheadControl<T extends TypeaheadControlValue = TypeaheadControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.Typeahead\n options: DeserializedTypeaheadControlConfig<T['value']>\n}\n\nfunction deserializeTypeaheadControl<T extends Data>(\n serializedControl: SerializedTypeaheadControl<TypeaheadControlValue<T>>,\n): DeserializedTypeaheadControl<TypeaheadControlValue<T>> {\n const { getItems } = serializedControl.options\n\n const deserializedGetItems = isSerializedFunction(getItems) ? deserializeFunction(getItems) : getItems\n\n return {\n ...serializedControl,\n options: { ...serializedControl.options, getItems: deserializedGetItems },\n }\n}\n\ntype SerializedConfig<T> =\n | T\n | SerializedFunction<(props: Record<string, unknown>, deviceMode: Device) => T>\n\nexport type DeserializedConfig<T> =\n | T\n | DeserializedFunction<(props: Record<string, unknown>, deviceMode: Device) => T>\n\ntype SerializedControlDef<P extends PropDef> = Descriptor<P> & {\n options: SerializedConfig<OptionsType<P>>\n}\n\nfunction serializeControlDef<P extends PropDef>(\n control: Descriptor<P>,\n): [SerializedControlDef<P>, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\nexport type DeserializedControlDef<P extends PropDef> = Descriptor<P> & {\n options: DeserializedConfig<OptionsType<P>>\n}\n\nfunction deserializeControlDef<P extends PropDef>(\n serializedControl: SerializedControlDef<P>,\n): DeserializedControlDef<P> {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype GapYControlConfig = {\n preset?: GapYPropControllerData\n label?: string\n defaultValue?: GapData\n min?: number\n max?: number\n step?: number\n hidden?: boolean\n}\n\ntype SerializedGapYControl<_T = GapYPropControllerData> = {\n type: typeof PropControllerTypes.GapY\n options: SerializedConfig<GapYControlConfig>\n}\n\nfunction serializeGapYControl(control: GapYDescriptor): [SerializedGapYControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedGapYControl<_T = GapYPropControllerData> = {\n type: typeof PropControllerTypes.GapY\n options: DeserializedConfig<GapYControlConfig>\n}\n\nfunction deserializeGapYControl(serializedControl: SerializedGapYControl): DeserializedGapYControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype CheckboxControlConfig = {\n preset?: CheckboxPropControllerData\n label: string\n hidden?: boolean\n}\n\ntype SerializedCheckboxControl<_T = CheckboxPropControllerData> = {\n type: typeof PropControllerTypes.Checkbox\n options: SerializedConfig<CheckboxControlConfig>\n}\n\nfunction serializeCheckboxControl(\n control: CheckboxControl,\n): [SerializedCheckboxControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedCheckboxControl<_T = CheckboxPropControllerData> = {\n type: typeof PropControllerTypes.Checkbox\n options: DeserializedConfig<CheckboxControlConfig>\n}\n\nfunction deserializeCheckboxControl(\n serializedControl: SerializedCheckboxControl,\n): DeserializedCheckboxControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype ResponsiveColorControlConfig = { label?: string; placeholder?: string; hidden?: boolean }\n\ntype SerializedResponsiveColorControl<_T = ResponsiveColorPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveColor\n options: SerializedConfig<ResponsiveColorControlConfig>\n}\n\nfunction serializeResponsiveColorControl(\n control: ResponsiveColorDescriptor,\n): [SerializedResponsiveColorControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedResponsiveColorControl<_T = ResponsiveColorPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveColor\n options: DeserializedConfig<ResponsiveColorControlConfig>\n}\n\nfunction deserializeResponsiveColorControl(\n serializedControl: SerializedResponsiveColorControl,\n): DeserializedResponsiveColorControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\ntype SerializedNumberControl<_T = NumberPropControllerData> = {\n type: typeof PropControllerTypes.Number\n options: SerializedConfig<NumberOptions>\n}\n\nfunction serializeNumberControl(\n control: NumberDescriptor,\n): [SerializedNumberControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedNumberControl<_T = NumberPropControllerData> = {\n type: typeof PropControllerTypes.Number\n options: DeserializedConfig<NumberOptions>\n}\n\nfunction deserializeNumberControl(\n serializedControl: SerializedNumberControl,\n): DeserializedNumberControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype DateControlConfig = { preset?: DatePropControllerData }\n\ntype SerializedDateControl<_T = DatePropControllerData> = {\n type: typeof PropControllerTypes.Date\n options: SerializedConfig<DateControlConfig>\n}\n\nfunction serializeDateControl(control: DateControl): [SerializedDateControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedDateControl<_T = DatePropControllerData> = {\n type: typeof PropControllerTypes.Date\n options: DeserializedConfig<DateControlConfig>\n}\n\nfunction deserializeDateControl(serializedControl: SerializedDateControl): DeserializedDateControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype LinkControlConfig = {\n preset?: LinkPropControllerData\n label?: string\n defaultValue?: LinkPropControllerData\n options?: { value: LinkData['type']; label: string }[]\n hidden?: boolean\n}\n\ntype SerializedLinkControl<_T = LinkPropControllerData> = {\n type: typeof PropControllerTypes.Link\n options: SerializedConfig<LinkControlConfig>\n}\n\nfunction serializeLinkControl(control: LinkControl): [SerializedLinkControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedLinkControl<_T = LinkPropControllerData> = {\n type: typeof PropControllerTypes.Link\n options: DeserializedConfig<LinkControlConfig>\n}\n\nfunction deserializeLinkControl(serializedControl: SerializedLinkControl): DeserializedLinkControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype TextInputControlConfig = { label?: string; placeholder?: string; hidden?: boolean }\n\ntype TextInputControlValue = string\n\ntype SerializedTextInputControl<_T = TextInputControlValue> = {\n type: typeof PropControllerTypes.TextInput\n options: SerializedConfig<TextInputControlConfig>\n}\n\nfunction serializeTextInputControl(\n control: TextInputControl,\n): [SerializedTextInputControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedTextInputControl<_T = TextInputControlValue> = {\n type: typeof PropControllerTypes.TextInput\n options: DeserializedConfig<TextInputControlConfig>\n}\n\nfunction deserializeTextInputControl(\n serializedControl: SerializedTextInputControl,\n): DeserializedTextInputControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype SerializedResponsiveLengthControl<_T = ResponsiveLengthPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveLength\n options: SerializedConfig<ResponsiveLengthOptions>\n}\n\nfunction serializeResponsiveLengthControl(\n control: ResponsiveLengthDescriptor,\n): [SerializedResponsiveLengthControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedResponsiveLengthControl<_T = ResponsiveLengthPropControllerData> = {\n type: typeof PropControllerTypes.ResponsiveLength\n options: DeserializedConfig<ResponsiveLengthOptions>\n}\n\nfunction deserializeResponsiveLengthControl(\n serializedControl: SerializedResponsiveLengthControl,\n): DeserializedResponsiveLengthControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype SerializedTextStyleControl<_T = TextStylePropControllerData> = {\n type: typeof PropControllerTypes.TextStyle\n options: SerializedConfig<TextStyleControlConfig>\n}\n\nfunction serializeTextStyleControl(\n control: TextStyleControl,\n): [SerializedTextStyleControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype TextStyleControlConfig = {\n preset?: TextStylePropControllerData\n label?: string\n hidden?: boolean\n}\n\ntype DeserializedTextStyleControl<_T = TextStylePropControllerData> = {\n type: typeof PropControllerTypes.TextStyle\n options: DeserializedConfig<TextStyleControlConfig>\n}\n\nfunction deserializeTextStyleControl(\n serializedControl: SerializedTextStyleControl,\n): DeserializedTextStyleControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype ImageControlConfig = { label?: string; hidden?: boolean }\n\ntype SerializedImageControl<_T = ImageControlValue> = {\n type: typeof PropControllerTypes.Image\n options: SerializedConfig<ImageControlConfig>\n}\n\nfunction serializeImageControl(control: ImageControl): [SerializedImageControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedImageControl<_T = ImageControlValue> = {\n type: typeof PropControllerTypes.Image\n options: DeserializedConfig<ImageControlConfig>\n}\n\nfunction deserializeImageControl(\n serializedControl: SerializedImageControl,\n): DeserializedImageControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\ntype RichTextControlConfig = { preset?: RichTextControlValue }\n\ntype SerializedRichTextControl<_T = RichTextControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.RichText\n options: SerializedConfig<RichTextControlConfig>\n}\n\nfunction serializeRichTextControl(\n control: RichTextControl,\n): [SerializedRichTextControl, Transferable[]] {\n const { options } = control\n\n if (typeof options !== 'function') return [{ ...control, options }, []]\n\n const serializedOptions = serializeFunction(options)\n\n return [{ ...control, options: serializedOptions }, [serializedOptions]]\n}\n\ntype DeserializedRichTextControl<_T = RichTextControlValue> = {\n type: typeof DELETED_PROP_CONTROLLER_TYPES.RichText\n options: DeserializedConfig<RichTextControlConfig>\n}\n\nfunction deserializeRichTextControl(\n serializedControl: SerializedRichTextControl,\n): DeserializedRichTextControl {\n const { options } = serializedControl\n\n if (!isSerializedFunction(options)) return { ...serializedControl, options }\n\n const deserializedOptions = deserializeFunction(options)\n\n return { ...serializedControl, options: deserializedOptions }\n}\n\nexport type SerializedLegacyControl<T extends Data = Data> =\n | Exclude<\n LegacyDescriptor<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | Descriptor<typeof GapX>\n | GapYDescriptor<T>\n | Descriptor<typeof ResponsiveNumber>\n | CheckboxControl<T>\n | ResponsiveColorDescriptor<T>\n | NumberDescriptor<T>\n | Descriptor<typeof ResponsiveIconRadioGroup>\n | Descriptor<typeof ResponsiveSelect>\n | ResponsiveLengthDescriptor<T>\n | DateControl<T>\n | LinkControl<T>\n | TextInputControl<T>\n | TextStyleControl<T>\n | ImageControl<T>\n | RichTextControl<T>\n >\n | SerializedListControl<T extends ListControlValue ? T : ListControlValue>\n | SerializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | SerializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | SerializedControlDef<typeof GapX>\n | SerializedGapYControl<T>\n | SerializedControlDef<typeof ResponsiveNumber>\n | SerializedCheckboxControl<T>\n | SerializedResponsiveColorControl<T>\n | SerializedNumberControl<T>\n | SerializedControlDef<typeof ResponsiveIconRadioGroup>\n | SerializedControlDef<typeof ResponsiveSelect>\n | SerializedResponsiveLengthControl<T>\n | SerializedDateControl<T>\n | SerializedLinkControl<T>\n | SerializedTextInputControl<T>\n | SerializedTextStyleControl<T>\n | SerializedImageControl<T>\n | SerializedRichTextControl<T>\n\nexport type SerializedControl<T extends Data = Data> = SerializedLegacyControl<T> | SerializedRecord\n\ntype SerializedPanelControl<T extends Data = Data> = Extract<\n SerializedControl<T>,\n { type: PanelControlType }\n>\n\ntype SerializedPanelControlValueType<T extends SerializedPanelControl> =\n T extends SerializedPanelControl<infer U> ? U : never\n\nexport type DeserializedLegacyControl<T extends Data = Data> =\n | Exclude<\n LegacyDescriptor<T>,\n | ListControl<T extends ListControlValue ? T : ListControlValue>\n | ShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | TypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | Descriptor<typeof GapX>\n | GapYDescriptor<T>\n | Descriptor<typeof ResponsiveNumber>\n | CheckboxControl<T>\n | ResponsiveColorDescriptor<T>\n | NumberDescriptor<T>\n | Descriptor<typeof ResponsiveIconRadioGroup>\n | Descriptor<typeof ResponsiveSelect>\n | ResponsiveLengthDescriptor<T>\n | DateControl<T>\n | LinkControl<T>\n | TextInputControl<T>\n | TextStyleControl<T>\n | ImageControl<T>\n | RichTextControl<T>\n >\n | DeserializedListControl<T extends ListControlValue ? T : ListControlValue>\n | DeserializedShapeControl<T extends ShapeControlValue ? T : ShapeControlValue, any>\n | DeserializedTypeaheadControl<T extends TypeaheadControlValue ? T : TypeaheadControlValue>\n | DeserializedControlDef<typeof GapX>\n | DeserializedGapYControl<T>\n | DeserializedControlDef<typeof ResponsiveNumber>\n | DeserializedCheckboxControl<T>\n | DeserializedResponsiveColorControl<T>\n | DeserializedNumberControl<T>\n | DeserializedControlDef<typeof ResponsiveIconRadioGroup>\n | DeserializedControlDef<typeof ResponsiveSelect>\n | DeserializedResponsiveLengthControl<T>\n | DeserializedDateControl<T>\n | DeserializedLinkControl<T>\n | DeserializedTextInputControl<T>\n | DeserializedTextStyleControl<T>\n | DeserializedImageControl<T>\n | DeserializedRichTextControl<T>\n\nexport type DeserializedControl<T extends Data = Data> =\n | DeserializedLegacyControl<T>\n | UnifiedControlDefinition\n\nexport type DeserializedPanelControl<T extends Data = Data> = Extract<\n DeserializedControl<T>,\n { type: PanelControlType }\n>\n\ntype DeserializedPanelControlValueType<T extends DeserializedPanelControl> =\n T extends DeserializedPanelControl<infer U> ? U : never\n\nexport function serializeControl<T extends Data>(\n control: ControlDefinition<T>,\n): [SerializedControl<T>, Transferable[]] {\n if (isLegacyDescriptor(control)) {\n return serializeLegacyControl(control)\n }\n\n const messagePortVisitor = new ClientMessagePortSerializationVisitor()\n const serializedControl = control.accept(messagePortVisitor)\n return [serializedControl, messagePortVisitor.getTransferables()]\n}\n\nexport function isSerializedControl(control: unknown): control is SerializedControl {\n return (\n control != null &&\n typeof control === 'object' &&\n 'type' in control &&\n typeof control.type === 'string'\n )\n}\n\nfunction serializeLegacyControl<T extends Data>(\n control: LegacyDescriptor<T>,\n): [SerializedControl<T>, Transferable[]] {\n switch (control.type) {\n case PropControllerTypes.Checkbox:\n return serializeCheckboxControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.List:\n return serializeListControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.Shape:\n return serializeShapeControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.Typeahead:\n return serializeTypeaheadControl(control) as [SerializedControl<T>, Transferable[]]\n\n case PropControllerTypes.GapX:\n return serializeControlDef<typeof GapX>(control)\n\n case PropControllerTypes.GapY:\n return serializeGapYControl(control)\n\n case PropControllerTypes.ResponsiveColor:\n return serializeResponsiveColorControl(control)\n\n case PropControllerTypes.ResponsiveNumber:\n return serializeControlDef<typeof ResponsiveNumber>(control)\n\n case PropControllerTypes.Number:\n return serializeNumberControl(control)\n\n case PropControllerTypes.ResponsiveIconRadioGroup:\n return serializeControlDef<typeof ResponsiveIconRadioGroup>(control)\n\n case PropControllerTypes.ResponsiveSelect:\n return serializeControlDef<typeof ResponsiveSelect>(control)\n\n case PropControllerTypes.ResponsiveLength:\n return serializeResponsiveLengthControl(control)\n\n case PropControllerTypes.Date:\n return serializeDateControl(control)\n\n case PropControllerTypes.Link:\n return serializeLinkControl(control)\n\n case PropControllerTypes.TextInput:\n return serializeTextInputControl(control)\n\n case PropControllerTypes.TextStyle:\n return serializeTextStyleControl(control)\n\n case PropControllerTypes.Image:\n return serializeImageControl(control)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return serializeRichTextControl(control)\n\n default:\n return [control, []]\n }\n}\n\nfunction isSerializedLegacyControl<T extends Data>(\n control: SerializedControl<T>,\n): control is SerializedLegacyControl<T> {\n return 'options' in control\n}\n\nexport function deserializeLegacyControl<T extends Data>(\n serializedControl: SerializedLegacyControl<T>,\n): DeserializedControl<T> {\n switch (serializedControl.type) {\n case PropControllerTypes.Checkbox:\n return deserializeCheckboxControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.List:\n return deserializeListControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.Shape:\n return deserializeShapeControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.Typeahead:\n return deserializeTypeaheadControl(serializedControl)\n\n case PropControllerTypes.GapX:\n return deserializeControlDef<typeof GapX>(serializedControl)\n\n case PropControllerTypes.GapY:\n return deserializeGapYControl(serializedControl)\n\n case PropControllerTypes.ResponsiveColor:\n return deserializeResponsiveColorControl(serializedControl)\n\n case PropControllerTypes.ResponsiveNumber:\n return deserializeControlDef<typeof ResponsiveNumber>(serializedControl)\n\n case PropControllerTypes.Number:\n return deserializeNumberControl(serializedControl)\n\n case PropControllerTypes.ResponsiveIconRadioGroup:\n return deserializeControlDef<typeof ResponsiveIconRadioGroup>(serializedControl)\n\n case PropControllerTypes.ResponsiveSelect:\n return deserializeControlDef<typeof ResponsiveSelect>(serializedControl)\n\n case PropControllerTypes.ResponsiveLength:\n return deserializeResponsiveLengthControl(serializedControl)\n\n case PropControllerTypes.Date:\n return deserializeDateControl(serializedControl)\n\n case PropControllerTypes.Link:\n return deserializeLinkControl(serializedControl)\n\n case PropControllerTypes.TextInput:\n return deserializeTextInputControl(serializedControl)\n\n case PropControllerTypes.TextStyle:\n return deserializeTextStyleControl(serializedControl)\n\n case PropControllerTypes.Image:\n return deserializeImageControl(serializedControl)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return deserializeRichTextControl(serializedControl)\n\n default:\n return serializedControl\n }\n}\n\nexport type DeserializeControlOptions = {\n plugins?: DeserializationPlugin<any>[]\n}\n\n\nexport function deserializeControl<T extends Data>(\n serializedControl: SerializedControl<T>,\n options?: DeserializeControlOptions,\n): DeserializedControl<T> {\n if (isSerializedLegacyControl(serializedControl)) {\n // Parity with controls deserialization logic below: \"preprocess\" serialized \n // legacy controls if the caller provided custom deserialization plugins\n const record = options?.plugins ? deserializeObject(serializedControl, options?.plugins) : serializedControl\n return deserializeLegacyControl(record as SerializedLegacyControl<T>)\n }\n\n const plugins = [functionDeserializationPlugin, ...(options?.plugins ?? [])]\n\n return deserializeUnifiedControlDef(\n deserializeRecord(serializedControl, plugins)\n )\n}\n\nexport function deserializeUnifiedControlDef(record: DeserializedRecord): UnifiedControlDefinition {\n type DeserializeMethod = (data: DeserializedRecord) => UnifiedControlDefinition\n const deserializeMethod: Record<string, DeserializeMethod> = {\n [CheckboxDefinition.type]: CheckboxDefinition.deserialize,\n [ColorDefinition.type]: ColorDefinition.deserialize,\n [ComboboxDefinition.type]: ComboboxDefinition.deserialize,\n [FontDefinition.type]: FontDefinition.deserialize,\n [GroupDefinition.type]: record =>\n GroupDefinition.deserialize(record, deserializeUnifiedControlDef),\n [IconRadioGroupDefinition.type]: IconRadioGroupDefinition.deserialize,\n [ImageDefinition.type]: ImageDefinition.deserialize,\n [LinkDefinition.type]: LinkDefinition.deserialize,\n [ListDefinition.type]: record =>\n ListDefinition.deserialize(record, deserializeUnifiedControlDef),\n [NumberDefinition.type]: NumberDefinition.deserialize,\n [RichTextV1Definition.type]: RichTextV1Definition.deserialize,\n [RichTextV2Definition.type]: record =>\n RichTextV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [SelectDefinition.type]: SelectDefinition.deserialize,\n [ShapeDefinition.type]: record =>\n ShapeDefinition.deserialize(record, deserializeUnifiedControlDef),\n [ShapeV2Definition.type]: record =>\n ShapeV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [SlotDefinition.type]: SlotDefinition.deserialize,\n [StyleDefinition.type]: StyleDefinition.deserialize,\n [StyleV2Definition.type]: record =>\n StyleV2Definition.deserialize(record, deserializeUnifiedControlDef),\n [TextAreaDefinition.type]: TextAreaDefinition.deserialize,\n [TextInputDefinition.type]: TextInputDefinition.deserialize,\n [unstable_TypographyDefinition.type]: unstable_TypographyDefinition.deserialize,\n } as const\n\n const deserialize = deserializeMethod[record.type] ?? null\n if (deserialize == null) {\n throw new Error(`Unknown control type: ${record.type}`)\n }\n\n return deserialize(record)\n}\n\nexport function serializeControls(\n controls: Record<string, ControlDefinition>,\n): [Record<string, SerializedControl>, Transferable[]] {\n return Object.entries(controls).reduce(\n ([accControls, accTransferables], [key, control]) => {\n const [serializedControl, transferables] = serializeControl(control)\n\n return [{ ...accControls, [key]: serializedControl }, [...accTransferables, ...transferables]]\n },\n [{}, []] as [Record<string, SerializedControl>, Transferable[]],\n )\n}\n\nexport type DeserializeControlsOptions = { onError?: (err: Error, context: { key: string; serializedControl: unknown }) => void } & Pick<DeserializeControlOptions, 'plugins'>\n\nexport function deserializeControls(\n serializedControls: Record<string, unknown>,\n {\n onError,\n plugins,\n }: DeserializeControlsOptions = {},\n): Record<string, DeserializedControl> {\n return Object.entries(serializedControls).reduce(\n (deserializedControls, [key, serializedControl]) => {\n try {\n if (!isSerializedControl(serializedControl)) {\n throw new Error(\n `Expected serialized control data, got ${JSON.stringify(serializedControl)}`,\n )\n }\n const deserializedControl = deserializeControl(serializedControl, { plugins })\n return { ...deserializedControls, [key]: deserializedControl }\n } catch (err: unknown) {\n const error =\n err instanceof Error\n ? new Error(`Could not deserialize control for \"${key}\": ${err.message}`, {\n cause: err,\n })\n : new Error(`Could not deserialize control for \"${key}\", unknown error: ${err}`)\n\n onError?.(error, { key, serializedControl })\n\n return deserializedControls\n }\n },\n {} as Record<string, DeserializedControl>,\n )\n}\n"],"mappings":"AAeA;AAAA,EAME;AAAA,EAEA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP;AAAA,EACE;AAAA,OAUK;AAEP;AAAA,EAEE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP;AAAA,EAIE,SAAS;AAAA,OAgBJ;AAEP,SAAgC,0BAA0B;AAC1D,SAAS,yBAAkD;AAC3D;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAeP,SAAS,sBAIP,SAOA;AACA,QAAM,EAAE,KAAK,IAAI,QAAQ;AACzB,QAAM,gBAAgC,CAAC;AACvC,QAAM,iBAAiB,CAAC;AAIxB,SAAO,QAAQ,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAKA,QAAO,MAAM;AAC/C,UAAM,CAAC,mBAAmB,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BACA;AAAA,EACE;AAAA,EACA;AACF,IAAgC,CAAC,GACI;AACrC,SAAO,OAAO,QAAQ,kBAAkB,EAAE;AAAA,IACxC,CAAC,sBAAsB,CAAC,KAAK,iBAAiB,MAAM;AAClD,UAAI;AACF,YAAI,CAAC,oBAAoB,iBAAiB,GAAG;AAC3C,gBAAM,IAAI;AAAA,YACR,yCAAyC,KAAK,UAAU,iBAAiB,CAAC;AAAA,UAC5E;AAAA,QACF;AACA,cAAM,sBAAsB,mBAAmB,mBAAmB,EAAE,QAAQ,CAAC;AAC7E,eAAO,EAAE,GAAG,sBAAsB,CAAC,GAAG,GAAG,oBAAoB;AAAA,MAC/D,SAAS,KAAc;AACrB,cAAM,QACJ,eAAe,QACX,IAAI,MAAM,sCAAsC,GAAG,MAAM,IAAI,OAAO,IAAI;AAAA,UACtE,OAAO;AAAA,QACT,CAAC,IACD,IAAI,MAAM,sCAAsC,GAAG,qBAAqB,GAAG,EAAE;AAEnF,kBAAU,OAAO,EAAE,KAAK,kBAAkB,CAAC;AAE3C,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":["control","record"]}
@@ -179,7 +179,8 @@ const getFontsAPISchema = z.object({
179
179
  googleFonts: z.array(z.object({
180
180
  family: z.string(),
181
181
  variants: z.array(z.string())
182
- }))
182
+ })),
183
+ siteId: z.string()
183
184
  });
184
185
  class MakeswiftClient {
185
186
  graphqlClient;
@@ -194,7 +195,7 @@ Received "${apiKey}" instead.`
194
195
  }
195
196
  this.apiKey = apiKey;
196
197
  this.graphqlClient = new GraphQLClient(new URL("graphql", runtime.apiOrigin).href, {
197
- "makeswift-runtime-version": "0.28.0-canary.2"
198
+ "makeswift-runtime-version": "0.28.0"
198
199
  });
199
200
  this.runtime = runtime;
200
201
  }
@@ -206,7 +207,7 @@ Received "${apiKey}" instead.`
206
207
  const requestHeaders = new Headers({
207
208
  "x-api-key": this.apiKey,
208
209
  "makeswift-site-api-key": this.apiKey,
209
- "makeswift-runtime-version": "0.28.0-canary.2"
210
+ "makeswift-runtime-version": "0.28.0"
210
211
  });
211
212
  if (siteVersion?.token) {
212
213
  requestUrl.searchParams.set("version", siteVersion.version);
@@ -664,7 +665,7 @@ Received "${apiKey}" instead.`
664
665
  headers: {
665
666
  "x-api-key": this.apiKey,
666
667
  "makeswift-site-api-key": this.apiKey,
667
- "makeswift-runtime-version": "0.28.0-canary.2",
668
+ "makeswift-runtime-version": "0.28.0",
668
669
  "content-type": "application/json"
669
670
  },
670
671
  body: JSON.stringify({ token }),