@builder.io/sdk-react-nextjs 0.18.1 → 0.18.8

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 (61) hide show
  1. package/lib/browser/blocks/custom-code/custom-code.cjs +1 -1
  2. package/lib/browser/blocks/custom-code/custom-code.mjs +27 -17
  3. package/lib/browser/blocks/embed/embed.cjs +1 -1
  4. package/lib/browser/blocks/embed/embed.mjs +16 -15
  5. package/lib/browser/blocks/image/component-info.cjs +1 -1
  6. package/lib/browser/blocks/image/component-info.mjs +12 -8
  7. package/lib/browser/blocks/image/image.cjs +4 -4
  8. package/lib/browser/blocks/image/image.mjs +14 -13
  9. package/lib/browser/components/blocks/blocks-wrapper.cjs +2 -2
  10. package/lib/browser/components/blocks/blocks-wrapper.mjs +18 -16
  11. package/lib/browser/components/content/components/enable-editor.cjs +1 -1
  12. package/lib/browser/components/content/components/enable-editor.mjs +65 -58
  13. package/lib/browser/components/content-variants/helpers.cjs +9 -9
  14. package/lib/browser/components/content-variants/helpers.mjs +16 -16
  15. package/lib/browser/components/content-variants/inlined-fns.cjs +5 -2
  16. package/lib/browser/components/content-variants/inlined-fns.mjs +5 -2
  17. package/lib/browser/constants/sdk-version.cjs +1 -1
  18. package/lib/browser/constants/sdk-version.mjs +1 -1
  19. package/lib/edge/blocks/custom-code/custom-code.cjs +1 -1
  20. package/lib/edge/blocks/custom-code/custom-code.mjs +27 -17
  21. package/lib/edge/blocks/embed/embed.cjs +1 -1
  22. package/lib/edge/blocks/embed/embed.mjs +16 -15
  23. package/lib/edge/blocks/image/component-info.cjs +1 -1
  24. package/lib/edge/blocks/image/component-info.mjs +12 -8
  25. package/lib/edge/blocks/image/image.cjs +4 -4
  26. package/lib/edge/blocks/image/image.mjs +14 -13
  27. package/lib/edge/components/blocks/blocks-wrapper.cjs +2 -2
  28. package/lib/edge/components/blocks/blocks-wrapper.mjs +18 -16
  29. package/lib/edge/components/content/components/enable-editor.cjs +1 -1
  30. package/lib/edge/components/content/components/enable-editor.mjs +65 -58
  31. package/lib/edge/components/content-variants/helpers.cjs +9 -9
  32. package/lib/edge/components/content-variants/helpers.mjs +16 -16
  33. package/lib/edge/components/content-variants/inlined-fns.cjs +5 -2
  34. package/lib/edge/components/content-variants/inlined-fns.mjs +5 -2
  35. package/lib/edge/constants/sdk-version.cjs +1 -1
  36. package/lib/edge/constants/sdk-version.mjs +1 -1
  37. package/lib/node/blocks/custom-code/custom-code.cjs +1 -1
  38. package/lib/node/blocks/custom-code/custom-code.mjs +27 -17
  39. package/lib/node/blocks/embed/embed.cjs +1 -1
  40. package/lib/node/blocks/embed/embed.mjs +16 -15
  41. package/lib/node/blocks/image/component-info.cjs +1 -1
  42. package/lib/node/blocks/image/component-info.mjs +12 -8
  43. package/lib/node/blocks/image/image.cjs +4 -4
  44. package/lib/node/blocks/image/image.mjs +14 -13
  45. package/lib/node/components/blocks/blocks-wrapper.cjs +2 -2
  46. package/lib/node/components/blocks/blocks-wrapper.mjs +18 -16
  47. package/lib/node/components/content/components/enable-editor.cjs +1 -1
  48. package/lib/node/components/content/components/enable-editor.mjs +65 -58
  49. package/lib/node/components/content-variants/helpers.cjs +9 -9
  50. package/lib/node/components/content-variants/helpers.mjs +16 -16
  51. package/lib/node/components/content-variants/inlined-fns.cjs +5 -2
  52. package/lib/node/components/content-variants/inlined-fns.mjs +5 -2
  53. package/lib/node/constants/sdk-version.cjs +1 -1
  54. package/lib/node/constants/sdk-version.mjs +1 -1
  55. package/package.json +1 -1
  56. package/types/cjs/blocks/image/image.types.d.ts +1 -0
  57. package/types/cjs/components/content-variants/inlined-fns.d.ts +1 -1
  58. package/types/cjs/constants/sdk-version.d.ts +1 -1
  59. package/types/esm/blocks/image/image.types.d.ts +1 -0
  60. package/types/esm/components/content-variants/inlined-fns.d.ts +1 -1
  61. package/types/esm/constants/sdk-version.d.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as k } from "react/jsx-runtime";
3
- import { useRef as P, useState as f, useEffect as l } from "react";
3
+ import { useRef as P, useState as m, useEffect as c } from "react";
4
4
  import O from "../../../context/builder.context.mjs";
5
5
  import { evaluate as W } from "../../../functions/evaluate/evaluate.mjs";
6
6
  import { fastClone as j } from "../../../functions/fast-clone.mjs";
@@ -9,21 +9,23 @@ import { isBrowser as L } from "../../../functions/is-browser.mjs";
9
9
  import { isEditing as g } from "../../../functions/is-editing.mjs";
10
10
  import { isPreviewing as B } from "../../../functions/is-previewing.mjs";
11
11
  import { logFetch as F } from "../../../functions/log-fetch.mjs";
12
- import { createRegisterComponentMessage as z } from "../../../functions/register-component.mjs";
12
+ import { createRegisterComponentMessage as $ } from "../../../functions/register-component.mjs";
13
13
  import { _track as H } from "../../../functions/track/index.mjs";
14
- import { getInteractionPropertiesForEvent as $ } from "../../../functions/track/interaction.mjs";
14
+ import { getInteractionPropertiesForEvent as z } from "../../../functions/track/interaction.mjs";
15
15
  import { getDefaultCanTrack as K } from "../../../helpers/canTrack.mjs";
16
- import { postPreviewContent as G } from "../../../helpers/preview-lru-cache/set.mjs";
17
- import { createEditorListener as J } from "../../../helpers/subscribe-to-editor.mjs";
18
- import { registerInsertMenu as Q, setupBrowserForEditing as X } from "../../../scripts/init-editing.mjs";
19
- import { triggerAnimation as Y } from "../../block/animator.mjs";
16
+ import { getCookieSync as G } from "../../../helpers/cookie.mjs";
17
+ import { postPreviewContent as J } from "../../../helpers/preview-lru-cache/set.mjs";
18
+ import { createEditorListener as Q } from "../../../helpers/subscribe-to-editor.mjs";
19
+ import { registerInsertMenu as X, setupBrowserForEditing as Y } from "../../../scripts/init-editing.mjs";
20
+ import { triggerAnimation as Z } from "../../block/animator.mjs";
20
21
  import { needsElementRefDivForEditing as q } from "./enable-editor.helpers.mjs";
21
- import { getWrapperClassName as Z } from "./styles.helpers.mjs";
22
- import { useRouter as p } from "next/navigation";
23
- function Re(e) {
22
+ import { getWrapperClassName as p } from "./styles.helpers.mjs";
23
+ import { useRouter as ee } from "next/navigation";
24
+ function ke(e) {
24
25
  var y, R, w;
25
- const c = P(null);
26
- function m(n) {
26
+ const u = P(null);
27
+ m(() => !1);
28
+ function s(n) {
27
29
  var i, r;
28
30
  const t = {
29
31
  ...e.builderContextSignal.rootState,
@@ -46,7 +48,7 @@ function Re(e) {
46
48
  breakpoints: ((a = n == null ? void 0 : n.meta) == null ? void 0 : a.breakpoints) || ((d = (o = e.builderContextSignal.content) == null ? void 0 : o.meta) == null ? void 0 : d.breakpoints)
47
49
  }
48
50
  };
49
- G({
51
+ J({
50
52
  value: t,
51
53
  key: t.id
52
54
  }).then(() => {
@@ -59,11 +61,11 @@ function Re(e) {
59
61
  "aria-hidden": !0
60
62
  };
61
63
  }
62
- const [U, ee] = f(
64
+ const [U, te] = m(
63
65
  () => e.contentWrapper || "div"
64
66
  );
65
67
  function v(n) {
66
- return J({
68
+ return Q({
67
69
  model: e.model,
68
70
  trustedHosts: e.trustedHosts,
69
71
  callbacks: {
@@ -77,19 +79,19 @@ function Re(e) {
77
79
  });
78
80
  },
79
81
  animation: (t) => {
80
- Y(t);
82
+ Z(t);
81
83
  },
82
84
  contentUpdate: (t) => {
83
85
  b(t);
84
86
  },
85
87
  stateUpdate: (t) => {
86
- m(t);
88
+ s(t);
87
89
  }
88
90
  }
89
91
  })(n);
90
92
  }
91
- const [h, te] = f(() => ({})), [S, ne] = f(() => ({})), [x, D] = f(() => !1);
92
- function N(n) {
93
+ const [h, ne] = m(() => ({})), [S, ie] = m(() => ({})), [x, D] = m(() => !1);
94
+ function V(n) {
93
95
  var t, i;
94
96
  if (e.builderContextSignal.content) {
95
97
  const r = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, a = (i = e.builderContextSignal.content) == null ? void 0 : i.id;
@@ -100,13 +102,13 @@ function Re(e) {
100
102
  contentId: a,
101
103
  apiKey: e.apiKey,
102
104
  variationId: r !== a ? r : void 0,
103
- ...$(n),
105
+ ...z(n),
104
106
  unique: !x
105
107
  });
106
108
  }
107
109
  x || D(!0);
108
110
  }
109
- function V() {
111
+ function N() {
110
112
  var t, i, r;
111
113
  const n = (r = (i = (t = e.builderContextSignal.content) == null ? void 0 : t.data) == null ? void 0 : i.httpRequests) != null ? r : {};
112
114
  Object.entries(n).forEach(([a, o]) => {
@@ -115,7 +117,7 @@ function Re(e) {
115
117
  S[a] = !0;
116
118
  const d = o.replace(
117
119
  /{{([^}]+)}}/g,
118
- (u, M) => String(
120
+ (l, M) => String(
119
121
  W({
120
122
  code: M,
121
123
  context: e.context || {},
@@ -125,18 +127,18 @@ function Re(e) {
125
127
  })
126
128
  )
127
129
  );
128
- F(d), fetch(d).then((u) => u.json()).then((u) => {
129
- m({
130
- [a]: u
130
+ F(d), fetch(d).then((l) => l.json()).then((l) => {
131
+ s({
132
+ [a]: l
131
133
  }), h[a] = !0;
132
- }).catch((u) => {
133
- console.error("error fetching dynamic data", o, u);
134
+ }).catch((l) => {
135
+ console.error("error fetching dynamic data", o, l);
134
136
  }).finally(() => {
135
137
  S[a] = !1;
136
138
  });
137
139
  });
138
140
  }
139
- function s() {
141
+ function f() {
140
142
  g() && window.dispatchEvent(
141
143
  new CustomEvent(
142
144
  "builder:component:stateChange",
@@ -153,7 +155,7 @@ function Re(e) {
153
155
  }
154
156
  function C(n) {
155
157
  var t;
156
- window.addEventListener("message", v), Q(), X({
158
+ window.addEventListener("message", v), X(), Y({
157
159
  ...e.locale ? {
158
160
  locale: e.locale
159
161
  } : {},
@@ -170,12 +172,12 @@ function Re(e) {
170
172
  ).forEach((i) => {
171
173
  var r, a;
172
174
  if (!((r = i.models) != null && r.length) || i.models.includes(e.model)) {
173
- const o = z(i);
175
+ const o = $(i);
174
176
  (a = window.parent) == null || a.postMessage(o, "*");
175
177
  }
176
178
  }), window.addEventListener(
177
179
  "builder:component:stateChangeListenerActivated",
178
- s
180
+ f
179
181
  );
180
182
  }
181
183
  function E(n) {
@@ -196,69 +198,74 @@ function Re(e) {
196
198
  d && b(d);
197
199
  });
198
200
  }
199
- const _ = p(), I = P(!1);
200
- return I.current || (V(), s(), I.current = !0), l(() => {
201
+ const _ = ee(), I = P(!1);
202
+ return I.current || (N(), f(), I.current = !0), c(() => {
201
203
  var n;
202
- return (n = c.current) == null || n.addEventListener(
204
+ return (n = u.current) == null || n.addEventListener(
203
205
  "initeditingbldr",
204
206
  C
205
207
  ), () => {
206
208
  var t;
207
- return (t = c.current) == null ? void 0 : t.removeEventListener(
209
+ return (t = u.current) == null ? void 0 : t.removeEventListener(
208
210
  "initeditingbldr",
209
211
  C
210
212
  );
211
213
  };
212
- }, []), l(() => {
214
+ }, []), c(() => {
213
215
  var n;
214
- return (n = c.current) == null || n.addEventListener(
216
+ return (n = u.current) == null || n.addEventListener(
215
217
  "initpreviewingbldr",
216
218
  E
217
219
  ), () => {
218
220
  var t;
219
- return (t = c.current) == null ? void 0 : t.removeEventListener(
221
+ return (t = u.current) == null ? void 0 : t.removeEventListener(
220
222
  "initpreviewingbldr",
221
223
  E
222
224
  );
223
225
  };
224
- }, []), l(() => {
225
- var n, t;
226
+ }, []), c(() => {
227
+ var n, t, i;
226
228
  if (L()) {
227
- if (g() && !e.isNestedRender && c.current && c.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && K(e.canTrack)) {
228
- const r = (n = e.builderContextSignal.content) == null ? void 0 : n.testVariationId, a = (t = e.builderContextSignal.content) == null ? void 0 : t.id, o = e.apiKey;
229
+ g() && !e.isNestedRender && u.current && u.current.dispatchEvent(new CustomEvent("initeditingbldr"));
230
+ const r = e.builderContextSignal.content && K(e.canTrack), a = G({
231
+ name: `builder.tests.${(n = e.builderContextSignal.content) == null ? void 0 : n.id}`,
232
+ canTrack: !0
233
+ }), o = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId;
234
+ if (r && o === a) {
235
+ const d = (i = e.builderContextSignal.content) == null ? void 0 : i.id, l = e.apiKey;
229
236
  H({
230
237
  apiHost: e.apiHost,
231
238
  type: "impression",
232
239
  canTrack: !0,
233
- contentId: a,
234
- apiKey: o,
235
- variationId: r !== a ? r : void 0
240
+ contentId: d,
241
+ apiKey: l,
242
+ variationId: a !== d ? a : void 0
236
243
  });
237
244
  }
238
245
  B() && g();
239
246
  }
240
- }, []), l(() => {
241
- }, [e.content]), l(() => {
242
- s();
243
- }, [e.builderContextSignal.rootState]), l(() => {
244
- e.data && m(e.data);
245
- }, [e.data]), l(() => {
246
- e.locale && m({
247
+ }, []), c(() => {
248
+ }, [e.content]), c(() => {
249
+ f();
250
+ }, [e.builderContextSignal.rootState]), c(() => {
251
+ e.data && s(e.data);
252
+ }, [e.data]), c(() => {
253
+ e.locale && s({
247
254
  locale: e.locale
248
255
  });
249
- }, [e.locale]), l(() => () => {
256
+ }, [e.locale]), c(() => () => {
250
257
  L() && (window.removeEventListener("message", v), window.removeEventListener(
251
258
  "builder:component:stateChangeListenerActivated",
252
- s
259
+ f
253
260
  ));
254
261
  }, []), /* @__PURE__ */ k(O.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content || q() ? /* @__PURE__ */ k(
255
262
  U,
256
263
  {
257
- ref: c,
258
- onClick: (n) => N(n),
264
+ ref: u,
265
+ onClick: (n) => V(n),
259
266
  "builder-content-id": (y = e.builderContextSignal.content) == null ? void 0 : y.id,
260
267
  "builder-model": e.model,
261
- className: Z(
268
+ className: p(
262
269
  ((R = e.content) == null ? void 0 : R.testVariationId) || ((w = e.content) == null ? void 0 : w.id)
263
270
  ),
264
271
  style: {
@@ -271,5 +278,5 @@ function Re(e) {
271
278
  ) : null });
272
279
  }
273
280
  export {
274
- Re as default
281
+ ke as default
275
282
  };
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../constants/target.cjs"),S=require("../../functions/is-browser.cjs"),r=require("./inlined-fns.cjs"),e="builderIoAbTest",s="builderIoRenderContent",a=i=>Object.values((i==null?void 0:i.variations)||{}).map(t=>({...t,testVariationId:t.id,id:i==null?void 0:i.id})),d=({canTrack:i,content:t})=>!(!(a(t).length>0)||!i||S.isBrowser()),I=i=>i==="react"||i==="reactNative",n=I(o.TARGET),T=()=>`
2
- window.${e} = ${r.UPDATE_COOKIES_AND_STYLES_SCRIPT}
3
- window.${s} = ${r.UPDATE_VARIANT_VISIBILITY_SCRIPT}
4
- `,c=(i,t)=>`
5
- window.${e}(
6
- "${t}",${JSON.stringify(i)}, ${n}
7
- )`,g=({contentId:i,variationId:t})=>`window.${s}(
8
- "${t}", "${i}", ${n}
9
- )`;exports.checkShouldRenderVariants=d;exports.getInitVariantsFnsScriptString=T;exports.getUpdateCookieAndStylesScript=c;exports.getUpdateVariantVisibilityScript=g;exports.getVariants=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/target.cjs"),S=require("../../functions/is-browser.cjs"),r=require("./inlined-fns.cjs"),s="builderIoAbTest",a="builderIoRenderContent",n=i=>Object.values((i==null?void 0:i.variations)||{}).map(t=>({...t,testVariationId:t.id,id:i==null?void 0:i.id})),d=({canTrack:i,content:t})=>!(!(n(t).length>0)||!i||S.isBrowser()),I=i=>i==="react"||i==="reactNative",T=e.TARGET==="angular",o=I(e.TARGET),c=()=>`
2
+ window.${s} = ${r.UPDATE_COOKIES_AND_STYLES_SCRIPT}
3
+ window.${a} = ${r.UPDATE_VARIANT_VISIBILITY_SCRIPT}
4
+ `,g=(i,t)=>`
5
+ window.${s}(
6
+ "${t}",${JSON.stringify(i)}, ${o}, ${T}
7
+ )`,l=({contentId:i,variationId:t})=>`window.${a}(
8
+ "${t}", "${i}", ${o}
9
+ )`;exports.checkShouldRenderVariants=d;exports.getInitVariantsFnsScriptString=c;exports.getUpdateCookieAndStylesScript=g;exports.getUpdateVariantVisibilityScript=l;exports.getVariants=n;
@@ -1,29 +1,29 @@
1
- import { TARGET as e } from "../../constants/target.mjs";
1
+ import { TARGET as t } from "../../constants/target.mjs";
2
2
  import { isBrowser as o } from "../../functions/is-browser.mjs";
3
- import { UPDATE_COOKIES_AND_STYLES_SCRIPT as I, UPDATE_VARIANT_VISIBILITY_SCRIPT as n } from "./inlined-fns.mjs";
4
- const t = "builderIoAbTest", s = "builderIoRenderContent", S = (i) => Object.values((i == null ? void 0 : i.variations) || {}).map((r) => ({
3
+ import { UPDATE_COOKIES_AND_STYLES_SCRIPT as n, UPDATE_VARIANT_VISIBILITY_SCRIPT as I } from "./inlined-fns.mjs";
4
+ const s = "builderIoAbTest", a = "builderIoRenderContent", S = (i) => Object.values((i == null ? void 0 : i.variations) || {}).map((r) => ({
5
5
  ...r,
6
6
  testVariationId: r.id,
7
7
  id: i == null ? void 0 : i.id
8
- })), $ = ({
8
+ })), V = ({
9
9
  canTrack: i,
10
10
  content: r
11
- }) => !(!(S(r).length > 0) || !i || o()), T = (i) => i === "react" || i === "reactNative", a = T(e), E = () => `
12
- window.${t} = ${I}
11
+ }) => !(!(S(r).length > 0) || !i || o()), T = (i) => i === "react" || i === "reactNative", d = t === "angular", e = T(t), g = () => `
13
12
  window.${s} = ${n}
14
- `, f = (i, r) => `
15
- window.${t}(
16
- "${r}",${JSON.stringify(i)}, ${a}
17
- )`, l = ({
13
+ window.${a} = ${I}
14
+ `, u = (i, r) => `
15
+ window.${s}(
16
+ "${r}",${JSON.stringify(i)}, ${e}, ${d}
17
+ )`, E = ({
18
18
  contentId: i,
19
19
  variationId: r
20
- }) => `window.${s}(
21
- "${r}", "${i}", ${a}
20
+ }) => `window.${a}(
21
+ "${r}", "${i}", ${e}
22
22
  )`;
23
23
  export {
24
- $ as checkShouldRenderVariants,
25
- E as getInitVariantsFnsScriptString,
26
- f as getUpdateCookieAndStylesScript,
27
- l as getUpdateVariantVisibilityScript,
24
+ V as checkShouldRenderVariants,
25
+ g as getInitVariantsFnsScriptString,
26
+ u as getUpdateCookieAndStylesScript,
27
+ E as getUpdateVariantVisibilityScript,
28
28
  S as getVariants
29
29
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=`function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=`function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {
2
2
  function getAndSetVariantId() {
3
3
  function setCookie(name, value, days) {
4
4
  let expires = '';
@@ -40,7 +40,10 @@
40
40
  return contentId;
41
41
  }
42
42
  const winningVariantId = getAndSetVariantId();
43
- const styleEl = document.currentScript?.previousElementSibling;
43
+ let styleEl = document.currentScript?.previousElementSibling;
44
+ if (isAngularSDK) {
45
+ styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');
46
+ }
44
47
  if (isHydrationTarget) {
45
48
  styleEl.remove();
46
49
  const thisScriptEl = document.currentScript;
@@ -1,4 +1,4 @@
1
- const n = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {
1
+ const n = `function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {
2
2
  function getAndSetVariantId() {
3
3
  function setCookie(name, value, days) {
4
4
  let expires = '';
@@ -40,7 +40,10 @@ const n = `function updateCookiesAndStyles(contentId, variants, isHydrationTarge
40
40
  return contentId;
41
41
  }
42
42
  const winningVariantId = getAndSetVariantId();
43
- const styleEl = document.currentScript?.previousElementSibling;
43
+ let styleEl = document.currentScript?.previousElementSibling;
44
+ if (isAngularSDK) {
45
+ styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');
46
+ }
44
47
  if (isHydrationTarget) {
45
48
  styleEl.remove();
46
49
  const thisScriptEl = document.currentScript;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.1";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.18.8";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.18.1";
1
+ const o = "0.18.8";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
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.18.1",
4
+ "version": "0.18.8",
5
5
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,6 +9,7 @@ export interface ImageProps {
9
9
  height?: number;
10
10
  width?: number;
11
11
  altText?: string;
12
+ title?: string;
12
13
  backgroundSize?: 'cover' | 'contain';
13
14
  backgroundPosition?: string;
14
15
  srcset?: string;
@@ -10,5 +10,5 @@
10
10
  * For more information on how this works,
11
11
  * see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/docs/SSR_AB_TEST.md)
12
12
  */
13
- export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\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 const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
13
+ export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\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 const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
14
14
  export declare const UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\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 const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.18.1";
1
+ export declare const SDK_VERSION = "0.18.8";
@@ -9,6 +9,7 @@ export interface ImageProps {
9
9
  height?: number;
10
10
  width?: number;
11
11
  altText?: string;
12
+ title?: string;
12
13
  backgroundSize?: 'cover' | 'contain';
13
14
  backgroundPosition?: string;
14
15
  srcset?: string;
@@ -10,5 +10,5 @@
10
10
  * For more information on how this works,
11
11
  * see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/docs/SSR_AB_TEST.md)
12
12
  */
13
- export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\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 const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
13
+ export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\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 const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
14
14
  export declare const UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\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 const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.18.1";
1
+ export declare const SDK_VERSION = "0.18.8";