@builder.io/sdk-react-nextjs 0.22.0 → 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 (35) 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/constants/sdk-version.cjs +1 -1
  6. package/lib/browser/constants/sdk-version.mjs +1 -1
  7. package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
  8. package/lib/browser/functions/get-content/generate-content-url.mjs +38 -42
  9. package/lib/browser/functions/get-content/index.cjs +1 -1
  10. package/lib/browser/functions/get-content/index.mjs +42 -36
  11. package/lib/edge/blocks/img/component-info.cjs +1 -1
  12. package/lib/edge/blocks/img/component-info.mjs +33 -3
  13. package/lib/edge/blocks/img/img.cjs +1 -1
  14. package/lib/edge/blocks/img/img.mjs +22 -17
  15. package/lib/edge/constants/sdk-version.cjs +1 -1
  16. package/lib/edge/constants/sdk-version.mjs +1 -1
  17. package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
  18. package/lib/edge/functions/get-content/generate-content-url.mjs +38 -42
  19. package/lib/edge/functions/get-content/index.cjs +1 -1
  20. package/lib/edge/functions/get-content/index.mjs +42 -36
  21. package/lib/node/blocks/img/component-info.cjs +1 -1
  22. package/lib/node/blocks/img/component-info.mjs +33 -3
  23. package/lib/node/blocks/img/img.cjs +1 -1
  24. package/lib/node/blocks/img/img.mjs +22 -17
  25. package/lib/node/constants/sdk-version.cjs +1 -1
  26. package/lib/node/constants/sdk-version.mjs +1 -1
  27. package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
  28. package/lib/node/functions/get-content/generate-content-url.mjs +38 -42
  29. package/lib/node/functions/get-content/index.cjs +1 -1
  30. package/lib/node/functions/get-content/index.mjs +42 -36
  31. package/package.json +1 -1
  32. package/types/cjs/blocks/img/img.d.ts +2 -0
  33. package/types/cjs/constants/sdk-version.d.ts +1 -1
  34. package/types/esm/blocks/img/img.d.ts +2 -0
  35. package/types/esm/constants/sdk-version.d.ts +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/file-types.cjs"),t={name:"Raw:Img",hideFromInsertMenu:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",inputs:[{name:"image",bubble:!0,type:"file",allowedFileTypes:e.IMAGE_FILE_TYPES,required:!0}],noWrap:!0,static:!0};exports.componentInfo=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/file-types.cjs"),t={name:"Raw:Img",hideFromInsertMenu:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",inputs:[{name:"image",bubble:!0,type:"file",allowedFileTypes:e.IMAGE_FILE_TYPES,required:!0},{name:"backgroundSize",type:"text",defaultValue:"cover",enum:[{label:"contain",value:"contain",helperText:"The image should never get cropped"},{label:"cover",value:"cover",helperText:"The image should fill it's box, cropping when needed"}]},{name:"backgroundPosition",type:"text",defaultValue:"center",enum:["center","top","left","right","bottom","top left","top right","bottom left","bottom right"]},{name:"altText",type:"string",helperText:"Text to display when the user has images off"},{name:"title",type:"string",helperText:"Text to display when hovering over the asset"},{name:"aspectRatio",type:"number",helperText:"This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",advanced:!0,defaultValue:.7041}],noWrap:!0};exports.componentInfo=t;
@@ -1,6 +1,5 @@
1
1
  import { IMAGE_FILE_TYPES as e } from "../../constants/file-types.mjs";
2
2
  const o = {
3
- // friendlyName?
4
3
  name: "Raw:Img",
5
4
  hideFromInsertMenu: !0,
6
5
  image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
@@ -10,9 +9,40 @@ const o = {
10
9
  type: "file",
11
10
  allowedFileTypes: e,
12
11
  required: !0
12
+ }, {
13
+ name: "backgroundSize",
14
+ type: "text",
15
+ defaultValue: "cover",
16
+ enum: [{
17
+ label: "contain",
18
+ value: "contain",
19
+ helperText: "The image should never get cropped"
20
+ }, {
21
+ label: "cover",
22
+ value: "cover",
23
+ helperText: "The image should fill it's box, cropping when needed"
24
+ }]
25
+ }, {
26
+ name: "backgroundPosition",
27
+ type: "text",
28
+ defaultValue: "center",
29
+ enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
30
+ }, {
31
+ name: "altText",
32
+ type: "string",
33
+ helperText: "Text to display when the user has images off"
34
+ }, {
35
+ name: "title",
36
+ type: "string",
37
+ helperText: "Text to display when hovering over the asset"
38
+ }, {
39
+ name: "aspectRatio",
40
+ type: "number",
41
+ helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
42
+ advanced: !0,
43
+ defaultValue: 0.7041
13
44
  }],
14
- noWrap: !0,
15
- static: !0
45
+ noWrap: !0
16
46
  };
17
47
  export {
18
48
  o as componentInfo
@@ -1 +1 @@
1
- "use client";"use strict";const n=require("react/jsx-runtime"),r=require("../../functions/is-editing.cjs"),c=require("../image/image.helpers.cjs");function u(e){function i(){const t=e.imgSrc||e.image;if(!(!t||typeof t!="string")&&t.match(/builder\.io/))return c.getSrcSet(t)}return n.jsx("img",{loading:"lazy",style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,srcSet:i(),...e.attributes},r.isEditing()&&e.imgSrc||"default-key")}module.exports=u;
1
+ "use client";"use strict";const s=require("react/jsx-runtime"),c=require("../../functions/is-editing.cjs"),a=require("../../functions/get-class-prop-name.cjs");function r(t){var e;function n(){const i={...t.attributes,[a.getClassPropName()]:`builder-raw-img ${t.attributes[a.getClassPropName()]||""}`};return delete i.style,i}return s.jsx("img",{loading:"lazy",alt:t.altText,title:t.title,src:t.imgSrc||t.image,...n(),style:{objectFit:t.backgroundSize||"cover",objectPosition:t.backgroundPosition||"center",aspectRatio:t.aspectRatio||void 0,...((e=t.attributes)==null?void 0:e.style)||{}}},c.isEditing()&&t.imgSrc||"default-key")}module.exports=r;
@@ -1,29 +1,34 @@
1
1
  "use client";
2
- import { jsx as r } from "react/jsx-runtime";
3
- import { isEditing as n } from "../../functions/is-editing.mjs";
4
- import { getSrcSet as o } from "../image/image.helpers.mjs";
5
- function a(t) {
6
- function e() {
7
- const i = t.imgSrc || t.image;
8
- if (!(!i || typeof i != "string") && i.match(/builder\.io/))
9
- return o(i);
2
+ import { jsx as o } from "react/jsx-runtime";
3
+ import { isEditing as r } from "../../functions/is-editing.mjs";
4
+ import { getClassPropName as a } from "../../functions/get-class-prop-name.mjs";
5
+ function u(t) {
6
+ var e;
7
+ function n() {
8
+ const i = {
9
+ ...t.attributes,
10
+ [a()]: `builder-raw-img ${t.attributes[a()] || ""}`
11
+ };
12
+ return delete i.style, i;
10
13
  }
11
- return /* @__PURE__ */ r(
14
+ return /* @__PURE__ */ o(
12
15
  "img",
13
16
  {
14
17
  loading: "lazy",
15
- style: {
16
- objectFit: t.backgroundSize || "cover",
17
- objectPosition: t.backgroundPosition || "center"
18
- },
19
18
  alt: t.altText,
19
+ title: t.title,
20
20
  src: t.imgSrc || t.image,
21
- srcSet: e(),
22
- ...t.attributes
21
+ ...n(),
22
+ style: {
23
+ objectFit: t.backgroundSize || "cover",
24
+ objectPosition: t.backgroundPosition || "center",
25
+ aspectRatio: t.aspectRatio || void 0,
26
+ ...((e = t.attributes) == null ? void 0 : e.style) || {}
27
+ }
23
28
  },
24
- n() && t.imgSrc || "default-key"
29
+ r() && t.imgSrc || "default-key"
25
30
  );
26
31
  }
27
32
  export {
28
- a as default
33
+ u as default
29
34
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.22.0";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.22.1";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.22.0";
1
+ const o = "0.22.1";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../helpers/flatten.cjs"),O=require("../../helpers/search/search.cjs"),E=require("../../types/api-version.cjs"),F=require("../get-builder-search-params/index.cjs"),T=require("../is-browser.cjs"),w=t=>typeof t=="number"&&!isNaN(t)&&t>=0,V=t=>{const{limit:a=30,userAttributes:s,query:d,model:A,apiKey:P,enrich:S,locale:v,apiVersion:c=E.DEFAULT_API_VERSION,fields:b,omit:l,offset:f,cacheSeconds:u,staleCacheSeconds:h,sort:g,includeUnpublished:p,apiHost:N}=t;if(!P)throw new Error("Missing API key");if(!["v3"].includes(c))throw new Error(`Invalid apiVersion: expected 'v3', received '${c}'`);const k=a!==1,I=N||"https://cdn.builder.io",e=new URL(`${I}/api/${c}/content/${A}`);e.searchParams.set("apiKey",P),e.searchParams.set("limit",String(a)),e.searchParams.set("noTraverse",String(k)),e.searchParams.set("includeRefs",String(!0));const m=v||(s==null?void 0:s.locale);let n=s||{};if(m&&(e.searchParams.set("locale",m),n={locale:m,...n}),S&&e.searchParams.set("enrich",String(S)),e.searchParams.set("omit",l!=null?l:"meta.componentsUsed"),b&&e.searchParams.set("fields",b),Number.isFinite(f)&&f>-1&&e.searchParams.set("offset",String(Math.floor(f))),typeof p=="boolean"&&e.searchParams.set("includeUnpublished",String(p)),u&&w(u)&&e.searchParams.set("cacheSeconds",String(u)),h&&w(h)&&e.searchParams.set("staleCacheSeconds",String(h)),g){const r=o.flatten({sort:g});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}const y={...F.getBuilderSearchParamsFromWindow(),...O.normalizeSearchParams(t.options||{})};n={...n,...B(y)};const U=o.flatten(y);for(const r in U)e.searchParams.set(r,String(U[r]));if(Object.keys(n).length>0&&e.searchParams.set("userAttributes",JSON.stringify(n)),d){const r=o.flattenMongoQuery({query:d});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}return e},$=t=>{const a={};for(const s in t)s.startsWith("userAttributes.")&&(a[s]=t[s],delete t[s]);return a},B=t=>{if(T.isBrowser()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const a=$(t),{userAttributes:s}=o.unflatten(a);return s}return{}};exports.generateContentUrl=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../helpers/flatten.cjs"),I=require("../../helpers/search/search.cjs"),O=require("../../types/api-version.cjs"),E=require("../get-builder-search-params/index.cjs"),F=require("../is-browser.cjs"),U=t=>typeof t=="number"&&!isNaN(t)&&t>=0,T=t=>{const{limit:i=30,userAttributes:s,query:m,model:w,apiKey:d,enrich:P,locale:S,apiVersion:c=O.DEFAULT_API_VERSION,fields:b,omit:l,offset:u,cacheSeconds:f,staleCacheSeconds:h,sort:g,includeUnpublished:p,apiHost:v}=t;if(!d)throw new Error("Missing API key");if(!["v3"].includes(c))throw new Error(`Invalid apiVersion: expected 'v3', received '${c}'`);const N=i!==1,k=v||"https://cdn.builder.io",e=new URL(`${k}/api/${c}/content/${w}`);e.searchParams.set("apiKey",d),e.searchParams.set("limit",String(i)),e.searchParams.set("noTraverse",String(N)),e.searchParams.set("includeRefs",String(!0)),S&&e.searchParams.set("locale",S);let a=s||{};if(P&&e.searchParams.set("enrich",String(P)),e.searchParams.set("omit",l!=null?l:"meta.componentsUsed"),b&&e.searchParams.set("fields",b),Number.isFinite(u)&&u>-1&&e.searchParams.set("offset",String(Math.floor(u))),typeof p=="boolean"&&e.searchParams.set("includeUnpublished",String(p)),f&&U(f)&&e.searchParams.set("cacheSeconds",String(f)),h&&U(h)&&e.searchParams.set("staleCacheSeconds",String(h)),g){const r=o.flatten({sort:g});for(const n in r)e.searchParams.set(n,JSON.stringify(r[n]))}const y={...E.getBuilderSearchParamsFromWindow(),...I.normalizeSearchParams(t.options||{})};a={...a,...$(y)};const A=o.flatten(y);for(const r in A)e.searchParams.set(r,String(A[r]));if(Object.keys(a).length>0&&e.searchParams.set("userAttributes",JSON.stringify(a)),m){const r=o.flattenMongoQuery({query:m});for(const n in r)e.searchParams.set(n,JSON.stringify(r[n]))}return e},V=t=>{const i={};for(const s in t)s.startsWith("userAttributes.")&&(i[s]=t[s],delete t[s]);return i},$=t=>{if(F.isBrowser()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const i=V(t),{userAttributes:s}=o.unflatten(i);return s}return{}};exports.generateContentUrl=T;
@@ -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
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/file-types.cjs"),t={name:"Raw:Img",hideFromInsertMenu:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",inputs:[{name:"image",bubble:!0,type:"file",allowedFileTypes:e.IMAGE_FILE_TYPES,required:!0}],noWrap:!0,static:!0};exports.componentInfo=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/file-types.cjs"),t={name:"Raw:Img",hideFromInsertMenu:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",inputs:[{name:"image",bubble:!0,type:"file",allowedFileTypes:e.IMAGE_FILE_TYPES,required:!0},{name:"backgroundSize",type:"text",defaultValue:"cover",enum:[{label:"contain",value:"contain",helperText:"The image should never get cropped"},{label:"cover",value:"cover",helperText:"The image should fill it's box, cropping when needed"}]},{name:"backgroundPosition",type:"text",defaultValue:"center",enum:["center","top","left","right","bottom","top left","top right","bottom left","bottom right"]},{name:"altText",type:"string",helperText:"Text to display when the user has images off"},{name:"title",type:"string",helperText:"Text to display when hovering over the asset"},{name:"aspectRatio",type:"number",helperText:"This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",advanced:!0,defaultValue:.7041}],noWrap:!0};exports.componentInfo=t;
@@ -1,6 +1,5 @@
1
1
  import { IMAGE_FILE_TYPES as e } from "../../constants/file-types.mjs";
2
2
  const o = {
3
- // friendlyName?
4
3
  name: "Raw:Img",
5
4
  hideFromInsertMenu: !0,
6
5
  image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
@@ -10,9 +9,40 @@ const o = {
10
9
  type: "file",
11
10
  allowedFileTypes: e,
12
11
  required: !0
12
+ }, {
13
+ name: "backgroundSize",
14
+ type: "text",
15
+ defaultValue: "cover",
16
+ enum: [{
17
+ label: "contain",
18
+ value: "contain",
19
+ helperText: "The image should never get cropped"
20
+ }, {
21
+ label: "cover",
22
+ value: "cover",
23
+ helperText: "The image should fill it's box, cropping when needed"
24
+ }]
25
+ }, {
26
+ name: "backgroundPosition",
27
+ type: "text",
28
+ defaultValue: "center",
29
+ enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
30
+ }, {
31
+ name: "altText",
32
+ type: "string",
33
+ helperText: "Text to display when the user has images off"
34
+ }, {
35
+ name: "title",
36
+ type: "string",
37
+ helperText: "Text to display when hovering over the asset"
38
+ }, {
39
+ name: "aspectRatio",
40
+ type: "number",
41
+ helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
42
+ advanced: !0,
43
+ defaultValue: 0.7041
13
44
  }],
14
- noWrap: !0,
15
- static: !0
45
+ noWrap: !0
16
46
  };
17
47
  export {
18
48
  o as componentInfo
@@ -1 +1 @@
1
- "use client";"use strict";const n=require("react/jsx-runtime"),r=require("../../functions/is-editing.cjs"),c=require("../image/image.helpers.cjs");function u(e){function i(){const t=e.imgSrc||e.image;if(!(!t||typeof t!="string")&&t.match(/builder\.io/))return c.getSrcSet(t)}return n.jsx("img",{loading:"lazy",style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,srcSet:i(),...e.attributes},r.isEditing()&&e.imgSrc||"default-key")}module.exports=u;
1
+ "use client";"use strict";const s=require("react/jsx-runtime"),c=require("../../functions/is-editing.cjs"),a=require("../../functions/get-class-prop-name.cjs");function r(t){var e;function n(){const i={...t.attributes,[a.getClassPropName()]:`builder-raw-img ${t.attributes[a.getClassPropName()]||""}`};return delete i.style,i}return s.jsx("img",{loading:"lazy",alt:t.altText,title:t.title,src:t.imgSrc||t.image,...n(),style:{objectFit:t.backgroundSize||"cover",objectPosition:t.backgroundPosition||"center",aspectRatio:t.aspectRatio||void 0,...((e=t.attributes)==null?void 0:e.style)||{}}},c.isEditing()&&t.imgSrc||"default-key")}module.exports=r;
@@ -1,29 +1,34 @@
1
1
  "use client";
2
- import { jsx as r } from "react/jsx-runtime";
3
- import { isEditing as n } from "../../functions/is-editing.mjs";
4
- import { getSrcSet as o } from "../image/image.helpers.mjs";
5
- function a(t) {
6
- function e() {
7
- const i = t.imgSrc || t.image;
8
- if (!(!i || typeof i != "string") && i.match(/builder\.io/))
9
- return o(i);
2
+ import { jsx as o } from "react/jsx-runtime";
3
+ import { isEditing as r } from "../../functions/is-editing.mjs";
4
+ import { getClassPropName as a } from "../../functions/get-class-prop-name.mjs";
5
+ function u(t) {
6
+ var e;
7
+ function n() {
8
+ const i = {
9
+ ...t.attributes,
10
+ [a()]: `builder-raw-img ${t.attributes[a()] || ""}`
11
+ };
12
+ return delete i.style, i;
10
13
  }
11
- return /* @__PURE__ */ r(
14
+ return /* @__PURE__ */ o(
12
15
  "img",
13
16
  {
14
17
  loading: "lazy",
15
- style: {
16
- objectFit: t.backgroundSize || "cover",
17
- objectPosition: t.backgroundPosition || "center"
18
- },
19
18
  alt: t.altText,
19
+ title: t.title,
20
20
  src: t.imgSrc || t.image,
21
- srcSet: e(),
22
- ...t.attributes
21
+ ...n(),
22
+ style: {
23
+ objectFit: t.backgroundSize || "cover",
24
+ objectPosition: t.backgroundPosition || "center",
25
+ aspectRatio: t.aspectRatio || void 0,
26
+ ...((e = t.attributes) == null ? void 0 : e.style) || {}
27
+ }
23
28
  },
24
- n() && t.imgSrc || "default-key"
29
+ r() && t.imgSrc || "default-key"
25
30
  );
26
31
  }
27
32
  export {
28
- a as default
33
+ u as default
29
34
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.22.0";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.22.1";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.22.0";
1
+ const o = "0.22.1";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../helpers/flatten.cjs"),O=require("../../helpers/search/search.cjs"),E=require("../../types/api-version.cjs"),F=require("../get-builder-search-params/index.cjs"),T=require("../is-browser.cjs"),w=t=>typeof t=="number"&&!isNaN(t)&&t>=0,V=t=>{const{limit:a=30,userAttributes:s,query:d,model:A,apiKey:P,enrich:S,locale:v,apiVersion:c=E.DEFAULT_API_VERSION,fields:b,omit:l,offset:f,cacheSeconds:u,staleCacheSeconds:h,sort:g,includeUnpublished:p,apiHost:N}=t;if(!P)throw new Error("Missing API key");if(!["v3"].includes(c))throw new Error(`Invalid apiVersion: expected 'v3', received '${c}'`);const k=a!==1,I=N||"https://cdn.builder.io",e=new URL(`${I}/api/${c}/content/${A}`);e.searchParams.set("apiKey",P),e.searchParams.set("limit",String(a)),e.searchParams.set("noTraverse",String(k)),e.searchParams.set("includeRefs",String(!0));const m=v||(s==null?void 0:s.locale);let n=s||{};if(m&&(e.searchParams.set("locale",m),n={locale:m,...n}),S&&e.searchParams.set("enrich",String(S)),e.searchParams.set("omit",l!=null?l:"meta.componentsUsed"),b&&e.searchParams.set("fields",b),Number.isFinite(f)&&f>-1&&e.searchParams.set("offset",String(Math.floor(f))),typeof p=="boolean"&&e.searchParams.set("includeUnpublished",String(p)),u&&w(u)&&e.searchParams.set("cacheSeconds",String(u)),h&&w(h)&&e.searchParams.set("staleCacheSeconds",String(h)),g){const r=o.flatten({sort:g});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}const y={...F.getBuilderSearchParamsFromWindow(),...O.normalizeSearchParams(t.options||{})};n={...n,...B(y)};const U=o.flatten(y);for(const r in U)e.searchParams.set(r,String(U[r]));if(Object.keys(n).length>0&&e.searchParams.set("userAttributes",JSON.stringify(n)),d){const r=o.flattenMongoQuery({query:d});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}return e},$=t=>{const a={};for(const s in t)s.startsWith("userAttributes.")&&(a[s]=t[s],delete t[s]);return a},B=t=>{if(T.isBrowser()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const a=$(t),{userAttributes:s}=o.unflatten(a);return s}return{}};exports.generateContentUrl=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../helpers/flatten.cjs"),I=require("../../helpers/search/search.cjs"),O=require("../../types/api-version.cjs"),E=require("../get-builder-search-params/index.cjs"),F=require("../is-browser.cjs"),U=t=>typeof t=="number"&&!isNaN(t)&&t>=0,T=t=>{const{limit:i=30,userAttributes:s,query:m,model:w,apiKey:d,enrich:P,locale:S,apiVersion:c=O.DEFAULT_API_VERSION,fields:b,omit:l,offset:u,cacheSeconds:f,staleCacheSeconds:h,sort:g,includeUnpublished:p,apiHost:v}=t;if(!d)throw new Error("Missing API key");if(!["v3"].includes(c))throw new Error(`Invalid apiVersion: expected 'v3', received '${c}'`);const N=i!==1,k=v||"https://cdn.builder.io",e=new URL(`${k}/api/${c}/content/${w}`);e.searchParams.set("apiKey",d),e.searchParams.set("limit",String(i)),e.searchParams.set("noTraverse",String(N)),e.searchParams.set("includeRefs",String(!0)),S&&e.searchParams.set("locale",S);let a=s||{};if(P&&e.searchParams.set("enrich",String(P)),e.searchParams.set("omit",l!=null?l:"meta.componentsUsed"),b&&e.searchParams.set("fields",b),Number.isFinite(u)&&u>-1&&e.searchParams.set("offset",String(Math.floor(u))),typeof p=="boolean"&&e.searchParams.set("includeUnpublished",String(p)),f&&U(f)&&e.searchParams.set("cacheSeconds",String(f)),h&&U(h)&&e.searchParams.set("staleCacheSeconds",String(h)),g){const r=o.flatten({sort:g});for(const n in r)e.searchParams.set(n,JSON.stringify(r[n]))}const y={...E.getBuilderSearchParamsFromWindow(),...I.normalizeSearchParams(t.options||{})};a={...a,...$(y)};const A=o.flatten(y);for(const r in A)e.searchParams.set(r,String(A[r]));if(Object.keys(a).length>0&&e.searchParams.set("userAttributes",JSON.stringify(a)),m){const r=o.flattenMongoQuery({query:m});for(const n in r)e.searchParams.set(n,JSON.stringify(r[n]))}return e},V=t=>{const i={};for(const s in t)s.startsWith("userAttributes.")&&(i[s]=t[s],delete t[s]);return i},$=t=>{if(F.isBrowser()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const i=V(t),{userAttributes:s}=o.unflatten(i);return s}return{}};exports.generateContentUrl=T;
@@ -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
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/file-types.cjs"),t={name:"Raw:Img",hideFromInsertMenu:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",inputs:[{name:"image",bubble:!0,type:"file",allowedFileTypes:e.IMAGE_FILE_TYPES,required:!0}],noWrap:!0,static:!0};exports.componentInfo=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../constants/file-types.cjs"),t={name:"Raw:Img",hideFromInsertMenu:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",inputs:[{name:"image",bubble:!0,type:"file",allowedFileTypes:e.IMAGE_FILE_TYPES,required:!0},{name:"backgroundSize",type:"text",defaultValue:"cover",enum:[{label:"contain",value:"contain",helperText:"The image should never get cropped"},{label:"cover",value:"cover",helperText:"The image should fill it's box, cropping when needed"}]},{name:"backgroundPosition",type:"text",defaultValue:"center",enum:["center","top","left","right","bottom","top left","top right","bottom left","bottom right"]},{name:"altText",type:"string",helperText:"Text to display when the user has images off"},{name:"title",type:"string",helperText:"Text to display when hovering over the asset"},{name:"aspectRatio",type:"number",helperText:"This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",advanced:!0,defaultValue:.7041}],noWrap:!0};exports.componentInfo=t;
@@ -1,6 +1,5 @@
1
1
  import { IMAGE_FILE_TYPES as e } from "../../constants/file-types.mjs";
2
2
  const o = {
3
- // friendlyName?
4
3
  name: "Raw:Img",
5
4
  hideFromInsertMenu: !0,
6
5
  image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
@@ -10,9 +9,40 @@ const o = {
10
9
  type: "file",
11
10
  allowedFileTypes: e,
12
11
  required: !0
12
+ }, {
13
+ name: "backgroundSize",
14
+ type: "text",
15
+ defaultValue: "cover",
16
+ enum: [{
17
+ label: "contain",
18
+ value: "contain",
19
+ helperText: "The image should never get cropped"
20
+ }, {
21
+ label: "cover",
22
+ value: "cover",
23
+ helperText: "The image should fill it's box, cropping when needed"
24
+ }]
25
+ }, {
26
+ name: "backgroundPosition",
27
+ type: "text",
28
+ defaultValue: "center",
29
+ enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
30
+ }, {
31
+ name: "altText",
32
+ type: "string",
33
+ helperText: "Text to display when the user has images off"
34
+ }, {
35
+ name: "title",
36
+ type: "string",
37
+ helperText: "Text to display when hovering over the asset"
38
+ }, {
39
+ name: "aspectRatio",
40
+ type: "number",
41
+ helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
42
+ advanced: !0,
43
+ defaultValue: 0.7041
13
44
  }],
14
- noWrap: !0,
15
- static: !0
45
+ noWrap: !0
16
46
  };
17
47
  export {
18
48
  o as componentInfo
@@ -1 +1 @@
1
- "use client";"use strict";const n=require("react/jsx-runtime"),r=require("../../functions/is-editing.cjs"),c=require("../image/image.helpers.cjs");function u(e){function i(){const t=e.imgSrc||e.image;if(!(!t||typeof t!="string")&&t.match(/builder\.io/))return c.getSrcSet(t)}return n.jsx("img",{loading:"lazy",style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,srcSet:i(),...e.attributes},r.isEditing()&&e.imgSrc||"default-key")}module.exports=u;
1
+ "use client";"use strict";const s=require("react/jsx-runtime"),c=require("../../functions/is-editing.cjs"),a=require("../../functions/get-class-prop-name.cjs");function r(t){var e;function n(){const i={...t.attributes,[a.getClassPropName()]:`builder-raw-img ${t.attributes[a.getClassPropName()]||""}`};return delete i.style,i}return s.jsx("img",{loading:"lazy",alt:t.altText,title:t.title,src:t.imgSrc||t.image,...n(),style:{objectFit:t.backgroundSize||"cover",objectPosition:t.backgroundPosition||"center",aspectRatio:t.aspectRatio||void 0,...((e=t.attributes)==null?void 0:e.style)||{}}},c.isEditing()&&t.imgSrc||"default-key")}module.exports=r;
@@ -1,29 +1,34 @@
1
1
  "use client";
2
- import { jsx as r } from "react/jsx-runtime";
3
- import { isEditing as n } from "../../functions/is-editing.mjs";
4
- import { getSrcSet as o } from "../image/image.helpers.mjs";
5
- function a(t) {
6
- function e() {
7
- const i = t.imgSrc || t.image;
8
- if (!(!i || typeof i != "string") && i.match(/builder\.io/))
9
- return o(i);
2
+ import { jsx as o } from "react/jsx-runtime";
3
+ import { isEditing as r } from "../../functions/is-editing.mjs";
4
+ import { getClassPropName as a } from "../../functions/get-class-prop-name.mjs";
5
+ function u(t) {
6
+ var e;
7
+ function n() {
8
+ const i = {
9
+ ...t.attributes,
10
+ [a()]: `builder-raw-img ${t.attributes[a()] || ""}`
11
+ };
12
+ return delete i.style, i;
10
13
  }
11
- return /* @__PURE__ */ r(
14
+ return /* @__PURE__ */ o(
12
15
  "img",
13
16
  {
14
17
  loading: "lazy",
15
- style: {
16
- objectFit: t.backgroundSize || "cover",
17
- objectPosition: t.backgroundPosition || "center"
18
- },
19
18
  alt: t.altText,
19
+ title: t.title,
20
20
  src: t.imgSrc || t.image,
21
- srcSet: e(),
22
- ...t.attributes
21
+ ...n(),
22
+ style: {
23
+ objectFit: t.backgroundSize || "cover",
24
+ objectPosition: t.backgroundPosition || "center",
25
+ aspectRatio: t.aspectRatio || void 0,
26
+ ...((e = t.attributes) == null ? void 0 : e.style) || {}
27
+ }
23
28
  },
24
- n() && t.imgSrc || "default-key"
29
+ r() && t.imgSrc || "default-key"
25
30
  );
26
31
  }
27
32
  export {
28
- a as default
33
+ u as default
29
34
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.22.0";exports.SDK_VERSION=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.22.1";exports.SDK_VERSION=e;
@@ -1,4 +1,4 @@
1
- const o = "0.22.0";
1
+ const o = "0.22.1";
2
2
  export {
3
3
  o as SDK_VERSION
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../helpers/flatten.cjs"),O=require("../../helpers/search/search.cjs"),E=require("../../types/api-version.cjs"),F=require("../get-builder-search-params/index.cjs"),T=require("../is-browser.cjs"),w=t=>typeof t=="number"&&!isNaN(t)&&t>=0,V=t=>{const{limit:a=30,userAttributes:s,query:d,model:A,apiKey:P,enrich:S,locale:v,apiVersion:c=E.DEFAULT_API_VERSION,fields:b,omit:l,offset:f,cacheSeconds:u,staleCacheSeconds:h,sort:g,includeUnpublished:p,apiHost:N}=t;if(!P)throw new Error("Missing API key");if(!["v3"].includes(c))throw new Error(`Invalid apiVersion: expected 'v3', received '${c}'`);const k=a!==1,I=N||"https://cdn.builder.io",e=new URL(`${I}/api/${c}/content/${A}`);e.searchParams.set("apiKey",P),e.searchParams.set("limit",String(a)),e.searchParams.set("noTraverse",String(k)),e.searchParams.set("includeRefs",String(!0));const m=v||(s==null?void 0:s.locale);let n=s||{};if(m&&(e.searchParams.set("locale",m),n={locale:m,...n}),S&&e.searchParams.set("enrich",String(S)),e.searchParams.set("omit",l!=null?l:"meta.componentsUsed"),b&&e.searchParams.set("fields",b),Number.isFinite(f)&&f>-1&&e.searchParams.set("offset",String(Math.floor(f))),typeof p=="boolean"&&e.searchParams.set("includeUnpublished",String(p)),u&&w(u)&&e.searchParams.set("cacheSeconds",String(u)),h&&w(h)&&e.searchParams.set("staleCacheSeconds",String(h)),g){const r=o.flatten({sort:g});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}const y={...F.getBuilderSearchParamsFromWindow(),...O.normalizeSearchParams(t.options||{})};n={...n,...B(y)};const U=o.flatten(y);for(const r in U)e.searchParams.set(r,String(U[r]));if(Object.keys(n).length>0&&e.searchParams.set("userAttributes",JSON.stringify(n)),d){const r=o.flattenMongoQuery({query:d});for(const i in r)e.searchParams.set(i,JSON.stringify(r[i]))}return e},$=t=>{const a={};for(const s in t)s.startsWith("userAttributes.")&&(a[s]=t[s],delete t[s]);return a},B=t=>{if(T.isBrowser()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const a=$(t),{userAttributes:s}=o.unflatten(a);return s}return{}};exports.generateContentUrl=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../helpers/flatten.cjs"),I=require("../../helpers/search/search.cjs"),O=require("../../types/api-version.cjs"),E=require("../get-builder-search-params/index.cjs"),F=require("../is-browser.cjs"),U=t=>typeof t=="number"&&!isNaN(t)&&t>=0,T=t=>{const{limit:i=30,userAttributes:s,query:m,model:w,apiKey:d,enrich:P,locale:S,apiVersion:c=O.DEFAULT_API_VERSION,fields:b,omit:l,offset:u,cacheSeconds:f,staleCacheSeconds:h,sort:g,includeUnpublished:p,apiHost:v}=t;if(!d)throw new Error("Missing API key");if(!["v3"].includes(c))throw new Error(`Invalid apiVersion: expected 'v3', received '${c}'`);const N=i!==1,k=v||"https://cdn.builder.io",e=new URL(`${k}/api/${c}/content/${w}`);e.searchParams.set("apiKey",d),e.searchParams.set("limit",String(i)),e.searchParams.set("noTraverse",String(N)),e.searchParams.set("includeRefs",String(!0)),S&&e.searchParams.set("locale",S);let a=s||{};if(P&&e.searchParams.set("enrich",String(P)),e.searchParams.set("omit",l!=null?l:"meta.componentsUsed"),b&&e.searchParams.set("fields",b),Number.isFinite(u)&&u>-1&&e.searchParams.set("offset",String(Math.floor(u))),typeof p=="boolean"&&e.searchParams.set("includeUnpublished",String(p)),f&&U(f)&&e.searchParams.set("cacheSeconds",String(f)),h&&U(h)&&e.searchParams.set("staleCacheSeconds",String(h)),g){const r=o.flatten({sort:g});for(const n in r)e.searchParams.set(n,JSON.stringify(r[n]))}const y={...E.getBuilderSearchParamsFromWindow(),...I.normalizeSearchParams(t.options||{})};a={...a,...$(y)};const A=o.flatten(y);for(const r in A)e.searchParams.set(r,String(A[r]));if(Object.keys(a).length>0&&e.searchParams.set("userAttributes",JSON.stringify(a)),m){const r=o.flattenMongoQuery({query:m});for(const n in r)e.searchParams.set(n,JSON.stringify(r[n]))}return e},V=t=>{const i={};for(const s in t)s.startsWith("userAttributes.")&&(i[s]=t[s],delete t[s]);return i},$=t=>{if(F.isBrowser()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const i=V(t),{userAttributes:s}=o.unflatten(i);return s}return{}};exports.generateContentUrl=T;
@@ -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
  };
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.22.0",
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;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.22.0";
1
+ export declare const SDK_VERSION = "0.22.1";
@@ -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;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.22.0";
1
+ export declare const SDK_VERSION = "0.22.1";