@contentstack/live-preview-utils 4.3.0 → 4.4.1

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 (110) hide show
  1. package/README.md +96 -30
  2. package/dist/legacy/chunk-HZF5SLJ7.js +625 -0
  3. package/dist/legacy/chunk-HZF5SLJ7.js.map +1 -0
  4. package/dist/legacy/index.d.cts +1 -1
  5. package/dist/legacy/index.d.ts +1 -1
  6. package/dist/legacy/light-sdk.cjs +1 -1
  7. package/dist/legacy/light-sdk.cjs.map +1 -1
  8. package/dist/legacy/light-sdk.js +1 -1
  9. package/dist/legacy/light-sdk.js.map +1 -1
  10. package/dist/legacy/livePreview/editButton/editButton.cjs +2 -0
  11. package/dist/legacy/livePreview/editButton/editButton.cjs.map +1 -1
  12. package/dist/legacy/livePreview/editButton/editButton.js +2 -0
  13. package/dist/legacy/livePreview/editButton/editButton.js.map +1 -1
  14. package/dist/legacy/livePreview/eventManager/livePreviewEventManager.cjs +172 -432
  15. package/dist/legacy/livePreview/eventManager/livePreviewEventManager.cjs.map +1 -1
  16. package/dist/legacy/livePreview/eventManager/livePreviewEventManager.js +1 -1
  17. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.cjs +1 -1
  18. package/dist/legacy/livePreview/eventManager/postMessageEvent.hooks.js +1 -1
  19. package/dist/legacy/preview/contentstack-live-preview-HOC.cjs +1 -1
  20. package/dist/legacy/preview/contentstack-live-preview-HOC.js +1 -1
  21. package/dist/legacy/timeline/timelinePostMessage/timelinePostMessage.cjs +172 -432
  22. package/dist/legacy/timeline/timelinePostMessage/timelinePostMessage.cjs.map +1 -1
  23. package/dist/legacy/timeline/timelinePostMessage/timelinePostMessage.js +1 -1
  24. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs +111 -27
  25. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  26. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js +112 -28
  27. package/dist/legacy/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  28. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.cjs +4 -0
  29. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.cjs.map +1 -1
  30. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.d.cts +8 -1
  31. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.d.ts +8 -1
  32. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.js +4 -0
  33. package/dist/legacy/visualBuilder/utils/getWorkflowStageDetails.js.map +1 -1
  34. package/dist/legacy/visualBuilder/utils/isFieldDisabled.cjs +41 -6
  35. package/dist/legacy/visualBuilder/utils/isFieldDisabled.cjs.map +1 -1
  36. package/dist/legacy/visualBuilder/utils/isFieldDisabled.d.cts +9 -1
  37. package/dist/legacy/visualBuilder/utils/isFieldDisabled.d.ts +9 -1
  38. package/dist/legacy/visualBuilder/utils/isFieldDisabled.js +41 -6
  39. package/dist/legacy/visualBuilder/utils/isFieldDisabled.js.map +1 -1
  40. package/dist/legacy/visualBuilder/utils/types/postMessage.types.cjs +1 -0
  41. package/dist/legacy/visualBuilder/utils/types/postMessage.types.cjs.map +1 -1
  42. package/dist/legacy/visualBuilder/utils/types/postMessage.types.d.cts +1 -0
  43. package/dist/legacy/visualBuilder/utils/types/postMessage.types.d.ts +1 -0
  44. package/dist/legacy/visualBuilder/utils/types/postMessage.types.js +1 -0
  45. package/dist/legacy/visualBuilder/utils/types/postMessage.types.js.map +1 -1
  46. package/dist/legacy/visualBuilder/utils/visualBuilderPostMessage.cjs +172 -432
  47. package/dist/legacy/visualBuilder/utils/visualBuilderPostMessage.cjs.map +1 -1
  48. package/dist/legacy/visualBuilder/utils/visualBuilderPostMessage.js +1 -1
  49. package/dist/legacy/visualBuilder/visualBuilder.style.cjs +30 -0
  50. package/dist/legacy/visualBuilder/visualBuilder.style.cjs.map +1 -1
  51. package/dist/legacy/visualBuilder/visualBuilder.style.d.cts +5 -0
  52. package/dist/legacy/visualBuilder/visualBuilder.style.d.ts +5 -0
  53. package/dist/legacy/visualBuilder/visualBuilder.style.js +30 -0
  54. package/dist/legacy/visualBuilder/visualBuilder.style.js.map +1 -1
  55. package/dist/modern/chunk-4RUJZCI2.js +625 -0
  56. package/dist/modern/chunk-4RUJZCI2.js.map +1 -0
  57. package/dist/modern/light-sdk.cjs +1 -1
  58. package/dist/modern/light-sdk.cjs.map +1 -1
  59. package/dist/modern/light-sdk.js +1 -1
  60. package/dist/modern/light-sdk.js.map +1 -1
  61. package/dist/modern/livePreview/editButton/editButton.cjs +2 -0
  62. package/dist/modern/livePreview/editButton/editButton.cjs.map +1 -1
  63. package/dist/modern/livePreview/editButton/editButton.js +2 -0
  64. package/dist/modern/livePreview/editButton/editButton.js.map +1 -1
  65. package/dist/modern/livePreview/eventManager/livePreviewEventManager.cjs +172 -432
  66. package/dist/modern/livePreview/eventManager/livePreviewEventManager.cjs.map +1 -1
  67. package/dist/modern/livePreview/eventManager/livePreviewEventManager.js +1 -1
  68. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.cjs +1 -1
  69. package/dist/modern/livePreview/eventManager/postMessageEvent.hooks.js +1 -1
  70. package/dist/modern/preview/contentstack-live-preview-HOC.cjs +1 -1
  71. package/dist/modern/preview/contentstack-live-preview-HOC.js +1 -1
  72. package/dist/modern/timeline/timelinePostMessage/timelinePostMessage.cjs +172 -432
  73. package/dist/modern/timeline/timelinePostMessage/timelinePostMessage.cjs.map +1 -1
  74. package/dist/modern/timeline/timelinePostMessage/timelinePostMessage.js +1 -1
  75. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs +110 -27
  76. package/dist/modern/visualBuilder/components/fieldLabelWrapper.cjs.map +1 -1
  77. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js +111 -28
  78. package/dist/modern/visualBuilder/components/fieldLabelWrapper.js.map +1 -1
  79. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.cjs +4 -0
  80. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.cjs.map +1 -1
  81. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.d.cts +8 -1
  82. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.d.ts +8 -1
  83. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.js +4 -0
  84. package/dist/modern/visualBuilder/utils/getWorkflowStageDetails.js.map +1 -1
  85. package/dist/modern/visualBuilder/utils/isFieldDisabled.cjs +40 -6
  86. package/dist/modern/visualBuilder/utils/isFieldDisabled.cjs.map +1 -1
  87. package/dist/modern/visualBuilder/utils/isFieldDisabled.d.cts +9 -1
  88. package/dist/modern/visualBuilder/utils/isFieldDisabled.d.ts +9 -1
  89. package/dist/modern/visualBuilder/utils/isFieldDisabled.js +40 -6
  90. package/dist/modern/visualBuilder/utils/isFieldDisabled.js.map +1 -1
  91. package/dist/modern/visualBuilder/utils/types/postMessage.types.cjs +1 -0
  92. package/dist/modern/visualBuilder/utils/types/postMessage.types.cjs.map +1 -1
  93. package/dist/modern/visualBuilder/utils/types/postMessage.types.d.cts +1 -0
  94. package/dist/modern/visualBuilder/utils/types/postMessage.types.d.ts +1 -0
  95. package/dist/modern/visualBuilder/utils/types/postMessage.types.js +1 -0
  96. package/dist/modern/visualBuilder/utils/types/postMessage.types.js.map +1 -1
  97. package/dist/modern/visualBuilder/utils/visualBuilderPostMessage.cjs +172 -432
  98. package/dist/modern/visualBuilder/utils/visualBuilderPostMessage.cjs.map +1 -1
  99. package/dist/modern/visualBuilder/utils/visualBuilderPostMessage.js +1 -1
  100. package/dist/modern/visualBuilder/visualBuilder.style.cjs +30 -0
  101. package/dist/modern/visualBuilder/visualBuilder.style.cjs.map +1 -1
  102. package/dist/modern/visualBuilder/visualBuilder.style.d.cts +5 -0
  103. package/dist/modern/visualBuilder/visualBuilder.style.d.ts +5 -0
  104. package/dist/modern/visualBuilder/visualBuilder.style.js +30 -0
  105. package/dist/modern/visualBuilder/visualBuilder.style.js.map +1 -1
  106. package/package.json +9 -9
  107. package/dist/legacy/chunk-7SRLYDRL.js +0 -885
  108. package/dist/legacy/chunk-7SRLYDRL.js.map +0 -1
  109. package/dist/modern/chunk-JYE4G3PN.js +0 -885
  110. package/dist/modern/chunk-JYE4G3PN.js.map +0 -1
package/README.md CHANGED
@@ -1,60 +1,126 @@
1
- # Contentstack Live Preview Utils SDK
1
+ # @contentstack/live-preview-utils
2
2
 
3
- Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest.
3
+ [![npm](https://img.shields.io/npm/v/@contentstack/live-preview-utils.svg)](https://www.npmjs.com/package/@contentstack/live-preview-utils)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
4
5
 
5
- Contentstack provides the Live Preview Utils SDK to establish a communication channel between the various Contentstack SDKs and your website, transmitting live changes to the preview pane. [Read More](https://www.contentstack.com/docs/content-managers/live-preview/).
6
+ The **Live Preview Utils** package runs on your website and establishes a communication channel between the page and Contentstack. This enables live content updates, edit controls, and Visual Editor UI within the preview surface.
6
7
 
7
- # Installation
8
+ This SDK is not a replacement for Contentstack delivery SDKs. Instead, it acts as a client-side bridge for preview and Visual Editor functionality.
8
9
 
9
- To install the package via npm, use the following command:
10
+ ## Where this SDK runs
11
+
12
+ The SDK works across multiple Contentstack preview and editing experiences:
13
+
14
+ - [**Live Preview**](https://www.contentstack.com/docs/content-managers/author-content/about-live-preview): Preview entries while your site loads inside the preview panel.
15
+ - [**Timeline**](https://www.contentstack.com/docs/content-managers/timeline/about-timeline): Preview how your site appears across future dates and scheduled updates using the same Live Preview setup.
16
+ - [**Visual Editor**](https://www.contentstack.com/docs/content-managers/visual-editor/about-visual-editor): Enable WYSIWYG editing with your site inside an iframe. Use [`mode: "builder"`](docs/live-preview-configs.md#mode) so “Start Editing” targets Visual Editor; the SDK still works when the same site is opened in Live Preview.
17
+ - [**Studio**](https://www.contentstack.com/docs/studio/about-studio): Use alongside Studio to structure pages from reusable components, bind CMS data, and preview changes in real time. It is designed to work with [Live Preview and Visual Editor](https://www.contentstack.com/docs/studio/live-preview-and-visual-editing-with-studio) on your connected site.
18
+
19
+ ## Requirements
20
+
21
+ - **Browser:** Initialize only on the client (`window` must exist). Avoid calling `init` during server-side rendering.
22
+ - **SSR vs CSR:** Defaults assume SSR-friendly behavior. For **client-side rendering**, pass [`stackSdk`](docs/live-preview-configs.md#stacksdk) and set [`ssr: false`](docs/live-preview-configs.md#ssr) as described in the config reference.
23
+
24
+ ## Installation
10
25
 
11
26
  ```bash
12
27
  npm install @contentstack/live-preview-utils
13
28
  ```
14
29
 
15
- Alternatively, if you want to include the package directly in your website HTML code, use the following command:
30
+ ### Load from a CDN (advanced)
31
+
32
+ Pin the version to match your app (update `4.4.1` when you upgrade):
16
33
 
17
34
  ```html
18
- <script type='module' crossorigin="anonymous">
19
- import ContentstackLivePreview from 'https://esm.sh/@contentstack/live-preview-utils@4.3.0';
20
-
21
- ContentstackLivePreview.init({
22
- stackDetails: {
23
- apiKey: "your-stack-api-key",
24
- },
25
- });
35
+ <script type="module" crossorigin="anonymous">
36
+ import ContentstackLivePreview from "https://esm.sh/@contentstack/live-preview-utils@4.4.1";
37
+
38
+ ContentstackLivePreview.init({
39
+ stackDetails: {
40
+ apiKey: "your-stack-api-key",
41
+ },
42
+ });
26
43
  </script>
27
44
  ```
28
- > [!NOTE]
29
- > This step involves incorporating the package into your HTML code and initializing it, eliminating the need for re-initialization in the subsequent step.
30
45
 
46
+ > [!TIP]
47
+ > If you initialize the SDK using this snippet, do not initialize it again in your app bundle on the same page.
31
48
 
32
- # Initializing the SDK
49
+ ## Quick start
33
50
 
34
- ### Live Preview Utils
35
-
36
- Since the Live Preview Utils SDK is responsible for communication, you need to only initialize it.
37
- Use the following command to initialize the SDK:
51
+ Initialize the SDK to enable communication between your site and Contentstack:
38
52
 
39
53
  ```javascript
40
54
  import ContentstackLivePreview from "@contentstack/live-preview-utils";
41
55
 
42
56
  ContentstackLivePreview.init({
43
- stackDetails: {
44
- apiKey: "your-stack-api-key",
45
- },
57
+ stackDetails: {
58
+ apiKey: "your-stack-api-key",
59
+ },
46
60
  });
47
61
  ```
48
62
 
63
+ See the [`init` configuration properties](docs/live-preview-configs.md#initconfig-iconfig) in **[docs/live-preview-configs.md](docs/live-preview-configs.md)** for every option you can pass to `init`.
64
+
65
+ ## Configuration
66
+
67
+ You can configure the SDK using the following options:
68
+
69
+ - [`enable`](docs/live-preview-configs.md#enable)
70
+ - [`ssr`](docs/live-preview-configs.md#ssr)
71
+ - [`mode`](docs/live-preview-configs.md#mode) (`preview` vs `builder`)
72
+ - [`editButton`](docs/live-preview-configs.md#editbutton)
73
+ - [`editInVisualBuilderButton`](docs/live-preview-configs.md#editinvisualbuilderbutton) (Start Editing outside Visual Editor)
74
+ - [`cleanCslpOnProduction`](docs/live-preview-configs.md#cleancslponproduction)
75
+ - [`stackDetails`](docs/live-preview-configs.md#stackdetails) ([`apiKey`](docs/live-preview-configs.md#apikey), [`environment`](docs/live-preview-configs.md#environment))
76
+ - [`clientUrlParams`](docs/live-preview-configs.md#clienturlparams) — [NA](docs/live-preview-configs.md#na-config) / [EU](docs/live-preview-configs.md#eu-config)
77
+ - [`stackSdk`](docs/live-preview-configs.md#stacksdk)
78
+
79
+ Full tables and examples: **[docs/live-preview-configs.md](docs/live-preview-configs.md)**.
80
+
81
+ ### Methods and properties
82
+
83
+ - [`onLiveEdit`](docs/live-preview-configs.md#onliveeditcallback---void): Trigger actions on live edits
84
+ - [`onEntryChange`](docs/live-preview-configs.md#onentrychangecallback---void): Listen for entry updates
85
+ - [`hash`](docs/live-preview-configs.md#hash): Access preview state identifier
86
+ - [`config`](docs/live-preview-configs.md#config): Includes runtime context (for example Live Preview / Timeline preview, Visual Editor, or independent)
87
+
88
+ The [configs table of contents](docs/live-preview-configs.md#contentstack-live-preview-utils-sdk-configs) also lists `setConfigFromParams` and `getGatsbyDataFormat` for deeper workflows.
89
+
90
+ ## Advanced: stripping the SDK at build time
91
+
92
+ Set `PURGE_PREVIEW_SDK` or `REACT_APP_PURGE_PREVIEW_SDK` to `"true"` during build to exclude preview code from production bundles.
93
+
94
+ **Note:** This reduces bundle size by replacing the SDK with a lightweight stub in production.
95
+
96
+ ## Resources
97
+
98
+ - **Source:** [github.com/contentstack/live-preview-sdk](https://github.com/contentstack/live-preview-sdk)
99
+ - **Typed API (local):** `npm run docs`
100
+
101
+ ## Documentation and learning
102
+
103
+ ### Developers
104
+
105
+ - [Set up Live Preview for your website](https://www.contentstack.com/docs/developers/set-up-live-preview/set-up-live-preview-for-your-website)
106
+ - [How Live Preview works](https://www.contentstack.com/docs/developers/set-up-live-preview/how-live-preview-works)
107
+ - [Preview API](https://www.contentstack.com/docs/developers/set-up-timeline/preview-api)
108
+ - [Set up Timeline for your website](https://www.contentstack.com/docs/developers/set-up-timeline/set-up-timeline-for-your-website)
49
109
 
50
- # License
110
+ ### Content managers
51
111
 
52
- MIT License
112
+ - [About Live Preview](https://www.contentstack.com/docs/content-managers/author-content/about-live-preview)
113
+ - [Preview content across a Timeline](https://www.contentstack.com/docs/content-managers/timeline/preview-content-across-a-timeline)
114
+ - [About Visual Editor](https://www.contentstack.com/docs/content-managers/visual-editor/about-visual-editor)
53
115
 
54
- Copyright © 2021-2026 [Contentstack](https://www.contentstack.com/). All Rights Reserved
116
+ ### Studio
55
117
 
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:
118
+ - [Studio](https://www.contentstack.com/docs/studio)
119
+ - [Get started with Studio](https://www.contentstack.com/docs/studio/get-started-with-studio)
57
120
 
58
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
121
+ ### Academy
59
122
 
60
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
123
+ - [Implementing Live Preview (course)](https://www.contentstack.com/academy/courses/implementing-live-preview)
124
+ - [Contentstack Live Preview under the hood](https://www.contentstack.com/academy/content/contentstack-live-preview-under-the-hood)
125
+ - [Understanding Timeline](https://www.contentstack.com/academy/content/understanding-timeline)
126
+ - [Understanding Visual Editor](https://www.contentstack.com/academy/content/understanding-visual-builder)