@builder.io/sdk-react-nextjs 0.17.6 → 0.17.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/blocks-exports.cjs +1 -1
- package/lib/browser/blocks-exports.mjs +14 -12
- package/lib/browser/components/blocks/blocks-wrapper.cjs +2 -2
- package/lib/browser/components/blocks/blocks-wrapper.mjs +13 -13
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/helpers/canTrack.cjs +1 -1
- package/lib/browser/helpers/canTrack.mjs +7 -3
- package/lib/browser/helpers/user-attributes.cjs +1 -0
- package/lib/browser/helpers/user-attributes.mjs +45 -0
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +32 -30
- package/lib/browser/scripts/init-editing.cjs +1 -1
- package/lib/browser/scripts/init-editing.mjs +12 -11
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +14 -12
- package/lib/edge/components/blocks/blocks-wrapper.cjs +2 -2
- package/lib/edge/components/blocks/blocks-wrapper.mjs +13 -13
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/helpers/canTrack.cjs +1 -1
- package/lib/edge/helpers/canTrack.mjs +7 -3
- package/lib/edge/helpers/user-attributes.cjs +1 -0
- package/lib/edge/helpers/user-attributes.mjs +45 -0
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +32 -30
- package/lib/edge/scripts/init-editing.cjs +1 -1
- package/lib/edge/scripts/init-editing.mjs +12 -11
- package/lib/node/blocks-exports.cjs +1 -1
- package/lib/node/blocks-exports.mjs +14 -12
- package/lib/node/components/blocks/blocks-wrapper.cjs +2 -2
- package/lib/node/components/blocks/blocks-wrapper.mjs +13 -13
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/helpers/canTrack.cjs +1 -1
- package/lib/node/helpers/canTrack.mjs +7 -3
- package/lib/node/helpers/user-attributes.cjs +1 -0
- package/lib/node/helpers/user-attributes.mjs +45 -0
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +32 -30
- package/lib/node/scripts/init-editing.cjs +1 -1
- package/lib/node/scripts/init-editing.mjs +12 -11
- package/package.json +1 -1
- package/types/cjs/blocks/personalization-container/component-info.d.ts +2 -0
- package/types/cjs/blocks/personalization-container/helpers/inlined-fns.d.ts +8 -0
- package/types/cjs/blocks/personalization-container/helpers.d.ts +27 -0
- package/types/cjs/blocks/personalization-container/index.d.ts +1 -0
- package/types/cjs/blocks/personalization-container/personalization-container.d.ts +4 -0
- package/types/cjs/blocks/personalization-container/personalization-container.types.d.ts +14 -0
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/helpers/user-attributes.d.ts +17 -0
- package/types/cjs/index-helpers/blocks-exports.d.ts +1 -0
- package/types/cjs/types/input.d.ts +1 -0
- package/types/esm/blocks/personalization-container/component-info.d.ts +2 -0
- package/types/esm/blocks/personalization-container/helpers/inlined-fns.d.ts +8 -0
- package/types/esm/blocks/personalization-container/helpers.d.ts +27 -0
- package/types/esm/blocks/personalization-container/index.d.ts +1 -0
- package/types/esm/blocks/personalization-container/personalization-container.d.ts +4 -0
- package/types/esm/blocks/personalization-container/personalization-container.types.d.ts +14 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/helpers/user-attributes.d.ts +17 -0
- package/types/esm/index-helpers/blocks-exports.d.ts +1 -0
- package/types/esm/types/input.d.ts +1 -0
package/lib/edge/index.mjs
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as r } from "./blocks/button/button.mjs";
|
|
2
2
|
import { default as f } from "./blocks/columns/columns.mjs";
|
|
3
|
-
import { default as
|
|
3
|
+
import { default as a } from "./blocks/fragment/fragment.mjs";
|
|
4
4
|
import { default as p } from "./blocks/image/image.mjs";
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
5
|
+
import { default as i } from "./blocks/section/section.mjs";
|
|
6
|
+
import { default as u } from "./blocks/symbol/symbol.mjs";
|
|
7
7
|
import { default as n } from "./blocks/text/text.mjs";
|
|
8
8
|
import { default as g } from "./blocks/video/video.mjs";
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
9
|
+
import { default as B } from "./components/blocks/blocks.mjs";
|
|
10
|
+
import { default as b } from "./components/content-variants/content-variants.mjs";
|
|
11
|
+
import { default as S } from "./context/builder.context.mjs";
|
|
12
|
+
import { setClientUserAttributes as k } from "./helpers/user-attributes.mjs";
|
|
13
|
+
import { isEditing as R } from "./functions/is-editing.mjs";
|
|
14
|
+
import { isPreviewing as v } from "./functions/is-previewing.mjs";
|
|
15
|
+
import { createRegisterComponentMessage as A } from "./functions/register-component.mjs";
|
|
16
|
+
import { register as I } from "./functions/register.mjs";
|
|
17
|
+
import { setEditorSettings as O } from "./functions/set-editor-settings.mjs";
|
|
17
18
|
import { getBuilderSearchParams as V } from "./functions/get-builder-search-params/index.mjs";
|
|
18
19
|
import { track as j } from "./functions/track/index.mjs";
|
|
19
20
|
import { subscribeToEditor as z } from "./helpers/subscribe-to-editor.mjs";
|
|
20
|
-
import { fetchBuilderProps as
|
|
21
|
-
import { _processContentResult as
|
|
21
|
+
import { fetchBuilderProps as G } from "./functions/fetch-builder-props.mjs";
|
|
22
|
+
import { _processContentResult as J, fetchEntries as K, fetchOneEntry as L } from "./functions/get-content/index.mjs";
|
|
22
23
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
B as Blocks,
|
|
25
|
+
S as BuilderContext,
|
|
26
|
+
r as Button,
|
|
26
27
|
f as Columns,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
b as Content,
|
|
29
|
+
a as Fragment,
|
|
29
30
|
p as Image,
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
i as Section,
|
|
32
|
+
u as Symbol,
|
|
32
33
|
n as Text,
|
|
33
34
|
g as Video,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
J as _processContentResult,
|
|
36
|
+
A as createRegisterComponentMessage,
|
|
37
|
+
G as fetchBuilderProps,
|
|
38
|
+
K as fetchEntries,
|
|
39
|
+
L as fetchOneEntry,
|
|
39
40
|
V as getBuilderSearchParams,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
R as isEditing,
|
|
42
|
+
v as isPreviewing,
|
|
43
|
+
I as register,
|
|
44
|
+
k as setClientUserAttributes,
|
|
45
|
+
O as setEditorSettings,
|
|
44
46
|
z as subscribeToEditor,
|
|
45
47
|
j as track
|
|
46
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../constants/sdk-version.cjs"),y=require("../constants/target.cjs"),b=require("../functions/is-browser.cjs"),M=require("../functions/is-from-trusted-host.cjs"),B=require("../functions/register.cjs"),E=()=>{B.register("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let c=!1;const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../constants/sdk-version.cjs"),y=require("../constants/target.cjs"),b=require("../functions/is-browser.cjs"),M=require("../functions/is-from-trusted-host.cjs"),B=require("../functions/register.cjs"),E=()=>{B.register("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let c=!1;const v=(o={})=>{var a,i;c||(c=!0,b.isBrowser()&&((a=window.parent)==null||a.postMessage({type:"builder.sdkInfo",data:{target:y.TARGET,version:f.SDK_VERSION,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,blockLevelPersonalization:!0}},"*"),(i=window.parent)==null||i.postMessage({type:"builder.updateContent",data:{options:o}},"*"),window.addEventListener("message",u=>{var d,l;if(!M.isFromTrustedHost(o.trustedHosts,u))return;const{data:e}=u;if(e!=null&&e.type)switch(e.type){case"builder.evaluate":{const g=e.data.text,m=e.data.arguments||[],r=e.data.id,w=new Function(g);let t,s=null;try{t=w.apply(null,m)}catch(n){s=n}s?(d=window.parent)==null||d.postMessage({type:"builder.evaluateError",data:{id:r,error:s.message}},"*"):t&&typeof t.then=="function"?t.then(n=>{var p;(p=window.parent)==null||p.postMessage({type:"builder.evaluateResult",data:{id:r,result:n}},"*")}).catch(console.error):(l=window.parent)==null||l.postMessage({type:"builder.evaluateResult",data:{result:t,id:r}},"*");break}}})))};exports.registerInsertMenu=E;exports.setupBrowserForEditing=v;
|
|
@@ -3,7 +3,7 @@ import { TARGET as y } from "../constants/target.mjs";
|
|
|
3
3
|
import { isBrowser as b } from "../functions/is-browser.mjs";
|
|
4
4
|
import { isFromTrustedHost as C } from "../functions/is-from-trusted-host.mjs";
|
|
5
5
|
import { register as E } from "../functions/register.mjs";
|
|
6
|
-
const
|
|
6
|
+
const x = () => {
|
|
7
7
|
E("insertMenu", {
|
|
8
8
|
name: "_default",
|
|
9
9
|
default: !0,
|
|
@@ -27,7 +27,7 @@ const S = () => {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
let m = !1;
|
|
30
|
-
const
|
|
30
|
+
const S = (a = {}) => {
|
|
31
31
|
var n, i;
|
|
32
32
|
m || (m = !0, b() && ((n = window.parent) == null || n.postMessage({
|
|
33
33
|
type: "builder.sdkInfo",
|
|
@@ -38,16 +38,17 @@ const k = (o = {}) => {
|
|
|
38
38
|
// Supports builder-model="..." attribute which is needed to
|
|
39
39
|
// scope our '+ add block' button styling
|
|
40
40
|
supportsAddBlockScoping: !0,
|
|
41
|
-
supportsCustomBreakpoints: !0
|
|
41
|
+
supportsCustomBreakpoints: !0,
|
|
42
|
+
blockLevelPersonalization: !0
|
|
42
43
|
}
|
|
43
44
|
}, "*"), (i = window.parent) == null || i.postMessage({
|
|
44
45
|
type: "builder.updateContent",
|
|
45
46
|
data: {
|
|
46
|
-
options:
|
|
47
|
+
options: a
|
|
47
48
|
}
|
|
48
49
|
}, "*"), window.addEventListener("message", (u) => {
|
|
49
50
|
var p, d;
|
|
50
|
-
if (!C(
|
|
51
|
+
if (!C(a.trustedHosts, u))
|
|
51
52
|
return;
|
|
52
53
|
const {
|
|
53
54
|
data: e
|
|
@@ -59,8 +60,8 @@ const k = (o = {}) => {
|
|
|
59
60
|
let t, s = null;
|
|
60
61
|
try {
|
|
61
62
|
t = g.apply(null, f);
|
|
62
|
-
} catch (
|
|
63
|
-
s =
|
|
63
|
+
} catch (o) {
|
|
64
|
+
s = o;
|
|
64
65
|
}
|
|
65
66
|
s ? (p = window.parent) == null || p.postMessage({
|
|
66
67
|
type: "builder.evaluateError",
|
|
@@ -68,13 +69,13 @@ const k = (o = {}) => {
|
|
|
68
69
|
id: r,
|
|
69
70
|
error: s.message
|
|
70
71
|
}
|
|
71
|
-
}, "*") : t && typeof t.then == "function" ? t.then((
|
|
72
|
+
}, "*") : t && typeof t.then == "function" ? t.then((o) => {
|
|
72
73
|
var l;
|
|
73
74
|
(l = window.parent) == null || l.postMessage({
|
|
74
75
|
type: "builder.evaluateResult",
|
|
75
76
|
data: {
|
|
76
77
|
id: r,
|
|
77
|
-
result:
|
|
78
|
+
result: o
|
|
78
79
|
}
|
|
79
80
|
}, "*");
|
|
80
81
|
}).catch(console.error) : (d = window.parent) == null || d.postMessage({
|
|
@@ -90,6 +91,6 @@ const k = (o = {}) => {
|
|
|
90
91
|
})));
|
|
91
92
|
};
|
|
92
93
|
export {
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
x as registerInsertMenu,
|
|
95
|
+
S as setupBrowserForEditing
|
|
95
96
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./blocks/button/button.cjs"),t=require("./blocks/columns/columns.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./blocks/button/button.cjs"),t=require("./blocks/columns/columns.cjs"),r=require("./blocks/fragment/fragment.cjs"),o=require("./blocks/image/image.cjs"),n=require("./blocks/section/section.cjs"),s=require("./blocks/symbol/symbol.cjs"),i=require("./blocks/text/text.cjs"),u=require("./blocks/video/video.cjs"),c=require("./components/blocks/blocks.cjs"),l=require("./components/content-variants/content-variants.cjs"),q=require("./context/builder.context.cjs"),b=require("./helpers/user-attributes.cjs");exports.Button=e;exports.Columns=t;exports.Fragment=r;exports.Image=o;exports.Section=n;exports.Symbol=s;exports.Text=i;exports.Video=u;exports.Blocks=c;exports.Content=l;exports.BuilderContext=q;exports.setClientUserAttributes=b.setClientUserAttributes;
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { default as o } from "./blocks/button/button.mjs";
|
|
2
|
-
import { default as
|
|
2
|
+
import { default as a } from "./blocks/columns/columns.mjs";
|
|
3
3
|
import { default as l } from "./blocks/fragment/fragment.mjs";
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as
|
|
4
|
+
import { default as s } from "./blocks/image/image.mjs";
|
|
5
|
+
import { default as x } from "./blocks/section/section.mjs";
|
|
6
6
|
import { default as p } from "./blocks/symbol/symbol.mjs";
|
|
7
7
|
import { default as i } from "./blocks/text/text.mjs";
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
8
|
+
import { default as B } from "./blocks/video/video.mjs";
|
|
9
|
+
import { default as c } from "./components/blocks/blocks.mjs";
|
|
10
|
+
import { default as S } from "./components/content-variants/content-variants.mjs";
|
|
11
11
|
import { default as y } from "./context/builder.context.mjs";
|
|
12
|
+
import { setClientUserAttributes as F } from "./helpers/user-attributes.mjs";
|
|
12
13
|
export {
|
|
13
|
-
|
|
14
|
+
c as Blocks,
|
|
14
15
|
y as BuilderContext,
|
|
15
16
|
o as Button,
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
a as Columns,
|
|
18
|
+
S as Content,
|
|
18
19
|
l as Fragment,
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
s as Image,
|
|
21
|
+
x as Section,
|
|
21
22
|
p as Symbol,
|
|
22
23
|
i as Text,
|
|
23
|
-
|
|
24
|
+
B as Video,
|
|
25
|
+
F as setClientUserAttributes
|
|
24
26
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use client";"use strict";const i=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";const i=require("react/jsx-runtime"),r=require("react"),l=require("../../functions/is-editing.cjs");function u(e){const c=r.useRef(null);function o(){var t;return["builder-blocks",(t=e.blocks)!=null&&t.length?"":"no-blocks",e.classNameProp].filter(Boolean).join(" ")}function a(){if(!e.path)return;const t="this.",n="component.options.";return e.path.startsWith(t)?e.path.replace(t,""):e.path.startsWith(n)?e.path:`${n}${e.path||""}`}function s(){var t,n;l.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:a()}},"*"))}function d(){var t,n;l.isEditing()&&!((t=e.blocks)!=null&&t.length)&&((n=window.parent)==null||n.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:a()}},"*"))}return r.useEffect(()=>{},[]),i.jsxs(i.Fragment,{children:[i.jsx(e.BlocksWrapper,{ref:c,className:o()+" props-blocks-wrapper-78b0d3be","builder-path":a(),"builder-parent-id":e.parent,style:e.styleProp,onClick:t=>s(),onMouseEnter:t=>d(),onKeyPress:t=>s(),...e.BlocksWrapperProps,children:e.children}),i.jsx("style",{children:`.props-blocks-wrapper-78b0d3be {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: stretch;
|
|
5
|
-
}`})]})}module.exports=
|
|
5
|
+
}`})]})}module.exports=u;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as d, Fragment as
|
|
3
|
-
import { useRef as f, useEffect as
|
|
2
|
+
import { jsxs as d, Fragment as h, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as f, useEffect as u } from "react";
|
|
4
4
|
import { isEditing as i } from "../../functions/is-editing.mjs";
|
|
5
|
-
function
|
|
5
|
+
function k(e) {
|
|
6
6
|
const o = f(null);
|
|
7
|
-
function
|
|
7
|
+
function s() {
|
|
8
8
|
var t;
|
|
9
9
|
return [
|
|
10
10
|
"builder-blocks",
|
|
@@ -15,8 +15,8 @@ function b(e) {
|
|
|
15
15
|
function a() {
|
|
16
16
|
if (!e.path)
|
|
17
17
|
return;
|
|
18
|
-
const t = "component.options.";
|
|
19
|
-
return e.path.startsWith(t) ? e.path : `${
|
|
18
|
+
const t = "this.", n = "component.options.";
|
|
19
|
+
return e.path.startsWith(t) ? e.path.replace(t, "") : e.path.startsWith(n) ? e.path : `${n}${e.path || ""}`;
|
|
20
20
|
}
|
|
21
21
|
function l() {
|
|
22
22
|
var t, n;
|
|
@@ -31,7 +31,7 @@ function b(e) {
|
|
|
31
31
|
"*"
|
|
32
32
|
));
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function c() {
|
|
35
35
|
var t, n;
|
|
36
36
|
i() && !((t = e.blocks) != null && t.length) && ((n = window.parent) == null || n.postMessage(
|
|
37
37
|
{
|
|
@@ -44,24 +44,24 @@ function b(e) {
|
|
|
44
44
|
"*"
|
|
45
45
|
));
|
|
46
46
|
}
|
|
47
|
-
return
|
|
48
|
-
}, []), /* @__PURE__ */ d(
|
|
47
|
+
return u(() => {
|
|
48
|
+
}, []), /* @__PURE__ */ d(h, { children: [
|
|
49
49
|
/* @__PURE__ */ r(
|
|
50
50
|
e.BlocksWrapper,
|
|
51
51
|
{
|
|
52
52
|
ref: o,
|
|
53
|
-
className:
|
|
53
|
+
className: s() + " props-blocks-wrapper-78b0d3be",
|
|
54
54
|
"builder-path": a(),
|
|
55
55
|
"builder-parent-id": e.parent,
|
|
56
56
|
style: e.styleProp,
|
|
57
57
|
onClick: (t) => l(),
|
|
58
|
-
onMouseEnter: (t) =>
|
|
58
|
+
onMouseEnter: (t) => c(),
|
|
59
59
|
onKeyPress: (t) => l(),
|
|
60
60
|
...e.BlocksWrapperProps,
|
|
61
61
|
children: e.children
|
|
62
62
|
}
|
|
63
63
|
),
|
|
64
|
-
/* @__PURE__ */ r("style", { children: `.props-blocks-wrapper-
|
|
64
|
+
/* @__PURE__ */ r("style", { children: `.props-blocks-wrapper-78b0d3be {
|
|
65
65
|
display: flex;
|
|
66
66
|
flex-direction: column;
|
|
67
67
|
align-items: stretch;
|
|
@@ -69,5 +69,5 @@ function b(e) {
|
|
|
69
69
|
] });
|
|
70
70
|
}
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
k as default
|
|
73
73
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.17.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.17.7";exports.SDK_VERSION=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./nullable.cjs"),u=require("./user-attributes.cjs"),s=e=>{const t=r.checkIsDefined(e)?e:!0;return u.userAttributesService.setCanTrack(t),t};exports.getDefaultCanTrack=s;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { checkIsDefined as
|
|
2
|
-
|
|
1
|
+
import { checkIsDefined as r } from "./nullable.mjs";
|
|
2
|
+
import { userAttributesService as o } from "./user-attributes.mjs";
|
|
3
|
+
const c = (e) => {
|
|
4
|
+
const t = r(e) ? e : !0;
|
|
5
|
+
return o.setCanTrack(t), t;
|
|
6
|
+
};
|
|
3
7
|
export {
|
|
4
|
-
|
|
8
|
+
c as getDefaultCanTrack
|
|
5
9
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../functions/is-browser.cjs"),n=require("./cookie.cjs"),s="builder.userAttributes";function c(){let t=!0;const r=new Set;return{setUserAttributes(e){if(!u.isBrowser())return;const i={...this.getUserAttributes(),...e};n.setCookie({name:s,value:JSON.stringify(i),canTrack:t}),r.forEach(b=>b(i))},getUserAttributes(){return u.isBrowser()?JSON.parse(n.getCookieSync({name:s,canTrack:t})||"{}"):{}},subscribeOnUserAttributesChange(e){return r.add(e),()=>{r.delete(e)}},setCanTrack(e){t=e}}}const o=c(),A=t=>{o.setUserAttributes(t)};exports.USER_ATTRIBUTES_COOKIE_NAME=s;exports.createUserAttributesService=c;exports.setClientUserAttributes=A;exports.userAttributesService=o;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isBrowser as i } from "../functions/is-browser.mjs";
|
|
2
|
+
import { setCookie as o, getCookieSync as b } from "./cookie.mjs";
|
|
3
|
+
const u = "builder.userAttributes";
|
|
4
|
+
function c() {
|
|
5
|
+
let e = !0;
|
|
6
|
+
const r = /* @__PURE__ */ new Set();
|
|
7
|
+
return {
|
|
8
|
+
setUserAttributes(t) {
|
|
9
|
+
if (!i())
|
|
10
|
+
return;
|
|
11
|
+
const s = {
|
|
12
|
+
...this.getUserAttributes(),
|
|
13
|
+
...t
|
|
14
|
+
};
|
|
15
|
+
o({
|
|
16
|
+
name: u,
|
|
17
|
+
value: JSON.stringify(s),
|
|
18
|
+
canTrack: e
|
|
19
|
+
}), r.forEach((n) => n(s));
|
|
20
|
+
},
|
|
21
|
+
getUserAttributes() {
|
|
22
|
+
return i() ? JSON.parse(b({
|
|
23
|
+
name: u,
|
|
24
|
+
canTrack: e
|
|
25
|
+
}) || "{}") : {};
|
|
26
|
+
},
|
|
27
|
+
subscribeOnUserAttributesChange(t) {
|
|
28
|
+
return r.add(t), () => {
|
|
29
|
+
r.delete(t);
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
setCanTrack(t) {
|
|
33
|
+
e = t;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const A = c(), S = (e) => {
|
|
38
|
+
A.setUserAttributes(e);
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
u as USER_ATTRIBUTES_COOKIE_NAME,
|
|
42
|
+
c as createUserAttributesService,
|
|
43
|
+
S as setClientUserAttributes,
|
|
44
|
+
A as userAttributesService
|
|
45
|
+
};
|
package/lib/node/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks/button/button.cjs"),r=require("./blocks/columns/columns.cjs"),i=require("./blocks/fragment/fragment.cjs"),s=require("./blocks/image/image.cjs"),n=require("./blocks/section/section.cjs"),o=require("./blocks/symbol/symbol.cjs"),c=require("./blocks/text/text.cjs"),u=require("./blocks/video/video.cjs"),g=require("./components/blocks/blocks.cjs"),d=require("./components/content-variants/content-variants.cjs"),q=require("./context/builder.context.cjs"),a=require("./functions/is-editing.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks/button/button.cjs"),r=require("./blocks/columns/columns.cjs"),i=require("./blocks/fragment/fragment.cjs"),s=require("./blocks/image/image.cjs"),n=require("./blocks/section/section.cjs"),o=require("./blocks/symbol/symbol.cjs"),c=require("./blocks/text/text.cjs"),u=require("./blocks/video/video.cjs"),g=require("./components/blocks/blocks.cjs"),d=require("./components/content-variants/content-variants.cjs"),q=require("./context/builder.context.cjs"),a=require("./helpers/user-attributes.cjs"),l=require("./functions/is-editing.cjs"),b=require("./functions/is-previewing.cjs"),m=require("./functions/register-component.cjs"),E=require("./functions/register.cjs"),C=require("./functions/set-editor-settings.cjs"),f=require("./functions/get-builder-search-params/index.cjs"),h=require("./functions/track/index.cjs"),p=require("./helpers/subscribe-to-editor.cjs"),P=require("./functions/fetch-builder-props.cjs"),e=require("./functions/get-content/index.cjs");exports.Button=t;exports.Columns=r;exports.Fragment=i;exports.Image=s;exports.Section=n;exports.Symbol=o;exports.Text=c;exports.Video=u;exports.Blocks=g;exports.Content=d;exports.BuilderContext=q;exports.setClientUserAttributes=a.setClientUserAttributes;exports.isEditing=l.isEditing;exports.isPreviewing=b.isPreviewing;exports.createRegisterComponentMessage=m.createRegisterComponentMessage;exports.register=E.register;exports.setEditorSettings=C.setEditorSettings;exports.getBuilderSearchParams=f.getBuilderSearchParams;exports.track=h.track;exports.subscribeToEditor=p.subscribeToEditor;exports.fetchBuilderProps=P.fetchBuilderProps;exports._processContentResult=e._processContentResult;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;
|
package/lib/node/index.mjs
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as r } from "./blocks/button/button.mjs";
|
|
2
2
|
import { default as f } from "./blocks/columns/columns.mjs";
|
|
3
|
-
import { default as
|
|
3
|
+
import { default as a } from "./blocks/fragment/fragment.mjs";
|
|
4
4
|
import { default as p } from "./blocks/image/image.mjs";
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
5
|
+
import { default as i } from "./blocks/section/section.mjs";
|
|
6
|
+
import { default as u } from "./blocks/symbol/symbol.mjs";
|
|
7
7
|
import { default as n } from "./blocks/text/text.mjs";
|
|
8
8
|
import { default as g } from "./blocks/video/video.mjs";
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
9
|
+
import { default as B } from "./components/blocks/blocks.mjs";
|
|
10
|
+
import { default as b } from "./components/content-variants/content-variants.mjs";
|
|
11
|
+
import { default as S } from "./context/builder.context.mjs";
|
|
12
|
+
import { setClientUserAttributes as k } from "./helpers/user-attributes.mjs";
|
|
13
|
+
import { isEditing as R } from "./functions/is-editing.mjs";
|
|
14
|
+
import { isPreviewing as v } from "./functions/is-previewing.mjs";
|
|
15
|
+
import { createRegisterComponentMessage as A } from "./functions/register-component.mjs";
|
|
16
|
+
import { register as I } from "./functions/register.mjs";
|
|
17
|
+
import { setEditorSettings as O } from "./functions/set-editor-settings.mjs";
|
|
17
18
|
import { getBuilderSearchParams as V } from "./functions/get-builder-search-params/index.mjs";
|
|
18
19
|
import { track as j } from "./functions/track/index.mjs";
|
|
19
20
|
import { subscribeToEditor as z } from "./helpers/subscribe-to-editor.mjs";
|
|
20
|
-
import { fetchBuilderProps as
|
|
21
|
-
import { _processContentResult as
|
|
21
|
+
import { fetchBuilderProps as G } from "./functions/fetch-builder-props.mjs";
|
|
22
|
+
import { _processContentResult as J, fetchEntries as K, fetchOneEntry as L } from "./functions/get-content/index.mjs";
|
|
22
23
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
B as Blocks,
|
|
25
|
+
S as BuilderContext,
|
|
26
|
+
r as Button,
|
|
26
27
|
f as Columns,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
b as Content,
|
|
29
|
+
a as Fragment,
|
|
29
30
|
p as Image,
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
i as Section,
|
|
32
|
+
u as Symbol,
|
|
32
33
|
n as Text,
|
|
33
34
|
g as Video,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
J as _processContentResult,
|
|
36
|
+
A as createRegisterComponentMessage,
|
|
37
|
+
G as fetchBuilderProps,
|
|
38
|
+
K as fetchEntries,
|
|
39
|
+
L as fetchOneEntry,
|
|
39
40
|
V as getBuilderSearchParams,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
R as isEditing,
|
|
42
|
+
v as isPreviewing,
|
|
43
|
+
I as register,
|
|
44
|
+
k as setClientUserAttributes,
|
|
45
|
+
O as setEditorSettings,
|
|
44
46
|
z as subscribeToEditor,
|
|
45
47
|
j as track
|
|
46
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../constants/sdk-version.cjs"),y=require("../constants/target.cjs"),b=require("../functions/is-browser.cjs"),M=require("../functions/is-from-trusted-host.cjs"),B=require("../functions/register.cjs"),E=()=>{B.register("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let c=!1;const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../constants/sdk-version.cjs"),y=require("../constants/target.cjs"),b=require("../functions/is-browser.cjs"),M=require("../functions/is-from-trusted-host.cjs"),B=require("../functions/register.cjs"),E=()=>{B.register("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let c=!1;const v=(o={})=>{var a,i;c||(c=!0,b.isBrowser()&&((a=window.parent)==null||a.postMessage({type:"builder.sdkInfo",data:{target:y.TARGET,version:f.SDK_VERSION,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,blockLevelPersonalization:!0}},"*"),(i=window.parent)==null||i.postMessage({type:"builder.updateContent",data:{options:o}},"*"),window.addEventListener("message",u=>{var d,l;if(!M.isFromTrustedHost(o.trustedHosts,u))return;const{data:e}=u;if(e!=null&&e.type)switch(e.type){case"builder.evaluate":{const g=e.data.text,m=e.data.arguments||[],r=e.data.id,w=new Function(g);let t,s=null;try{t=w.apply(null,m)}catch(n){s=n}s?(d=window.parent)==null||d.postMessage({type:"builder.evaluateError",data:{id:r,error:s.message}},"*"):t&&typeof t.then=="function"?t.then(n=>{var p;(p=window.parent)==null||p.postMessage({type:"builder.evaluateResult",data:{id:r,result:n}},"*")}).catch(console.error):(l=window.parent)==null||l.postMessage({type:"builder.evaluateResult",data:{result:t,id:r}},"*");break}}})))};exports.registerInsertMenu=E;exports.setupBrowserForEditing=v;
|
|
@@ -3,7 +3,7 @@ import { TARGET as y } from "../constants/target.mjs";
|
|
|
3
3
|
import { isBrowser as b } from "../functions/is-browser.mjs";
|
|
4
4
|
import { isFromTrustedHost as C } from "../functions/is-from-trusted-host.mjs";
|
|
5
5
|
import { register as E } from "../functions/register.mjs";
|
|
6
|
-
const
|
|
6
|
+
const x = () => {
|
|
7
7
|
E("insertMenu", {
|
|
8
8
|
name: "_default",
|
|
9
9
|
default: !0,
|
|
@@ -27,7 +27,7 @@ const S = () => {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
let m = !1;
|
|
30
|
-
const
|
|
30
|
+
const S = (a = {}) => {
|
|
31
31
|
var n, i;
|
|
32
32
|
m || (m = !0, b() && ((n = window.parent) == null || n.postMessage({
|
|
33
33
|
type: "builder.sdkInfo",
|
|
@@ -38,16 +38,17 @@ const k = (o = {}) => {
|
|
|
38
38
|
// Supports builder-model="..." attribute which is needed to
|
|
39
39
|
// scope our '+ add block' button styling
|
|
40
40
|
supportsAddBlockScoping: !0,
|
|
41
|
-
supportsCustomBreakpoints: !0
|
|
41
|
+
supportsCustomBreakpoints: !0,
|
|
42
|
+
blockLevelPersonalization: !0
|
|
42
43
|
}
|
|
43
44
|
}, "*"), (i = window.parent) == null || i.postMessage({
|
|
44
45
|
type: "builder.updateContent",
|
|
45
46
|
data: {
|
|
46
|
-
options:
|
|
47
|
+
options: a
|
|
47
48
|
}
|
|
48
49
|
}, "*"), window.addEventListener("message", (u) => {
|
|
49
50
|
var p, d;
|
|
50
|
-
if (!C(
|
|
51
|
+
if (!C(a.trustedHosts, u))
|
|
51
52
|
return;
|
|
52
53
|
const {
|
|
53
54
|
data: e
|
|
@@ -59,8 +60,8 @@ const k = (o = {}) => {
|
|
|
59
60
|
let t, s = null;
|
|
60
61
|
try {
|
|
61
62
|
t = g.apply(null, f);
|
|
62
|
-
} catch (
|
|
63
|
-
s =
|
|
63
|
+
} catch (o) {
|
|
64
|
+
s = o;
|
|
64
65
|
}
|
|
65
66
|
s ? (p = window.parent) == null || p.postMessage({
|
|
66
67
|
type: "builder.evaluateError",
|
|
@@ -68,13 +69,13 @@ const k = (o = {}) => {
|
|
|
68
69
|
id: r,
|
|
69
70
|
error: s.message
|
|
70
71
|
}
|
|
71
|
-
}, "*") : t && typeof t.then == "function" ? t.then((
|
|
72
|
+
}, "*") : t && typeof t.then == "function" ? t.then((o) => {
|
|
72
73
|
var l;
|
|
73
74
|
(l = window.parent) == null || l.postMessage({
|
|
74
75
|
type: "builder.evaluateResult",
|
|
75
76
|
data: {
|
|
76
77
|
id: r,
|
|
77
|
-
result:
|
|
78
|
+
result: o
|
|
78
79
|
}
|
|
79
80
|
}, "*");
|
|
80
81
|
}).catch(console.error) : (d = window.parent) == null || d.postMessage({
|
|
@@ -90,6 +91,6 @@ const k = (o = {}) => {
|
|
|
90
91
|
})));
|
|
91
92
|
};
|
|
92
93
|
export {
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
x as registerInsertMenu,
|
|
95
|
+
S as setupBrowserForEditing
|
|
95
96
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react-nextjs",
|
|
3
3
|
"description": "Builder.io RSC SDK for NextJS App Directory",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.7",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WARNING: This file contains functions that get stringified and inlined into the HTML at build-time.
|
|
3
|
+
* They cannot import anything.
|
|
4
|
+
*/
|
|
5
|
+
import type { Query, UserAttributes } from '../helpers.js';
|
|
6
|
+
export declare function filterWithCustomTargeting(userAttributes: UserAttributes, query: Query[], startDate?: string, endDate?: string): boolean;
|
|
7
|
+
export declare const PERSONALIZATION_SCRIPT = "function getPersonalizedVariant(variants, blockId, locale) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) == ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n function removeVariants() {\n variants?.forEach(function (_, index) {\n document.querySelector('template[data-variant-id=\"' + blockId + '-' + index + '\"]')?.remove();\n });\n document.querySelector('script[data-id=\"variants-script-' + blockId + '\"]')?.remove();\n document.querySelector('style[data-id=\"variants-styles-' + blockId + '\"]')?.remove();\n }\n const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n const isDebug = location.href.includes('builder.debug=true');\n if (isDebug) {\n console.debug('PersonalizationContainer', {\n attributes,\n variants,\n winningVariantIndex\n });\n }\n if (winningVariantIndex !== -1) {\n const winningVariant = document.querySelector('template[data-variant-id=\"' + blockId + '-' + winningVariantIndex + '\"]');\n if (winningVariant) {\n const parentNode = winningVariant.parentNode;\n if (parentNode) {\n const newParent = parentNode.cloneNode(false);\n newParent.appendChild(winningVariant.content.firstChild);\n newParent.appendChild(winningVariant.content.lastChild);\n parentNode.parentNode?.replaceChild(newParent, parentNode);\n }\n if (isDebug) {\n console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);\n }\n }\n } else if (variants && variants.length > 0) {\n removeVariants();\n }\n}";
|
|
8
|
+
export declare const FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BuilderBlock } from '../../types/builder-block.js';
|
|
2
|
+
import type { PersonalizationContainerProps } from './personalization-container.types.js';
|
|
3
|
+
export type UserAttributes = {
|
|
4
|
+
date?: string | Date;
|
|
5
|
+
urlPath?: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
type QueryOperator = 'is' | 'isNot' | 'contains' | 'startsWith' | 'endsWith' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqualTo' | 'lessThanOrEqualTo';
|
|
9
|
+
type QueryValue = string | number | boolean | Array<string | number | boolean>;
|
|
10
|
+
export type Query = {
|
|
11
|
+
property: string;
|
|
12
|
+
operator: QueryOperator;
|
|
13
|
+
value: QueryValue;
|
|
14
|
+
};
|
|
15
|
+
export declare function checkShouldRenderVariants(variants: PersonalizationContainerProps['variants'], canTrack: boolean): boolean;
|
|
16
|
+
export declare function getBlocksToRender({ variants, previewingIndex, isHydrated, filteredVariants, fallbackBlocks }: {
|
|
17
|
+
variants: PersonalizationContainerProps['variants'];
|
|
18
|
+
previewingIndex?: number | null;
|
|
19
|
+
isHydrated: boolean;
|
|
20
|
+
filteredVariants: PersonalizationContainerProps['variants'];
|
|
21
|
+
fallbackBlocks?: BuilderBlock[];
|
|
22
|
+
}): {
|
|
23
|
+
blocks: BuilderBlock[];
|
|
24
|
+
path: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
export declare const getPersonalizationScript: (variants: PersonalizationContainerProps['variants'], blockId: string, locale?: string) => string;
|
|
27
|
+
export { filterWithCustomTargeting } from './helpers/inlined-fns.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './personalization-container.js';
|