@builder.io/sdk-react-nextjs 0.23.2 → 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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.23.2";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.24.0";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.23.2";
1
+ const o = "0.24.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 o=require("./functions/evaluate/should-force-browser-runtime-in-node.cjs"),t=require("isolated-vm"),n=require("./functions/evaluate/node-runtime/node-runtime.cjs"),r=e=>{if(o.shouldForceBrowserRuntimeInNode({shouldLogWarning:!0}))return;const{ivmIsolateOptions:i}=e||{};n.setIvm(t,i)};exports.initializeNodeRuntime=r;
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;
@@ -1,16 +1,11 @@
1
- import { shouldForceBrowserRuntimeInNode as r } from "./functions/evaluate/should-force-browser-runtime-in-node.mjs";
2
- import t from "isolated-vm";
3
- import { setIvm as e } from "./functions/evaluate/node-runtime/node-runtime.mjs";
4
- const u = (o) => {
5
- if (r({
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
- u as initializeNodeRuntime
10
+ n as initializeNodeRuntime
16
11
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.23.2";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.24.0";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.23.2";
1
+ const o = "0.24.0";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
package/lib/edge/init.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions/evaluate/should-force-browser-runtime-in-node.cjs"),t=require("isolated-vm"),n=require("./functions/evaluate/node-runtime/node-runtime.cjs"),r=e=>{if(o.shouldForceBrowserRuntimeInNode({shouldLogWarning:!0}))return;const{ivmIsolateOptions:i}=e||{};n.setIvm(t,i)};exports.initializeNodeRuntime=r;
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 r } from "./functions/evaluate/should-force-browser-runtime-in-node.mjs";
2
- import t from "isolated-vm";
3
- import { setIvm as e } from "./functions/evaluate/node-runtime/node-runtime.mjs";
4
- const u = (o) => {
5
- if (r({
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
- u as initializeNodeRuntime
10
+ n as initializeNodeRuntime
16
11
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.23.2";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.24.0";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.23.2";
1
+ const o = "0.24.0";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../constants/sdk-name.cjs"),m=require("../../../helpers/logger.cjs"),A=require("../../fast-clone.cjs"),R=require("../../set.cjs"),M=require("../helpers.cjs"),k=require("./safeDynamicRequire.cjs"),g=t=>`bldr_${t}_sync`,b="BUILDER_SET_STATE",I="BUILDER_IVM",h=`
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 ${I}.Reference(value) : value;
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
- `,x=({code:t,args:e})=>{const u=e.map(([o])=>`var ${o} = refToProxy(${g(o)}); `).join("");return`
27
+ `,k=({code:t,args:e})=>{const l=e.map(([s])=>`var ${s} = refToProxy(${S(s)}); `).join("");return`
28
28
  ${h}
29
- ${u}
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 l=null,y=null;const C=(t,e={})=>{l||(l=t,E(e))},D=c.SDK_NAME==="@builder.io/sdk-react-nextjs"||c.SDK_NAME==="@builder.io/sdk-react"||c.SDK_NAME==="@builder.io/sdk-qwik"||c.SDK_NAME==="@builder.io/sdk-vue",S=()=>{try{if(l)return l;const e=k.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.
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 "${c.SDK_NAME}/node/init".`:""}
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)};function E(t={memoryLimit:128}){if(y)return y;const e=S(),o=new e.Isolate(t).createContextSync(),n=o.global;return n.setSync("global",n.derefInto()),n.setSync("log",function(...i){console.log(...i)}),n.setSync(I,e),y=o,o}const O=()=>E(),w=({code:t,builder:e,context:u,event:o,localState:n,rootSetState:i,rootState:a})=>{const _=S(),N=A.fastClone({...a,...n}),d=M.getFunctionArguments({builder:e,context:u,event:o,state:N}),f=O(),p=f.global;p.setSync(b,function(r,s){R.set(a,r,s),i==null||i(a)}),d.forEach(([r,s])=>{const j=typeof s=="object"?new _.Reference(r==="builder"?{...s,getUserAttributes:()=>s.getUserAttributes()}:s):null;p.setSync(g(r),j)});const T=x({code:t,args:d}),v=f.evalClosureSync(T);try{return JSON.parse(v)}catch{return v}};exports.runInNode=w;exports.setIvm=C;
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 c } from "../../../constants/sdk-name.mjs";
2
- import { logger as j, MSG_PREFIX as R } from "../../../helpers/logger.mjs";
3
- import { fastClone as x } from "../../fast-clone.mjs";
4
- import { set as k } from "../../set.mjs";
5
- import { getFunctionArguments as A } from "../helpers.mjs";
6
- import { safeDynamicRequire as h } from "./safeDynamicRequire.mjs";
7
- const v = (e) => `bldr_${e}_sync`, b = "BUILDER_SET_STATE", I = "BUILDER_IVM", w = `
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
- `, C = ({
34
- code: e,
35
- args: t
33
+ `, w = ({
34
+ code: t,
35
+ args: e
36
36
  }) => {
37
- const l = t.map(([o]) => `var ${o} = refToProxy(${v(o)}); `).join("");
37
+ const u = e.map(([c]) => `var ${c} = refToProxy(${v(c)}); `).join("");
38
38
  return `
39
- ${w}
40
- ${l}
39
+ ${O}
40
+ ${u}
41
41
  function theFunction() {
42
- ${e}
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 u = null, y = null;
55
- const V = (e, t = {}) => {
56
- u || (u = e, E(t));
57
- }, O = c === "@builder.io/sdk-react-nextjs" || c === "@builder.io/sdk-react" || c === "@builder.io/sdk-qwik" || c === "@builder.io/sdk-vue", g = () => {
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 (u)
60
- return u;
61
- const t = h("isolated-vm");
62
- if (t)
63
- return t;
64
- } catch (t) {
65
- j.error("isolated-vm import error.", t);
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 e = `${R}could not import \`isolated-vm\` module for safe script execution on a Node server.
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
- ${O ? `- import and call \`initializeNodeRuntime()\` from "${c}/node/init".` : ""}
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(e);
76
- };
77
- function E(e = {
78
- memoryLimit: 128
79
- }) {
80
- if (y)
81
- return y;
82
- const t = g(), o = new t.Isolate(e).createContextSync(), n = o.global;
83
- return n.setSync("global", n.derefInto()), n.setSync("log", function(...s) {
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 S = g(), _ = x({
97
- ...a,
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
- return JSON.parse(d);
123
- } catch {
124
- return d;
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
- B as runInNode,
129
- V as setIvm
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.23.2",
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.23.2";
1
+ export declare const SDK_VERSION = "0.24.0";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.23.2";
1
+ export declare const SDK_VERSION = "0.24.0";
@@ -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
- };