@builder.io/sdk-vue 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/{awaiter-GjRYxPnU.cjs → awaiter-Xj7xgU8A.cjs} +1 -1
- package/lib/browser/{awaiter-5WjT5CVy.js → awaiter-fiHMd9OX.js} +1 -1
- package/lib/browser/block-wrapper-2d_iPFQQ.js +51 -0
- package/lib/browser/block-wrapper-lKLgKxgH.cjs +1 -0
- package/lib/browser/blocks/form/form/form.vue.d.ts +3 -3
- package/lib/browser/blocks/form/input/input.vue.d.ts +3 -3
- package/lib/browser/blocks/symbol/symbol.helpers.d.ts +2 -0
- package/lib/browser/blocks/symbol/symbol.types.d.ts +2 -0
- package/lib/browser/component-ref-Bo_fwbYK.cjs +1 -0
- package/lib/browser/component-ref-YEfZKvMy.js +185 -0
- package/lib/browser/components/content/components/enable-editor.vue.d.ts +9 -9
- package/lib/browser/components/content/components/styles.vue.d.ts +3 -3
- package/lib/browser/components/content/content.vue.d.ts +9 -9
- package/lib/browser/components/content-variants/content-variants.vue.d.ts +9 -9
- package/lib/browser/components/inlined-script.vue.d.ts +3 -3
- package/lib/browser/components/inlined-styles.vue.d.ts +3 -3
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/functions/evaluate/evaluate.d.ts +1 -1
- package/lib/browser/functions/evaluate/helpers.d.ts +9 -1
- package/lib/browser/functions/get-block-actions-handler.d.ts +2 -0
- package/lib/browser/functions/get-block-actions.d.ts +2 -0
- package/lib/{edge/get-block-properties--YFzBEV7.js → browser/get-block-properties-5nuoWf39.js} +9 -7
- package/lib/browser/get-block-properties-d-Ruoi4f.cjs +1 -0
- package/lib/browser/index-1GET5eOz.cjs +334 -0
- package/lib/browser/{index-EQdaCBDB.js → index-eVqO7_Qb.js} +475 -459
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/{live-edit-tO-V6Sv7.js → live-edit-9paJdIsz.js} +1 -1
- package/lib/browser/{live-edit-Jion_iv8.cjs → live-edit-ETOoXz63.cjs} +1 -1
- package/lib/browser/{repeated-block-kNj6mfjr.js → repeated-block-A24n6o-E.js} +2 -2
- package/lib/browser/{repeated-block-uNYlrd8d.cjs → repeated-block-RfWox6Ev.cjs} +1 -1
- package/lib/browser/{style-wrapper-jthdwC6f.cjs → style-wrapper-GTejPbe6.cjs} +1 -1
- package/lib/browser/{style-wrapper-CSSH3Epu.js → style-wrapper-tibcUSpL.js} +1 -1
- package/lib/edge/{awaiter-0PdAd6k-.cjs → awaiter-SdqgCFCT.cjs} +1 -1
- package/lib/edge/{awaiter-OJqvwrja.js → awaiter-rbgcBB2Y.js} +1 -1
- package/lib/edge/block-wrapper-DYh1gucy.js +50 -0
- package/lib/edge/block-wrapper-WT0fK9OQ.cjs +1 -0
- package/lib/edge/blocks/form/form/form.vue.d.ts +3 -3
- package/lib/edge/blocks/form/input/input.vue.d.ts +3 -3
- package/lib/edge/blocks/symbol/symbol.helpers.d.ts +2 -0
- package/lib/edge/blocks/symbol/symbol.types.d.ts +2 -0
- package/lib/edge/component-ref-14bWdw0y.js +184 -0
- package/lib/edge/component-ref-Ari_o8qM.cjs +1 -0
- package/lib/edge/components/content/components/enable-editor.vue.d.ts +9 -9
- package/lib/edge/components/content/components/styles.vue.d.ts +3 -3
- package/lib/edge/components/content/content.vue.d.ts +9 -9
- package/lib/edge/components/content-variants/content-variants.vue.d.ts +9 -9
- package/lib/edge/components/inlined-script.vue.d.ts +3 -3
- package/lib/edge/components/inlined-styles.vue.d.ts +3 -3
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/functions/evaluate/evaluate.d.ts +1 -1
- package/lib/edge/functions/evaluate/helpers.d.ts +9 -1
- package/lib/edge/functions/get-block-actions-handler.d.ts +2 -0
- package/lib/edge/functions/get-block-actions.d.ts +2 -0
- package/lib/{browser/get-block-properties-dmm_DIxo.js → edge/get-block-properties-6j21Yx4_.js} +17 -17
- package/lib/edge/get-block-properties-kMAb8z5D.cjs +1 -0
- package/lib/edge/{index-ljVeDS39.cjs → index-2Armmtcs.cjs} +17 -17
- package/lib/edge/{index-Agn-gjHJ.js → index-unVH2XRb.js} +848 -832
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/{node/live-edit-jWT4dXgM.cjs → edge/live-edit-gMqK1-U2.cjs} +1 -1
- package/lib/{node/live-edit-E90Rueqo.js → edge/live-edit-yXkE9pDV.js} +1 -1
- package/lib/{node/repeated-block-gCLdrEyt.js → edge/repeated-block-F4oPiI78.js} +2 -2
- package/lib/edge/{repeated-block-GaabRNMP.cjs → repeated-block-Y0Z3ldLT.cjs} +1 -1
- package/lib/edge/{style-wrapper-I1DS5PUP.js → style-wrapper-Ad7ABy2Z.js} +1 -1
- package/lib/edge/{style-wrapper-MIBe_b13.cjs → style-wrapper-sL972lDH.cjs} +1 -1
- package/lib/node/{awaiter-qP3UIYQS.js → awaiter-_ZqW9w8N.js} +1 -1
- package/lib/node/{awaiter-ZX8mvzyL.cjs → awaiter-i0lAEAYI.cjs} +1 -1
- package/lib/node/block-wrapper-Bv_s1rr1.cjs +1 -0
- package/lib/node/block-wrapper-CnMu7UjK.js +50 -0
- package/lib/node/blocks/form/form/form.vue.d.ts +3 -3
- package/lib/node/blocks/form/input/input.vue.d.ts +3 -3
- package/lib/node/blocks/symbol/symbol.helpers.d.ts +2 -0
- package/lib/node/blocks/symbol/symbol.types.d.ts +2 -0
- package/lib/node/component-ref-LWytt0tD.cjs +1 -0
- package/lib/node/component-ref-lU9WFg32.js +185 -0
- package/lib/node/components/content/components/enable-editor.vue.d.ts +9 -9
- package/lib/node/components/content/components/styles.vue.d.ts +3 -3
- package/lib/node/components/content/content.vue.d.ts +9 -9
- package/lib/node/components/content-variants/content-variants.vue.d.ts +9 -9
- package/lib/node/components/inlined-script.vue.d.ts +3 -3
- package/lib/node/components/inlined-styles.vue.d.ts +3 -3
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/functions/evaluate/evaluate.d.ts +1 -1
- package/lib/node/functions/evaluate/helpers.d.ts +9 -1
- package/lib/node/functions/get-block-actions-handler.d.ts +2 -0
- package/lib/node/functions/get-block-actions.d.ts +2 -0
- package/lib/node/{get-block-properties-o5VoFlz_.js → get-block-properties-oSP4WCJG.js} +18 -17
- package/lib/node/get-block-properties-sdbm535D.cjs +1 -0
- package/lib/node/{index-SH8gdiHf.js → index-9Wxomhx_.js} +702 -900
- package/lib/node/{index-AumTeVyL.cjs → index-z7Ed9MEJ.cjs} +30 -30
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +11 -11
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +1 -1
- package/lib/{edge/live-edit-TWpZ33A7.js → node/live-edit-ZjrPT1e_.js} +1 -1
- package/lib/{edge/live-edit-nHq1I7ij.cjs → node/live-edit-nQPgUSEF.cjs} +1 -1
- package/lib/node/{repeated-block-4pHYUEBM.cjs → repeated-block-G-7Wr2Ub.cjs} +1 -1
- package/lib/{edge/repeated-block-_wYfLmVg.js → node/repeated-block-zGwBOU59.js} +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-5h08TaCf.js → should-force-browser-runtime-in-node-0jTQ7bdA.js} +261 -41
- package/lib/node/should-force-browser-runtime-in-node-kkE7IeZS.cjs +48 -0
- package/lib/node/{style-wrapper-7nh-8JLA.cjs → style-wrapper-QZvOi8Ur.cjs} +1 -1
- package/lib/node/{style-wrapper-1rHE_XSt.js → style-wrapper-QtIk1dHP.js} +10 -10
- package/package.json +1 -1
- package/lib/browser/block-wrapper-8v7I2JSB.cjs +0 -1
- package/lib/browser/block-wrapper-s3-0mqGr.js +0 -44
- package/lib/browser/component-ref-8g4g9kyF.js +0 -178
- package/lib/browser/component-ref-r7lSDLc0.cjs +0 -1
- package/lib/browser/get-block-properties-GPPIll7t.cjs +0 -1
- package/lib/browser/index-Treb985Y.cjs +0 -334
- package/lib/edge/block-wrapper-DfG53TBm.cjs +0 -1
- package/lib/edge/block-wrapper-LzMR5J5q.js +0 -43
- package/lib/edge/component-ref-30u-bbmm.js +0 -177
- package/lib/edge/component-ref-VTMpfeME.cjs +0 -1
- package/lib/edge/get-block-properties-yv9bFXVp.cjs +0 -1
- package/lib/node/block-wrapper-3FbaAWv9.js +0 -43
- package/lib/node/block-wrapper-mEOIfHOk.cjs +0 -1
- package/lib/node/component-ref-DHpSqIaD.cjs +0 -1
- package/lib/node/component-ref-MKSj3oym.js +0 -178
- package/lib/node/get-block-properties-b4xkM8mc.cjs +0 -1
- package/lib/node/should-force-browser-runtime-in-node-IsToRTN-.cjs +0 -48
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-z7Ed9MEJ.cjs"),t=require("./should-force-browser-runtime-in-node-kkE7IeZS.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.registerAction=e.registerAction;exports.setClientUserAttributes=e.setClientUserAttributes;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.isEditing=t.isEditing;exports.track=t.track;
|
package/lib/node/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { m as t, b as a, k as r, C as
|
|
2
|
-
import {
|
|
1
|
+
import { m as t, b as a, k as r, C as o, n as i, F as n, I as c, S as g, l, T as m, V as u, y as d, p as C, x as p, z as b, A as f, u as x, o as B, r as E, q as S, s as h, t as k, v as y } from "./index-9Wxomhx_.js";
|
|
2
|
+
import { o as P, t as T } from "./should-force-browser-runtime-in-node-0jTQ7bdA.js";
|
|
3
3
|
export {
|
|
4
4
|
t as Blocks,
|
|
5
5
|
a as BuilderContext,
|
|
6
6
|
r as Button,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
o as Columns,
|
|
8
|
+
i as Content,
|
|
9
9
|
n as Fragment,
|
|
10
10
|
c as Image,
|
|
11
11
|
g as Section,
|
|
@@ -17,13 +17,13 @@ export {
|
|
|
17
17
|
p as fetchBuilderProps,
|
|
18
18
|
b as fetchEntries,
|
|
19
19
|
f as fetchOneEntry,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
x as getBuilderSearchParams,
|
|
21
|
+
P as isEditing,
|
|
22
|
+
B as isPreviewing,
|
|
23
|
+
E as register,
|
|
24
|
+
S as registerAction,
|
|
25
|
+
h as setClientUserAttributes,
|
|
26
26
|
k as setEditorSettings,
|
|
27
27
|
y as subscribeToEditor,
|
|
28
|
-
|
|
28
|
+
T as track
|
|
29
29
|
};
|
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-kkE7IeZS.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,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as o, openBlock as r, createBlock as n, resolveDynamicComponent as i, mergeProps as s, withCtx as p, renderSlot as a } from "vue";
|
|
2
2
|
import { f as c } from "./find-block-3Ig0kVVe.js";
|
|
3
|
-
import { b as d, _ as l } from "./index-
|
|
3
|
+
import { b as d, _ as l } from "./index-9Wxomhx_.js";
|
|
4
4
|
const m = o({
|
|
5
5
|
name: "live-edit",
|
|
6
6
|
props: ["id", "attributes", "Wrapper"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),r=require("./find-block-FREohLcp.cjs"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),r=require("./find-block-FREohLcp.cjs"),n=require("./index-z7Ed9MEJ.cjs"),i=t.defineComponent({name:"live-edit",props:["id","attributes","Wrapper"],inject:{context:n.BuilderContext.key},computed:{block(){return r.findBlockById(this.context.content,this.id)},options(){var e,o;return((o=(e=this.block)==null?void 0:e.component)==null?void 0:o.options)||{}}}});function s(e,o,p,u,d,a){return t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.Wrapper),t.mergeProps({attributes:e.attributes},e.options),{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:3},16,["attributes"])}const c=n._export_sfc(i,[["render",s]]);exports.default=c;
|
|
@@ -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-z7Ed9MEJ.cjs"),r=()=>Promise.resolve().then(()=>require("./index-z7Ed9MEJ.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}},watch:{onUpdateHook0:{handler(){this.store=this.repeatContext},immediate:!0}},computed:{onUpdateHook0(){return{0:this.repeatContext}}}});function s(e,p,l,a,d,m){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 i=t._export_sfc(c,[["render",s]]);exports.default=i;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as t, defineAsyncComponent as n, resolveComponent as r, openBlock as p, createBlock as s } from "vue";
|
|
2
|
-
import { b as c, _ as i } from "./index-
|
|
3
|
-
const a = () => import("./index-
|
|
2
|
+
import { b as c, _ as i } from "./index-9Wxomhx_.js";
|
|
3
|
+
const a = () => import("./index-9Wxomhx_.js").then((e) => e.E).then((e) => e.default).catch((e) => {
|
|
4
4
|
throw console.error(
|
|
5
5
|
"Error while attempting to dynamically import component Block at ../block.vue",
|
|
6
6
|
e
|
|
@@ -10,8 +10,8 @@ function isBrowser() {
|
|
|
10
10
|
}
|
|
11
11
|
const convertSearchParamsToQueryObject = (e) => {
|
|
12
12
|
const t = {};
|
|
13
|
-
return e.forEach((r,
|
|
14
|
-
t[
|
|
13
|
+
return e.forEach((r, o) => {
|
|
14
|
+
t[o] = 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,29 +47,242 @@ const getLocation = () => {
|
|
|
47
47
|
any() {
|
|
48
48
|
return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || TARGET === "reactNative";
|
|
49
49
|
}
|
|
50
|
-
}, r = e.match(/Tablet|iPad/i),
|
|
50
|
+
}, r = e.match(/Tablet|iPad/i), o = getLocation();
|
|
51
51
|
return {
|
|
52
|
-
urlPath:
|
|
53
|
-
host: (
|
|
52
|
+
urlPath: o == null ? void 0 : o.pathname,
|
|
53
|
+
host: (o == null ? void 0 : o.host) || (o == null ? void 0 : o.hostname),
|
|
54
54
|
device: r ? "tablet" : t.any() ? "mobile" : "desktop"
|
|
55
55
|
};
|
|
56
|
-
},
|
|
56
|
+
}, SDK_VERSION = "5.2.0", getSdkHeaders = () => ({
|
|
57
|
+
"X-Builder-SDK": TARGET,
|
|
58
|
+
"X-Builder-SDK-GEN": "2",
|
|
59
|
+
"X-Builder-SDK-Version": SDK_VERSION
|
|
60
|
+
}), checkIsDefined = (e) => e != null, getTopLevelDomain = (e) => {
|
|
61
|
+
if (e === "localhost" || e === "127.0.0.1")
|
|
62
|
+
return e;
|
|
63
|
+
const t = e.split(".");
|
|
64
|
+
return t.length > 2 ? t.slice(1).join(".") : e;
|
|
65
|
+
}, getCookieSync = ({
|
|
66
|
+
name: e,
|
|
67
|
+
canTrack: t
|
|
68
|
+
}) => {
|
|
69
|
+
var r;
|
|
70
|
+
try {
|
|
71
|
+
return t ? (r = document.cookie.split("; ").find((o) => o.startsWith(`${e}=`))) == null ? void 0 : r.split("=")[1] : void 0;
|
|
72
|
+
} catch (o) {
|
|
73
|
+
logger.warn("[COOKIE] GET error: ", (o == null ? void 0 : o.message) || o);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}, getCookie = async (e) => getCookieSync(e), stringifyCookie = (e) => e.map(([t, r]) => r ? `${t}=${r}` : t).filter(checkIsDefined).join("; "), SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]], createCookieString = ({
|
|
77
|
+
name: e,
|
|
78
|
+
value: t,
|
|
79
|
+
expires: r
|
|
80
|
+
}) => {
|
|
81
|
+
const n = (isBrowser() ? location.protocol === "https:" : !0) ? SECURE_CONFIG : [[]], s = r ? [["expires", r.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...n];
|
|
82
|
+
return stringifyCookie(i);
|
|
83
|
+
}, setCookie = async ({
|
|
84
|
+
name: e,
|
|
85
|
+
value: t,
|
|
86
|
+
expires: r,
|
|
87
|
+
canTrack: o
|
|
88
|
+
}) => {
|
|
89
|
+
try {
|
|
90
|
+
if (!o)
|
|
91
|
+
return;
|
|
92
|
+
const n = createCookieString({
|
|
93
|
+
name: e,
|
|
94
|
+
value: t,
|
|
95
|
+
expires: r
|
|
96
|
+
});
|
|
97
|
+
document.cookie = n;
|
|
98
|
+
} catch (n) {
|
|
99
|
+
logger.warn("[COOKIE] SET error: ", (n == null ? void 0 : n.message) || n);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
function uuidv4() {
|
|
103
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
104
|
+
const t = Math.random() * 16 | 0;
|
|
105
|
+
return (e == "x" ? t : t & 3 | 8).toString(16);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function uuid() {
|
|
109
|
+
return uuidv4().replace(/-/g, "");
|
|
110
|
+
}
|
|
111
|
+
const SESSION_LOCAL_STORAGE_KEY = "builderSessionId", getSessionId = async ({
|
|
112
|
+
canTrack: e
|
|
113
|
+
}) => {
|
|
114
|
+
if (!e)
|
|
115
|
+
return;
|
|
116
|
+
const t = await getCookie({
|
|
117
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
118
|
+
canTrack: e
|
|
119
|
+
});
|
|
120
|
+
if (checkIsDefined(t))
|
|
121
|
+
return t;
|
|
122
|
+
{
|
|
123
|
+
const r = createSessionId();
|
|
124
|
+
return setSessionId({
|
|
125
|
+
id: r,
|
|
126
|
+
canTrack: e
|
|
127
|
+
}), r;
|
|
128
|
+
}
|
|
129
|
+
}, createSessionId = () => uuid(), setSessionId = ({
|
|
130
|
+
id: e,
|
|
131
|
+
canTrack: t
|
|
132
|
+
}) => setCookie({
|
|
133
|
+
name: SESSION_LOCAL_STORAGE_KEY,
|
|
134
|
+
value: e,
|
|
135
|
+
canTrack: t
|
|
136
|
+
}), getLocalStorage = () => isBrowser() && typeof localStorage < "u" ? localStorage : void 0, getLocalStorageItem = ({
|
|
137
|
+
key: e,
|
|
138
|
+
canTrack: t
|
|
139
|
+
}) => {
|
|
140
|
+
var r;
|
|
141
|
+
try {
|
|
142
|
+
return t ? (r = getLocalStorage()) == null ? void 0 : r.getItem(e) : void 0;
|
|
143
|
+
} catch (o) {
|
|
144
|
+
console.debug("[LocalStorage] GET error: ", o);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}, setLocalStorageItem = ({
|
|
148
|
+
key: e,
|
|
149
|
+
canTrack: t,
|
|
150
|
+
value: r
|
|
151
|
+
}) => {
|
|
152
|
+
var o;
|
|
153
|
+
try {
|
|
154
|
+
t && ((o = getLocalStorage()) == null || o.setItem(e, r));
|
|
155
|
+
} catch (n) {
|
|
156
|
+
console.debug("[LocalStorage] SET error: ", n);
|
|
157
|
+
}
|
|
158
|
+
}, VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId", getVisitorId = ({
|
|
159
|
+
canTrack: e
|
|
160
|
+
}) => {
|
|
161
|
+
if (!e)
|
|
162
|
+
return;
|
|
163
|
+
const t = getLocalStorageItem({
|
|
164
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
165
|
+
canTrack: e
|
|
166
|
+
});
|
|
167
|
+
if (checkIsDefined(t))
|
|
168
|
+
return t;
|
|
169
|
+
{
|
|
170
|
+
const r = createVisitorId();
|
|
171
|
+
return setVisitorId({
|
|
172
|
+
id: r,
|
|
173
|
+
canTrack: e
|
|
174
|
+
}), r;
|
|
175
|
+
}
|
|
176
|
+
}, createVisitorId = () => uuid(), setVisitorId = ({
|
|
177
|
+
id: e,
|
|
178
|
+
canTrack: t
|
|
179
|
+
}) => setLocalStorageItem({
|
|
180
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
181
|
+
value: e,
|
|
182
|
+
canTrack: t
|
|
183
|
+
});
|
|
184
|
+
function logFetch(e) {
|
|
185
|
+
var t;
|
|
186
|
+
typeof process < "u" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" && logger.log(e);
|
|
187
|
+
}
|
|
188
|
+
const getTrackingEventData = async ({
|
|
189
|
+
canTrack: e
|
|
190
|
+
}) => {
|
|
191
|
+
if (!e)
|
|
192
|
+
return {
|
|
193
|
+
visitorId: void 0,
|
|
194
|
+
sessionId: void 0
|
|
195
|
+
};
|
|
196
|
+
const t = await getSessionId({
|
|
197
|
+
canTrack: e
|
|
198
|
+
}), r = getVisitorId({
|
|
199
|
+
canTrack: e
|
|
200
|
+
});
|
|
201
|
+
return {
|
|
202
|
+
sessionId: t,
|
|
203
|
+
visitorId: r
|
|
204
|
+
};
|
|
205
|
+
}, createEvent = async ({
|
|
206
|
+
type: e,
|
|
207
|
+
canTrack: t,
|
|
208
|
+
apiKey: r,
|
|
209
|
+
metadata: o,
|
|
210
|
+
...n
|
|
211
|
+
}) => ({
|
|
212
|
+
type: e,
|
|
213
|
+
data: {
|
|
214
|
+
...n,
|
|
215
|
+
metadata: {
|
|
216
|
+
url: location.href,
|
|
217
|
+
...o
|
|
218
|
+
},
|
|
219
|
+
...await getTrackingEventData({
|
|
220
|
+
canTrack: t
|
|
221
|
+
}),
|
|
222
|
+
userAttributes: getUserAttributes(),
|
|
223
|
+
ownerId: r
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
async function _track({
|
|
227
|
+
apiHost: e,
|
|
228
|
+
...t
|
|
229
|
+
}) {
|
|
230
|
+
if (!t.apiKey) {
|
|
231
|
+
logger.error("Missing API key for track call. Please provide your API key.");
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (!t.canTrack || isEditing() || !(isBrowser() || TARGET === "reactNative"))
|
|
235
|
+
return;
|
|
236
|
+
const o = `${e || "https://cdn.builder.io"}/api/v1/track`;
|
|
237
|
+
return logFetch(o), fetch(o, {
|
|
238
|
+
method: "POST",
|
|
239
|
+
body: JSON.stringify({
|
|
240
|
+
events: [await createEvent(t)]
|
|
241
|
+
}),
|
|
242
|
+
headers: {
|
|
243
|
+
"content-type": "application/json",
|
|
244
|
+
...getSdkHeaders()
|
|
245
|
+
},
|
|
246
|
+
mode: "cors"
|
|
247
|
+
}).catch((n) => {
|
|
248
|
+
console.error("Failed to track: ", n);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
const track = (e) => _track({
|
|
252
|
+
...e,
|
|
253
|
+
canTrack: !0
|
|
254
|
+
}), getFunctionArguments = ({
|
|
57
255
|
builder: e,
|
|
58
256
|
context: t,
|
|
59
257
|
event: r,
|
|
60
|
-
state:
|
|
258
|
+
state: o
|
|
61
259
|
}) => Object.entries({
|
|
62
|
-
state:
|
|
260
|
+
state: o,
|
|
63
261
|
Builder: e,
|
|
64
262
|
// legacy
|
|
65
263
|
builder: e,
|
|
66
264
|
context: t,
|
|
67
265
|
event: r
|
|
68
|
-
}), getBuilderGlobals = () => ({
|
|
266
|
+
}), getBuilderGlobals = (e) => ({
|
|
69
267
|
isEditing: isEditing(),
|
|
70
268
|
isBrowser: isBrowser(),
|
|
71
269
|
isServer: !isBrowser(),
|
|
72
|
-
getUserAttributes: () => getUserAttributes()
|
|
270
|
+
getUserAttributes: () => getUserAttributes(),
|
|
271
|
+
trackConversion: (t, r) => {
|
|
272
|
+
!(e != null && e.apiKey) || (e == null ? void 0 : e.canTrack) === !1 || _track({
|
|
273
|
+
type: "conversion",
|
|
274
|
+
apiKey: e.apiKey,
|
|
275
|
+
canTrack: e.canTrack ?? !0,
|
|
276
|
+
contentId: e.contentId,
|
|
277
|
+
variationId: e.variationId !== e.contentId ? e.variationId : void 0,
|
|
278
|
+
metadata: {
|
|
279
|
+
...r || {},
|
|
280
|
+
...t !== void 0 ? {
|
|
281
|
+
amount: t
|
|
282
|
+
} : {}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
73
286
|
}), parseCode = (e, {
|
|
74
287
|
isExpression: t = !0
|
|
75
288
|
}) => /* 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;
|
|
@@ -79,22 +292,22 @@ function flattenState({
|
|
|
79
292
|
rootSetState: r
|
|
80
293
|
}) {
|
|
81
294
|
return new Proxy(e, {
|
|
82
|
-
get: (
|
|
83
|
-
if (t &&
|
|
84
|
-
return t[
|
|
85
|
-
const s = n
|
|
295
|
+
get: (o, n) => {
|
|
296
|
+
if (t && n in t)
|
|
297
|
+
return t[n];
|
|
298
|
+
const s = o[n];
|
|
86
299
|
return typeof s == "object" && s !== null ? flattenState({
|
|
87
300
|
rootState: s,
|
|
88
301
|
localState: void 0,
|
|
89
302
|
rootSetState: r ? (i) => {
|
|
90
|
-
n
|
|
303
|
+
o[n] = i, r(o);
|
|
91
304
|
} : void 0
|
|
92
305
|
}) : s;
|
|
93
306
|
},
|
|
94
|
-
set: (
|
|
95
|
-
if (t &&
|
|
307
|
+
set: (o, n, s) => {
|
|
308
|
+
if (t && n in t)
|
|
96
309
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
97
|
-
return n
|
|
310
|
+
return o[n] = s, r == null || r(o), !0;
|
|
98
311
|
}
|
|
99
312
|
});
|
|
100
313
|
}
|
|
@@ -110,8 +323,8 @@ const SDK_NAME_FOR_TARGET = (() => {
|
|
|
110
323
|
})(), SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`, fastClone = (e) => JSON.parse(JSON.stringify(e)), set = (e, t, r) => {
|
|
111
324
|
if (Object(e) !== e)
|
|
112
325
|
return e;
|
|
113
|
-
const
|
|
114
|
-
return
|
|
326
|
+
const o = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
|
|
327
|
+
return o.slice(0, -1).reduce((n, s, i) => Object(n[s]) === n[s] ? n[s] : n[s] = Math.abs(Number(o[i + 1])) >> 0 === +o[i + 1] ? [] : {}, e)[o[o.length - 1]] = r, e;
|
|
115
328
|
}, noop = () => {
|
|
116
329
|
};
|
|
117
330
|
let safeDynamicRequire = noop;
|
|
@@ -153,7 +366,7 @@ var refToProxy = (obj) => {
|
|
|
153
366
|
code: e,
|
|
154
367
|
args: t
|
|
155
368
|
}) => {
|
|
156
|
-
const r = t.map(([
|
|
369
|
+
const r = t.map(([o]) => `var ${o} = refToProxy(${getSyncValName(o)}); `).join("");
|
|
157
370
|
return `
|
|
158
371
|
${REF_TO_PROXY_FN}
|
|
159
372
|
${r}
|
|
@@ -198,8 +411,8 @@ const setIvm = (e, t) => {
|
|
|
198
411
|
code: e,
|
|
199
412
|
builder: t,
|
|
200
413
|
context: r,
|
|
201
|
-
event:
|
|
202
|
-
localState:
|
|
414
|
+
event: o,
|
|
415
|
+
localState: n,
|
|
203
416
|
rootSetState: s,
|
|
204
417
|
rootState: i
|
|
205
418
|
}) => {
|
|
@@ -211,35 +424,35 @@ const setIvm = (e, t) => {
|
|
|
211
424
|
a.setSync("global", a.derefInto()), a.setSync("log", function(...c) {
|
|
212
425
|
console.log(...c);
|
|
213
426
|
}), a.setSync(INJECTED_IVM_GLOBAL, d);
|
|
214
|
-
const
|
|
427
|
+
const I = fastClone({
|
|
215
428
|
...i,
|
|
216
|
-
...
|
|
429
|
+
...n
|
|
217
430
|
}), g = getFunctionArguments({
|
|
218
431
|
builder: t,
|
|
219
432
|
context: r,
|
|
220
|
-
event:
|
|
221
|
-
state:
|
|
433
|
+
event: o,
|
|
434
|
+
state: I
|
|
222
435
|
});
|
|
223
436
|
a.setSync(BUILDER_SET_STATE_NAME, function(c, u) {
|
|
224
437
|
set(i, c, u), s == null || s(i);
|
|
225
438
|
}), g.forEach(([c, u]) => {
|
|
226
|
-
const
|
|
439
|
+
const y = typeof u == "object" ? new d.Reference(
|
|
227
440
|
// workaround: methods with default values for arguments is not being cloned over
|
|
228
441
|
c === "builder" ? {
|
|
229
442
|
...u,
|
|
230
443
|
getUserAttributes: () => u.getUserAttributes()
|
|
231
444
|
} : u
|
|
232
445
|
) : null;
|
|
233
|
-
a.setSync(getSyncValName(c),
|
|
446
|
+
a.setSync(getSyncValName(c), y);
|
|
234
447
|
});
|
|
235
448
|
const E = processCode({
|
|
236
449
|
code: e,
|
|
237
450
|
args: g
|
|
238
|
-
}),
|
|
451
|
+
}), S = f.evalClosureSync(E);
|
|
239
452
|
try {
|
|
240
|
-
return JSON.parse(
|
|
453
|
+
return JSON.parse(S);
|
|
241
454
|
} catch {
|
|
242
|
-
return
|
|
455
|
+
return S;
|
|
243
456
|
}
|
|
244
457
|
} finally {
|
|
245
458
|
if (l)
|
|
@@ -248,7 +461,7 @@ const setIvm = (e, t) => {
|
|
|
248
461
|
} catch {
|
|
249
462
|
}
|
|
250
463
|
}
|
|
251
|
-
}
|
|
464
|
+
};
|
|
252
465
|
function isNodeRuntime() {
|
|
253
466
|
var e;
|
|
254
467
|
return typeof process < "u" && checkIsDefined((e = process == null ? void 0 : process.versions) == null ? void 0 : e.node);
|
|
@@ -256,28 +469,35 @@ function isNodeRuntime() {
|
|
|
256
469
|
const shouldForceBrowserRuntimeInNode = ({
|
|
257
470
|
shouldLogWarning: e
|
|
258
471
|
}) => {
|
|
259
|
-
var
|
|
472
|
+
var n;
|
|
260
473
|
if (!isNodeRuntime())
|
|
261
474
|
return !1;
|
|
262
|
-
const t = process.arch === "arm64", r = process.version.startsWith("v20"),
|
|
263
|
-
return t && r && !
|
|
475
|
+
const t = process.arch === "arm64", r = process.version.startsWith("v20"), o = (n = process.env.NODE_OPTIONS) == null ? void 0 : n.includes("--no-node-snapshot");
|
|
476
|
+
return t && r && !o ? (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;
|
|
264
477
|
};
|
|
265
478
|
export {
|
|
479
|
+
SDK_VERSION as S,
|
|
266
480
|
TARGET as T,
|
|
481
|
+
_track as _,
|
|
267
482
|
getBuilderGlobals as a,
|
|
268
483
|
set as b,
|
|
269
484
|
fastClone as c,
|
|
270
485
|
getSearchString as d,
|
|
271
|
-
|
|
486
|
+
getCookieSync as e,
|
|
272
487
|
flattenState as f,
|
|
273
488
|
getFunctionArguments as g,
|
|
274
|
-
|
|
489
|
+
checkIsDefined as h,
|
|
275
490
|
isBrowser as i,
|
|
276
|
-
|
|
277
|
-
|
|
491
|
+
getCookie as j,
|
|
492
|
+
setCookie as k,
|
|
278
493
|
logger as l,
|
|
494
|
+
getSdkHeaders as m,
|
|
279
495
|
normalizeSearchParams as n,
|
|
496
|
+
isEditing as o,
|
|
280
497
|
parseCode as p,
|
|
498
|
+
logFetch as q,
|
|
281
499
|
runInNode as r,
|
|
282
|
-
shouldForceBrowserRuntimeInNode as s
|
|
500
|
+
shouldForceBrowserRuntimeInNode as s,
|
|
501
|
+
track as t,
|
|
502
|
+
setIvm as u
|
|
283
503
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
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((r,o)=>{t[o]=r}),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"}},r=e.match(/Tablet|iPad/i),o=getLocation();return{urlPath:o==null?void 0:o.pathname,host:(o==null?void 0:o.host)||(o==null?void 0:o.hostname),device:r?"tablet":t.any()?"mobile":"desktop"}},SDK_VERSION="5.2.0",getSdkHeaders=()=>({"X-Builder-SDK":TARGET,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":SDK_VERSION}),checkIsDefined=e=>e!=null,getTopLevelDomain=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},getCookieSync=({name:e,canTrack:t})=>{var r;try{return t?(r=document.cookie.split("; ").find(o=>o.startsWith(`${e}=`)))==null?void 0:r.split("=")[1]:void 0}catch(o){logger.warn("[COOKIE] GET error: ",(o==null?void 0:o.message)||o);return}},getCookie=async e=>getCookieSync(e),stringifyCookie=e=>e.map(([t,r])=>r?`${t}=${r}`:t).filter(checkIsDefined).join("; "),SECURE_CONFIG=[["secure",""],["SameSite","None"]],createCookieString=({name:e,value:t,expires:r})=>{const n=(isBrowser()?location.protocol==="https:":!0)?SECURE_CONFIG:[[]],s=r?[["expires",r.toUTCString()]]:[[]],i=[[e,t],...s,["path","/"],["domain",getTopLevelDomain(window.location.hostname)],...n];return stringifyCookie(i)},setCookie=async({name:e,value:t,expires:r,canTrack:o})=>{try{if(!o)return;const n=createCookieString({name:e,value:t,expires:r});document.cookie=n}catch(n){logger.warn("[COOKIE] SET error: ",(n==null?void 0:n.message)||n)}};function uuidv4(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}function uuid(){return uuidv4().replace(/-/g,"")}const SESSION_LOCAL_STORAGE_KEY="builderSessionId",getSessionId=async({canTrack:e})=>{if(!e)return;const t=await getCookie({name:SESSION_LOCAL_STORAGE_KEY,canTrack:e});if(checkIsDefined(t))return t;{const r=createSessionId();return setSessionId({id:r,canTrack:e}),r}},createSessionId=()=>uuid(),setSessionId=({id:e,canTrack:t})=>setCookie({name:SESSION_LOCAL_STORAGE_KEY,value:e,canTrack:t}),getLocalStorage=()=>isBrowser()&&typeof localStorage<"u"?localStorage:void 0,getLocalStorageItem=({key:e,canTrack:t})=>{var r;try{return t?(r=getLocalStorage())==null?void 0:r.getItem(e):void 0}catch(o){console.debug("[LocalStorage] GET error: ",o);return}},setLocalStorageItem=({key:e,canTrack:t,value:r})=>{var o;try{t&&((o=getLocalStorage())==null||o.setItem(e,r))}catch(n){console.debug("[LocalStorage] SET error: ",n)}},VISITOR_LOCAL_STORAGE_KEY="builderVisitorId",getVisitorId=({canTrack:e})=>{if(!e)return;const t=getLocalStorageItem({key:VISITOR_LOCAL_STORAGE_KEY,canTrack:e});if(checkIsDefined(t))return t;{const r=createVisitorId();return setVisitorId({id:r,canTrack:e}),r}},createVisitorId=()=>uuid(),setVisitorId=({id:e,canTrack:t})=>setLocalStorageItem({key:VISITOR_LOCAL_STORAGE_KEY,value:e,canTrack:t});function logFetch(e){var t;typeof process<"u"&&((t=process.env)!=null&&t.DEBUG)&&String(process.env.DEBUG)=="true"&&logger.log(e)}const getTrackingEventData=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await getSessionId({canTrack:e}),r=getVisitorId({canTrack:e});return{sessionId:t,visitorId:r}},createEvent=async({type:e,canTrack:t,apiKey:r,metadata:o,...n})=>({type:e,data:{...n,metadata:{url:location.href,...o},...await getTrackingEventData({canTrack:t}),userAttributes:getUserAttributes(),ownerId:r}});async function _track({apiHost:e,...t}){if(!t.apiKey){logger.error("Missing API key for track call. Please provide your API key.");return}if(!t.canTrack||isEditing()||!(isBrowser()||TARGET==="reactNative"))return;const o=`${e||"https://cdn.builder.io"}/api/v1/track`;return logFetch(o),fetch(o,{method:"POST",body:JSON.stringify({events:[await createEvent(t)]}),headers:{"content-type":"application/json",...getSdkHeaders()},mode:"cors"}).catch(n=>{console.error("Failed to track: ",n)})}const track=e=>_track({...e,canTrack:!0}),getFunctionArguments=({builder:e,context:t,event:r,state:o})=>Object.entries({state:o,Builder:e,builder:e,context:t,event:r}),getBuilderGlobals=e=>({isEditing:isEditing(),isBrowser:isBrowser(),isServer:!isBrowser(),getUserAttributes:()=>getUserAttributes(),trackConversion:(t,r)=>{!(e!=null&&e.apiKey)||(e==null?void 0:e.canTrack)===!1||_track({type:"conversion",apiKey:e.apiKey,canTrack:e.canTrack??!0,contentId:e.contentId,variationId:e.variationId!==e.contentId?e.variationId:void 0,metadata:{...r||{},...t!==void 0?{amount:t}:{}}})}}),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:r}){return new Proxy(e,{get:(o,n)=>{if(t&&n in t)return t[n];const s=o[n];return typeof s=="object"&&s!==null?flattenState({rootState:s,localState:void 0,rootSetState:r?i=>{o[n]=i,r(o)}:void 0}):s},set:(o,n,s)=>{if(t&&n in t)throw new Error("Writing to local state is not allowed as it is read-only.");return o[n]=s,r==null||r(o),!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,r)=>{if(Object(e)!==e)return e;const o=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g);return o.slice(0,-1).reduce((n,s,i)=>Object(n[s])===n[s]?n[s]:n[s]=Math.abs(Number(o[i+1]))>>0===+o[i+1]?[]:{},e)[o[o.length-1]]=r,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-kkE7IeZS.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 r=t.map(([o])=>`var ${o} = refToProxy(${getSyncValName(o)}); `).join("");return`
|
|
28
|
+
${REF_TO_PROXY_FN}
|
|
29
|
+
${r}
|
|
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_OPTIONS={memoryLimit:128};const setIvm=(e,t)=>{IVM_INSTANCE||(IVM_INSTANCE=e,t&&(IVM_OPTIONS=t))},SHOULD_MENTION_INITIALIZE_SCRIPT=SDK_NAME==="@builder.io/sdk-react-nextjs"||SDK_NAME==="@builder.io/sdk-react"||SDK_NAME==="@builder.io/sdk-qwik"||SDK_NAME==="@builder.io/sdk-vue",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)},runInNode=({code:e,builder:t,context:r,event:o,localState:n,rootSetState:s,rootState:i})=>{const d=getIvm();let l;try{l=new d.Isolate(IVM_OPTIONS);const g=l.createContextSync(),a=g.global;a.setSync("global",a.derefInto()),a.setSync("log",function(...c){console.log(...c)}),a.setSync(INJECTED_IVM_GLOBAL,d);const I=fastClone({...i,...n}),S=getFunctionArguments({builder:t,context:r,event:o,state:I});a.setSync(BUILDER_SET_STATE_NAME,function(c,u){set(i,c,u),s==null||s(i)}),S.forEach(([c,u])=>{const m=typeof u=="object"?new d.Reference(c==="builder"?{...u,getUserAttributes:()=>u.getUserAttributes()}:u):null;a.setSync(getSyncValName(c),m)});const p=processCode({code:e,args:S}),f=g.evalClosureSync(p);try{return JSON.parse(f)}catch{return f}}finally{if(l)try{l.dispose()}catch{}}};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 n;if(!isNodeRuntime())return!1;const t=process.arch==="arm64",r=process.version.startsWith("v20"),o=(n=process.env.NODE_OPTIONS)==null?void 0:n.includes("--no-node-snapshot");return t&&r&&!o?(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.SDK_VERSION=SDK_VERSION;exports.TARGET=TARGET;exports._track=_track;exports.checkIsDefined=checkIsDefined;exports.fastClone=fastClone;exports.flattenState=flattenState;exports.getBuilderGlobals=getBuilderGlobals;exports.getCookie=getCookie;exports.getCookieSync=getCookieSync;exports.getFunctionArguments=getFunctionArguments;exports.getSdkHeaders=getSdkHeaders;exports.getSearchString=getSearchString;exports.isBrowser=isBrowser;exports.isEditing=isEditing;exports.logFetch=logFetch;exports.logger=logger;exports.normalizeSearchParams=normalizeSearchParams;exports.parseCode=parseCode;exports.runInNode=runInNode;exports.set=set;exports.setCookie=setCookie;exports.setIvm=setIvm;exports.shouldForceBrowserRuntimeInNode=shouldForceBrowserRuntimeInNode;exports.track=track;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),u=require("./should-force-browser-runtime-in-node-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),u=require("./should-force-browser-runtime-in-node-kkE7IeZS.cjs"),s=require("./index-z7Ed9MEJ.cjs"),T=require("./find-block-FREohLcp.cjs"),_=o.defineComponent({name:"block-styles",components:{InlinedStyles:s._sfc_main},props:["block","context"],data(){return{TARGET:u.TARGET}},computed:{canShowBlock(){const e=this.block;return u.checkIsDefined(e.hide)?!e.hide:u.checkIsDefined(e.show)?e.show:!0},css(){var h,B,C,f,v;const e=this.block,t=e.responsiveStyles,n=this.context.content,l=s.getSizesForBreakpoints(((h=n==null?void 0:n.meta)==null?void 0:h.breakpoints)||{}),p=!!((C=(B=n==null?void 0:n.meta)==null?void 0:B.breakpoints)!=null&&C.xsmall),a=t==null?void 0:t.large,c=t==null?void 0:t.medium,d=t==null?void 0:t.small,r=t==null?void 0:t.xsmall,m=e.id;if(!m)return"";const b=a?s.createCssClass({className:m,styles:a}):"",x=c?s.createCssClass({className:m,styles:c,mediaQuery:s.getMaxWidthQueryForSize("medium",l)}):"",g=d?s.createCssClass({className:m,styles:d,mediaQuery:s.getMaxWidthQueryForSize("small",l)}):"",k=r&&p?s.createCssClass({className:m,styles:r,mediaQuery:s.getMaxWidthQueryForSize("xsmall",l)}):"",i=e.animations&&e.animations.find(y=>y.trigger==="hover");let S="";if(i){const y=((v=(f=i.steps)==null?void 0:f[1])==null?void 0:v.styles)||{};S=s.createCssClass({className:`${m}:hover`,styles:{...y,transition:`all ${i.duration}s ${s.camelToKebabCase(i.easing)}`,transitionDelay:i.delay?`${i.delay}s`:"0s"}})||""}return[b,x,g,k,S].join(" ")}}});function E(e,t,n,l,p,a){const c=o.resolveComponent("InlinedStyles");return e.TARGET!=="reactNative"&&e.css&&e.canShowBlock?(o.openBlock(),o.createBlock(c,{key:0,id:"builderio-block",styles:e.css,nonce:e.context.nonce},null,8,["styles","nonce"])):o.createCommentVNode("",!0)}const P=s._export_sfc(_,[["render",E]]),I=o.defineComponent({name:"live-edit-block-styles",components:{InlinedStyles:s._sfc_main},props:["contextProvider","id"],data(){return{TARGET:u.TARGET}},computed:{block(){return T.findBlockById(this.contextProvider.content,this.id)},processedBlock(){var n;const e=this.block;return e?(n=e.repeat)!=null&&n.collection?e:s.getProcessedBlock({block:e,localState:this.contextProvider.localState,rootState:this.contextProvider.rootState,rootSetState:this.contextProvider.rootSetState,context:this.contextProvider.context}):null},canShowBlock(){var e,t,n,l;return u.checkIsDefined((e=this.processedBlock)==null?void 0:e.hide)?!((t=this.processedBlock)!=null&&t.hide):u.checkIsDefined((n=this.processedBlock)==null?void 0:n.show)?(l=this.processedBlock)==null?void 0:l.show:!0},css(){var S,h,B,C,f,v,y;const e=(S=this.processedBlock)==null?void 0:S.responsiveStyles,t=this.contextProvider.content,n=s.getSizesForBreakpoints(((h=t==null?void 0:t.meta)==null?void 0:h.breakpoints)||{}),l=!!((C=(B=t==null?void 0:t.meta)==null?void 0:B.breakpoints)!=null&&C.xsmall),p=e==null?void 0:e.large,a=e==null?void 0:e.medium,c=e==null?void 0:e.small,d=e==null?void 0:e.xsmall,r=(f=this.processedBlock)==null?void 0:f.id;if(!r)return"";const m=p?s.createCssClass({className:r,styles:p}):"",b=a?s.createCssClass({className:r,styles:a,mediaQuery:s.getMaxWidthQueryForSize("medium",n)}):"",x=c?s.createCssClass({className:r,styles:c,mediaQuery:s.getMaxWidthQueryForSize("small",n)}):"",g=d&&l?s.createCssClass({className:r,styles:d,mediaQuery:s.getMaxWidthQueryForSize("xsmall",n)}):"",k=this.processedBlock.animations&&this.processedBlock.animations.find($=>$.trigger==="hover");let i="";if(k){const $=((y=(v=k.steps)==null?void 0:v[1])==null?void 0:y.styles)||{};i=s.createCssClass({className:`${r}:hover`,styles:{...$,transition:`all ${k.duration}s ${s.camelToKebabCase(k.easing)}`,transitionDelay:k.delay?`${k.delay}s`:"0s"}})||""}return[m,b,x,g,i].join(" ")}}});function Q(e,t,n,l,p,a){const c=o.resolveComponent("InlinedStyles");return e.TARGET==="rsc"&&e.css&&e.canShowBlock?(o.openBlock(),o.createBlock(c,{key:0,id:"builderio-block",styles:e.css,nonce:e.contextProvider.nonce},null,8,["styles","nonce"])):o.createCommentVNode("",!0)}const A=s._export_sfc(I,[["render",Q]]),w=o.defineComponent({name:"style-wrapper",components:{BlockStyles:P,LiveEditBlockStyles:A},props:["block","context"],data(){return{isClientEditing:!1,isHydrated:!1,TARGET:u.TARGET}},inject:{contextProvider:s.BuilderContext.key},mounted(){}});function z(e,t,n,l,p,a){const c=o.resolveComponent("LiveEditBlockStyles"),d=o.resolveComponent("BlockStyles");return e.isHydrated?(o.openBlock(),o.createElementBlock(o.Fragment,{key:0},[e.TARGET==="rsc"&&e.isClientEditing?(o.openBlock(),o.createBlock(c,{key:0,id:e.block.id,contextProvider:e.contextProvider},null,8,["id","contextProvider"])):(o.openBlock(),o.createBlock(d,{key:1,block:e.block,context:e.context},null,8,["block","context"]))],64)):(o.openBlock(),o.createBlock(d,{key:1,block:e.block,context:e.context},null,8,["block","context"]))}const F=s._export_sfc(w,[["render",z]]);exports.default=F;
|