@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.
@@ -3030,13 +3030,6 @@ async function fetchEntries(options) {
3030
3030
  }
3031
3031
  var getAllContent = fetchEntries;
3032
3032
 
3033
- // src/functions/is-from-trusted-host.ts
3034
- var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
3035
- function isFromTrustedHost(trustedHosts, e) {
3036
- const url = new URL(e.origin), hostname = url.hostname;
3037
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3038
- }
3039
-
3040
3033
  // src/functions/is-previewing.ts
3041
3034
  function isPreviewing() {
3042
3035
  if (!isBrowser()) {
@@ -3284,8 +3277,15 @@ var getInteractionPropertiesForEvent = (event) => {
3284
3277
  };
3285
3278
  };
3286
3279
 
3280
+ // src/functions/is-from-trusted-host.ts
3281
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
3282
+ function isFromTrustedHost(trustedHosts, e) {
3283
+ const url = new URL(e.origin), hostname = url.hostname;
3284
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3285
+ }
3286
+
3287
3287
  // src/constants/sdk-version.ts
3288
- var SDK_VERSION = "0.12.7";
3288
+ var SDK_VERSION = "0.12.8";
3289
3289
 
3290
3290
  // src/functions/register.ts
3291
3291
  var registry = {};
@@ -3421,6 +3421,66 @@ var setupBrowserForEditing = (options = {}) => {
3421
3421
  }
3422
3422
  };
3423
3423
 
3424
+ // src/helpers/subscribe-to-editor.ts
3425
+ var createEditorListener = ({
3426
+ model,
3427
+ trustedHosts,
3428
+ callbacks
3429
+ }) => {
3430
+ return (event) => {
3431
+ if (!isFromTrustedHost(trustedHosts, event)) {
3432
+ return;
3433
+ }
3434
+ const {
3435
+ data
3436
+ } = event;
3437
+ if (data) {
3438
+ switch (data.type) {
3439
+ case "builder.configureSdk": {
3440
+ callbacks.configureSdk(data.data);
3441
+ break;
3442
+ }
3443
+ case "builder.triggerAnimation": {
3444
+ callbacks.animation(data.data);
3445
+ break;
3446
+ }
3447
+ case "builder.contentUpdate": {
3448
+ const messageContent = data.data;
3449
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3450
+ const contentData = messageContent.data;
3451
+ if (key === model) {
3452
+ callbacks.contentUpdate(contentData);
3453
+ }
3454
+ break;
3455
+ }
3456
+ }
3457
+ }
3458
+ };
3459
+ };
3460
+ var subscribeToEditor = (model, callback, options) => {
3461
+ if (!isBrowser) {
3462
+ logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
3463
+ return () => {
3464
+ };
3465
+ }
3466
+ setupBrowserForEditing();
3467
+ const listener = createEditorListener({
3468
+ callbacks: {
3469
+ contentUpdate: callback,
3470
+ animation: () => {
3471
+ },
3472
+ configureSdk: () => {
3473
+ }
3474
+ },
3475
+ model,
3476
+ trustedHosts: options?.trustedHosts
3477
+ });
3478
+ window.addEventListener("message", listener);
3479
+ return () => {
3480
+ window.removeEventListener("message", listener);
3481
+ };
3482
+ };
3483
+
3424
3484
  // src/components/content/components/enable-editor.tsx
3425
3485
  function EnableEditor(props) {
3426
3486
  const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
@@ -3466,14 +3526,11 @@ function EnableEditor(props) {
3466
3526
  }));
3467
3527
  }
3468
3528
  function processMessage(event) {
3469
- if (!isFromTrustedHost(props.trustedHosts, event)) {
3470
- return;
3471
- }
3472
- const { data } = event;
3473
- if (data) {
3474
- switch (data.type) {
3475
- case "builder.configureSdk": {
3476
- const messageContent = data.data;
3529
+ return createEditorListener({
3530
+ model: props.model,
3531
+ trustedHosts: props.trustedHosts,
3532
+ callbacks: {
3533
+ configureSdk: (messageContent) => {
3477
3534
  const { breakpoints, contentId } = messageContent;
3478
3535
  if (!contentId || contentId !== props.builderContextSignal.content?.id) {
3479
3536
  return;
@@ -3484,26 +3541,18 @@ function EnableEditor(props) {
3484
3541
  breakpoints
3485
3542
  }
3486
3543
  });
3487
- }
3488
- setForceReRenderCount(forceReRenderCount() + 1);
3489
- break;
3490
- }
3491
- case "builder.triggerAnimation": {
3492
- triggerAnimation(data.data);
3493
- break;
3494
- }
3495
- case "builder.contentUpdate": {
3496
- const messageContent = data.data;
3497
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3498
- const contentData = messageContent.data;
3499
- if (key === props.model) {
3500
- mergeNewContent(contentData);
3501
3544
  setForceReRenderCount(forceReRenderCount() + 1);
3502
3545
  }
3503
- break;
3546
+ },
3547
+ animation: (animation) => {
3548
+ triggerAnimation(animation);
3549
+ },
3550
+ contentUpdate: (newContent) => {
3551
+ mergeNewContent(newContent);
3552
+ setForceReRenderCount(forceReRenderCount() + 1);
3504
3553
  }
3505
3554
  }
3506
- }
3555
+ })(event);
3507
3556
  }
3508
3557
  function evaluateJsCode() {
3509
3558
  const jsCode = props.builderContextSignal.content?.data?.jsCode;
@@ -4196,5 +4245,6 @@ export {
4196
4245
  isPreviewing,
4197
4246
  register,
4198
4247
  setEditorSettings,
4248
+ subscribeToEditor,
4199
4249
  track
4200
4250
  };
package/lib/edge/dev.js CHANGED
@@ -6521,13 +6521,6 @@ async function fetchEntries(options) {
6521
6521
  }
6522
6522
  var getAllContent = fetchEntries;
6523
6523
 
6524
- // src/functions/is-from-trusted-host.ts
6525
- var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
6526
- function isFromTrustedHost(trustedHosts, e) {
6527
- const url = new URL(e.origin), hostname = url.hostname;
6528
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
6529
- }
6530
-
6531
6524
  // src/functions/is-previewing.ts
6532
6525
  function isPreviewing() {
6533
6526
  if (!isBrowser()) {
@@ -6778,8 +6771,15 @@ var getInteractionPropertiesForEvent = (event) => {
6778
6771
  };
6779
6772
  };
6780
6773
 
6774
+ // src/functions/is-from-trusted-host.ts
6775
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
6776
+ function isFromTrustedHost(trustedHosts, e) {
6777
+ const url = new URL(e.origin), hostname = url.hostname;
6778
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
6779
+ }
6780
+
6781
6781
  // src/constants/sdk-version.ts
6782
- var SDK_VERSION = "0.12.7";
6782
+ var SDK_VERSION = "0.12.8";
6783
6783
 
6784
6784
  // src/functions/register.ts
6785
6785
  var registry = {};
@@ -6916,6 +6916,66 @@ var setupBrowserForEditing = (options = {}) => {
6916
6916
  }
6917
6917
  };
6918
6918
 
6919
+ // src/helpers/subscribe-to-editor.ts
6920
+ var createEditorListener = ({
6921
+ model,
6922
+ trustedHosts,
6923
+ callbacks
6924
+ }) => {
6925
+ return (event) => {
6926
+ if (!isFromTrustedHost(trustedHosts, event)) {
6927
+ return;
6928
+ }
6929
+ const {
6930
+ data
6931
+ } = event;
6932
+ if (data) {
6933
+ switch (data.type) {
6934
+ case "builder.configureSdk": {
6935
+ callbacks.configureSdk(data.data);
6936
+ break;
6937
+ }
6938
+ case "builder.triggerAnimation": {
6939
+ callbacks.animation(data.data);
6940
+ break;
6941
+ }
6942
+ case "builder.contentUpdate": {
6943
+ const messageContent = data.data;
6944
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
6945
+ const contentData = messageContent.data;
6946
+ if (key === model) {
6947
+ callbacks.contentUpdate(contentData);
6948
+ }
6949
+ break;
6950
+ }
6951
+ }
6952
+ }
6953
+ };
6954
+ };
6955
+ var subscribeToEditor = (model, callback, options) => {
6956
+ if (!isBrowser) {
6957
+ logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
6958
+ return () => {
6959
+ };
6960
+ }
6961
+ setupBrowserForEditing();
6962
+ const listener = createEditorListener({
6963
+ callbacks: {
6964
+ contentUpdate: callback,
6965
+ animation: () => {
6966
+ },
6967
+ configureSdk: () => {
6968
+ }
6969
+ },
6970
+ model,
6971
+ trustedHosts: options?.trustedHosts
6972
+ });
6973
+ window.addEventListener("message", listener);
6974
+ return () => {
6975
+ window.removeEventListener("message", listener);
6976
+ };
6977
+ };
6978
+
6919
6979
  // src/components/content/components/enable-editor.tsx
6920
6980
  function EnableEditor(props) {
6921
6981
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
@@ -6959,16 +7019,11 @@ function EnableEditor(props) {
6959
7019
  }));
6960
7020
  }
6961
7021
  function processMessage(event) {
6962
- if (!isFromTrustedHost(props.trustedHosts, event)) {
6963
- return;
6964
- }
6965
- const {
6966
- data
6967
- } = event;
6968
- if (data) {
6969
- switch (data.type) {
6970
- case "builder.configureSdk": {
6971
- const messageContent = data.data;
7022
+ return createEditorListener({
7023
+ model: props.model,
7024
+ trustedHosts: props.trustedHosts,
7025
+ callbacks: {
7026
+ configureSdk: (messageContent) => {
6972
7027
  const {
6973
7028
  breakpoints,
6974
7029
  contentId
@@ -6982,26 +7037,18 @@ function EnableEditor(props) {
6982
7037
  breakpoints
6983
7038
  }
6984
7039
  });
6985
- }
6986
- setForceReRenderCount(forceReRenderCount() + 1);
6987
- break;
6988
- }
6989
- case "builder.triggerAnimation": {
6990
- triggerAnimation(data.data);
6991
- break;
6992
- }
6993
- case "builder.contentUpdate": {
6994
- const messageContent = data.data;
6995
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
6996
- const contentData = messageContent.data;
6997
- if (key === props.model) {
6998
- mergeNewContent(contentData);
6999
7040
  setForceReRenderCount(forceReRenderCount() + 1);
7000
7041
  }
7001
- break;
7042
+ },
7043
+ animation: (animation) => {
7044
+ triggerAnimation(animation);
7045
+ },
7046
+ contentUpdate: (newContent) => {
7047
+ mergeNewContent(newContent);
7048
+ setForceReRenderCount(forceReRenderCount() + 1);
7002
7049
  }
7003
7050
  }
7004
- }
7051
+ })(event);
7005
7052
  }
7006
7053
  function evaluateJsCode() {
7007
7054
  const jsCode = props.builderContextSignal.content?.data?.jsCode;
@@ -7845,4 +7892,4 @@ var fetchBuilderProps = async (_args) => {
7845
7892
  };
7846
7893
  };
7847
7894
 
7848
- 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 };
7895
+ 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/edge/dev.jsx CHANGED
@@ -6197,13 +6197,6 @@ async function fetchEntries(options) {
6197
6197
  }
6198
6198
  var getAllContent = fetchEntries;
6199
6199
 
6200
- // src/functions/is-from-trusted-host.ts
6201
- var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
6202
- function isFromTrustedHost(trustedHosts, e) {
6203
- const url = new URL(e.origin), hostname = url.hostname;
6204
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
6205
- }
6206
-
6207
6200
  // src/functions/is-previewing.ts
6208
6201
  function isPreviewing() {
6209
6202
  if (!isBrowser()) {
@@ -6454,8 +6447,15 @@ var getInteractionPropertiesForEvent = (event) => {
6454
6447
  };
6455
6448
  };
6456
6449
 
6450
+ // src/functions/is-from-trusted-host.ts
6451
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
6452
+ function isFromTrustedHost(trustedHosts, e) {
6453
+ const url = new URL(e.origin), hostname = url.hostname;
6454
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
6455
+ }
6456
+
6457
6457
  // src/constants/sdk-version.ts
6458
- var SDK_VERSION = "0.12.7";
6458
+ var SDK_VERSION = "0.12.8";
6459
6459
 
6460
6460
  // src/functions/register.ts
6461
6461
  var registry = {};
@@ -6592,6 +6592,66 @@ var setupBrowserForEditing = (options = {}) => {
6592
6592
  }
6593
6593
  };
6594
6594
 
6595
+ // src/helpers/subscribe-to-editor.ts
6596
+ var createEditorListener = ({
6597
+ model,
6598
+ trustedHosts,
6599
+ callbacks
6600
+ }) => {
6601
+ return (event) => {
6602
+ if (!isFromTrustedHost(trustedHosts, event)) {
6603
+ return;
6604
+ }
6605
+ const {
6606
+ data
6607
+ } = event;
6608
+ if (data) {
6609
+ switch (data.type) {
6610
+ case "builder.configureSdk": {
6611
+ callbacks.configureSdk(data.data);
6612
+ break;
6613
+ }
6614
+ case "builder.triggerAnimation": {
6615
+ callbacks.animation(data.data);
6616
+ break;
6617
+ }
6618
+ case "builder.contentUpdate": {
6619
+ const messageContent = data.data;
6620
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
6621
+ const contentData = messageContent.data;
6622
+ if (key === model) {
6623
+ callbacks.contentUpdate(contentData);
6624
+ }
6625
+ break;
6626
+ }
6627
+ }
6628
+ }
6629
+ };
6630
+ };
6631
+ var subscribeToEditor = (model, callback, options) => {
6632
+ if (!isBrowser) {
6633
+ logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
6634
+ return () => {
6635
+ };
6636
+ }
6637
+ setupBrowserForEditing();
6638
+ const listener = createEditorListener({
6639
+ callbacks: {
6640
+ contentUpdate: callback,
6641
+ animation: () => {
6642
+ },
6643
+ configureSdk: () => {
6644
+ }
6645
+ },
6646
+ model,
6647
+ trustedHosts: options?.trustedHosts
6648
+ });
6649
+ window.addEventListener("message", listener);
6650
+ return () => {
6651
+ window.removeEventListener("message", listener);
6652
+ };
6653
+ };
6654
+
6595
6655
  // src/components/content/components/enable-editor.tsx
6596
6656
  function EnableEditor(props) {
6597
6657
  const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
@@ -6637,14 +6697,11 @@ function EnableEditor(props) {
6637
6697
  }));
6638
6698
  }
6639
6699
  function processMessage(event) {
6640
- if (!isFromTrustedHost(props.trustedHosts, event)) {
6641
- return;
6642
- }
6643
- const { data } = event;
6644
- if (data) {
6645
- switch (data.type) {
6646
- case "builder.configureSdk": {
6647
- const messageContent = data.data;
6700
+ return createEditorListener({
6701
+ model: props.model,
6702
+ trustedHosts: props.trustedHosts,
6703
+ callbacks: {
6704
+ configureSdk: (messageContent) => {
6648
6705
  const { breakpoints, contentId } = messageContent;
6649
6706
  if (!contentId || contentId !== props.builderContextSignal.content?.id) {
6650
6707
  return;
@@ -6655,26 +6712,18 @@ function EnableEditor(props) {
6655
6712
  breakpoints
6656
6713
  }
6657
6714
  });
6658
- }
6659
- setForceReRenderCount(forceReRenderCount() + 1);
6660
- break;
6661
- }
6662
- case "builder.triggerAnimation": {
6663
- triggerAnimation(data.data);
6664
- break;
6665
- }
6666
- case "builder.contentUpdate": {
6667
- const messageContent = data.data;
6668
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
6669
- const contentData = messageContent.data;
6670
- if (key === props.model) {
6671
- mergeNewContent(contentData);
6672
6715
  setForceReRenderCount(forceReRenderCount() + 1);
6673
6716
  }
6674
- break;
6717
+ },
6718
+ animation: (animation) => {
6719
+ triggerAnimation(animation);
6720
+ },
6721
+ contentUpdate: (newContent) => {
6722
+ mergeNewContent(newContent);
6723
+ setForceReRenderCount(forceReRenderCount() + 1);
6675
6724
  }
6676
6725
  }
6677
- }
6726
+ })(event);
6678
6727
  }
6679
6728
  function evaluateJsCode() {
6680
6729
  const jsCode = props.builderContextSignal.content?.data?.jsCode;
@@ -7368,5 +7417,6 @@ export {
7368
7417
  isPreviewing,
7369
7418
  register,
7370
7419
  setEditorSettings,
7420
+ subscribeToEditor,
7371
7421
  track
7372
7422
  };
package/lib/edge/index.js CHANGED
@@ -6509,13 +6509,6 @@ async function fetchEntries(options) {
6509
6509
  }
6510
6510
  var getAllContent = fetchEntries;
6511
6511
 
6512
- // src/functions/is-from-trusted-host.ts
6513
- var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
6514
- function isFromTrustedHost(trustedHosts, e) {
6515
- const url = new URL(e.origin), hostname = url.hostname;
6516
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
6517
- }
6518
-
6519
6512
  // src/functions/is-previewing.ts
6520
6513
  function isPreviewing() {
6521
6514
  if (!isBrowser()) {
@@ -6763,8 +6756,15 @@ var getInteractionPropertiesForEvent = (event) => {
6763
6756
  };
6764
6757
  };
6765
6758
 
6759
+ // src/functions/is-from-trusted-host.ts
6760
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
6761
+ function isFromTrustedHost(trustedHosts, e) {
6762
+ const url = new URL(e.origin), hostname = url.hostname;
6763
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
6764
+ }
6765
+
6766
6766
  // src/constants/sdk-version.ts
6767
- var SDK_VERSION = "0.12.7";
6767
+ var SDK_VERSION = "0.12.8";
6768
6768
 
6769
6769
  // src/functions/register.ts
6770
6770
  var registry = {};
@@ -6900,6 +6900,66 @@ var setupBrowserForEditing = (options = {}) => {
6900
6900
  }
6901
6901
  };
6902
6902
 
6903
+ // src/helpers/subscribe-to-editor.ts
6904
+ var createEditorListener = ({
6905
+ model,
6906
+ trustedHosts,
6907
+ callbacks
6908
+ }) => {
6909
+ return (event) => {
6910
+ if (!isFromTrustedHost(trustedHosts, event)) {
6911
+ return;
6912
+ }
6913
+ const {
6914
+ data
6915
+ } = event;
6916
+ if (data) {
6917
+ switch (data.type) {
6918
+ case "builder.configureSdk": {
6919
+ callbacks.configureSdk(data.data);
6920
+ break;
6921
+ }
6922
+ case "builder.triggerAnimation": {
6923
+ callbacks.animation(data.data);
6924
+ break;
6925
+ }
6926
+ case "builder.contentUpdate": {
6927
+ const messageContent = data.data;
6928
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
6929
+ const contentData = messageContent.data;
6930
+ if (key === model) {
6931
+ callbacks.contentUpdate(contentData);
6932
+ }
6933
+ break;
6934
+ }
6935
+ }
6936
+ }
6937
+ };
6938
+ };
6939
+ var subscribeToEditor = (model, callback, options) => {
6940
+ if (!isBrowser) {
6941
+ logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
6942
+ return () => {
6943
+ };
6944
+ }
6945
+ setupBrowserForEditing();
6946
+ const listener = createEditorListener({
6947
+ callbacks: {
6948
+ contentUpdate: callback,
6949
+ animation: () => {
6950
+ },
6951
+ configureSdk: () => {
6952
+ }
6953
+ },
6954
+ model,
6955
+ trustedHosts: options?.trustedHosts
6956
+ });
6957
+ window.addEventListener("message", listener);
6958
+ return () => {
6959
+ window.removeEventListener("message", listener);
6960
+ };
6961
+ };
6962
+
6903
6963
  // src/components/content/components/enable-editor.tsx
6904
6964
  function EnableEditor(props) {
6905
6965
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
@@ -6943,16 +7003,11 @@ function EnableEditor(props) {
6943
7003
  }));
6944
7004
  }
6945
7005
  function processMessage(event) {
6946
- if (!isFromTrustedHost(props.trustedHosts, event)) {
6947
- return;
6948
- }
6949
- const {
6950
- data
6951
- } = event;
6952
- if (data) {
6953
- switch (data.type) {
6954
- case "builder.configureSdk": {
6955
- const messageContent = data.data;
7006
+ return createEditorListener({
7007
+ model: props.model,
7008
+ trustedHosts: props.trustedHosts,
7009
+ callbacks: {
7010
+ configureSdk: (messageContent) => {
6956
7011
  const {
6957
7012
  breakpoints,
6958
7013
  contentId
@@ -6966,26 +7021,18 @@ function EnableEditor(props) {
6966
7021
  breakpoints
6967
7022
  }
6968
7023
  });
6969
- }
6970
- setForceReRenderCount(forceReRenderCount() + 1);
6971
- break;
6972
- }
6973
- case "builder.triggerAnimation": {
6974
- triggerAnimation(data.data);
6975
- break;
6976
- }
6977
- case "builder.contentUpdate": {
6978
- const messageContent = data.data;
6979
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
6980
- const contentData = messageContent.data;
6981
- if (key === props.model) {
6982
- mergeNewContent(contentData);
6983
7024
  setForceReRenderCount(forceReRenderCount() + 1);
6984
7025
  }
6985
- break;
7026
+ },
7027
+ animation: (animation) => {
7028
+ triggerAnimation(animation);
7029
+ },
7030
+ contentUpdate: (newContent) => {
7031
+ mergeNewContent(newContent);
7032
+ setForceReRenderCount(forceReRenderCount() + 1);
6986
7033
  }
6987
7034
  }
6988
- }
7035
+ })(event);
6989
7036
  }
6990
7037
  function evaluateJsCode() {
6991
7038
  const jsCode = props.builderContextSignal.content?.data?.jsCode;
@@ -7828,4 +7875,4 @@ var fetchBuilderProps = async (_args) => {
7828
7875
  };
7829
7876
  };
7830
7877
 
7831
- 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 };
7878
+ 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 };