@contentstack/studio-messenger 1.4.0 → 1.5.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.
- package/dist/cjs/index.cjs +75 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/constant.js +48 -3
- package/dist/esm/constant.js.map +1 -1
- package/dist/esm/index.d.ts +64 -22
- package/dist/esm/main.js +8 -1
- package/dist/esm/main.js.map +1 -1
- package/package.json +5 -8
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
var advancedPostMessage = require('@contentstack/advanced-post-message');
|
|
4
4
|
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var advancedPostMessage__namespace = /*#__PURE__*/_interopNamespaceDefault(advancedPostMessage);
|
|
23
|
+
|
|
5
24
|
const COMPOSABLE_STUDIO_CHANNEL_ID = "composable-studio";
|
|
6
25
|
const COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID = "composable-studio-built-in-canvas";
|
|
7
26
|
const LIVE_EDITOR_CHANNEL_ID = "live-editor";
|
|
@@ -9,7 +28,6 @@ const COMPOSABLE_STUDIO_POPUP_CHANNEL_ID = "composable-studio-popup";
|
|
|
9
28
|
const VISUAL_BUILDER_CHANNEL_ID = "composable-client-visual-builder";
|
|
10
29
|
const COMPOSABLE_STUDIO_QUERY_PARAM = {
|
|
11
30
|
ENABLED: "cs-composable-studio",
|
|
12
|
-
COMPOSITION_ENTRY_UID: "cs-composition-uid",
|
|
13
31
|
COMPOSABLE_UID: "cs-composable-uid",
|
|
14
32
|
PREVIEW_HASH: "hash",
|
|
15
33
|
/**
|
|
@@ -18,9 +36,32 @@ const COMPOSABLE_STUDIO_QUERY_PARAM = {
|
|
|
18
36
|
* So we need to handle both the cases.
|
|
19
37
|
*/
|
|
20
38
|
LIVE_PREVIEW_HASH: "live_preview",
|
|
21
|
-
CONNECTED_CONTENT_TYPE: "connected-content-type",
|
|
22
|
-
DYNAMIC_URL: "dynamic-url",
|
|
23
39
|
VISUAL_BUILDER: "builder",
|
|
40
|
+
/**
|
|
41
|
+
* When Studio renders the iframe and the user has explicitly picked an
|
|
42
|
+
* entry from the navbar, Studio appends this param so the SDK (running
|
|
43
|
+
* inside Studio) can prefer it over a host-passed `templateEntryUid`.
|
|
44
|
+
*
|
|
45
|
+
* Only honored when the SDK detects it is running inside Studio (via
|
|
46
|
+
* `ENABLED`). Outside Studio it is ignored.
|
|
47
|
+
*/
|
|
48
|
+
TEMPLATE_ENTRY_UID: "cs-template-entry-uid",
|
|
49
|
+
/**
|
|
50
|
+
* Locale Studio wants the SDK to render in. Set by Studio when its canvas
|
|
51
|
+
* URL carries `?locale=...`. The SDK overrides its own `config.locale`
|
|
52
|
+
* with this value so all SDK-side data fetches (initial + linked entries)
|
|
53
|
+
* use the right locale, and so the postmessages back to Studio
|
|
54
|
+
* (INIT_STUDIO.globalLocale, GET_COMPOSITION_SPEC.locale) carry it too.
|
|
55
|
+
*
|
|
56
|
+
* Only honored when the SDK detects it is running inside Studio (via
|
|
57
|
+
* `ENABLED`). Outside Studio it is ignored.
|
|
58
|
+
*/
|
|
59
|
+
LOCALE: "cs-locale",
|
|
60
|
+
/**
|
|
61
|
+
* Variant alias Studio wants the SDK to render in. Same flow as `LOCALE`
|
|
62
|
+
* but for variant. Set by Studio when its canvas URL carries `?variant=...`.
|
|
63
|
+
*/
|
|
64
|
+
VARIANT_ALIAS: "cs-variant-alias",
|
|
24
65
|
};
|
|
25
66
|
const POST_MESSAGE_EVENTS = {
|
|
26
67
|
INIT_STUDIO: "init-studio",
|
|
@@ -54,8 +95,20 @@ const POST_MESSAGE_EVENTS = {
|
|
|
54
95
|
// Fast Rendering Protocol (Canvas Delay Fix)
|
|
55
96
|
IFRAME_STUDIO_CONTEXT: "iframe-studio-context",
|
|
56
97
|
SDK_SPEC_RESOLVED: "sdk-spec-resolved",
|
|
98
|
+
// Iframe → Studio: per-component resolution telemetry (what was queried,
|
|
99
|
+
// which compositions were shortlisted with specificity, and which won).
|
|
100
|
+
// Emitted by every SDK component instance regardless of the edited-composition
|
|
101
|
+
// gate, so Studio can list what loaded and explain why the edited one didn't.
|
|
102
|
+
SDK_DIAGNOSTICS: "sdk-diagnostics",
|
|
57
103
|
// SDK Initialization Signal (SDK 1.5.0+)
|
|
58
104
|
SDK_INITIALIZED: "sdk-initialized",
|
|
105
|
+
// Iframe → Studio: fired once the post-message listeners registered by
|
|
106
|
+
// `useSpecDataListener` are in place. Studio should gate any editor → iframe
|
|
107
|
+
// sends (notably UPDATE_SPEC_DATA) on receipt of this signal — it is the
|
|
108
|
+
// only event guaranteed to fire AFTER EditableRenderer commits its first
|
|
109
|
+
// render. Earlier signals (SDK_SPEC_RESOLVED, INIT_STUDIO) fire before the
|
|
110
|
+
// React tree mounts and race against the listener registration.
|
|
111
|
+
LISTENERS_READY: "listeners-ready",
|
|
59
112
|
REPLACE_PREVIEW_ENTRY: "replace-preview-entry",
|
|
60
113
|
CHANGE_ACTIVE_STYLE_SECTION: "change-active-style-section",
|
|
61
114
|
CHANGE_STYLE_SECTION: "change-style-section",
|
|
@@ -65,6 +118,17 @@ const POST_MESSAGE_EVENTS = {
|
|
|
65
118
|
UPDATE_BINDING_ERRORS: "update-binding-errors",
|
|
66
119
|
OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE: "open-composable-studio",
|
|
67
120
|
UPDATE_SYMBOLS: "update-symbols",
|
|
121
|
+
GET_SYMBOLS: "get-symbols",
|
|
122
|
+
GET_SECTIONS: "get-sections",
|
|
123
|
+
// Parent → SDK: push the latest per-instance section binding map
|
|
124
|
+
// (dataSources.section_compositions) after a section-context recompute on
|
|
125
|
+
// Studio side. Carries only the section slice, not the full spec.data.
|
|
126
|
+
UPDATE_SECTION_CONTEXTS: "update-section-contexts",
|
|
127
|
+
// Parent → SDK: push the full section-composition catalog (one entry per
|
|
128
|
+
// section in the project). Fired by Studio whenever the local section
|
|
129
|
+
// store hydrates / updates, so the iframe doesn't depend on a one-shot
|
|
130
|
+
// GET_SECTIONS reply that races with Studio's async fetch.
|
|
131
|
+
UPDATE_SECTIONS_CATALOG: "update-sections-catalog",
|
|
68
132
|
ADD_NEW_SYMBOL: "add-new-symbol",
|
|
69
133
|
HIDDEN_COMPONENT_NOTIFICATION: "hidden-component-notification",
|
|
70
134
|
CONTEXT_MENU: "context-menu",
|
|
@@ -84,6 +148,11 @@ const COMPOSABLE_STUDIO_BUILT_IN_CANVAS_POST_MESSAGE_EVENTS = {
|
|
|
84
148
|
};
|
|
85
149
|
const IS_BROWSER = typeof window !== "undefined";
|
|
86
150
|
|
|
151
|
+
const apmModule = advancedPostMessage__namespace;
|
|
152
|
+
const EventManager = apmModule.EventManager ?? apmModule.default?.EventManager;
|
|
153
|
+
if (!EventManager) {
|
|
154
|
+
throw new Error("studio-messenger: EventManager missing from @contentstack/advanced-post-message");
|
|
155
|
+
}
|
|
87
156
|
const getEventManager = (channelId) => {
|
|
88
157
|
if (!IS_BROWSER) {
|
|
89
158
|
return undefined;
|
|
@@ -92,7 +161,9 @@ const getEventManager = (channelId) => {
|
|
|
92
161
|
window.__csMessengerListeners__ = {};
|
|
93
162
|
}
|
|
94
163
|
if (!window.__csMessengerListeners__[channelId]) {
|
|
95
|
-
|
|
164
|
+
// Cache one EventManager per channel so repeated imports/mounts reuse the
|
|
165
|
+
// same postMessage bridge instead of creating duplicate listeners.
|
|
166
|
+
window.__csMessengerListeners__[channelId] = new EventManager(channelId, {
|
|
96
167
|
target: window.parent,
|
|
97
168
|
debug: false,
|
|
98
169
|
});
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/constant.ts","../../src/main.ts"],"sourcesContent":[null,null],"names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/constant.ts","../../src/main.ts"],"sourcesContent":[null,null],"names":["advancedPostMessage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,4BAA4B,GAAG;AACrC,MAAM,4CAA4C,GACvD;AACK,MAAM,sBAAsB,GAAG;AAE/B,MAAM,kCAAkC,GAAG;AAC3C,MAAM,yBAAyB,GAAG;AAElC,MAAM,6BAA6B,GAAG;AAC3C,IAAA,OAAO,EAAE,sBAAsB;AAC/B,IAAA,cAAc,EAAE,mBAAmB;AACnC,IAAA,YAAY,EAAE,MAAM;AACpB;;;;AAIG;AACH,IAAA,iBAAiB,EAAE,cAAc;AACjC,IAAA,cAAc,EAAE,SAAS;AACzB;;;;;;;AAOG;AACH,IAAA,kBAAkB,EAAE,uBAAuB;AAC3C;;;;;;;;;AASG;AACH,IAAA,MAAM,EAAE,WAAW;AACnB;;;AAGG;AACH,IAAA,aAAa,EAAE,kBAAkB;;AAG5B,MAAM,mBAAmB,GAAG;AACjC,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,gBAAgB,EAAE,kBAAkB;AACpC,IAAA,eAAe,EAAE,iBAAiB;AAClC,IAAA,qBAAqB,EAAE,uBAAuB;AAC9C,IAAA,mBAAmB,EAAE,qBAAqB;AAC1C,IAAA,mBAAmB,EAAE,qBAAqB;AAC1C,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,sBAAsB,EAAE,wBAAwB;AAChD,IAAA,uBAAuB,EAAE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ACA,eAAe,CAAC,yBAAyB;MAC9B,yCAAyC;AAGpD;AACA,eAAe,CAAC,4CAA4C;;;;;;;;;;;;;;;;;"}
|
package/dist/esm/constant.js
CHANGED
|
@@ -5,7 +5,6 @@ const COMPOSABLE_STUDIO_POPUP_CHANNEL_ID = "composable-studio-popup";
|
|
|
5
5
|
const VISUAL_BUILDER_CHANNEL_ID = "composable-client-visual-builder";
|
|
6
6
|
const COMPOSABLE_STUDIO_QUERY_PARAM = {
|
|
7
7
|
ENABLED: "cs-composable-studio",
|
|
8
|
-
COMPOSITION_ENTRY_UID: "cs-composition-uid",
|
|
9
8
|
COMPOSABLE_UID: "cs-composable-uid",
|
|
10
9
|
PREVIEW_HASH: "hash",
|
|
11
10
|
/**
|
|
@@ -14,9 +13,32 @@ const COMPOSABLE_STUDIO_QUERY_PARAM = {
|
|
|
14
13
|
* So we need to handle both the cases.
|
|
15
14
|
*/
|
|
16
15
|
LIVE_PREVIEW_HASH: "live_preview",
|
|
17
|
-
CONNECTED_CONTENT_TYPE: "connected-content-type",
|
|
18
|
-
DYNAMIC_URL: "dynamic-url",
|
|
19
16
|
VISUAL_BUILDER: "builder",
|
|
17
|
+
/**
|
|
18
|
+
* When Studio renders the iframe and the user has explicitly picked an
|
|
19
|
+
* entry from the navbar, Studio appends this param so the SDK (running
|
|
20
|
+
* inside Studio) can prefer it over a host-passed `templateEntryUid`.
|
|
21
|
+
*
|
|
22
|
+
* Only honored when the SDK detects it is running inside Studio (via
|
|
23
|
+
* `ENABLED`). Outside Studio it is ignored.
|
|
24
|
+
*/
|
|
25
|
+
TEMPLATE_ENTRY_UID: "cs-template-entry-uid",
|
|
26
|
+
/**
|
|
27
|
+
* Locale Studio wants the SDK to render in. Set by Studio when its canvas
|
|
28
|
+
* URL carries `?locale=...`. The SDK overrides its own `config.locale`
|
|
29
|
+
* with this value so all SDK-side data fetches (initial + linked entries)
|
|
30
|
+
* use the right locale, and so the postmessages back to Studio
|
|
31
|
+
* (INIT_STUDIO.globalLocale, GET_COMPOSITION_SPEC.locale) carry it too.
|
|
32
|
+
*
|
|
33
|
+
* Only honored when the SDK detects it is running inside Studio (via
|
|
34
|
+
* `ENABLED`). Outside Studio it is ignored.
|
|
35
|
+
*/
|
|
36
|
+
LOCALE: "cs-locale",
|
|
37
|
+
/**
|
|
38
|
+
* Variant alias Studio wants the SDK to render in. Same flow as `LOCALE`
|
|
39
|
+
* but for variant. Set by Studio when its canvas URL carries `?variant=...`.
|
|
40
|
+
*/
|
|
41
|
+
VARIANT_ALIAS: "cs-variant-alias",
|
|
20
42
|
};
|
|
21
43
|
const POST_MESSAGE_EVENTS = {
|
|
22
44
|
INIT_STUDIO: "init-studio",
|
|
@@ -50,8 +72,20 @@ const POST_MESSAGE_EVENTS = {
|
|
|
50
72
|
// Fast Rendering Protocol (Canvas Delay Fix)
|
|
51
73
|
IFRAME_STUDIO_CONTEXT: "iframe-studio-context",
|
|
52
74
|
SDK_SPEC_RESOLVED: "sdk-spec-resolved",
|
|
75
|
+
// Iframe → Studio: per-component resolution telemetry (what was queried,
|
|
76
|
+
// which compositions were shortlisted with specificity, and which won).
|
|
77
|
+
// Emitted by every SDK component instance regardless of the edited-composition
|
|
78
|
+
// gate, so Studio can list what loaded and explain why the edited one didn't.
|
|
79
|
+
SDK_DIAGNOSTICS: "sdk-diagnostics",
|
|
53
80
|
// SDK Initialization Signal (SDK 1.5.0+)
|
|
54
81
|
SDK_INITIALIZED: "sdk-initialized",
|
|
82
|
+
// Iframe → Studio: fired once the post-message listeners registered by
|
|
83
|
+
// `useSpecDataListener` are in place. Studio should gate any editor → iframe
|
|
84
|
+
// sends (notably UPDATE_SPEC_DATA) on receipt of this signal — it is the
|
|
85
|
+
// only event guaranteed to fire AFTER EditableRenderer commits its first
|
|
86
|
+
// render. Earlier signals (SDK_SPEC_RESOLVED, INIT_STUDIO) fire before the
|
|
87
|
+
// React tree mounts and race against the listener registration.
|
|
88
|
+
LISTENERS_READY: "listeners-ready",
|
|
55
89
|
REPLACE_PREVIEW_ENTRY: "replace-preview-entry",
|
|
56
90
|
CHANGE_ACTIVE_STYLE_SECTION: "change-active-style-section",
|
|
57
91
|
CHANGE_STYLE_SECTION: "change-style-section",
|
|
@@ -61,6 +95,17 @@ const POST_MESSAGE_EVENTS = {
|
|
|
61
95
|
UPDATE_BINDING_ERRORS: "update-binding-errors",
|
|
62
96
|
OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE: "open-composable-studio",
|
|
63
97
|
UPDATE_SYMBOLS: "update-symbols",
|
|
98
|
+
GET_SYMBOLS: "get-symbols",
|
|
99
|
+
GET_SECTIONS: "get-sections",
|
|
100
|
+
// Parent → SDK: push the latest per-instance section binding map
|
|
101
|
+
// (dataSources.section_compositions) after a section-context recompute on
|
|
102
|
+
// Studio side. Carries only the section slice, not the full spec.data.
|
|
103
|
+
UPDATE_SECTION_CONTEXTS: "update-section-contexts",
|
|
104
|
+
// Parent → SDK: push the full section-composition catalog (one entry per
|
|
105
|
+
// section in the project). Fired by Studio whenever the local section
|
|
106
|
+
// store hydrates / updates, so the iframe doesn't depend on a one-shot
|
|
107
|
+
// GET_SECTIONS reply that races with Studio's async fetch.
|
|
108
|
+
UPDATE_SECTIONS_CATALOG: "update-sections-catalog",
|
|
64
109
|
ADD_NEW_SYMBOL: "add-new-symbol",
|
|
65
110
|
HIDDEN_COMPONENT_NOTIFICATION: "hidden-component-notification",
|
|
66
111
|
CONTEXT_MENU: "context-menu",
|
package/dist/esm/constant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","sources":["../../src/constant.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,4BAA4B,GAAG;AACrC,MAAM,4CAA4C,GACvD;AACK,MAAM,sBAAsB,GAAG;AAE/B,MAAM,kCAAkC,GAAG;AAC3C,MAAM,yBAAyB,GAAG;AAElC,MAAM,6BAA6B,GAAG;AAC3C,IAAA,OAAO,EAAE,sBAAsB;AAC/B,IAAA,
|
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AAM,qDAAqD,GAAG;AACnE,IAAA,8BAA8B,EAAE,gCAAgC;;MAGrD,UAAU,GAAG,OAAO,MAAM,KAAK;;;;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { CompositionSavedEventData, GetNodeScreenshotEventData, GetNodeScreenshotResponseEventData, HiddenElementNotificationEventData, OpenComposableStudioFromStudioEventData, OpenComposableStudioFromVBEventData, PrimaryCompositionDetectedEventData } from '@contentstack/studio-message-types/latest';
|
|
1
|
+
import * as advancedPostMessage from '@contentstack/advanced-post-message';
|
|
2
|
+
export { CompositionResolutionDiagnosticEventData, CompositionSavedEventData, GetNodeScreenshotEventData, GetNodeScreenshotResponseEventData, HiddenElementNotificationEventData, OpenComposableStudioFromStudioEventData, OpenComposableStudioFromVBEventData, PrimaryCompositionDetectedEventData, ResolvedComposition, ShortlistedComposition } from '@contentstack/studio-message-types/latest';
|
|
3
|
+
export { CompositionQuery } from '@contentstack/studio-message-types/base';
|
|
3
4
|
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
5
|
+
declare const EventManager: typeof advancedPostMessage.EventManager;
|
|
6
|
+
type EventManagerInstance = InstanceType<typeof EventManager>;
|
|
7
|
+
declare const composableStudioEventManager: EventManagerInstance | undefined;
|
|
8
|
+
declare const composableStudioPopupEventManager: EventManagerInstance | undefined;
|
|
9
|
+
declare const visualBuilderEventManager: EventManagerInstance | undefined;
|
|
10
|
+
declare const composableStudioBuiltInCanvasEventManager: EventManagerInstance | undefined;
|
|
8
11
|
|
|
9
12
|
declare const COMPOSABLE_STUDIO_CHANNEL_ID = "composable-studio";
|
|
10
13
|
declare const COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID = "composable-studio-built-in-canvas";
|
|
@@ -13,7 +16,6 @@ declare const COMPOSABLE_STUDIO_POPUP_CHANNEL_ID = "composable-studio-popup";
|
|
|
13
16
|
declare const VISUAL_BUILDER_CHANNEL_ID = "composable-client-visual-builder";
|
|
14
17
|
declare const COMPOSABLE_STUDIO_QUERY_PARAM: {
|
|
15
18
|
readonly ENABLED: "cs-composable-studio";
|
|
16
|
-
readonly COMPOSITION_ENTRY_UID: "cs-composition-uid";
|
|
17
19
|
readonly COMPOSABLE_UID: "cs-composable-uid";
|
|
18
20
|
readonly PREVIEW_HASH: "hash";
|
|
19
21
|
/**
|
|
@@ -22,9 +24,32 @@ declare const COMPOSABLE_STUDIO_QUERY_PARAM: {
|
|
|
22
24
|
* So we need to handle both the cases.
|
|
23
25
|
*/
|
|
24
26
|
readonly LIVE_PREVIEW_HASH: "live_preview";
|
|
25
|
-
readonly CONNECTED_CONTENT_TYPE: "connected-content-type";
|
|
26
|
-
readonly DYNAMIC_URL: "dynamic-url";
|
|
27
27
|
readonly VISUAL_BUILDER: "builder";
|
|
28
|
+
/**
|
|
29
|
+
* When Studio renders the iframe and the user has explicitly picked an
|
|
30
|
+
* entry from the navbar, Studio appends this param so the SDK (running
|
|
31
|
+
* inside Studio) can prefer it over a host-passed `templateEntryUid`.
|
|
32
|
+
*
|
|
33
|
+
* Only honored when the SDK detects it is running inside Studio (via
|
|
34
|
+
* `ENABLED`). Outside Studio it is ignored.
|
|
35
|
+
*/
|
|
36
|
+
readonly TEMPLATE_ENTRY_UID: "cs-template-entry-uid";
|
|
37
|
+
/**
|
|
38
|
+
* Locale Studio wants the SDK to render in. Set by Studio when its canvas
|
|
39
|
+
* URL carries `?locale=...`. The SDK overrides its own `config.locale`
|
|
40
|
+
* with this value so all SDK-side data fetches (initial + linked entries)
|
|
41
|
+
* use the right locale, and so the postmessages back to Studio
|
|
42
|
+
* (INIT_STUDIO.globalLocale, GET_COMPOSITION_SPEC.locale) carry it too.
|
|
43
|
+
*
|
|
44
|
+
* Only honored when the SDK detects it is running inside Studio (via
|
|
45
|
+
* `ENABLED`). Outside Studio it is ignored.
|
|
46
|
+
*/
|
|
47
|
+
readonly LOCALE: "cs-locale";
|
|
48
|
+
/**
|
|
49
|
+
* Variant alias Studio wants the SDK to render in. Same flow as `LOCALE`
|
|
50
|
+
* but for variant. Set by Studio when its canvas URL carries `?variant=...`.
|
|
51
|
+
*/
|
|
52
|
+
readonly VARIANT_ALIAS: "cs-variant-alias";
|
|
28
53
|
};
|
|
29
54
|
declare const POST_MESSAGE_EVENTS: {
|
|
30
55
|
readonly INIT_STUDIO: "init-studio";
|
|
@@ -56,7 +81,9 @@ declare const POST_MESSAGE_EVENTS: {
|
|
|
56
81
|
readonly GET_STUDIO_INTELLIGENCE: "get-studio-intelligence";
|
|
57
82
|
readonly IFRAME_STUDIO_CONTEXT: "iframe-studio-context";
|
|
58
83
|
readonly SDK_SPEC_RESOLVED: "sdk-spec-resolved";
|
|
84
|
+
readonly SDK_DIAGNOSTICS: "sdk-diagnostics";
|
|
59
85
|
readonly SDK_INITIALIZED: "sdk-initialized";
|
|
86
|
+
readonly LISTENERS_READY: "listeners-ready";
|
|
60
87
|
readonly REPLACE_PREVIEW_ENTRY: "replace-preview-entry";
|
|
61
88
|
readonly CHANGE_ACTIVE_STYLE_SECTION: "change-active-style-section";
|
|
62
89
|
readonly CHANGE_STYLE_SECTION: "change-style-section";
|
|
@@ -65,6 +92,10 @@ declare const POST_MESSAGE_EVENTS: {
|
|
|
65
92
|
readonly UPDATE_BINDING_ERRORS: "update-binding-errors";
|
|
66
93
|
readonly OPEN_IN_COMPOSABLE_STUDIO_EVENT_MESSAGE: "open-composable-studio";
|
|
67
94
|
readonly UPDATE_SYMBOLS: "update-symbols";
|
|
95
|
+
readonly GET_SYMBOLS: "get-symbols";
|
|
96
|
+
readonly GET_SECTIONS: "get-sections";
|
|
97
|
+
readonly UPDATE_SECTION_CONTEXTS: "update-section-contexts";
|
|
98
|
+
readonly UPDATE_SECTIONS_CATALOG: "update-sections-catalog";
|
|
68
99
|
readonly ADD_NEW_SYMBOL: "add-new-symbol";
|
|
69
100
|
readonly HIDDEN_COMPONENT_NOTIFICATION: "hidden-component-notification";
|
|
70
101
|
readonly CONTEXT_MENU: "context-menu";
|
|
@@ -87,20 +118,15 @@ type ComposableStudioQueryParams = {
|
|
|
87
118
|
[key in ComposableStudioQueryParamsKeys]: string;
|
|
88
119
|
};
|
|
89
120
|
|
|
90
|
-
type
|
|
91
|
-
composableUid: string;
|
|
92
|
-
} | {
|
|
121
|
+
type CompositionQueryInput = {
|
|
93
122
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
123
|
+
* Passing only the composition UID is the fastest way to fetch the composition.
|
|
124
|
+
* It is useful for the freeform templates.
|
|
125
|
+
*
|
|
126
|
+
* However, if you only pass the composition UID, you should also pass the
|
|
127
|
+
* `templateEntryUid` to fetch the correct entry from the connected content type.
|
|
128
|
+
* Otherwise, we will fetch the first entry of the connected content type.
|
|
97
129
|
*/
|
|
98
|
-
url: string;
|
|
99
|
-
} | {
|
|
100
|
-
composableUid: string;
|
|
101
|
-
url: string;
|
|
102
|
-
};
|
|
103
|
-
type CompositionQueryInput = {
|
|
104
130
|
compositionUid: string;
|
|
105
131
|
} | {
|
|
106
132
|
/**
|
|
@@ -112,6 +138,22 @@ type CompositionQueryInput = {
|
|
|
112
138
|
} | {
|
|
113
139
|
compositionUid: string;
|
|
114
140
|
url: string;
|
|
141
|
+
} | {
|
|
142
|
+
url: string;
|
|
143
|
+
/**
|
|
144
|
+
* It is the Content type UID of the connected content type.
|
|
145
|
+
*/
|
|
146
|
+
templateContentTypeUid: string;
|
|
147
|
+
} | {
|
|
148
|
+
/**
|
|
149
|
+
* It is the Content type UID of the connected content type.
|
|
150
|
+
*
|
|
151
|
+
* If you only pass the template content type UID, you should also pass the
|
|
152
|
+
* `templateEntryUid` to fetch the correct entry from the connected content type.
|
|
153
|
+
* Otherwise, we will fetch the first entry of the connected content type.
|
|
154
|
+
* first entry of the connected content type for the linked templates.
|
|
155
|
+
*/
|
|
156
|
+
templateContentTypeUid: string;
|
|
115
157
|
};
|
|
116
158
|
|
|
117
159
|
type BuiltInCanvasConfig = {
|
|
@@ -119,4 +161,4 @@ type BuiltInCanvasConfig = {
|
|
|
119
161
|
};
|
|
120
162
|
|
|
121
163
|
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 };
|
|
122
|
-
export type { BuiltInCanvasConfig, ComposableStudioQueryParams, ComposableStudioQueryParamsKeys,
|
|
164
|
+
export type { BuiltInCanvasConfig, ComposableStudioQueryParams, ComposableStudioQueryParamsKeys, CompositionQueryInput };
|
package/dist/esm/main.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as advancedPostMessage from '@contentstack/advanced-post-message';
|
|
2
2
|
import { IS_BROWSER, COMPOSABLE_STUDIO_CHANNEL_ID, COMPOSABLE_STUDIO_POPUP_CHANNEL_ID, VISUAL_BUILDER_CHANNEL_ID, COMPOSABLE_STUDIO_BUILT_IN_CANVAS_CHANNEL_ID } from './constant.js';
|
|
3
3
|
|
|
4
|
+
const apmModule = advancedPostMessage;
|
|
5
|
+
const EventManager = apmModule.EventManager ?? apmModule.default?.EventManager;
|
|
6
|
+
if (!EventManager) {
|
|
7
|
+
throw new Error("studio-messenger: EventManager missing from @contentstack/advanced-post-message");
|
|
8
|
+
}
|
|
4
9
|
const getEventManager = (channelId) => {
|
|
5
10
|
if (!IS_BROWSER) {
|
|
6
11
|
return undefined;
|
|
@@ -9,6 +14,8 @@ const getEventManager = (channelId) => {
|
|
|
9
14
|
window.__csMessengerListeners__ = {};
|
|
10
15
|
}
|
|
11
16
|
if (!window.__csMessengerListeners__[channelId]) {
|
|
17
|
+
// Cache one EventManager per channel so repeated imports/mounts reuse the
|
|
18
|
+
// same postMessage bridge instead of creating duplicate listeners.
|
|
12
19
|
window.__csMessengerListeners__[channelId] = new EventManager(channelId, {
|
|
13
20
|
target: window.parent,
|
|
14
21
|
debug: false,
|
package/dist/esm/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":["../../src/main.ts"],"sourcesContent":[null],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"main.js","sources":["../../src/main.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAkBA,MAAM,SAAS,GAAG,mBAAgD;AAClE,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,IAAI,SAAS,CAAC,OAAO,EAAE,YAAY;AAE9E,IAAI,CAAC,YAAY,EAAE;AACjB,IAAA,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF;AACH;AAIA,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;;;QAG/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;AAG5C;AACA,eAAe,CAAC,kCAAkC;MACvC,yBAAyB;AACpC;AACA,eAAe,CAAC,yBAAyB;MAC9B,yCAAyC;AAGpD;AACA,eAAe,CAAC,4CAA4C;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/studio-messenger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "This package handles communication between the Studio platform and the iframe webpage.",
|
|
5
5
|
"main": "dist/cjs/index.cjs",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"url": "https://github.com/contentstack/composable-studio-sdk/issues"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@contentstack/common-config": "^1.
|
|
43
|
+
"@contentstack/common-config": "^1.2.0",
|
|
44
44
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
45
45
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
46
46
|
"@rollup/plugin-terser": "^1.0.0",
|
|
@@ -52,11 +52,8 @@
|
|
|
52
52
|
"typescript": "^5.5.4"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@contentstack/advanced-post-message": "^0.0.
|
|
56
|
-
"@contentstack/studio-message-types": "^1.
|
|
55
|
+
"@contentstack/advanced-post-message": "^0.0.5",
|
|
56
|
+
"@contentstack/studio-message-types": "^1.3.0"
|
|
57
57
|
},
|
|
58
|
-
"
|
|
59
|
-
"access": "public"
|
|
60
|
-
},
|
|
61
|
-
"gitHead": "1877b45f4a73ffb0c570ea06c197ba95504c014a"
|
|
58
|
+
"gitHead": "8ac2eaeeeab2403708cf075475d8553832fb7866"
|
|
62
59
|
}
|