@contentstack/studio-messenger 0.0.2
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.
- package/README.md +204 -0
- package/dist/cjs/index.cjs +121 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/constant.js +75 -0
- package/dist/esm/constant.js.map +1 -0
- package/dist/esm/index.d.ts +121 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/main.js +34 -0
- package/dist/esm/main.js.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Studio Messenger
|
|
2
|
+
|
|
3
|
+
A communication package that handles messaging between the Studio platform and iframe webpages using postMessage API.
|
|
4
|
+
|
|
5
|
+
<details>
|
|
6
|
+
<summary>Table of Contents</summary>
|
|
7
|
+
|
|
8
|
+
- [Studio Messenger](#studio-messenger)
|
|
9
|
+
- [Overview](#overview)
|
|
10
|
+
- [Features](#features)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Usage](#usage)
|
|
13
|
+
- [Basic Setup](#basic-setup)
|
|
14
|
+
- [Available Event Managers](#available-event-managers)
|
|
15
|
+
- [Sending Messages](#sending-messages)
|
|
16
|
+
- [Listening for Messages](#listening-for-messages)
|
|
17
|
+
- [API Reference](#api-reference)
|
|
18
|
+
- [Constants](#constants)
|
|
19
|
+
- [Channel IDs](#channel-ids)
|
|
20
|
+
- [Query Parameters](#query-parameters)
|
|
21
|
+
- [Event Types](#event-types)
|
|
22
|
+
- [Studio Events (`POST_MESSAGE_EVENTS`)](#studio-events-post_message_events)
|
|
23
|
+
- [Visual Builder Events (`VISUAL_BUILDER_POST_MESSAGE_EVENTS`)](#visual-builder-events-visual_builder_post_message_events)
|
|
24
|
+
- [Built-in Canvas Events (`COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS`)](#built-in-canvas-events-composable_studio_built_in_canvas_post_message_events)
|
|
25
|
+
- [Event Data Types](#event-data-types)
|
|
26
|
+
- [Development](#development)
|
|
27
|
+
- [Building](#building)
|
|
28
|
+
- [Development Mode](#development-mode)
|
|
29
|
+
- [Linting](#linting)
|
|
30
|
+
- [Architecture](#architecture)
|
|
31
|
+
- [Channel Flow](#channel-flow)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
</details>
|
|
35
|
+
|
|
36
|
+
## Overview
|
|
37
|
+
|
|
38
|
+
This package provides a robust messaging system for communication between different parts of the Studio ecosystem:
|
|
39
|
+
|
|
40
|
+
- **Studio** - The main editing interface
|
|
41
|
+
- **Visual Builder** - The visual editing interface
|
|
42
|
+
- **Built-in Canvas** - Embedded canvas components
|
|
43
|
+
- **Popup Windows** - Modal dialogs and popups
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- **Bidirectional Communication** - Send and receive messages between iframes and parent windows
|
|
48
|
+
- **Multiple Channels** - Separate communication channels for different contexts
|
|
49
|
+
- **Type Safety** - Full TypeScript support with typed event data
|
|
50
|
+
- **Event Management** - Built on `@contentstack/advanced-post-message` for reliable messaging
|
|
51
|
+
- **Debug Support** - Optional debug mode for development
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install @contentstack/studio-messenger
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
### Basic Setup
|
|
62
|
+
|
|
63
|
+
The package automatically initializes event managers when loaded in a browser environment:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import {
|
|
67
|
+
composableStudioEventManager,
|
|
68
|
+
visualBuilderEventManager,
|
|
69
|
+
composableStudioPopupEventManager,
|
|
70
|
+
composableStudioBuiltInCanvasEventManager
|
|
71
|
+
} from '@contentstack/studio-messenger';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Available Event Managers
|
|
75
|
+
|
|
76
|
+
- `composableStudioEventManager` - Main Studio communication
|
|
77
|
+
- `visualBuilderEventManager` - Visual Builder communication
|
|
78
|
+
- `composableStudioPopupEventManager` - Popup window communication
|
|
79
|
+
- `composableStudioBuiltInCanvasEventManager` - Built-in canvas communication
|
|
80
|
+
|
|
81
|
+
### Sending Messages
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
|
|
85
|
+
|
|
86
|
+
// Send a highlight node event
|
|
87
|
+
composableStudioEventManager?.emit(POST_MESSAGE_EVENTS.HIGHLIGHT_NODE, {
|
|
88
|
+
nodeId: 'my-node-id',
|
|
89
|
+
highlight: true
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Send a transform operation
|
|
93
|
+
composableStudioEventManager?.emit(POST_MESSAGE_EVENTS.TRANSFORM_OPERATION, {
|
|
94
|
+
operation: 'insert-node',
|
|
95
|
+
data: { /* operation data */ }
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Listening for Messages
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { visualBuilderEventManager, VISUAL_BUILDER_POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
|
|
103
|
+
|
|
104
|
+
// Listen for composition saved events
|
|
105
|
+
visualBuilderEventManager?.on(VISUAL_BUILDER_POST_MESSAGE_EVENTS.COMPOSITION_SAVED, (data) => {
|
|
106
|
+
console.log('Composition saved:', data);
|
|
107
|
+
// Handle the saved composition
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## API Reference
|
|
112
|
+
|
|
113
|
+
### Constants
|
|
114
|
+
|
|
115
|
+
#### Channel IDs
|
|
116
|
+
- `COMPOSABLE_STUDIO_CHANNEL_ID` - Main Studio channel
|
|
117
|
+
- `VISUAL_BUILDER_CHANNEL_ID` - Visual Builder channel
|
|
118
|
+
- `COMPOSABLE_STUDIO_POPUP_CHANNEL_ID` - Popup channel
|
|
119
|
+
- `COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID` - Built-in canvas channel
|
|
120
|
+
|
|
121
|
+
#### Query Parameters
|
|
122
|
+
- `COMPOSABLE_STUDIO_QUERY_PARAM` - Available query parameters for configuration
|
|
123
|
+
|
|
124
|
+
### Event Types
|
|
125
|
+
|
|
126
|
+
#### Studio Events (`POST_MESSAGE_EVENTS`)
|
|
127
|
+
- `HIGHLIGHT_NODE` - Highlight/unhighlight nodes
|
|
128
|
+
- `SET_ACTIVE_NODE` - Set the currently active node
|
|
129
|
+
- `TRANSFORM_OPERATION` - Apply transformations to nodes
|
|
130
|
+
- `REGISTER_COMPONENTS` - Register new components
|
|
131
|
+
- `GET_NODE_STYLE` - Retrieve node styles
|
|
132
|
+
- `UPDATE_DATA_SOURCE` - Update data sources
|
|
133
|
+
- `APPLY_OPERATION` - Apply operations
|
|
134
|
+
- `GET_ACTIVE_BREAKPOINT` - Get current breakpoint
|
|
135
|
+
- `REGISTER_BREAKPOINTS` - Register breakpoint definitions
|
|
136
|
+
- `SET_CURSOR_TYPE` - Set cursor type
|
|
137
|
+
- `HIGHLIGHT_SLOT_NODE` - Highlight slot nodes
|
|
138
|
+
- `UPDATE_BINDING_ERRORS` - Update binding validation errors
|
|
139
|
+
- `HIDDEN_COMPONENT_NOTIFICATION` - Notify about hidden components
|
|
140
|
+
|
|
141
|
+
#### Visual Builder Events (`VISUAL_BUILDER_POST_MESSAGE_EVENTS`)
|
|
142
|
+
- `REFETCH_SPEC` - Request spec refetch
|
|
143
|
+
- `COMPOSITION_SAVED` - Composition save notification
|
|
144
|
+
- `OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE` - Open in Studio
|
|
145
|
+
|
|
146
|
+
#### Built-in Canvas Events (`COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS`)
|
|
147
|
+
- `REQUEST_FOR_COMPOSITION_CONFIG` - Request composition configuration
|
|
148
|
+
|
|
149
|
+
### Event Data Types
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
interface OpenComposableStudioFromVBEventData {
|
|
153
|
+
compositionEntryUid: string;
|
|
154
|
+
windowFeatures?: string;
|
|
155
|
+
fetchCompositionData: FetchCompositionData | null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface CompositionSavedEventData {
|
|
159
|
+
entryUid: string;
|
|
160
|
+
contentTypeUid: string;
|
|
161
|
+
locale: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface HiddenElementNotificationEventData {
|
|
165
|
+
action: "open" | "close";
|
|
166
|
+
uid: "__all__" | string;
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Development
|
|
171
|
+
|
|
172
|
+
### Building
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npm run build
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Development Mode
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npm run dev
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Linting
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm run lint
|
|
188
|
+
npm run lint:fix
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Architecture
|
|
192
|
+
|
|
193
|
+
The package uses a singleton pattern to manage event managers across the application. Each manager is stored in `window.__csMessengerListeners__` to ensure consistent communication channels.
|
|
194
|
+
|
|
195
|
+
### Channel Flow
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
Studio ↔ Visual Builder
|
|
199
|
+
↕
|
|
200
|
+
Built-in Canvas
|
|
201
|
+
↕
|
|
202
|
+
Popup Windows
|
|
203
|
+
```
|
|
204
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var advancedPostMessage = require('@contentstack/advanced-post-message');
|
|
4
|
+
|
|
5
|
+
const COMPOSABLE_STUDIO_CHANNEL_ID = "composable-studio";
|
|
6
|
+
const COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID = "composable-studio-built-in-canvas";
|
|
7
|
+
const LIVE_EDITOR_CHANNEL_ID = "live-editor";
|
|
8
|
+
const COMPOSABLE_STUDIO_POPUP_CHANNEL_ID = "composable-studio-popup";
|
|
9
|
+
const VISUAL_BUILDER_CHANNEL_ID = "composable-client-visual-builder";
|
|
10
|
+
const COMPOSABLE_STUDIO_QUERY_PARAM = {
|
|
11
|
+
ENABLED: "cs-composable-studio",
|
|
12
|
+
COMPOSITION_ENTRY_UID: "cs-composition-uid",
|
|
13
|
+
COMPOSABLE_UID: "cs-composable-uid",
|
|
14
|
+
PREVIEW_HASH: "hash",
|
|
15
|
+
/**
|
|
16
|
+
* This hash is same as the PREVIEW_HASH.
|
|
17
|
+
* In the Live preview panel, we receive the hash as live_preview.
|
|
18
|
+
* So we need to handle both the cases.
|
|
19
|
+
*/
|
|
20
|
+
LIVE_PREVIEW_HASH: "live_preview",
|
|
21
|
+
CONNECTED_CONTENT_TYPE: "connected-content-type",
|
|
22
|
+
DYNAMIC_URL: "dynamic-url",
|
|
23
|
+
VISUAL_BUILDER: "builder",
|
|
24
|
+
};
|
|
25
|
+
const POST_MESSAGE_EVENTS = {
|
|
26
|
+
INIT_STUDIO: "init-studio",
|
|
27
|
+
HIGHLIGHT_NODE: "highlight-node",
|
|
28
|
+
SET_FOCUSED_NODE: "set-focused-node",
|
|
29
|
+
SET_ACTIVE_NODE: "set-active-node",
|
|
30
|
+
REMOVE_HIGHLIGHT_NODE: "remove-highlight-node",
|
|
31
|
+
TRANSFORM_OPERATION: "transform-operation",
|
|
32
|
+
REGISTER_COMPONENTS: "register-components",
|
|
33
|
+
GET_NODE_STYLE: "get-node-style",
|
|
34
|
+
REGISTER_DESIGN_TOKENS: "register-design-tokens",
|
|
35
|
+
REGISTER_DESIGN_CLASSES: "register-design-classes",
|
|
36
|
+
VALIDATE_PROP_VALUE: "validate-prop-value",
|
|
37
|
+
GET_COMPONENT_PROPS: "get-component-props",
|
|
38
|
+
UPDATE_DATA_SOURCE: "update-data-source",
|
|
39
|
+
UPDATE_SPEC_DATA: "update-spec-data",
|
|
40
|
+
UPDATE_STATIC_VALUE: "update-static-value",
|
|
41
|
+
MOUSE_DOWN: "mouse-down",
|
|
42
|
+
MOUSE_UP: "mouse-up",
|
|
43
|
+
MOUSE_MOVE: "mouse-move",
|
|
44
|
+
PARENT_DRAG_START: "parent-drag-start",
|
|
45
|
+
PARENT_DRAG_END: "parent-drag-end",
|
|
46
|
+
APPLY_OPERATION: "apply-operation",
|
|
47
|
+
APPLY_SYMBOL_OPERATION: "apply-symbol-operation",
|
|
48
|
+
GET_ACTIVE_BREAKPOINT: "get-active-breakpoint",
|
|
49
|
+
REGISTER_BREAKPOINTS: "register-breakpoints",
|
|
50
|
+
SET_CURSOR_TYPE: "set-cursor-type",
|
|
51
|
+
GET_COMPOSITION_SPEC: "get-composition-spec",
|
|
52
|
+
REPLACE_PREVIEW_ENTRY: "replace-preview-entry",
|
|
53
|
+
CHANGE_ACTIVE_STYLE_SECTION: "change-active-style-section",
|
|
54
|
+
CHANGE_STYLE_SECTION: "change-style-section",
|
|
55
|
+
HIGHLIGHT_SLOT_NODE: "highlight-slot-node",
|
|
56
|
+
SET_ACTIVE_SLOT_UID: "set-active-slot-uid",
|
|
57
|
+
// SDK sends this event to Parent to update the schema validation error
|
|
58
|
+
UPDATE_BINDING_ERRORS: "update-binding-errors",
|
|
59
|
+
OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE: "open-composable-studio",
|
|
60
|
+
UPDATE_SYMBOLS: "update-symbols",
|
|
61
|
+
ADD_NEW_SYMBOL: "add-new-symbol",
|
|
62
|
+
HIDDEN_COMPONENT_NOTIFICATION: "hidden-component-notification",
|
|
63
|
+
CONTEXT_MENU: "context-menu",
|
|
64
|
+
GET_NODE_SCREENSHOT: "get-node-screenshot",
|
|
65
|
+
};
|
|
66
|
+
const VISUAL_BUILDER_POST_MESSAGE_EVENTS = {
|
|
67
|
+
// From visual builder to composable client
|
|
68
|
+
REFETCH_SPEC: "refetch-spec",
|
|
69
|
+
// From studio to visual builder
|
|
70
|
+
COMPOSITION_SAVED: "composition-saved",
|
|
71
|
+
OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE: "open-composable-studio",
|
|
72
|
+
};
|
|
73
|
+
const COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS = {
|
|
74
|
+
REQUEST_FOR_COMPOSITION_CONFIG: "request-for-composition-config",
|
|
75
|
+
};
|
|
76
|
+
const IS_BROWSER = typeof window !== "undefined";
|
|
77
|
+
|
|
78
|
+
const getEventManager = (channelId) => {
|
|
79
|
+
if (!IS_BROWSER) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
if (!window.__csMessengerListeners__) {
|
|
83
|
+
window.__csMessengerListeners__ = {};
|
|
84
|
+
}
|
|
85
|
+
if (!window.__csMessengerListeners__[channelId]) {
|
|
86
|
+
window.__csMessengerListeners__[channelId] = new advancedPostMessage.EventManager(channelId, {
|
|
87
|
+
target: window.parent,
|
|
88
|
+
debug: false,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return window.__csMessengerListeners__[channelId];
|
|
92
|
+
};
|
|
93
|
+
//TODO: Make it tree shakable
|
|
94
|
+
const composableStudioEventManager =
|
|
95
|
+
/*#__PURE__*/
|
|
96
|
+
getEventManager(COMPOSABLE_STUDIO_CHANNEL_ID);
|
|
97
|
+
const composableStudioPopupEventManager =
|
|
98
|
+
/*#__PURE__*/
|
|
99
|
+
getEventManager(COMPOSABLE_STUDIO_POPUP_CHANNEL_ID);
|
|
100
|
+
const visualBuilderEventManager =
|
|
101
|
+
/*#__PURE__*/
|
|
102
|
+
getEventManager(VISUAL_BUILDER_CHANNEL_ID);
|
|
103
|
+
const composableStudioBuiltInCanvasEventManager =
|
|
104
|
+
/*#__PURE__*/
|
|
105
|
+
getEventManager(COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID);
|
|
106
|
+
|
|
107
|
+
exports.COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID = COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID;
|
|
108
|
+
exports.COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS = COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS;
|
|
109
|
+
exports.COMPOSABLE_STUDIO_CHANNEL_ID = COMPOSABLE_STUDIO_CHANNEL_ID;
|
|
110
|
+
exports.COMPOSABLE_STUDIO_POPUP_CHANNEL_ID = COMPOSABLE_STUDIO_POPUP_CHANNEL_ID;
|
|
111
|
+
exports.COMPOSABLE_STUDIO_QUERY_PARAM = COMPOSABLE_STUDIO_QUERY_PARAM;
|
|
112
|
+
exports.IS_BROWSER = IS_BROWSER;
|
|
113
|
+
exports.LIVE_EDITOR_CHANNEL_ID = LIVE_EDITOR_CHANNEL_ID;
|
|
114
|
+
exports.POST_MESSAGE_EVENTS = POST_MESSAGE_EVENTS;
|
|
115
|
+
exports.VISUAL_BUILDER_CHANNEL_ID = VISUAL_BUILDER_CHANNEL_ID;
|
|
116
|
+
exports.VISUAL_BUILDER_POST_MESSAGE_EVENTS = VISUAL_BUILDER_POST_MESSAGE_EVENTS;
|
|
117
|
+
exports.composableStudioBuiltInCanvasEventManager = composableStudioBuiltInCanvasEventManager;
|
|
118
|
+
exports.composableStudioEventManager = composableStudioEventManager;
|
|
119
|
+
exports.composableStudioPopupEventManager = composableStudioPopupEventManager;
|
|
120
|
+
exports.visualBuilderEventManager = visualBuilderEventManager;
|
|
121
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/constant.ts","../../src/main.ts"],"sourcesContent":[null,null],"names":["EventManager"],"mappings":";;;;AAAO,MAAM,4BAA4B,G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CAAC,SAAS,CAAC;AACnD,CAAC;AACD;MACa,4BAA4B;AACvC;AACA,eAAe,CAAC,4BAA4B;MACjC,iCAAiC;AAC5C;AACA,eAAe,CAAC,kCAAkC;MACvC,yBAAyB;AACpC;AACA,eAAe,CAAC,yBAAyB;MAC9B,yCAAyC;AAGpD;AACA,eAAe,CAAC,4CAA4C;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const COMPOSABLE_STUDIO_CHANNEL_ID = "composable-studio";
|
|
2
|
+
const COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID = "composable-studio-built-in-canvas";
|
|
3
|
+
const LIVE_EDITOR_CHANNEL_ID = "live-editor";
|
|
4
|
+
const COMPOSABLE_STUDIO_POPUP_CHANNEL_ID = "composable-studio-popup";
|
|
5
|
+
const VISUAL_BUILDER_CHANNEL_ID = "composable-client-visual-builder";
|
|
6
|
+
const COMPOSABLE_STUDIO_QUERY_PARAM = {
|
|
7
|
+
ENABLED: "cs-composable-studio",
|
|
8
|
+
COMPOSITION_ENTRY_UID: "cs-composition-uid",
|
|
9
|
+
COMPOSABLE_UID: "cs-composable-uid",
|
|
10
|
+
PREVIEW_HASH: "hash",
|
|
11
|
+
/**
|
|
12
|
+
* This hash is same as the PREVIEW_HASH.
|
|
13
|
+
* In the Live preview panel, we receive the hash as live_preview.
|
|
14
|
+
* So we need to handle both the cases.
|
|
15
|
+
*/
|
|
16
|
+
LIVE_PREVIEW_HASH: "live_preview",
|
|
17
|
+
CONNECTED_CONTENT_TYPE: "connected-content-type",
|
|
18
|
+
DYNAMIC_URL: "dynamic-url",
|
|
19
|
+
VISUAL_BUILDER: "builder",
|
|
20
|
+
};
|
|
21
|
+
const POST_MESSAGE_EVENTS = {
|
|
22
|
+
INIT_STUDIO: "init-studio",
|
|
23
|
+
HIGHLIGHT_NODE: "highlight-node",
|
|
24
|
+
SET_FOCUSED_NODE: "set-focused-node",
|
|
25
|
+
SET_ACTIVE_NODE: "set-active-node",
|
|
26
|
+
REMOVE_HIGHLIGHT_NODE: "remove-highlight-node",
|
|
27
|
+
TRANSFORM_OPERATION: "transform-operation",
|
|
28
|
+
REGISTER_COMPONENTS: "register-components",
|
|
29
|
+
GET_NODE_STYLE: "get-node-style",
|
|
30
|
+
REGISTER_DESIGN_TOKENS: "register-design-tokens",
|
|
31
|
+
REGISTER_DESIGN_CLASSES: "register-design-classes",
|
|
32
|
+
VALIDATE_PROP_VALUE: "validate-prop-value",
|
|
33
|
+
GET_COMPONENT_PROPS: "get-component-props",
|
|
34
|
+
UPDATE_DATA_SOURCE: "update-data-source",
|
|
35
|
+
UPDATE_SPEC_DATA: "update-spec-data",
|
|
36
|
+
UPDATE_STATIC_VALUE: "update-static-value",
|
|
37
|
+
MOUSE_DOWN: "mouse-down",
|
|
38
|
+
MOUSE_UP: "mouse-up",
|
|
39
|
+
MOUSE_MOVE: "mouse-move",
|
|
40
|
+
PARENT_DRAG_START: "parent-drag-start",
|
|
41
|
+
PARENT_DRAG_END: "parent-drag-end",
|
|
42
|
+
APPLY_OPERATION: "apply-operation",
|
|
43
|
+
APPLY_SYMBOL_OPERATION: "apply-symbol-operation",
|
|
44
|
+
GET_ACTIVE_BREAKPOINT: "get-active-breakpoint",
|
|
45
|
+
REGISTER_BREAKPOINTS: "register-breakpoints",
|
|
46
|
+
SET_CURSOR_TYPE: "set-cursor-type",
|
|
47
|
+
GET_COMPOSITION_SPEC: "get-composition-spec",
|
|
48
|
+
REPLACE_PREVIEW_ENTRY: "replace-preview-entry",
|
|
49
|
+
CHANGE_ACTIVE_STYLE_SECTION: "change-active-style-section",
|
|
50
|
+
CHANGE_STYLE_SECTION: "change-style-section",
|
|
51
|
+
HIGHLIGHT_SLOT_NODE: "highlight-slot-node",
|
|
52
|
+
SET_ACTIVE_SLOT_UID: "set-active-slot-uid",
|
|
53
|
+
// SDK sends this event to Parent to update the schema validation error
|
|
54
|
+
UPDATE_BINDING_ERRORS: "update-binding-errors",
|
|
55
|
+
OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE: "open-composable-studio",
|
|
56
|
+
UPDATE_SYMBOLS: "update-symbols",
|
|
57
|
+
ADD_NEW_SYMBOL: "add-new-symbol",
|
|
58
|
+
HIDDEN_COMPONENT_NOTIFICATION: "hidden-component-notification",
|
|
59
|
+
CONTEXT_MENU: "context-menu",
|
|
60
|
+
GET_NODE_SCREENSHOT: "get-node-screenshot",
|
|
61
|
+
};
|
|
62
|
+
const VISUAL_BUILDER_POST_MESSAGE_EVENTS = {
|
|
63
|
+
// From visual builder to composable client
|
|
64
|
+
REFETCH_SPEC: "refetch-spec",
|
|
65
|
+
// From studio to visual builder
|
|
66
|
+
COMPOSITION_SAVED: "composition-saved",
|
|
67
|
+
OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE: "open-composable-studio",
|
|
68
|
+
};
|
|
69
|
+
const COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS = {
|
|
70
|
+
REQUEST_FOR_COMPOSITION_CONFIG: "request-for-composition-config",
|
|
71
|
+
};
|
|
72
|
+
const IS_BROWSER = typeof window !== "undefined";
|
|
73
|
+
|
|
74
|
+
export { COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID, COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS, COMPOSABLE_STUDIO_CHANNEL_ID, COMPOSABLE_STUDIO_POPUP_CHANNEL_ID, COMPOSABLE_STUDIO_QUERY_PARAM, IS_BROWSER, LIVE_EDITOR_CHANNEL_ID, POST_MESSAGE_EVENTS, VISUAL_BUILDER_CHANNEL_ID, VISUAL_BUILDER_POST_MESSAGE_EVENTS };
|
|
75
|
+
//# sourceMappingURL=constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.js","sources":["../../src/constant.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,4BAA4B,GAAG;AACrC,MAAM,4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E,sBAAsB;AAC5C,IAAA,eAAe,EAAE,iBAAiB;AAClC,IAAA,oBAAoB,EAAE,sBAAsB;AAC5C,IAAA,qBAAqB,EAAE,uBAAuB;AAC9C,IAAA,2BAA2B,EAAE,6BAA6B;AAC1D,IAAA,oBAAoB,EAAE,sBAAsB;AAC5C,IAAA,mBAAmB,EAAE,qBAAqB;AAC1C,IAAA,mBAAmB,EAAE,qBAAqB;;AAE1C,IAAA,qBAAqB,EAAE,uBAAuB;AAC9C,IAAA,uCAAuC,EAAE,wBAAwB;AACjE,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,6BAA6B,EAAE,+BAA+B;AAC9D,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,mBAAmB,EAAE,qBAAqB;;AAGrC,MAAM,kCAAkC,GAAG;;AAEhD,IAAA,YAAY,EAAE,cAAc;;AAG5B,IAAA,iBAAiB,EAAE,mBAAmB;AACtC,IAAA,uCAAuC,EAAE,wBAAwB;;AAG5D,MAAM,qDAAqD,GAAG;AACnE,IAAA,8BAA8B,EAAE,gCAAgC;;MAGrD,UAAU,GAAG,OAAO,MAAM,KAAK;;;;"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { EventManager } from '@contentstack/advanced-post-message';
|
|
2
|
+
export { CompositionSavedEventData, GetNodeScreenshotEventData, GetNodeScreenshotResponseEventData, HiddenElementNotificationEventData, OpenComposableStudioFromStudioEventData, OpenComposableStudioFromVBEventData } from '@contentstack/studio-message-types/latest';
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
__csMessengerListeners__: Record<string, EventManager>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare const composableStudioEventManager: EventManager | undefined;
|
|
10
|
+
declare const composableStudioPopupEventManager: EventManager | undefined;
|
|
11
|
+
declare const visualBuilderEventManager: EventManager | undefined;
|
|
12
|
+
declare const composableStudioBuiltInCanvasEventManager: EventManager | undefined;
|
|
13
|
+
|
|
14
|
+
declare const COMPOSABLE_STUDIO_CHANNEL_ID = "composable-studio";
|
|
15
|
+
declare const COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID = "composable-studio-built-in-canvas";
|
|
16
|
+
declare const LIVE_EDITOR_CHANNEL_ID = "live-editor";
|
|
17
|
+
declare const COMPOSABLE_STUDIO_POPUP_CHANNEL_ID = "composable-studio-popup";
|
|
18
|
+
declare const VISUAL_BUILDER_CHANNEL_ID = "composable-client-visual-builder";
|
|
19
|
+
declare const COMPOSABLE_STUDIO_QUERY_PARAM: {
|
|
20
|
+
readonly ENABLED: "cs-composable-studio";
|
|
21
|
+
readonly COMPOSITION_ENTRY_UID: "cs-composition-uid";
|
|
22
|
+
readonly COMPOSABLE_UID: "cs-composable-uid";
|
|
23
|
+
readonly PREVIEW_HASH: "hash";
|
|
24
|
+
/**
|
|
25
|
+
* This hash is same as the PREVIEW_HASH.
|
|
26
|
+
* In the Live preview panel, we receive the hash as live_preview.
|
|
27
|
+
* So we need to handle both the cases.
|
|
28
|
+
*/
|
|
29
|
+
readonly LIVE_PREVIEW_HASH: "live_preview";
|
|
30
|
+
readonly CONNECTED_CONTENT_TYPE: "connected-content-type";
|
|
31
|
+
readonly DYNAMIC_URL: "dynamic-url";
|
|
32
|
+
readonly VISUAL_BUILDER: "builder";
|
|
33
|
+
};
|
|
34
|
+
declare const POST_MESSAGE_EVENTS: {
|
|
35
|
+
readonly INIT_STUDIO: "init-studio";
|
|
36
|
+
readonly HIGHLIGHT_NODE: "highlight-node";
|
|
37
|
+
readonly SET_FOCUSED_NODE: "set-focused-node";
|
|
38
|
+
readonly SET_ACTIVE_NODE: "set-active-node";
|
|
39
|
+
readonly REMOVE_HIGHLIGHT_NODE: "remove-highlight-node";
|
|
40
|
+
readonly TRANSFORM_OPERATION: "transform-operation";
|
|
41
|
+
readonly REGISTER_COMPONENTS: "register-components";
|
|
42
|
+
readonly GET_NODE_STYLE: "get-node-style";
|
|
43
|
+
readonly REGISTER_DESIGN_TOKENS: "register-design-tokens";
|
|
44
|
+
readonly REGISTER_DESIGN_CLASSES: "register-design-classes";
|
|
45
|
+
readonly VALIDATE_PROP_VALUE: "validate-prop-value";
|
|
46
|
+
readonly GET_COMPONENT_PROPS: "get-component-props";
|
|
47
|
+
readonly UPDATE_DATA_SOURCE: "update-data-source";
|
|
48
|
+
readonly UPDATE_SPEC_DATA: "update-spec-data";
|
|
49
|
+
readonly UPDATE_STATIC_VALUE: "update-static-value";
|
|
50
|
+
readonly MOUSE_DOWN: "mouse-down";
|
|
51
|
+
readonly MOUSE_UP: "mouse-up";
|
|
52
|
+
readonly MOUSE_MOVE: "mouse-move";
|
|
53
|
+
readonly PARENT_DRAG_START: "parent-drag-start";
|
|
54
|
+
readonly PARENT_DRAG_END: "parent-drag-end";
|
|
55
|
+
readonly APPLY_OPERATION: "apply-operation";
|
|
56
|
+
readonly APPLY_SYMBOL_OPERATION: "apply-symbol-operation";
|
|
57
|
+
readonly GET_ACTIVE_BREAKPOINT: "get-active-breakpoint";
|
|
58
|
+
readonly REGISTER_BREAKPOINTS: "register-breakpoints";
|
|
59
|
+
readonly SET_CURSOR_TYPE: "set-cursor-type";
|
|
60
|
+
readonly GET_COMPOSITION_SPEC: "get-composition-spec";
|
|
61
|
+
readonly REPLACE_PREVIEW_ENTRY: "replace-preview-entry";
|
|
62
|
+
readonly CHANGE_ACTIVE_STYLE_SECTION: "change-active-style-section";
|
|
63
|
+
readonly CHANGE_STYLE_SECTION: "change-style-section";
|
|
64
|
+
readonly HIGHLIGHT_SLOT_NODE: "highlight-slot-node";
|
|
65
|
+
readonly SET_ACTIVE_SLOT_UID: "set-active-slot-uid";
|
|
66
|
+
readonly UPDATE_BINDING_ERRORS: "update-binding-errors";
|
|
67
|
+
readonly OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE: "open-composable-studio";
|
|
68
|
+
readonly UPDATE_SYMBOLS: "update-symbols";
|
|
69
|
+
readonly ADD_NEW_SYMBOL: "add-new-symbol";
|
|
70
|
+
readonly HIDDEN_COMPONENT_NOTIFICATION: "hidden-component-notification";
|
|
71
|
+
readonly CONTEXT_MENU: "context-menu";
|
|
72
|
+
readonly GET_NODE_SCREENSHOT: "get-node-screenshot";
|
|
73
|
+
};
|
|
74
|
+
declare const VISUAL_BUILDER_POST_MESSAGE_EVENTS: {
|
|
75
|
+
readonly REFETCH_SPEC: "refetch-spec";
|
|
76
|
+
readonly COMPOSITION_SAVED: "composition-saved";
|
|
77
|
+
readonly OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE: "open-composable-studio";
|
|
78
|
+
};
|
|
79
|
+
declare const COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS: {
|
|
80
|
+
readonly REQUEST_FOR_COMPOSITION_CONFIG: "request-for-composition-config";
|
|
81
|
+
};
|
|
82
|
+
declare const IS_BROWSER: boolean;
|
|
83
|
+
|
|
84
|
+
type ComposableStudioQueryParamsKeys = (typeof COMPOSABLE_STUDIO_QUERY_PARAM)[keyof typeof COMPOSABLE_STUDIO_QUERY_PARAM];
|
|
85
|
+
type ComposableStudioQueryParams = {
|
|
86
|
+
[key in ComposableStudioQueryParamsKeys]: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
type CompositionQuery = {
|
|
90
|
+
composableUid: string;
|
|
91
|
+
} | {
|
|
92
|
+
/**
|
|
93
|
+
* IMPORTANT: If you only pass the URL without the composable UID,
|
|
94
|
+
* we will still fetch the composition. However, it will be slower
|
|
95
|
+
* as we will have to process all the compositions.
|
|
96
|
+
*/
|
|
97
|
+
url: string;
|
|
98
|
+
} | {
|
|
99
|
+
composableUid: string;
|
|
100
|
+
url: string;
|
|
101
|
+
};
|
|
102
|
+
type CompositionQueryInput = {
|
|
103
|
+
compositionUid: string;
|
|
104
|
+
} | {
|
|
105
|
+
/**
|
|
106
|
+
* IMPORTANT: If you only pass the URL without the composable UID,
|
|
107
|
+
* we will still fetch the composition. However, it will be slower
|
|
108
|
+
* as we will have to process all the compositions.
|
|
109
|
+
*/
|
|
110
|
+
url: string;
|
|
111
|
+
} | {
|
|
112
|
+
compositionUid: string;
|
|
113
|
+
url: string;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
type BuiltInCanvasConfig = {
|
|
117
|
+
compositionContentTypeUid: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export { COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID, COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS, COMPOSABLE_STUDIO_CHANNEL_ID, COMPOSABLE_STUDIO_POPUP_CHANNEL_ID, COMPOSABLE_STUDIO_QUERY_PARAM, IS_BROWSER, LIVE_EDITOR_CHANNEL_ID, POST_MESSAGE_EVENTS, VISUAL_BUILDER_CHANNEL_ID, VISUAL_BUILDER_POST_MESSAGE_EVENTS, composableStudioBuiltInCanvasEventManager, composableStudioEventManager, composableStudioPopupEventManager, visualBuilderEventManager };
|
|
121
|
+
export type { BuiltInCanvasConfig, ComposableStudioQueryParams, ComposableStudioQueryParamsKeys, CompositionQuery, CompositionQueryInput };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { composableStudioBuiltInCanvasEventManager, composableStudioEventManager, composableStudioPopupEventManager, visualBuilderEventManager } from './main.js';
|
|
2
|
+
export { COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID, COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS, COMPOSABLE_STUDIO_CHANNEL_ID, COMPOSABLE_STUDIO_POPUP_CHANNEL_ID, COMPOSABLE_STUDIO_QUERY_PARAM, IS_BROWSER, LIVE_EDITOR_CHANNEL_ID, POST_MESSAGE_EVENTS, VISUAL_BUILDER_CHANNEL_ID, VISUAL_BUILDER_POST_MESSAGE_EVENTS } from './constant.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/esm/main.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EventManager } from '@contentstack/advanced-post-message';
|
|
2
|
+
import { IS_BROWSER, COMPOSABLE_STUDIO_POPUP_CHANNEL_ID, VISUAL_BUILDER_CHANNEL_ID, COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID, COMPOSABLE_STUDIO_CHANNEL_ID } from './constant.js';
|
|
3
|
+
|
|
4
|
+
const getEventManager = (channelId) => {
|
|
5
|
+
if (!IS_BROWSER) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
if (!window.__csMessengerListeners__) {
|
|
9
|
+
window.__csMessengerListeners__ = {};
|
|
10
|
+
}
|
|
11
|
+
if (!window.__csMessengerListeners__[channelId]) {
|
|
12
|
+
window.__csMessengerListeners__[channelId] = new EventManager(channelId, {
|
|
13
|
+
target: window.parent,
|
|
14
|
+
debug: false,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return window.__csMessengerListeners__[channelId];
|
|
18
|
+
};
|
|
19
|
+
//TODO: Make it tree shakable
|
|
20
|
+
const composableStudioEventManager =
|
|
21
|
+
/*#__PURE__*/
|
|
22
|
+
getEventManager(COMPOSABLE_STUDIO_CHANNEL_ID);
|
|
23
|
+
const composableStudioPopupEventManager =
|
|
24
|
+
/*#__PURE__*/
|
|
25
|
+
getEventManager(COMPOSABLE_STUDIO_POPUP_CHANNEL_ID);
|
|
26
|
+
const visualBuilderEventManager =
|
|
27
|
+
/*#__PURE__*/
|
|
28
|
+
getEventManager(VISUAL_BUILDER_CHANNEL_ID);
|
|
29
|
+
const composableStudioBuiltInCanvasEventManager =
|
|
30
|
+
/*#__PURE__*/
|
|
31
|
+
getEventManager(COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID);
|
|
32
|
+
|
|
33
|
+
export { composableStudioBuiltInCanvasEventManager, composableStudioEventManager, composableStudioPopupEventManager, visualBuilderEventManager };
|
|
34
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sources":["../../src/main.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAeA,MAAM,eAAe,GAAG,CAAC,SAAiB,KAAI;IAC5C,IAAI,CAAC,UAAU,EAAE;AACf,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,IAAI,CAAC,MAAM,CAAC,wBAAwB,EAAE;AACpC,QAAA,MAAM,CAAC,wBAAwB,GAAG,EAAE;IACtC;IACA,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE;QAC/C,MAAM,CAAC,wBAAwB,CAAC,SAAS,CAAC,GAAG,IAAI,YAAY,CAAC,SAAS,EAAE;YACvE,MAAM,EAAE,MAAM,CAAC,MAAM;AACrB,YAAA,KAAK,EAAE,KAAK;AACb,SAAA,CAAC;IACJ;AACA,IAAA,OAAO,MAAM,CAAC,wBAAwB,CAAC,SAAS,CAAC;AACnD,CAAC;AACD;MACa,4BAA4B;AACvC;AACA,eAAe,CAAC,4BAA4B;MACjC,iCAAiC;AAC5C;AACA,eAAe,CAAC,kCAAkC;MACvC,yBAAyB;AACpC;AACA,eAAe,CAAC,yBAAyB;MAC9B,yCAAyC;AAGpD;AACA,eAAe,CAAC,4CAA4C;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contentstack/studio-messenger",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "This package handles communication between the Studio platform and the iframe webpage.",
|
|
5
|
+
"main": "dist/cjs/index.cjs",
|
|
6
|
+
"types": "dist/esm/index.d.ts",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"author": "Contentstack",
|
|
9
|
+
"homepage": "https://github.com/contentstack/composable-studio-sdk/tree/main/packages/studio-messenger#readme",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/esm/index.d.ts",
|
|
17
|
+
"default": "./dist/esm/index.js"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/esm/index.d.ts",
|
|
21
|
+
"default": "./dist/cjs/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/contentstack/composable-studio-sdk.git"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "rollup -c ./rollup.config.mjs --watch",
|
|
34
|
+
"build": "rollup -c rollup.config.mjs",
|
|
35
|
+
"test": "exit 0",
|
|
36
|
+
"lint": "eslint src/ --max-warnings 0",
|
|
37
|
+
"lint:fix": "eslint src/ --fix"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/contentstack/composable-studio-sdk/issues"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@contentstack/common-config": "file:../common-config",
|
|
44
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
45
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
46
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
47
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
48
|
+
"rollup": "^4.46.2",
|
|
49
|
+
"rollup-plugin-dts": "^6.2.1",
|
|
50
|
+
"rollup-plugin-node-externals": "^8.0.1",
|
|
51
|
+
"rollup-plugin-preserve-directives": "^0.4.0",
|
|
52
|
+
"typescript": "^5.5.4"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@contentstack/advanced-post-message": "^0.0.2",
|
|
56
|
+
"@contentstack/studio-message-types": "file:../studio-message-types"
|
|
57
|
+
}
|
|
58
|
+
}
|