@builder.io/sdk-react-nextjs 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.
- package/lib/browser/components/block/components/block-wrapper.cjs +1 -1
- package/lib/browser/components/block/components/block-wrapper.mjs +16 -9
- package/lib/browser/components/block/components/interactive-element.cjs +1 -1
- package/lib/browser/components/block/components/interactive-element.mjs +28 -21
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/functions/evaluate/evaluate.cjs +1 -1
- package/lib/browser/functions/evaluate/evaluate.mjs +18 -17
- package/lib/browser/functions/evaluate/helpers.cjs +1 -1
- package/lib/browser/functions/evaluate/helpers.mjs +52 -35
- package/lib/browser/functions/get-block-actions-handler.cjs +1 -1
- package/lib/browser/functions/get-block-actions-handler.mjs +4 -3
- package/lib/browser/init.cjs +1 -1
- package/lib/browser/init.mjs +7 -12
- package/lib/edge/components/block/components/block-wrapper.cjs +1 -1
- package/lib/edge/components/block/components/block-wrapper.mjs +16 -9
- package/lib/edge/components/block/components/interactive-element.cjs +1 -1
- package/lib/edge/components/block/components/interactive-element.mjs +28 -21
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/functions/evaluate/evaluate.cjs +1 -1
- package/lib/edge/functions/evaluate/evaluate.mjs +18 -17
- package/lib/edge/functions/evaluate/helpers.cjs +1 -1
- package/lib/edge/functions/evaluate/helpers.mjs +52 -35
- package/lib/edge/functions/get-block-actions-handler.cjs +1 -1
- package/lib/edge/functions/get-block-actions-handler.mjs +4 -3
- package/lib/edge/init.cjs +1 -1
- package/lib/edge/init.mjs +7 -12
- package/lib/node/components/block/components/block-wrapper.cjs +1 -1
- package/lib/node/components/block/components/block-wrapper.mjs +16 -9
- package/lib/node/components/block/components/interactive-element.cjs +1 -1
- package/lib/node/components/block/components/interactive-element.mjs +28 -21
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/functions/evaluate/evaluate.cjs +1 -1
- package/lib/node/functions/evaluate/evaluate.mjs +18 -17
- package/lib/node/functions/evaluate/helpers.cjs +1 -1
- package/lib/node/functions/evaluate/helpers.mjs +52 -35
- package/lib/node/functions/evaluate/node-runtime/node-runtime.cjs +7 -7
- package/lib/node/functions/evaluate/node-runtime/node-runtime.mjs +83 -77
- package/lib/node/functions/get-block-actions-handler.cjs +1 -1
- package/lib/node/functions/get-block-actions-handler.mjs +4 -3
- package/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/evaluate/evaluate.d.ts +1 -1
- package/types/cjs/functions/evaluate/helpers.d.ts +9 -1
- package/types/cjs/functions/get-block-actions-handler.d.ts +2 -0
- package/types/cjs/functions/get-block-actions.d.ts +2 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/evaluate/evaluate.d.ts +1 -1
- package/types/esm/functions/evaluate/helpers.d.ts +9 -1
- package/types/esm/functions/get-block-actions-handler.d.ts +2 -0
- package/types/esm/functions/get-block-actions.d.ts +2 -0
- package/lib/browser/constants/sdk-name.cjs +0 -1
- package/lib/browser/constants/sdk-name.mjs +0 -14
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.cjs +0 -8
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.mjs +0 -40
- package/lib/edge/constants/sdk-name.cjs +0 -1
- package/lib/edge/constants/sdk-name.mjs +0 -14
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.cjs +0 -8
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.mjs +0 -40
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { get as
|
|
3
|
-
import { chooseBrowserOrServerEval as
|
|
4
|
-
import { parseCode as
|
|
5
|
-
const
|
|
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 =
|
|
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
|
|
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 =
|
|
21
|
+
const n = f(r.trim());
|
|
21
22
|
if (n)
|
|
22
|
-
return
|
|
23
|
+
return E({
|
|
23
24
|
...t,
|
|
24
25
|
...e
|
|
25
26
|
}, n);
|
|
26
|
-
const
|
|
27
|
-
code:
|
|
27
|
+
const l = {
|
|
28
|
+
code: v(r, {
|
|
28
29
|
isExpression: a
|
|
29
30
|
}),
|
|
30
|
-
builder:
|
|
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
|
|
39
|
+
return c(l);
|
|
39
40
|
} catch (u) {
|
|
40
|
-
|
|
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
|
-
|
|
48
|
-
|
|
48
|
+
G as evaluate,
|
|
49
|
+
f as getSimpleExpressionGetPath
|
|
49
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
2
|
-
import { isEditing as
|
|
3
|
-
import { getUserAttributes as
|
|
4
|
-
|
|
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:
|
|
7
|
-
event:
|
|
8
|
-
state:
|
|
7
|
+
context: s,
|
|
8
|
+
event: e,
|
|
9
|
+
state: i
|
|
9
10
|
}) => Object.entries({
|
|
10
|
-
state:
|
|
11
|
+
state: i,
|
|
11
12
|
Builder: r,
|
|
12
13
|
// legacy
|
|
13
14
|
builder: r,
|
|
14
|
-
context:
|
|
15
|
-
event:
|
|
16
|
-
}),
|
|
17
|
-
isEditing:
|
|
18
|
-
isBrowser:
|
|
19
|
-
isServer: !
|
|
20
|
-
getUserAttributes: () =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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:
|
|
27
|
-
rootSetState:
|
|
43
|
+
localState: s,
|
|
44
|
+
rootSetState: e
|
|
28
45
|
}) {
|
|
29
46
|
return new Proxy(r, {
|
|
30
|
-
get: (
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
33
|
-
const
|
|
34
|
-
return typeof
|
|
35
|
-
rootState:
|
|
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:
|
|
38
|
-
|
|
54
|
+
rootSetState: e ? (f) => {
|
|
55
|
+
i[u] = f, e(i);
|
|
39
56
|
} : void 0
|
|
40
|
-
}) :
|
|
57
|
+
}) : n;
|
|
41
58
|
},
|
|
42
|
-
set: (
|
|
43
|
-
if (
|
|
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
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
13
|
+
c as createEventHandler
|
|
13
14
|
};
|
package/lib/edge/init.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./functions/evaluate/should-force-browser-runtime-in-node.cjs");require("isolated-vm");require("./functions/evaluate/node-runtime/safeDynamicRequire.cjs");const r=i=>{e.shouldForceBrowserRuntimeInNode({shouldLogWarning:!0})};exports.initializeNodeRuntime=r;
|
package/lib/edge/init.mjs
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { shouldForceBrowserRuntimeInNode as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
import { shouldForceBrowserRuntimeInNode as o } from "./functions/evaluate/should-force-browser-runtime-in-node.mjs";
|
|
2
|
+
import "isolated-vm";
|
|
3
|
+
import "./functions/evaluate/node-runtime/safeDynamicRequire.mjs";
|
|
4
|
+
const n = (r) => {
|
|
5
|
+
o({
|
|
6
6
|
shouldLogWarning: !0
|
|
7
|
-
})
|
|
8
|
-
return;
|
|
9
|
-
const {
|
|
10
|
-
ivmIsolateOptions: i
|
|
11
|
-
} = o || {};
|
|
12
|
-
e(t, i);
|
|
7
|
+
});
|
|
13
8
|
};
|
|
14
9
|
export {
|
|
15
|
-
|
|
10
|
+
n as initializeNodeRuntime
|
|
16
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const
|
|
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
|
|
3
|
-
import { getBlockActions as
|
|
4
|
-
import { getBlockProperties as
|
|
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
|
|
7
|
-
|
|
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:
|
|
12
|
+
attributes: i({
|
|
12
13
|
block: t.block,
|
|
13
14
|
context: t.context
|
|
14
15
|
}),
|
|
15
|
-
actionAttributes:
|
|
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
|
-
|
|
35
|
+
d as default
|
|
29
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";const e=require("react/jsx-runtime"),
|
|
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
|
|
3
|
-
import { useState as
|
|
4
|
-
import { getBlockActions as
|
|
5
|
-
import { getBlockProperties as
|
|
6
|
-
import { isEditing as
|
|
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
|
|
10
|
-
import
|
|
11
|
-
function
|
|
12
|
-
var
|
|
13
|
-
|
|
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
|
-
...
|
|
17
|
+
...x({
|
|
17
18
|
block: t.block,
|
|
18
19
|
context: t.context
|
|
19
20
|
}),
|
|
20
|
-
...
|
|
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
|
|
36
|
+
function d() {
|
|
30
37
|
return t.wrapperProps;
|
|
31
38
|
}
|
|
32
|
-
return
|
|
33
|
-
}, [t.wrapperProps, (c = (
|
|
34
|
-
|
|
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
|
-
) }) :
|
|
43
|
-
|
|
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, { ...
|
|
57
|
+
) : /* @__PURE__ */ e(t.Wrapper, { ...d(), attributes: r(), children: t.children }) });
|
|
51
58
|
}
|
|
52
59
|
export {
|
|
53
|
-
|
|
60
|
+
y as default
|
|
54
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.24.1";exports.SDK_VERSION=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
2
|
-
import { get as
|
|
3
|
-
import { chooseBrowserOrServerEval as
|
|
4
|
-
import { parseCode as
|
|
5
|
-
const
|
|
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 =
|
|
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
|
|
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 =
|
|
21
|
+
const n = f(r.trim());
|
|
21
22
|
if (n)
|
|
22
|
-
return
|
|
23
|
+
return E({
|
|
23
24
|
...t,
|
|
24
25
|
...e
|
|
25
26
|
}, n);
|
|
26
|
-
const
|
|
27
|
-
code:
|
|
27
|
+
const l = {
|
|
28
|
+
code: v(r, {
|
|
28
29
|
isExpression: a
|
|
29
30
|
}),
|
|
30
|
-
builder:
|
|
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
|
|
39
|
+
return c(l);
|
|
39
40
|
} catch (u) {
|
|
40
|
-
|
|
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
|
-
|
|
48
|
-
|
|
48
|
+
G as evaluate,
|
|
49
|
+
f as getSimpleExpressionGetPath
|
|
49
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
2
|
-
import { isEditing as
|
|
3
|
-
import { getUserAttributes as
|
|
4
|
-
|
|
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:
|
|
7
|
-
event:
|
|
8
|
-
state:
|
|
7
|
+
context: s,
|
|
8
|
+
event: e,
|
|
9
|
+
state: i
|
|
9
10
|
}) => Object.entries({
|
|
10
|
-
state:
|
|
11
|
+
state: i,
|
|
11
12
|
Builder: r,
|
|
12
13
|
// legacy
|
|
13
14
|
builder: r,
|
|
14
|
-
context:
|
|
15
|
-
event:
|
|
16
|
-
}),
|
|
17
|
-
isEditing:
|
|
18
|
-
isBrowser:
|
|
19
|
-
isServer: !
|
|
20
|
-
getUserAttributes: () =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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:
|
|
27
|
-
rootSetState:
|
|
43
|
+
localState: s,
|
|
44
|
+
rootSetState: e
|
|
28
45
|
}) {
|
|
29
46
|
return new Proxy(r, {
|
|
30
|
-
get: (
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
33
|
-
const
|
|
34
|
-
return typeof
|
|
35
|
-
rootState:
|
|
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:
|
|
38
|
-
|
|
54
|
+
rootSetState: e ? (f) => {
|
|
55
|
+
i[u] = f, e(i);
|
|
39
56
|
} : void 0
|
|
40
|
-
}) :
|
|
57
|
+
}) : n;
|
|
41
58
|
},
|
|
42
|
-
set: (
|
|
43
|
-
if (
|
|
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
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
a as getBuilderGlobals,
|
|
69
|
+
B as getFunctionArguments,
|
|
70
|
+
c as parseCode
|
|
54
71
|
};
|