@builder.io/sdk-svelte 4.0.0 → 4.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/lib/browser/components/content/components/enable-editor.svelte +12 -3
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/helpers/subscribe-to-editor.d.ts +2 -0
- package/lib/browser/helpers/subscribe-to-editor.js +12 -1
- package/lib/edge/components/content/components/enable-editor.svelte +12 -3
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/helpers/subscribe-to-editor.d.ts +2 -0
- package/lib/edge/helpers/subscribe-to-editor.js +12 -1
- package/lib/node/components/content/components/enable-editor.svelte +12 -3
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/helpers/subscribe-to-editor.d.ts +2 -0
- package/lib/node/helpers/subscribe-to-editor.js +12 -1
- package/package.json +1 -1
- package/src/components/content/components/enable-editor.svelte +13 -3
- package/src/constants/sdk-version.ts +1 -1
- package/src/helpers/subscribe-to-editor.ts +14 -1
|
@@ -13,6 +13,7 @@ import { createRegisterComponentMessage } from "../../../functions/register-comp
|
|
|
13
13
|
import { _track } from "../../../functions/track/index";
|
|
14
14
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
|
|
15
15
|
import { getDefaultCanTrack } from "../../../helpers/canTrack";
|
|
16
|
+
import { getCookieSync } from "../../../helpers/cookie";
|
|
16
17
|
import "../../../helpers/preview-lru-cache/set";
|
|
17
18
|
import { createEditorListener } from "../../../helpers/subscribe-to-editor";
|
|
18
19
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing";
|
|
@@ -98,6 +99,9 @@ function processMessage(event) {
|
|
|
98
99
|
contentUpdate: (newContent) => {
|
|
99
100
|
mergeNewContent(newContent);
|
|
100
101
|
},
|
|
102
|
+
stateUpdate: (newState) => {
|
|
103
|
+
mergeNewRootState(newState);
|
|
104
|
+
},
|
|
101
105
|
},
|
|
102
106
|
})(event);
|
|
103
107
|
}
|
|
@@ -244,6 +248,7 @@ $: showContentProps = () => {
|
|
|
244
248
|
};
|
|
245
249
|
};
|
|
246
250
|
let elementRef;
|
|
251
|
+
let hasExecuted = false;
|
|
247
252
|
let ContentWrapper = contentWrapper || "div";
|
|
248
253
|
let httpReqsData = {};
|
|
249
254
|
let httpReqsPending = {};
|
|
@@ -258,8 +263,12 @@ onMount(() => {
|
|
|
258
263
|
}
|
|
259
264
|
}
|
|
260
265
|
const shouldTrackImpression = $builderContextSignal.content && getDefaultCanTrack(canTrack);
|
|
261
|
-
|
|
262
|
-
|
|
266
|
+
const winningVariantId = getCookieSync({
|
|
267
|
+
name: `builder.tests.${$builderContextSignal.content?.id}`,
|
|
268
|
+
canTrack: true,
|
|
269
|
+
});
|
|
270
|
+
const variationId = $builderContextSignal.content?.testVariationId;
|
|
271
|
+
if (shouldTrackImpression && variationId === winningVariantId) {
|
|
263
272
|
const contentId = $builderContextSignal.content?.id;
|
|
264
273
|
const apiKeyProp = apiKey;
|
|
265
274
|
_track({
|
|
@@ -268,7 +277,7 @@ onMount(() => {
|
|
|
268
277
|
canTrack: true,
|
|
269
278
|
contentId,
|
|
270
279
|
apiKey: apiKeyProp,
|
|
271
|
-
variationId:
|
|
280
|
+
variationId: winningVariantId !== contentId ? winningVariantId : undefined,
|
|
272
281
|
});
|
|
273
282
|
}
|
|
274
283
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "4.0.
|
|
1
|
+
export declare const SDK_VERSION = "4.0.2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "4.0.
|
|
1
|
+
export const SDK_VERSION = "4.0.2";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ContentProps } from '../components/content/content.types';
|
|
2
2
|
import type { BuilderAnimation } from '../types/builder-block';
|
|
3
3
|
import type { BuilderContent } from '../types/builder-content';
|
|
4
|
+
import type { Dictionary } from '../types/typescript';
|
|
4
5
|
type ContentListener = Required<Pick<ContentProps, 'model' | 'trustedHosts'>> & {
|
|
5
6
|
callbacks: {
|
|
6
7
|
contentUpdate: (updatedContent: BuilderContent) => void;
|
|
8
|
+
stateUpdate: (newState: Dictionary<string>) => void;
|
|
7
9
|
animation: (updatedContent: BuilderAnimation) => void;
|
|
8
10
|
configureSdk: (updatedContent: any) => void;
|
|
9
11
|
};
|
|
@@ -20,6 +20,16 @@ export const createEditorListener = ({ model, trustedHosts, callbacks }) => {
|
|
|
20
20
|
callbacks.animation(data.data);
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
|
+
case 'builder.resetState':
|
|
24
|
+
{
|
|
25
|
+
const messageContent = data.data;
|
|
26
|
+
const modelName = messageContent.model;
|
|
27
|
+
const newState = messageContent?.state;
|
|
28
|
+
if (modelName === model && newState) {
|
|
29
|
+
callbacks.stateUpdate(newState);
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
23
33
|
case 'builder.contentUpdate':
|
|
24
34
|
{
|
|
25
35
|
const messageContent = data.data;
|
|
@@ -51,7 +61,8 @@ export const subscribeToEditor = ({ model, apiKey, callback, trustedHosts }) =>
|
|
|
51
61
|
callbacks: {
|
|
52
62
|
contentUpdate: callback,
|
|
53
63
|
animation: () => { },
|
|
54
|
-
configureSdk: () => { }
|
|
64
|
+
configureSdk: () => { },
|
|
65
|
+
stateUpdate: () => { }
|
|
55
66
|
},
|
|
56
67
|
model,
|
|
57
68
|
trustedHosts
|
|
@@ -13,6 +13,7 @@ import { createRegisterComponentMessage } from "../../../functions/register-comp
|
|
|
13
13
|
import { _track } from "../../../functions/track/index";
|
|
14
14
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
|
|
15
15
|
import { getDefaultCanTrack } from "../../../helpers/canTrack";
|
|
16
|
+
import { getCookieSync } from "../../../helpers/cookie";
|
|
16
17
|
import "../../../helpers/preview-lru-cache/set";
|
|
17
18
|
import { createEditorListener } from "../../../helpers/subscribe-to-editor";
|
|
18
19
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing";
|
|
@@ -98,6 +99,9 @@ function processMessage(event) {
|
|
|
98
99
|
contentUpdate: (newContent) => {
|
|
99
100
|
mergeNewContent(newContent);
|
|
100
101
|
},
|
|
102
|
+
stateUpdate: (newState) => {
|
|
103
|
+
mergeNewRootState(newState);
|
|
104
|
+
},
|
|
101
105
|
},
|
|
102
106
|
})(event);
|
|
103
107
|
}
|
|
@@ -244,6 +248,7 @@ $: showContentProps = () => {
|
|
|
244
248
|
};
|
|
245
249
|
};
|
|
246
250
|
let elementRef;
|
|
251
|
+
let hasExecuted = false;
|
|
247
252
|
let ContentWrapper = contentWrapper || "div";
|
|
248
253
|
let httpReqsData = {};
|
|
249
254
|
let httpReqsPending = {};
|
|
@@ -258,8 +263,12 @@ onMount(() => {
|
|
|
258
263
|
}
|
|
259
264
|
}
|
|
260
265
|
const shouldTrackImpression = $builderContextSignal.content && getDefaultCanTrack(canTrack);
|
|
261
|
-
|
|
262
|
-
|
|
266
|
+
const winningVariantId = getCookieSync({
|
|
267
|
+
name: `builder.tests.${$builderContextSignal.content?.id}`,
|
|
268
|
+
canTrack: true,
|
|
269
|
+
});
|
|
270
|
+
const variationId = $builderContextSignal.content?.testVariationId;
|
|
271
|
+
if (shouldTrackImpression && variationId === winningVariantId) {
|
|
263
272
|
const contentId = $builderContextSignal.content?.id;
|
|
264
273
|
const apiKeyProp = apiKey;
|
|
265
274
|
_track({
|
|
@@ -268,7 +277,7 @@ onMount(() => {
|
|
|
268
277
|
canTrack: true,
|
|
269
278
|
contentId,
|
|
270
279
|
apiKey: apiKeyProp,
|
|
271
|
-
variationId:
|
|
280
|
+
variationId: winningVariantId !== contentId ? winningVariantId : undefined,
|
|
272
281
|
});
|
|
273
282
|
}
|
|
274
283
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "4.0.
|
|
1
|
+
export declare const SDK_VERSION = "4.0.2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "4.0.
|
|
1
|
+
export const SDK_VERSION = "4.0.2";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ContentProps } from '../components/content/content.types';
|
|
2
2
|
import type { BuilderAnimation } from '../types/builder-block';
|
|
3
3
|
import type { BuilderContent } from '../types/builder-content';
|
|
4
|
+
import type { Dictionary } from '../types/typescript';
|
|
4
5
|
type ContentListener = Required<Pick<ContentProps, 'model' | 'trustedHosts'>> & {
|
|
5
6
|
callbacks: {
|
|
6
7
|
contentUpdate: (updatedContent: BuilderContent) => void;
|
|
8
|
+
stateUpdate: (newState: Dictionary<string>) => void;
|
|
7
9
|
animation: (updatedContent: BuilderAnimation) => void;
|
|
8
10
|
configureSdk: (updatedContent: any) => void;
|
|
9
11
|
};
|
|
@@ -20,6 +20,16 @@ export const createEditorListener = ({ model, trustedHosts, callbacks }) => {
|
|
|
20
20
|
callbacks.animation(data.data);
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
|
+
case 'builder.resetState':
|
|
24
|
+
{
|
|
25
|
+
const messageContent = data.data;
|
|
26
|
+
const modelName = messageContent.model;
|
|
27
|
+
const newState = messageContent?.state;
|
|
28
|
+
if (modelName === model && newState) {
|
|
29
|
+
callbacks.stateUpdate(newState);
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
23
33
|
case 'builder.contentUpdate':
|
|
24
34
|
{
|
|
25
35
|
const messageContent = data.data;
|
|
@@ -51,7 +61,8 @@ export const subscribeToEditor = ({ model, apiKey, callback, trustedHosts }) =>
|
|
|
51
61
|
callbacks: {
|
|
52
62
|
contentUpdate: callback,
|
|
53
63
|
animation: () => { },
|
|
54
|
-
configureSdk: () => { }
|
|
64
|
+
configureSdk: () => { },
|
|
65
|
+
stateUpdate: () => { }
|
|
55
66
|
},
|
|
56
67
|
model,
|
|
57
68
|
trustedHosts
|
|
@@ -13,6 +13,7 @@ import { createRegisterComponentMessage } from "../../../functions/register-comp
|
|
|
13
13
|
import { _track } from "../../../functions/track/index";
|
|
14
14
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
|
|
15
15
|
import { getDefaultCanTrack } from "../../../helpers/canTrack";
|
|
16
|
+
import { getCookieSync } from "../../../helpers/cookie";
|
|
16
17
|
import "../../../helpers/preview-lru-cache/set";
|
|
17
18
|
import { createEditorListener } from "../../../helpers/subscribe-to-editor";
|
|
18
19
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing";
|
|
@@ -98,6 +99,9 @@ function processMessage(event) {
|
|
|
98
99
|
contentUpdate: (newContent) => {
|
|
99
100
|
mergeNewContent(newContent);
|
|
100
101
|
},
|
|
102
|
+
stateUpdate: (newState) => {
|
|
103
|
+
mergeNewRootState(newState);
|
|
104
|
+
},
|
|
101
105
|
},
|
|
102
106
|
})(event);
|
|
103
107
|
}
|
|
@@ -244,6 +248,7 @@ $: showContentProps = () => {
|
|
|
244
248
|
};
|
|
245
249
|
};
|
|
246
250
|
let elementRef;
|
|
251
|
+
let hasExecuted = false;
|
|
247
252
|
let ContentWrapper = contentWrapper || "div";
|
|
248
253
|
let httpReqsData = {};
|
|
249
254
|
let httpReqsPending = {};
|
|
@@ -258,8 +263,12 @@ onMount(() => {
|
|
|
258
263
|
}
|
|
259
264
|
}
|
|
260
265
|
const shouldTrackImpression = $builderContextSignal.content && getDefaultCanTrack(canTrack);
|
|
261
|
-
|
|
262
|
-
|
|
266
|
+
const winningVariantId = getCookieSync({
|
|
267
|
+
name: `builder.tests.${$builderContextSignal.content?.id}`,
|
|
268
|
+
canTrack: true,
|
|
269
|
+
});
|
|
270
|
+
const variationId = $builderContextSignal.content?.testVariationId;
|
|
271
|
+
if (shouldTrackImpression && variationId === winningVariantId) {
|
|
263
272
|
const contentId = $builderContextSignal.content?.id;
|
|
264
273
|
const apiKeyProp = apiKey;
|
|
265
274
|
_track({
|
|
@@ -268,7 +277,7 @@ onMount(() => {
|
|
|
268
277
|
canTrack: true,
|
|
269
278
|
contentId,
|
|
270
279
|
apiKey: apiKeyProp,
|
|
271
|
-
variationId:
|
|
280
|
+
variationId: winningVariantId !== contentId ? winningVariantId : undefined,
|
|
272
281
|
});
|
|
273
282
|
}
|
|
274
283
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "4.0.
|
|
1
|
+
export declare const SDK_VERSION = "4.0.2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "4.0.
|
|
1
|
+
export const SDK_VERSION = "4.0.2";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ContentProps } from '../components/content/content.types';
|
|
2
2
|
import type { BuilderAnimation } from '../types/builder-block';
|
|
3
3
|
import type { BuilderContent } from '../types/builder-content';
|
|
4
|
+
import type { Dictionary } from '../types/typescript';
|
|
4
5
|
type ContentListener = Required<Pick<ContentProps, 'model' | 'trustedHosts'>> & {
|
|
5
6
|
callbacks: {
|
|
6
7
|
contentUpdate: (updatedContent: BuilderContent) => void;
|
|
8
|
+
stateUpdate: (newState: Dictionary<string>) => void;
|
|
7
9
|
animation: (updatedContent: BuilderAnimation) => void;
|
|
8
10
|
configureSdk: (updatedContent: any) => void;
|
|
9
11
|
};
|
|
@@ -20,6 +20,16 @@ export const createEditorListener = ({ model, trustedHosts, callbacks }) => {
|
|
|
20
20
|
callbacks.animation(data.data);
|
|
21
21
|
break;
|
|
22
22
|
}
|
|
23
|
+
case 'builder.resetState':
|
|
24
|
+
{
|
|
25
|
+
const messageContent = data.data;
|
|
26
|
+
const modelName = messageContent.model;
|
|
27
|
+
const newState = messageContent?.state;
|
|
28
|
+
if (modelName === model && newState) {
|
|
29
|
+
callbacks.stateUpdate(newState);
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
23
33
|
case 'builder.contentUpdate':
|
|
24
34
|
{
|
|
25
35
|
const messageContent = data.data;
|
|
@@ -51,7 +61,8 @@ export const subscribeToEditor = ({ model, apiKey, callback, trustedHosts }) =>
|
|
|
51
61
|
callbacks: {
|
|
52
62
|
contentUpdate: callback,
|
|
53
63
|
animation: () => { },
|
|
54
|
-
configureSdk: () => { }
|
|
64
|
+
configureSdk: () => { },
|
|
65
|
+
stateUpdate: () => { }
|
|
55
66
|
},
|
|
56
67
|
model,
|
|
57
68
|
trustedHosts
|
package/package.json
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
import { _track } from "../../../functions/track/index";
|
|
31
31
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
|
|
32
32
|
import { getDefaultCanTrack } from "../../../helpers/canTrack";
|
|
33
|
+
import { getCookieSync } from "../../../helpers/cookie";
|
|
33
34
|
import { postPreviewContent } from "../../../helpers/preview-lru-cache/set";
|
|
34
35
|
import { createEditorListener } from "../../../helpers/subscribe-to-editor";
|
|
35
36
|
import {
|
|
@@ -130,6 +131,9 @@
|
|
|
130
131
|
contentUpdate: (newContent) => {
|
|
131
132
|
mergeNewContent(newContent);
|
|
132
133
|
},
|
|
134
|
+
stateUpdate: (newState) => {
|
|
135
|
+
mergeNewRootState(newState);
|
|
136
|
+
},
|
|
133
137
|
},
|
|
134
138
|
})(event);
|
|
135
139
|
}
|
|
@@ -301,6 +305,7 @@
|
|
|
301
305
|
|
|
302
306
|
let elementRef;
|
|
303
307
|
|
|
308
|
+
let hasExecuted = false;
|
|
304
309
|
let ContentWrapper = contentWrapper || "div";
|
|
305
310
|
let httpReqsData = {};
|
|
306
311
|
let httpReqsPending = {};
|
|
@@ -317,8 +322,12 @@
|
|
|
317
322
|
}
|
|
318
323
|
const shouldTrackImpression =
|
|
319
324
|
$builderContextSignal.content && getDefaultCanTrack(canTrack);
|
|
320
|
-
|
|
321
|
-
|
|
325
|
+
const winningVariantId = getCookieSync({
|
|
326
|
+
name: `builder.tests.${$builderContextSignal.content?.id}`,
|
|
327
|
+
canTrack: true,
|
|
328
|
+
});
|
|
329
|
+
const variationId = $builderContextSignal.content?.testVariationId;
|
|
330
|
+
if (shouldTrackImpression && variationId === winningVariantId) {
|
|
322
331
|
const contentId = $builderContextSignal.content?.id;
|
|
323
332
|
const apiKeyProp = apiKey;
|
|
324
333
|
_track({
|
|
@@ -327,7 +336,8 @@
|
|
|
327
336
|
canTrack: true,
|
|
328
337
|
contentId,
|
|
329
338
|
apiKey: apiKeyProp!,
|
|
330
|
-
variationId:
|
|
339
|
+
variationId:
|
|
340
|
+
winningVariantId !== contentId ? winningVariantId : undefined,
|
|
331
341
|
});
|
|
332
342
|
}
|
|
333
343
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "4.0.
|
|
1
|
+
export const SDK_VERSION = "4.0.2"
|
|
@@ -4,10 +4,12 @@ import { isFromTrustedHost } from '../functions/is-from-trusted-host';
|
|
|
4
4
|
import { setupBrowserForEditing } from '../scripts/init-editing';
|
|
5
5
|
import type { BuilderAnimation } from '../types/builder-block';
|
|
6
6
|
import type { BuilderContent } from '../types/builder-content';
|
|
7
|
+
import type { Dictionary } from '../types/typescript';
|
|
7
8
|
import { logger } from './logger';
|
|
8
9
|
type ContentListener = Required<Pick<ContentProps, 'model' | 'trustedHosts'>> & {
|
|
9
10
|
callbacks: {
|
|
10
11
|
contentUpdate: (updatedContent: BuilderContent) => void;
|
|
12
|
+
stateUpdate: (newState: Dictionary<string>) => void;
|
|
11
13
|
animation: (updatedContent: BuilderAnimation) => void;
|
|
12
14
|
configureSdk: (updatedContent: any) => void;
|
|
13
15
|
};
|
|
@@ -36,6 +38,16 @@ export const createEditorListener = ({
|
|
|
36
38
|
callbacks.animation(data.data);
|
|
37
39
|
break;
|
|
38
40
|
}
|
|
41
|
+
case 'builder.resetState':
|
|
42
|
+
{
|
|
43
|
+
const messageContent = data.data;
|
|
44
|
+
const modelName = messageContent.model;
|
|
45
|
+
const newState = messageContent?.state;
|
|
46
|
+
if (modelName === model && newState) {
|
|
47
|
+
callbacks.stateUpdate(newState);
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
39
51
|
case 'builder.contentUpdate':
|
|
40
52
|
{
|
|
41
53
|
const messageContent = data.data;
|
|
@@ -96,7 +108,8 @@ export const subscribeToEditor: SubscribeToEditor = ({
|
|
|
96
108
|
callbacks: {
|
|
97
109
|
contentUpdate: callback,
|
|
98
110
|
animation: () => {},
|
|
99
|
-
configureSdk: () => {}
|
|
111
|
+
configureSdk: () => {},
|
|
112
|
+
stateUpdate: () => {}
|
|
100
113
|
},
|
|
101
114
|
model,
|
|
102
115
|
trustedHosts
|