@builder.io/sdk-react-nextjs 0.16.12 → 0.16.14
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/blocks/columns/columns.cjs +2 -2
- package/lib/browser/blocks/columns/columns.mjs +2 -2
- package/lib/browser/blocks/image/image.cjs +4 -4
- package/lib/browser/blocks/image/image.mjs +25 -25
- package/lib/browser/components/awaiter.cjs +1 -0
- package/lib/browser/components/awaiter.mjs +10 -0
- package/lib/browser/components/block/components/interactive-element.cjs +1 -1
- package/lib/browser/components/block/components/interactive-element.mjs +19 -9
- package/lib/browser/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/browser/components/blocks/blocks-wrapper.mjs +5 -5
- package/lib/browser/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +114 -139
- package/lib/browser/components/content/content.cjs +1 -1
- package/lib/browser/components/content/content.mjs +62 -43
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/functions/evaluate/browser-runtime/browser.cjs +1 -1
- package/lib/browser/functions/evaluate/browser-runtime/browser.mjs +19 -45
- package/lib/browser/functions/evaluate/choose-eval.cjs +1 -1
- package/lib/browser/functions/evaluate/choose-eval.mjs +5 -3
- package/lib/browser/functions/evaluate/helpers.cjs +1 -1
- package/lib/browser/functions/evaluate/helpers.mjs +50 -24
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.cjs +3 -3
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.mjs +7 -7
- package/lib/browser/functions/evaluate/should-force-browser-runtime-in-node.cjs +1 -1
- package/lib/browser/functions/evaluate/should-force-browser-runtime-in-node.mjs +8 -6
- package/lib/browser/init.cjs +1 -1
- package/lib/browser/init.mjs +11 -6
- package/lib/edge/blocks/columns/columns.cjs +2 -2
- package/lib/edge/blocks/columns/columns.mjs +2 -2
- package/lib/edge/blocks/image/image.cjs +4 -4
- package/lib/edge/blocks/image/image.mjs +25 -25
- package/lib/edge/components/awaiter.cjs +1 -0
- package/lib/edge/components/awaiter.mjs +10 -0
- package/lib/edge/components/block/components/interactive-element.cjs +1 -1
- package/lib/edge/components/block/components/interactive-element.mjs +19 -9
- package/lib/edge/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/edge/components/blocks/blocks-wrapper.mjs +5 -5
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +114 -139
- package/lib/edge/components/content/content.cjs +1 -1
- package/lib/edge/components/content/content.mjs +62 -43
- package/lib/edge/constants/builder-registered-components.cjs +1 -1
- package/lib/edge/constants/builder-registered-components.mjs +1 -1
- package/lib/edge/constants/extra-components.cjs +1 -1
- package/lib/edge/constants/extra-components.mjs +1 -1
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/functions/evaluate/browser-runtime/browser.cjs +1 -1
- package/lib/edge/functions/evaluate/browser-runtime/browser.mjs +19 -45
- package/lib/edge/functions/evaluate/choose-eval.cjs +1 -1
- package/lib/edge/functions/evaluate/choose-eval.mjs +4 -2
- package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.cjs +8 -10
- package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.mjs +70 -53
- package/lib/edge/functions/evaluate/helpers.cjs +1 -1
- package/lib/edge/functions/evaluate/helpers.mjs +50 -24
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.cjs +3 -3
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.mjs +7 -7
- package/lib/edge/functions/evaluate/should-force-browser-runtime-in-node.cjs +1 -1
- package/lib/edge/functions/evaluate/should-force-browser-runtime-in-node.mjs +8 -6
- package/lib/edge/init.cjs +1 -1
- package/lib/edge/init.mjs +11 -6
- package/lib/node/blocks/columns/columns.cjs +2 -2
- package/lib/node/blocks/columns/columns.mjs +2 -2
- package/lib/node/blocks/image/image.cjs +4 -4
- package/lib/node/blocks/image/image.mjs +25 -25
- package/lib/node/components/awaiter.cjs +1 -0
- package/lib/node/components/awaiter.mjs +10 -0
- package/lib/node/components/block/components/interactive-element.cjs +1 -1
- package/lib/node/components/block/components/interactive-element.mjs +19 -9
- package/lib/node/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/node/components/blocks/blocks-wrapper.mjs +5 -5
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +114 -139
- package/lib/node/components/content/content.cjs +1 -1
- package/lib/node/components/content/content.mjs +62 -43
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/functions/evaluate/browser-runtime/browser.cjs +1 -1
- package/lib/node/functions/evaluate/browser-runtime/browser.mjs +19 -45
- package/lib/node/functions/evaluate/choose-eval.cjs +1 -1
- package/lib/node/functions/evaluate/choose-eval.mjs +4 -2
- package/lib/node/functions/evaluate/helpers.cjs +1 -1
- package/lib/node/functions/evaluate/helpers.mjs +50 -24
- package/lib/node/functions/evaluate/node-runtime/node-runtime.cjs +9 -9
- package/lib/node/functions/evaluate/node-runtime/node-runtime.mjs +26 -26
- package/lib/node/functions/evaluate/should-force-browser-runtime-in-node.cjs +1 -1
- package/lib/node/functions/evaluate/should-force-browser-runtime-in-node.mjs +8 -6
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +11 -6
- package/package.json +1 -1
- package/types/cjs/components/awaiter.d.ts +14 -0
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/context/component-reference-types.d.ts +4 -0
- package/types/cjs/context/types.d.ts +2 -1
- package/types/cjs/functions/evaluate/browser-runtime/browser.d.ts +0 -6
- package/types/cjs/functions/evaluate/helpers.d.ts +5 -0
- package/types/cjs/functions/evaluate/should-force-browser-runtime-in-node.d.ts +3 -1
- package/types/esm/components/awaiter.d.ts +14 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/context/component-reference-types.d.ts +4 -0
- package/types/esm/context/types.d.ts +2 -1
- package/types/esm/functions/evaluate/browser-runtime/browser.d.ts +0 -6
- package/types/esm/functions/evaluate/helpers.d.ts +5 -0
- package/types/esm/functions/evaluate/should-force-browser-runtime-in-node.d.ts +3 -1
|
@@ -1,51 +1,25 @@
|
|
|
1
|
-
import { getFunctionArguments as
|
|
2
|
-
const
|
|
3
|
-
code:
|
|
4
|
-
builder:
|
|
5
|
-
context:
|
|
6
|
-
event:
|
|
7
|
-
localState:
|
|
8
|
-
rootSetState:
|
|
9
|
-
rootState:
|
|
1
|
+
import { getFunctionArguments as m, flattenState as i } from "../helpers.mjs";
|
|
2
|
+
const f = ({
|
|
3
|
+
code: r,
|
|
4
|
+
builder: e,
|
|
5
|
+
context: o,
|
|
6
|
+
event: s,
|
|
7
|
+
localState: u,
|
|
8
|
+
rootSetState: a,
|
|
9
|
+
rootState: c
|
|
10
10
|
}) => {
|
|
11
|
-
const
|
|
12
|
-
builder:
|
|
13
|
-
context:
|
|
14
|
-
event:
|
|
15
|
-
state:
|
|
16
|
-
rootState:
|
|
17
|
-
localState:
|
|
18
|
-
rootSetState:
|
|
11
|
+
const n = m({
|
|
12
|
+
builder: e,
|
|
13
|
+
context: o,
|
|
14
|
+
event: s,
|
|
15
|
+
state: i({
|
|
16
|
+
rootState: c,
|
|
17
|
+
localState: u,
|
|
18
|
+
rootSetState: a
|
|
19
19
|
})
|
|
20
20
|
});
|
|
21
|
-
return new Function(...
|
|
21
|
+
return new Function(...n.map(([t]) => t), r)(...n.map(([, t]) => t));
|
|
22
22
|
};
|
|
23
|
-
function t({
|
|
24
|
-
rootState: e,
|
|
25
|
-
localState: u,
|
|
26
|
-
rootSetState: s
|
|
27
|
-
}) {
|
|
28
|
-
return new Proxy(e, {
|
|
29
|
-
get: (i, n) => {
|
|
30
|
-
if (u && n in u)
|
|
31
|
-
return u[n];
|
|
32
|
-
const r = i[n];
|
|
33
|
-
return typeof r == "object" && r !== null ? t({
|
|
34
|
-
rootState: r,
|
|
35
|
-
localState: void 0,
|
|
36
|
-
rootSetState: s ? (f) => {
|
|
37
|
-
i[n] = f, s(i);
|
|
38
|
-
} : void 0
|
|
39
|
-
}) : r;
|
|
40
|
-
},
|
|
41
|
-
set: (i, n, r) => {
|
|
42
|
-
if (u && n in u)
|
|
43
|
-
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
44
|
-
return i[n] = r, s == null || s(i), !0;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
23
|
export {
|
|
49
|
-
|
|
50
|
-
d as runInBrowser
|
|
24
|
+
f as runInBrowser
|
|
51
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../is-browser.cjs"),o=require("./browser-runtime/browser.cjs"),s=require("./node-runtime/node-runtime.cjs"),n=require("./should-force-browser-runtime-in-node.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../is-browser.cjs"),o=require("./browser-runtime/browser.cjs"),s=require("./node-runtime/node-runtime.cjs"),n=require("./should-force-browser-runtime-in-node.cjs"),u=e=>r.isBrowser()||n.shouldForceBrowserRuntimeInNode({shouldLogWarning:!0})?o.runInBrowser(e):s.runInNode(e);exports.chooseBrowserOrServerEval=u;
|
|
@@ -2,7 +2,9 @@ import { isBrowser as o } from "../is-browser.mjs";
|
|
|
2
2
|
import { runInBrowser as e } from "./browser-runtime/browser.mjs";
|
|
3
3
|
import { runInNode as m } from "./node-runtime/node-runtime.mjs";
|
|
4
4
|
import { shouldForceBrowserRuntimeInNode as n } from "./should-force-browser-runtime-in-node.mjs";
|
|
5
|
-
const
|
|
5
|
+
const p = (r) => o() || n({
|
|
6
|
+
shouldLogWarning: !0
|
|
7
|
+
}) ? e(r) : m(r);
|
|
6
8
|
export {
|
|
7
|
-
|
|
9
|
+
p as chooseBrowserOrServerEval
|
|
8
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../is-browser.cjs"),d=require("../is-editing.cjs"),c=require("../track/helpers.cjs"),g=({builder:e,context:r,event:n,state:s})=>Object.entries({state:s,Builder:e,builder:e,context:r,event:n}),f=()=>({isEditing:d.isEditing(),isBrowser:u.isBrowser(),isServer:!u.isBrowser(),getUserAttributes:()=>c.getUserAttributes()}),w=(e,{isExpression:r=!0})=>r&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e;function o({rootState:e,localState:r,rootSetState:n}){return new Proxy(e,{get:(s,t)=>{if(r&&t in r)return r[t];const i=s[t];return typeof i=="object"&&i!==null?o({rootState:i,localState:void 0,rootSetState:n?l=>{s[t]=l,n(s)}:void 0}):i},set:(s,t,i)=>{if(r&&t in r)throw new Error("Writing to local state is not allowed as it is read-only.");return s[t]=i,n==null||n(s),!0}})}exports.flattenState=o;exports.getBuilderGlobals=f;exports.getFunctionArguments=g;exports.parseCode=w;
|
|
@@ -1,28 +1,54 @@
|
|
|
1
|
-
import { isBrowser as
|
|
2
|
-
import { isEditing as
|
|
3
|
-
import { getUserAttributes as
|
|
4
|
-
const
|
|
5
|
-
builder:
|
|
6
|
-
context:
|
|
7
|
-
event:
|
|
8
|
-
state:
|
|
1
|
+
import { isBrowser as u } from "../is-browser.mjs";
|
|
2
|
+
import { isEditing as f } from "../is-editing.mjs";
|
|
3
|
+
import { getUserAttributes as d } from "../track/helpers.mjs";
|
|
4
|
+
const w = ({
|
|
5
|
+
builder: r,
|
|
6
|
+
context: n,
|
|
7
|
+
event: i,
|
|
8
|
+
state: e
|
|
9
9
|
}) => Object.entries({
|
|
10
|
-
state:
|
|
11
|
-
Builder:
|
|
10
|
+
state: e,
|
|
11
|
+
Builder: r,
|
|
12
12
|
// legacy
|
|
13
|
-
builder:
|
|
14
|
-
context:
|
|
15
|
-
event:
|
|
16
|
-
}),
|
|
17
|
-
isEditing:
|
|
18
|
-
isBrowser:
|
|
19
|
-
isServer: !
|
|
20
|
-
getUserAttributes: () =>
|
|
21
|
-
}),
|
|
22
|
-
isExpression:
|
|
23
|
-
}) => /* we disable this for cases where we definitely don't want a return */
|
|
13
|
+
builder: r,
|
|
14
|
+
context: n,
|
|
15
|
+
event: i
|
|
16
|
+
}), b = () => ({
|
|
17
|
+
isEditing: f(),
|
|
18
|
+
isBrowser: u(),
|
|
19
|
+
isServer: !u(),
|
|
20
|
+
getUserAttributes: () => d()
|
|
21
|
+
}), v = (r, {
|
|
22
|
+
isExpression: n = !0
|
|
23
|
+
}) => /* we disable this for cases where we definitely don't want a return */ n && !(r.includes(";") || r.includes(" return ") || r.trim().startsWith("return ")) ? `return (${r});` : r;
|
|
24
|
+
function l({
|
|
25
|
+
rootState: r,
|
|
26
|
+
localState: n,
|
|
27
|
+
rootSetState: i
|
|
28
|
+
}) {
|
|
29
|
+
return new Proxy(r, {
|
|
30
|
+
get: (e, s) => {
|
|
31
|
+
if (n && s in n)
|
|
32
|
+
return n[s];
|
|
33
|
+
const t = e[s];
|
|
34
|
+
return typeof t == "object" && t !== null ? l({
|
|
35
|
+
rootState: t,
|
|
36
|
+
localState: void 0,
|
|
37
|
+
rootSetState: i ? (o) => {
|
|
38
|
+
e[s] = o, i(e);
|
|
39
|
+
} : void 0
|
|
40
|
+
}) : t;
|
|
41
|
+
},
|
|
42
|
+
set: (e, s, t) => {
|
|
43
|
+
if (n && s in n)
|
|
44
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
45
|
+
return e[s] = t, i == null || i(e), !0;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
24
49
|
export {
|
|
25
|
-
l as
|
|
26
|
-
|
|
27
|
-
|
|
50
|
+
l as flattenState,
|
|
51
|
+
b as getBuilderGlobals,
|
|
52
|
+
w as getFunctionArguments,
|
|
53
|
+
v as parseCode
|
|
28
54
|
};
|
|
@@ -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"),A=require("../../fast-clone.cjs"),R=require("../../set.cjs"),x=require("../helpers.cjs"),M=require("./safeDynamicRequire.cjs"),g=t=>`bldr_${t}_sync`,b="BUILDER_SET_STATE",I="BUILDER_IVM",k=`
|
|
2
2
|
var refToProxy = (obj) => {
|
|
3
3
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
4
|
return obj;
|
|
@@ -15,18 +15,18 @@ 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 ${I}.Reference(value) : value;
|
|
19
19
|
obj.setSync(key, v);
|
|
20
|
-
${
|
|
20
|
+
${b}(key, value)
|
|
21
21
|
},
|
|
22
22
|
deleteProperty(target, key) {
|
|
23
23
|
obj.deleteSync(key);
|
|
24
24
|
}
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
|
-
`,
|
|
28
|
-
${
|
|
29
|
-
${
|
|
27
|
+
`,h=({code:t,args:e})=>{const u=e.map(([o])=>`var ${o} = refToProxy(${g(o)}); `).join("");return`
|
|
28
|
+
${k}
|
|
29
|
+
${u}
|
|
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 a=null,y=null;const C=(t,e={})=>{a=t,E(e)},
|
|
41
|
+
`};let a=null,y=null;const C=(t,e={})=>{a=t,E(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",S=()=>{try{if(a)return a;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
|
-
${
|
|
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}){const e=S(),o=new e.Isolate(t).createContextSync(),n=o.global;return n.setSync("global",n.derefInto()),n.setSync("log",function(...c){console.log(...c)}),n.setSync(
|
|
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}){const e=S(),o=new e.Isolate(t).createContextSync(),n=o.global;return n.setSync("global",n.derefInto()),n.setSync("log",function(...c){console.log(...c)}),n.setSync(I,e),y=o,o}const O=()=>y||E(),w=({code:t,builder:e,context:u,event:o,localState:n,rootSetState:c,rootState:l})=>{const _=S(),N=A.fastClone({...l,...n}),d=x.getFunctionArguments({builder:e,context:u,event:o,state:N}),f=O(),p=f.global;p.setSync(b,function(r,s){R.set(l,r,s),c==null||c(l)}),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=h({code:t,args:d}),v=f.evalClosureSync(T);try{return JSON.parse(v)}catch{return v}};exports.runInNode=w;exports.setIvm=C;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { SDK_NAME as
|
|
1
|
+
import { SDK_NAME as s } from "../../../constants/sdk-name.mjs";
|
|
2
2
|
import { logger as j, MSG_PREFIX as x } from "../../../helpers/logger.mjs";
|
|
3
3
|
import { fastClone as R } from "../../fast-clone.mjs";
|
|
4
|
-
import { set as
|
|
5
|
-
import { getFunctionArguments as
|
|
6
|
-
import { safeDynamicRequire as
|
|
7
|
-
const v = (e) => `bldr_${e}_sync`,
|
|
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 = `
|
|
8
8
|
var refToProxy = (obj) => {
|
|
9
9
|
if (typeof obj !== 'object' || obj === null) {
|
|
10
10
|
return obj;
|
|
@@ -21,9 +21,9 @@ var refToProxy = (obj) => {
|
|
|
21
21
|
return val;
|
|
22
22
|
},
|
|
23
23
|
set(target, key, value) {
|
|
24
|
-
const v = typeof value === 'object' ? new ${
|
|
24
|
+
const v = typeof value === 'object' ? new ${I}.Reference(value) : value;
|
|
25
25
|
obj.setSync(key, v);
|
|
26
|
-
${
|
|
26
|
+
${b}(key, value)
|
|
27
27
|
},
|
|
28
28
|
deleteProperty(target, key) {
|
|
29
29
|
obj.deleteSync(key);
|
|
@@ -34,10 +34,10 @@ var refToProxy = (obj) => {
|
|
|
34
34
|
code: e,
|
|
35
35
|
args: t
|
|
36
36
|
}) => {
|
|
37
|
-
const
|
|
37
|
+
const l = t.map(([o]) => `var ${o} = refToProxy(${v(o)}); `).join("");
|
|
38
38
|
return `
|
|
39
39
|
${w}
|
|
40
|
-
${
|
|
40
|
+
${l}
|
|
41
41
|
function theFunction() {
|
|
42
42
|
${e}
|
|
43
43
|
}
|
|
@@ -54,11 +54,11 @@ if (typeof output === 'object' && output !== null) {
|
|
|
54
54
|
let a = null, y = null;
|
|
55
55
|
const V = (e, t = {}) => {
|
|
56
56
|
a = e, E(t);
|
|
57
|
-
}, O =
|
|
57
|
+
}, O = s === "@builder.io/sdk-react-nextjs" || s === "@builder.io/sdk-react" || s === "@builder.io/sdk-qwik" || s === "@builder.io/sdk-vue", g = () => {
|
|
58
58
|
try {
|
|
59
59
|
if (a)
|
|
60
60
|
return a;
|
|
61
|
-
const t =
|
|
61
|
+
const t = h("isolated-vm");
|
|
62
62
|
if (t)
|
|
63
63
|
return t;
|
|
64
64
|
} catch (t) {
|
|
@@ -68,7 +68,7 @@ const V = (e, t = {}) => {
|
|
|
68
68
|
|
|
69
69
|
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
70
70
|
|
|
71
|
-
${O ? `- import and call \`initializeNodeRuntime()\` from "${
|
|
71
|
+
${O ? `- import and call \`initializeNodeRuntime()\` from "${s}/node/init".` : ""}
|
|
72
72
|
- add the following import: \`await import('isolated-vm')\`.
|
|
73
73
|
|
|
74
74
|
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
@@ -78,37 +78,37 @@ function E(e = {
|
|
|
78
78
|
memoryLimit: 128
|
|
79
79
|
}) {
|
|
80
80
|
const t = g(), o = new t.Isolate(e).createContextSync(), n = o.global;
|
|
81
|
-
return n.setSync("global", n.derefInto()), n.setSync("log", function(...
|
|
82
|
-
console.log(...
|
|
83
|
-
}), n.setSync(
|
|
81
|
+
return n.setSync("global", n.derefInto()), n.setSync("log", function(...c) {
|
|
82
|
+
console.log(...c);
|
|
83
|
+
}), n.setSync(I, t), y = o, o;
|
|
84
84
|
}
|
|
85
85
|
const $ = () => y || E(), B = ({
|
|
86
86
|
code: e,
|
|
87
87
|
builder: t,
|
|
88
|
-
context:
|
|
88
|
+
context: l,
|
|
89
89
|
event: o,
|
|
90
90
|
localState: n,
|
|
91
|
-
rootSetState:
|
|
91
|
+
rootSetState: c,
|
|
92
92
|
rootState: u
|
|
93
93
|
}) => {
|
|
94
94
|
const S = g(), _ = R({
|
|
95
95
|
...u,
|
|
96
96
|
...n
|
|
97
|
-
}), f =
|
|
97
|
+
}), f = A({
|
|
98
98
|
builder: t,
|
|
99
|
-
context:
|
|
99
|
+
context: l,
|
|
100
100
|
event: o,
|
|
101
101
|
state: _
|
|
102
102
|
}), m = $(), p = m.global;
|
|
103
|
-
p.setSync(
|
|
104
|
-
|
|
105
|
-
}), f.forEach(([r,
|
|
106
|
-
const N = typeof
|
|
103
|
+
p.setSync(b, function(r, i) {
|
|
104
|
+
k(u, r, i), c == null || c(u);
|
|
105
|
+
}), f.forEach(([r, i]) => {
|
|
106
|
+
const N = typeof i == "object" ? new S.Reference(
|
|
107
107
|
// workaround: methods with default values for arguments is not being cloned over
|
|
108
108
|
r === "builder" ? {
|
|
109
|
-
...
|
|
110
|
-
getUserAttributes: () =>
|
|
111
|
-
} :
|
|
109
|
+
...i,
|
|
110
|
+
getUserAttributes: () => i.getUserAttributes()
|
|
111
|
+
} : i
|
|
112
112
|
) : null;
|
|
113
113
|
p.setSync(v(r), N);
|
|
114
114
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../helpers/logger.cjs"),t=require("../is-node-runtime.cjs"),a=({shouldLogWarning:o})=>{var e;if(!t.isNodeRuntime())return!1;const s=process.arch==="arm64",r=process.version.startsWith("v20"),n=(e=process.env.NODE_OPTIONS)==null?void 0:e.includes("--no-node-snapshot");return s&&r&&!n?(o&&i.logger.log("Skipping usage of `isolated-vm` to avoid crashes in Node v20 on an arm64 machine.\n If you would like to use the `isolated-vm` package on this machine, please provide the `NODE_OPTIONS=--no-node-snapshot` config to your Node process.\n See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.\n "),!0):!1};exports.shouldForceBrowserRuntimeInNode=a;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { logger as n } from "../../helpers/logger.mjs";
|
|
2
|
-
import { isNodeRuntime as
|
|
3
|
-
const
|
|
2
|
+
import { isNodeRuntime as t } from "../is-node-runtime.mjs";
|
|
3
|
+
const d = ({
|
|
4
|
+
shouldLogWarning: e
|
|
5
|
+
}) => {
|
|
4
6
|
var o;
|
|
5
|
-
if (!
|
|
7
|
+
if (!t())
|
|
6
8
|
return !1;
|
|
7
|
-
const
|
|
8
|
-
return
|
|
9
|
+
const s = process.arch === "arm64", r = process.version.startsWith("v20"), i = (o = process.env.NODE_OPTIONS) == null ? void 0 : o.includes("--no-node-snapshot");
|
|
10
|
+
return s && r && !i ? (e && n.log("Skipping usage of `isolated-vm` to avoid crashes in Node v20 on an arm64 machine.\n If you would like to use the `isolated-vm` package on this machine, please provide the `NODE_OPTIONS=--no-node-snapshot` config to your Node process.\n See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.\n "), !0) : !1;
|
|
9
11
|
};
|
|
10
12
|
export {
|
|
11
|
-
|
|
13
|
+
d as shouldForceBrowserRuntimeInNode
|
|
12
14
|
};
|
package/lib/node/init.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("isolated-vm"),n=require("./functions/evaluate/node-runtime/node-runtime.cjs"),
|
|
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;
|
package/lib/node/init.mjs
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { shouldForceBrowserRuntimeInNode as r } from "./functions/evaluate/should-force-browser-runtime-in-node.mjs";
|
|
1
2
|
import t from "isolated-vm";
|
|
2
|
-
import { setIvm as
|
|
3
|
-
const
|
|
3
|
+
import { setIvm as e } from "./functions/evaluate/node-runtime/node-runtime.mjs";
|
|
4
|
+
const u = (o) => {
|
|
5
|
+
if (r({
|
|
6
|
+
shouldLogWarning: !0
|
|
7
|
+
}))
|
|
8
|
+
return;
|
|
4
9
|
const {
|
|
5
|
-
ivmIsolateOptions:
|
|
6
|
-
} =
|
|
7
|
-
|
|
10
|
+
ivmIsolateOptions: i
|
|
11
|
+
} = o || {};
|
|
12
|
+
e(t, i);
|
|
8
13
|
};
|
|
9
14
|
export {
|
|
10
|
-
|
|
15
|
+
u as initializeNodeRuntime
|
|
11
16
|
};
|
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.16.
|
|
4
|
+
"version": "0.16.14",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Placeholder component to be overridden by specific SDKs.
|
|
4
|
+
* Allows to dynamically import components.
|
|
5
|
+
*/
|
|
6
|
+
type AwaiterProps = {
|
|
7
|
+
load: () => Promise<any>;
|
|
8
|
+
props?: any;
|
|
9
|
+
attributes?: any;
|
|
10
|
+
fallback?: any;
|
|
11
|
+
children?: any;
|
|
12
|
+
};
|
|
13
|
+
declare function Awaiter(props: AwaiterProps): React.JSX.Element;
|
|
14
|
+
export default Awaiter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.16.
|
|
1
|
+
export declare const SDK_VERSION = "0.16.14";
|
|
@@ -3,9 +3,10 @@ import type { ApiVersion } from '../types/api-version.js';
|
|
|
3
3
|
import type { BuilderContent } from '../types/builder-content.js';
|
|
4
4
|
import type { ComponentInfo } from '../types/components.js';
|
|
5
5
|
import type { Dictionary, Nullable } from '../types/typescript.js';
|
|
6
|
+
import type { ComponentReference } from './component-reference-types.js';
|
|
6
7
|
import type { ExtraContextTypes } from './extra-context-types.js';
|
|
7
8
|
export type RegisteredComponent = ComponentInfo & {
|
|
8
|
-
component:
|
|
9
|
+
component: ComponentReference;
|
|
9
10
|
};
|
|
10
11
|
export type RegisteredComponents = Dictionary<RegisteredComponent>;
|
|
11
12
|
export type BuilderRenderState = Record<string, unknown>;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import type { BuilderRenderState } from '../../../context/types.js';
|
|
2
1
|
import type { ExecutorArgs } from '../helpers.js';
|
|
3
2
|
export declare const runInBrowser: ({ code, builder, context, event, localState, rootSetState, rootState }: ExecutorArgs) => any;
|
|
4
|
-
export declare function flattenState({ rootState, localState, rootSetState }: {
|
|
5
|
-
rootState: Record<string | symbol, any>;
|
|
6
|
-
localState: Record<string | symbol, any> | undefined;
|
|
7
|
-
rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
|
|
8
|
-
}): BuilderRenderState;
|
|
@@ -23,3 +23,8 @@ export declare const getFunctionArguments: ({ builder, context, event, state }:
|
|
|
23
23
|
}) => [string, Event | BuilderRenderState | import("../../context/types.js").BuilderRenderContext | BuilderGlobals][];
|
|
24
24
|
export declare const getBuilderGlobals: () => BuilderGlobals;
|
|
25
25
|
export declare const parseCode: (code: string, { isExpression }: Pick<EvaluatorArgs, 'isExpression'>) => string;
|
|
26
|
+
export declare function flattenState({ rootState, localState, rootSetState }: {
|
|
27
|
+
rootState: Record<string | symbol, any>;
|
|
28
|
+
localState: Record<string | symbol, any> | undefined;
|
|
29
|
+
rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
|
|
30
|
+
}): BuilderRenderState;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Placeholder component to be overridden by specific SDKs.
|
|
4
|
+
* Allows to dynamically import components.
|
|
5
|
+
*/
|
|
6
|
+
type AwaiterProps = {
|
|
7
|
+
load: () => Promise<any>;
|
|
8
|
+
props?: any;
|
|
9
|
+
attributes?: any;
|
|
10
|
+
fallback?: any;
|
|
11
|
+
children?: any;
|
|
12
|
+
};
|
|
13
|
+
declare function Awaiter(props: AwaiterProps): React.JSX.Element;
|
|
14
|
+
export default Awaiter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.16.
|
|
1
|
+
export declare const SDK_VERSION = "0.16.14";
|
|
@@ -3,9 +3,10 @@ import type { ApiVersion } from '../types/api-version.js';
|
|
|
3
3
|
import type { BuilderContent } from '../types/builder-content.js';
|
|
4
4
|
import type { ComponentInfo } from '../types/components.js';
|
|
5
5
|
import type { Dictionary, Nullable } from '../types/typescript.js';
|
|
6
|
+
import type { ComponentReference } from './component-reference-types.js';
|
|
6
7
|
import type { ExtraContextTypes } from './extra-context-types.js';
|
|
7
8
|
export type RegisteredComponent = ComponentInfo & {
|
|
8
|
-
component:
|
|
9
|
+
component: ComponentReference;
|
|
9
10
|
};
|
|
10
11
|
export type RegisteredComponents = Dictionary<RegisteredComponent>;
|
|
11
12
|
export type BuilderRenderState = Record<string, unknown>;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import type { BuilderRenderState } from '../../../context/types.js';
|
|
2
1
|
import type { ExecutorArgs } from '../helpers.js';
|
|
3
2
|
export declare const runInBrowser: ({ code, builder, context, event, localState, rootSetState, rootState }: ExecutorArgs) => any;
|
|
4
|
-
export declare function flattenState({ rootState, localState, rootSetState }: {
|
|
5
|
-
rootState: Record<string | symbol, any>;
|
|
6
|
-
localState: Record<string | symbol, any> | undefined;
|
|
7
|
-
rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
|
|
8
|
-
}): BuilderRenderState;
|
|
@@ -23,3 +23,8 @@ export declare const getFunctionArguments: ({ builder, context, event, state }:
|
|
|
23
23
|
}) => [string, Event | BuilderRenderState | import("../../context/types.js").BuilderRenderContext | BuilderGlobals][];
|
|
24
24
|
export declare const getBuilderGlobals: () => BuilderGlobals;
|
|
25
25
|
export declare const parseCode: (code: string, { isExpression }: Pick<EvaluatorArgs, 'isExpression'>) => string;
|
|
26
|
+
export declare function flattenState({ rootState, localState, rootSetState }: {
|
|
27
|
+
rootState: Record<string | symbol, any>;
|
|
28
|
+
localState: Record<string | symbol, any> | undefined;
|
|
29
|
+
rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
|
|
30
|
+
}): BuilderRenderState;
|