@builder.io/sdk-solid 0.12.7 → 0.12.8

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.
@@ -6185,13 +6185,6 @@ async function fetchEntries(options) {
6185
6185
  }
6186
6186
  var getAllContent = fetchEntries;
6187
6187
 
6188
- // src/functions/is-from-trusted-host.ts
6189
- var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
6190
- function isFromTrustedHost(trustedHosts, e) {
6191
- const url = new URL(e.origin), hostname = url.hostname;
6192
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
6193
- }
6194
-
6195
6188
  // src/functions/is-previewing.ts
6196
6189
  function isPreviewing() {
6197
6190
  if (!isBrowser()) {
@@ -6439,8 +6432,15 @@ var getInteractionPropertiesForEvent = (event) => {
6439
6432
  };
6440
6433
  };
6441
6434
 
6435
+ // src/functions/is-from-trusted-host.ts
6436
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
6437
+ function isFromTrustedHost(trustedHosts, e) {
6438
+ const url = new URL(e.origin), hostname = url.hostname;
6439
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
6440
+ }
6441
+
6442
6442
  // src/constants/sdk-version.ts
6443
- var SDK_VERSION = "0.12.7";
6443
+ var SDK_VERSION = "0.12.8";
6444
6444
 
6445
6445
  // src/functions/register.ts
6446
6446
  var registry = {};
@@ -6576,6 +6576,66 @@ var setupBrowserForEditing = (options = {}) => {
6576
6576
  }
6577
6577
  };
6578
6578
 
6579
+ // src/helpers/subscribe-to-editor.ts
6580
+ var createEditorListener = ({
6581
+ model,
6582
+ trustedHosts,
6583
+ callbacks
6584
+ }) => {
6585
+ return (event) => {
6586
+ if (!isFromTrustedHost(trustedHosts, event)) {
6587
+ return;
6588
+ }
6589
+ const {
6590
+ data
6591
+ } = event;
6592
+ if (data) {
6593
+ switch (data.type) {
6594
+ case "builder.configureSdk": {
6595
+ callbacks.configureSdk(data.data);
6596
+ break;
6597
+ }
6598
+ case "builder.triggerAnimation": {
6599
+ callbacks.animation(data.data);
6600
+ break;
6601
+ }
6602
+ case "builder.contentUpdate": {
6603
+ const messageContent = data.data;
6604
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
6605
+ const contentData = messageContent.data;
6606
+ if (key === model) {
6607
+ callbacks.contentUpdate(contentData);
6608
+ }
6609
+ break;
6610
+ }
6611
+ }
6612
+ }
6613
+ };
6614
+ };
6615
+ var subscribeToEditor = (model, callback, options) => {
6616
+ if (!isBrowser) {
6617
+ logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
6618
+ return () => {
6619
+ };
6620
+ }
6621
+ setupBrowserForEditing();
6622
+ const listener = createEditorListener({
6623
+ callbacks: {
6624
+ contentUpdate: callback,
6625
+ animation: () => {
6626
+ },
6627
+ configureSdk: () => {
6628
+ }
6629
+ },
6630
+ model,
6631
+ trustedHosts: options?.trustedHosts
6632
+ });
6633
+ window.addEventListener("message", listener);
6634
+ return () => {
6635
+ window.removeEventListener("message", listener);
6636
+ };
6637
+ };
6638
+
6579
6639
  // src/components/content/components/enable-editor.tsx
6580
6640
  function EnableEditor(props) {
6581
6641
  const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
@@ -6621,14 +6681,11 @@ function EnableEditor(props) {
6621
6681
  }));
6622
6682
  }
6623
6683
  function processMessage(event) {
6624
- if (!isFromTrustedHost(props.trustedHosts, event)) {
6625
- return;
6626
- }
6627
- const { data } = event;
6628
- if (data) {
6629
- switch (data.type) {
6630
- case "builder.configureSdk": {
6631
- const messageContent = data.data;
6684
+ return createEditorListener({
6685
+ model: props.model,
6686
+ trustedHosts: props.trustedHosts,
6687
+ callbacks: {
6688
+ configureSdk: (messageContent) => {
6632
6689
  const { breakpoints, contentId } = messageContent;
6633
6690
  if (!contentId || contentId !== props.builderContextSignal.content?.id) {
6634
6691
  return;
@@ -6639,26 +6696,18 @@ function EnableEditor(props) {
6639
6696
  breakpoints
6640
6697
  }
6641
6698
  });
6642
- }
6643
- setForceReRenderCount(forceReRenderCount() + 1);
6644
- break;
6645
- }
6646
- case "builder.triggerAnimation": {
6647
- triggerAnimation(data.data);
6648
- break;
6649
- }
6650
- case "builder.contentUpdate": {
6651
- const messageContent = data.data;
6652
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
6653
- const contentData = messageContent.data;
6654
- if (key === props.model) {
6655
- mergeNewContent(contentData);
6656
6699
  setForceReRenderCount(forceReRenderCount() + 1);
6657
6700
  }
6658
- break;
6701
+ },
6702
+ animation: (animation) => {
6703
+ triggerAnimation(animation);
6704
+ },
6705
+ contentUpdate: (newContent) => {
6706
+ mergeNewContent(newContent);
6707
+ setForceReRenderCount(forceReRenderCount() + 1);
6659
6708
  }
6660
6709
  }
6661
- }
6710
+ })(event);
6662
6711
  }
6663
6712
  function evaluateJsCode() {
6664
6713
  const jsCode = props.builderContextSignal.content?.data?.jsCode;
@@ -7351,5 +7400,6 @@ export {
7351
7400
  isPreviewing,
7352
7401
  register,
7353
7402
  setEditorSettings,
7403
+ subscribeToEditor,
7354
7404
  track
7355
7405
  };
package/lib/node/dev.js CHANGED
@@ -3492,13 +3492,6 @@ async function fetchEntries(options) {
3492
3492
  }
3493
3493
  var getAllContent = fetchEntries;
3494
3494
 
3495
- // src/functions/is-from-trusted-host.ts
3496
- var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
3497
- function isFromTrustedHost(trustedHosts, e) {
3498
- const url = new URL(e.origin), hostname = url.hostname;
3499
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3500
- }
3501
-
3502
3495
  // src/functions/is-previewing.ts
3503
3496
  function isPreviewing() {
3504
3497
  if (!isBrowser()) {
@@ -3749,8 +3742,15 @@ var getInteractionPropertiesForEvent = (event) => {
3749
3742
  };
3750
3743
  };
3751
3744
 
3745
+ // src/functions/is-from-trusted-host.ts
3746
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
3747
+ function isFromTrustedHost(trustedHosts, e) {
3748
+ const url = new URL(e.origin), hostname = url.hostname;
3749
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3750
+ }
3751
+
3752
3752
  // src/constants/sdk-version.ts
3753
- var SDK_VERSION = "0.12.7";
3753
+ var SDK_VERSION = "0.12.8";
3754
3754
 
3755
3755
  // src/functions/register.ts
3756
3756
  var registry = {};
@@ -3887,6 +3887,66 @@ var setupBrowserForEditing = (options = {}) => {
3887
3887
  }
3888
3888
  };
3889
3889
 
3890
+ // src/helpers/subscribe-to-editor.ts
3891
+ var createEditorListener = ({
3892
+ model,
3893
+ trustedHosts,
3894
+ callbacks
3895
+ }) => {
3896
+ return (event) => {
3897
+ if (!isFromTrustedHost(trustedHosts, event)) {
3898
+ return;
3899
+ }
3900
+ const {
3901
+ data
3902
+ } = event;
3903
+ if (data) {
3904
+ switch (data.type) {
3905
+ case "builder.configureSdk": {
3906
+ callbacks.configureSdk(data.data);
3907
+ break;
3908
+ }
3909
+ case "builder.triggerAnimation": {
3910
+ callbacks.animation(data.data);
3911
+ break;
3912
+ }
3913
+ case "builder.contentUpdate": {
3914
+ const messageContent = data.data;
3915
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3916
+ const contentData = messageContent.data;
3917
+ if (key === model) {
3918
+ callbacks.contentUpdate(contentData);
3919
+ }
3920
+ break;
3921
+ }
3922
+ }
3923
+ }
3924
+ };
3925
+ };
3926
+ var subscribeToEditor = (model, callback, options) => {
3927
+ if (!isBrowser) {
3928
+ logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
3929
+ return () => {
3930
+ };
3931
+ }
3932
+ setupBrowserForEditing();
3933
+ const listener = createEditorListener({
3934
+ callbacks: {
3935
+ contentUpdate: callback,
3936
+ animation: () => {
3937
+ },
3938
+ configureSdk: () => {
3939
+ }
3940
+ },
3941
+ model,
3942
+ trustedHosts: options?.trustedHosts
3943
+ });
3944
+ window.addEventListener("message", listener);
3945
+ return () => {
3946
+ window.removeEventListener("message", listener);
3947
+ };
3948
+ };
3949
+
3890
3950
  // src/components/content/components/enable-editor.tsx
3891
3951
  function EnableEditor(props) {
3892
3952
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
@@ -3930,16 +3990,11 @@ function EnableEditor(props) {
3930
3990
  }));
3931
3991
  }
3932
3992
  function processMessage(event) {
3933
- if (!isFromTrustedHost(props.trustedHosts, event)) {
3934
- return;
3935
- }
3936
- const {
3937
- data
3938
- } = event;
3939
- if (data) {
3940
- switch (data.type) {
3941
- case "builder.configureSdk": {
3942
- const messageContent = data.data;
3993
+ return createEditorListener({
3994
+ model: props.model,
3995
+ trustedHosts: props.trustedHosts,
3996
+ callbacks: {
3997
+ configureSdk: (messageContent) => {
3943
3998
  const {
3944
3999
  breakpoints,
3945
4000
  contentId
@@ -3953,26 +4008,18 @@ function EnableEditor(props) {
3953
4008
  breakpoints
3954
4009
  }
3955
4010
  });
3956
- }
3957
- setForceReRenderCount(forceReRenderCount() + 1);
3958
- break;
3959
- }
3960
- case "builder.triggerAnimation": {
3961
- triggerAnimation(data.data);
3962
- break;
3963
- }
3964
- case "builder.contentUpdate": {
3965
- const messageContent = data.data;
3966
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3967
- const contentData = messageContent.data;
3968
- if (key === props.model) {
3969
- mergeNewContent(contentData);
3970
4011
  setForceReRenderCount(forceReRenderCount() + 1);
3971
4012
  }
3972
- break;
4013
+ },
4014
+ animation: (animation) => {
4015
+ triggerAnimation(animation);
4016
+ },
4017
+ contentUpdate: (newContent) => {
4018
+ mergeNewContent(newContent);
4019
+ setForceReRenderCount(forceReRenderCount() + 1);
3973
4020
  }
3974
4021
  }
3975
- }
4022
+ })(event);
3976
4023
  }
3977
4024
  function evaluateJsCode() {
3978
4025
  const jsCode = props.builderContextSignal.content?.data?.jsCode;
@@ -4816,4 +4863,4 @@ var fetchBuilderProps = async (_args) => {
4816
4863
  };
4817
4864
  };
4818
4865
 
4819
- export { blocks_default as Blocks, button_default as Button, columns_default as Columns, content_variants_default as Content, fragment_default as Fragment, image_default as Image, RenderBlocks, RenderContent, section_default as Section, symbol_default as Symbol, text_default as Text, video_default as Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, track };
4866
+ export { blocks_default as Blocks, button_default as Button, columns_default as Columns, content_variants_default as Content, fragment_default as Fragment, image_default as Image, RenderBlocks, RenderContent, section_default as Section, symbol_default as Symbol, text_default as Text, video_default as Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, subscribeToEditor, track };
package/lib/node/dev.jsx CHANGED
@@ -3168,13 +3168,6 @@ async function fetchEntries(options) {
3168
3168
  }
3169
3169
  var getAllContent = fetchEntries;
3170
3170
 
3171
- // src/functions/is-from-trusted-host.ts
3172
- var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
3173
- function isFromTrustedHost(trustedHosts, e) {
3174
- const url = new URL(e.origin), hostname = url.hostname;
3175
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3176
- }
3177
-
3178
3171
  // src/functions/is-previewing.ts
3179
3172
  function isPreviewing() {
3180
3173
  if (!isBrowser()) {
@@ -3425,8 +3418,15 @@ var getInteractionPropertiesForEvent = (event) => {
3425
3418
  };
3426
3419
  };
3427
3420
 
3421
+ // src/functions/is-from-trusted-host.ts
3422
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
3423
+ function isFromTrustedHost(trustedHosts, e) {
3424
+ const url = new URL(e.origin), hostname = url.hostname;
3425
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3426
+ }
3427
+
3428
3428
  // src/constants/sdk-version.ts
3429
- var SDK_VERSION = "0.12.7";
3429
+ var SDK_VERSION = "0.12.8";
3430
3430
 
3431
3431
  // src/functions/register.ts
3432
3432
  var registry = {};
@@ -3563,6 +3563,66 @@ var setupBrowserForEditing = (options = {}) => {
3563
3563
  }
3564
3564
  };
3565
3565
 
3566
+ // src/helpers/subscribe-to-editor.ts
3567
+ var createEditorListener = ({
3568
+ model,
3569
+ trustedHosts,
3570
+ callbacks
3571
+ }) => {
3572
+ return (event) => {
3573
+ if (!isFromTrustedHost(trustedHosts, event)) {
3574
+ return;
3575
+ }
3576
+ const {
3577
+ data
3578
+ } = event;
3579
+ if (data) {
3580
+ switch (data.type) {
3581
+ case "builder.configureSdk": {
3582
+ callbacks.configureSdk(data.data);
3583
+ break;
3584
+ }
3585
+ case "builder.triggerAnimation": {
3586
+ callbacks.animation(data.data);
3587
+ break;
3588
+ }
3589
+ case "builder.contentUpdate": {
3590
+ const messageContent = data.data;
3591
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3592
+ const contentData = messageContent.data;
3593
+ if (key === model) {
3594
+ callbacks.contentUpdate(contentData);
3595
+ }
3596
+ break;
3597
+ }
3598
+ }
3599
+ }
3600
+ };
3601
+ };
3602
+ var subscribeToEditor = (model, callback, options) => {
3603
+ if (!isBrowser) {
3604
+ logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
3605
+ return () => {
3606
+ };
3607
+ }
3608
+ setupBrowserForEditing();
3609
+ const listener = createEditorListener({
3610
+ callbacks: {
3611
+ contentUpdate: callback,
3612
+ animation: () => {
3613
+ },
3614
+ configureSdk: () => {
3615
+ }
3616
+ },
3617
+ model,
3618
+ trustedHosts: options?.trustedHosts
3619
+ });
3620
+ window.addEventListener("message", listener);
3621
+ return () => {
3622
+ window.removeEventListener("message", listener);
3623
+ };
3624
+ };
3625
+
3566
3626
  // src/components/content/components/enable-editor.tsx
3567
3627
  function EnableEditor(props) {
3568
3628
  const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
@@ -3608,14 +3668,11 @@ function EnableEditor(props) {
3608
3668
  }));
3609
3669
  }
3610
3670
  function processMessage(event) {
3611
- if (!isFromTrustedHost(props.trustedHosts, event)) {
3612
- return;
3613
- }
3614
- const { data } = event;
3615
- if (data) {
3616
- switch (data.type) {
3617
- case "builder.configureSdk": {
3618
- const messageContent = data.data;
3671
+ return createEditorListener({
3672
+ model: props.model,
3673
+ trustedHosts: props.trustedHosts,
3674
+ callbacks: {
3675
+ configureSdk: (messageContent) => {
3619
3676
  const { breakpoints, contentId } = messageContent;
3620
3677
  if (!contentId || contentId !== props.builderContextSignal.content?.id) {
3621
3678
  return;
@@ -3626,26 +3683,18 @@ function EnableEditor(props) {
3626
3683
  breakpoints
3627
3684
  }
3628
3685
  });
3629
- }
3630
- setForceReRenderCount(forceReRenderCount() + 1);
3631
- break;
3632
- }
3633
- case "builder.triggerAnimation": {
3634
- triggerAnimation(data.data);
3635
- break;
3636
- }
3637
- case "builder.contentUpdate": {
3638
- const messageContent = data.data;
3639
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3640
- const contentData = messageContent.data;
3641
- if (key === props.model) {
3642
- mergeNewContent(contentData);
3643
3686
  setForceReRenderCount(forceReRenderCount() + 1);
3644
3687
  }
3645
- break;
3688
+ },
3689
+ animation: (animation) => {
3690
+ triggerAnimation(animation);
3691
+ },
3692
+ contentUpdate: (newContent) => {
3693
+ mergeNewContent(newContent);
3694
+ setForceReRenderCount(forceReRenderCount() + 1);
3646
3695
  }
3647
3696
  }
3648
- }
3697
+ })(event);
3649
3698
  }
3650
3699
  function evaluateJsCode() {
3651
3700
  const jsCode = props.builderContextSignal.content?.data?.jsCode;
@@ -4339,5 +4388,6 @@ export {
4339
4388
  isPreviewing,
4340
4389
  register,
4341
4390
  setEditorSettings,
4391
+ subscribeToEditor,
4342
4392
  track
4343
4393
  };
package/lib/node/index.js CHANGED
@@ -3479,13 +3479,6 @@ async function fetchEntries(options) {
3479
3479
  }
3480
3480
  var getAllContent = fetchEntries;
3481
3481
 
3482
- // src/functions/is-from-trusted-host.ts
3483
- var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
3484
- function isFromTrustedHost(trustedHosts, e) {
3485
- const url = new URL(e.origin), hostname = url.hostname;
3486
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3487
- }
3488
-
3489
3482
  // src/functions/is-previewing.ts
3490
3483
  function isPreviewing() {
3491
3484
  if (!isBrowser()) {
@@ -3733,8 +3726,15 @@ var getInteractionPropertiesForEvent = (event) => {
3733
3726
  };
3734
3727
  };
3735
3728
 
3729
+ // src/functions/is-from-trusted-host.ts
3730
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
3731
+ function isFromTrustedHost(trustedHosts, e) {
3732
+ const url = new URL(e.origin), hostname = url.hostname;
3733
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3734
+ }
3735
+
3736
3736
  // src/constants/sdk-version.ts
3737
- var SDK_VERSION = "0.12.7";
3737
+ var SDK_VERSION = "0.12.8";
3738
3738
 
3739
3739
  // src/functions/register.ts
3740
3740
  var registry = {};
@@ -3870,6 +3870,66 @@ var setupBrowserForEditing = (options = {}) => {
3870
3870
  }
3871
3871
  };
3872
3872
 
3873
+ // src/helpers/subscribe-to-editor.ts
3874
+ var createEditorListener = ({
3875
+ model,
3876
+ trustedHosts,
3877
+ callbacks
3878
+ }) => {
3879
+ return (event) => {
3880
+ if (!isFromTrustedHost(trustedHosts, event)) {
3881
+ return;
3882
+ }
3883
+ const {
3884
+ data
3885
+ } = event;
3886
+ if (data) {
3887
+ switch (data.type) {
3888
+ case "builder.configureSdk": {
3889
+ callbacks.configureSdk(data.data);
3890
+ break;
3891
+ }
3892
+ case "builder.triggerAnimation": {
3893
+ callbacks.animation(data.data);
3894
+ break;
3895
+ }
3896
+ case "builder.contentUpdate": {
3897
+ const messageContent = data.data;
3898
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3899
+ const contentData = messageContent.data;
3900
+ if (key === model) {
3901
+ callbacks.contentUpdate(contentData);
3902
+ }
3903
+ break;
3904
+ }
3905
+ }
3906
+ }
3907
+ };
3908
+ };
3909
+ var subscribeToEditor = (model, callback, options) => {
3910
+ if (!isBrowser) {
3911
+ logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
3912
+ return () => {
3913
+ };
3914
+ }
3915
+ setupBrowserForEditing();
3916
+ const listener = createEditorListener({
3917
+ callbacks: {
3918
+ contentUpdate: callback,
3919
+ animation: () => {
3920
+ },
3921
+ configureSdk: () => {
3922
+ }
3923
+ },
3924
+ model,
3925
+ trustedHosts: options?.trustedHosts
3926
+ });
3927
+ window.addEventListener("message", listener);
3928
+ return () => {
3929
+ window.removeEventListener("message", listener);
3930
+ };
3931
+ };
3932
+
3873
3933
  // src/components/content/components/enable-editor.tsx
3874
3934
  function EnableEditor(props) {
3875
3935
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
@@ -3913,16 +3973,11 @@ function EnableEditor(props) {
3913
3973
  }));
3914
3974
  }
3915
3975
  function processMessage(event) {
3916
- if (!isFromTrustedHost(props.trustedHosts, event)) {
3917
- return;
3918
- }
3919
- const {
3920
- data
3921
- } = event;
3922
- if (data) {
3923
- switch (data.type) {
3924
- case "builder.configureSdk": {
3925
- const messageContent = data.data;
3976
+ return createEditorListener({
3977
+ model: props.model,
3978
+ trustedHosts: props.trustedHosts,
3979
+ callbacks: {
3980
+ configureSdk: (messageContent) => {
3926
3981
  const {
3927
3982
  breakpoints,
3928
3983
  contentId
@@ -3936,26 +3991,18 @@ function EnableEditor(props) {
3936
3991
  breakpoints
3937
3992
  }
3938
3993
  });
3939
- }
3940
- setForceReRenderCount(forceReRenderCount() + 1);
3941
- break;
3942
- }
3943
- case "builder.triggerAnimation": {
3944
- triggerAnimation(data.data);
3945
- break;
3946
- }
3947
- case "builder.contentUpdate": {
3948
- const messageContent = data.data;
3949
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3950
- const contentData = messageContent.data;
3951
- if (key === props.model) {
3952
- mergeNewContent(contentData);
3953
3994
  setForceReRenderCount(forceReRenderCount() + 1);
3954
3995
  }
3955
- break;
3996
+ },
3997
+ animation: (animation) => {
3998
+ triggerAnimation(animation);
3999
+ },
4000
+ contentUpdate: (newContent) => {
4001
+ mergeNewContent(newContent);
4002
+ setForceReRenderCount(forceReRenderCount() + 1);
3956
4003
  }
3957
4004
  }
3958
- }
4005
+ })(event);
3959
4006
  }
3960
4007
  function evaluateJsCode() {
3961
4008
  const jsCode = props.builderContextSignal.content?.data?.jsCode;
@@ -4798,4 +4845,4 @@ var fetchBuilderProps = async (_args) => {
4798
4845
  };
4799
4846
  };
4800
4847
 
4801
- export { blocks_default as Blocks, button_default as Button, columns_default as Columns, content_variants_default as Content, fragment_default as Fragment, image_default as Image, RenderBlocks, RenderContent, section_default as Section, symbol_default as Symbol, text_default as Text, video_default as Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, track };
4848
+ export { blocks_default as Blocks, button_default as Button, columns_default as Columns, content_variants_default as Content, fragment_default as Fragment, image_default as Image, RenderBlocks, RenderContent, section_default as Section, symbol_default as Symbol, text_default as Text, video_default as Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getAllContent, getBuilderSearchParams, getContent, isEditing, isPreviewing, register, setEditorSettings, subscribeToEditor, track };