@builder.io/sdk-vue 2.0.20 → 2.0.21
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/{awaiter-A9QVJBD9.cjs → awaiter-63wFxDc-.cjs} +1 -1
- package/lib/browser/{awaiter-jLgWnSTO.js → awaiter-wFAQUD8u.js} +1 -1
- package/lib/browser/{block-styles-McsYN1Hd.js → block-styles-e9UJWxRw.js} +1 -1
- package/lib/browser/{block-styles-FLI6qMZg.cjs → block-styles-w3CYR9qS.cjs} +1 -1
- package/lib/browser/{block-wrapper-kIbAHG8K.js → block-wrapper-BBK1LMQ8.js} +3 -3
- package/lib/browser/{block-wrapper-c1TRGGdm.cjs → block-wrapper-KE-bUIi7.cjs} +1 -1
- package/lib/browser/{component-ref-VsUS3j2W.js → component-ref-cecMbUuX.js} +3 -3
- package/lib/browser/{component-ref-t_X6BYoD.cjs → component-ref-e6CG1TqL.cjs} +1 -1
- package/lib/browser/components/content/components/enable-editor.vue.d.ts +0 -7
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/functions/evaluate/browser-runtime/browser.d.ts +0 -6
- package/lib/browser/functions/evaluate/helpers.d.ts +5 -0
- package/lib/browser/{get-block-properties-Ub4OGrZU.cjs → get-block-properties-8qBDZMKr.cjs} +1 -1
- package/lib/browser/{get-block-properties-pnQ6T89t.js → get-block-properties-JZrAY1r_.js} +1 -1
- package/lib/browser/{index-IkCq97zU.js → index-ei0E4zOL.js} +249 -270
- package/lib/browser/{index-G94Y3yOE.cjs → index-uR3yr3o2.cjs} +15 -15
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/{repeated-block-9kzlJZ0z.js → repeated-block-4KouNbyE.js} +2 -2
- package/lib/browser/{repeated-block-phJGhJDz.cjs → repeated-block-5kGcO6DI.cjs} +1 -1
- package/lib/edge/{awaiter-qkwHnyG4.cjs → awaiter-aq8paHrs.cjs} +1 -1
- package/lib/edge/{awaiter-EaEHpSME.js → awaiter-byTF6qeD.js} +1 -1
- package/lib/edge/{block-styles-e5rHDnez.js → block-styles-8MRmenjP.js} +1 -1
- package/lib/edge/{block-styles-dBm-UB6s.cjs → block-styles-sHjSbOMY.cjs} +1 -1
- package/lib/edge/{block-wrapper-XFAJUGmy.cjs → block-wrapper-ilLh_PHh.cjs} +1 -1
- package/lib/edge/{block-wrapper-IsmLQCso.js → block-wrapper-rzB4thH4.js} +3 -3
- package/lib/edge/{component-ref-VkKlvDcE.cjs → component-ref-FJL2g6D2.cjs} +1 -1
- package/lib/edge/{component-ref-mDQskFmn.js → component-ref-hkYDlUjG.js} +3 -3
- package/lib/edge/components/content/components/enable-editor.vue.d.ts +0 -7
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/functions/evaluate/browser-runtime/browser.d.ts +0 -6
- package/lib/edge/functions/evaluate/helpers.d.ts +5 -0
- package/lib/edge/{get-block-properties-FTpxQBNr.cjs → get-block-properties-aM96dauJ.cjs} +1 -1
- package/lib/edge/{get-block-properties-jWWYZFYS.js → get-block-properties-cbYhtG2B.js} +1 -1
- package/lib/edge/index-Nw62yGCU.cjs +184 -0
- package/lib/edge/{index-a1uEIlXu.js → index-s36DlX8g.js} +1377 -1380
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/{node/repeated-block-opGUN59c.cjs → edge/repeated-block-wdJ005G3.cjs} +1 -1
- package/lib/edge/{repeated-block-WbUp3X7n.js → repeated-block-zOlg6ACd.js} +2 -2
- package/lib/node/{awaiter-nnMnOtUG.cjs → awaiter-Fsn-BZdK.cjs} +1 -1
- package/lib/node/{awaiter-bSGzxUtO.js → awaiter-c00-BKl8.js} +1 -1
- package/lib/node/{block-styles-nafXA7XU.cjs → block-styles-dNkK6XUk.cjs} +1 -1
- package/lib/node/{block-styles-z1hRu_oN.js → block-styles-y32fRgui.js} +2 -2
- package/lib/node/{block-wrapper-7Zyz-IHk.cjs → block-wrapper-9SHqyGhh.cjs} +1 -1
- package/lib/node/{block-wrapper-VbshFnwD.js → block-wrapper-Gb1-_hO0.js} +3 -3
- package/lib/node/{component-ref-0qWwbS8J.js → component-ref-9ri0cWhO.js} +3 -3
- package/lib/node/{component-ref-pMpl8Ppd.cjs → component-ref-LAJelZZi.cjs} +1 -1
- package/lib/node/components/content/components/enable-editor.vue.d.ts +0 -7
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/functions/evaluate/browser-runtime/browser.d.ts +0 -6
- package/lib/node/functions/evaluate/helpers.d.ts +5 -0
- package/lib/node/{get-block-properties-3bo9EXiT.cjs → get-block-properties-XKVJQeGu.cjs} +1 -1
- package/lib/node/{get-block-properties-7k5SVVoM.js → get-block-properties-hbwsLjcS.js} +2 -2
- package/lib/node/{index-m2Te0zyE.cjs → index-eLulgxIT.cjs} +25 -25
- package/lib/node/{index-arpbCDNz.js → index-owOkjqS8.js} +490 -537
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +7 -7
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +1 -1
- package/lib/{edge/repeated-block--9pU5oBU.cjs → node/repeated-block-keRWtfEG.cjs} +1 -1
- package/lib/node/{repeated-block-7xPIdLvm.js → repeated-block-xs28_Dw4.js} +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-cm1lg4FM.cjs → should-force-browser-runtime-in-node-k58tZzl7.cjs} +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-Hy3G5eB4.js → should-force-browser-runtime-in-node-o45oecPI.js} +61 -34
- package/package.json +1 -1
- package/lib/edge/index-wbH9RC9d.cjs +0 -186
package/lib/node/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-eLulgxIT.cjs"),t=require("./should-force-browser-runtime-in-node-k58tZzl7.cjs");exports.Blocks=e.Blocks;exports.BuilderContext=e.BuilderContext;exports.Button=e.Button;exports.Columns=e.Columns;exports.Content=e.ContentVariants;exports.Fragment=e.Fragment;exports.Image=e.Image;exports.Section=e.Section;exports.Symbol=e.Symbol;exports.Text=e.Text;exports.Video=e.Video;exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;exports.isEditing=t.isEditing;
|
package/lib/node/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as t, i as a, j as r, C as o, m as i, F as n, I as c, S as g, k as m, T as l, V as u, v as d, o as p, u as C, x as f, y as
|
|
2
|
-
import {
|
|
1
|
+
import { l as t, i as a, j as r, C as o, m as i, F as n, I as c, S as g, k as m, T as l, V as u, v as d, o as p, u as C, x as f, y as h, p as x, n as B, r as E, s as S, q as b, t as k } from "./index-owOkjqS8.js";
|
|
2
|
+
import { h as P } from "./should-force-browser-runtime-in-node-o45oecPI.js";
|
|
3
3
|
export {
|
|
4
4
|
t as Blocks,
|
|
5
5
|
a as BuilderContext,
|
|
@@ -16,12 +16,12 @@ export {
|
|
|
16
16
|
p as createRegisterComponentMessage,
|
|
17
17
|
C as fetchBuilderProps,
|
|
18
18
|
f as fetchEntries,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
h as fetchOneEntry,
|
|
20
|
+
x as getBuilderSearchParams,
|
|
21
21
|
P as isEditing,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
B as isPreviewing,
|
|
23
|
+
E as register,
|
|
24
|
+
S as setEditorSettings,
|
|
25
25
|
b as subscribeToEditor,
|
|
26
26
|
k as track
|
|
27
27
|
};
|
package/lib/node/init.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./should-force-browser-runtime-in-node-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./should-force-browser-runtime-in-node-k58tZzl7.cjs"),t=require("isolated-vm"),n=i=>{if(e.shouldForceBrowserRuntimeInNode({shouldLogWarning:!0}))return;const{ivmIsolateOptions:o}=i||{};e.setIvm(t,o)};exports.initializeNodeRuntime=n;
|
package/lib/node/init.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),t=require("./index-eLulgxIT.cjs"),r=()=>Promise.resolve().then(()=>require("./index-eLulgxIT.cjs")).then(e=>e.block).then(e=>e.default).catch(e=>{throw console.error("Error while attempting to dynamically import component Block at ../block.vue",e),e}),c=o.defineComponent({name:"repeated-block",components:{Block:o.defineAsyncComponent(r)},props:["repeatContext","block","registeredComponents","linkComponent"],data(){return{store:this.repeatContext}},provide(){const e=this;return{[t.BuilderContext.key]:e.store}}});function s(e,i,p,a,m,d){const n=o.resolveComponent("Block");return o.openBlock(),o.createBlock(n,{block:e.block,context:e.store,registeredComponents:e.registeredComponents,linkComponent:e.linkComponent},null,8,["block","context","registeredComponents","linkComponent"])}const l=t._export_sfc(c,[["render",s]]);exports.default=l;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as t, defineAsyncComponent as n, resolveComponent as r, openBlock as c, createBlock as p } from "vue";
|
|
2
|
-
import { i as s, d as l } from "./index-
|
|
3
|
-
const i = () => import("./index-
|
|
2
|
+
import { i as s, d as l } from "./index-owOkjqS8.js";
|
|
3
|
+
const i = () => import("./index-owOkjqS8.js").then((o) => o.A).then((o) => o.default).catch((o) => {
|
|
4
4
|
throw console.error(
|
|
5
5
|
"Error while attempting to dynamically import component Block at ../block.vue",
|
|
6
6
|
o
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const node_module=require("node:module");var _documentCurrentScript=typeof document<"u"?document.currentScript:null;const TARGET="vue",MSG_PREFIX="[Builder.io]: ",logger={log:(...e)=>console.log(MSG_PREFIX,...e),error:(...e)=>console.error(MSG_PREFIX,...e),warn:(...e)=>console.warn(MSG_PREFIX,...e),debug:(...e)=>console.debug(MSG_PREFIX,...e)};function isBrowser(){return typeof window<"u"&&typeof document<"u"}const convertSearchParamsToQueryObject=e=>{const t={};return e.forEach((o,n)=>{t[n]=o}),t},normalizeSearchParams=e=>e instanceof URLSearchParams?convertSearchParamsToQueryObject(e):e,getSearchString=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function isIframe(){return isBrowser()&&window.self!==window.top}function isEditing(e){return isIframe()&&getSearchString(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const getLocation=()=>{if(isBrowser()){const e=new URL(location.href);return e.pathname===""&&(e.pathname="/"),e}else return console.warn("Cannot get location for tracking in non-browser environment"),null},getUserAgent=()=>typeof navigator=="object"&&navigator.userAgent||"",getUserAttributes=()=>{const e=getUserAgent(),t={Android(){return e.match(/Android/i)},BlackBerry(){return e.match(/BlackBerry/i)},iOS(){return e.match(/iPhone|iPod/i)},Opera(){return e.match(/Opera Mini/i)},Windows(){return e.match(/IEMobile/i)||e.match(/WPDesktop/i)},any(){return t.Android()||t.BlackBerry()||t.iOS()||t.Opera()||t.Windows()||TARGET==="reactNative"}},o=e.match(/Tablet|iPad/i),n=getLocation();return{urlPath:n==null?void 0:n.pathname,host:(n==null?void 0:n.host)||(n==null?void 0:n.hostname),device:o?"tablet":t.any()?"mobile":"desktop"}},getFunctionArguments=({builder:e,context:t,event:o,state:n})=>Object.entries({state:n,Builder:e,builder:e,context:t,event:o}),getBuilderGlobals=()=>({isEditing:isEditing(),isBrowser:isBrowser(),isServer:!isBrowser(),getUserAttributes:()=>getUserAttributes()}),parseCode=(e,{isExpression:t=!0})=>t&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e,SDK_NAME_FOR_TARGET=(()=>{switch(TARGET){case"rsc":return"react-nextjs";case"reactNative":return"react-native";default:return TARGET}})(),SDK_NAME=`@builder.io/sdk-${SDK_NAME_FOR_TARGET}`,fastClone=e=>JSON.parse(JSON.stringify(e)),set=(e,t,o)=>{if(Object(e)!==e)return e;const n=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g);return n.slice(0,-1).reduce((r,s,i)=>Object(r[s])===r[s]?r[s]:r[s]=Math.abs(Number(n[i+1]))>>0===+n[i+1]?[]:{},e)[n[n.length-1]]=o,e},noop=()=>{};let safeDynamicRequire=noop;try{safeDynamicRequire=node_module.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:_documentCurrentScript&&_documentCurrentScript.src||new URL("should-force-browser-runtime-in-node-
|
|
1
|
+
"use strict";const node_module=require("node:module");var _documentCurrentScript=typeof document<"u"?document.currentScript:null;const TARGET="vue",MSG_PREFIX="[Builder.io]: ",logger={log:(...e)=>console.log(MSG_PREFIX,...e),error:(...e)=>console.error(MSG_PREFIX,...e),warn:(...e)=>console.warn(MSG_PREFIX,...e),debug:(...e)=>console.debug(MSG_PREFIX,...e)};function isBrowser(){return typeof window<"u"&&typeof document<"u"}const convertSearchParamsToQueryObject=e=>{const t={};return e.forEach((o,n)=>{t[n]=o}),t},normalizeSearchParams=e=>e instanceof URLSearchParams?convertSearchParamsToQueryObject(e):e,getSearchString=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function isIframe(){return isBrowser()&&window.self!==window.top}function isEditing(e){return isIframe()&&getSearchString(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const getLocation=()=>{if(isBrowser()){const e=new URL(location.href);return e.pathname===""&&(e.pathname="/"),e}else return console.warn("Cannot get location for tracking in non-browser environment"),null},getUserAgent=()=>typeof navigator=="object"&&navigator.userAgent||"",getUserAttributes=()=>{const e=getUserAgent(),t={Android(){return e.match(/Android/i)},BlackBerry(){return e.match(/BlackBerry/i)},iOS(){return e.match(/iPhone|iPod/i)},Opera(){return e.match(/Opera Mini/i)},Windows(){return e.match(/IEMobile/i)||e.match(/WPDesktop/i)},any(){return t.Android()||t.BlackBerry()||t.iOS()||t.Opera()||t.Windows()||TARGET==="reactNative"}},o=e.match(/Tablet|iPad/i),n=getLocation();return{urlPath:n==null?void 0:n.pathname,host:(n==null?void 0:n.host)||(n==null?void 0:n.hostname),device:o?"tablet":t.any()?"mobile":"desktop"}},getFunctionArguments=({builder:e,context:t,event:o,state:n})=>Object.entries({state:n,Builder:e,builder:e,context:t,event:o}),getBuilderGlobals=()=>({isEditing:isEditing(),isBrowser:isBrowser(),isServer:!isBrowser(),getUserAttributes:()=>getUserAttributes()}),parseCode=(e,{isExpression:t=!0})=>t&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e;function flattenState({rootState:e,localState:t,rootSetState:o}){return new Proxy(e,{get:(n,r)=>{if(t&&r in t)return t[r];const s=n[r];return typeof s=="object"&&s!==null?flattenState({rootState:s,localState:void 0,rootSetState:o?i=>{n[r]=i,o(n)}:void 0}):s},set:(n,r,s)=>{if(t&&r in t)throw new Error("Writing to local state is not allowed as it is read-only.");return n[r]=s,o==null||o(n),!0}})}const SDK_NAME_FOR_TARGET=(()=>{switch(TARGET){case"rsc":return"react-nextjs";case"reactNative":return"react-native";default:return TARGET}})(),SDK_NAME=`@builder.io/sdk-${SDK_NAME_FOR_TARGET}`,fastClone=e=>JSON.parse(JSON.stringify(e)),set=(e,t,o)=>{if(Object(e)!==e)return e;const n=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g);return n.slice(0,-1).reduce((r,s,i)=>Object(r[s])===r[s]?r[s]:r[s]=Math.abs(Number(n[i+1]))>>0===+n[i+1]?[]:{},e)[n[n.length-1]]=o,e},noop=()=>{};let safeDynamicRequire=noop;try{safeDynamicRequire=node_module.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:_documentCurrentScript&&_documentCurrentScript.src||new URL("should-force-browser-runtime-in-node-k58tZzl7.cjs",document.baseURI).href)}catch(error){try{safeDynamicRequire=eval("require")}catch(e){}}const getSyncValName=e=>`bldr_${e}_sync`,BUILDER_SET_STATE_NAME="BUILDER_SET_STATE",INJECTED_IVM_GLOBAL="BUILDER_IVM",REF_TO_PROXY_FN=`
|
|
2
2
|
var refToProxy = (obj) => {
|
|
3
3
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
4
|
return obj;
|
|
@@ -45,4 +45,4 @@ if (typeof output === 'object' && output !== null) {
|
|
|
45
45
|
${SHOULD_MENTION_INITIALIZE_SCRIPT?`- import and call \`initializeNodeRuntime()\` from "${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(e)};function setIsolateContext(e={memoryLimit:128}){const t=getIvm(),n=new t.Isolate(e).createContextSync(),r=n.global;return r.setSync("global",r.derefInto()),r.setSync("log",function(...s){console.log(...s)}),r.setSync(INJECTED_IVM_GLOBAL,t),IVM_CONTEXT=n,n}const getIsolateContext=()=>IVM_CONTEXT||setIsolateContext(),runInNode=({code:e,builder:t,context:o,event:n,localState:r,rootSetState:s,rootState:i})=>{const
|
|
48
|
+
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;throw new Error(e)};function setIsolateContext(e={memoryLimit:128}){const t=getIvm(),n=new t.Isolate(e).createContextSync(),r=n.global;return r.setSync("global",r.derefInto()),r.setSync("log",function(...s){console.log(...s)}),r.setSync(INJECTED_IVM_GLOBAL,t),IVM_CONTEXT=n,n}const getIsolateContext=()=>IVM_CONTEXT||setIsolateContext(),runInNode=({code:e,builder:t,context:o,event:n,localState:r,rootSetState:s,rootState:i})=>{const m=getIvm(),g=fastClone({...i,...r}),u=getFunctionArguments({builder:t,context:o,event:n,state:g}),l=getIsolateContext(),d=l.global;d.setSync(BUILDER_SET_STATE_NAME,function(c,a){set(i,c,a),s==null||s(i)}),u.forEach(([c,a])=>{const E=typeof a=="object"?new m.Reference(c==="builder"?{...a,getUserAttributes:()=>a.getUserAttributes()}:a):null;d.setSync(getSyncValName(c),E)});const p=processCode({code:e,args:u}),f=l.evalClosureSync(p);try{return JSON.parse(f)}catch{return f}},checkIsDefined=e=>e!=null;function isNodeRuntime(){var e;return typeof process<"u"&&checkIsDefined((e=process==null?void 0:process.versions)==null?void 0:e.node)}const shouldForceBrowserRuntimeInNode=({shouldLogWarning:e})=>{var r;if(!isNodeRuntime())return!1;const t=process.arch==="arm64",o=process.version.startsWith("v20"),n=(r=process.env.NODE_OPTIONS)==null?void 0:r.includes("--no-node-snapshot");return t&&o&&!n?(e&&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.TARGET=TARGET;exports.checkIsDefined=checkIsDefined;exports.fastClone=fastClone;exports.flattenState=flattenState;exports.getBuilderGlobals=getBuilderGlobals;exports.getFunctionArguments=getFunctionArguments;exports.getSearchString=getSearchString;exports.getUserAttributes=getUserAttributes;exports.isBrowser=isBrowser;exports.isEditing=isEditing;exports.logger=logger;exports.normalizeSearchParams=normalizeSearchParams;exports.parseCode=parseCode;exports.runInNode=runInNode;exports.set=set;exports.setIvm=setIvm;exports.shouldForceBrowserRuntimeInNode=shouldForceBrowserRuntimeInNode;
|
|
@@ -10,8 +10,8 @@ function isBrowser() {
|
|
|
10
10
|
}
|
|
11
11
|
const convertSearchParamsToQueryObject = (e) => {
|
|
12
12
|
const t = {};
|
|
13
|
-
return e.forEach((
|
|
14
|
-
t[n] =
|
|
13
|
+
return e.forEach((r, n) => {
|
|
14
|
+
t[n] = r;
|
|
15
15
|
}), t;
|
|
16
16
|
}, normalizeSearchParams = (e) => e instanceof URLSearchParams ? convertSearchParamsToQueryObject(e) : e, getSearchString = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
|
|
17
17
|
function isIframe() {
|
|
@@ -47,16 +47,16 @@ const getLocation = () => {
|
|
|
47
47
|
any() {
|
|
48
48
|
return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || TARGET === "reactNative";
|
|
49
49
|
}
|
|
50
|
-
},
|
|
50
|
+
}, r = e.match(/Tablet|iPad/i), n = getLocation();
|
|
51
51
|
return {
|
|
52
52
|
urlPath: n == null ? void 0 : n.pathname,
|
|
53
53
|
host: (n == null ? void 0 : n.host) || (n == null ? void 0 : n.hostname),
|
|
54
|
-
device:
|
|
54
|
+
device: r ? "tablet" : t.any() ? "mobile" : "desktop"
|
|
55
55
|
};
|
|
56
56
|
}, getFunctionArguments = ({
|
|
57
57
|
builder: e,
|
|
58
58
|
context: t,
|
|
59
|
-
event:
|
|
59
|
+
event: r,
|
|
60
60
|
state: n
|
|
61
61
|
}) => Object.entries({
|
|
62
62
|
state: n,
|
|
@@ -64,7 +64,7 @@ const getLocation = () => {
|
|
|
64
64
|
// legacy
|
|
65
65
|
builder: e,
|
|
66
66
|
context: t,
|
|
67
|
-
event:
|
|
67
|
+
event: r
|
|
68
68
|
}), getBuilderGlobals = () => ({
|
|
69
69
|
isEditing: isEditing(),
|
|
70
70
|
isBrowser: isBrowser(),
|
|
@@ -72,7 +72,33 @@ const getLocation = () => {
|
|
|
72
72
|
getUserAttributes: () => getUserAttributes()
|
|
73
73
|
}), parseCode = (e, {
|
|
74
74
|
isExpression: t = !0
|
|
75
|
-
}) => /* we disable this for cases where we definitely don't want a return */ t && !(e.includes(";") || e.includes(" return ") || e.trim().startsWith("return ")) ? `return (${e});` : e
|
|
75
|
+
}) => /* we disable this for cases where we definitely don't want a return */ t && !(e.includes(";") || e.includes(" return ") || e.trim().startsWith("return ")) ? `return (${e});` : e;
|
|
76
|
+
function flattenState({
|
|
77
|
+
rootState: e,
|
|
78
|
+
localState: t,
|
|
79
|
+
rootSetState: r
|
|
80
|
+
}) {
|
|
81
|
+
return new Proxy(e, {
|
|
82
|
+
get: (n, o) => {
|
|
83
|
+
if (t && o in t)
|
|
84
|
+
return t[o];
|
|
85
|
+
const s = n[o];
|
|
86
|
+
return typeof s == "object" && s !== null ? flattenState({
|
|
87
|
+
rootState: s,
|
|
88
|
+
localState: void 0,
|
|
89
|
+
rootSetState: r ? (i) => {
|
|
90
|
+
n[o] = i, r(n);
|
|
91
|
+
} : void 0
|
|
92
|
+
}) : s;
|
|
93
|
+
},
|
|
94
|
+
set: (n, o, s) => {
|
|
95
|
+
if (t && o in t)
|
|
96
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
97
|
+
return n[o] = s, r == null || r(n), !0;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const SDK_NAME_FOR_TARGET = (() => {
|
|
76
102
|
switch (TARGET) {
|
|
77
103
|
case "rsc":
|
|
78
104
|
return "react-nextjs";
|
|
@@ -81,11 +107,11 @@ const getLocation = () => {
|
|
|
81
107
|
default:
|
|
82
108
|
return TARGET;
|
|
83
109
|
}
|
|
84
|
-
})(), SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`, fastClone = (e) => JSON.parse(JSON.stringify(e)), set = (e, t,
|
|
110
|
+
})(), SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`, fastClone = (e) => JSON.parse(JSON.stringify(e)), set = (e, t, r) => {
|
|
85
111
|
if (Object(e) !== e)
|
|
86
112
|
return e;
|
|
87
113
|
const n = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
|
|
88
|
-
return n.slice(0, -1).reduce((
|
|
114
|
+
return n.slice(0, -1).reduce((o, s, i) => Object(o[s]) === o[s] ? o[s] : o[s] = Math.abs(Number(n[i + 1])) >> 0 === +n[i + 1] ? [] : {}, e)[n[n.length - 1]] = r, e;
|
|
89
115
|
}, noop = () => {
|
|
90
116
|
};
|
|
91
117
|
let safeDynamicRequire = noop;
|
|
@@ -127,10 +153,10 @@ var refToProxy = (obj) => {
|
|
|
127
153
|
code: e,
|
|
128
154
|
args: t
|
|
129
155
|
}) => {
|
|
130
|
-
const
|
|
156
|
+
const r = t.map(([n]) => `var ${n} = refToProxy(${getSyncValName(n)}); `).join("");
|
|
131
157
|
return `
|
|
132
158
|
${REF_TO_PROXY_FN}
|
|
133
|
-
${
|
|
159
|
+
${r}
|
|
134
160
|
function theFunction() {
|
|
135
161
|
${e}
|
|
136
162
|
}
|
|
@@ -170,49 +196,49 @@ const setIvm = (e, t = {}) => {
|
|
|
170
196
|
function setIsolateContext(e = {
|
|
171
197
|
memoryLimit: 128
|
|
172
198
|
}) {
|
|
173
|
-
const t = getIvm(), n = new t.Isolate(e).createContextSync(),
|
|
174
|
-
return
|
|
199
|
+
const t = getIvm(), n = new t.Isolate(e).createContextSync(), o = n.global;
|
|
200
|
+
return o.setSync("global", o.derefInto()), o.setSync("log", function(...s) {
|
|
175
201
|
console.log(...s);
|
|
176
|
-
}),
|
|
202
|
+
}), o.setSync(INJECTED_IVM_GLOBAL, t), IVM_CONTEXT = n, n;
|
|
177
203
|
}
|
|
178
204
|
const getIsolateContext = () => IVM_CONTEXT || setIsolateContext(), runInNode = ({
|
|
179
205
|
code: e,
|
|
180
206
|
builder: t,
|
|
181
|
-
context:
|
|
207
|
+
context: r,
|
|
182
208
|
event: n,
|
|
183
|
-
localState:
|
|
209
|
+
localState: o,
|
|
184
210
|
rootSetState: s,
|
|
185
211
|
rootState: i
|
|
186
212
|
}) => {
|
|
187
|
-
const
|
|
213
|
+
const g = getIvm(), m = fastClone({
|
|
188
214
|
...i,
|
|
189
|
-
...
|
|
215
|
+
...o
|
|
190
216
|
}), u = getFunctionArguments({
|
|
191
217
|
builder: t,
|
|
192
|
-
context:
|
|
218
|
+
context: r,
|
|
193
219
|
event: n,
|
|
194
220
|
state: m
|
|
195
221
|
}), l = getIsolateContext(), d = l.global;
|
|
196
222
|
d.setSync(BUILDER_SET_STATE_NAME, function(c, a) {
|
|
197
223
|
set(i, c, a), s == null || s(i);
|
|
198
224
|
}), u.forEach(([c, a]) => {
|
|
199
|
-
const
|
|
225
|
+
const y = typeof a == "object" ? new g.Reference(
|
|
200
226
|
// workaround: methods with default values for arguments is not being cloned over
|
|
201
227
|
c === "builder" ? {
|
|
202
228
|
...a,
|
|
203
229
|
getUserAttributes: () => a.getUserAttributes()
|
|
204
230
|
} : a
|
|
205
231
|
) : null;
|
|
206
|
-
d.setSync(getSyncValName(c),
|
|
232
|
+
d.setSync(getSyncValName(c), y);
|
|
207
233
|
});
|
|
208
|
-
const
|
|
234
|
+
const E = processCode({
|
|
209
235
|
code: e,
|
|
210
236
|
args: u
|
|
211
|
-
}),
|
|
237
|
+
}), f = l.evalClosureSync(E);
|
|
212
238
|
try {
|
|
213
|
-
return JSON.parse(
|
|
239
|
+
return JSON.parse(f);
|
|
214
240
|
} catch {
|
|
215
|
-
return
|
|
241
|
+
return f;
|
|
216
242
|
}
|
|
217
243
|
}, checkIsDefined = (e) => e != null;
|
|
218
244
|
function isNodeRuntime() {
|
|
@@ -222,24 +248,25 @@ function isNodeRuntime() {
|
|
|
222
248
|
const shouldForceBrowserRuntimeInNode = ({
|
|
223
249
|
shouldLogWarning: e
|
|
224
250
|
}) => {
|
|
225
|
-
var
|
|
251
|
+
var o;
|
|
226
252
|
if (!isNodeRuntime())
|
|
227
253
|
return !1;
|
|
228
|
-
const t = process.arch === "arm64",
|
|
229
|
-
return t &&
|
|
254
|
+
const t = process.arch === "arm64", r = process.version.startsWith("v20"), n = (o = process.env.NODE_OPTIONS) == null ? void 0 : o.includes("--no-node-snapshot");
|
|
255
|
+
return t && r && !n ? (e && 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;
|
|
230
256
|
};
|
|
231
257
|
export {
|
|
232
258
|
TARGET as T,
|
|
233
259
|
getBuilderGlobals as a,
|
|
234
260
|
set as b,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
261
|
+
fastClone as c,
|
|
262
|
+
getSearchString as d,
|
|
263
|
+
checkIsDefined as e,
|
|
264
|
+
flattenState as f,
|
|
239
265
|
getFunctionArguments as g,
|
|
240
|
-
|
|
266
|
+
isEditing as h,
|
|
241
267
|
isBrowser as i,
|
|
242
|
-
|
|
268
|
+
getUserAttributes as j,
|
|
269
|
+
setIvm as k,
|
|
243
270
|
logger as l,
|
|
244
271
|
normalizeSearchParams as n,
|
|
245
272
|
parseCode as p,
|