@embeddable.com/sdk-core 3.9.9 → 3.9.11
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/lib/index.esm.js +7 -3
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +7 -3
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/validate.ts +8 -4
- package/templates/component.tsx.template +28 -8
package/package.json
CHANGED
package/src/validate.ts
CHANGED
|
@@ -247,10 +247,13 @@ const viewModelSchema = z.object({
|
|
|
247
247
|
});
|
|
248
248
|
|
|
249
249
|
const securityContextSchema = z.array(
|
|
250
|
-
z
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
250
|
+
z
|
|
251
|
+
.object({
|
|
252
|
+
name: z.string(),
|
|
253
|
+
securityContext: z.object({}), // can be any object
|
|
254
|
+
environment: z.string().optional(),
|
|
255
|
+
})
|
|
256
|
+
.strict(),
|
|
254
257
|
);
|
|
255
258
|
|
|
256
259
|
const clientContextSchema = z.array(
|
|
@@ -258,6 +261,7 @@ const clientContextSchema = z.array(
|
|
|
258
261
|
.object({
|
|
259
262
|
name: z.string(),
|
|
260
263
|
clientContext: z.object({}), // can be any object
|
|
264
|
+
canvas: z.object({}).optional(),
|
|
261
265
|
})
|
|
262
266
|
.strict(),
|
|
263
267
|
);
|
|
@@ -9,7 +9,7 @@ import { Component, Watch, Host, Prop, Event, EventEmitter, h, Listen } from '@s
|
|
|
9
9
|
export class EmbeddableComponent {
|
|
10
10
|
|
|
11
11
|
private rootElement?: HTMLDivElement;
|
|
12
|
-
private
|
|
12
|
+
private updateEventDispatched?: boolean;
|
|
13
13
|
|
|
14
14
|
@Prop() componentName: string;
|
|
15
15
|
@Prop() props: string = '{}';
|
|
@@ -22,7 +22,6 @@ export class EmbeddableComponent {
|
|
|
22
22
|
bubbles: true,
|
|
23
23
|
}) componentDidLoadEvent: EventEmitter<any>;
|
|
24
24
|
|
|
25
|
-
@Watch('clientContext')
|
|
26
25
|
@Watch('componentName')
|
|
27
26
|
watchComponentName() {
|
|
28
27
|
this.handlePops();
|
|
@@ -45,20 +44,27 @@ export class EmbeddableComponent {
|
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
componentWillUpdate() {
|
|
48
|
-
const
|
|
47
|
+
const eventProps = new CustomEvent('embeddable-event:update-props', {
|
|
49
48
|
bubbles: false,
|
|
50
49
|
detail: JSON.parse(this.props),
|
|
51
50
|
});
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
|
|
52
|
+
const eventClientContext = new CustomEvent('embeddable-event:update-client-context', {
|
|
53
|
+
bubbles: false,
|
|
54
|
+
detail: JSON.parse(this.clientContext),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
this.rootElement.dispatchEvent(eventProps);
|
|
58
|
+
this.rootElement.dispatchEvent(eventClientContext);
|
|
59
|
+
this.updateEventDispatched = true;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
@Listen('embeddable-event:update-props-listen', {target: 'window'})
|
|
57
63
|
handleUpdatePropsListen(e) {
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
if(this.updateEventDispatched && componentId === props.componentId) {
|
|
65
|
+
const componentId = e.detail.componentId;
|
|
66
|
+
const props = JSON.parse(this.props);
|
|
60
67
|
|
|
61
|
-
if(this.updatePropsEventDispatched && componentId === props.componentId) {
|
|
62
68
|
const event = new CustomEvent('embeddable-event:update-props', {
|
|
63
69
|
bubbles: false,
|
|
64
70
|
detail: props,
|
|
@@ -67,6 +73,20 @@ export class EmbeddableComponent {
|
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
|
|
76
|
+
@Listen('embeddable-event:update-client-context-listen', {target: 'window'})
|
|
77
|
+
handleUpdateClientContextListen(e) {
|
|
78
|
+
if(this.updateEventDispatched && componentId === props.componentId) {
|
|
79
|
+
const componentId = e.detail.componentId;
|
|
80
|
+
const clientContext = JSON.parse(this.clientContext);
|
|
81
|
+
|
|
82
|
+
const event = new CustomEvent('embeddable-event:update-client-context', {
|
|
83
|
+
bubbles: false,
|
|
84
|
+
detail: props,
|
|
85
|
+
});
|
|
86
|
+
this.rootElement.dispatchEvent(event);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
render() {
|
|
71
91
|
return (
|
|
72
92
|
<Host>
|