@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,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../../constants/sdk-name.cjs"),m=require("../../../helpers/logger.cjs"),j=require("../../fast-clone.cjs"),A=require("../../set.cjs"),R=require("../helpers.cjs"),M=require("./safeDynamicRequire.cjs"),S=t=>`bldr_${t}_sync`,b="BUILDER_SET_STATE",g="BUILDER_IVM",h=`
|
|
2
2
|
var refToProxy = (obj) => {
|
|
3
3
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
4
|
return obj;
|
|
@@ -15,7 +15,7 @@ var refToProxy = (obj) => {
|
|
|
15
15
|
return val;
|
|
16
16
|
},
|
|
17
17
|
set(target, key, value) {
|
|
18
|
-
const v = typeof value === 'object' ? new ${
|
|
18
|
+
const v = typeof value === 'object' ? new ${g}.Reference(value) : value;
|
|
19
19
|
obj.setSync(key, v);
|
|
20
20
|
${b}(key, value)
|
|
21
21
|
},
|
|
@@ -24,9 +24,9 @@ var refToProxy = (obj) => {
|
|
|
24
24
|
}
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
|
-
`,
|
|
27
|
+
`,k=({code:t,args:e})=>{const l=e.map(([s])=>`var ${s} = refToProxy(${S(s)}); `).join("");return`
|
|
28
28
|
${h}
|
|
29
|
-
${
|
|
29
|
+
${l}
|
|
30
30
|
function theFunction() {
|
|
31
31
|
${t}
|
|
32
32
|
}
|
|
@@ -38,11 +38,11 @@ if (typeof output === 'object' && output !== null) {
|
|
|
38
38
|
} else {
|
|
39
39
|
return output;
|
|
40
40
|
}
|
|
41
|
-
`};let
|
|
41
|
+
`};let u=null,I={memoryLimit:128};const O=(t,e)=>{u||(u=t,e&&(I=e))},D=i.SDK_NAME==="@builder.io/sdk-react-nextjs"||i.SDK_NAME==="@builder.io/sdk-react"||i.SDK_NAME==="@builder.io/sdk-qwik"||i.SDK_NAME==="@builder.io/sdk-vue",w=()=>{try{if(u)return u;const e=M.safeDynamicRequire("isolated-vm");if(e)return e}catch(e){m.logger.error("isolated-vm import error.",e)}const t=`${m.MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
42
42
|
|
|
43
43
|
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
44
44
|
|
|
45
|
-
${D?`- import and call \`initializeNodeRuntime()\` from "${
|
|
45
|
+
${D?`- import and call \`initializeNodeRuntime()\` from "${i.SDK_NAME}/node/init".`:""}
|
|
46
46
|
- add the following import: \`await import('isolated-vm')\`.
|
|
47
47
|
|
|
48
|
-
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;throw new Error(t)}
|
|
48
|
+
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;throw new Error(t)},$=({code:t,builder:e,context:l,event:s,localState:_,rootSetState:a,rootState:y})=>{const d=w();let c;try{c=new d.Isolate(I);const f=c.createContextSync(),n=f.global;n.setSync("global",n.derefInto()),n.setSync("log",function(...o){console.log(...o)}),n.setSync(g,d);const E=j.fastClone({...y,..._}),p=R.getFunctionArguments({builder:e,context:l,event:s,state:E});n.setSync(b,function(o,r){A.set(y,o,r),a==null||a(y)}),p.forEach(([o,r])=>{const T=typeof r=="object"?new d.Reference(o==="builder"?{...r,getUserAttributes:()=>r.getUserAttributes()}:r):null;n.setSync(S(o),T)});const N=k({code:t,args:p}),v=f.evalClosureSync(N);try{return JSON.parse(v)}catch{return v}}finally{if(c)try{c.dispose()}catch{}}};exports.runInNode=$;exports.setIvm=O;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { SDK_NAME as
|
|
2
|
-
import { logger as
|
|
3
|
-
import { fastClone as
|
|
4
|
-
import { set as
|
|
5
|
-
import { getFunctionArguments as
|
|
6
|
-
import { safeDynamicRequire as
|
|
7
|
-
const v = (
|
|
1
|
+
import { SDK_NAME as i } from "../../../constants/sdk-name.mjs";
|
|
2
|
+
import { logger as T, MSG_PREFIX as j } from "../../../helpers/logger.mjs";
|
|
3
|
+
import { fastClone as R } from "../../fast-clone.mjs";
|
|
4
|
+
import { set as h } from "../../set.mjs";
|
|
5
|
+
import { getFunctionArguments as k } from "../helpers.mjs";
|
|
6
|
+
import { safeDynamicRequire as A } from "./safeDynamicRequire.mjs";
|
|
7
|
+
const v = (t) => `bldr_${t}_sync`, b = "BUILDER_SET_STATE", I = "BUILDER_IVM", O = `
|
|
8
8
|
var refToProxy = (obj) => {
|
|
9
9
|
if (typeof obj !== 'object' || obj === null) {
|
|
10
10
|
return obj;
|
|
@@ -30,16 +30,16 @@ var refToProxy = (obj) => {
|
|
|
30
30
|
}
|
|
31
31
|
})
|
|
32
32
|
}
|
|
33
|
-
`,
|
|
34
|
-
code:
|
|
35
|
-
args:
|
|
33
|
+
`, w = ({
|
|
34
|
+
code: t,
|
|
35
|
+
args: e
|
|
36
36
|
}) => {
|
|
37
|
-
const
|
|
37
|
+
const u = e.map(([c]) => `var ${c} = refToProxy(${v(c)}); `).join("");
|
|
38
38
|
return `
|
|
39
|
-
${
|
|
40
|
-
${
|
|
39
|
+
${O}
|
|
40
|
+
${u}
|
|
41
41
|
function theFunction() {
|
|
42
|
-
${
|
|
42
|
+
${t}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const output = theFunction()
|
|
@@ -51,80 +51,86 @@ if (typeof output === 'object' && output !== null) {
|
|
|
51
51
|
}
|
|
52
52
|
`;
|
|
53
53
|
};
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
let l = null, g = {
|
|
55
|
+
memoryLimit: 128
|
|
56
|
+
};
|
|
57
|
+
const U = (t, e) => {
|
|
58
|
+
l || (l = t, e && (g = e));
|
|
59
|
+
}, $ = i === "@builder.io/sdk-react-nextjs" || i === "@builder.io/sdk-react" || i === "@builder.io/sdk-qwik" || i === "@builder.io/sdk-vue", x = () => {
|
|
58
60
|
try {
|
|
59
|
-
if (
|
|
60
|
-
return
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
64
|
-
} catch (
|
|
65
|
-
|
|
61
|
+
if (l)
|
|
62
|
+
return l;
|
|
63
|
+
const e = A("isolated-vm");
|
|
64
|
+
if (e)
|
|
65
|
+
return e;
|
|
66
|
+
} catch (e) {
|
|
67
|
+
T.error("isolated-vm import error.", e);
|
|
66
68
|
}
|
|
67
|
-
const
|
|
69
|
+
const t = `${j}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
68
70
|
|
|
69
71
|
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
70
72
|
|
|
71
|
-
${
|
|
73
|
+
${$ ? `- import and call \`initializeNodeRuntime()\` from "${i}/node/init".` : ""}
|
|
72
74
|
- add the following import: \`await import('isolated-vm')\`.
|
|
73
75
|
|
|
74
76
|
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
75
|
-
throw new Error(
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log(...s);
|
|
85
|
-
}), n.setSync(I, t), y = o, o;
|
|
86
|
-
}
|
|
87
|
-
const $ = () => E(), B = ({
|
|
88
|
-
code: e,
|
|
89
|
-
builder: t,
|
|
90
|
-
context: l,
|
|
91
|
-
event: o,
|
|
92
|
-
localState: n,
|
|
93
|
-
rootSetState: s,
|
|
94
|
-
rootState: a
|
|
77
|
+
throw new Error(t);
|
|
78
|
+
}, V = ({
|
|
79
|
+
code: t,
|
|
80
|
+
builder: e,
|
|
81
|
+
context: u,
|
|
82
|
+
event: c,
|
|
83
|
+
localState: S,
|
|
84
|
+
rootSetState: a,
|
|
85
|
+
rootState: y
|
|
95
86
|
}) => {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
...n
|
|
99
|
-
}), f = A({
|
|
100
|
-
builder: t,
|
|
101
|
-
context: l,
|
|
102
|
-
event: o,
|
|
103
|
-
state: _
|
|
104
|
-
}), m = $(), p = m.global;
|
|
105
|
-
p.setSync(b, function(r, i) {
|
|
106
|
-
k(a, r, i), s == null || s(a);
|
|
107
|
-
}), f.forEach(([r, i]) => {
|
|
108
|
-
const N = typeof i == "object" ? new S.Reference(
|
|
109
|
-
// workaround: methods with default values for arguments is not being cloned over
|
|
110
|
-
r === "builder" ? {
|
|
111
|
-
...i,
|
|
112
|
-
getUserAttributes: () => i.getUserAttributes()
|
|
113
|
-
} : i
|
|
114
|
-
) : null;
|
|
115
|
-
p.setSync(v(r), N);
|
|
116
|
-
});
|
|
117
|
-
const T = C({
|
|
118
|
-
code: e,
|
|
119
|
-
args: f
|
|
120
|
-
}), d = m.evalClosureSync(T);
|
|
87
|
+
const f = x();
|
|
88
|
+
let s;
|
|
121
89
|
try {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
90
|
+
s = new f.Isolate(g);
|
|
91
|
+
const p = s.createContextSync(), n = p.global;
|
|
92
|
+
n.setSync("global", n.derefInto()), n.setSync("log", function(...o) {
|
|
93
|
+
console.log(...o);
|
|
94
|
+
}), n.setSync(I, f);
|
|
95
|
+
const _ = R({
|
|
96
|
+
...y,
|
|
97
|
+
...S
|
|
98
|
+
}), m = k({
|
|
99
|
+
builder: e,
|
|
100
|
+
context: u,
|
|
101
|
+
event: c,
|
|
102
|
+
state: _
|
|
103
|
+
});
|
|
104
|
+
n.setSync(b, function(o, r) {
|
|
105
|
+
h(y, o, r), a == null || a(y);
|
|
106
|
+
}), m.forEach(([o, r]) => {
|
|
107
|
+
const N = typeof r == "object" ? new f.Reference(
|
|
108
|
+
// workaround: methods with default values for arguments is not being cloned over
|
|
109
|
+
o === "builder" ? {
|
|
110
|
+
...r,
|
|
111
|
+
getUserAttributes: () => r.getUserAttributes()
|
|
112
|
+
} : r
|
|
113
|
+
) : null;
|
|
114
|
+
n.setSync(v(o), N);
|
|
115
|
+
});
|
|
116
|
+
const E = w({
|
|
117
|
+
code: t,
|
|
118
|
+
args: m
|
|
119
|
+
}), d = p.evalClosureSync(E);
|
|
120
|
+
try {
|
|
121
|
+
return JSON.parse(d);
|
|
122
|
+
} catch {
|
|
123
|
+
return d;
|
|
124
|
+
}
|
|
125
|
+
} finally {
|
|
126
|
+
if (s)
|
|
127
|
+
try {
|
|
128
|
+
s.dispose();
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
125
131
|
}
|
|
126
132
|
};
|
|
127
133
|
export {
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
V as runInNode,
|
|
135
|
+
U as setIvm
|
|
130
136
|
};
|
|
@@ -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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react-nextjs",
|
|
3
3
|
"description": "Builder.io RSC SDK for NextJS App Directory",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.24.1",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.24.1";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EvaluatorArgs } from './helpers.js';
|
|
2
2
|
type EvalValue = unknown;
|
|
3
3
|
export declare const getSimpleExpressionGetPath: (code: string) => string;
|
|
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.js';
|
|
2
2
|
import { getUserAttributes } from '../track/helpers.js';
|
|
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, "context" | "builder" | "event"> & {
|
|
21
29
|
state: BuilderRenderState;
|
|
22
30
|
}) => [string, Event | BuilderRenderState | import("../../context/types.js").BuilderRenderContext | BuilderGlobals][];
|
|
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,7 +1,9 @@
|
|
|
1
1
|
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
2
|
import type { BuilderBlock } from '../types/builder-block.js';
|
|
3
|
+
import type { TrackingContext } from './evaluate/helpers.js';
|
|
3
4
|
type Options = {
|
|
4
5
|
block: BuilderBlock;
|
|
6
|
+
trackingContext?: TrackingContext;
|
|
5
7
|
} & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>;
|
|
6
8
|
type EventHandler = (event: Event) => any;
|
|
7
9
|
export declare const createEventHandler: (value: string, options: Options) => EventHandler;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
2
|
import type { BuilderBlock } from '../types/builder-block.js';
|
|
3
|
+
import type { TrackingContext } from './evaluate/helpers.js';
|
|
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 {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.24.1";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EvaluatorArgs } from './helpers.js';
|
|
2
2
|
type EvalValue = unknown;
|
|
3
3
|
export declare const getSimpleExpressionGetPath: (code: string) => string;
|
|
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.js';
|
|
2
2
|
import { getUserAttributes } from '../track/helpers.js';
|
|
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, "context" | "builder" | "event"> & {
|
|
21
29
|
state: BuilderRenderState;
|
|
22
30
|
}) => [string, Event | BuilderRenderState | import("../../context/types.js").BuilderRenderContext | BuilderGlobals][];
|
|
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,7 +1,9 @@
|
|
|
1
1
|
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
2
|
import type { BuilderBlock } from '../types/builder-block.js';
|
|
3
|
+
import type { TrackingContext } from './evaluate/helpers.js';
|
|
3
4
|
type Options = {
|
|
4
5
|
block: BuilderBlock;
|
|
6
|
+
trackingContext?: TrackingContext;
|
|
5
7
|
} & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>;
|
|
6
8
|
type EventHandler = (event: Event) => any;
|
|
7
9
|
export declare const createEventHandler: (value: string, options: Options) => EventHandler;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
2
|
import type { BuilderBlock } from '../types/builder-block.js';
|
|
3
|
+
import type { TrackingContext } from './evaluate/helpers.js';
|
|
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 {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./target.cjs"),t=(()=>{switch(e.TARGET){case"rsc":return"react-nextjs";case"reactNative":return"react-native";default:return e.TARGET}})(),r=`@builder.io/sdk-${t}`;exports.SDK_NAME=r;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TARGET as t } from "./target.mjs";
|
|
2
|
-
const e = (() => {
|
|
3
|
-
switch (t) {
|
|
4
|
-
case "rsc":
|
|
5
|
-
return "react-nextjs";
|
|
6
|
-
case "reactNative":
|
|
7
|
-
return "react-native";
|
|
8
|
-
default:
|
|
9
|
-
return t;
|
|
10
|
-
}
|
|
11
|
-
})(), c = `@builder.io/sdk-${e}`;
|
|
12
|
-
export {
|
|
13
|
-
c as SDK_NAME
|
|
14
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../constants/sdk-name.cjs"),l=require("../../../helpers/logger.cjs"),c=require("./safeDynamicRequire.cjs"),d="BUILDER_IVM";let n=null,s=null;const u=(t,e={})=>{n||(n=t,S(e))},m=o.SDK_NAME==="@builder.io/sdk-react-nextjs"||o.SDK_NAME==="@builder.io/sdk-react"||o.SDK_NAME==="@builder.io/sdk-qwik"||o.SDK_NAME==="@builder.io/sdk-vue",I=()=>{try{if(n)return n;const e=c.safeDynamicRequire("isolated-vm");if(e)return e}catch(e){l.logger.error("isolated-vm import error.",e)}const t=`${l.MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
2
|
-
|
|
3
|
-
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
4
|
-
|
|
5
|
-
${m?`- import and call \`initializeNodeRuntime()\` from "${o.SDK_NAME}/node/init".`:""}
|
|
6
|
-
- add the following import: \`await import('isolated-vm')\`.
|
|
7
|
-
|
|
8
|
-
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;throw new Error(t)};function S(t={memoryLimit:128}){if(s)return s;const e=I(),r=new e.Isolate(t).createContextSync(),i=r.global;return i.setSync("global",i.derefInto()),i.setSync("log",function(...a){console.log(...a)}),i.setSync(d,e),s=r,r}exports.setIvm=u;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { SDK_NAME as e } from "../../../constants/sdk-name.mjs";
|
|
2
|
-
import { logger as a, MSG_PREFIX as c } from "../../../helpers/logger.mjs";
|
|
3
|
-
import { safeDynamicRequire as d } from "./safeDynamicRequire.mjs";
|
|
4
|
-
const m = "BUILDER_IVM";
|
|
5
|
-
let n = null, l = null;
|
|
6
|
-
const S = (t, o = {}) => {
|
|
7
|
-
n || (n = t, f(o));
|
|
8
|
-
}, u = e === "@builder.io/sdk-react-nextjs" || e === "@builder.io/sdk-react" || e === "@builder.io/sdk-qwik" || e === "@builder.io/sdk-vue", I = () => {
|
|
9
|
-
try {
|
|
10
|
-
if (n)
|
|
11
|
-
return n;
|
|
12
|
-
const o = d("isolated-vm");
|
|
13
|
-
if (o)
|
|
14
|
-
return o;
|
|
15
|
-
} catch (o) {
|
|
16
|
-
a.error("isolated-vm import error.", o);
|
|
17
|
-
}
|
|
18
|
-
const t = `${c}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
19
|
-
|
|
20
|
-
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
21
|
-
|
|
22
|
-
${u ? `- import and call \`initializeNodeRuntime()\` from "${e}/node/init".` : ""}
|
|
23
|
-
- add the following import: \`await import('isolated-vm')\`.
|
|
24
|
-
|
|
25
|
-
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
26
|
-
throw new Error(t);
|
|
27
|
-
};
|
|
28
|
-
function f(t = {
|
|
29
|
-
memoryLimit: 128
|
|
30
|
-
}) {
|
|
31
|
-
if (l)
|
|
32
|
-
return l;
|
|
33
|
-
const o = I(), r = new o.Isolate(t).createContextSync(), i = r.global;
|
|
34
|
-
return i.setSync("global", i.derefInto()), i.setSync("log", function(...s) {
|
|
35
|
-
console.log(...s);
|
|
36
|
-
}), i.setSync(m, o), l = r, r;
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
S as setIvm
|
|
40
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./target.cjs"),t=(()=>{switch(e.TARGET){case"rsc":return"react-nextjs";case"reactNative":return"react-native";default:return e.TARGET}})(),r=`@builder.io/sdk-${t}`;exports.SDK_NAME=r;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TARGET as t } from "./target.mjs";
|
|
2
|
-
const e = (() => {
|
|
3
|
-
switch (t) {
|
|
4
|
-
case "rsc":
|
|
5
|
-
return "react-nextjs";
|
|
6
|
-
case "reactNative":
|
|
7
|
-
return "react-native";
|
|
8
|
-
default:
|
|
9
|
-
return t;
|
|
10
|
-
}
|
|
11
|
-
})(), c = `@builder.io/sdk-${e}`;
|
|
12
|
-
export {
|
|
13
|
-
c as SDK_NAME
|
|
14
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../constants/sdk-name.cjs"),l=require("../../../helpers/logger.cjs"),c=require("./safeDynamicRequire.cjs"),d="BUILDER_IVM";let n=null,s=null;const u=(t,e={})=>{n||(n=t,S(e))},m=o.SDK_NAME==="@builder.io/sdk-react-nextjs"||o.SDK_NAME==="@builder.io/sdk-react"||o.SDK_NAME==="@builder.io/sdk-qwik"||o.SDK_NAME==="@builder.io/sdk-vue",I=()=>{try{if(n)return n;const e=c.safeDynamicRequire("isolated-vm");if(e)return e}catch(e){l.logger.error("isolated-vm import error.",e)}const t=`${l.MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
2
|
-
|
|
3
|
-
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
4
|
-
|
|
5
|
-
${m?`- import and call \`initializeNodeRuntime()\` from "${o.SDK_NAME}/node/init".`:""}
|
|
6
|
-
- add the following import: \`await import('isolated-vm')\`.
|
|
7
|
-
|
|
8
|
-
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;throw new Error(t)};function S(t={memoryLimit:128}){if(s)return s;const e=I(),r=new e.Isolate(t).createContextSync(),i=r.global;return i.setSync("global",i.derefInto()),i.setSync("log",function(...a){console.log(...a)}),i.setSync(d,e),s=r,r}exports.setIvm=u;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { SDK_NAME as e } from "../../../constants/sdk-name.mjs";
|
|
2
|
-
import { logger as a, MSG_PREFIX as c } from "../../../helpers/logger.mjs";
|
|
3
|
-
import { safeDynamicRequire as d } from "./safeDynamicRequire.mjs";
|
|
4
|
-
const m = "BUILDER_IVM";
|
|
5
|
-
let n = null, l = null;
|
|
6
|
-
const S = (t, o = {}) => {
|
|
7
|
-
n || (n = t, f(o));
|
|
8
|
-
}, u = e === "@builder.io/sdk-react-nextjs" || e === "@builder.io/sdk-react" || e === "@builder.io/sdk-qwik" || e === "@builder.io/sdk-vue", I = () => {
|
|
9
|
-
try {
|
|
10
|
-
if (n)
|
|
11
|
-
return n;
|
|
12
|
-
const o = d("isolated-vm");
|
|
13
|
-
if (o)
|
|
14
|
-
return o;
|
|
15
|
-
} catch (o) {
|
|
16
|
-
a.error("isolated-vm import error.", o);
|
|
17
|
-
}
|
|
18
|
-
const t = `${c}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
19
|
-
|
|
20
|
-
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
21
|
-
|
|
22
|
-
${u ? `- import and call \`initializeNodeRuntime()\` from "${e}/node/init".` : ""}
|
|
23
|
-
- add the following import: \`await import('isolated-vm')\`.
|
|
24
|
-
|
|
25
|
-
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
26
|
-
throw new Error(t);
|
|
27
|
-
};
|
|
28
|
-
function f(t = {
|
|
29
|
-
memoryLimit: 128
|
|
30
|
-
}) {
|
|
31
|
-
if (l)
|
|
32
|
-
return l;
|
|
33
|
-
const o = I(), r = new o.Isolate(t).createContextSync(), i = r.global;
|
|
34
|
-
return i.setSync("global", i.derefInto()), i.setSync("log", function(...s) {
|
|
35
|
-
console.log(...s);
|
|
36
|
-
}), i.setSync(m, o), l = r, r;
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
S as setIvm
|
|
40
|
-
};
|