@builder.io/sdk-react-nextjs 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/lib/browser/blocks/symbol/symbol.cjs +1 -1
  2. package/lib/browser/blocks/symbol/symbol.helpers.cjs +1 -1
  3. package/lib/browser/blocks/symbol/symbol.helpers.mjs +5 -5
  4. package/lib/browser/blocks/symbol/symbol.mjs +24 -24
  5. package/lib/browser/components/block/components/block-wrapper.cjs +1 -1
  6. package/lib/browser/components/block/components/block-wrapper.mjs +16 -9
  7. package/lib/browser/components/block/components/interactive-element.cjs +1 -1
  8. package/lib/browser/components/block/components/interactive-element.mjs +28 -21
  9. package/lib/browser/constants/sdk-version.cjs +1 -1
  10. package/lib/browser/constants/sdk-version.mjs +1 -1
  11. package/lib/browser/functions/evaluate/evaluate.cjs +1 -1
  12. package/lib/browser/functions/evaluate/evaluate.mjs +18 -17
  13. package/lib/browser/functions/evaluate/helpers.cjs +1 -1
  14. package/lib/browser/functions/evaluate/helpers.mjs +52 -35
  15. package/lib/browser/functions/get-block-actions-handler.cjs +1 -1
  16. package/lib/browser/functions/get-block-actions-handler.mjs +4 -3
  17. package/lib/edge/blocks/symbol/symbol.cjs +1 -1
  18. package/lib/edge/blocks/symbol/symbol.helpers.cjs +1 -1
  19. package/lib/edge/blocks/symbol/symbol.helpers.mjs +5 -5
  20. package/lib/edge/blocks/symbol/symbol.mjs +24 -24
  21. package/lib/edge/components/block/components/block-wrapper.cjs +1 -1
  22. package/lib/edge/components/block/components/block-wrapper.mjs +16 -9
  23. package/lib/edge/components/block/components/interactive-element.cjs +1 -1
  24. package/lib/edge/components/block/components/interactive-element.mjs +28 -21
  25. package/lib/edge/constants/sdk-version.cjs +1 -1
  26. package/lib/edge/constants/sdk-version.mjs +1 -1
  27. package/lib/edge/functions/evaluate/evaluate.cjs +1 -1
  28. package/lib/edge/functions/evaluate/evaluate.mjs +18 -17
  29. package/lib/edge/functions/evaluate/helpers.cjs +1 -1
  30. package/lib/edge/functions/evaluate/helpers.mjs +52 -35
  31. package/lib/edge/functions/get-block-actions-handler.cjs +1 -1
  32. package/lib/edge/functions/get-block-actions-handler.mjs +4 -3
  33. package/lib/node/blocks/symbol/symbol.cjs +1 -1
  34. package/lib/node/blocks/symbol/symbol.helpers.cjs +1 -1
  35. package/lib/node/blocks/symbol/symbol.helpers.mjs +5 -5
  36. package/lib/node/blocks/symbol/symbol.mjs +24 -24
  37. package/lib/node/components/block/components/block-wrapper.cjs +1 -1
  38. package/lib/node/components/block/components/block-wrapper.mjs +16 -9
  39. package/lib/node/components/block/components/interactive-element.cjs +1 -1
  40. package/lib/node/components/block/components/interactive-element.mjs +28 -21
  41. package/lib/node/constants/sdk-version.cjs +1 -1
  42. package/lib/node/constants/sdk-version.mjs +1 -1
  43. package/lib/node/functions/evaluate/evaluate.cjs +1 -1
  44. package/lib/node/functions/evaluate/evaluate.mjs +18 -17
  45. package/lib/node/functions/evaluate/helpers.cjs +1 -1
  46. package/lib/node/functions/evaluate/helpers.mjs +52 -35
  47. package/lib/node/functions/get-block-actions-handler.cjs +1 -1
  48. package/lib/node/functions/get-block-actions-handler.mjs +4 -3
  49. package/package.json +1 -1
  50. package/types/cjs/blocks/symbol/symbol.helpers.d.ts +2 -0
  51. package/types/cjs/blocks/symbol/symbol.types.d.ts +2 -0
  52. package/types/cjs/constants/sdk-version.d.ts +1 -1
  53. package/types/cjs/functions/evaluate/evaluate.d.ts +1 -1
  54. package/types/cjs/functions/evaluate/helpers.d.ts +9 -1
  55. package/types/cjs/functions/get-block-actions-handler.d.ts +2 -0
  56. package/types/cjs/functions/get-block-actions.d.ts +2 -0
  57. package/types/esm/blocks/symbol/symbol.helpers.d.ts +2 -0
  58. package/types/esm/blocks/symbol/symbol.types.d.ts +2 -0
  59. package/types/esm/constants/sdk-version.d.ts +1 -1
  60. package/types/esm/functions/evaluate/evaluate.d.ts +1 -1
  61. package/types/esm/functions/evaluate/helpers.d.ts +9 -1
  62. package/types/esm/functions/get-block-actions-handler.d.ts +2 -0
  63. package/types/esm/functions/get-block-actions.d.ts +2 -0
@@ -1 +1 @@
1
- "use client";"use strict";const e=require("react/jsx-runtime"),c=require("../../../functions/get-block-actions.cjs"),o=require("../../../functions/get-block-properties.cjs"),r=require("../../dynamic-renderer/dynamic-renderer.cjs");function n(t){return e.jsx(r,{TagName:t.Wrapper,attributes:o.getBlockProperties({block:t.block,context:t.context}),actionAttributes:c.getBlockActions({block:t.block,rootState:t.context.rootState,rootSetState:t.context.rootSetState,localState:t.context.localState,context:t.context.context,stripPrefix:!0}),children:t.children})}module.exports=n;
1
+ "use client";"use strict";const o=require("react/jsx-runtime"),i=require("../../../functions/get-block-actions.cjs"),r=require("../../../functions/get-block-properties.cjs"),a=require("../../dynamic-renderer/dynamic-renderer.cjs");function x(t){var e,c,n;return o.jsx(a,{TagName:t.Wrapper,attributes:r.getBlockProperties({block:t.block,context:t.context}),actionAttributes:i.getBlockActions({block:t.block,rootState:t.context.rootState,rootSetState:t.context.rootSetState,localState:t.context.localState,context:t.context.context,stripPrefix:!0,trackingContext:{apiKey:t.context.apiKey,canTrack:(e=t.context.canTrack)!=null?e:!0,contentId:(c=t.context.content)==null?void 0:c.id,variationId:(n=t.context.content)==null?void 0:n.testVariationId}}),children:t.children})}module.exports=x;
@@ -1,29 +1,36 @@
1
1
  "use client";
2
- import { jsx as e } from "react/jsx-runtime";
3
- import { getBlockActions as o } from "../../../functions/get-block-actions.mjs";
4
- import { getBlockProperties as c } from "../../../functions/get-block-properties.mjs";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ import { getBlockActions as a } from "../../../functions/get-block-actions.mjs";
4
+ import { getBlockProperties as i } from "../../../functions/get-block-properties.mjs";
5
5
  import r from "../../dynamic-renderer/dynamic-renderer.mjs";
6
- function x(t) {
7
- return /* @__PURE__ */ e(
6
+ function d(t) {
7
+ var e, c, o;
8
+ return /* @__PURE__ */ n(
8
9
  r,
9
10
  {
10
11
  TagName: t.Wrapper,
11
- attributes: c({
12
+ attributes: i({
12
13
  block: t.block,
13
14
  context: t.context
14
15
  }),
15
- actionAttributes: o({
16
+ actionAttributes: a({
16
17
  block: t.block,
17
18
  rootState: t.context.rootState,
18
19
  rootSetState: t.context.rootSetState,
19
20
  localState: t.context.localState,
20
21
  context: t.context.context,
21
- stripPrefix: !0
22
+ stripPrefix: !0,
23
+ trackingContext: {
24
+ apiKey: t.context.apiKey,
25
+ canTrack: (e = t.context.canTrack) != null ? e : !0,
26
+ contentId: (c = t.context.content) == null ? void 0 : c.id,
27
+ variationId: (o = t.context.content) == null ? void 0 : o.testVariationId
28
+ }
22
29
  }),
23
30
  children: t.children
24
31
  }
25
32
  );
26
33
  }
27
34
  export {
28
- x as default
35
+ d as default
29
36
  };
@@ -1 +1 @@
1
- "use client";"use strict";const e=require("react/jsx-runtime"),i=require("react"),o=require("../../../functions/get-block-actions.cjs"),l=require("../../../functions/get-block-properties.cjs"),u=require("../../../functions/is-editing.cjs");require("../../../helpers/user-attributes.cjs");require("../../../functions/get-fetch.cjs");const d=require("../../awaiter.cjs"),s=require("../../live-edit.cjs");function x(t){var c,n;i.useState(()=>0);function r(){return t.includeBlockProps?{...l.getBlockProperties({block:t.block,context:t.context}),...o.getBlockActions({block:t.block,rootState:t.context.rootState,rootSetState:t.context.rootSetState,localState:t.context.localState,context:t.context.context})}:{}}function a(){return t.wrapperProps}return i.useEffect(()=>{},[t.wrapperProps,(n=(c=t.block)==null?void 0:c.component)==null?void 0:n.options]),e.jsx(e.Fragment,{children:t.Wrapper.load?e.jsx(e.Fragment,{children:e.jsx(d,{load:t.Wrapper.load,fallback:t.Wrapper.fallback,props:t.wrapperProps,attributes:r(),children:t.children})}):u.isEditing()?e.jsx(s,{Wrapper:t.Wrapper,id:t.block.id||"",attributes:r(),children:t.children}):e.jsx(t.Wrapper,{...a(),attributes:r(),children:t.children})})}module.exports=x;
1
+ "use client";"use strict";const e=require("react/jsx-runtime"),l=require("react"),d=require("../../../functions/get-block-actions.cjs"),x=require("../../../functions/get-block-properties.cjs"),k=require("../../../functions/is-editing.cjs");require("../../../helpers/user-attributes.cjs");require("../../../functions/get-fetch.cjs");const s=require("../../awaiter.cjs"),b=require("../../live-edit.cjs");function g(t){var n,r;l.useState(()=>0);function c(){var i,a,o;return t.includeBlockProps?{...x.getBlockProperties({block:t.block,context:t.context}),...d.getBlockActions({block:t.block,rootState:t.context.rootState,rootSetState:t.context.rootSetState,localState:t.context.localState,context:t.context.context,trackingContext:{apiKey:t.context.apiKey,canTrack:(i=t.context.canTrack)!=null?i:!0,contentId:(a=t.context.content)==null?void 0:a.id,variationId:(o=t.context.content)==null?void 0:o.testVariationId}})}:{}}function u(){return t.wrapperProps}return l.useEffect(()=>{},[t.wrapperProps,(r=(n=t.block)==null?void 0:n.component)==null?void 0:r.options]),e.jsx(e.Fragment,{children:t.Wrapper.load?e.jsx(e.Fragment,{children:e.jsx(s,{load:t.Wrapper.load,fallback:t.Wrapper.fallback,props:t.wrapperProps,attributes:c(),children:t.children})}):k.isEditing()?e.jsx(b,{Wrapper:t.Wrapper,id:t.block.id||"",attributes:c(),children:t.children}):e.jsx(t.Wrapper,{...u(),attributes:c(),children:t.children})})}module.exports=g;
@@ -1,37 +1,44 @@
1
1
  "use client";
2
- import { jsx as e, Fragment as i } from "react/jsx-runtime";
3
- import { useState as n, useEffect as l } from "react";
4
- import { getBlockActions as m } from "../../../functions/get-block-actions.mjs";
5
- import { getBlockProperties as d } from "../../../functions/get-block-properties.mjs";
6
- import { isEditing as f } from "../../../functions/is-editing.mjs";
2
+ import { jsx as e, Fragment as l } from "react/jsx-runtime";
3
+ import { useState as m, useEffect as u } from "react";
4
+ import { getBlockActions as f } from "../../../functions/get-block-actions.mjs";
5
+ import { getBlockProperties as x } from "../../../functions/get-block-properties.mjs";
6
+ import { isEditing as k } from "../../../functions/is-editing.mjs";
7
7
  import "../../../helpers/user-attributes.mjs";
8
8
  import "../../../functions/get-fetch.mjs";
9
- import u from "../../awaiter.mjs";
10
- import b from "../../live-edit.mjs";
11
- function B(t) {
12
- var o, c;
13
- n(() => 0);
9
+ import b from "../../awaiter.mjs";
10
+ import S from "../../live-edit.mjs";
11
+ function y(t) {
12
+ var n, c;
13
+ m(() => 0);
14
14
  function r() {
15
+ var o, a, i;
15
16
  return t.includeBlockProps ? {
16
- ...d({
17
+ ...x({
17
18
  block: t.block,
18
19
  context: t.context
19
20
  }),
20
- ...m({
21
+ ...f({
21
22
  block: t.block,
22
23
  rootState: t.context.rootState,
23
24
  rootSetState: t.context.rootSetState,
24
25
  localState: t.context.localState,
25
- context: t.context.context
26
+ context: t.context.context,
27
+ trackingContext: {
28
+ apiKey: t.context.apiKey,
29
+ canTrack: (o = t.context.canTrack) != null ? o : !0,
30
+ contentId: (a = t.context.content) == null ? void 0 : a.id,
31
+ variationId: (i = t.context.content) == null ? void 0 : i.testVariationId
32
+ }
26
33
  })
27
34
  } : {};
28
35
  }
29
- function a() {
36
+ function d() {
30
37
  return t.wrapperProps;
31
38
  }
32
- return l(() => {
33
- }, [t.wrapperProps, (c = (o = t.block) == null ? void 0 : o.component) == null ? void 0 : c.options]), /* @__PURE__ */ e(i, { children: t.Wrapper.load ? /* @__PURE__ */ e(i, { children: /* @__PURE__ */ e(
34
- u,
39
+ return u(() => {
40
+ }, [t.wrapperProps, (c = (n = t.block) == null ? void 0 : n.component) == null ? void 0 : c.options]), /* @__PURE__ */ e(l, { children: t.Wrapper.load ? /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(
41
+ b,
35
42
  {
36
43
  load: t.Wrapper.load,
37
44
  fallback: t.Wrapper.fallback,
@@ -39,16 +46,16 @@ function B(t) {
39
46
  attributes: r(),
40
47
  children: t.children
41
48
  }
42
- ) }) : f() ? /* @__PURE__ */ e(
43
- b,
49
+ ) }) : k() ? /* @__PURE__ */ e(
50
+ S,
44
51
  {
45
52
  Wrapper: t.Wrapper,
46
53
  id: t.block.id || "",
47
54
  attributes: r(),
48
55
  children: t.children
49
56
  }
50
- ) : /* @__PURE__ */ e(t.Wrapper, { ...a(), attributes: r(), children: t.children }) });
57
+ ) : /* @__PURE__ */ e(t.Wrapper, { ...d(), attributes: r(), children: t.children }) });
51
58
  }
52
59
  export {
53
- B as default
60
+ y as default
54
61
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.24.0";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.25.0";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.24.0";
1
+ const o = "0.25.0";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../../helpers/logger.cjs"),E=require("../get.cjs"),h=require("./choose-eval.cjs"),l=require("./helpers.cjs"),p=/^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/,d=/(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/,g=e=>{var s,t,r,i,n,a;return((r=(t=(s=p.exec(e.trim()))==null?void 0:s.groups)==null?void 0:t.getPath)==null?void 0:r.slice(1))||((a=(n=(i=d.exec(e.trim()))==null?void 0:i.groups)==null?void 0:n.getPath)==null?void 0:a.slice(1))};function m({code:e,context:s,localState:t,rootState:r,rootSetState:i,event:n,isExpression:a=!0}){if(e.trim()==="")return;const o=g(e.trim());if(o)return E.get({...r,...t},o);const c={code:l.parseCode(e,{isExpression:a}),builder:l.getBuilderGlobals(),context:s,event:n,rootSetState:i,rootState:r,localState:t};try{return h.chooseBrowserOrServerEval(c)}catch(u){v.logger.error("Failed code evaluation: "+u.message,{code:e});return}}exports.evaluate=m;exports.getSimpleExpressionGetPath=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("../../helpers/logger.cjs"),h=require("../get.cjs"),p=require("./choose-eval.cjs"),l=require("./helpers.cjs"),d=/^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/,m=/(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/,g=e=>{var s,t,r,i,n,a;return((r=(t=(s=d.exec(e.trim()))==null?void 0:s.groups)==null?void 0:t.getPath)==null?void 0:r.slice(1))||((a=(n=(i=m.exec(e.trim()))==null?void 0:i.groups)==null?void 0:n.getPath)==null?void 0:a.slice(1))};function P({code:e,context:s,localState:t,rootState:r,rootSetState:i,event:n,isExpression:a=!0,trackingContext:c}){if(e.trim()==="")return;const o=g(e.trim());if(o)return h.get({...r,...t},o);const v={code:l.parseCode(e,{isExpression:a}),builder:l.getBuilderGlobals(c),context:s,event:n,rootSetState:i,rootState:r,localState:t};try{return p.chooseBrowserOrServerEval(v)}catch(u){E.logger.error("Failed code evaluation: "+u.message,{code:e});return}}exports.evaluate=P;exports.getSimpleExpressionGetPath=g;
@@ -1,33 +1,34 @@
1
- import { logger as l } from "../../helpers/logger.mjs";
2
- import { get as m } from "../get.mjs";
3
- import { chooseBrowserOrServerEval as E } from "./choose-eval.mjs";
4
- import { parseCode as c, getBuilderGlobals as v } from "./helpers.mjs";
5
- const p = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/, h = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/, _ = (r) => {
1
+ import { logger as m } from "../../helpers/logger.mjs";
2
+ import { get as E } from "../get.mjs";
3
+ import { chooseBrowserOrServerEval as c } from "./choose-eval.mjs";
4
+ import { parseCode as v, getBuilderGlobals as p } from "./helpers.mjs";
5
+ const h = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/, _ = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/, f = (r) => {
6
6
  var s, e, t, i, o, a;
7
- return ((t = (e = (s = p.exec(r.trim())) == null ? void 0 : s.groups) == null ? void 0 : e.getPath) == null ? void 0 : t.slice(1)) || ((a = (o = (i = h.exec(r.trim())) == null ? void 0 : i.groups) == null ? void 0 : o.getPath) == null ? void 0 : a.slice(1));
7
+ return ((t = (e = (s = h.exec(r.trim())) == null ? void 0 : s.groups) == null ? void 0 : e.getPath) == null ? void 0 : t.slice(1)) || ((a = (o = (i = _.exec(r.trim())) == null ? void 0 : i.groups) == null ? void 0 : o.getPath) == null ? void 0 : a.slice(1));
8
8
  };
9
- function w({
9
+ function G({
10
10
  code: r,
11
11
  context: s,
12
12
  localState: e,
13
13
  rootState: t,
14
14
  rootSetState: i,
15
15
  event: o,
16
- isExpression: a = !0
16
+ isExpression: a = !0,
17
+ trackingContext: g
17
18
  }) {
18
19
  if (r.trim() === "")
19
20
  return;
20
- const n = _(r.trim());
21
+ const n = f(r.trim());
21
22
  if (n)
22
- return m({
23
+ return E({
23
24
  ...t,
24
25
  ...e
25
26
  }, n);
26
- const g = {
27
- code: c(r, {
27
+ const l = {
28
+ code: v(r, {
28
29
  isExpression: a
29
30
  }),
30
- builder: v(),
31
+ builder: p(g),
31
32
  context: s,
32
33
  event: o,
33
34
  rootSetState: i,
@@ -35,15 +36,15 @@ function w({
35
36
  localState: e
36
37
  };
37
38
  try {
38
- return E(g);
39
+ return c(l);
39
40
  } catch (u) {
40
- l.error("Failed code evaluation: " + u.message, {
41
+ m.error("Failed code evaluation: " + u.message, {
41
42
  code: r
42
43
  });
43
44
  return;
44
45
  }
45
46
  }
46
47
  export {
47
- w as evaluate,
48
- _ as getSimpleExpressionGetPath
48
+ G as evaluate,
49
+ f as getSimpleExpressionGetPath
49
50
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../is-browser.cjs"),d=require("../is-editing.cjs"),c=require("../track/helpers.cjs"),g=({builder:e,context:r,event:n,state:s})=>Object.entries({state:s,Builder:e,builder:e,context:r,event:n}),f=()=>({isEditing:d.isEditing(),isBrowser:u.isBrowser(),isServer:!u.isBrowser(),getUserAttributes:()=>c.getUserAttributes()}),w=(e,{isExpression:r=!0})=>r&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e;function o({rootState:e,localState:r,rootSetState:n}){return new Proxy(e,{get:(s,t)=>{if(r&&t in r)return r[t];const i=s[t];return typeof i=="object"&&i!==null?o({rootState:i,localState:void 0,rootSetState:n?l=>{s[t]=l,n(s)}:void 0}):i},set:(s,t,i)=>{if(r&&t in r)throw new Error("Writing to local state is not allowed as it is read-only.");return s[t]=i,n==null||n(s),!0}})}exports.flattenState=o;exports.getBuilderGlobals=f;exports.getFunctionArguments=g;exports.parseCode=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../is-browser.cjs"),t=require("../is-editing.cjs"),v=require("../track/helpers.cjs"),c=require("../track/index.cjs"),f=({builder:e,context:r,event:i,state:s})=>Object.entries({state:s,Builder:e,builder:e,context:r,event:i}),a=e=>({isEditing:t.isEditing(),isBrowser:d.isBrowser(),isServer:!d.isBrowser(),getUserAttributes:()=>v.getUserAttributes(),trackConversion:(r,i)=>{var s;!(e!=null&&e.apiKey)||(e==null?void 0:e.canTrack)===!1||c._track({type:"conversion",apiKey:e.apiKey,canTrack:(s=e.canTrack)!=null?s:!0,contentId:e.contentId,variationId:e.variationId!==e.contentId?e.variationId:void 0,metadata:{...i||{},...r!==void 0?{amount:r}:{}}})}}),y=(e,{isExpression:r=!0})=>r&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e;function l({rootState:e,localState:r,rootSetState:i}){return new Proxy(e,{get:(s,u)=>{if(r&&u in r)return r[u];const n=s[u];return typeof n=="object"&&n!==null?l({rootState:n,localState:void 0,rootSetState:i?o=>{s[u]=o,i(s)}:void 0}):n},set:(s,u,n)=>{if(r&&u in r)throw new Error("Writing to local state is not allowed as it is read-only.");return s[u]=n,i==null||i(s),!0}})}exports.flattenState=l;exports.getBuilderGlobals=a;exports.getFunctionArguments=f;exports.parseCode=y;
@@ -1,54 +1,71 @@
1
- import { isBrowser as u } from "../is-browser.mjs";
2
- import { isEditing as f } from "../is-editing.mjs";
3
- import { getUserAttributes as d } from "../track/helpers.mjs";
4
- const w = ({
1
+ import { isBrowser as d } from "../is-browser.mjs";
2
+ import { isEditing as o } from "../is-editing.mjs";
3
+ import { getUserAttributes as v } from "../track/helpers.mjs";
4
+ import { _track as m } from "../track/index.mjs";
5
+ const B = ({
5
6
  builder: r,
6
- context: n,
7
- event: i,
8
- state: e
7
+ context: s,
8
+ event: e,
9
+ state: i
9
10
  }) => Object.entries({
10
- state: e,
11
+ state: i,
11
12
  Builder: r,
12
13
  // legacy
13
14
  builder: r,
14
- context: n,
15
- event: i
16
- }), b = () => ({
17
- isEditing: f(),
18
- isBrowser: u(),
19
- isServer: !u(),
20
- getUserAttributes: () => d()
21
- }), v = (r, {
22
- isExpression: n = !0
23
- }) => /* we disable this for cases where we definitely don't want a return */ n && !(r.includes(";") || r.includes(" return ") || r.trim().startsWith("return ")) ? `return (${r});` : r;
15
+ context: s,
16
+ event: e
17
+ }), a = (r) => ({
18
+ isEditing: o(),
19
+ isBrowser: d(),
20
+ isServer: !d(),
21
+ getUserAttributes: () => v(),
22
+ trackConversion: (s, e) => {
23
+ var i;
24
+ !(r != null && r.apiKey) || (r == null ? void 0 : r.canTrack) === !1 || m({
25
+ type: "conversion",
26
+ apiKey: r.apiKey,
27
+ canTrack: (i = r.canTrack) != null ? i : !0,
28
+ contentId: r.contentId,
29
+ variationId: r.variationId !== r.contentId ? r.variationId : void 0,
30
+ metadata: {
31
+ ...e || {},
32
+ ...s !== void 0 ? {
33
+ amount: s
34
+ } : {}
35
+ }
36
+ });
37
+ }
38
+ }), c = (r, {
39
+ isExpression: s = !0
40
+ }) => /* we disable this for cases where we definitely don't want a return */ s && !(r.includes(";") || r.includes(" return ") || r.trim().startsWith("return ")) ? `return (${r});` : r;
24
41
  function l({
25
42
  rootState: r,
26
- localState: n,
27
- rootSetState: i
43
+ localState: s,
44
+ rootSetState: e
28
45
  }) {
29
46
  return new Proxy(r, {
30
- get: (e, s) => {
31
- if (n && s in n)
32
- return n[s];
33
- const t = e[s];
34
- return typeof t == "object" && t !== null ? l({
35
- rootState: t,
47
+ get: (i, u) => {
48
+ if (s && u in s)
49
+ return s[u];
50
+ const n = i[u];
51
+ return typeof n == "object" && n !== null ? l({
52
+ rootState: n,
36
53
  localState: void 0,
37
- rootSetState: i ? (o) => {
38
- e[s] = o, i(e);
54
+ rootSetState: e ? (f) => {
55
+ i[u] = f, e(i);
39
56
  } : void 0
40
- }) : t;
57
+ }) : n;
41
58
  },
42
- set: (e, s, t) => {
43
- if (n && s in n)
59
+ set: (i, u, n) => {
60
+ if (s && u in s)
44
61
  throw new Error("Writing to local state is not allowed as it is read-only.");
45
- return e[s] = t, i == null || i(e), !0;
62
+ return i[u] = n, e == null || e(i), !0;
46
63
  }
47
64
  });
48
65
  }
49
66
  export {
50
67
  l as flattenState,
51
- b as getBuilderGlobals,
52
- w as getFunctionArguments,
53
- v as parseCode
68
+ a as getBuilderGlobals,
69
+ B as getFunctionArguments,
70
+ c as parseCode
54
71
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./evaluate/evaluate.cjs"),o=(t,e)=>a=>r.evaluate({code:t,context:e.context,localState:e.localState,rootState:e.rootState,rootSetState:e.rootSetState,event:a,isExpression:!1});exports.createEventHandler=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./evaluate/evaluate.cjs"),o=(e,t)=>a=>r.evaluate({code:e,context:t.context,localState:t.localState,rootState:t.rootState,rootSetState:t.rootSetState,event:a,isExpression:!1,trackingContext:t.trackingContext});exports.createEventHandler=o;
@@ -1,13 +1,14 @@
1
1
  import { evaluate as o } from "./evaluate/evaluate.mjs";
2
- const S = (e, t) => (a) => o({
2
+ const c = (e, t) => (a) => o({
3
3
  code: e,
4
4
  context: t.context,
5
5
  localState: t.localState,
6
6
  rootState: t.rootState,
7
7
  rootSetState: t.rootSetState,
8
8
  event: a,
9
- isExpression: !1
9
+ isExpression: !1,
10
+ trackingContext: t.trackingContext
10
11
  });
11
12
  export {
12
- S as createEventHandler
13
+ c as createEventHandler
13
14
  };
@@ -1 +1 @@
1
- "use strict";const m=require("react/jsx-runtime"),k=require("../../components/content-variants/content-variants.cjs"),f=require("../../functions/get-class-prop-name.cjs"),v=require("./symbol.helpers.cjs");async function N(e){var o,i,l,a,c,r,s;const d=function(){return"div"},y=function(){return"div"},C=function(){return Object.values(e.builderComponents)},x=function(){var u,b;return[e.attributes[f.getClassPropName()],"builder-symbol",(u=e.symbol)!=null&&u.inline?"builder-inline-symbol":void 0,(b=e.symbol)!=null&&b.dynamic||e.dynamic?"builder-dynamic-symbol":void 0].filter(Boolean).join(" ")},t=((o=e.symbol)==null?void 0:o.content)||await v.fetchSymbolContent({symbol:e.symbol,builderContextValue:e.builderContext});return(i=e.symbol)==null||i.entry,m.jsx("div",{...e.attributes,className:x(),children:m.jsx(k,{nonce:e.builderContext.nonce,isNestedRender:!0,apiVersion:e.builderContext.apiVersion,apiKey:e.builderContext.apiKey,context:{...e.builderContext.context,symbolId:(l=e.builderBlock)==null?void 0:l.id},customComponents:C(),data:{...(a=e.symbol)==null?void 0:a.data,...e.builderContext.localState,...(c=t==null?void 0:t.data)==null?void 0:c.state},canTrack:e.builderContext.canTrack,model:(s=(r=e.symbol)==null?void 0:r.model)!=null?s:"",content:t,linkComponent:e.builderLinkComponent,blocksWrapper:d(),contentWrapper:y()})})}module.exports=N;
1
+ "use strict";const y=require("react/jsx-runtime"),v=require("../../components/content-variants/content-variants.cjs"),N=require("../../functions/get-class-prop-name.cjs"),W=require("./symbol.helpers.cjs");async function j(e){var o,l,i,a,c,r,b,s,m;const C=function(){return"div"},x=function(){return"div"},k=function(){return Object.values(e.builderComponents)},f=function(){var u,d;return[e.attributes[N.getClassPropName()],"builder-symbol",(u=e.symbol)!=null&&u.inline?"builder-inline-symbol":void 0,(d=e.symbol)!=null&&d.dynamic||e.dynamic?"builder-dynamic-symbol":void 0].filter(Boolean).join(" ")},t=((o=e.symbol)==null?void 0:o.content)||await W.fetchSymbolContent({symbol:e.symbol,builderContextValue:e.builderContext});return(l=e.symbol)==null||l.entry,y.jsx("div",{...e.attributes,className:f(),children:y.jsx(v,{nonce:e.builderContext.nonce,isNestedRender:!0,apiVersion:e.builderContext.apiVersion,apiKey:(i=e.symbol)!=null&&i.global&&((a=e.symbol)!=null&&a.ownerId)?e.symbol.ownerId:e.builderContext.apiKey,context:{...e.builderContext.context,symbolId:(c=e.builderBlock)==null?void 0:c.id},customComponents:k(),data:{...(r=e.symbol)==null?void 0:r.data,...e.builderContext.localState,...(b=t==null?void 0:t.data)==null?void 0:b.state},canTrack:e.builderContext.canTrack,model:(m=(s=e.symbol)==null?void 0:s.model)!=null?m:"",content:t,linkComponent:e.builderLinkComponent,blocksWrapper:C(),contentWrapper:x()})})}module.exports=j;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../functions/get-content/index.cjs"),c=require("../../helpers/logger.cjs"),i=async({builderContextValue:r,symbol:e})=>{if(e!=null&&e.model&&(r!=null&&r.apiKey))return t.fetchOneEntry({model:e.model,apiKey:r.apiKey,apiVersion:r.apiVersion,...(e==null?void 0:e.entry)&&{query:{id:e.entry}}}).catch(n=>{c.logger.error("Could not fetch symbol content: ",n)})};exports.fetchSymbolContent=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../functions/get-content/index.cjs"),c=require("../../helpers/logger.cjs"),i=async({builderContextValue:r,symbol:e})=>{if(e!=null&&e.model&&(r!=null&&r.apiKey))return t.fetchOneEntry({model:e.model,apiKey:e.global&&e.ownerId?e.ownerId:r.apiKey,apiVersion:r.apiVersion,...(e==null?void 0:e.entry)&&{query:{id:e.entry}}}).catch(n=>{c.logger.error("Could not fetch symbol content: ",n)})};exports.fetchSymbolContent=i;
@@ -1,6 +1,6 @@
1
1
  import { fetchOneEntry as p } from "../../functions/get-content/index.mjs";
2
- import { logger as i } from "../../helpers/logger.mjs";
3
- const e = async ({
2
+ import { logger as e } from "../../helpers/logger.mjs";
3
+ const f = async ({
4
4
  builderContextValue: n,
5
5
  symbol: r
6
6
  }) => {
@@ -8,7 +8,7 @@ const e = async ({
8
8
  (n != null && n.apiKey))
9
9
  return p({
10
10
  model: r.model,
11
- apiKey: n.apiKey,
11
+ apiKey: r.global && r.ownerId ? r.ownerId : n.apiKey,
12
12
  apiVersion: n.apiVersion,
13
13
  ...(r == null ? void 0 : r.entry) && {
14
14
  query: {
@@ -16,9 +16,9 @@ const e = async ({
16
16
  }
17
17
  }
18
18
  }).catch((c) => {
19
- i.error("Could not fetch symbol content: ", c);
19
+ e.error("Could not fetch symbol content: ", c);
20
20
  });
21
21
  };
22
22
  export {
23
- e as fetchSymbolContent
23
+ f as fetchSymbolContent
24
24
  };
@@ -1,50 +1,50 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import x from "../../components/content-variants/content-variants.mjs";
3
- import { getClassPropName as k } from "../../functions/get-class-prop-name.mjs";
4
- import { fetchSymbolContent as v } from "./symbol.helpers.mjs";
1
+ import { jsx as y } from "react/jsx-runtime";
2
+ import v from "../../components/content-variants/content-variants.mjs";
3
+ import { getClassPropName as W } from "../../functions/get-class-prop-name.mjs";
4
+ import { fetchSymbolContent as N } from "./symbol.helpers.mjs";
5
5
  async function S(t) {
6
- var o, i, l, a, c, m, r;
7
- const s = function() {
6
+ var o, l, i, a, m, c, b, r, d;
7
+ const C = function() {
8
8
  return "div";
9
- }, y = function() {
9
+ }, f = function() {
10
10
  return "div";
11
- }, C = function() {
11
+ }, x = function() {
12
12
  return Object.values(t.builderComponents);
13
- }, f = function() {
14
- var b, d;
13
+ }, k = function() {
14
+ var u, s;
15
15
  return [
16
- t.attributes[k()],
16
+ t.attributes[W()],
17
17
  "builder-symbol",
18
- (b = t.symbol) != null && b.inline ? "builder-inline-symbol" : void 0,
19
- (d = t.symbol) != null && d.dynamic || t.dynamic ? "builder-dynamic-symbol" : void 0
18
+ (u = t.symbol) != null && u.inline ? "builder-inline-symbol" : void 0,
19
+ (s = t.symbol) != null && s.dynamic || t.dynamic ? "builder-dynamic-symbol" : void 0
20
20
  ].filter(Boolean).join(" ");
21
- }, e = ((o = t.symbol) == null ? void 0 : o.content) || await v({
21
+ }, e = ((o = t.symbol) == null ? void 0 : o.content) || await N({
22
22
  symbol: t.symbol,
23
23
  builderContextValue: t.builderContext
24
24
  });
25
- return (i = t.symbol) == null || i.entry, /* @__PURE__ */ u("div", { ...t.attributes, className: f(), children: /* @__PURE__ */ u(
26
- x,
25
+ return (l = t.symbol) == null || l.entry, /* @__PURE__ */ y("div", { ...t.attributes, className: k(), children: /* @__PURE__ */ y(
26
+ v,
27
27
  {
28
28
  nonce: t.builderContext.nonce,
29
29
  isNestedRender: !0,
30
30
  apiVersion: t.builderContext.apiVersion,
31
- apiKey: t.builderContext.apiKey,
31
+ apiKey: (i = t.symbol) != null && i.global && ((a = t.symbol) != null && a.ownerId) ? t.symbol.ownerId : t.builderContext.apiKey,
32
32
  context: {
33
33
  ...t.builderContext.context,
34
- symbolId: (l = t.builderBlock) == null ? void 0 : l.id
34
+ symbolId: (m = t.builderBlock) == null ? void 0 : m.id
35
35
  },
36
- customComponents: C(),
36
+ customComponents: x(),
37
37
  data: {
38
- ...(a = t.symbol) == null ? void 0 : a.data,
38
+ ...(c = t.symbol) == null ? void 0 : c.data,
39
39
  ...t.builderContext.localState,
40
- ...(c = e == null ? void 0 : e.data) == null ? void 0 : c.state
40
+ ...(b = e == null ? void 0 : e.data) == null ? void 0 : b.state
41
41
  },
42
42
  canTrack: t.builderContext.canTrack,
43
- model: (r = (m = t.symbol) == null ? void 0 : m.model) != null ? r : "",
43
+ model: (d = (r = t.symbol) == null ? void 0 : r.model) != null ? d : "",
44
44
  content: e,
45
45
  linkComponent: t.builderLinkComponent,
46
- blocksWrapper: s(),
47
- contentWrapper: y()
46
+ blocksWrapper: C(),
47
+ contentWrapper: f()
48
48
  }
49
49
  ) });
50
50
  }
@@ -1 +1 @@
1
- "use client";"use strict";const e=require("react/jsx-runtime"),c=require("../../../functions/get-block-actions.cjs"),o=require("../../../functions/get-block-properties.cjs"),r=require("../../dynamic-renderer/dynamic-renderer.cjs");function n(t){return e.jsx(r,{TagName:t.Wrapper,attributes:o.getBlockProperties({block:t.block,context:t.context}),actionAttributes:c.getBlockActions({block:t.block,rootState:t.context.rootState,rootSetState:t.context.rootSetState,localState:t.context.localState,context:t.context.context,stripPrefix:!0}),children:t.children})}module.exports=n;
1
+ "use client";"use strict";const o=require("react/jsx-runtime"),i=require("../../../functions/get-block-actions.cjs"),r=require("../../../functions/get-block-properties.cjs"),a=require("../../dynamic-renderer/dynamic-renderer.cjs");function x(t){var e,c,n;return o.jsx(a,{TagName:t.Wrapper,attributes:r.getBlockProperties({block:t.block,context:t.context}),actionAttributes:i.getBlockActions({block:t.block,rootState:t.context.rootState,rootSetState:t.context.rootSetState,localState:t.context.localState,context:t.context.context,stripPrefix:!0,trackingContext:{apiKey:t.context.apiKey,canTrack:(e=t.context.canTrack)!=null?e:!0,contentId:(c=t.context.content)==null?void 0:c.id,variationId:(n=t.context.content)==null?void 0:n.testVariationId}}),children:t.children})}module.exports=x;
@@ -1,29 +1,36 @@
1
1
  "use client";
2
- import { jsx as e } from "react/jsx-runtime";
3
- import { getBlockActions as o } from "../../../functions/get-block-actions.mjs";
4
- import { getBlockProperties as c } from "../../../functions/get-block-properties.mjs";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ import { getBlockActions as a } from "../../../functions/get-block-actions.mjs";
4
+ import { getBlockProperties as i } from "../../../functions/get-block-properties.mjs";
5
5
  import r from "../../dynamic-renderer/dynamic-renderer.mjs";
6
- function x(t) {
7
- return /* @__PURE__ */ e(
6
+ function d(t) {
7
+ var e, c, o;
8
+ return /* @__PURE__ */ n(
8
9
  r,
9
10
  {
10
11
  TagName: t.Wrapper,
11
- attributes: c({
12
+ attributes: i({
12
13
  block: t.block,
13
14
  context: t.context
14
15
  }),
15
- actionAttributes: o({
16
+ actionAttributes: a({
16
17
  block: t.block,
17
18
  rootState: t.context.rootState,
18
19
  rootSetState: t.context.rootSetState,
19
20
  localState: t.context.localState,
20
21
  context: t.context.context,
21
- stripPrefix: !0
22
+ stripPrefix: !0,
23
+ trackingContext: {
24
+ apiKey: t.context.apiKey,
25
+ canTrack: (e = t.context.canTrack) != null ? e : !0,
26
+ contentId: (c = t.context.content) == null ? void 0 : c.id,
27
+ variationId: (o = t.context.content) == null ? void 0 : o.testVariationId
28
+ }
22
29
  }),
23
30
  children: t.children
24
31
  }
25
32
  );
26
33
  }
27
34
  export {
28
- x as default
35
+ d as default
29
36
  };
@@ -1 +1 @@
1
- "use client";"use strict";const e=require("react/jsx-runtime"),i=require("react"),o=require("../../../functions/get-block-actions.cjs"),l=require("../../../functions/get-block-properties.cjs"),u=require("../../../functions/is-editing.cjs");require("../../../helpers/user-attributes.cjs");require("../../../functions/get-fetch.cjs");const d=require("../../awaiter.cjs"),s=require("../../live-edit.cjs");function x(t){var c,n;i.useState(()=>0);function r(){return t.includeBlockProps?{...l.getBlockProperties({block:t.block,context:t.context}),...o.getBlockActions({block:t.block,rootState:t.context.rootState,rootSetState:t.context.rootSetState,localState:t.context.localState,context:t.context.context})}:{}}function a(){return t.wrapperProps}return i.useEffect(()=>{},[t.wrapperProps,(n=(c=t.block)==null?void 0:c.component)==null?void 0:n.options]),e.jsx(e.Fragment,{children:t.Wrapper.load?e.jsx(e.Fragment,{children:e.jsx(d,{load:t.Wrapper.load,fallback:t.Wrapper.fallback,props:t.wrapperProps,attributes:r(),children:t.children})}):u.isEditing()?e.jsx(s,{Wrapper:t.Wrapper,id:t.block.id||"",attributes:r(),children:t.children}):e.jsx(t.Wrapper,{...a(),attributes:r(),children:t.children})})}module.exports=x;
1
+ "use client";"use strict";const e=require("react/jsx-runtime"),l=require("react"),d=require("../../../functions/get-block-actions.cjs"),x=require("../../../functions/get-block-properties.cjs"),k=require("../../../functions/is-editing.cjs");require("../../../helpers/user-attributes.cjs");require("../../../functions/get-fetch.cjs");const s=require("../../awaiter.cjs"),b=require("../../live-edit.cjs");function g(t){var n,r;l.useState(()=>0);function c(){var i,a,o;return t.includeBlockProps?{...x.getBlockProperties({block:t.block,context:t.context}),...d.getBlockActions({block:t.block,rootState:t.context.rootState,rootSetState:t.context.rootSetState,localState:t.context.localState,context:t.context.context,trackingContext:{apiKey:t.context.apiKey,canTrack:(i=t.context.canTrack)!=null?i:!0,contentId:(a=t.context.content)==null?void 0:a.id,variationId:(o=t.context.content)==null?void 0:o.testVariationId}})}:{}}function u(){return t.wrapperProps}return l.useEffect(()=>{},[t.wrapperProps,(r=(n=t.block)==null?void 0:n.component)==null?void 0:r.options]),e.jsx(e.Fragment,{children:t.Wrapper.load?e.jsx(e.Fragment,{children:e.jsx(s,{load:t.Wrapper.load,fallback:t.Wrapper.fallback,props:t.wrapperProps,attributes:c(),children:t.children})}):k.isEditing()?e.jsx(b,{Wrapper:t.Wrapper,id:t.block.id||"",attributes:c(),children:t.children}):e.jsx(t.Wrapper,{...u(),attributes:c(),children:t.children})})}module.exports=g;