@builder.io/sdk-react-nextjs 0.21.1 → 0.22.1

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 (117) hide show
  1. package/lib/browser/blocks/img/component-info.cjs +1 -1
  2. package/lib/browser/blocks/img/component-info.mjs +33 -3
  3. package/lib/browser/blocks/img/img.cjs +1 -1
  4. package/lib/browser/blocks/img/img.mjs +22 -17
  5. package/lib/browser/blocks/text/component-info.cjs +1 -1
  6. package/lib/browser/blocks/text/component-info.mjs +0 -1
  7. package/lib/browser/blocks/text/text.cjs +1 -1
  8. package/lib/browser/blocks/text/text.mjs +3 -2
  9. package/lib/browser/components/block/block.cjs +1 -1
  10. package/lib/browser/components/block/block.mjs +27 -20
  11. package/lib/browser/components/block/components/interactive-element.cjs +1 -1
  12. package/lib/browser/components/block/components/interactive-element.mjs +27 -15
  13. package/lib/browser/components/block/components/live-edit-block-styles.cjs +1 -0
  14. package/lib/browser/components/block/components/live-edit-block-styles.mjs +94 -0
  15. package/lib/browser/components/block/components/style-wrapper.cjs +1 -0
  16. package/lib/browser/components/block/components/style-wrapper.mjs +24 -0
  17. package/lib/browser/components/content/components/enable-editor.cjs +1 -1
  18. package/lib/browser/components/content/components/enable-editor.mjs +182 -164
  19. package/lib/browser/components/live-edit.cjs +1 -0
  20. package/lib/browser/components/live-edit.mjs +19 -0
  21. package/lib/browser/constants/builder-registered-components.cjs +1 -1
  22. package/lib/browser/constants/builder-registered-components.mjs +3 -2
  23. package/lib/browser/constants/extra-components.cjs +1 -1
  24. package/lib/browser/constants/extra-components.mjs +3 -2
  25. package/lib/browser/constants/sdk-version.cjs +1 -1
  26. package/lib/browser/constants/sdk-version.mjs +1 -1
  27. package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
  28. package/lib/browser/functions/get-content/generate-content-url.mjs +38 -42
  29. package/lib/browser/functions/get-content/index.cjs +1 -1
  30. package/lib/browser/functions/get-content/index.mjs +42 -36
  31. package/lib/browser/helpers/find-block.cjs +1 -0
  32. package/lib/browser/helpers/find-block.mjs +30 -0
  33. package/lib/browser/helpers/subscribe-to-editor.cjs +1 -1
  34. package/lib/browser/helpers/subscribe-to-editor.mjs +15 -15
  35. package/lib/edge/blocks/img/component-info.cjs +1 -1
  36. package/lib/edge/blocks/img/component-info.mjs +33 -3
  37. package/lib/edge/blocks/img/img.cjs +1 -1
  38. package/lib/edge/blocks/img/img.mjs +22 -17
  39. package/lib/edge/blocks/text/component-info.cjs +1 -1
  40. package/lib/edge/blocks/text/component-info.mjs +0 -1
  41. package/lib/edge/blocks/text/text.cjs +1 -1
  42. package/lib/edge/blocks/text/text.mjs +3 -2
  43. package/lib/edge/components/block/block.cjs +1 -1
  44. package/lib/edge/components/block/block.mjs +27 -20
  45. package/lib/edge/components/block/components/interactive-element.cjs +1 -1
  46. package/lib/edge/components/block/components/interactive-element.mjs +27 -15
  47. package/lib/edge/components/block/components/live-edit-block-styles.cjs +1 -0
  48. package/lib/edge/components/block/components/live-edit-block-styles.mjs +94 -0
  49. package/lib/edge/components/block/components/style-wrapper.cjs +1 -0
  50. package/lib/edge/components/block/components/style-wrapper.mjs +24 -0
  51. package/lib/edge/components/content/components/enable-editor.cjs +1 -1
  52. package/lib/edge/components/content/components/enable-editor.mjs +182 -164
  53. package/lib/edge/components/live-edit.cjs +1 -0
  54. package/lib/edge/components/live-edit.mjs +19 -0
  55. package/lib/edge/constants/builder-registered-components.cjs +1 -1
  56. package/lib/edge/constants/builder-registered-components.mjs +3 -2
  57. package/lib/edge/constants/extra-components.cjs +1 -1
  58. package/lib/edge/constants/extra-components.mjs +3 -2
  59. package/lib/edge/constants/sdk-version.cjs +1 -1
  60. package/lib/edge/constants/sdk-version.mjs +1 -1
  61. package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
  62. package/lib/edge/functions/get-content/generate-content-url.mjs +38 -42
  63. package/lib/edge/functions/get-content/index.cjs +1 -1
  64. package/lib/edge/functions/get-content/index.mjs +42 -36
  65. package/lib/edge/helpers/find-block.cjs +1 -0
  66. package/lib/edge/helpers/find-block.mjs +30 -0
  67. package/lib/edge/helpers/subscribe-to-editor.cjs +1 -1
  68. package/lib/edge/helpers/subscribe-to-editor.mjs +15 -15
  69. package/lib/node/blocks/img/component-info.cjs +1 -1
  70. package/lib/node/blocks/img/component-info.mjs +33 -3
  71. package/lib/node/blocks/img/img.cjs +1 -1
  72. package/lib/node/blocks/img/img.mjs +22 -17
  73. package/lib/node/blocks/text/component-info.cjs +1 -1
  74. package/lib/node/blocks/text/component-info.mjs +0 -1
  75. package/lib/node/blocks/text/text.cjs +1 -1
  76. package/lib/node/blocks/text/text.mjs +3 -2
  77. package/lib/node/components/block/block.cjs +1 -1
  78. package/lib/node/components/block/block.mjs +27 -20
  79. package/lib/node/components/block/components/interactive-element.cjs +1 -1
  80. package/lib/node/components/block/components/interactive-element.mjs +27 -15
  81. package/lib/node/components/block/components/live-edit-block-styles.cjs +1 -0
  82. package/lib/node/components/block/components/live-edit-block-styles.mjs +94 -0
  83. package/lib/node/components/block/components/style-wrapper.cjs +1 -0
  84. package/lib/node/components/block/components/style-wrapper.mjs +24 -0
  85. package/lib/node/components/content/components/enable-editor.cjs +1 -1
  86. package/lib/node/components/content/components/enable-editor.mjs +182 -164
  87. package/lib/node/components/live-edit.cjs +1 -0
  88. package/lib/node/components/live-edit.mjs +19 -0
  89. package/lib/node/constants/builder-registered-components.cjs +1 -1
  90. package/lib/node/constants/builder-registered-components.mjs +3 -2
  91. package/lib/node/constants/extra-components.cjs +1 -1
  92. package/lib/node/constants/extra-components.mjs +3 -2
  93. package/lib/node/constants/sdk-version.cjs +1 -1
  94. package/lib/node/constants/sdk-version.mjs +1 -1
  95. package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
  96. package/lib/node/functions/get-content/generate-content-url.mjs +38 -42
  97. package/lib/node/functions/get-content/index.cjs +1 -1
  98. package/lib/node/functions/get-content/index.mjs +42 -36
  99. package/lib/node/helpers/find-block.cjs +1 -0
  100. package/lib/node/helpers/find-block.mjs +30 -0
  101. package/lib/node/helpers/subscribe-to-editor.cjs +1 -1
  102. package/lib/node/helpers/subscribe-to-editor.mjs +15 -15
  103. package/package.json +1 -1
  104. package/types/cjs/blocks/img/img.d.ts +2 -0
  105. package/types/cjs/components/block/components/live-edit-block-styles.d.ts +8 -0
  106. package/types/cjs/components/block/components/style-wrapper.d.ts +9 -0
  107. package/types/cjs/components/live-edit.d.ts +9 -0
  108. package/types/cjs/constants/sdk-version.d.ts +1 -1
  109. package/types/cjs/helpers/find-block.d.ts +18 -0
  110. package/types/cjs/helpers/subscribe-to-editor.d.ts +3 -2
  111. package/types/esm/blocks/img/img.d.ts +2 -0
  112. package/types/esm/components/block/components/live-edit-block-styles.d.ts +8 -0
  113. package/types/esm/components/block/components/style-wrapper.d.ts +9 -0
  114. package/types/esm/components/live-edit.d.ts +9 -0
  115. package/types/esm/constants/sdk-version.d.ts +1 -1
  116. package/types/esm/helpers/find-block.d.ts +18 -0
  117. package/types/esm/helpers/subscribe-to-editor.d.ts +3 -2
@@ -1,62 +1,58 @@
1
- import { flatten as w, flattenMongoQuery as E, unflatten as F } from "../../helpers/flatten.mjs";
2
- import { normalizeSearchParams as O } from "../../helpers/search/search.mjs";
3
- import { DEFAULT_API_VERSION as J } from "../../types/api-version.mjs";
4
- import { getBuilderSearchParamsFromWindow as L } from "../get-builder-search-params/index.mjs";
1
+ import { flatten as U, flattenMongoQuery as I, unflatten as E } from "../../helpers/flatten.mjs";
2
+ import { normalizeSearchParams as F } from "../../helpers/search/search.mjs";
3
+ import { DEFAULT_API_VERSION as O } from "../../types/api-version.mjs";
4
+ import { getBuilderSearchParamsFromWindow as J } from "../get-builder-search-params/index.mjs";
5
5
  import { isBrowser as R } from "../is-browser.mjs";
6
- const y = (t) => typeof t == "number" && !isNaN(t) && t >= 0, _ = (t) => {
6
+ const w = (t) => typeof t == "number" && !isNaN(t) && t >= 0, V = (t) => {
7
7
  const {
8
8
  limit: a = 30,
9
9
  userAttributes: r,
10
10
  query: u,
11
- model: A,
12
- apiKey: d,
13
- enrich: P,
14
- locale: N,
15
- apiVersion: o = J,
11
+ model: y,
12
+ apiKey: h,
13
+ enrich: d,
14
+ locale: P,
15
+ apiVersion: o = O,
16
16
  fields: S,
17
17
  omit: c,
18
- offset: l,
19
- cacheSeconds: f,
20
- staleCacheSeconds: m,
21
- sort: p,
22
- includeUnpublished: b,
23
- apiHost: v
18
+ offset: f,
19
+ cacheSeconds: m,
20
+ staleCacheSeconds: l,
21
+ sort: b,
22
+ includeUnpublished: p,
23
+ apiHost: N
24
24
  } = t;
25
- if (!d)
25
+ if (!h)
26
26
  throw new Error("Missing API key");
27
27
  if (!["v3"].includes(o))
28
28
  throw new Error(`Invalid apiVersion: expected 'v3', received '${o}'`);
29
- const k = a !== 1, I = v || "https://cdn.builder.io", e = new URL(`${I}/api/${o}/content/${A}`);
30
- e.searchParams.set("apiKey", d), e.searchParams.set("limit", String(a)), e.searchParams.set("noTraverse", String(k)), e.searchParams.set("includeRefs", String(!0));
31
- const h = N || (r == null ? void 0 : r.locale);
32
- let i = r || {};
33
- if (h && (e.searchParams.set("locale", h), i = {
34
- locale: h,
35
- ...i
36
- }), P && e.searchParams.set("enrich", String(P)), e.searchParams.set("omit", c != null ? c : "meta.componentsUsed"), S && e.searchParams.set("fields", S), Number.isFinite(l) && l > -1 && e.searchParams.set("offset", String(Math.floor(l))), typeof b == "boolean" && e.searchParams.set("includeUnpublished", String(b)), f && y(f) && e.searchParams.set("cacheSeconds", String(f)), m && y(m) && e.searchParams.set("staleCacheSeconds", String(m)), p) {
37
- const s = w({
38
- sort: p
29
+ const v = a !== 1, k = N || "https://cdn.builder.io", e = new URL(`${k}/api/${o}/content/${y}`);
30
+ e.searchParams.set("apiKey", h), e.searchParams.set("limit", String(a)), e.searchParams.set("noTraverse", String(v)), e.searchParams.set("includeRefs", String(!0)), P && e.searchParams.set("locale", P);
31
+ let n = r || {};
32
+ if (d && e.searchParams.set("enrich", String(d)), e.searchParams.set("omit", c != null ? c : "meta.componentsUsed"), S && e.searchParams.set("fields", S), Number.isFinite(f) && f > -1 && e.searchParams.set("offset", String(Math.floor(f))), typeof p == "boolean" && e.searchParams.set("includeUnpublished", String(p)), m && w(m) && e.searchParams.set("cacheSeconds", String(m)), l && w(l) && e.searchParams.set("staleCacheSeconds", String(l)), b) {
33
+ const s = U({
34
+ sort: b
39
35
  });
40
- for (const n in s)
41
- e.searchParams.set(n, JSON.stringify(s[n]));
36
+ for (const i in s)
37
+ e.searchParams.set(i, JSON.stringify(s[i]));
42
38
  }
43
39
  const g = {
44
- ...L(),
45
- ...O(t.options || {})
40
+ ...J(),
41
+ ...F(t.options || {})
46
42
  };
47
- i = {
48
- ...i,
43
+ n = {
44
+ ...n,
49
45
  ...$(g)
50
46
  };
51
- const U = w(g);
52
- for (const s in U)
53
- e.searchParams.set(s, String(U[s]));
54
- if (Object.keys(i).length > 0 && e.searchParams.set("userAttributes", JSON.stringify(i)), u) {
55
- const s = E({
47
+ const A = U(g);
48
+ for (const s in A)
49
+ e.searchParams.set(s, String(A[s]));
50
+ if (Object.keys(n).length > 0 && e.searchParams.set("userAttributes", JSON.stringify(n)), u) {
51
+ const s = I({
56
52
  query: u
57
53
  });
58
- for (const n in s)
59
- e.searchParams.set(n, JSON.stringify(s[n]));
54
+ for (const i in s)
55
+ e.searchParams.set(i, JSON.stringify(s[i]));
60
56
  }
61
57
  return e;
62
58
  }, T = (t) => {
@@ -69,11 +65,11 @@ const y = (t) => typeof t == "number" && !isNaN(t) && t >= 0, _ = (t) => {
69
65
  t["userAttributes.urlPath"] = window.location.pathname, t["userAttributes.host"] = window.location.host;
70
66
  const a = T(t), {
71
67
  userAttributes: r
72
- } = F(a);
68
+ } = E(a);
73
69
  return r;
74
70
  }
75
71
  return {};
76
72
  };
77
73
  export {
78
- _ as generateContentUrl
74
+ V as generateContentUrl
79
75
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../constants/target.cjs"),g=require("../../helpers/ab-tests.cjs"),w=require("../../helpers/canTrack.cjs"),i=require("../../helpers/logger.cjs"),C=require("../../helpers/preview-lru-cache/get.cjs"),d=require("../../helpers/sdk-headers.cjs"),T=require("../get-fetch.cjs"),q=require("../is-browser.cjs"),o=require("./generate-content-url.cjs"),y=e=>"results"in e;async function k(e){const t=await l({...e,limit:1});return t&&t[0]||null}const v=async e=>{var n,a;const t=o.generateContentUrl(e),r=(n=e.fetch)!=null?n:T.fetch,c={...e.fetchOptions,headers:{...(a=e.fetchOptions)==null?void 0:a.headers,...d.getSdkHeaders()}};return await(await r(t.href,c)).json()},u=async(e,t,r=o.generateContentUrl(e))=>{const c=w.getDefaultCanTrack(e.canTrack);if(r.search.includes("preview=")){const s=[];for(const n of t.results){const a=C.getPreviewContent(r.searchParams);s.push(a||n)}t.results=s}if(!c||!(q.isBrowser()||h.TARGET==="reactNative"))return t.results;try{const s=[];for(const n of t.results)s.push(await g.handleABTesting({item:n,canTrack:c}));t.results=s}catch(s){i.logger.error("Could not process A/B tests. ",s)}return t.results};async function l(e){const t=o.generateContentUrl(e),r=await v(e);if(!y(r))throw i.logger.error("Error fetching data. ",{url:t,content:r,options:e}),r;return u(e,r)}exports._processContentResult=u;exports.fetchEntries=l;exports.fetchOneEntry=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../constants/target.cjs"),g=require("../../helpers/ab-tests.cjs"),w=require("../../helpers/canTrack.cjs"),l=require("../../helpers/logger.cjs"),C=require("../../helpers/preview-lru-cache/get.cjs"),d=require("../../helpers/sdk-headers.cjs"),T=require("../get-fetch.cjs"),q=require("../is-browser.cjs"),u=require("./generate-content-url.cjs"),y=e=>"results"in e;async function k(e){var n;const t=e.locale||((n=e.userAttributes)==null?void 0:n.locale);t&&(e.locale=t,e.userAttributes={locale:t,...e.userAttributes});const r=await i({...e,limit:1});return r&&r[0]||null}const v=async e=>{var c,a;const t=u.generateContentUrl(e),r=(c=e.fetch)!=null?c:T.fetch,n={...e.fetchOptions,headers:{...(a=e.fetchOptions)==null?void 0:a.headers,...d.getSdkHeaders()}};return await(await r(t.href,n)).json()},o=async(e,t,r=u.generateContentUrl(e))=>{const n=w.getDefaultCanTrack(e.canTrack);if(r.search.includes("preview=")){const s=[];for(const c of t.results){const a=C.getPreviewContent(r.searchParams);s.push(a||c)}t.results=s}if(!n||!(q.isBrowser()||h.TARGET==="reactNative"))return t.results;try{const s=[];for(const c of t.results)s.push(await g.handleABTesting({item:c,canTrack:n}));t.results=s}catch(s){l.logger.error("Could not process A/B tests. ",s)}return t.results};async function i(e){const t=u.generateContentUrl(e),r=await v(e);if(!y(r))throw l.logger.error("Error fetching data. ",{url:t,content:r,options:e}),r;return o(e,r)}exports._processContentResult=o;exports.fetchEntries=i;exports.fetchOneEntry=k;
@@ -1,67 +1,73 @@
1
1
  import { TARGET as u } from "../../constants/target.mjs";
2
- import { handleABTesting as l } from "../../helpers/ab-tests.mjs";
2
+ import { handleABTesting as f } from "../../helpers/ab-tests.mjs";
3
3
  import { getDefaultCanTrack as m } from "../../helpers/canTrack.mjs";
4
4
  import { logger as i } from "../../helpers/logger.mjs";
5
5
  import { getPreviewContent as h } from "../../helpers/preview-lru-cache/get.mjs";
6
6
  import { getSdkHeaders as w } from "../../helpers/sdk-headers.mjs";
7
- import { fetch as p } from "../get-fetch.mjs";
8
- import { isBrowser as g } from "../is-browser.mjs";
9
- import { generateContentUrl as a } from "./generate-content-url.mjs";
10
- const C = (t) => "results" in t;
11
- async function H(t) {
12
- const e = await y({
13
- ...t,
7
+ import { fetch as g } from "../get-fetch.mjs";
8
+ import { isBrowser as C } from "../is-browser.mjs";
9
+ import { generateContentUrl as o } from "./generate-content-url.mjs";
10
+ const d = (e) => "results" in e;
11
+ async function _(e) {
12
+ var n;
13
+ const t = e.locale || ((n = e.userAttributes) == null ? void 0 : n.locale);
14
+ t && (e.locale = t, e.userAttributes = {
15
+ locale: t,
16
+ ...e.userAttributes
17
+ });
18
+ const r = await y({
19
+ ...e,
14
20
  limit: 1
15
21
  });
16
- return e && e[0] || null;
22
+ return r && r[0] || null;
17
23
  }
18
- const d = async (t) => {
19
- var n, c;
20
- const e = a(t), r = (n = t.fetch) != null ? n : p, o = {
21
- ...t.fetchOptions,
24
+ const p = async (e) => {
25
+ var c, a;
26
+ const t = o(e), r = (c = e.fetch) != null ? c : g, n = {
27
+ ...e.fetchOptions,
22
28
  headers: {
23
- ...(c = t.fetchOptions) == null ? void 0 : c.headers,
29
+ ...(a = e.fetchOptions) == null ? void 0 : a.headers,
24
30
  ...w()
25
31
  }
26
32
  };
27
- return await (await r(e.href, o)).json();
28
- }, v = async (t, e, r = a(t)) => {
29
- const o = m(t.canTrack);
33
+ return await (await r(t.href, n)).json();
34
+ }, v = async (e, t, r = o(e)) => {
35
+ const n = m(e.canTrack);
30
36
  if (r.search.includes("preview=")) {
31
37
  const s = [];
32
- for (const n of e.results) {
33
- const c = h(r.searchParams);
34
- s.push(c || n);
38
+ for (const c of t.results) {
39
+ const a = h(r.searchParams);
40
+ s.push(a || c);
35
41
  }
36
- e.results = s;
42
+ t.results = s;
37
43
  }
38
- if (!o || !(g() || u === "reactNative"))
39
- return e.results;
44
+ if (!n || !(C() || u === "reactNative"))
45
+ return t.results;
40
46
  try {
41
47
  const s = [];
42
- for (const n of e.results)
43
- s.push(await l({
44
- item: n,
45
- canTrack: o
48
+ for (const c of t.results)
49
+ s.push(await f({
50
+ item: c,
51
+ canTrack: n
46
52
  }));
47
- e.results = s;
53
+ t.results = s;
48
54
  } catch (s) {
49
55
  i.error("Could not process A/B tests. ", s);
50
56
  }
51
- return e.results;
57
+ return t.results;
52
58
  };
53
- async function y(t) {
54
- const e = a(t), r = await d(t);
55
- if (!C(r))
59
+ async function y(e) {
60
+ const t = o(e), r = await p(e);
61
+ if (!d(r))
56
62
  throw i.error("Error fetching data. ", {
57
- url: e,
63
+ url: t,
58
64
  content: r,
59
- options: t
65
+ options: e
60
66
  }), r;
61
- return v(t, r);
67
+ return v(e, r);
62
68
  }
63
69
  export {
64
70
  v as _processContentResult,
65
71
  y as fetchEntries,
66
- H as fetchOneEntry
72
+ _ as fetchOneEntry
67
73
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=(e,o)=>{var c;return l((c=e.data)==null?void 0:c.blocks,o)},l=(e,o)=>{var c,r,i;if(!e)return null;for(const n of e){if(n.id===o)return n;if(n.children){const t=l(n.children,o);if(t)return t}if(((c=n.component)==null?void 0:c.name)==="Columns"&&((i=(r=n.component)==null?void 0:r.options)!=null&&i.columns)){for(const t of n.component.options.columns)if(t.blocks){const f=l(t.blocks,o);if(f)return f}}}return null};exports.findBlockById=s;exports.findBlockInTree=l;
@@ -0,0 +1,30 @@
1
+ const s = (r, o) => {
2
+ var c;
3
+ return l((c = r.data) == null ? void 0 : c.blocks, o);
4
+ }, l = (r, o) => {
5
+ var c, e, i;
6
+ if (!r)
7
+ return null;
8
+ for (const n of r) {
9
+ if (n.id === o)
10
+ return n;
11
+ if (n.children) {
12
+ const t = l(n.children, o);
13
+ if (t)
14
+ return t;
15
+ }
16
+ if (((c = n.component) == null ? void 0 : c.name) === "Columns" && ((i = (e = n.component) == null ? void 0 : e.options) != null && i.columns)) {
17
+ for (const t of n.component.options.columns)
18
+ if (t.blocks) {
19
+ const f = l(t.blocks, o);
20
+ if (f)
21
+ return f;
22
+ }
23
+ }
24
+ }
25
+ return null;
26
+ };
27
+ export {
28
+ s as findBlockById,
29
+ l as findBlockInTree
30
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../functions/is-browser.cjs"),u=require("../functions/is-from-trusted-host.cjs"),b=require("../scripts/init-editing.cjs"),g=require("./logger.cjs"),d=({model:n,trustedHosts:i,callbacks:r})=>o=>{if(!u.isFromTrustedHost(i,o))return;const{data:t}=o;if(t)switch(t.type){case"builder.configureSdk":{r.configureSdk(t.data);break}case"builder.triggerAnimation":{r.animation(t.data);break}case"builder.resetState":{const e=t.data,a=e.model,s=e==null?void 0:e.state;a===n&&s&&r.stateUpdate(s);break}case"builder.contentUpdate":{const e=t.data,a=e.key||e.alias||e.entry||e.modelName,s=e.data;a===n&&r.contentUpdate(s);break}}},m=({model:n,apiKey:i,callback:r,trustedHosts:o})=>{if(!c.isBrowser)return g.logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};b.setupBrowserForEditing({modelName:n,apiKey:i});const t=d({callbacks:{contentUpdate:r,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:n,trustedHosts:o});return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}};exports.createEditorListener=d;exports.subscribeToEditor=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../functions/is-browser.cjs"),b=require("../functions/is-from-trusted-host.cjs"),g=require("../scripts/init-editing.cjs"),m=require("./logger.cjs"),c=({model:n,trustedHosts:s,callbacks:r})=>i=>{if(!b.isFromTrustedHost(s,i))return;const{data:t}=i;if(t)switch(t.type){case"builder.configureSdk":{r.configureSdk(t.data);break}case"builder.triggerAnimation":{r.animation(t.data);break}case"builder.resetState":{const e=t.data,a=e.model,o=e==null?void 0:e.state,d=e.editType;a===n&&o&&r.stateUpdate(o,d);break}case"builder.contentUpdate":{const e=t.data,a=e.key||e.alias||e.entry||e.modelName,o=e.data,d=e.editType;a===n&&r.contentUpdate(o,d);break}}},p=({model:n,apiKey:s,callback:r,trustedHosts:i})=>{if(!u.isBrowser)return m.logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};g.setupBrowserForEditing({modelName:n,apiKey:s});const t=c({callbacks:{contentUpdate:r,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:n,trustedHosts:i});return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}};exports.createEditorListener=c;exports.subscribeToEditor=p;
@@ -1,13 +1,13 @@
1
- import { isBrowser as d } from "../functions/is-browser.mjs";
2
- import { isFromTrustedHost as c } from "../functions/is-from-trusted-host.mjs";
3
- import { setupBrowserForEditing as m } from "../scripts/init-editing.mjs";
4
- import { logger as u } from "./logger.mjs";
1
+ import { isBrowser as c } from "../functions/is-browser.mjs";
2
+ import { isFromTrustedHost as m } from "../functions/is-from-trusted-host.mjs";
3
+ import { setupBrowserForEditing as u } from "../scripts/init-editing.mjs";
4
+ import { logger as p } from "./logger.mjs";
5
5
  const b = ({
6
6
  model: o,
7
- trustedHosts: i,
7
+ trustedHosts: s,
8
8
  callbacks: r
9
9
  }) => (n) => {
10
- if (!c(i, n))
10
+ if (!m(s, n))
11
11
  return;
12
12
  const {
13
13
  data: t
@@ -23,28 +23,28 @@ const b = ({
23
23
  break;
24
24
  }
25
25
  case "builder.resetState": {
26
- const e = t.data, s = e.model, a = e == null ? void 0 : e.state;
27
- s === o && a && r.stateUpdate(a);
26
+ const e = t.data, a = e.model, i = e == null ? void 0 : e.state, d = e.editType;
27
+ a === o && i && r.stateUpdate(i, d);
28
28
  break;
29
29
  }
30
30
  case "builder.contentUpdate": {
31
- const e = t.data, s = e.key || e.alias || e.entry || e.modelName, a = e.data;
32
- s === o && r.contentUpdate(a);
31
+ const e = t.data, a = e.key || e.alias || e.entry || e.modelName, i = e.data, d = e.editType;
32
+ a === o && r.contentUpdate(i, d);
33
33
  break;
34
34
  }
35
35
  }
36
36
  }, k = ({
37
37
  model: o,
38
- apiKey: i,
38
+ apiKey: s,
39
39
  callback: r,
40
40
  trustedHosts: n
41
41
  }) => {
42
- if (!d)
43
- return u.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
42
+ if (!c)
43
+ return p.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
44
44
  };
45
- m({
45
+ u({
46
46
  modelName: o,
47
- apiKey: i
47
+ apiKey: s
48
48
  });
49
49
  const t = b({
50
50
  callbacks: {
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.21.1",
4
+ "version": "0.22.1",
5
5
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,6 +9,8 @@ export interface ImgProps {
9
9
  altText?: string;
10
10
  backgroundSize?: "cover" | "contain";
11
11
  backgroundPosition?: "center" | "top" | "left" | "right" | "bottom" | "top left" | "top right" | "bottom left" | "bottom right";
12
+ aspectRatio?: number;
13
+ title?: string;
12
14
  }
13
15
  declare function ImgComponent(props: ImgProps): React.JSX.Element;
14
16
  export default ImgComponent;
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ type LiveEditBlockStylesProps = {
3
+ id?: any;
4
+ contextProvider: BuilderContextInterface;
5
+ };
6
+ import type { BuilderContextInterface } from "../../../server-index.js";
7
+ declare function LiveEditBlockStyles(props: LiveEditBlockStylesProps): React.JSX.Element;
8
+ export default LiveEditBlockStyles;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ type StyleWrapperProps = {
3
+ block: BuilderBlock;
4
+ context: BuilderContextInterface;
5
+ id?: string;
6
+ };
7
+ import { BuilderBlock, BuilderContextInterface } from "../../../server-index.js";
8
+ declare function StyleWrapper(props: StyleWrapperProps): React.JSX.Element;
9
+ export default StyleWrapper;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ type LiveEditProps = {
3
+ children?: any;
4
+ id?: any;
5
+ Wrapper?: any;
6
+ attributes?: any;
7
+ };
8
+ declare function LiveEdit(props: LiveEditProps): React.JSX.Element;
9
+ export default LiveEdit;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.21.1";
1
+ export declare const SDK_VERSION = "0.22.1";
@@ -0,0 +1,18 @@
1
+ import type { BuilderBlock, BuilderContent } from '../server-index.js';
2
+ /**
3
+ * Recursively searches for a block by ID.
4
+ *
5
+ * @param content The Builder content to search through.
6
+ * @param id The ID of the block to search for.
7
+ * @returns The block if found, otherwise null.
8
+ */
9
+ export declare const findBlockById: (content: BuilderContent, id: string) => BuilderBlock | null;
10
+ /**
11
+ * Helper function to recursively search through block tree.
12
+ *
13
+ * @param blocks The blocks to search through.
14
+ * @param id The ID of the block to search for.
15
+ * @returns The block if found, otherwise null.
16
+ * @private This is an internal implementation detail.
17
+ */
18
+ export declare const findBlockInTree: (blocks: BuilderBlock[] | undefined, id: string) => BuilderBlock | null;
@@ -2,10 +2,11 @@ import type { ContentProps } from '../components/content/content.types.js';
2
2
  import type { BuilderAnimation } from '../types/builder-block.js';
3
3
  import type { BuilderContent } from '../types/builder-content.js';
4
4
  import type { Dictionary } from '../types/typescript.js';
5
+ export type EditType = 'client' | 'server' | undefined;
5
6
  type ContentListener = Required<Pick<ContentProps, 'model' | 'trustedHosts'>> & {
6
7
  callbacks: {
7
- contentUpdate: (updatedContent: BuilderContent) => void;
8
- stateUpdate: (newState: Dictionary<string>) => void;
8
+ contentUpdate: (updatedContent: BuilderContent, editType?: EditType) => void;
9
+ stateUpdate: (newState: Dictionary<string>, editType?: EditType) => void;
9
10
  animation: (updatedContent: BuilderAnimation) => void;
10
11
  configureSdk: (updatedContent: any) => void;
11
12
  };
@@ -9,6 +9,8 @@ export interface ImgProps {
9
9
  altText?: string;
10
10
  backgroundSize?: "cover" | "contain";
11
11
  backgroundPosition?: "center" | "top" | "left" | "right" | "bottom" | "top left" | "top right" | "bottom left" | "bottom right";
12
+ aspectRatio?: number;
13
+ title?: string;
12
14
  }
13
15
  declare function ImgComponent(props: ImgProps): React.JSX.Element;
14
16
  export default ImgComponent;
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ type LiveEditBlockStylesProps = {
3
+ id?: any;
4
+ contextProvider: BuilderContextInterface;
5
+ };
6
+ import type { BuilderContextInterface } from "../../../server-index.js";
7
+ declare function LiveEditBlockStyles(props: LiveEditBlockStylesProps): React.JSX.Element;
8
+ export default LiveEditBlockStyles;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ type StyleWrapperProps = {
3
+ block: BuilderBlock;
4
+ context: BuilderContextInterface;
5
+ id?: string;
6
+ };
7
+ import { BuilderBlock, BuilderContextInterface } from "../../../server-index.js";
8
+ declare function StyleWrapper(props: StyleWrapperProps): React.JSX.Element;
9
+ export default StyleWrapper;
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ type LiveEditProps = {
3
+ children?: any;
4
+ id?: any;
5
+ Wrapper?: any;
6
+ attributes?: any;
7
+ };
8
+ declare function LiveEdit(props: LiveEditProps): React.JSX.Element;
9
+ export default LiveEdit;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.21.1";
1
+ export declare const SDK_VERSION = "0.22.1";
@@ -0,0 +1,18 @@
1
+ import type { BuilderBlock, BuilderContent } from '../server-index.js';
2
+ /**
3
+ * Recursively searches for a block by ID.
4
+ *
5
+ * @param content The Builder content to search through.
6
+ * @param id The ID of the block to search for.
7
+ * @returns The block if found, otherwise null.
8
+ */
9
+ export declare const findBlockById: (content: BuilderContent, id: string) => BuilderBlock | null;
10
+ /**
11
+ * Helper function to recursively search through block tree.
12
+ *
13
+ * @param blocks The blocks to search through.
14
+ * @param id The ID of the block to search for.
15
+ * @returns The block if found, otherwise null.
16
+ * @private This is an internal implementation detail.
17
+ */
18
+ export declare const findBlockInTree: (blocks: BuilderBlock[] | undefined, id: string) => BuilderBlock | null;
@@ -2,10 +2,11 @@ import type { ContentProps } from '../components/content/content.types.js';
2
2
  import type { BuilderAnimation } from '../types/builder-block.js';
3
3
  import type { BuilderContent } from '../types/builder-content.js';
4
4
  import type { Dictionary } from '../types/typescript.js';
5
+ export type EditType = 'client' | 'server' | undefined;
5
6
  type ContentListener = Required<Pick<ContentProps, 'model' | 'trustedHosts'>> & {
6
7
  callbacks: {
7
- contentUpdate: (updatedContent: BuilderContent) => void;
8
- stateUpdate: (newState: Dictionary<string>) => void;
8
+ contentUpdate: (updatedContent: BuilderContent, editType?: EditType) => void;
9
+ stateUpdate: (newState: Dictionary<string>, editType?: EditType) => void;
9
10
  animation: (updatedContent: BuilderAnimation) => void;
10
11
  configureSdk: (updatedContent: any) => void;
11
12
  };