@contentstack/live-preview-utils 4.0.1 → 4.1.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 (106) hide show
  1. package/README.md +3 -3
  2. package/dist/legacy/light-sdk.cjs +1 -1
  3. package/dist/legacy/light-sdk.js +1 -1
  4. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs +24 -8
  5. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs.map +1 -1
  6. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js +24 -8
  7. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js.map +1 -1
  8. package/dist/legacy/preview/contentstack-live-preview-HOC.cjs +1 -1
  9. package/dist/legacy/preview/contentstack-live-preview-HOC.js +1 -1
  10. package/dist/legacy/visualBuilder/components/VariantIndicator.cjs +36 -0
  11. package/dist/legacy/visualBuilder/components/VariantIndicator.cjs.map +1 -0
  12. package/dist/legacy/visualBuilder/components/VariantIndicator.d.cts +3 -0
  13. package/dist/legacy/visualBuilder/components/VariantIndicator.d.ts +3 -0
  14. package/dist/legacy/visualBuilder/components/VariantIndicator.js +13 -0
  15. package/dist/legacy/visualBuilder/components/VariantIndicator.js.map +1 -0
  16. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs +124 -114
  17. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  18. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js +124 -114
  19. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  20. package/dist/legacy/visualBuilder/components/icons/variant.cjs +5 -1
  21. package/dist/legacy/visualBuilder/components/icons/variant.cjs.map +1 -1
  22. package/dist/legacy/visualBuilder/components/icons/variant.d.cts +3 -1
  23. package/dist/legacy/visualBuilder/components/icons/variant.d.ts +3 -1
  24. package/dist/legacy/visualBuilder/components/icons/variant.js +5 -1
  25. package/dist/legacy/visualBuilder/components/icons/variant.js.map +1 -1
  26. package/dist/legacy/visualBuilder/generators/generateHoverOutline.cjs +10 -1
  27. package/dist/legacy/visualBuilder/generators/generateHoverOutline.cjs.map +1 -1
  28. package/dist/legacy/visualBuilder/generators/generateHoverOutline.d.cts +1 -1
  29. package/dist/legacy/visualBuilder/generators/generateHoverOutline.d.ts +1 -1
  30. package/dist/legacy/visualBuilder/generators/generateHoverOutline.js +10 -1
  31. package/dist/legacy/visualBuilder/generators/generateHoverOutline.js.map +1 -1
  32. package/dist/legacy/visualBuilder/listeners/mouseHover.cjs +13 -10
  33. package/dist/legacy/visualBuilder/listeners/mouseHover.cjs.map +1 -1
  34. package/dist/legacy/visualBuilder/listeners/mouseHover.js +13 -10
  35. package/dist/legacy/visualBuilder/listeners/mouseHover.js.map +1 -1
  36. package/dist/legacy/visualBuilder/utils/enableInlineEditing.cjs +3 -1
  37. package/dist/legacy/visualBuilder/utils/enableInlineEditing.cjs.map +1 -1
  38. package/dist/legacy/visualBuilder/utils/enableInlineEditing.js +3 -1
  39. package/dist/legacy/visualBuilder/utils/enableInlineEditing.js.map +1 -1
  40. package/dist/legacy/visualBuilder/utils/handleFieldMouseDown.cjs +5 -0
  41. package/dist/legacy/visualBuilder/utils/handleFieldMouseDown.cjs.map +1 -1
  42. package/dist/legacy/visualBuilder/utils/handleFieldMouseDown.js +5 -0
  43. package/dist/legacy/visualBuilder/utils/handleFieldMouseDown.js.map +1 -1
  44. package/dist/legacy/visualBuilder/utils/isFieldDisabled.cjs +1 -1
  45. package/dist/legacy/visualBuilder/utils/isFieldDisabled.cjs.map +1 -1
  46. package/dist/legacy/visualBuilder/utils/isFieldDisabled.js +1 -1
  47. package/dist/legacy/visualBuilder/utils/isFieldDisabled.js.map +1 -1
  48. package/dist/legacy/visualBuilder/visualBuilder.style.cjs +26 -1
  49. package/dist/legacy/visualBuilder/visualBuilder.style.cjs.map +1 -1
  50. package/dist/legacy/visualBuilder/visualBuilder.style.d.cts +3 -0
  51. package/dist/legacy/visualBuilder/visualBuilder.style.d.ts +3 -0
  52. package/dist/legacy/visualBuilder/visualBuilder.style.js +26 -1
  53. package/dist/legacy/visualBuilder/visualBuilder.style.js.map +1 -1
  54. package/dist/modern/light-sdk.cjs +1 -1
  55. package/dist/modern/light-sdk.js +1 -1
  56. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs +23 -7
  57. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs.map +1 -1
  58. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js +23 -7
  59. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js.map +1 -1
  60. package/dist/modern/preview/contentstack-live-preview-HOC.cjs +1 -1
  61. package/dist/modern/preview/contentstack-live-preview-HOC.js +1 -1
  62. package/dist/modern/visualBuilder/components/VariantIndicator.cjs +36 -0
  63. package/dist/modern/visualBuilder/components/VariantIndicator.cjs.map +1 -0
  64. package/dist/modern/visualBuilder/components/VariantIndicator.d.cts +3 -0
  65. package/dist/modern/visualBuilder/components/VariantIndicator.d.ts +3 -0
  66. package/dist/modern/visualBuilder/components/VariantIndicator.js +13 -0
  67. package/dist/modern/visualBuilder/components/VariantIndicator.js.map +1 -0
  68. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs +124 -114
  69. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  70. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js +124 -114
  71. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  72. package/dist/modern/visualBuilder/components/icons/variant.cjs +5 -1
  73. package/dist/modern/visualBuilder/components/icons/variant.cjs.map +1 -1
  74. package/dist/modern/visualBuilder/components/icons/variant.d.cts +3 -1
  75. package/dist/modern/visualBuilder/components/icons/variant.d.ts +3 -1
  76. package/dist/modern/visualBuilder/components/icons/variant.js +5 -1
  77. package/dist/modern/visualBuilder/components/icons/variant.js.map +1 -1
  78. package/dist/modern/visualBuilder/generators/generateHoverOutline.cjs +10 -1
  79. package/dist/modern/visualBuilder/generators/generateHoverOutline.cjs.map +1 -1
  80. package/dist/modern/visualBuilder/generators/generateHoverOutline.d.cts +1 -1
  81. package/dist/modern/visualBuilder/generators/generateHoverOutline.d.ts +1 -1
  82. package/dist/modern/visualBuilder/generators/generateHoverOutline.js +10 -1
  83. package/dist/modern/visualBuilder/generators/generateHoverOutline.js.map +1 -1
  84. package/dist/modern/visualBuilder/listeners/mouseHover.cjs +13 -10
  85. package/dist/modern/visualBuilder/listeners/mouseHover.cjs.map +1 -1
  86. package/dist/modern/visualBuilder/listeners/mouseHover.js +13 -10
  87. package/dist/modern/visualBuilder/listeners/mouseHover.js.map +1 -1
  88. package/dist/modern/visualBuilder/utils/enableInlineEditing.cjs +3 -1
  89. package/dist/modern/visualBuilder/utils/enableInlineEditing.cjs.map +1 -1
  90. package/dist/modern/visualBuilder/utils/enableInlineEditing.js +3 -1
  91. package/dist/modern/visualBuilder/utils/enableInlineEditing.js.map +1 -1
  92. package/dist/modern/visualBuilder/utils/handleFieldMouseDown.cjs +5 -0
  93. package/dist/modern/visualBuilder/utils/handleFieldMouseDown.cjs.map +1 -1
  94. package/dist/modern/visualBuilder/utils/handleFieldMouseDown.js +5 -0
  95. package/dist/modern/visualBuilder/utils/handleFieldMouseDown.js.map +1 -1
  96. package/dist/modern/visualBuilder/utils/isFieldDisabled.cjs +1 -1
  97. package/dist/modern/visualBuilder/utils/isFieldDisabled.cjs.map +1 -1
  98. package/dist/modern/visualBuilder/utils/isFieldDisabled.js +1 -1
  99. package/dist/modern/visualBuilder/utils/isFieldDisabled.js.map +1 -1
  100. package/dist/modern/visualBuilder/visualBuilder.style.cjs +26 -1
  101. package/dist/modern/visualBuilder/visualBuilder.style.cjs.map +1 -1
  102. package/dist/modern/visualBuilder/visualBuilder.style.d.cts +3 -0
  103. package/dist/modern/visualBuilder/visualBuilder.style.d.ts +3 -0
  104. package/dist/modern/visualBuilder/visualBuilder.style.js +26 -1
  105. package/dist/modern/visualBuilder/visualBuilder.style.js.map +1 -1
  106. package/package.json +1 -3
package/README.md CHANGED
@@ -15,8 +15,8 @@ npm install @contentstack/live-preview-utils
15
15
  Alternatively, if you want to include the package directly in your website HTML code, use the following command:
16
16
 
17
17
  ```html
18
- <script type='module' integrity='sha384-b6G+ggU20rGxqCqsgaS6zludFgj5N11xsuXhMEIARMuQY2PtyDS04TU0H5goP+32' crossorigin="anonymous">
19
- import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@4.0.1';
18
+ <script type='module' crossorigin="anonymous">
19
+ import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@4.1.0';
20
20
 
21
21
  ContentstackLivePreview.init({
22
22
  stackDetails: {
@@ -51,7 +51,7 @@ ContentstackLivePreview.init({
51
51
 
52
52
  MIT License
53
53
 
54
- Copyright © 2024 [Contentstack](https://www.contentstack.com/). All Rights Reserved
54
+ Copyright © 2021-2025 [Contentstack](https://www.contentstack.com/). All Rights Reserved
55
55
 
56
56
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
57
57
 
@@ -60,7 +60,7 @@ var _LightLivePreviewHoC = class _LightLivePreviewHoC {
60
60
  static unsubscribeOnEntryChange() {
61
61
  }
62
62
  static getSdkVersion() {
63
- return "4.0.1";
63
+ return "4.1.0";
64
64
  }
65
65
  };
66
66
  _LightLivePreviewHoC.previewConstructors = {};
@@ -38,7 +38,7 @@ var _LightLivePreviewHoC = class _LightLivePreviewHoC {
38
38
  static unsubscribeOnEntryChange() {
39
39
  }
40
40
  static getSdkVersion() {
41
- return "4.0.1";
41
+ return "4.1.0";
42
42
  }
43
43
  };
44
44
  _LightLivePreviewHoC.previewConstructors = {};
@@ -74,9 +74,9 @@ function useOnEntryUpdatePostMessageEvent() {
74
74
  (_a = import_livePreviewEventManager.default) == null ? void 0 : _a.on(
75
75
  import_livePreviewEventManager2.LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,
76
76
  (event) => {
77
- var _a2;
77
+ var _a2, _b, _c;
78
78
  try {
79
- const { ssr, onChange } = import_configManager.default.get();
79
+ const { ssr, onChange, stackDetails } = import_configManager.default.get();
80
80
  const event_type = (_a2 = event.data._metadata) == null ? void 0 : _a2.event_type;
81
81
  (0, import_configManager.setConfigFromParams)({
82
82
  live_preview: event.data.hash
@@ -91,13 +91,29 @@ function useOnEntryUpdatePostMessageEvent() {
91
91
  }
92
92
  ;
93
93
  if (ssr && !event_type) {
94
- if (window.location.href.includes("live_preview")) {
94
+ const url = new URL(window.location.href);
95
+ let live_preview = url.searchParams.get("live_preview");
96
+ let content_type_uid = url.searchParams.get("content_type_uid");
97
+ let entry_uid = url.searchParams.get("entry_uid");
98
+ if (live_preview && content_type_uid && entry_uid) {
95
99
  window.location.reload();
96
100
  } else {
97
- const url = new URL(window.location.href);
98
- url.searchParams.set("live_preview", event.data.hash);
99
- url.searchParams.set("content_type_uid", import_configManager.default.get().stackDetails.contentTypeUid || "");
100
- url.searchParams.set("entry_uid", import_configManager.default.get().stackDetails.entryUid || "");
101
+ live_preview = event.data.hash;
102
+ content_type_uid = event.data.content_type_uid || ((_b = stackDetails.$contentTypeUid) == null ? void 0 : _b.toString()) || "";
103
+ entry_uid = event.data.entry_uid || ((_c = stackDetails.$entryUid) == null ? void 0 : _c.toString()) || "";
104
+ url.searchParams.set("live_preview", live_preview);
105
+ if (content_type_uid) {
106
+ url.searchParams.set(
107
+ "content_type_uid",
108
+ content_type_uid
109
+ );
110
+ }
111
+ if (entry_uid) {
112
+ url.searchParams.set(
113
+ "entry_uid",
114
+ entry_uid
115
+ );
116
+ }
101
117
  window.location.href = url.toString();
102
118
  }
103
119
  }
@@ -125,7 +141,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
125
141
  config: {
126
142
  shouldReload: import_configManager.default.get().ssr,
127
143
  href: window.location.href,
128
- sdkVersion: "4.0.1",
144
+ sdkVersion: "4.1.0",
129
145
  mode: import_configManager.default.get().mode
130
146
  }
131
147
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import { isOpeningInNewTab } from \"../../common/inIframe\";\nimport Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { PublicLogger } from \"../../logger/logger\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n OnChangeLivePreviewPostMessageEventTypes,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n try {\n const { ssr, onChange } = Config.get();\n const event_type = event.data._metadata?.event_type;\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n\n // This section will run when there is a change in the entry and the website is CSR\n if (!ssr && !event_type) {\n onChange();\n } \n\n if(isOpeningInNewTab()) {\n if(!window) {\n PublicLogger.error(\"window is not defined\");\n return;\n };\n \n // This section will run when there is a change in the entry and the website is SSR\n if(ssr && !event_type) {\n if(window.location.href.includes(\"live_preview\")) {\n window.location.reload();\n } else {\n const url = new URL(window.location.href);\n url.searchParams.set(\"live_preview\", event.data.hash);\n url.searchParams.set(\"content_type_uid\", Config.get().stackDetails.contentTypeUid || \"\");\n url.searchParams.set(\"entry_uid\", Config.get().stackDetails.entryUid || \"\");\n window.location.href = url.toString();\n }\n }\n \n // This section will run when the hash changes and the website is SSR or CSR\n if(event_type === OnChangeLivePreviewPostMessageEventTypes.HASH_CHANGE){\n const newUrl = new URL(window.location.href);\n newUrl.searchParams.set(\"live_preview\", event.data.hash);\n window.history.pushState({}, \"\", newUrl.toString());\n }\n \n // This section will run when the URL of the page changes\n if(event_type === OnChangeLivePreviewPostMessageEventTypes.URL_CHANGE && event.data.url){\n window.location.href = event.data.url;\n }\n }\n\n \n } catch (error) {\n PublicLogger.error(\"Error handling live preview update:\", error);\n return;\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline() || isOpeningInNewTab()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAkC;AAClC,2BAA4C;AAC5C,oBAA6B;AAC7B,mBAAuC;AACvC,mBAAoD;AACpD,qCAAmC;AACnC,IAAAA,kCAAiD;AACjD,yCAKO;AAMA,SAAS,6BAAmC;AAlBnD;AAmBI,uCAAAC,YAAA,mBAAwB;AAAA,IACpB,iEAAiC;AAAA,IACjC,CAAC,UAAU;AACP,cAAQ,MAAM,KAAK,MAAM;AAAA,QACrB,KAAK,WAAW;AACZ,iBAAO,QAAQ,QAAQ;AACvB;AAAA,QACJ;AAAA,QACA,KAAK,YAAY;AACb,iBAAO,QAAQ,KAAK;AACpB;AAAA,QACJ;AAAA,QACA,KAAK,UAAU;AACX,iBAAO,QAAQ,GAAG;AAClB;AAAA,QACJ;AAAA,QACA,SAAS;AACL,gBAAM,kBAAyB,MAAM,KAAK;AAC1C,gBAAM,IAAI,MAAM,oBAAoB,eAAe,EAAE;AAAA,QACzD;AAAA,MACJ;AAAA,IACJ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OAAO,SAAS;AAAA,EAC1B,GACC,MAAM,MAAM;AAAA,EAEb;AACR;","names":["import_livePreviewEventManager","livePreviewPostMessage","_a","Config"]}
1
+ {"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import { isOpeningInNewTab } from \"../../common/inIframe\";\nimport Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { PublicLogger } from \"../../logger/logger\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n OnChangeLivePreviewPostMessageEventTypes,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n try {\n const { ssr, onChange, stackDetails } = Config.get();\n const event_type = event.data._metadata?.event_type;\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n\n // This section will run when there is a change in the entry and the website is CSR\n if (!ssr && !event_type) {\n onChange();\n }\n\n if (isOpeningInNewTab()) {\n if (!window) {\n PublicLogger.error(\"window is not defined\");\n return;\n };\n\n if (ssr && !event_type) {\n const url = new URL(window.location.href);\n let live_preview = url.searchParams.get(\"live_preview\");\n let content_type_uid = url.searchParams.get(\"content_type_uid\");\n let entry_uid = url.searchParams.get(\"entry_uid\");\n\n if (live_preview && content_type_uid && entry_uid) {\n // All required params are present, just reload\n window.location.reload();\n } else {\n live_preview = event.data.hash;\n content_type_uid = event.data.content_type_uid || stackDetails.$contentTypeUid?.toString() || \"\";\n entry_uid = event.data.entry_uid || stackDetails.$entryUid?.toString() || \"\";\n // Set missing params and redirect\n url.searchParams.set(\"live_preview\", live_preview);\n if (content_type_uid) {\n url.searchParams.set(\n \"content_type_uid\",\n content_type_uid\n );\n }\n if (entry_uid) {\n url.searchParams.set(\n \"entry_uid\",\n entry_uid\n );\n }\n window.location.href = url.toString();\n }\n }\n\n // This section will run when the hash changes and the website is SSR or CSR\n if (event_type === OnChangeLivePreviewPostMessageEventTypes.HASH_CHANGE) {\n const newUrl = new URL(window.location.href);\n newUrl.searchParams.set(\"live_preview\", event.data.hash);\n window.history.pushState({}, \"\", newUrl.toString());\n }\n\n // This section will run when the URL of the page changes\n if (event_type === OnChangeLivePreviewPostMessageEventTypes.URL_CHANGE && event.data.url) {\n window.location.href = event.data.url;\n }\n }\n } catch (error) {\n PublicLogger.error(\"Error handling live preview update:\", error);\n return;\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline() || isOpeningInNewTab()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAkC;AAClC,2BAA4C;AAC5C,oBAA6B;AAC7B,mBAAuC;AACvC,mBAAoD;AACpD,qCAAmC;AACnC,IAAAA,kCAAiD;AACjD,yCAKO;AAMA,SAAS,6BAAmC;AAlBnD;AAmBI,uCAAAC,YAAA,mBAAwB;AAAA,IACpB,iEAAiC;AAAA,IACjC,CAAC,UAAU;AACP,cAAQ,MAAM,KAAK,MAAM;AAAA,QACrB,KAAK,WAAW;AACZ,iBAAO,QAAQ,QAAQ;AACvB;AAAA,QACJ;AAAA,QACA,KAAK,Y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;AAE5B,oDAAoB;AAAA,QAChB,kBAAkB;AAAA,QAClB,WAAW;AAAA,MACf,CAAC;AAAA,IACL,OAAO;AAAA,IAKP;AACA,QAAI,qBAAAA,QAAO,IAAI,EAAE,WAAO,kCAAoB,SAAK,mCAAkB,GAAG;AAClE,uCAAe;AAAA,IACnB;AACA,yBAAAA,QAAO,IAAI,cAAc,UAAU;AAGnC,QAAI,CAAC,qBAAAA,QAAO,IAAI,EAAE,KAAK;AACnB,kBAAY,MAAM;AACd,2CAAmC;AAAA,MACvC,GAAG,IAAI;AAAA,IACX;AAEA,+BAA2B;AAC3B,qCAAiC;AAAA,EACrC,GACC,MAAM,CAAC,MAAM;AAAA,EAGd;AACR;AAEA,SAAS,qCAA2C;AAnLpD;AAoLI,uCAAAF,YAAA,mBACM,KAAK,iEAAiC,kBAAkB;AAAA,IACtD,MAAM,OAAO,SAAS;AAAA,EAC1B,GACC,MAAM,MAAM;AAAA,EAEb;AACR;","names":["import_livePreviewEventManager","livePreviewPostMessage","_a","Config"]}
@@ -42,9 +42,9 @@ function useOnEntryUpdatePostMessageEvent() {
42
42
  (_a = livePreviewPostMessage) == null ? void 0 : _a.on(
43
43
  LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,
44
44
  (event) => {
45
- var _a2;
45
+ var _a2, _b, _c;
46
46
  try {
47
- const { ssr, onChange } = Config.get();
47
+ const { ssr, onChange, stackDetails } = Config.get();
48
48
  const event_type = (_a2 = event.data._metadata) == null ? void 0 : _a2.event_type;
49
49
  setConfigFromParams({
50
50
  live_preview: event.data.hash
@@ -59,13 +59,29 @@ function useOnEntryUpdatePostMessageEvent() {
59
59
  }
60
60
  ;
61
61
  if (ssr && !event_type) {
62
- if (window.location.href.includes("live_preview")) {
62
+ const url = new URL(window.location.href);
63
+ let live_preview = url.searchParams.get("live_preview");
64
+ let content_type_uid = url.searchParams.get("content_type_uid");
65
+ let entry_uid = url.searchParams.get("entry_uid");
66
+ if (live_preview && content_type_uid && entry_uid) {
63
67
  window.location.reload();
64
68
  } else {
65
- const url = new URL(window.location.href);
66
- url.searchParams.set("live_preview", event.data.hash);
67
- url.searchParams.set("content_type_uid", Config.get().stackDetails.contentTypeUid || "");
68
- url.searchParams.set("entry_uid", Config.get().stackDetails.entryUid || "");
69
+ live_preview = event.data.hash;
70
+ content_type_uid = event.data.content_type_uid || ((_b = stackDetails.$contentTypeUid) == null ? void 0 : _b.toString()) || "";
71
+ entry_uid = event.data.entry_uid || ((_c = stackDetails.$entryUid) == null ? void 0 : _c.toString()) || "";
72
+ url.searchParams.set("live_preview", live_preview);
73
+ if (content_type_uid) {
74
+ url.searchParams.set(
75
+ "content_type_uid",
76
+ content_type_uid
77
+ );
78
+ }
79
+ if (entry_uid) {
80
+ url.searchParams.set(
81
+ "entry_uid",
82
+ entry_uid
83
+ );
84
+ }
69
85
  window.location.href = url.toString();
70
86
  }
71
87
  }
@@ -93,7 +109,7 @@ function sendInitializeLivePreviewPostMessageEvent() {
93
109
  config: {
94
110
  shouldReload: Config.get().ssr,
95
111
  href: window.location.href,
96
- sdkVersion: "4.0.1",
112
+ sdkVersion: "4.1.0",
97
113
  mode: Config.get().mode
98
114
  }
99
115
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import { isOpeningInNewTab } from \"../../common/inIframe\";\nimport Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { PublicLogger } from \"../../logger/logger\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n OnChangeLivePreviewPostMessageEventTypes,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n try {\n const { ssr, onChange } = Config.get();\n const event_type = event.data._metadata?.event_type;\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n\n // This section will run when there is a change in the entry and the website is CSR\n if (!ssr && !event_type) {\n onChange();\n } \n\n if(isOpeningInNewTab()) {\n if(!window) {\n PublicLogger.error(\"window is not defined\");\n return;\n };\n \n // This section will run when there is a change in the entry and the website is SSR\n if(ssr && !event_type) {\n if(window.location.href.includes(\"live_preview\")) {\n window.location.reload();\n } else {\n const url = new URL(window.location.href);\n url.searchParams.set(\"live_preview\", event.data.hash);\n url.searchParams.set(\"content_type_uid\", Config.get().stackDetails.contentTypeUid || \"\");\n url.searchParams.set(\"entry_uid\", Config.get().stackDetails.entryUid || \"\");\n window.location.href = url.toString();\n }\n }\n \n // This section will run when the hash changes and the website is SSR or CSR\n if(event_type === OnChangeLivePreviewPostMessageEventTypes.HASH_CHANGE){\n const newUrl = new URL(window.location.href);\n newUrl.searchParams.set(\"live_preview\", event.data.hash);\n window.history.pushState({}, \"\", newUrl.toString());\n }\n \n // This section will run when the URL of the page changes\n if(event_type === OnChangeLivePreviewPostMessageEventTypes.URL_CHANGE && event.data.url){\n window.location.href = event.data.url;\n }\n }\n\n \n } catch (error) {\n PublicLogger.error(\"Error handling live preview update:\", error);\n return;\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline() || isOpeningInNewTab()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .catch(() => {\n // TODO: add debug logs that runs conditionally\n });\n}\n"],"mappings":";;;AA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B,UAAU;AAE5B,0BAAoB;AAAA,QAChB,kBAAkB;AAAA,QAClB,WAAW;AAAA,MACf,CAAC;AAAA,IACL,OAAO;AAAA,IAKP;AACA,QAAI,OAAO,IAAI,EAAE,OAAO,oBAAoB,KAAK,kBAAkB,GAAG;AAClE,qBAAe;AAAA,IACnB;AACA,WAAO,IAAI,cAAc,UAAU;AAGnC,QAAI,CAAC,OAAO,IAAI,EAAE,KAAK;AACnB,kBAAY,MAAM;AACd,2CAAmC;AAAA,MACvC,GAAG,IAAI;AAAA,IACX;AAEA,+BAA2B;AAC3B,qCAAiC;AAAA,EACrC,GACC,MAAM,CAAC,MAAM;AAAA,EAGd;AACR;AAEA,SAAS,qCAA2C;AAnKpD;AAoKI,sDACM,KAAK,iCAAiC,kBAAkB;AAAA,IACtD,MAAM,OAAO,SAAS;AAAA,EAC1B,GACC,MAAM,MAAM;AAAA,EAEb;AACR;","names":["_a"]}
1
+ {"version":3,"sources":["../../../../src/livePreview/eventManager/postMessageEvent.hooks.ts"],"sourcesContent":["import { isOpeningInNewTab } from \"../../common/inIframe\";\nimport Config, { setConfigFromParams } from \"../../configManager/configManager\";\nimport { PublicLogger } from \"../../logger/logger\";\nimport { ILivePreviewWindowType } from \"../../types/types\";\nimport { addParamsToUrl, isOpeningInTimeline } from \"../../utils\";\nimport livePreviewPostMessage from \"./livePreviewEventManager\";\nimport { LIVE_PREVIEW_POST_MESSAGE_EVENTS } from \"./livePreviewEventManager.constant\";\nimport {\n HistoryLivePreviewPostMessageEventData,\n LivePreviewInitEventResponse,\n OnChangeLivePreviewPostMessageEventData,\n OnChangeLivePreviewPostMessageEventTypes,\n} from \"./types/livePreviewPostMessageEvent.type\";\n\n/**\n * Registers a post message event listener for history-related events.\n * The listener handles events for forward, backward, and reload actions on the browser history.\n */\nexport function useHistoryPostMessageEvent(): void {\n livePreviewPostMessage?.on<HistoryLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.HISTORY,\n (event) => {\n switch (event.data.type) {\n case \"forward\": {\n window.history.forward();\n break;\n }\n case \"backward\": {\n window.history.back();\n break;\n }\n case \"reload\": {\n window.history.go();\n break;\n }\n default: {\n const exhaustiveCheck: never = event.data.type;\n throw new Error(`Unhandled event: ${exhaustiveCheck}`);\n }\n }\n }\n );\n}\n\n/**\n * Registers a post message event listener for updating the entry in the live preview.\n */\nexport function useOnEntryUpdatePostMessageEvent(): void {\n livePreviewPostMessage?.on<OnChangeLivePreviewPostMessageEventData>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.ON_CHANGE,\n (event) => {\n try {\n const { ssr, onChange, stackDetails } = Config.get();\n const event_type = event.data._metadata?.event_type;\n setConfigFromParams({\n live_preview: event.data.hash,\n });\n\n // This section will run when there is a change in the entry and the website is CSR\n if (!ssr && !event_type) {\n onChange();\n }\n\n if (isOpeningInNewTab()) {\n if (!window) {\n PublicLogger.error(\"window is not defined\");\n return;\n };\n\n if (ssr && !event_type) {\n const url = new URL(window.location.href);\n let live_preview = url.searchParams.get(\"live_preview\");\n let content_type_uid = url.searchParams.get(\"content_type_uid\");\n let entry_uid = url.searchParams.get(\"entry_uid\");\n\n if (live_preview && content_type_uid && entry_uid) {\n // All required params are present, just reload\n window.location.reload();\n } else {\n live_preview = event.data.hash;\n content_type_uid = event.data.content_type_uid || stackDetails.$contentTypeUid?.toString() || \"\";\n entry_uid = event.data.entry_uid || stackDetails.$entryUid?.toString() || \"\";\n // Set missing params and redirect\n url.searchParams.set(\"live_preview\", live_preview);\n if (content_type_uid) {\n url.searchParams.set(\n \"content_type_uid\",\n content_type_uid\n );\n }\n if (entry_uid) {\n url.searchParams.set(\n \"entry_uid\",\n entry_uid\n );\n }\n window.location.href = url.toString();\n }\n }\n\n // This section will run when the hash changes and the website is SSR or CSR\n if (event_type === OnChangeLivePreviewPostMessageEventTypes.HASH_CHANGE) {\n const newUrl = new URL(window.location.href);\n newUrl.searchParams.set(\"live_preview\", event.data.hash);\n window.history.pushState({}, \"\", newUrl.toString());\n }\n\n // This section will run when the URL of the page changes\n if (event_type === OnChangeLivePreviewPostMessageEventTypes.URL_CHANGE && event.data.url) {\n window.location.href = event.data.url;\n }\n }\n } catch (error) {\n PublicLogger.error(\"Error handling live preview update:\", error);\n return;\n }\n }\n );\n}\n\nexport function sendInitializeLivePreviewPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send<LivePreviewInitEventResponse>(\n LIVE_PREVIEW_POST_MESSAGE_EVENTS.INIT,\n {\n config: {\n shouldReload: Config.get().ssr,\n href: window.location.href,\n sdkVersion: process?.env?.PACKAGE_VERSION,\n mode: Config.get().mode,\n },\n }\n )\n .then((data) => {\n const {\n contentTypeUid,\n entryUid,\n windowType = ILivePreviewWindowType.PREVIEW,\n } = data || {};\n\n // TODO: This is a fix for the issue where we were calling sending init in the builder\n // Let's remove this condition when we fix it.\n if (Config?.get()?.windowType && Config.get().windowType === ILivePreviewWindowType.BUILDER) {\n return;\n }\n\n if (contentTypeUid && entryUid) {\n // TODO: we should not use this function. Instead we should have sideEffect run automatically when we set the config.\n setConfigFromParams({\n content_type_uid: contentTypeUid,\n entry_uid: entryUid,\n });\n } else {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\n // \"init message did not contain contentTypeUid or entryUid.\"\n // );\n }\n if (Config.get().ssr || isOpeningInTimeline() || isOpeningInNewTab()) {\n addParamsToUrl();\n }\n Config.set(\"windowType\", windowType);\n\n // set timeout for client side (use to show warning: You are not editing this page)\n if (!Config.get().ssr) {\n setInterval(() => {\n sendCurrentPageUrlPostMessageEvent();\n }, 1500);\n }\n\n useHistoryPostMessageEvent();\n useOnEntryUpdatePostMessageEvent();\n })\n .catch((e) => {\n // TODO: add debug logs that runs conditionally\n // PublicLogger.debug(\"Error while sending init message\", e);\n });\n}\n\nfunction sendCurrentPageUrlPostMessageEvent(): void {\n livePreviewPostMessage\n ?.send(LIVE_PREVIEW_POST_MESSAGE_EVENTS.CHECK_ENTRY_PAGE, {\n href: window.location.href,\n })\n .cat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AAS;AAAA,QACtB,YAAY;AAAA,QACZ,MAAM,OAAO,IAAI,EAAE;AAAA,MACvB;AAAA,IACJ;AAAA,IAEH,KAAK,CAAC,SAAS;AArIxB,QAAAA,KAAA;AAsIY,UAAM;AAAA,MACF;AAAA,MACA;AAAA,MACA,aAAa,uBAAuB;AAAA,IACxC,IAAI,QAAQ,CAAC;AAIb,UAAI,MAAAA,MAAA,2BAAAA,IAAQ,UAAR,mBAAe,eAAc,OAAO,IAAI,EAAE,eAAe,uBAAuB,SAAS;AACzF;AAAA,IACJ;AAEA,QAAI,kBAAkB,UAAU;AAE5B,0BAAoB;AAAA,QAChB,kBAAkB;AAAA,QAClB,WAAW;AAAA,MACf,CAAC;AAAA,IACL,OAAO;AAAA,IAKP;AACA,QAAI,OAAO,IAAI,EAAE,OAAO,oBAAoB,KAAK,kBAAkB,GAAG;AAClE,qBAAe;AAAA,IACnB;AACA,WAAO,IAAI,cAAc,UAAU;AAGnC,QAAI,CAAC,OAAO,IAAI,EAAE,KAAK;AACnB,kBAAY,MAAM;AACd,2CAAmC;AAAA,MACvC,GAAG,IAAI;AAAA,IACX;AAEA,+BAA2B;AAC3B,qCAAiC;AAAA,EACrC,GACC,MAAM,CAAC,MAAM;AAAA,EAGd;AACR;AAEA,SAAS,qCAA2C;AAnLpD;AAoLI,sDACM,KAAK,iCAAiC,kBAAkB;AAAA,IACtD,MAAM,OAAO,SAAS;AAAA,EAC1B,GACC,MAAM,MAAM;AAAA,EAEb;AACR;","names":["_a"]}
@@ -227,7 +227,7 @@ var _ContentstackLivePreview = class _ContentstackLivePreview {
227
227
  * @returns The version of the SDK as a string.
228
228
  */
229
229
  static getSdkVersion() {
230
- return "4.0.1";
230
+ return "4.1.0";
231
231
  }
232
232
  };
233
233
  _ContentstackLivePreview.previewConstructors = {};
@@ -195,7 +195,7 @@ var _ContentstackLivePreview = class _ContentstackLivePreview {
195
195
  * @returns The version of the SDK as a string.
196
196
  */
197
197
  static getSdkVersion() {
198
- return "4.0.1";
198
+ return "4.1.0";
199
199
  }
200
200
  };
201
201
  _ContentstackLivePreview.previewConstructors = {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/visualBuilder/components/VariantIndicator.tsx
21
+ var VariantIndicator_exports = {};
22
+ __export(VariantIndicator_exports, {
23
+ VariantIndicator: () => VariantIndicator
24
+ });
25
+ module.exports = __toCommonJS(VariantIndicator_exports);
26
+ var import_variant = require("./icons/variant.cjs");
27
+ var import_visualBuilder = require("../visualBuilder.style.cjs");
28
+ var import_jsx_runtime = require("preact/jsx-runtime");
29
+ function VariantIndicator() {
30
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__variant-indicator"], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_variant.VariantIcon, { size: "18px" }) });
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ VariantIndicator
35
+ });
36
+ //# sourceMappingURL=VariantIndicator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/visualBuilder/components/VariantIndicator.tsx"],"sourcesContent":["import React from \"preact/compat\";\nimport { VariantIcon } from \"./icons/variant\";\nimport { visualBuilderStyles } from \"../visualBuilder.style\";\n\nexport function VariantIndicator(): JSX.Element {\n return (\n <div className={visualBuilderStyles()[\"visual-builder__variant-indicator\"]}>\n <VariantIcon size=\"18px\" />\n </div>\n );\n\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAA4B;AAC5B,2BAAoC;AAKxB;AAHL,SAAS,mBAAgC;AAC5C,SACI,4CAAC,SAAI,eAAW,0CAAoB,EAAE,mCAAmC,GACrE,sDAAC,8BAAY,MAAK,QAAO,GAC7B;AAGR;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare function VariantIndicator(): JSX.Element;
2
+
3
+ export { VariantIndicator };
@@ -0,0 +1,3 @@
1
+ declare function VariantIndicator(): JSX.Element;
2
+
3
+ export { VariantIndicator };
@@ -0,0 +1,13 @@
1
+ import "../../chunk-5WRI5ZAA.js";
2
+
3
+ // src/visualBuilder/components/VariantIndicator.tsx
4
+ import { VariantIcon } from "./icons/variant.js";
5
+ import { visualBuilderStyles } from "../visualBuilder.style.js";
6
+ import { jsx } from "preact/jsx-runtime";
7
+ function VariantIndicator() {
8
+ return /* @__PURE__ */ jsx("div", { className: visualBuilderStyles()["visual-builder__variant-indicator"], children: /* @__PURE__ */ jsx(VariantIcon, { size: "18px" }) });
9
+ }
10
+ export {
11
+ VariantIndicator
12
+ };
13
+ //# sourceMappingURL=VariantIndicator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/visualBuilder/components/VariantIndicator.tsx"],"sourcesContent":["import React from \"preact/compat\";\nimport { VariantIcon } from \"./icons/variant\";\nimport { visualBuilderStyles } from \"../visualBuilder.style\";\n\nexport function VariantIndicator(): JSX.Element {\n return (\n <div className={visualBuilderStyles()[\"visual-builder__variant-indicator\"]}>\n <VariantIcon size=\"18px\" />\n </div>\n );\n\n}"],"mappings":";;;AACA,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AAKxB;AAHL,SAAS,mBAAgC;AAC5C,SACI,oBAAC,SAAI,WAAW,oBAAoB,EAAE,mCAAmC,GACrE,8BAAC,eAAY,MAAK,QAAO,GAC7B;AAGR;","names":[]}
@@ -50,6 +50,7 @@ var import_postMessage = require("../utils/types/postMessage.types.cjs");
50
50
  var import_icons2 = require("./icons/index.cjs");
51
51
  var import_Tooltip = require("./Tooltip.cjs");
52
52
  var import_fetchEntryPermissionsAndStageDetails = require("../utils/fetchEntryPermissionsAndStageDetails.cjs");
53
+ var import_VariantIndicator = require("./VariantIndicator.cjs");
53
54
  var import_jsx_runtime = require("preact/jsx-runtime");
54
55
  async function getFieldDisplayNames(fieldMetadata) {
55
56
  var _a;
@@ -212,135 +213,144 @@ function FieldLabelWrapperComponent(props) {
212
213
  return currentField.icon;
213
214
  }
214
215
  }
215
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
216
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
216
217
  "div",
217
218
  {
218
219
  className: (0, import_classnames.default)(
219
220
  "visual-builder__focused-toolbar__field-label-container",
220
221
  (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-container"]
221
222
  ),
222
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Tooltip.ToolbarTooltip, { data: { contentTypeName: currentField.parentContentTypeName, referenceFieldName: currentField.referenceFieldName }, disabled: !currentField.isReference || isDropdownOpen, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
223
- "div",
224
- {
225
- className: (0, import_classnames.default)(
226
- "visual-builder__focused-toolbar__field-label-wrapper",
227
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper"],
228
- {
229
- "visual-builder__focused-toolbar--field-disabled": currentField.disabled
230
- },
231
- {
232
- [(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar--field-disabled"]]: currentField.disabled
233
- },
234
- {
235
- "field-label-dropdown-open": isDropdownOpen,
236
- [(0, import_visualBuilder.visualBuilderStyles)()["field-label-dropdown-open"]]: isDropdownOpen
237
- }
238
- ),
239
- onClick: () => setIsDropdownOpen((prev) => !prev),
240
- "data-testid": "visual-builder__focused-toolbar__field-label-wrapper",
241
- "data-hovered-cslp": props.fieldMetadata.cslpValue,
242
- children: [
243
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
244
- "button",
223
+ children: [
224
+ currentField.isVariant ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_VariantIndicator.VariantIndicator, {}) : null,
225
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Tooltip.ToolbarTooltip, { data: { contentTypeName: currentField.parentContentTypeName, referenceFieldName: currentField.referenceFieldName }, disabled: !currentField.isReference || isDropdownOpen, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
226
+ "div",
227
+ {
228
+ className: (0, import_classnames.default)(
229
+ "visual-builder__focused-toolbar__field-label-wrapper",
230
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper"],
231
+ {
232
+ "visual-builder__focused-toolbar--field-disabled": currentField.disabled
233
+ },
234
+ {
235
+ [(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar--field-disabled"]]: currentField.disabled
236
+ },
245
237
  {
246
- className: (0, import_classnames.default)(
247
- "visual-builder__focused-toolbar__field-label-wrapper__current-field visual-builder__button visual-builder__button--primary visual-builder__button-loader",
248
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper__current-field"],
249
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button"],
250
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button--primary"],
251
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button-loader"],
252
- error && (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button-error"]
253
- ),
254
- disabled: dataLoading,
255
- children: [
256
- currentField.isReference && !dataLoading && !error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
257
- "div",
258
- {
259
- className: (0, import_classnames.default)(
260
- "visual-builder__reference-icon-container",
261
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__reference-icon-container"]
262
- ),
263
- children: [
264
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
265
- "div",
266
- {
267
- className: (0, import_classnames.default)(
268
- "visual-builder__field-icon",
269
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-icon"]
270
- ),
271
- dangerouslySetInnerHTML: {
272
- __html: import_generateCustomCursor.FieldTypeIconsMap.reference
273
- },
274
- "data-testid": "visual-builder__field-icon-caret"
275
- }
238
+ "field-label-dropdown-open": isDropdownOpen,
239
+ [(0, import_visualBuilder.visualBuilderStyles)()["field-label-dropdown-open"]]: isDropdownOpen
240
+ },
241
+ {
242
+ "visual-builder__focused-toolbar--variant": currentField.isVariant
243
+ },
244
+ {
245
+ [(0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar--variant"]]: currentField.isVariant
246
+ }
247
+ ),
248
+ onClick: () => setIsDropdownOpen((prev) => !prev),
249
+ "data-testid": "visual-builder__focused-toolbar__field-label-wrapper",
250
+ "data-hovered-cslp": props.fieldMetadata.cslpValue,
251
+ children: [
252
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
253
+ "button",
254
+ {
255
+ className: (0, import_classnames.default)(
256
+ "visual-builder__focused-toolbar__field-label-wrapper__current-field visual-builder__button visual-builder__button--primary visual-builder__button-loader",
257
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper__current-field"],
258
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button"],
259
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button--primary"],
260
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button-loader"],
261
+ error && (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button-error"]
262
+ ),
263
+ disabled: dataLoading,
264
+ children: [
265
+ currentField.isReference && !dataLoading && !error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
266
+ "div",
267
+ {
268
+ className: (0, import_classnames.default)(
269
+ "visual-builder__reference-icon-container",
270
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__reference-icon-container"]
271
+ ),
272
+ children: [
273
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
274
+ "div",
275
+ {
276
+ className: (0, import_classnames.default)(
277
+ "visual-builder__field-icon",
278
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-icon"]
279
+ ),
280
+ dangerouslySetInnerHTML: {
281
+ __html: import_generateCustomCursor.FieldTypeIconsMap.reference
282
+ },
283
+ "data-testid": "visual-builder__field-icon-caret"
284
+ }
285
+ ),
286
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CaretRightIcon, {})
287
+ ]
288
+ }
289
+ ) : null,
290
+ currentField.contentTypeName && !dataLoading && !error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
291
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.ContentTypeIcon, {}),
292
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
293
+ "div",
294
+ {
295
+ className: (0, import_classnames.default)(
296
+ "visual-builder__focused-toolbar__text",
297
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
298
+ ),
299
+ "data-testid": "visual-builder__focused-toolbar__ct-name",
300
+ children: currentField.contentTypeName + " : "
301
+ }
302
+ )
303
+ ] }) : null,
304
+ currentField.prefixIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
305
+ "div",
306
+ {
307
+ className: (0, import_classnames.default)(
308
+ "visual-builder__field-icon",
309
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-icon"]
276
310
  ),
277
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CaretRightIcon, {})
278
- ]
279
- }
280
- ) : null,
281
- currentField.contentTypeName && !dataLoading && !error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
282
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.ContentTypeIcon, {}),
283
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
311
+ dangerouslySetInnerHTML: {
312
+ __html: currentField.prefixIcon
313
+ },
314
+ "data-testid": "visual-builder__field-icon"
315
+ }
316
+ ) : null,
317
+ currentField.text ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
284
318
  "div",
285
319
  {
286
320
  className: (0, import_classnames.default)(
287
321
  "visual-builder__focused-toolbar__text",
288
322
  (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
289
323
  ),
290
- "data-testid": "visual-builder__focused-toolbar__ct-name",
291
- children: currentField.contentTypeName + " : "
324
+ "data-testid": "visual-builder__focused-toolbar__text",
325
+ children: currentField.text
292
326
  }
293
- )
294
- ] }) : null,
295
- currentField.prefixIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
296
- "div",
297
- {
298
- className: (0, import_classnames.default)(
299
- "visual-builder__field-icon",
300
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__field-icon"]
301
- ),
302
- dangerouslySetInnerHTML: {
303
- __html: currentField.prefixIcon
304
- },
305
- "data-testid": "visual-builder__field-icon"
306
- }
307
- ) : null,
308
- currentField.text ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
309
- "div",
310
- {
311
- className: (0, import_classnames.default)(
312
- "visual-builder__focused-toolbar__text",
313
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
314
- ),
315
- "data-testid": "visual-builder__focused-toolbar__text",
316
- children: currentField.text
317
- }
318
- ) : null,
319
- getCurrentFieldIcon(),
320
- error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_CslpError.CslpError, {}) : null
321
- ]
322
- }
323
- ),
324
- props.parentPaths.map((path, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
325
- "button",
326
- {
327
- className: (0, import_classnames.default)(
328
- "visual-builder__focused-toolbar__field-label-wrapper__parent-field visual-builder__button visual-builder__button--secondary visual-builder__focused-toolbar__text",
329
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper__parent-field"],
330
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button"],
331
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button--secondary"],
332
- (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
333
- ),
334
- "data-target-cslp": path,
335
- style: { top: calculateTopOffset(index) },
336
- onClick: () => onParentPathClick(path),
337
- children: displayNames[path]
338
- },
339
- path
340
- ))
341
- ]
342
- }
343
- ) })
327
+ ) : null,
328
+ getCurrentFieldIcon(),
329
+ error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_CslpError.CslpError, {}) : null
330
+ ]
331
+ }
332
+ ),
333
+ props.parentPaths.map((path, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
334
+ "button",
335
+ {
336
+ className: (0, import_classnames.default)(
337
+ "visual-builder__focused-toolbar__field-label-wrapper__parent-field visual-builder__button visual-builder__button--secondary visual-builder__focused-toolbar__text",
338
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__field-label-wrapper__parent-field"],
339
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button"],
340
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__button--secondary"],
341
+ (0, import_visualBuilder.visualBuilderStyles)()["visual-builder__focused-toolbar__text"]
342
+ ),
343
+ "data-target-cslp": path,
344
+ style: { top: calculateTopOffset(index) },
345
+ onClick: () => onParentPathClick(path),
346
+ children: displayNames[path]
347
+ },
348
+ path
349
+ ))
350
+ ]
351
+ }
352
+ ) })
353
+ ]
344
354
  }
345
355
  );
346
356
  }