@builder.io/sdk-vue 2.0.14-6 → 2.0.15

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.
Files changed (76) hide show
  1. package/lib/{edge/block-styles-zRPUnWLf.js → browser/block-styles-3kNIHbfo.js} +6 -6
  2. package/lib/browser/block-styles-mYBwPtv0.cjs +1 -0
  3. package/lib/browser/{block-wrapper-hPYvxseU.js → block-wrapper-N1PMQPGA.js} +3 -3
  4. package/lib/browser/{block-wrapper-l_mdj42t.cjs → block-wrapper-mGepkLsD.cjs} +1 -1
  5. package/lib/browser/{component-ref-dPnPtrON.cjs → component-ref-D4a8WUvU.cjs} +1 -1
  6. package/lib/browser/{component-ref-JlpkOrad.js → component-ref-eSpEv_vu.js} +2 -2
  7. package/lib/browser/constants/sdk-version.d.ts +1 -1
  8. package/lib/{edge/get-block-properties-PLBPSz3W.js → browser/get-block-properties--gxTb6u9.js} +13 -13
  9. package/lib/browser/get-block-properties-1Vr9AX-f.cjs +1 -0
  10. package/lib/browser/{index-ZL8QUFiN.js → index-dh7iM10N.js} +552 -546
  11. package/lib/browser/index-vQfvmzgX.cjs +166 -0
  12. package/lib/browser/index.cjs +1 -1
  13. package/lib/browser/index.mjs +1 -1
  14. package/lib/browser/{repeated-block-8EN4xN25.js → repeated-block-CnX7KaV3.js} +2 -2
  15. package/lib/browser/{repeated-block-uV-zuqkw.cjs → repeated-block-zZGzC5Ez.cjs} +1 -1
  16. package/lib/browser/server-index.d.ts +1 -0
  17. package/lib/{node/block-styles-gLB-jSXN.js → edge/block-styles-IJpbU1il.js} +12 -13
  18. package/lib/edge/block-styles-c-t5DB1d.cjs +1 -0
  19. package/lib/{node/block-wrapper-frfIIST_.js → edge/block-wrapper-UEsTg8bU.js} +3 -3
  20. package/lib/edge/{block-wrapper-9IWz2vxg.cjs → block-wrapper-cbxxzz21.cjs} +1 -1
  21. package/lib/{node/component-ref-IbarjSnq.js → edge/component-ref-2h-cUV3Z.js} +2 -2
  22. package/lib/{node/component-ref-ZlBAzimq.cjs → edge/component-ref-pqmk5wUc.cjs} +1 -1
  23. package/lib/edge/constants/sdk-version.d.ts +1 -1
  24. package/lib/{node/get-block-properties-QIsIgfnu.js → edge/get-block-properties-S3qjKi7G.js} +16 -17
  25. package/lib/edge/get-block-properties-egDFLKDW.cjs +1 -0
  26. package/lib/edge/{index-TGe9_80q.js → index-BN18YEfB.js} +843 -837
  27. package/lib/edge/{index-5-C3UhJz.cjs → index-NQs12e6I.cjs} +31 -31
  28. package/lib/edge/index.cjs +1 -1
  29. package/lib/edge/index.mjs +1 -1
  30. package/lib/edge/{repeated-block-_9Gs2AOY.js → repeated-block-3py1q2sc.js} +2 -2
  31. package/lib/{node/repeated-block-ZpVu-xdw.cjs → edge/repeated-block-IMmb2AE9.cjs} +1 -1
  32. package/lib/edge/server-index.d.ts +1 -0
  33. package/lib/{browser/block-styles-nWGppwAf.js → node/block-styles-E0MOJgK4.js} +12 -14
  34. package/lib/node/block-styles-VaKrzGA5.cjs +1 -0
  35. package/lib/node/{block-wrapper-cCYzfiv5.cjs → block-wrapper-TvqPY7Mt.cjs} +1 -1
  36. package/lib/{edge/block-wrapper-x7ERONr-.js → node/block-wrapper-cHgl5RuV.js} +5 -5
  37. package/lib/{edge/component-ref-eV0RBAzs.cjs → node/component-ref-fYSFTWDE.cjs} +1 -1
  38. package/lib/{edge/component-ref-JRfa9Vwo.js → node/component-ref-gqNpKniv.js} +2 -2
  39. package/lib/node/constants/sdk-version.d.ts +1 -1
  40. package/lib/{browser/get-block-properties-HzVZCpxa.js → node/get-block-properties-AZMTucap.js} +18 -20
  41. package/lib/node/get-block-properties-IntKgx2x.cjs +1 -0
  42. package/lib/node/index-ozkdxROi.cjs +213 -0
  43. package/lib/node/{index-BugETl2c.js → index-xSGjb-sL.js} +1123 -907
  44. package/lib/node/index.cjs +1 -1
  45. package/lib/node/index.mjs +16 -17
  46. package/lib/node/{repeated-block-Z-_chLeZ.js → repeated-block-WqJu5DET.js} +2 -2
  47. package/lib/{edge/repeated-block-FB2jF4o_.cjs → node/repeated-block-wW6CINnA.cjs} +1 -1
  48. package/lib/node/server-index.d.ts +1 -0
  49. package/nuxt.js +0 -13
  50. package/package.json +2 -8
  51. package/lib/browser/block-styles-rt4v7rBl.cjs +0 -1
  52. package/lib/browser/get-block-properties-sInACBRh.cjs +0 -1
  53. package/lib/browser/index-MDNnQzZB.cjs +0 -166
  54. package/lib/browser/init.cjs +0 -8
  55. package/lib/browser/init.d.cts +0 -14
  56. package/lib/browser/init.d.mts +0 -14
  57. package/lib/browser/init.mjs +0 -65
  58. package/lib/browser/logger-0-1mARBa.cjs +0 -1
  59. package/lib/browser/logger-Hm2e1Xk_.js +0 -12
  60. package/lib/edge/block-styles-Ta3OQAmE.cjs +0 -1
  61. package/lib/edge/get-block-properties-Dy3XF05J.cjs +0 -1
  62. package/lib/edge/init.cjs +0 -8
  63. package/lib/edge/init.d.cts +0 -14
  64. package/lib/edge/init.d.mts +0 -14
  65. package/lib/edge/init.mjs +0 -64
  66. package/lib/edge/logger-I8FmJD_1.js +0 -11
  67. package/lib/edge/logger-U9-0vDJK.cjs +0 -1
  68. package/lib/node/block-styles-u7KGnyuc.cjs +0 -1
  69. package/lib/node/get-block-properties-2Q2lr9bu.cjs +0 -1
  70. package/lib/node/index-s5vEnK-M.cjs +0 -166
  71. package/lib/node/init.cjs +0 -1
  72. package/lib/node/init.d.cts +0 -14
  73. package/lib/node/init.d.mts +0 -14
  74. package/lib/node/init.mjs +0 -11
  75. package/lib/node/node-runtime-0rF8vJwU.js +0 -233
  76. package/lib/node/node-runtime-Bqb5TnyM.cjs +0 -48
@@ -1,233 +0,0 @@
1
- import { createRequire } from "node:module";
2
- const TARGET = "vue", MSG_PREFIX = "[Builder.io]: ", logger = {
3
- log: (...e) => console.log(MSG_PREFIX, ...e),
4
- error: (...e) => console.error(MSG_PREFIX, ...e),
5
- warn: (...e) => console.warn(MSG_PREFIX, ...e),
6
- debug: (...e) => console.debug(MSG_PREFIX, ...e)
7
- };
8
- function isBrowser() {
9
- return typeof window < "u" && typeof document < "u";
10
- }
11
- const convertSearchParamsToQueryObject = (e) => {
12
- const t = {};
13
- return e.forEach((r, n) => {
14
- t[n] = r;
15
- }), t;
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
- function isIframe() {
18
- return isBrowser() && window.self !== window.top;
19
- }
20
- function isEditing(e) {
21
- return isIframe() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
22
- getSearchString(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
23
- }
24
- const getLocation = () => {
25
- if (isBrowser()) {
26
- const e = new URL(location.href);
27
- return e.pathname === "" && (e.pathname = "/"), e;
28
- } else
29
- return console.warn("Cannot get location for tracking in non-browser environment"), null;
30
- }, getUserAgent = () => typeof navigator == "object" && navigator.userAgent || "", getUserAttributes = () => {
31
- const e = getUserAgent(), t = {
32
- Android() {
33
- return e.match(/Android/i);
34
- },
35
- BlackBerry() {
36
- return e.match(/BlackBerry/i);
37
- },
38
- iOS() {
39
- return e.match(/iPhone|iPod/i);
40
- },
41
- Opera() {
42
- return e.match(/Opera Mini/i);
43
- },
44
- Windows() {
45
- return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
46
- },
47
- any() {
48
- return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || TARGET === "reactNative";
49
- }
50
- }, r = e.match(/Tablet|iPad/i), n = getLocation();
51
- return {
52
- urlPath: n == null ? void 0 : n.pathname,
53
- host: (n == null ? void 0 : n.host) || (n == null ? void 0 : n.hostname),
54
- device: r ? "tablet" : t.any() ? "mobile" : "desktop"
55
- };
56
- }, getFunctionArguments = ({
57
- builder: e,
58
- context: t,
59
- event: r,
60
- state: n
61
- }) => Object.entries({
62
- state: n,
63
- Builder: e,
64
- // legacy
65
- builder: e,
66
- context: t,
67
- event: r
68
- }), getBuilderGlobals = () => ({
69
- isEditing: isEditing(),
70
- isBrowser: isBrowser(),
71
- isServer: !isBrowser(),
72
- getUserAttributes: () => getUserAttributes()
73
- }), parseCode = (e, {
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, SDK_NAME_FOR_TARGET = (() => {
76
- switch (TARGET) {
77
- case "rsc":
78
- return "react-nextjs";
79
- case "reactNative":
80
- return "react-native";
81
- default:
82
- return TARGET;
83
- }
84
- })(), SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`, fastClone = (e) => JSON.parse(JSON.stringify(e)), set = (e, t, r) => {
85
- if (Object(e) !== e)
86
- return e;
87
- const n = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
88
- 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
- }, noop = () => {
90
- };
91
- let safeDynamicRequire = noop;
92
- try {
93
- safeDynamicRequire = createRequire(import.meta.url);
94
- } catch (error) {
95
- try {
96
- safeDynamicRequire = eval("require");
97
- } catch (e) {
98
- }
99
- }
100
- const getSyncValName = (e) => `bldr_${e}_sync`, BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE", INJECTED_IVM_GLOBAL = "BUILDER_IVM", REF_TO_PROXY_FN = `
101
- var refToProxy = (obj) => {
102
- if (typeof obj !== 'object' || obj === null) {
103
- return obj;
104
- }
105
- return new Proxy({}, {
106
- get(target, key) {
107
- if (key === 'copySync') {
108
- return () => obj.copySync();
109
- }
110
- const val = obj.getSync(key);
111
- if (typeof val?.getSync === 'function') {
112
- return refToProxy(val);
113
- }
114
- return val;
115
- },
116
- set(target, key, value) {
117
- const v = typeof value === 'object' ? new ${INJECTED_IVM_GLOBAL}.Reference(value) : value;
118
- obj.setSync(key, v);
119
- ${BUILDER_SET_STATE_NAME}(key, value)
120
- },
121
- deleteProperty(target, key) {
122
- obj.deleteSync(key);
123
- }
124
- })
125
- }
126
- `, processCode = ({
127
- code: e,
128
- args: t
129
- }) => {
130
- const r = t.map(([n]) => `var ${n} = refToProxy(${getSyncValName(n)}); `).join("");
131
- return `
132
- ${REF_TO_PROXY_FN}
133
- ${r}
134
- function theFunction() {
135
- ${e}
136
- }
137
-
138
- const output = theFunction()
139
-
140
- if (typeof output === 'object' && output !== null) {
141
- return JSON.stringify(output.copySync ? output.copySync() : output);
142
- } else {
143
- return output;
144
- }
145
- `;
146
- };
147
- let IVM_INSTANCE = null, IVM_CONTEXT = null;
148
- const setIvm = (e, t = {}) => {
149
- IVM_INSTANCE = e, setIsolateContext(t);
150
- }, SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react" || SDK_NAME === "@builder.io/sdk-qwik", getIvm = () => {
151
- try {
152
- if (IVM_INSTANCE)
153
- return IVM_INSTANCE;
154
- const t = safeDynamicRequire("isolated-vm");
155
- if (t)
156
- return t;
157
- } catch (t) {
158
- logger.error("isolated-vm import error.", t);
159
- }
160
- const e = `${MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
161
-
162
- SOLUTION: In a server-only execution path within your application, do one of the following:
163
-
164
- ${SHOULD_MENTION_INITIALIZE_SCRIPT ? `- import and call \`initializeNodeRuntime()\` from "${SDK_NAME}/node/init".` : ""}
165
- - add the following import: \`await import('isolated-vm')\`.
166
-
167
- For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
168
- throw new Error(e);
169
- };
170
- function setIsolateContext(e = {
171
- memoryLimit: 128
172
- }) {
173
- const t = getIvm(), n = new t.Isolate(e).createContextSync(), o = n.global;
174
- return o.setSync("global", o.derefInto()), o.setSync("log", function(...s) {
175
- console.log(...s);
176
- }), o.setSync(INJECTED_IVM_GLOBAL, t), IVM_CONTEXT = n, n;
177
- }
178
- const getIsolateContext = () => IVM_CONTEXT || setIsolateContext(), runInNode = ({
179
- code: e,
180
- builder: t,
181
- context: r,
182
- event: n,
183
- localState: o,
184
- rootSetState: s,
185
- rootState: i
186
- }) => {
187
- const f = getIvm(), E = fastClone({
188
- ...i,
189
- ...o
190
- }), u = getFunctionArguments({
191
- builder: t,
192
- context: r,
193
- event: n,
194
- state: E
195
- }), l = getIsolateContext(), g = l.global;
196
- g.setSync(BUILDER_SET_STATE_NAME, function(c, a) {
197
- set(i, c, a), s == null || s(i);
198
- }), u.forEach(([c, a]) => {
199
- const y = typeof a == "object" ? new f.Reference(
200
- // workaround: methods with default values for arguments is not being cloned over
201
- c === "builder" ? {
202
- ...a,
203
- getUserAttributes: () => a.getUserAttributes()
204
- } : a
205
- ) : null;
206
- g.setSync(getSyncValName(c), y);
207
- });
208
- const m = processCode({
209
- code: e,
210
- args: u
211
- }), d = l.evalClosureSync(m);
212
- try {
213
- return JSON.parse(d);
214
- } catch {
215
- return d;
216
- }
217
- };
218
- export {
219
- TARGET as T,
220
- getBuilderGlobals as a,
221
- getSearchString as b,
222
- isEditing as c,
223
- getUserAttributes as d,
224
- setIvm as e,
225
- fastClone as f,
226
- getFunctionArguments as g,
227
- isBrowser as i,
228
- logger as l,
229
- normalizeSearchParams as n,
230
- parseCode as p,
231
- runInNode as r,
232
- set as s
233
- };
@@ -1,48 +0,0 @@
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((n,r)=>{t[r]=n}),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"}},n=e.match(/Tablet|iPad/i),r=getLocation();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},getFunctionArguments=({builder:e,context:t,event:n,state:r})=>Object.entries({state:r,Builder:e,builder:e,context:t,event:n}),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,n)=>{if(Object(e)!==e)return e;const r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g);return r.slice(0,-1).reduce((o,s,i)=>Object(o[s])===o[s]?o[s]:o[s]=Math.abs(Number(r[i+1]))>>0===+r[i+1]?[]:{},e)[r[r.length-1]]=n,e},noop=()=>{};let safeDynamicRequire=noop;try{safeDynamicRequire=node_module.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:_documentCurrentScript&&_documentCurrentScript.src||new URL("node-runtime-Bqb5TnyM.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
- var refToProxy = (obj) => {
3
- if (typeof obj !== 'object' || obj === null) {
4
- return obj;
5
- }
6
- return new Proxy({}, {
7
- get(target, key) {
8
- if (key === 'copySync') {
9
- return () => obj.copySync();
10
- }
11
- const val = obj.getSync(key);
12
- if (typeof val?.getSync === 'function') {
13
- return refToProxy(val);
14
- }
15
- return val;
16
- },
17
- set(target, key, value) {
18
- const v = typeof value === 'object' ? new ${INJECTED_IVM_GLOBAL}.Reference(value) : value;
19
- obj.setSync(key, v);
20
- ${BUILDER_SET_STATE_NAME}(key, value)
21
- },
22
- deleteProperty(target, key) {
23
- obj.deleteSync(key);
24
- }
25
- })
26
- }
27
- `,processCode=({code:e,args:t})=>{const n=t.map(([r])=>`var ${r} = refToProxy(${getSyncValName(r)}); `).join("");return`
28
- ${REF_TO_PROXY_FN}
29
- ${n}
30
- function theFunction() {
31
- ${e}
32
- }
33
-
34
- const output = theFunction()
35
-
36
- if (typeof output === 'object' && output !== null) {
37
- return JSON.stringify(output.copySync ? output.copySync() : output);
38
- } else {
39
- return output;
40
- }
41
- `};let IVM_INSTANCE=null,IVM_CONTEXT=null;const setIvm=(e,t={})=>{IVM_INSTANCE=e,setIsolateContext(t)},SHOULD_MENTION_INITIALIZE_SCRIPT=SDK_NAME==="@builder.io/sdk-react-nextjs"||SDK_NAME==="@builder.io/sdk-react"||SDK_NAME==="@builder.io/sdk-qwik",getIvm=()=>{try{if(IVM_INSTANCE)return IVM_INSTANCE;const t=safeDynamicRequire("isolated-vm");if(t)return t}catch(t){logger.error("isolated-vm import error.",t)}const e=`${MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
42
-
43
- SOLUTION: In a server-only execution path within your application, do one of the following:
44
-
45
- ${SHOULD_MENTION_INITIALIZE_SCRIPT?`- import and call \`initializeNodeRuntime()\` from "${SDK_NAME}/node/init".`:""}
46
- - add the following import: \`await import('isolated-vm')\`.
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(),r=new t.Isolate(e).createContextSync(),o=r.global;return o.setSync("global",o.derefInto()),o.setSync("log",function(...s){console.log(...s)}),o.setSync(INJECTED_IVM_GLOBAL,t),IVM_CONTEXT=r,r}const getIsolateContext=()=>IVM_CONTEXT||setIsolateContext(),runInNode=({code:e,builder:t,context:n,event:r,localState:o,rootSetState:s,rootState:i})=>{const m=getIvm(),f=fastClone({...i,...o}),u=getFunctionArguments({builder:t,context:n,event:r,state:f}),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 S=typeof a=="object"?new m.Reference(c==="builder"?{...a,getUserAttributes:()=>a.getUserAttributes()}:a):null;d.setSync(getSyncValName(c),S)});const p=processCode({code:e,args:u}),g=l.evalClosureSync(p);try{return JSON.parse(g)}catch{return g}};exports.TARGET=TARGET;exports.fastClone=fastClone;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;