@builder.io/sdk-react-nextjs 0.16.20 → 0.16.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/blocks/columns/columns.cjs +2 -2
- package/lib/browser/blocks/columns/columns.mjs +24 -24
- package/lib/browser/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/browser/components/blocks/blocks-wrapper.mjs +26 -20
- package/lib/browser/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +58 -57
- package/lib/browser/constants/sdk-version.cjs +1 -1
- package/lib/browser/constants/sdk-version.mjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.mjs +43 -37
- package/lib/browser/functions/log-fetch.cjs +1 -0
- package/lib/browser/functions/log-fetch.mjs +8 -0
- package/lib/browser/functions/register-component.cjs +1 -1
- package/lib/browser/functions/register-component.mjs +6 -6
- package/lib/browser/functions/track/index.cjs +1 -1
- package/lib/browser/functions/track/index.mjs +18 -14
- package/lib/edge/blocks/columns/columns.cjs +2 -2
- package/lib/edge/blocks/columns/columns.mjs +24 -24
- package/lib/edge/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/edge/components/blocks/blocks-wrapper.mjs +26 -20
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +58 -57
- package/lib/edge/constants/sdk-version.cjs +1 -1
- package/lib/edge/constants/sdk-version.mjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.mjs +43 -37
- package/lib/edge/functions/log-fetch.cjs +1 -0
- package/lib/edge/functions/log-fetch.mjs +8 -0
- package/lib/edge/functions/register-component.cjs +1 -1
- package/lib/edge/functions/register-component.mjs +6 -6
- package/lib/edge/functions/track/index.cjs +1 -1
- package/lib/edge/functions/track/index.mjs +18 -14
- package/lib/node/blocks/columns/columns.cjs +2 -2
- package/lib/node/blocks/columns/columns.mjs +24 -24
- package/lib/node/components/blocks/blocks-wrapper.cjs +1 -1
- package/lib/node/components/blocks/blocks-wrapper.mjs +26 -20
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +58 -57
- package/lib/node/constants/sdk-version.cjs +1 -1
- package/lib/node/constants/sdk-version.mjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.cjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.mjs +43 -37
- package/lib/node/functions/log-fetch.cjs +1 -0
- package/lib/node/functions/log-fetch.mjs +8 -0
- package/lib/node/functions/register-component.cjs +1 -1
- package/lib/node/functions/register-component.mjs +6 -6
- package/lib/node/functions/track/index.cjs +1 -1
- package/lib/node/functions/track/index.mjs +18 -14
- package/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/log-fetch.d.ts +1 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/log-fetch.d.ts +1 -0
|
@@ -1,47 +1,53 @@
|
|
|
1
|
-
import { flatten as
|
|
2
|
-
import { normalizeSearchParams as
|
|
3
|
-
import { DEFAULT_API_VERSION as
|
|
4
|
-
import { getBuilderSearchParamsFromWindow as
|
|
5
|
-
const
|
|
1
|
+
import { flatten as y, flattenMongoQuery as E } from "../../helpers/flatten.mjs";
|
|
2
|
+
import { normalizeSearchParams as I } from "../../helpers/search/search.mjs";
|
|
3
|
+
import { DEFAULT_API_VERSION as $ } from "../../types/api-version.mjs";
|
|
4
|
+
import { getBuilderSearchParamsFromWindow as C } from "../get-builder-search-params/index.mjs";
|
|
5
|
+
const b = (r) => typeof r == "number" && !isNaN(r) && r >= 0, R = (r) => {
|
|
6
6
|
const {
|
|
7
|
-
limit:
|
|
8
|
-
userAttributes:
|
|
9
|
-
query:
|
|
10
|
-
model:
|
|
11
|
-
apiKey:
|
|
12
|
-
enrich:
|
|
13
|
-
locale:
|
|
14
|
-
apiVersion:
|
|
15
|
-
fields:
|
|
16
|
-
omit:
|
|
17
|
-
offset:
|
|
18
|
-
cacheSeconds:
|
|
19
|
-
staleCacheSeconds:
|
|
20
|
-
sort:
|
|
21
|
-
includeUnpublished:
|
|
22
|
-
apiHost:
|
|
7
|
+
limit: m = 30,
|
|
8
|
+
userAttributes: a,
|
|
9
|
+
query: h,
|
|
10
|
+
model: N,
|
|
11
|
+
apiKey: d,
|
|
12
|
+
enrich: P,
|
|
13
|
+
locale: U,
|
|
14
|
+
apiVersion: n = $,
|
|
15
|
+
fields: p,
|
|
16
|
+
omit: v,
|
|
17
|
+
offset: o,
|
|
18
|
+
cacheSeconds: c,
|
|
19
|
+
staleCacheSeconds: f,
|
|
20
|
+
sort: S,
|
|
21
|
+
includeUnpublished: u,
|
|
22
|
+
apiHost: w
|
|
23
23
|
} = r;
|
|
24
|
-
if (!
|
|
24
|
+
if (!d)
|
|
25
25
|
throw new Error("Missing API key");
|
|
26
|
-
if (!["v3"].includes(
|
|
27
|
-
throw new Error(`Invalid apiVersion: expected 'v3', received '${
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
if (!["v3"].includes(n))
|
|
27
|
+
throw new Error(`Invalid apiVersion: expected 'v3', received '${n}'`);
|
|
28
|
+
const O = m !== 1, k = w || "https://cdn.builder.io", e = new URL(`${k}/api/${n}/content/${N}`);
|
|
29
|
+
e.searchParams.set("apiKey", d), e.searchParams.set("limit", String(m)), e.searchParams.set("noTraverse", String(O)), e.searchParams.set("includeRefs", String(!0));
|
|
30
|
+
const l = U || (a == null ? void 0 : a.locale);
|
|
31
|
+
let i = a;
|
|
32
|
+
if (l && (e.searchParams.set("locale", l), i = {
|
|
33
|
+
locale: l,
|
|
34
|
+
...i
|
|
35
|
+
}), P && e.searchParams.set("enrich", String(P)), e.searchParams.set("omit", v || "meta.componentsUsed"), p && e.searchParams.set("fields", p), Number.isFinite(o) && o > -1 && e.searchParams.set("offset", String(Math.floor(o))), typeof u == "boolean" && e.searchParams.set("includeUnpublished", String(u)), c && b(c) && e.searchParams.set("cacheSeconds", String(c)), f && b(f) && e.searchParams.set("staleCacheSeconds", String(f)), S) {
|
|
36
|
+
const s = y({
|
|
37
|
+
sort: S
|
|
32
38
|
});
|
|
33
39
|
for (const t in s)
|
|
34
40
|
e.searchParams.set(t, JSON.stringify(s[t]));
|
|
35
41
|
}
|
|
36
42
|
const A = {
|
|
37
|
-
...
|
|
38
|
-
...
|
|
39
|
-
},
|
|
40
|
-
for (const s in
|
|
41
|
-
e.searchParams.set(s, String(
|
|
42
|
-
if (
|
|
43
|
-
const s =
|
|
44
|
-
query:
|
|
43
|
+
...C(),
|
|
44
|
+
...I(r.options || {})
|
|
45
|
+
}, g = y(A);
|
|
46
|
+
for (const s in g)
|
|
47
|
+
e.searchParams.set(s, String(g[s]));
|
|
48
|
+
if (i && e.searchParams.set("userAttributes", JSON.stringify(i)), h) {
|
|
49
|
+
const s = E({
|
|
50
|
+
query: h
|
|
45
51
|
});
|
|
46
52
|
for (const t in s)
|
|
47
53
|
e.searchParams.set(t, JSON.stringify(s[t]));
|
|
@@ -49,5 +55,5 @@ const y = (r) => typeof r == "number" && !isNaN(r) && r >= 0, M = (r) => {
|
|
|
49
55
|
return e;
|
|
50
56
|
};
|
|
51
57
|
export {
|
|
52
|
-
|
|
58
|
+
R as generateContentUrl
|
|
53
59
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../helpers/logger.cjs");function t(o){var e;typeof process!="undefined"&&((e=process.env)!=null&&e.DEBUG)&&String(process.env.DEBUG)=="true"&&r.logger.log(o)}exports.logFetch=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=t=>({type:"builder.registerComponent",data:r(t)}),s=t=>{const n=t.toString().trim();return`return (${!n.startsWith("function")&&!n.startsWith("(")?"function ":""}${n}).apply(this, arguments)`};function r(t){return JSON.parse(JSON.stringify(t,(n,e)=>typeof e=="function"?s(e):e))}exports.createRegisterComponentMessage=i;exports.serializeIncludingFunctions=r;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=t=>({type:"builder.registerComponent",data:r(t)}),s=t=>{const n=t.toString().trim(),e=/^[a-zA-Z0-9_]+\s*=>/i.test(n);return`return (${!n.startsWith("function")&&!n.startsWith("(")&&!e?"function ":""}${n}).apply(this, arguments)`};function r(t){return JSON.parse(JSON.stringify(t,(n,e)=>typeof e=="function"?s(e):e))}exports.createRegisterComponentMessage=i;exports.serializeIncludingFunctions=r;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const
|
|
1
|
+
const o = (t) => ({
|
|
2
2
|
type: "builder.registerComponent",
|
|
3
3
|
data: i(t)
|
|
4
|
-
}),
|
|
5
|
-
const n = t.toString().trim();
|
|
6
|
-
return `return (${!n.startsWith("function") && !n.startsWith("(") ? "function " : ""}${n}).apply(this, arguments)`;
|
|
4
|
+
}), e = (t) => {
|
|
5
|
+
const n = t.toString().trim(), r = /^[a-zA-Z0-9_]+\s*=>/i.test(n);
|
|
6
|
+
return `return (${!n.startsWith("function") && !n.startsWith("(") && !r ? "function " : ""}${n}).apply(this, arguments)`;
|
|
7
7
|
};
|
|
8
8
|
function i(t) {
|
|
9
|
-
return JSON.parse(JSON.stringify(t, (n,
|
|
9
|
+
return JSON.parse(JSON.stringify(t, (n, r) => typeof r == "function" ? e(r) : r));
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
o as createRegisterComponentMessage,
|
|
13
13
|
i as serializeIncludingFunctions
|
|
14
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../constants/target.cjs"),a=require("../../helpers/logger.cjs"),c=require("../../helpers/sdk-headers.cjs"),d=require("../../helpers/sessionId.cjs"),u=require("../../helpers/visitorId.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../constants/target.cjs"),a=require("../../helpers/logger.cjs"),c=require("../../helpers/sdk-headers.cjs"),d=require("../../helpers/sessionId.cjs"),u=require("../../helpers/visitorId.cjs"),l=require("../is-browser.cjs"),g=require("../is-editing.cjs"),y=require("../log-fetch.cjs"),I=require("./helpers.cjs"),k=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await d.getSessionId({canTrack:e}),r=u.getVisitorId({canTrack:e});return{sessionId:t,visitorId:r}},f=async({type:e,canTrack:t,apiKey:r,metadata:s,...i})=>({type:e,data:{...i,metadata:{url:location.href,...s},...await k({canTrack:t}),userAttributes:I.getUserAttributes(),ownerId:r}});async function o({apiHost:e,...t}){if(!t.apiKey){a.logger.error("Missing API key for track call. Please provide your API key.");return}if(!t.canTrack||g.isEditing()||!(l.isBrowser()||n.TARGET==="reactNative"))return;const s=`${e||"https://cdn.builder.io"}/api/v1/track`;return y.logFetch(s),fetch(s,{method:"POST",body:JSON.stringify({events:[await f(t)]}),headers:{"content-type":"application/json",...c.getSdkHeaders()},mode:"cors"}).catch(i=>{console.error("Failed to track: ",i)})}const v=e=>o({...e,canTrack:!0});exports._track=o;exports.track=v;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { TARGET as
|
|
2
|
-
import { logger as
|
|
1
|
+
import { TARGET as s } from "../../constants/target.mjs";
|
|
2
|
+
import { logger as a } from "../../helpers/logger.mjs";
|
|
3
3
|
import { getSdkHeaders as n } from "../../helpers/sdk-headers.mjs";
|
|
4
4
|
import { getSessionId as c } from "../../helpers/sessionId.mjs";
|
|
5
5
|
import { getVisitorId as d } from "../../helpers/visitorId.mjs";
|
|
6
6
|
import { isBrowser as m } from "../is-browser.mjs";
|
|
7
7
|
import { isEditing as f } from "../is-editing.mjs";
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { logFetch as p } from "../log-fetch.mjs";
|
|
9
|
+
import { getUserAttributes as u } from "./helpers.mjs";
|
|
10
|
+
const l = async ({
|
|
10
11
|
canTrack: t
|
|
11
12
|
}) => {
|
|
12
13
|
if (!t)
|
|
@@ -23,7 +24,7 @@ const u = async ({
|
|
|
23
24
|
sessionId: r,
|
|
24
25
|
visitorId: e
|
|
25
26
|
};
|
|
26
|
-
},
|
|
27
|
+
}, g = async ({
|
|
27
28
|
type: t,
|
|
28
29
|
canTrack: r,
|
|
29
30
|
apiKey: e,
|
|
@@ -37,10 +38,10 @@ const u = async ({
|
|
|
37
38
|
url: location.href,
|
|
38
39
|
...o
|
|
39
40
|
},
|
|
40
|
-
...await
|
|
41
|
+
...await l({
|
|
41
42
|
canTrack: r
|
|
42
43
|
}),
|
|
43
|
-
userAttributes:
|
|
44
|
+
userAttributes: u(),
|
|
44
45
|
ownerId: e
|
|
45
46
|
}
|
|
46
47
|
});
|
|
@@ -49,28 +50,31 @@ async function y({
|
|
|
49
50
|
...r
|
|
50
51
|
}) {
|
|
51
52
|
if (!r.apiKey) {
|
|
52
|
-
|
|
53
|
+
a.error("Missing API key for track call. Please provide your API key.");
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
if (!r.canTrack || f() || !(m() || s === "reactNative"))
|
|
57
|
+
return;
|
|
58
|
+
const o = `${t || "https://cdn.builder.io"}/api/v1/track`;
|
|
59
|
+
return p(o), fetch(o, {
|
|
56
60
|
method: "POST",
|
|
57
61
|
body: JSON.stringify({
|
|
58
|
-
events: [await
|
|
62
|
+
events: [await g(r)]
|
|
59
63
|
}),
|
|
60
64
|
headers: {
|
|
61
65
|
"content-type": "application/json",
|
|
62
66
|
...n()
|
|
63
67
|
},
|
|
64
68
|
mode: "cors"
|
|
65
|
-
}).catch((
|
|
66
|
-
console.error("Failed to track: ",
|
|
69
|
+
}).catch((i) => {
|
|
70
|
+
console.error("Failed to track: ", i);
|
|
67
71
|
});
|
|
68
72
|
}
|
|
69
|
-
const
|
|
73
|
+
const T = (t) => y({
|
|
70
74
|
...t,
|
|
71
75
|
canTrack: !0
|
|
72
76
|
});
|
|
73
77
|
export {
|
|
74
78
|
y as _track,
|
|
75
|
-
|
|
79
|
+
T as track
|
|
76
80
|
};
|
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.16.
|
|
4
|
+
"version": "0.16.24",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.16.
|
|
1
|
+
export declare const SDK_VERSION = "0.16.24";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function logFetch(url: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.16.
|
|
1
|
+
export declare const SDK_VERSION = "0.16.24";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function logFetch(url: string): void;
|