@builder.io/sdk-qwik 0.18.0 → 0.18.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.
@@ -14,6 +14,7 @@ const registerComponent = require("../../../functions/register-component.qwik.cj
14
14
  const index$1 = require("../../../functions/track/index.qwik.cjs");
15
15
  const interaction = require("../../../functions/track/interaction.qwik.cjs");
16
16
  const canTrack = require("../../../helpers/canTrack.qwik.cjs");
17
+ const cookie = require("../../../helpers/cookie.qwik.cjs");
17
18
  const subscribeToEditor = require("../../../helpers/subscribe-to-editor.qwik.cjs");
18
19
  const initEditing = require("../../../scripts/init-editing.qwik.cjs");
19
20
  const animator = require("../../block/animator.qwik.cjs");
@@ -69,6 +70,9 @@ const processMessage = function processMessage2(props, state, showContentProps,
69
70
  },
70
71
  contentUpdate: (newContent) => {
71
72
  mergeNewContent(props, state, showContentProps, elementRef, newContent);
73
+ },
74
+ stateUpdate: (newState) => {
75
+ mergeNewRootState(props, state, showContentProps, elementRef, newState);
72
76
  }
73
77
  }
74
78
  })(event);
@@ -150,6 +154,7 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
150
154
  const state = qwik.useStore({
151
155
  ContentWrapper: props.contentWrapper || "div",
152
156
  clicked: false,
157
+ hasExecuted: false,
153
158
  httpReqsData: {},
154
159
  httpReqsPending: {}
155
160
  }, {
@@ -214,25 +219,32 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
214
219
  state
215
220
  ]));
216
221
  qwik.useOnDocument("readystatechange", /* @__PURE__ */ qwik.inlinedQrl((event, element) => {
217
- var _a2, _b2, _c, _d;
218
- const [props2] = qwik.useLexicalScope();
222
+ var _a2, _b2, _c, _d, _e;
223
+ const [props2, state2] = qwik.useLexicalScope();
224
+ if (state2.hasExecuted)
225
+ return;
219
226
  if (isBrowser.isBrowser()) {
227
+ state2.hasExecuted = true;
220
228
  if (isEditing.isEditing() && !props2.isNestedRender) {
221
229
  if (element)
222
230
  element.dispatchEvent(new CustomEvent("initeditingbldr"));
223
231
  }
224
232
  const shouldTrackImpression = ((_a2 = element.attributes.getNamedItem("shouldTrack")) == null ? void 0 : _a2.value) === "true";
225
- if (shouldTrackImpression) {
226
- const variationId = (_b2 = element.attributes.getNamedItem("variationId")) == null ? void 0 : _b2.value;
227
- const contentId = (_c = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c.value;
228
- const apiKeyProp = (_d = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d.value;
233
+ const winningVariantId = cookie.getCookieSync({
234
+ name: `builder.tests.${(_b2 = props2.builderContextSignal.content) == null ? void 0 : _b2.id}`,
235
+ canTrack: true
236
+ });
237
+ const variationId = (_c = element.attributes.getNamedItem("variationId")) == null ? void 0 : _c.value;
238
+ if (shouldTrackImpression && variationId === winningVariantId) {
239
+ const contentId = (_d = element.attributes.getNamedItem("contentId")) == null ? void 0 : _d.value;
240
+ const apiKeyProp = (_e = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _e.value;
229
241
  index$1._track({
230
242
  apiHost: props2.apiHost,
231
243
  type: "impression",
232
244
  canTrack: true,
233
245
  contentId,
234
246
  apiKey: apiKeyProp,
235
- variationId: variationId !== contentId ? variationId : void 0
247
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
236
248
  });
237
249
  }
238
250
  if (isPreviewing.isPreviewing() && !isEditing.isEditing()) {
@@ -241,7 +253,8 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
241
253
  }
242
254
  }
243
255
  }, "EnableEditor_component_useOnDocument_H7syEGJXM4Y", [
244
- props
256
+ props,
257
+ state
245
258
  ]));
246
259
  qwik.useContextProvider(builder_context, props.builderContextSignal);
247
260
  qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
@@ -12,6 +12,7 @@ import { createRegisterComponentMessage } from "../../../functions/register-comp
12
12
  import { _track } from "../../../functions/track/index.qwik.mjs";
13
13
  import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.qwik.mjs";
14
14
  import { getDefaultCanTrack } from "../../../helpers/canTrack.qwik.mjs";
15
+ import { getCookieSync } from "../../../helpers/cookie.qwik.mjs";
15
16
  import { createEditorListener } from "../../../helpers/subscribe-to-editor.qwik.mjs";
16
17
  import { registerInsertMenu, setupBrowserForEditing } from "../../../scripts/init-editing.qwik.mjs";
17
18
  import { triggerAnimation } from "../../block/animator.qwik.mjs";
@@ -67,6 +68,9 @@ const processMessage = function processMessage2(props, state, showContentProps,
67
68
  },
68
69
  contentUpdate: (newContent) => {
69
70
  mergeNewContent(props, state, showContentProps, elementRef, newContent);
71
+ },
72
+ stateUpdate: (newState) => {
73
+ mergeNewRootState(props, state, showContentProps, elementRef, newState);
70
74
  }
71
75
  }
72
76
  })(event);
@@ -148,6 +152,7 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
148
152
  const state = useStore({
149
153
  ContentWrapper: props.contentWrapper || "div",
150
154
  clicked: false,
155
+ hasExecuted: false,
151
156
  httpReqsData: {},
152
157
  httpReqsPending: {}
153
158
  }, {
@@ -212,25 +217,32 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
212
217
  state
213
218
  ]));
214
219
  useOnDocument("readystatechange", /* @__PURE__ */ inlinedQrl((event, element) => {
215
- var _a2, _b2, _c, _d;
216
- const [props2] = useLexicalScope();
220
+ var _a2, _b2, _c, _d, _e;
221
+ const [props2, state2] = useLexicalScope();
222
+ if (state2.hasExecuted)
223
+ return;
217
224
  if (isBrowser()) {
225
+ state2.hasExecuted = true;
218
226
  if (isEditing() && !props2.isNestedRender) {
219
227
  if (element)
220
228
  element.dispatchEvent(new CustomEvent("initeditingbldr"));
221
229
  }
222
230
  const shouldTrackImpression = ((_a2 = element.attributes.getNamedItem("shouldTrack")) == null ? void 0 : _a2.value) === "true";
223
- if (shouldTrackImpression) {
224
- const variationId = (_b2 = element.attributes.getNamedItem("variationId")) == null ? void 0 : _b2.value;
225
- const contentId = (_c = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c.value;
226
- const apiKeyProp = (_d = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d.value;
231
+ const winningVariantId = getCookieSync({
232
+ name: `builder.tests.${(_b2 = props2.builderContextSignal.content) == null ? void 0 : _b2.id}`,
233
+ canTrack: true
234
+ });
235
+ const variationId = (_c = element.attributes.getNamedItem("variationId")) == null ? void 0 : _c.value;
236
+ if (shouldTrackImpression && variationId === winningVariantId) {
237
+ const contentId = (_d = element.attributes.getNamedItem("contentId")) == null ? void 0 : _d.value;
238
+ const apiKeyProp = (_e = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _e.value;
227
239
  _track({
228
240
  apiHost: props2.apiHost,
229
241
  type: "impression",
230
242
  canTrack: true,
231
243
  contentId,
232
244
  apiKey: apiKeyProp,
233
- variationId: variationId !== contentId ? variationId : void 0
245
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
234
246
  });
235
247
  }
236
248
  if (isPreviewing() && !isEditing()) {
@@ -239,7 +251,8 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
239
251
  }
240
252
  }
241
253
  }, "EnableEditor_component_useOnDocument_H7syEGJXM4Y", [
242
- props
254
+ props,
255
+ state
243
256
  ]));
244
257
  useContextProvider(builderContext, props.builderContextSignal);
245
258
  useTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.18.0";
3
+ const SDK_VERSION = "0.18.2";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.18.0";
1
+ const SDK_VERSION = "0.18.2";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -17,6 +17,14 @@ const createEditorListener = ({ model, trustedHosts, callbacks }) => {
17
17
  case "builder.triggerAnimation":
18
18
  callbacks.animation(data.data);
19
19
  break;
20
+ case "builder.resetState": {
21
+ const messageContent = data.data;
22
+ const modelName = messageContent.model;
23
+ const newState = messageContent == null ? void 0 : messageContent.state;
24
+ if (modelName === model && newState)
25
+ callbacks.stateUpdate(newState);
26
+ break;
27
+ }
20
28
  case "builder.contentUpdate": {
21
29
  const messageContent = data.data;
22
30
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -44,6 +52,8 @@ const subscribeToEditor = ({ model, apiKey, callback, trustedHosts }) => {
44
52
  animation: () => {
45
53
  },
46
54
  configureSdk: () => {
55
+ },
56
+ stateUpdate: () => {
47
57
  }
48
58
  },
49
59
  model,
@@ -15,6 +15,14 @@ const createEditorListener = ({ model, trustedHosts, callbacks }) => {
15
15
  case "builder.triggerAnimation":
16
16
  callbacks.animation(data.data);
17
17
  break;
18
+ case "builder.resetState": {
19
+ const messageContent = data.data;
20
+ const modelName = messageContent.model;
21
+ const newState = messageContent == null ? void 0 : messageContent.state;
22
+ if (modelName === model && newState)
23
+ callbacks.stateUpdate(newState);
24
+ break;
25
+ }
18
26
  case "builder.contentUpdate": {
19
27
  const messageContent = data.data;
20
28
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -42,6 +50,8 @@ const subscribeToEditor = ({ model, apiKey, callback, trustedHosts }) => {
42
50
  animation: () => {
43
51
  },
44
52
  configureSdk: () => {
53
+ },
54
+ stateUpdate: () => {
45
55
  }
46
56
  },
47
57
  model,
@@ -14,6 +14,7 @@ const registerComponent = require("../../../functions/register-component.qwik.cj
14
14
  const index$1 = require("../../../functions/track/index.qwik.cjs");
15
15
  const interaction = require("../../../functions/track/interaction.qwik.cjs");
16
16
  const canTrack = require("../../../helpers/canTrack.qwik.cjs");
17
+ const cookie = require("../../../helpers/cookie.qwik.cjs");
17
18
  const subscribeToEditor = require("../../../helpers/subscribe-to-editor.qwik.cjs");
18
19
  const initEditing = require("../../../scripts/init-editing.qwik.cjs");
19
20
  const animator = require("../../block/animator.qwik.cjs");
@@ -69,6 +70,9 @@ const processMessage = function processMessage2(props, state, showContentProps,
69
70
  },
70
71
  contentUpdate: (newContent) => {
71
72
  mergeNewContent(props, state, showContentProps, elementRef, newContent);
73
+ },
74
+ stateUpdate: (newState) => {
75
+ mergeNewRootState(props, state, showContentProps, elementRef, newState);
72
76
  }
73
77
  }
74
78
  })(event);
@@ -150,6 +154,7 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
150
154
  const state = qwik.useStore({
151
155
  ContentWrapper: props.contentWrapper || "div",
152
156
  clicked: false,
157
+ hasExecuted: false,
153
158
  httpReqsData: {},
154
159
  httpReqsPending: {}
155
160
  }, {
@@ -214,25 +219,32 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
214
219
  state
215
220
  ]));
216
221
  qwik.useOnDocument("readystatechange", /* @__PURE__ */ qwik.inlinedQrl((event, element) => {
217
- var _a2, _b2, _c, _d;
218
- const [props2] = qwik.useLexicalScope();
222
+ var _a2, _b2, _c, _d, _e;
223
+ const [props2, state2] = qwik.useLexicalScope();
224
+ if (state2.hasExecuted)
225
+ return;
219
226
  if (isBrowser.isBrowser()) {
227
+ state2.hasExecuted = true;
220
228
  if (isEditing.isEditing() && !props2.isNestedRender) {
221
229
  if (element)
222
230
  element.dispatchEvent(new CustomEvent("initeditingbldr"));
223
231
  }
224
232
  const shouldTrackImpression = ((_a2 = element.attributes.getNamedItem("shouldTrack")) == null ? void 0 : _a2.value) === "true";
225
- if (shouldTrackImpression) {
226
- const variationId = (_b2 = element.attributes.getNamedItem("variationId")) == null ? void 0 : _b2.value;
227
- const contentId = (_c = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c.value;
228
- const apiKeyProp = (_d = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d.value;
233
+ const winningVariantId = cookie.getCookieSync({
234
+ name: `builder.tests.${(_b2 = props2.builderContextSignal.content) == null ? void 0 : _b2.id}`,
235
+ canTrack: true
236
+ });
237
+ const variationId = (_c = element.attributes.getNamedItem("variationId")) == null ? void 0 : _c.value;
238
+ if (shouldTrackImpression && variationId === winningVariantId) {
239
+ const contentId = (_d = element.attributes.getNamedItem("contentId")) == null ? void 0 : _d.value;
240
+ const apiKeyProp = (_e = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _e.value;
229
241
  index$1._track({
230
242
  apiHost: props2.apiHost,
231
243
  type: "impression",
232
244
  canTrack: true,
233
245
  contentId,
234
246
  apiKey: apiKeyProp,
235
- variationId: variationId !== contentId ? variationId : void 0
247
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
236
248
  });
237
249
  }
238
250
  if (isPreviewing.isPreviewing() && !isEditing.isEditing()) {
@@ -241,7 +253,8 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
241
253
  }
242
254
  }
243
255
  }, "EnableEditor_component_useOnDocument_H7syEGJXM4Y", [
244
- props
256
+ props,
257
+ state
245
258
  ]));
246
259
  qwik.useContextProvider(builder_context, props.builderContextSignal);
247
260
  qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
@@ -12,6 +12,7 @@ import { createRegisterComponentMessage } from "../../../functions/register-comp
12
12
  import { _track } from "../../../functions/track/index.qwik.mjs";
13
13
  import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.qwik.mjs";
14
14
  import { getDefaultCanTrack } from "../../../helpers/canTrack.qwik.mjs";
15
+ import { getCookieSync } from "../../../helpers/cookie.qwik.mjs";
15
16
  import { createEditorListener } from "../../../helpers/subscribe-to-editor.qwik.mjs";
16
17
  import { registerInsertMenu, setupBrowserForEditing } from "../../../scripts/init-editing.qwik.mjs";
17
18
  import { triggerAnimation } from "../../block/animator.qwik.mjs";
@@ -67,6 +68,9 @@ const processMessage = function processMessage2(props, state, showContentProps,
67
68
  },
68
69
  contentUpdate: (newContent) => {
69
70
  mergeNewContent(props, state, showContentProps, elementRef, newContent);
71
+ },
72
+ stateUpdate: (newState) => {
73
+ mergeNewRootState(props, state, showContentProps, elementRef, newState);
70
74
  }
71
75
  }
72
76
  })(event);
@@ -148,6 +152,7 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
148
152
  const state = useStore({
149
153
  ContentWrapper: props.contentWrapper || "div",
150
154
  clicked: false,
155
+ hasExecuted: false,
151
156
  httpReqsData: {},
152
157
  httpReqsPending: {}
153
158
  }, {
@@ -212,25 +217,32 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
212
217
  state
213
218
  ]));
214
219
  useOnDocument("readystatechange", /* @__PURE__ */ inlinedQrl((event, element) => {
215
- var _a2, _b2, _c, _d;
216
- const [props2] = useLexicalScope();
220
+ var _a2, _b2, _c, _d, _e;
221
+ const [props2, state2] = useLexicalScope();
222
+ if (state2.hasExecuted)
223
+ return;
217
224
  if (isBrowser()) {
225
+ state2.hasExecuted = true;
218
226
  if (isEditing() && !props2.isNestedRender) {
219
227
  if (element)
220
228
  element.dispatchEvent(new CustomEvent("initeditingbldr"));
221
229
  }
222
230
  const shouldTrackImpression = ((_a2 = element.attributes.getNamedItem("shouldTrack")) == null ? void 0 : _a2.value) === "true";
223
- if (shouldTrackImpression) {
224
- const variationId = (_b2 = element.attributes.getNamedItem("variationId")) == null ? void 0 : _b2.value;
225
- const contentId = (_c = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c.value;
226
- const apiKeyProp = (_d = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d.value;
231
+ const winningVariantId = getCookieSync({
232
+ name: `builder.tests.${(_b2 = props2.builderContextSignal.content) == null ? void 0 : _b2.id}`,
233
+ canTrack: true
234
+ });
235
+ const variationId = (_c = element.attributes.getNamedItem("variationId")) == null ? void 0 : _c.value;
236
+ if (shouldTrackImpression && variationId === winningVariantId) {
237
+ const contentId = (_d = element.attributes.getNamedItem("contentId")) == null ? void 0 : _d.value;
238
+ const apiKeyProp = (_e = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _e.value;
227
239
  _track({
228
240
  apiHost: props2.apiHost,
229
241
  type: "impression",
230
242
  canTrack: true,
231
243
  contentId,
232
244
  apiKey: apiKeyProp,
233
- variationId: variationId !== contentId ? variationId : void 0
245
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
234
246
  });
235
247
  }
236
248
  if (isPreviewing() && !isEditing()) {
@@ -239,7 +251,8 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
239
251
  }
240
252
  }
241
253
  }, "EnableEditor_component_useOnDocument_H7syEGJXM4Y", [
242
- props
254
+ props,
255
+ state
243
256
  ]));
244
257
  useContextProvider(builderContext, props.builderContextSignal);
245
258
  useTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.18.0";
3
+ const SDK_VERSION = "0.18.2";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.18.0";
1
+ const SDK_VERSION = "0.18.2";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -17,6 +17,14 @@ const createEditorListener = ({ model, trustedHosts, callbacks }) => {
17
17
  case "builder.triggerAnimation":
18
18
  callbacks.animation(data.data);
19
19
  break;
20
+ case "builder.resetState": {
21
+ const messageContent = data.data;
22
+ const modelName = messageContent.model;
23
+ const newState = messageContent == null ? void 0 : messageContent.state;
24
+ if (modelName === model && newState)
25
+ callbacks.stateUpdate(newState);
26
+ break;
27
+ }
20
28
  case "builder.contentUpdate": {
21
29
  const messageContent = data.data;
22
30
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -44,6 +52,8 @@ const subscribeToEditor = ({ model, apiKey, callback, trustedHosts }) => {
44
52
  animation: () => {
45
53
  },
46
54
  configureSdk: () => {
55
+ },
56
+ stateUpdate: () => {
47
57
  }
48
58
  },
49
59
  model,
@@ -15,6 +15,14 @@ const createEditorListener = ({ model, trustedHosts, callbacks }) => {
15
15
  case "builder.triggerAnimation":
16
16
  callbacks.animation(data.data);
17
17
  break;
18
+ case "builder.resetState": {
19
+ const messageContent = data.data;
20
+ const modelName = messageContent.model;
21
+ const newState = messageContent == null ? void 0 : messageContent.state;
22
+ if (modelName === model && newState)
23
+ callbacks.stateUpdate(newState);
24
+ break;
25
+ }
18
26
  case "builder.contentUpdate": {
19
27
  const messageContent = data.data;
20
28
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -42,6 +50,8 @@ const subscribeToEditor = ({ model, apiKey, callback, trustedHosts }) => {
42
50
  animation: () => {
43
51
  },
44
52
  configureSdk: () => {
53
+ },
54
+ stateUpdate: () => {
45
55
  }
46
56
  },
47
57
  model,
@@ -14,6 +14,7 @@ const registerComponent = require("../../../functions/register-component.qwik.cj
14
14
  const index$1 = require("../../../functions/track/index.qwik.cjs");
15
15
  const interaction = require("../../../functions/track/interaction.qwik.cjs");
16
16
  const canTrack = require("../../../helpers/canTrack.qwik.cjs");
17
+ const cookie = require("../../../helpers/cookie.qwik.cjs");
17
18
  const subscribeToEditor = require("../../../helpers/subscribe-to-editor.qwik.cjs");
18
19
  const initEditing = require("../../../scripts/init-editing.qwik.cjs");
19
20
  const animator = require("../../block/animator.qwik.cjs");
@@ -69,6 +70,9 @@ const processMessage = function processMessage2(props, state, showContentProps,
69
70
  },
70
71
  contentUpdate: (newContent) => {
71
72
  mergeNewContent(props, state, showContentProps, elementRef, newContent);
73
+ },
74
+ stateUpdate: (newState) => {
75
+ mergeNewRootState(props, state, showContentProps, elementRef, newState);
72
76
  }
73
77
  }
74
78
  })(event);
@@ -150,6 +154,7 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
150
154
  const state = qwik.useStore({
151
155
  ContentWrapper: props.contentWrapper || "div",
152
156
  clicked: false,
157
+ hasExecuted: false,
153
158
  httpReqsData: {},
154
159
  httpReqsPending: {}
155
160
  }, {
@@ -214,25 +219,32 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
214
219
  state
215
220
  ]));
216
221
  qwik.useOnDocument("readystatechange", /* @__PURE__ */ qwik.inlinedQrl((event, element) => {
217
- var _a2, _b2, _c, _d;
218
- const [props2] = qwik.useLexicalScope();
222
+ var _a2, _b2, _c, _d, _e;
223
+ const [props2, state2] = qwik.useLexicalScope();
224
+ if (state2.hasExecuted)
225
+ return;
219
226
  if (isBrowser.isBrowser()) {
227
+ state2.hasExecuted = true;
220
228
  if (isEditing.isEditing() && !props2.isNestedRender) {
221
229
  if (element)
222
230
  element.dispatchEvent(new CustomEvent("initeditingbldr"));
223
231
  }
224
232
  const shouldTrackImpression = ((_a2 = element.attributes.getNamedItem("shouldTrack")) == null ? void 0 : _a2.value) === "true";
225
- if (shouldTrackImpression) {
226
- const variationId = (_b2 = element.attributes.getNamedItem("variationId")) == null ? void 0 : _b2.value;
227
- const contentId = (_c = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c.value;
228
- const apiKeyProp = (_d = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d.value;
233
+ const winningVariantId = cookie.getCookieSync({
234
+ name: `builder.tests.${(_b2 = props2.builderContextSignal.content) == null ? void 0 : _b2.id}`,
235
+ canTrack: true
236
+ });
237
+ const variationId = (_c = element.attributes.getNamedItem("variationId")) == null ? void 0 : _c.value;
238
+ if (shouldTrackImpression && variationId === winningVariantId) {
239
+ const contentId = (_d = element.attributes.getNamedItem("contentId")) == null ? void 0 : _d.value;
240
+ const apiKeyProp = (_e = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _e.value;
229
241
  index$1._track({
230
242
  apiHost: props2.apiHost,
231
243
  type: "impression",
232
244
  canTrack: true,
233
245
  contentId,
234
246
  apiKey: apiKeyProp,
235
- variationId: variationId !== contentId ? variationId : void 0
247
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
236
248
  });
237
249
  }
238
250
  if (isPreviewing.isPreviewing() && !isEditing.isEditing()) {
@@ -241,7 +253,8 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
241
253
  }
242
254
  }
243
255
  }, "EnableEditor_component_useOnDocument_H7syEGJXM4Y", [
244
- props
256
+ props,
257
+ state
245
258
  ]));
246
259
  qwik.useContextProvider(builder_context, props.builderContextSignal);
247
260
  qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
@@ -12,6 +12,7 @@ import { createRegisterComponentMessage } from "../../../functions/register-comp
12
12
  import { _track } from "../../../functions/track/index.qwik.mjs";
13
13
  import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.qwik.mjs";
14
14
  import { getDefaultCanTrack } from "../../../helpers/canTrack.qwik.mjs";
15
+ import { getCookieSync } from "../../../helpers/cookie.qwik.mjs";
15
16
  import { createEditorListener } from "../../../helpers/subscribe-to-editor.qwik.mjs";
16
17
  import { registerInsertMenu, setupBrowserForEditing } from "../../../scripts/init-editing.qwik.mjs";
17
18
  import { triggerAnimation } from "../../block/animator.qwik.mjs";
@@ -67,6 +68,9 @@ const processMessage = function processMessage2(props, state, showContentProps,
67
68
  },
68
69
  contentUpdate: (newContent) => {
69
70
  mergeNewContent(props, state, showContentProps, elementRef, newContent);
71
+ },
72
+ stateUpdate: (newState) => {
73
+ mergeNewRootState(props, state, showContentProps, elementRef, newState);
70
74
  }
71
75
  }
72
76
  })(event);
@@ -148,6 +152,7 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
148
152
  const state = useStore({
149
153
  ContentWrapper: props.contentWrapper || "div",
150
154
  clicked: false,
155
+ hasExecuted: false,
151
156
  httpReqsData: {},
152
157
  httpReqsPending: {}
153
158
  }, {
@@ -212,25 +217,32 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
212
217
  state
213
218
  ]));
214
219
  useOnDocument("readystatechange", /* @__PURE__ */ inlinedQrl((event, element) => {
215
- var _a2, _b2, _c, _d;
216
- const [props2] = useLexicalScope();
220
+ var _a2, _b2, _c, _d, _e;
221
+ const [props2, state2] = useLexicalScope();
222
+ if (state2.hasExecuted)
223
+ return;
217
224
  if (isBrowser()) {
225
+ state2.hasExecuted = true;
218
226
  if (isEditing() && !props2.isNestedRender) {
219
227
  if (element)
220
228
  element.dispatchEvent(new CustomEvent("initeditingbldr"));
221
229
  }
222
230
  const shouldTrackImpression = ((_a2 = element.attributes.getNamedItem("shouldTrack")) == null ? void 0 : _a2.value) === "true";
223
- if (shouldTrackImpression) {
224
- const variationId = (_b2 = element.attributes.getNamedItem("variationId")) == null ? void 0 : _b2.value;
225
- const contentId = (_c = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c.value;
226
- const apiKeyProp = (_d = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d.value;
231
+ const winningVariantId = getCookieSync({
232
+ name: `builder.tests.${(_b2 = props2.builderContextSignal.content) == null ? void 0 : _b2.id}`,
233
+ canTrack: true
234
+ });
235
+ const variationId = (_c = element.attributes.getNamedItem("variationId")) == null ? void 0 : _c.value;
236
+ if (shouldTrackImpression && variationId === winningVariantId) {
237
+ const contentId = (_d = element.attributes.getNamedItem("contentId")) == null ? void 0 : _d.value;
238
+ const apiKeyProp = (_e = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _e.value;
227
239
  _track({
228
240
  apiHost: props2.apiHost,
229
241
  type: "impression",
230
242
  canTrack: true,
231
243
  contentId,
232
244
  apiKey: apiKeyProp,
233
- variationId: variationId !== contentId ? variationId : void 0
245
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
234
246
  });
235
247
  }
236
248
  if (isPreviewing() && !isEditing()) {
@@ -239,7 +251,8 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
239
251
  }
240
252
  }
241
253
  }, "EnableEditor_component_useOnDocument_H7syEGJXM4Y", [
242
- props
254
+ props,
255
+ state
243
256
  ]));
244
257
  useContextProvider(builderContext, props.builderContextSignal);
245
258
  useTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.18.0";
3
+ const SDK_VERSION = "0.18.2";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.18.0";
1
+ const SDK_VERSION = "0.18.2";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -17,6 +17,14 @@ const createEditorListener = ({ model, trustedHosts, callbacks }) => {
17
17
  case "builder.triggerAnimation":
18
18
  callbacks.animation(data.data);
19
19
  break;
20
+ case "builder.resetState": {
21
+ const messageContent = data.data;
22
+ const modelName = messageContent.model;
23
+ const newState = messageContent == null ? void 0 : messageContent.state;
24
+ if (modelName === model && newState)
25
+ callbacks.stateUpdate(newState);
26
+ break;
27
+ }
20
28
  case "builder.contentUpdate": {
21
29
  const messageContent = data.data;
22
30
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -44,6 +52,8 @@ const subscribeToEditor = ({ model, apiKey, callback, trustedHosts }) => {
44
52
  animation: () => {
45
53
  },
46
54
  configureSdk: () => {
55
+ },
56
+ stateUpdate: () => {
47
57
  }
48
58
  },
49
59
  model,
@@ -15,6 +15,14 @@ const createEditorListener = ({ model, trustedHosts, callbacks }) => {
15
15
  case "builder.triggerAnimation":
16
16
  callbacks.animation(data.data);
17
17
  break;
18
+ case "builder.resetState": {
19
+ const messageContent = data.data;
20
+ const modelName = messageContent.model;
21
+ const newState = messageContent == null ? void 0 : messageContent.state;
22
+ if (modelName === model && newState)
23
+ callbacks.stateUpdate(newState);
24
+ break;
25
+ }
18
26
  case "builder.contentUpdate": {
19
27
  const messageContent = data.data;
20
28
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -42,6 +50,8 @@ const subscribeToEditor = ({ model, apiKey, callback, trustedHosts }) => {
42
50
  animation: () => {
43
51
  },
44
52
  configureSdk: () => {
53
+ },
54
+ stateUpdate: () => {
45
55
  }
46
56
  },
47
57
  model,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/qwik",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.18.0";
1
+ export declare const SDK_VERSION = "0.18.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
  };