@builder.io/sdk-qwik 0.23.2 → 0.24.1

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.
Files changed (37) hide show
  1. package/lib/browser/components/block/components/block-wrapper.qwik.cjs +8 -1
  2. package/lib/browser/components/block/components/block-wrapper.qwik.mjs +8 -1
  3. package/lib/browser/components/block/components/interactive-element.qwik.cjs +8 -1
  4. package/lib/browser/components/block/components/interactive-element.qwik.mjs +8 -1
  5. package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
  6. package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
  7. package/lib/browser/functions/evaluate/evaluate.qwik.cjs +2 -2
  8. package/lib/browser/functions/evaluate/evaluate.qwik.mjs +2 -2
  9. package/lib/browser/functions/evaluate/helpers.qwik.cjs +20 -2
  10. package/lib/browser/functions/evaluate/helpers.qwik.mjs +20 -2
  11. package/lib/edge/components/block/components/block-wrapper.qwik.cjs +8 -1
  12. package/lib/edge/components/block/components/block-wrapper.qwik.mjs +8 -1
  13. package/lib/edge/components/block/components/interactive-element.qwik.cjs +8 -1
  14. package/lib/edge/components/block/components/interactive-element.qwik.mjs +8 -1
  15. package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
  16. package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
  17. package/lib/edge/functions/evaluate/evaluate.qwik.cjs +2 -2
  18. package/lib/edge/functions/evaluate/evaluate.qwik.mjs +2 -2
  19. package/lib/edge/functions/evaluate/helpers.qwik.cjs +20 -2
  20. package/lib/edge/functions/evaluate/helpers.qwik.mjs +20 -2
  21. package/lib/node/components/block/components/block-wrapper.qwik.cjs +8 -1
  22. package/lib/node/components/block/components/block-wrapper.qwik.mjs +8 -1
  23. package/lib/node/components/block/components/interactive-element.qwik.cjs +8 -1
  24. package/lib/node/components/block/components/interactive-element.qwik.mjs +8 -1
  25. package/lib/node/constants/sdk-version.qwik.cjs +1 -1
  26. package/lib/node/constants/sdk-version.qwik.mjs +1 -1
  27. package/lib/node/functions/evaluate/evaluate.qwik.cjs +2 -2
  28. package/lib/node/functions/evaluate/evaluate.qwik.mjs +2 -2
  29. package/lib/node/functions/evaluate/helpers.qwik.cjs +20 -2
  30. package/lib/node/functions/evaluate/helpers.qwik.mjs +20 -2
  31. package/lib/node/functions/evaluate/node-runtime/node-runtime.qwik.cjs +56 -58
  32. package/lib/node/functions/evaluate/node-runtime/node-runtime.qwik.mjs +56 -58
  33. package/package.json +1 -1
  34. package/types/src/constants/sdk-version.d.ts +1 -1
  35. package/types/src/functions/evaluate/evaluate.d.ts +1 -1
  36. package/types/src/functions/evaluate/helpers.d.ts +9 -1
  37. package/types/src/functions/get-block-actions.d.ts +2 -0
@@ -5,6 +5,7 @@ const getBlockActions = require("../../../functions/get-block-actions.qwik.cjs")
5
5
  const getBlockProperties = require("../../../functions/get-block-properties.qwik.cjs");
6
6
  const dynamicRenderer = require("../../dynamic-renderer/dynamic-renderer.qwik.cjs");
7
7
  const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
8
+ var _a, _b;
8
9
  return /* @__PURE__ */ qwik._jsxC(dynamicRenderer.DynamicRenderer, {
9
10
  get TagName() {
10
11
  return props.Wrapper;
@@ -15,7 +16,13 @@ const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
15
16
  rootSetState: props.context.rootSetState,
16
17
  localState: props.context.localState,
17
18
  context: props.context.context,
18
- stripPrefix: true
19
+ stripPrefix: true,
20
+ trackingContext: {
21
+ apiKey: props.context.apiKey,
22
+ canTrack: props.context.canTrack ?? true,
23
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
24
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
25
+ }
19
26
  }),
20
27
  attributes: getBlockProperties.getBlockProperties({
21
28
  block: props.block,
@@ -3,6 +3,7 @@ import { getBlockActions } from "../../../functions/get-block-actions.qwik.mjs";
3
3
  import { getBlockProperties } from "../../../functions/get-block-properties.qwik.mjs";
4
4
  import { DynamicRenderer } from "../../dynamic-renderer/dynamic-renderer.qwik.mjs";
5
5
  const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
6
+ var _a, _b;
6
7
  return /* @__PURE__ */ _jsxC(DynamicRenderer, {
7
8
  get TagName() {
8
9
  return props.Wrapper;
@@ -13,7 +14,13 @@ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
13
14
  rootSetState: props.context.rootSetState,
14
15
  localState: props.context.localState,
15
16
  context: props.context.context,
16
- stripPrefix: true
17
+ stripPrefix: true,
18
+ trackingContext: {
19
+ apiKey: props.context.apiKey,
20
+ canTrack: props.context.canTrack ?? true,
21
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
22
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
23
+ }
17
24
  }),
18
25
  attributes: getBlockProperties({
19
26
  block: props.block,
@@ -11,6 +11,7 @@ require("../../../context/builder.context.qwik.cjs");
11
11
  const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
12
12
  qwik._jsxBranch();
13
13
  const attributes = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
14
+ var _a, _b;
14
15
  const [props2] = qwik.useLexicalScope();
15
16
  return props2.includeBlockProps ? {
16
17
  ...getBlockProperties.getBlockProperties({
@@ -22,7 +23,13 @@ const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwi
22
23
  rootState: props2.context.rootState,
23
24
  rootSetState: props2.context.rootSetState,
24
25
  localState: props2.context.localState,
25
- context: props2.context.context
26
+ context: props2.context.context,
27
+ trackingContext: {
28
+ apiKey: props2.context.apiKey,
29
+ canTrack: props2.context.canTrack ?? true,
30
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
31
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
32
+ }
26
33
  })
27
34
  } : {};
28
35
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -9,6 +9,7 @@ import "../../../context/builder.context.qwik.mjs";
9
9
  const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10
10
  _jsxBranch();
11
11
  const attributes = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
12
+ var _a, _b;
12
13
  const [props2] = useLexicalScope();
13
14
  return props2.includeBlockProps ? {
14
15
  ...getBlockProperties({
@@ -20,7 +21,13 @@ const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQ
20
21
  rootState: props2.context.rootState,
21
22
  rootSetState: props2.context.rootSetState,
22
23
  localState: props2.context.localState,
23
- context: props2.context.context
24
+ context: props2.context.context,
25
+ trackingContext: {
26
+ apiKey: props2.context.apiKey,
27
+ canTrack: props2.context.canTrack ?? true,
28
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
29
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
30
+ }
24
31
  })
25
32
  } : {};
26
33
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.23.2";
3
+ const SDK_VERSION = "0.24.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.23.2";
1
+ const SDK_VERSION = "0.24.1";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -10,7 +10,7 @@ const getSimpleExpressionGetPath = (code) => {
10
10
  var _a, _b, _c, _d, _e, _f;
11
11
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
12
12
  };
13
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
13
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
14
14
  if (code.trim() === "")
15
15
  return void 0;
16
16
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -23,7 +23,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
23
23
  code: helpers.parseCode(code, {
24
24
  isExpression
25
25
  }),
26
- builder: helpers.getBuilderGlobals(),
26
+ builder: helpers.getBuilderGlobals(trackingContext),
27
27
  context,
28
28
  event,
29
29
  rootSetState,
@@ -8,7 +8,7 @@ const getSimpleExpressionGetPath = (code) => {
8
8
  var _a, _b, _c, _d, _e, _f;
9
9
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
10
10
  };
11
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
11
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
12
12
  if (code.trim() === "")
13
13
  return void 0;
14
14
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -21,7 +21,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
21
21
  code: parseCode(code, {
22
22
  isExpression
23
23
  }),
24
- builder: getBuilderGlobals(),
24
+ builder: getBuilderGlobals(trackingContext),
25
25
  context,
26
26
  event,
27
27
  rootSetState,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const isBrowser = require("../is-browser.qwik.cjs");
4
4
  const isEditing = require("../is-editing.qwik.cjs");
5
5
  const helpers = require("../track/helpers.qwik.cjs");
6
+ const index = require("../track/index.qwik.cjs");
6
7
  const getFunctionArguments = ({ builder, context, event, state }) => {
7
8
  return Object.entries({
8
9
  state,
@@ -13,11 +14,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
13
14
  event
14
15
  });
15
16
  };
16
- const getBuilderGlobals = () => ({
17
+ const getBuilderGlobals = (trackingContext) => ({
17
18
  isEditing: isEditing.isEditing(),
18
19
  isBrowser: isBrowser.isBrowser(),
19
20
  isServer: !isBrowser.isBrowser(),
20
- getUserAttributes: () => helpers.getUserAttributes()
21
+ getUserAttributes: () => helpers.getUserAttributes(),
22
+ trackConversion: (amount, customProperties) => {
23
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
24
+ return;
25
+ index._track({
26
+ type: "conversion",
27
+ apiKey: trackingContext.apiKey,
28
+ canTrack: trackingContext.canTrack ?? true,
29
+ contentId: trackingContext.contentId,
30
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
31
+ metadata: {
32
+ ...customProperties || {},
33
+ ...amount !== void 0 ? {
34
+ amount
35
+ } : {}
36
+ }
37
+ });
38
+ }
21
39
  });
22
40
  const parseCode = (code, { isExpression = true }) => {
23
41
  const useReturn = (
@@ -1,6 +1,7 @@
1
1
  import { isBrowser } from "../is-browser.qwik.mjs";
2
2
  import { isEditing } from "../is-editing.qwik.mjs";
3
3
  import { getUserAttributes } from "../track/helpers.qwik.mjs";
4
+ import { _track } from "../track/index.qwik.mjs";
4
5
  const getFunctionArguments = ({ builder, context, event, state }) => {
5
6
  return Object.entries({
6
7
  state,
@@ -11,11 +12,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
11
12
  event
12
13
  });
13
14
  };
14
- const getBuilderGlobals = () => ({
15
+ const getBuilderGlobals = (trackingContext) => ({
15
16
  isEditing: isEditing(),
16
17
  isBrowser: isBrowser(),
17
18
  isServer: !isBrowser(),
18
- getUserAttributes: () => getUserAttributes()
19
+ getUserAttributes: () => getUserAttributes(),
20
+ trackConversion: (amount, customProperties) => {
21
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
22
+ return;
23
+ _track({
24
+ type: "conversion",
25
+ apiKey: trackingContext.apiKey,
26
+ canTrack: trackingContext.canTrack ?? true,
27
+ contentId: trackingContext.contentId,
28
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
29
+ metadata: {
30
+ ...customProperties || {},
31
+ ...amount !== void 0 ? {
32
+ amount
33
+ } : {}
34
+ }
35
+ });
36
+ }
19
37
  });
20
38
  const parseCode = (code, { isExpression = true }) => {
21
39
  const useReturn = (
@@ -5,6 +5,7 @@ const getBlockActions = require("../../../functions/get-block-actions.qwik.cjs")
5
5
  const getBlockProperties = require("../../../functions/get-block-properties.qwik.cjs");
6
6
  const dynamicRenderer = require("../../dynamic-renderer/dynamic-renderer.qwik.cjs");
7
7
  const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
8
+ var _a, _b;
8
9
  return /* @__PURE__ */ qwik._jsxC(dynamicRenderer.DynamicRenderer, {
9
10
  get TagName() {
10
11
  return props.Wrapper;
@@ -15,7 +16,13 @@ const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
15
16
  rootSetState: props.context.rootSetState,
16
17
  localState: props.context.localState,
17
18
  context: props.context.context,
18
- stripPrefix: true
19
+ stripPrefix: true,
20
+ trackingContext: {
21
+ apiKey: props.context.apiKey,
22
+ canTrack: props.context.canTrack ?? true,
23
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
24
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
25
+ }
19
26
  }),
20
27
  attributes: getBlockProperties.getBlockProperties({
21
28
  block: props.block,
@@ -3,6 +3,7 @@ import { getBlockActions } from "../../../functions/get-block-actions.qwik.mjs";
3
3
  import { getBlockProperties } from "../../../functions/get-block-properties.qwik.mjs";
4
4
  import { DynamicRenderer } from "../../dynamic-renderer/dynamic-renderer.qwik.mjs";
5
5
  const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
6
+ var _a, _b;
6
7
  return /* @__PURE__ */ _jsxC(DynamicRenderer, {
7
8
  get TagName() {
8
9
  return props.Wrapper;
@@ -13,7 +14,13 @@ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
13
14
  rootSetState: props.context.rootSetState,
14
15
  localState: props.context.localState,
15
16
  context: props.context.context,
16
- stripPrefix: true
17
+ stripPrefix: true,
18
+ trackingContext: {
19
+ apiKey: props.context.apiKey,
20
+ canTrack: props.context.canTrack ?? true,
21
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
22
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
23
+ }
17
24
  }),
18
25
  attributes: getBlockProperties({
19
26
  block: props.block,
@@ -11,6 +11,7 @@ require("../../../context/builder.context.qwik.cjs");
11
11
  const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
12
12
  qwik._jsxBranch();
13
13
  const attributes = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
14
+ var _a, _b;
14
15
  const [props2] = qwik.useLexicalScope();
15
16
  return props2.includeBlockProps ? {
16
17
  ...getBlockProperties.getBlockProperties({
@@ -22,7 +23,13 @@ const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwi
22
23
  rootState: props2.context.rootState,
23
24
  rootSetState: props2.context.rootSetState,
24
25
  localState: props2.context.localState,
25
- context: props2.context.context
26
+ context: props2.context.context,
27
+ trackingContext: {
28
+ apiKey: props2.context.apiKey,
29
+ canTrack: props2.context.canTrack ?? true,
30
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
31
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
32
+ }
26
33
  })
27
34
  } : {};
28
35
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -9,6 +9,7 @@ import "../../../context/builder.context.qwik.mjs";
9
9
  const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10
10
  _jsxBranch();
11
11
  const attributes = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
12
+ var _a, _b;
12
13
  const [props2] = useLexicalScope();
13
14
  return props2.includeBlockProps ? {
14
15
  ...getBlockProperties({
@@ -20,7 +21,13 @@ const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQ
20
21
  rootState: props2.context.rootState,
21
22
  rootSetState: props2.context.rootSetState,
22
23
  localState: props2.context.localState,
23
- context: props2.context.context
24
+ context: props2.context.context,
25
+ trackingContext: {
26
+ apiKey: props2.context.apiKey,
27
+ canTrack: props2.context.canTrack ?? true,
28
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
29
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
30
+ }
24
31
  })
25
32
  } : {};
26
33
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.23.2";
3
+ const SDK_VERSION = "0.24.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.23.2";
1
+ const SDK_VERSION = "0.24.1";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -10,7 +10,7 @@ const getSimpleExpressionGetPath = (code) => {
10
10
  var _a, _b, _c, _d, _e, _f;
11
11
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
12
12
  };
13
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
13
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
14
14
  if (code.trim() === "")
15
15
  return void 0;
16
16
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -23,7 +23,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
23
23
  code: helpers.parseCode(code, {
24
24
  isExpression
25
25
  }),
26
- builder: helpers.getBuilderGlobals(),
26
+ builder: helpers.getBuilderGlobals(trackingContext),
27
27
  context,
28
28
  event,
29
29
  rootSetState,
@@ -8,7 +8,7 @@ const getSimpleExpressionGetPath = (code) => {
8
8
  var _a, _b, _c, _d, _e, _f;
9
9
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
10
10
  };
11
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
11
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
12
12
  if (code.trim() === "")
13
13
  return void 0;
14
14
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -21,7 +21,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
21
21
  code: parseCode(code, {
22
22
  isExpression
23
23
  }),
24
- builder: getBuilderGlobals(),
24
+ builder: getBuilderGlobals(trackingContext),
25
25
  context,
26
26
  event,
27
27
  rootSetState,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const isBrowser = require("../is-browser.qwik.cjs");
4
4
  const isEditing = require("../is-editing.qwik.cjs");
5
5
  const helpers = require("../track/helpers.qwik.cjs");
6
+ const index = require("../track/index.qwik.cjs");
6
7
  const getFunctionArguments = ({ builder, context, event, state }) => {
7
8
  return Object.entries({
8
9
  state,
@@ -13,11 +14,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
13
14
  event
14
15
  });
15
16
  };
16
- const getBuilderGlobals = () => ({
17
+ const getBuilderGlobals = (trackingContext) => ({
17
18
  isEditing: isEditing.isEditing(),
18
19
  isBrowser: isBrowser.isBrowser(),
19
20
  isServer: !isBrowser.isBrowser(),
20
- getUserAttributes: () => helpers.getUserAttributes()
21
+ getUserAttributes: () => helpers.getUserAttributes(),
22
+ trackConversion: (amount, customProperties) => {
23
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
24
+ return;
25
+ index._track({
26
+ type: "conversion",
27
+ apiKey: trackingContext.apiKey,
28
+ canTrack: trackingContext.canTrack ?? true,
29
+ contentId: trackingContext.contentId,
30
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
31
+ metadata: {
32
+ ...customProperties || {},
33
+ ...amount !== void 0 ? {
34
+ amount
35
+ } : {}
36
+ }
37
+ });
38
+ }
21
39
  });
22
40
  const parseCode = (code, { isExpression = true }) => {
23
41
  const useReturn = (
@@ -1,6 +1,7 @@
1
1
  import { isBrowser } from "../is-browser.qwik.mjs";
2
2
  import { isEditing } from "../is-editing.qwik.mjs";
3
3
  import { getUserAttributes } from "../track/helpers.qwik.mjs";
4
+ import { _track } from "../track/index.qwik.mjs";
4
5
  const getFunctionArguments = ({ builder, context, event, state }) => {
5
6
  return Object.entries({
6
7
  state,
@@ -11,11 +12,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
11
12
  event
12
13
  });
13
14
  };
14
- const getBuilderGlobals = () => ({
15
+ const getBuilderGlobals = (trackingContext) => ({
15
16
  isEditing: isEditing(),
16
17
  isBrowser: isBrowser(),
17
18
  isServer: !isBrowser(),
18
- getUserAttributes: () => getUserAttributes()
19
+ getUserAttributes: () => getUserAttributes(),
20
+ trackConversion: (amount, customProperties) => {
21
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
22
+ return;
23
+ _track({
24
+ type: "conversion",
25
+ apiKey: trackingContext.apiKey,
26
+ canTrack: trackingContext.canTrack ?? true,
27
+ contentId: trackingContext.contentId,
28
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
29
+ metadata: {
30
+ ...customProperties || {},
31
+ ...amount !== void 0 ? {
32
+ amount
33
+ } : {}
34
+ }
35
+ });
36
+ }
19
37
  });
20
38
  const parseCode = (code, { isExpression = true }) => {
21
39
  const useReturn = (
@@ -5,6 +5,7 @@ const getBlockActions = require("../../../functions/get-block-actions.qwik.cjs")
5
5
  const getBlockProperties = require("../../../functions/get-block-properties.qwik.cjs");
6
6
  const dynamicRenderer = require("../../dynamic-renderer/dynamic-renderer.qwik.cjs");
7
7
  const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
8
+ var _a, _b;
8
9
  return /* @__PURE__ */ qwik._jsxC(dynamicRenderer.DynamicRenderer, {
9
10
  get TagName() {
10
11
  return props.Wrapper;
@@ -15,7 +16,13 @@ const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
15
16
  rootSetState: props.context.rootSetState,
16
17
  localState: props.context.localState,
17
18
  context: props.context.context,
18
- stripPrefix: true
19
+ stripPrefix: true,
20
+ trackingContext: {
21
+ apiKey: props.context.apiKey,
22
+ canTrack: props.context.canTrack ?? true,
23
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
24
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
25
+ }
19
26
  }),
20
27
  attributes: getBlockProperties.getBlockProperties({
21
28
  block: props.block,
@@ -3,6 +3,7 @@ import { getBlockActions } from "../../../functions/get-block-actions.qwik.mjs";
3
3
  import { getBlockProperties } from "../../../functions/get-block-properties.qwik.mjs";
4
4
  import { DynamicRenderer } from "../../dynamic-renderer/dynamic-renderer.qwik.mjs";
5
5
  const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
6
+ var _a, _b;
6
7
  return /* @__PURE__ */ _jsxC(DynamicRenderer, {
7
8
  get TagName() {
8
9
  return props.Wrapper;
@@ -13,7 +14,13 @@ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
13
14
  rootSetState: props.context.rootSetState,
14
15
  localState: props.context.localState,
15
16
  context: props.context.context,
16
- stripPrefix: true
17
+ stripPrefix: true,
18
+ trackingContext: {
19
+ apiKey: props.context.apiKey,
20
+ canTrack: props.context.canTrack ?? true,
21
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
22
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
23
+ }
17
24
  }),
18
25
  attributes: getBlockProperties({
19
26
  block: props.block,
@@ -11,6 +11,7 @@ require("../../../context/builder.context.qwik.cjs");
11
11
  const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
12
12
  qwik._jsxBranch();
13
13
  const attributes = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
14
+ var _a, _b;
14
15
  const [props2] = qwik.useLexicalScope();
15
16
  return props2.includeBlockProps ? {
16
17
  ...getBlockProperties.getBlockProperties({
@@ -22,7 +23,13 @@ const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwi
22
23
  rootState: props2.context.rootState,
23
24
  rootSetState: props2.context.rootSetState,
24
25
  localState: props2.context.localState,
25
- context: props2.context.context
26
+ context: props2.context.context,
27
+ trackingContext: {
28
+ apiKey: props2.context.apiKey,
29
+ canTrack: props2.context.canTrack ?? true,
30
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
31
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
32
+ }
26
33
  })
27
34
  } : {};
28
35
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -9,6 +9,7 @@ import "../../../context/builder.context.qwik.mjs";
9
9
  const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10
10
  _jsxBranch();
11
11
  const attributes = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
12
+ var _a, _b;
12
13
  const [props2] = useLexicalScope();
13
14
  return props2.includeBlockProps ? {
14
15
  ...getBlockProperties({
@@ -20,7 +21,13 @@ const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQ
20
21
  rootState: props2.context.rootState,
21
22
  rootSetState: props2.context.rootSetState,
22
23
  localState: props2.context.localState,
23
- context: props2.context.context
24
+ context: props2.context.context,
25
+ trackingContext: {
26
+ apiKey: props2.context.apiKey,
27
+ canTrack: props2.context.canTrack ?? true,
28
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
29
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
30
+ }
24
31
  })
25
32
  } : {};
26
33
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.23.2";
3
+ const SDK_VERSION = "0.24.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.23.2";
1
+ const SDK_VERSION = "0.24.1";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -10,7 +10,7 @@ const getSimpleExpressionGetPath = (code) => {
10
10
  var _a, _b, _c, _d, _e, _f;
11
11
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
12
12
  };
13
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
13
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
14
14
  if (code.trim() === "")
15
15
  return void 0;
16
16
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -23,7 +23,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
23
23
  code: helpers.parseCode(code, {
24
24
  isExpression
25
25
  }),
26
- builder: helpers.getBuilderGlobals(),
26
+ builder: helpers.getBuilderGlobals(trackingContext),
27
27
  context,
28
28
  event,
29
29
  rootSetState,
@@ -8,7 +8,7 @@ const getSimpleExpressionGetPath = (code) => {
8
8
  var _a, _b, _c, _d, _e, _f;
9
9
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
10
10
  };
11
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
11
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
12
12
  if (code.trim() === "")
13
13
  return void 0;
14
14
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -21,7 +21,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
21
21
  code: parseCode(code, {
22
22
  isExpression
23
23
  }),
24
- builder: getBuilderGlobals(),
24
+ builder: getBuilderGlobals(trackingContext),
25
25
  context,
26
26
  event,
27
27
  rootSetState,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const isBrowser = require("../is-browser.qwik.cjs");
4
4
  const isEditing = require("../is-editing.qwik.cjs");
5
5
  const helpers = require("../track/helpers.qwik.cjs");
6
+ const index = require("../track/index.qwik.cjs");
6
7
  const getFunctionArguments = ({ builder, context, event, state }) => {
7
8
  return Object.entries({
8
9
  state,
@@ -13,11 +14,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
13
14
  event
14
15
  });
15
16
  };
16
- const getBuilderGlobals = () => ({
17
+ const getBuilderGlobals = (trackingContext) => ({
17
18
  isEditing: isEditing.isEditing(),
18
19
  isBrowser: isBrowser.isBrowser(),
19
20
  isServer: !isBrowser.isBrowser(),
20
- getUserAttributes: () => helpers.getUserAttributes()
21
+ getUserAttributes: () => helpers.getUserAttributes(),
22
+ trackConversion: (amount, customProperties) => {
23
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
24
+ return;
25
+ index._track({
26
+ type: "conversion",
27
+ apiKey: trackingContext.apiKey,
28
+ canTrack: trackingContext.canTrack ?? true,
29
+ contentId: trackingContext.contentId,
30
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
31
+ metadata: {
32
+ ...customProperties || {},
33
+ ...amount !== void 0 ? {
34
+ amount
35
+ } : {}
36
+ }
37
+ });
38
+ }
21
39
  });
22
40
  const parseCode = (code, { isExpression = true }) => {
23
41
  const useReturn = (
@@ -1,6 +1,7 @@
1
1
  import { isBrowser } from "../is-browser.qwik.mjs";
2
2
  import { isEditing } from "../is-editing.qwik.mjs";
3
3
  import { getUserAttributes } from "../track/helpers.qwik.mjs";
4
+ import { _track } from "../track/index.qwik.mjs";
4
5
  const getFunctionArguments = ({ builder, context, event, state }) => {
5
6
  return Object.entries({
6
7
  state,
@@ -11,11 +12,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
11
12
  event
12
13
  });
13
14
  };
14
- const getBuilderGlobals = () => ({
15
+ const getBuilderGlobals = (trackingContext) => ({
15
16
  isEditing: isEditing(),
16
17
  isBrowser: isBrowser(),
17
18
  isServer: !isBrowser(),
18
- getUserAttributes: () => getUserAttributes()
19
+ getUserAttributes: () => getUserAttributes(),
20
+ trackConversion: (amount, customProperties) => {
21
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
22
+ return;
23
+ _track({
24
+ type: "conversion",
25
+ apiKey: trackingContext.apiKey,
26
+ canTrack: trackingContext.canTrack ?? true,
27
+ contentId: trackingContext.contentId,
28
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
29
+ metadata: {
30
+ ...customProperties || {},
31
+ ...amount !== void 0 ? {
32
+ amount
33
+ } : {}
34
+ }
35
+ });
36
+ }
19
37
  });
20
38
  const parseCode = (code, { isExpression = true }) => {
21
39
  const useReturn = (
@@ -55,12 +55,15 @@ if (typeof output === 'object' && output !== null) {
55
55
  `;
56
56
  };
57
57
  let IVM_INSTANCE = null;
58
- let IVM_CONTEXT = null;
59
- const setIvm = (ivm, options = {}) => {
58
+ let IVM_OPTIONS = {
59
+ memoryLimit: 128
60
+ };
61
+ const setIvm = (ivm, options) => {
60
62
  if (IVM_INSTANCE)
61
63
  return;
62
64
  IVM_INSTANCE = ivm;
63
- setIsolateContext(options);
65
+ if (options)
66
+ IVM_OPTIONS = options;
64
67
  };
65
68
  const SHOULD_MENTION_INITIALIZE_SCRIPT = sdkName.SDK_NAME === "@builder.io/sdk-react-nextjs" || sdkName.SDK_NAME === "@builder.io/sdk-react" || sdkName.SDK_NAME === "@builder.io/sdk-qwik" || sdkName.SDK_NAME === "@builder.io/sdk-vue";
66
69
  const getIvm = () => {
@@ -83,64 +86,59 @@ const getIvm = () => {
83
86
  For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
84
87
  throw new Error(ERROR_MESSAGE);
85
88
  };
86
- function setIsolateContext(options = {
87
- memoryLimit: 128
88
- }) {
89
- if (IVM_CONTEXT)
90
- return IVM_CONTEXT;
91
- const ivm = getIvm();
92
- const isolate = new ivm.Isolate(options);
93
- const context = isolate.createContextSync();
94
- const jail = context.global;
95
- jail.setSync("global", jail.derefInto());
96
- jail.setSync("log", function(...logArgs) {
97
- console.log(...logArgs);
98
- });
99
- jail.setSync(INJECTED_IVM_GLOBAL, ivm);
100
- IVM_CONTEXT = context;
101
- return context;
102
- }
103
- const getIsolateContext = () => {
104
- return setIsolateContext();
105
- };
106
89
  const runInNode = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
107
90
  const ivm = getIvm();
108
- const state = fastClone.fastClone({
109
- ...rootState,
110
- ...localState
111
- });
112
- const args = helpers.getFunctionArguments({
113
- builder,
114
- context,
115
- event,
116
- state
117
- });
118
- const isolateContext = getIsolateContext();
119
- const jail = isolateContext.global;
120
- jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
121
- set.set(rootState, key, value);
122
- rootSetState == null ? void 0 : rootSetState(rootState);
123
- });
124
- args.forEach(([key, arg]) => {
125
- const val = typeof arg === "object" ? new ivm.Reference(
126
- // workaround: methods with default values for arguments is not being cloned over
127
- key === "builder" ? {
128
- ...arg,
129
- getUserAttributes: () => arg.getUserAttributes()
130
- } : arg
131
- ) : null;
132
- jail.setSync(getSyncValName(key), val);
133
- });
134
- const evalStr = processCode({
135
- code,
136
- args
137
- });
138
- const resultStr = isolateContext.evalClosureSync(evalStr);
91
+ let isolate;
139
92
  try {
140
- const res = JSON.parse(resultStr);
141
- return res;
142
- } catch (_error) {
143
- return resultStr;
93
+ isolate = new ivm.Isolate(IVM_OPTIONS);
94
+ const isolateContext = isolate.createContextSync();
95
+ const jail = isolateContext.global;
96
+ jail.setSync("global", jail.derefInto());
97
+ jail.setSync("log", function(...logArgs) {
98
+ console.log(...logArgs);
99
+ });
100
+ jail.setSync(INJECTED_IVM_GLOBAL, ivm);
101
+ const state = fastClone.fastClone({
102
+ ...rootState,
103
+ ...localState
104
+ });
105
+ const args = helpers.getFunctionArguments({
106
+ builder,
107
+ context,
108
+ event,
109
+ state
110
+ });
111
+ jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
112
+ set.set(rootState, key, value);
113
+ rootSetState == null ? void 0 : rootSetState(rootState);
114
+ });
115
+ args.forEach(([key, arg]) => {
116
+ const val = typeof arg === "object" ? new ivm.Reference(
117
+ // workaround: methods with default values for arguments is not being cloned over
118
+ key === "builder" ? {
119
+ ...arg,
120
+ getUserAttributes: () => arg.getUserAttributes()
121
+ } : arg
122
+ ) : null;
123
+ jail.setSync(getSyncValName(key), val);
124
+ });
125
+ const evalStr = processCode({
126
+ code,
127
+ args
128
+ });
129
+ const resultStr = isolateContext.evalClosureSync(evalStr);
130
+ try {
131
+ const res = JSON.parse(resultStr);
132
+ return res;
133
+ } catch (_error) {
134
+ return resultStr;
135
+ }
136
+ } finally {
137
+ if (isolate)
138
+ try {
139
+ isolate.dispose();
140
+ } catch (e) {
141
+ }
144
142
  }
145
143
  };
146
144
  exports.runInNode = runInNode;
@@ -53,12 +53,15 @@ if (typeof output === 'object' && output !== null) {
53
53
  `;
54
54
  };
55
55
  let IVM_INSTANCE = null;
56
- let IVM_CONTEXT = null;
57
- const setIvm = (ivm, options = {}) => {
56
+ let IVM_OPTIONS = {
57
+ memoryLimit: 128
58
+ };
59
+ const setIvm = (ivm, options) => {
58
60
  if (IVM_INSTANCE)
59
61
  return;
60
62
  IVM_INSTANCE = ivm;
61
- setIsolateContext(options);
63
+ if (options)
64
+ IVM_OPTIONS = options;
62
65
  };
63
66
  const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react" || SDK_NAME === "@builder.io/sdk-qwik" || SDK_NAME === "@builder.io/sdk-vue";
64
67
  const getIvm = () => {
@@ -81,64 +84,59 @@ const getIvm = () => {
81
84
  For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
82
85
  throw new Error(ERROR_MESSAGE);
83
86
  };
84
- function setIsolateContext(options = {
85
- memoryLimit: 128
86
- }) {
87
- if (IVM_CONTEXT)
88
- return IVM_CONTEXT;
89
- const ivm = getIvm();
90
- const isolate = new ivm.Isolate(options);
91
- const context = isolate.createContextSync();
92
- const jail = context.global;
93
- jail.setSync("global", jail.derefInto());
94
- jail.setSync("log", function(...logArgs) {
95
- console.log(...logArgs);
96
- });
97
- jail.setSync(INJECTED_IVM_GLOBAL, ivm);
98
- IVM_CONTEXT = context;
99
- return context;
100
- }
101
- const getIsolateContext = () => {
102
- return setIsolateContext();
103
- };
104
87
  const runInNode = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
105
88
  const ivm = getIvm();
106
- const state = fastClone({
107
- ...rootState,
108
- ...localState
109
- });
110
- const args = getFunctionArguments({
111
- builder,
112
- context,
113
- event,
114
- state
115
- });
116
- const isolateContext = getIsolateContext();
117
- const jail = isolateContext.global;
118
- jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
119
- set(rootState, key, value);
120
- rootSetState == null ? void 0 : rootSetState(rootState);
121
- });
122
- args.forEach(([key, arg]) => {
123
- const val = typeof arg === "object" ? new ivm.Reference(
124
- // workaround: methods with default values for arguments is not being cloned over
125
- key === "builder" ? {
126
- ...arg,
127
- getUserAttributes: () => arg.getUserAttributes()
128
- } : arg
129
- ) : null;
130
- jail.setSync(getSyncValName(key), val);
131
- });
132
- const evalStr = processCode({
133
- code,
134
- args
135
- });
136
- const resultStr = isolateContext.evalClosureSync(evalStr);
89
+ let isolate;
137
90
  try {
138
- const res = JSON.parse(resultStr);
139
- return res;
140
- } catch (_error) {
141
- return resultStr;
91
+ isolate = new ivm.Isolate(IVM_OPTIONS);
92
+ const isolateContext = isolate.createContextSync();
93
+ const jail = isolateContext.global;
94
+ jail.setSync("global", jail.derefInto());
95
+ jail.setSync("log", function(...logArgs) {
96
+ console.log(...logArgs);
97
+ });
98
+ jail.setSync(INJECTED_IVM_GLOBAL, ivm);
99
+ const state = fastClone({
100
+ ...rootState,
101
+ ...localState
102
+ });
103
+ const args = getFunctionArguments({
104
+ builder,
105
+ context,
106
+ event,
107
+ state
108
+ });
109
+ jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
110
+ set(rootState, key, value);
111
+ rootSetState == null ? void 0 : rootSetState(rootState);
112
+ });
113
+ args.forEach(([key, arg]) => {
114
+ const val = typeof arg === "object" ? new ivm.Reference(
115
+ // workaround: methods with default values for arguments is not being cloned over
116
+ key === "builder" ? {
117
+ ...arg,
118
+ getUserAttributes: () => arg.getUserAttributes()
119
+ } : arg
120
+ ) : null;
121
+ jail.setSync(getSyncValName(key), val);
122
+ });
123
+ const evalStr = processCode({
124
+ code,
125
+ args
126
+ });
127
+ const resultStr = isolateContext.evalClosureSync(evalStr);
128
+ try {
129
+ const res = JSON.parse(resultStr);
130
+ return res;
131
+ } catch (_error) {
132
+ return resultStr;
133
+ }
134
+ } finally {
135
+ if (isolate)
136
+ try {
137
+ isolate.dispose();
138
+ } catch (e) {
139
+ }
142
140
  }
143
141
  };
144
142
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.23.2",
3
+ "version": "0.24.1",
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.23.2";
1
+ export declare const SDK_VERSION = "0.24.1";
@@ -1,5 +1,5 @@
1
1
  import type { EvaluatorArgs } from './helpers';
2
2
  type EvalValue = unknown;
3
3
  export declare const getSimpleExpressionGetPath: (code: string) => string | undefined;
4
- export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression }: EvaluatorArgs): EvalValue;
4
+ export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression, trackingContext }: EvaluatorArgs): EvalValue;
5
5
  export {};
@@ -1,14 +1,22 @@
1
1
  import type { BuilderContextInterface, BuilderRenderState } from '../../context/types';
2
2
  import { getUserAttributes } from '../track/helpers';
3
+ export type TrackingContext = {
4
+ apiKey: string | null;
5
+ canTrack?: boolean;
6
+ contentId?: string;
7
+ variationId?: string;
8
+ };
3
9
  export type EvaluatorArgs = Omit<ExecutorArgs, 'builder' | 'event'> & {
4
10
  event?: Event;
5
11
  isExpression?: boolean;
12
+ trackingContext?: TrackingContext;
6
13
  };
7
14
  export type BuilderGlobals = {
8
15
  isEditing: boolean | undefined;
9
16
  isBrowser: boolean | undefined;
10
17
  isServer: boolean | undefined;
11
18
  getUserAttributes: typeof getUserAttributes;
19
+ trackConversion: (amount?: number, customProperties?: Record<string, any>) => void;
12
20
  };
13
21
  export type ExecutorArgs = Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'> & {
14
22
  code: string;
@@ -20,7 +28,7 @@ export type FunctionArguments = ReturnType<typeof getFunctionArguments>;
20
28
  export declare const getFunctionArguments: ({ builder, context, event, state }: Pick<ExecutorArgs, "builder" | "context" | "event"> & {
21
29
  state: BuilderRenderState;
22
30
  }) => [string, Event | BuilderRenderState | import("../../context/types").BuilderRenderContext | BuilderGlobals | undefined][];
23
- export declare const getBuilderGlobals: () => BuilderGlobals;
31
+ export declare const getBuilderGlobals: (trackingContext?: TrackingContext) => BuilderGlobals;
24
32
  export declare const parseCode: (code: string, { isExpression }: Pick<EvaluatorArgs, "isExpression">) => string;
25
33
  export declare function flattenState({ rootState, localState, rootSetState }: {
26
34
  rootState: Record<string | symbol, any>;
@@ -1,10 +1,12 @@
1
1
  import type { BuilderContextInterface } from '../context/types';
2
2
  import type { BuilderBlock } from '../types/builder-block';
3
+ import type { TrackingContext } from './evaluate/helpers';
3
4
  type Actions = {
4
5
  [index: string]: (event: Event) => any;
5
6
  };
6
7
  export declare function getBlockActions(options: {
7
8
  block: BuilderBlock;
8
9
  stripPrefix?: boolean;
10
+ trackingContext?: TrackingContext;
9
11
  } & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>): Actions;
10
12
  export {};