@builder.io/sdk-react-nextjs 0.16.18 → 0.16.19
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/components/content/components/enable-editor.cjs +1 -1
- package/lib/browser/components/content/components/enable-editor.mjs +107 -105
- package/lib/browser/components/content/content.cjs +1 -1
- package/lib/browser/components/content/content.mjs +23 -21
- package/lib/browser/components/content-variants/content-variants.cjs +1 -1
- package/lib/browser/components/content-variants/content-variants.mjs +10 -8
- 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 +24 -23
- package/lib/browser/functions/track/index.cjs +1 -1
- package/lib/browser/functions/track/index.mjs +21 -19
- package/lib/edge/components/content/components/enable-editor.cjs +1 -1
- package/lib/edge/components/content/components/enable-editor.mjs +107 -105
- package/lib/edge/components/content/content.cjs +1 -1
- package/lib/edge/components/content/content.mjs +23 -21
- package/lib/edge/components/content-variants/content-variants.cjs +1 -1
- package/lib/edge/components/content-variants/content-variants.mjs +10 -8
- 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 +24 -23
- package/lib/edge/functions/track/index.cjs +1 -1
- package/lib/edge/functions/track/index.mjs +21 -19
- package/lib/node/components/content/components/enable-editor.cjs +1 -1
- package/lib/node/components/content/components/enable-editor.mjs +107 -105
- package/lib/node/components/content/content.cjs +1 -1
- package/lib/node/components/content/content.mjs +23 -21
- package/lib/node/components/content-variants/content-variants.cjs +1 -1
- package/lib/node/components/content-variants/content-variants.mjs +10 -8
- 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 +24 -23
- package/lib/node/functions/track/index.cjs +1 -1
- package/lib/node/functions/track/index.mjs +21 -19
- package/package.json +1 -1
- package/types/cjs/components/content/components/enable-editor.d.ts +1 -1
- package/types/cjs/components/content-variants/content-variants.types.d.ts +4 -0
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/get-content/types.d.ts +4 -0
- package/types/cjs/functions/track/index.d.ts +3 -1
- package/types/esm/components/content/components/enable-editor.d.ts +1 -1
- package/types/esm/components/content-variants/content-variants.types.d.ts +4 -0
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/get-content/types.d.ts +4 -0
- package/types/esm/functions/track/index.d.ts +3 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { flatten as g, flattenMongoQuery as
|
|
2
|
-
import { normalizeSearchParams as
|
|
3
|
-
import { DEFAULT_API_VERSION as
|
|
4
|
-
import { getBuilderSearchParamsFromWindow as
|
|
5
|
-
const y = (
|
|
1
|
+
import { flatten as g, flattenMongoQuery as O } from "../../helpers/flatten.mjs";
|
|
2
|
+
import { normalizeSearchParams as k } from "../../helpers/search/search.mjs";
|
|
3
|
+
import { DEFAULT_API_VERSION as E } from "../../types/api-version.mjs";
|
|
4
|
+
import { getBuilderSearchParamsFromWindow as I } from "../get-builder-search-params/index.mjs";
|
|
5
|
+
const y = (r) => typeof r == "number" && !isNaN(r) && r >= 0, M = (r) => {
|
|
6
6
|
const {
|
|
7
7
|
limit: c = 30,
|
|
8
8
|
userAttributes: m,
|
|
@@ -11,42 +11,43 @@ const y = (s) => typeof s == "number" && !isNaN(s) && s >= 0, J = (s) => {
|
|
|
11
11
|
apiKey: l,
|
|
12
12
|
enrich: h,
|
|
13
13
|
locale: d,
|
|
14
|
-
apiVersion: a =
|
|
14
|
+
apiVersion: a = E,
|
|
15
15
|
fields: u,
|
|
16
16
|
omit: N,
|
|
17
17
|
offset: i,
|
|
18
18
|
cacheSeconds: n,
|
|
19
19
|
staleCacheSeconds: o,
|
|
20
20
|
sort: P,
|
|
21
|
-
includeUnpublished:
|
|
22
|
-
|
|
21
|
+
includeUnpublished: p,
|
|
22
|
+
apiHost: v
|
|
23
|
+
} = r;
|
|
23
24
|
if (!l)
|
|
24
25
|
throw new Error("Missing API key");
|
|
25
26
|
if (!["v3"].includes(a))
|
|
26
27
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${a}'`);
|
|
27
|
-
const
|
|
28
|
-
if (e.searchParams.set("apiKey", l), e.searchParams.set("limit", String(c)), e.searchParams.set("noTraverse", String(
|
|
29
|
-
const
|
|
28
|
+
const U = c !== 1, w = v || "https://cdn.builder.io", e = new URL(`${w}/api/${a}/content/${b}`);
|
|
29
|
+
if (e.searchParams.set("apiKey", l), e.searchParams.set("limit", String(c)), e.searchParams.set("noTraverse", String(U)), e.searchParams.set("includeRefs", String(!0)), d && e.searchParams.set("locale", d), h && e.searchParams.set("enrich", String(h)), e.searchParams.set("omit", N || "meta.componentsUsed"), u && e.searchParams.set("fields", u), Number.isFinite(i) && i > -1 && e.searchParams.set("offset", String(Math.floor(i))), typeof p == "boolean" && e.searchParams.set("includeUnpublished", String(p)), n && y(n) && e.searchParams.set("cacheSeconds", String(n)), o && y(o) && e.searchParams.set("staleCacheSeconds", String(o)), P) {
|
|
30
|
+
const s = g({
|
|
30
31
|
sort: P
|
|
31
32
|
});
|
|
32
|
-
for (const t in
|
|
33
|
-
e.searchParams.set(t, JSON.stringify(
|
|
33
|
+
for (const t in s)
|
|
34
|
+
e.searchParams.set(t, JSON.stringify(s[t]));
|
|
34
35
|
}
|
|
35
|
-
const
|
|
36
|
-
...
|
|
37
|
-
...
|
|
38
|
-
},
|
|
39
|
-
for (const
|
|
40
|
-
e.searchParams.set(
|
|
36
|
+
const A = {
|
|
37
|
+
...I(),
|
|
38
|
+
...k(r.options || {})
|
|
39
|
+
}, S = g(A);
|
|
40
|
+
for (const s in S)
|
|
41
|
+
e.searchParams.set(s, String(S[s]));
|
|
41
42
|
if (m && e.searchParams.set("userAttributes", JSON.stringify(m)), f) {
|
|
42
|
-
const
|
|
43
|
+
const s = O({
|
|
43
44
|
query: f
|
|
44
45
|
});
|
|
45
|
-
for (const t in
|
|
46
|
-
e.searchParams.set(t, JSON.stringify(
|
|
46
|
+
for (const t in s)
|
|
47
|
+
e.searchParams.set(t, JSON.stringify(s[t]));
|
|
47
48
|
}
|
|
48
49
|
return e;
|
|
49
50
|
};
|
|
50
51
|
export {
|
|
51
|
-
|
|
52
|
+
M as generateContentUrl
|
|
52
53
|
};
|
|
@@ -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"),g=require("../is-browser.cjs"),l=require("../is-editing.cjs"),y=require("./helpers.cjs"),I=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}},k=async({type:e,canTrack:t,apiKey:r,metadata:
|
|
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"),g=require("../is-browser.cjs"),l=require("../is-editing.cjs"),y=require("./helpers.cjs"),I=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}},k=async({type:e,canTrack:t,apiKey:r,metadata:i,...o})=>({type:e,data:{...o,metadata:{url:location.href,...i},...await I({canTrack:t}),userAttributes:y.getUserAttributes(),ownerId:r}});async function s({apiHost:e,...t}){if(!t.apiKey){a.logger.error("Missing API key for track call. Please provide your API key.");return}return!t.canTrack||l.isEditing()||!(g.isBrowser()||n.TARGET==="reactNative")?void 0:fetch(`${e||"https://cdn.builder.io"}/api/v1/track`,{method:"POST",body:JSON.stringify({events:[await k(t)]}),headers:{"content-type":"application/json",...c.getSdkHeaders()},mode:"cors"}).catch(i=>{console.error("Failed to track: ",i)})}const f=e=>s({...e,canTrack:!0});exports._track=s;exports.track=f;
|
|
@@ -23,7 +23,7 @@ const u = async ({
|
|
|
23
23
|
sessionId: r,
|
|
24
24
|
visitorId: e
|
|
25
25
|
};
|
|
26
|
-
},
|
|
26
|
+
}, l = async ({
|
|
27
27
|
type: t,
|
|
28
28
|
canTrack: r,
|
|
29
29
|
apiKey: e,
|
|
@@ -44,31 +44,33 @@ const u = async ({
|
|
|
44
44
|
ownerId: e
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
async function
|
|
48
|
-
|
|
47
|
+
async function y({
|
|
48
|
+
apiHost: t,
|
|
49
|
+
...r
|
|
50
|
+
}) {
|
|
51
|
+
if (!r.apiKey) {
|
|
49
52
|
s.error("Missing API key for track call. Please provide your API key.");
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
55
|
+
return !r.canTrack || f() || !(m() || a === "reactNative") ? void 0 : fetch(`${t || "https://cdn.builder.io"}/api/v1/track`, {
|
|
56
|
+
method: "POST",
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
events: [await l(r)]
|
|
59
|
+
}),
|
|
60
|
+
headers: {
|
|
61
|
+
"content-type": "application/json",
|
|
62
|
+
...n()
|
|
63
|
+
},
|
|
64
|
+
mode: "cors"
|
|
65
|
+
}).catch((o) => {
|
|
66
|
+
console.error("Failed to track: ", o);
|
|
67
|
+
});
|
|
66
68
|
}
|
|
67
|
-
const E = (t) =>
|
|
69
|
+
const E = (t) => y({
|
|
68
70
|
...t,
|
|
69
71
|
canTrack: !0
|
|
70
72
|
});
|
|
71
73
|
export {
|
|
72
|
-
|
|
74
|
+
y as _track,
|
|
73
75
|
E as track
|
|
74
76
|
};
|
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.19",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/nextjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "
|
|
2
|
+
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "linkComponent"> & {
|
|
3
3
|
builderContextSignal: BuilderContextInterface;
|
|
4
4
|
setBuilderContextSignal?: (signal: any) => any;
|
|
5
5
|
children?: any;
|
|
@@ -26,6 +26,10 @@ export interface ContentVariantsPrps extends ExtraFrameworkProps {
|
|
|
26
26
|
* Your API Key: needed to enable visual editing, and to dynamically fetch symbols (required).
|
|
27
27
|
*/
|
|
28
28
|
apiKey: string;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the host of Builder API calls. (Defaults to global `https://cdn.builder.io`)
|
|
31
|
+
*/
|
|
32
|
+
apiHost?: string;
|
|
29
33
|
apiVersion?: ApiVersion;
|
|
30
34
|
/**
|
|
31
35
|
* An array of custom components to register (optional).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.16.
|
|
1
|
+
export declare const SDK_VERSION = "0.16.19";
|
|
@@ -136,4 +136,8 @@ export interface GetContentOptions {
|
|
|
136
136
|
* Optional fetch options to be passed as the second argument to the `fetch` function.
|
|
137
137
|
*/
|
|
138
138
|
fetchOptions?: object;
|
|
139
|
+
/**
|
|
140
|
+
* Sets the host of Builder API calls. (Defaults to global `https://cdn.builder.io`)
|
|
141
|
+
*/
|
|
142
|
+
apiHost?: string;
|
|
139
143
|
}
|
|
@@ -46,6 +46,8 @@ type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | '
|
|
|
46
46
|
[index: string]: any;
|
|
47
47
|
};
|
|
48
48
|
export type EventProps = EventProperties & CanTrack;
|
|
49
|
-
export declare function _track(eventProps: EventProps
|
|
49
|
+
export declare function _track({ apiHost, ...eventProps }: EventProps & {
|
|
50
|
+
apiHost?: string;
|
|
51
|
+
}): Promise<void | Response>;
|
|
50
52
|
export declare const track: (args: EventProperties) => Promise<void | Response>;
|
|
51
53
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "
|
|
2
|
+
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "linkComponent"> & {
|
|
3
3
|
builderContextSignal: BuilderContextInterface;
|
|
4
4
|
setBuilderContextSignal?: (signal: any) => any;
|
|
5
5
|
children?: any;
|
|
@@ -26,6 +26,10 @@ export interface ContentVariantsPrps extends ExtraFrameworkProps {
|
|
|
26
26
|
* Your API Key: needed to enable visual editing, and to dynamically fetch symbols (required).
|
|
27
27
|
*/
|
|
28
28
|
apiKey: string;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the host of Builder API calls. (Defaults to global `https://cdn.builder.io`)
|
|
31
|
+
*/
|
|
32
|
+
apiHost?: string;
|
|
29
33
|
apiVersion?: ApiVersion;
|
|
30
34
|
/**
|
|
31
35
|
* An array of custom components to register (optional).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.16.
|
|
1
|
+
export declare const SDK_VERSION = "0.16.19";
|
|
@@ -136,4 +136,8 @@ export interface GetContentOptions {
|
|
|
136
136
|
* Optional fetch options to be passed as the second argument to the `fetch` function.
|
|
137
137
|
*/
|
|
138
138
|
fetchOptions?: object;
|
|
139
|
+
/**
|
|
140
|
+
* Sets the host of Builder API calls. (Defaults to global `https://cdn.builder.io`)
|
|
141
|
+
*/
|
|
142
|
+
apiHost?: string;
|
|
139
143
|
}
|
|
@@ -46,6 +46,8 @@ type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | '
|
|
|
46
46
|
[index: string]: any;
|
|
47
47
|
};
|
|
48
48
|
export type EventProps = EventProperties & CanTrack;
|
|
49
|
-
export declare function _track(eventProps: EventProps
|
|
49
|
+
export declare function _track({ apiHost, ...eventProps }: EventProps & {
|
|
50
|
+
apiHost?: string;
|
|
51
|
+
}): Promise<void | Response>;
|
|
50
52
|
export declare const track: (args: EventProperties) => Promise<void | Response>;
|
|
51
53
|
export {};
|