@builder.io/sdk-react-nextjs 0.23.0 → 0.24.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.
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/init.cjs +1 -1
- package/lib/browser/init.mjs +7 -12
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/init.cjs +1 -1
- package/lib/edge/init.mjs +7 -12
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- 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/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/types/input.d.ts +1 -1
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/types/input.d.ts +1 -1
- 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 +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.0";exports.SDK_VERSION=e;
|
package/lib/browser/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/browser/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 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.0";exports.SDK_VERSION=e;
|
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 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.0";exports.SDK_VERSION=e;
|
|
@@ -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
|
};
|
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.0",
|
|
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.0";
|
|
@@ -3,7 +3,7 @@ export interface Input {
|
|
|
3
3
|
name: string;
|
|
4
4
|
/** A friendlier name to show in the UI if the component prop name is not ideal for end users */
|
|
5
5
|
friendlyName?: string;
|
|
6
|
-
/**
|
|
6
|
+
/** A description to show in the UI to give guidance on how to use this input */
|
|
7
7
|
description?: string;
|
|
8
8
|
/** A default value to use */
|
|
9
9
|
defaultValue?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.24.0";
|
|
@@ -3,7 +3,7 @@ export interface Input {
|
|
|
3
3
|
name: string;
|
|
4
4
|
/** A friendlier name to show in the UI if the component prop name is not ideal for end users */
|
|
5
5
|
friendlyName?: string;
|
|
6
|
-
/**
|
|
6
|
+
/** A description to show in the UI to give guidance on how to use this input */
|
|
7
7
|
description?: string;
|
|
8
8
|
/** A default value to use */
|
|
9
9
|
defaultValue?: any;
|
|
@@ -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
|
-
};
|