@builder.io/sdk-qwik 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.qwik.cjs +3 -1
- package/lib/browser/components/content/components/enable-editor.qwik.mjs +3 -1
- package/lib/browser/components/content/content.qwik.cjs +2 -0
- package/lib/browser/components/content/content.qwik.mjs +2 -0
- package/lib/browser/components/content-variants/content-variants.qwik.cjs +2 -0
- package/lib/browser/components/content-variants/content-variants.qwik.mjs +2 -0
- package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
- package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
- package/lib/browser/functions/get-content/generate-content-url.qwik.cjs +3 -2
- package/lib/browser/functions/get-content/generate-content-url.qwik.mjs +3 -2
- package/lib/browser/functions/track/index.qwik.cjs +3 -2
- package/lib/browser/functions/track/index.qwik.mjs +3 -2
- package/lib/edge/components/content/components/enable-editor.qwik.cjs +3 -1
- package/lib/edge/components/content/components/enable-editor.qwik.mjs +3 -1
- package/lib/edge/components/content/content.qwik.cjs +2 -0
- package/lib/edge/components/content/content.qwik.mjs +2 -0
- package/lib/edge/components/content-variants/content-variants.qwik.cjs +2 -0
- package/lib/edge/components/content-variants/content-variants.qwik.mjs +2 -0
- package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
- package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
- package/lib/edge/functions/get-content/generate-content-url.qwik.cjs +3 -2
- package/lib/edge/functions/get-content/generate-content-url.qwik.mjs +3 -2
- package/lib/edge/functions/track/index.qwik.cjs +3 -2
- package/lib/edge/functions/track/index.qwik.mjs +3 -2
- package/lib/node/components/content/components/enable-editor.qwik.cjs +3 -1
- package/lib/node/components/content/components/enable-editor.qwik.mjs +3 -1
- package/lib/node/components/content/content.qwik.cjs +2 -0
- package/lib/node/components/content/content.qwik.mjs +2 -0
- package/lib/node/components/content-variants/content-variants.qwik.cjs +2 -0
- package/lib/node/components/content-variants/content-variants.qwik.mjs +2 -0
- package/lib/node/constants/sdk-version.qwik.cjs +1 -1
- package/lib/node/constants/sdk-version.qwik.mjs +1 -1
- package/lib/node/functions/get-content/generate-content-url.qwik.cjs +3 -2
- package/lib/node/functions/get-content/generate-content-url.qwik.mjs +3 -2
- package/lib/node/functions/track/index.qwik.cjs +3 -2
- package/lib/node/functions/track/index.qwik.mjs +3 -2
- package/package.json +1 -1
- package/types/src/components/content/components/enable-editor.d.ts +1 -1
- package/types/src/components/content-variants/content-variants.types.d.ts +4 -0
- package/types/src/constants/sdk-version.d.ts +1 -1
- package/types/src/functions/get-content/types.d.ts +4 -0
- package/types/src/functions/track/index.d.ts +3 -1
|
@@ -80,6 +80,7 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
|
|
|
80
80
|
const variationId = (_a = props.builderContextSignal.content) == null ? void 0 : _a.testVariationId;
|
|
81
81
|
const contentId = (_b = props.builderContextSignal.content) == null ? void 0 : _b.id;
|
|
82
82
|
index$1._track({
|
|
83
|
+
apiHost: props.apiHost,
|
|
83
84
|
type: "click",
|
|
84
85
|
canTrack: canTrack.getDefaultCanTrack(props.canTrack),
|
|
85
86
|
contentId,
|
|
@@ -193,7 +194,7 @@ const EnableEditor = qwik.component$((props) => {
|
|
|
193
194
|
qwik.useOn("qvisible", qwik.$((event, element) => {
|
|
194
195
|
var _a2, _b2, _c2, _d2;
|
|
195
196
|
if (isBrowser.isBrowser()) {
|
|
196
|
-
if (isEditing.isEditing()) {
|
|
197
|
+
if (isEditing.isEditing() && !props.isNestedRender) {
|
|
197
198
|
if (element) {
|
|
198
199
|
element.dispatchEvent(new CustomEvent("initeditingbldr"));
|
|
199
200
|
}
|
|
@@ -204,6 +205,7 @@ const EnableEditor = qwik.component$((props) => {
|
|
|
204
205
|
const contentId = (_c2 = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c2.value;
|
|
205
206
|
const apiKeyProp = (_d2 = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d2.value;
|
|
206
207
|
index$1._track({
|
|
208
|
+
apiHost: props.apiHost,
|
|
207
209
|
type: "impression",
|
|
208
210
|
canTrack: true,
|
|
209
211
|
contentId,
|
|
@@ -78,6 +78,7 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
|
|
|
78
78
|
const variationId = (_a = props.builderContextSignal.content) == null ? void 0 : _a.testVariationId;
|
|
79
79
|
const contentId = (_b = props.builderContextSignal.content) == null ? void 0 : _b.id;
|
|
80
80
|
_track({
|
|
81
|
+
apiHost: props.apiHost,
|
|
81
82
|
type: "click",
|
|
82
83
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
83
84
|
contentId,
|
|
@@ -191,7 +192,7 @@ const EnableEditor = component$((props) => {
|
|
|
191
192
|
useOn("qvisible", $((event, element) => {
|
|
192
193
|
var _a2, _b2, _c2, _d2;
|
|
193
194
|
if (isBrowser()) {
|
|
194
|
-
if (isEditing()) {
|
|
195
|
+
if (isEditing() && !props.isNestedRender) {
|
|
195
196
|
if (element) {
|
|
196
197
|
element.dispatchEvent(new CustomEvent("initeditingbldr"));
|
|
197
198
|
}
|
|
@@ -202,6 +203,7 @@ const EnableEditor = component$((props) => {
|
|
|
202
203
|
const contentId = (_c2 = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c2.value;
|
|
203
204
|
const apiKeyProp = (_d2 = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d2.value;
|
|
204
205
|
_track({
|
|
206
|
+
apiHost: props.apiHost,
|
|
205
207
|
type: "impression",
|
|
206
208
|
canTrack: true,
|
|
207
209
|
contentId,
|
|
@@ -99,6 +99,7 @@ const ContentComponent = qwik.component$((props) => {
|
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
return /* @__PURE__ */ jsxRuntime.jsxs(enableEditor.EnableEditor, {
|
|
102
|
+
apiHost: props.apiHost,
|
|
102
103
|
nonce: props.nonce,
|
|
103
104
|
content: props.content,
|
|
104
105
|
data: props.data,
|
|
@@ -113,6 +114,7 @@ const ContentComponent = qwik.component$((props) => {
|
|
|
113
114
|
contentWrapper: props.contentWrapper,
|
|
114
115
|
contentWrapperProps: props.contentWrapperProps,
|
|
115
116
|
trustedHosts: props.trustedHosts,
|
|
117
|
+
isNestedRender: props.isNestedRender,
|
|
116
118
|
children: [
|
|
117
119
|
props.isSsrAbTest ? /* @__PURE__ */ jsxRuntime.jsx(inlinedScript.InlinedScript, {
|
|
118
120
|
id: "builderio-variant-visibility",
|
|
@@ -97,6 +97,7 @@ const ContentComponent = component$((props) => {
|
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
return /* @__PURE__ */ jsxs(EnableEditor, {
|
|
100
|
+
apiHost: props.apiHost,
|
|
100
101
|
nonce: props.nonce,
|
|
101
102
|
content: props.content,
|
|
102
103
|
data: props.data,
|
|
@@ -111,6 +112,7 @@ const ContentComponent = component$((props) => {
|
|
|
111
112
|
contentWrapper: props.contentWrapper,
|
|
112
113
|
contentWrapperProps: props.contentWrapperProps,
|
|
113
114
|
trustedHosts: props.trustedHosts,
|
|
115
|
+
isNestedRender: props.isNestedRender,
|
|
114
116
|
children: [
|
|
115
117
|
props.isSsrAbTest ? /* @__PURE__ */ jsx(InlinedScript, {
|
|
116
118
|
id: "builderio-variant-visibility",
|
|
@@ -57,6 +57,7 @@ const ContentVariants = qwik.component$((props) => {
|
|
|
57
57
|
}),
|
|
58
58
|
(helpers.getVariants(props.content) || []).map((variant) => {
|
|
59
59
|
return /* @__PURE__ */ jsxRuntime.jsx(content.ContentComponent, {
|
|
60
|
+
apiHost: props.apiHost,
|
|
60
61
|
isNestedRender: props.isNestedRender,
|
|
61
62
|
nonce: props.nonce,
|
|
62
63
|
content: variant,
|
|
@@ -82,6 +83,7 @@ const ContentVariants = qwik.component$((props) => {
|
|
|
82
83
|
]
|
|
83
84
|
}) : null,
|
|
84
85
|
/* @__PURE__ */ jsxRuntime.jsx(content.ContentComponent, {
|
|
86
|
+
apiHost: props.apiHost,
|
|
85
87
|
nonce: props.nonce,
|
|
86
88
|
isNestedRender: props.isNestedRender,
|
|
87
89
|
content: defaultContent.value,
|
|
@@ -55,6 +55,7 @@ const ContentVariants = component$((props) => {
|
|
|
55
55
|
}),
|
|
56
56
|
(getVariants(props.content) || []).map((variant) => {
|
|
57
57
|
return /* @__PURE__ */ jsx(ContentComponent, {
|
|
58
|
+
apiHost: props.apiHost,
|
|
58
59
|
isNestedRender: props.isNestedRender,
|
|
59
60
|
nonce: props.nonce,
|
|
60
61
|
content: variant,
|
|
@@ -80,6 +81,7 @@ const ContentVariants = component$((props) => {
|
|
|
80
81
|
]
|
|
81
82
|
}) : null,
|
|
82
83
|
/* @__PURE__ */ jsx(ContentComponent, {
|
|
84
|
+
apiHost: props.apiHost,
|
|
83
85
|
nonce: props.nonce,
|
|
84
86
|
isNestedRender: props.isNestedRender,
|
|
85
87
|
content: defaultContent.value,
|
|
@@ -6,7 +6,7 @@ const apiVersion = require("../../types/api-version.qwik.cjs");
|
|
|
6
6
|
const index = require("../get-builder-search-params/index.qwik.cjs");
|
|
7
7
|
const isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
8
8
|
const generateContentUrl = (options) => {
|
|
9
|
-
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion: apiVersion$1 = apiVersion.DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
9
|
+
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion: apiVersion$1 = apiVersion.DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished, apiHost } = options;
|
|
10
10
|
if (!apiKey) {
|
|
11
11
|
throw new Error("Missing API key");
|
|
12
12
|
}
|
|
@@ -16,7 +16,8 @@ const generateContentUrl = (options) => {
|
|
|
16
16
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion$1}'`);
|
|
17
17
|
}
|
|
18
18
|
const noTraverse = limit !== 1;
|
|
19
|
-
const
|
|
19
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
20
|
+
const url = new URL(`${baseUrl}/api/${apiVersion$1}/content/${model}`);
|
|
20
21
|
url.searchParams.set("apiKey", apiKey);
|
|
21
22
|
url.searchParams.set("limit", String(limit));
|
|
22
23
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -4,7 +4,7 @@ import { DEFAULT_API_VERSION } from "../../types/api-version.qwik.mjs";
|
|
|
4
4
|
import { getBuilderSearchParamsFromWindow } from "../get-builder-search-params/index.qwik.mjs";
|
|
5
5
|
const isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
6
6
|
const generateContentUrl = (options) => {
|
|
7
|
-
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
7
|
+
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished, apiHost } = options;
|
|
8
8
|
if (!apiKey) {
|
|
9
9
|
throw new Error("Missing API key");
|
|
10
10
|
}
|
|
@@ -14,7 +14,8 @@ const generateContentUrl = (options) => {
|
|
|
14
14
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
15
15
|
}
|
|
16
16
|
const noTraverse = limit !== 1;
|
|
17
|
-
const
|
|
17
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
18
|
+
const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
|
|
18
19
|
url.searchParams.set("apiKey", apiKey);
|
|
19
20
|
url.searchParams.set("limit", String(limit));
|
|
20
21
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -41,7 +41,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
|
|
|
41
41
|
ownerId: apiKey
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
-
async function _track(eventProps) {
|
|
44
|
+
async function _track({ apiHost, ...eventProps }) {
|
|
45
45
|
if (!eventProps.apiKey) {
|
|
46
46
|
logger.logger.error("Missing API key for track call. Please provide your API key.");
|
|
47
47
|
return;
|
|
@@ -55,7 +55,8 @@ async function _track(eventProps) {
|
|
|
55
55
|
if (!(isBrowser.isBrowser() || target.TARGET === "reactNative")) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
59
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
59
60
|
method: "POST",
|
|
60
61
|
body: JSON.stringify({
|
|
61
62
|
events: [
|
|
@@ -39,7 +39,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
|
|
|
39
39
|
ownerId: apiKey
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
async function _track(eventProps) {
|
|
42
|
+
async function _track({ apiHost, ...eventProps }) {
|
|
43
43
|
if (!eventProps.apiKey) {
|
|
44
44
|
logger.error("Missing API key for track call. Please provide your API key.");
|
|
45
45
|
return;
|
|
@@ -53,7 +53,8 @@ async function _track(eventProps) {
|
|
|
53
53
|
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
57
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
57
58
|
method: "POST",
|
|
58
59
|
body: JSON.stringify({
|
|
59
60
|
events: [
|
|
@@ -80,6 +80,7 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
|
|
|
80
80
|
const variationId = (_a = props.builderContextSignal.content) == null ? void 0 : _a.testVariationId;
|
|
81
81
|
const contentId = (_b = props.builderContextSignal.content) == null ? void 0 : _b.id;
|
|
82
82
|
index$1._track({
|
|
83
|
+
apiHost: props.apiHost,
|
|
83
84
|
type: "click",
|
|
84
85
|
canTrack: canTrack.getDefaultCanTrack(props.canTrack),
|
|
85
86
|
contentId,
|
|
@@ -193,7 +194,7 @@ const EnableEditor = qwik.component$((props) => {
|
|
|
193
194
|
qwik.useOn("qvisible", qwik.$((event, element) => {
|
|
194
195
|
var _a2, _b2, _c2, _d2;
|
|
195
196
|
if (isBrowser.isBrowser()) {
|
|
196
|
-
if (isEditing.isEditing()) {
|
|
197
|
+
if (isEditing.isEditing() && !props.isNestedRender) {
|
|
197
198
|
if (element) {
|
|
198
199
|
element.dispatchEvent(new CustomEvent("initeditingbldr"));
|
|
199
200
|
}
|
|
@@ -204,6 +205,7 @@ const EnableEditor = qwik.component$((props) => {
|
|
|
204
205
|
const contentId = (_c2 = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c2.value;
|
|
205
206
|
const apiKeyProp = (_d2 = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d2.value;
|
|
206
207
|
index$1._track({
|
|
208
|
+
apiHost: props.apiHost,
|
|
207
209
|
type: "impression",
|
|
208
210
|
canTrack: true,
|
|
209
211
|
contentId,
|
|
@@ -78,6 +78,7 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
|
|
|
78
78
|
const variationId = (_a = props.builderContextSignal.content) == null ? void 0 : _a.testVariationId;
|
|
79
79
|
const contentId = (_b = props.builderContextSignal.content) == null ? void 0 : _b.id;
|
|
80
80
|
_track({
|
|
81
|
+
apiHost: props.apiHost,
|
|
81
82
|
type: "click",
|
|
82
83
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
83
84
|
contentId,
|
|
@@ -191,7 +192,7 @@ const EnableEditor = component$((props) => {
|
|
|
191
192
|
useOn("qvisible", $((event, element) => {
|
|
192
193
|
var _a2, _b2, _c2, _d2;
|
|
193
194
|
if (isBrowser()) {
|
|
194
|
-
if (isEditing()) {
|
|
195
|
+
if (isEditing() && !props.isNestedRender) {
|
|
195
196
|
if (element) {
|
|
196
197
|
element.dispatchEvent(new CustomEvent("initeditingbldr"));
|
|
197
198
|
}
|
|
@@ -202,6 +203,7 @@ const EnableEditor = component$((props) => {
|
|
|
202
203
|
const contentId = (_c2 = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c2.value;
|
|
203
204
|
const apiKeyProp = (_d2 = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d2.value;
|
|
204
205
|
_track({
|
|
206
|
+
apiHost: props.apiHost,
|
|
205
207
|
type: "impression",
|
|
206
208
|
canTrack: true,
|
|
207
209
|
contentId,
|
|
@@ -99,6 +99,7 @@ const ContentComponent = qwik.component$((props) => {
|
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
return /* @__PURE__ */ jsxRuntime.jsxs(enableEditor.EnableEditor, {
|
|
102
|
+
apiHost: props.apiHost,
|
|
102
103
|
nonce: props.nonce,
|
|
103
104
|
content: props.content,
|
|
104
105
|
data: props.data,
|
|
@@ -113,6 +114,7 @@ const ContentComponent = qwik.component$((props) => {
|
|
|
113
114
|
contentWrapper: props.contentWrapper,
|
|
114
115
|
contentWrapperProps: props.contentWrapperProps,
|
|
115
116
|
trustedHosts: props.trustedHosts,
|
|
117
|
+
isNestedRender: props.isNestedRender,
|
|
116
118
|
children: [
|
|
117
119
|
props.isSsrAbTest ? /* @__PURE__ */ jsxRuntime.jsx(inlinedScript.InlinedScript, {
|
|
118
120
|
id: "builderio-variant-visibility",
|
|
@@ -97,6 +97,7 @@ const ContentComponent = component$((props) => {
|
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
return /* @__PURE__ */ jsxs(EnableEditor, {
|
|
100
|
+
apiHost: props.apiHost,
|
|
100
101
|
nonce: props.nonce,
|
|
101
102
|
content: props.content,
|
|
102
103
|
data: props.data,
|
|
@@ -111,6 +112,7 @@ const ContentComponent = component$((props) => {
|
|
|
111
112
|
contentWrapper: props.contentWrapper,
|
|
112
113
|
contentWrapperProps: props.contentWrapperProps,
|
|
113
114
|
trustedHosts: props.trustedHosts,
|
|
115
|
+
isNestedRender: props.isNestedRender,
|
|
114
116
|
children: [
|
|
115
117
|
props.isSsrAbTest ? /* @__PURE__ */ jsx(InlinedScript, {
|
|
116
118
|
id: "builderio-variant-visibility",
|
|
@@ -57,6 +57,7 @@ const ContentVariants = qwik.component$((props) => {
|
|
|
57
57
|
}),
|
|
58
58
|
(helpers.getVariants(props.content) || []).map((variant) => {
|
|
59
59
|
return /* @__PURE__ */ jsxRuntime.jsx(content.ContentComponent, {
|
|
60
|
+
apiHost: props.apiHost,
|
|
60
61
|
isNestedRender: props.isNestedRender,
|
|
61
62
|
nonce: props.nonce,
|
|
62
63
|
content: variant,
|
|
@@ -82,6 +83,7 @@ const ContentVariants = qwik.component$((props) => {
|
|
|
82
83
|
]
|
|
83
84
|
}) : null,
|
|
84
85
|
/* @__PURE__ */ jsxRuntime.jsx(content.ContentComponent, {
|
|
86
|
+
apiHost: props.apiHost,
|
|
85
87
|
nonce: props.nonce,
|
|
86
88
|
isNestedRender: props.isNestedRender,
|
|
87
89
|
content: defaultContent.value,
|
|
@@ -55,6 +55,7 @@ const ContentVariants = component$((props) => {
|
|
|
55
55
|
}),
|
|
56
56
|
(getVariants(props.content) || []).map((variant) => {
|
|
57
57
|
return /* @__PURE__ */ jsx(ContentComponent, {
|
|
58
|
+
apiHost: props.apiHost,
|
|
58
59
|
isNestedRender: props.isNestedRender,
|
|
59
60
|
nonce: props.nonce,
|
|
60
61
|
content: variant,
|
|
@@ -80,6 +81,7 @@ const ContentVariants = component$((props) => {
|
|
|
80
81
|
]
|
|
81
82
|
}) : null,
|
|
82
83
|
/* @__PURE__ */ jsx(ContentComponent, {
|
|
84
|
+
apiHost: props.apiHost,
|
|
83
85
|
nonce: props.nonce,
|
|
84
86
|
isNestedRender: props.isNestedRender,
|
|
85
87
|
content: defaultContent.value,
|
|
@@ -6,7 +6,7 @@ const apiVersion = require("../../types/api-version.qwik.cjs");
|
|
|
6
6
|
const index = require("../get-builder-search-params/index.qwik.cjs");
|
|
7
7
|
const isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
8
8
|
const generateContentUrl = (options) => {
|
|
9
|
-
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion: apiVersion$1 = apiVersion.DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
9
|
+
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion: apiVersion$1 = apiVersion.DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished, apiHost } = options;
|
|
10
10
|
if (!apiKey) {
|
|
11
11
|
throw new Error("Missing API key");
|
|
12
12
|
}
|
|
@@ -16,7 +16,8 @@ const generateContentUrl = (options) => {
|
|
|
16
16
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion$1}'`);
|
|
17
17
|
}
|
|
18
18
|
const noTraverse = limit !== 1;
|
|
19
|
-
const
|
|
19
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
20
|
+
const url = new URL(`${baseUrl}/api/${apiVersion$1}/content/${model}`);
|
|
20
21
|
url.searchParams.set("apiKey", apiKey);
|
|
21
22
|
url.searchParams.set("limit", String(limit));
|
|
22
23
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -4,7 +4,7 @@ import { DEFAULT_API_VERSION } from "../../types/api-version.qwik.mjs";
|
|
|
4
4
|
import { getBuilderSearchParamsFromWindow } from "../get-builder-search-params/index.qwik.mjs";
|
|
5
5
|
const isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
6
6
|
const generateContentUrl = (options) => {
|
|
7
|
-
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
7
|
+
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished, apiHost } = options;
|
|
8
8
|
if (!apiKey) {
|
|
9
9
|
throw new Error("Missing API key");
|
|
10
10
|
}
|
|
@@ -14,7 +14,8 @@ const generateContentUrl = (options) => {
|
|
|
14
14
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
15
15
|
}
|
|
16
16
|
const noTraverse = limit !== 1;
|
|
17
|
-
const
|
|
17
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
18
|
+
const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
|
|
18
19
|
url.searchParams.set("apiKey", apiKey);
|
|
19
20
|
url.searchParams.set("limit", String(limit));
|
|
20
21
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -41,7 +41,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
|
|
|
41
41
|
ownerId: apiKey
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
-
async function _track(eventProps) {
|
|
44
|
+
async function _track({ apiHost, ...eventProps }) {
|
|
45
45
|
if (!eventProps.apiKey) {
|
|
46
46
|
logger.logger.error("Missing API key for track call. Please provide your API key.");
|
|
47
47
|
return;
|
|
@@ -55,7 +55,8 @@ async function _track(eventProps) {
|
|
|
55
55
|
if (!(isBrowser.isBrowser() || target.TARGET === "reactNative")) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
59
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
59
60
|
method: "POST",
|
|
60
61
|
body: JSON.stringify({
|
|
61
62
|
events: [
|
|
@@ -39,7 +39,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
|
|
|
39
39
|
ownerId: apiKey
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
async function _track(eventProps) {
|
|
42
|
+
async function _track({ apiHost, ...eventProps }) {
|
|
43
43
|
if (!eventProps.apiKey) {
|
|
44
44
|
logger.error("Missing API key for track call. Please provide your API key.");
|
|
45
45
|
return;
|
|
@@ -53,7 +53,8 @@ async function _track(eventProps) {
|
|
|
53
53
|
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
57
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
57
58
|
method: "POST",
|
|
58
59
|
body: JSON.stringify({
|
|
59
60
|
events: [
|
|
@@ -80,6 +80,7 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
|
|
|
80
80
|
const variationId = (_a = props.builderContextSignal.content) == null ? void 0 : _a.testVariationId;
|
|
81
81
|
const contentId = (_b = props.builderContextSignal.content) == null ? void 0 : _b.id;
|
|
82
82
|
index$1._track({
|
|
83
|
+
apiHost: props.apiHost,
|
|
83
84
|
type: "click",
|
|
84
85
|
canTrack: canTrack.getDefaultCanTrack(props.canTrack),
|
|
85
86
|
contentId,
|
|
@@ -193,7 +194,7 @@ const EnableEditor = qwik.component$((props) => {
|
|
|
193
194
|
qwik.useOn("qvisible", qwik.$((event, element) => {
|
|
194
195
|
var _a2, _b2, _c2, _d2;
|
|
195
196
|
if (isBrowser.isBrowser()) {
|
|
196
|
-
if (isEditing.isEditing()) {
|
|
197
|
+
if (isEditing.isEditing() && !props.isNestedRender) {
|
|
197
198
|
if (element) {
|
|
198
199
|
element.dispatchEvent(new CustomEvent("initeditingbldr"));
|
|
199
200
|
}
|
|
@@ -204,6 +205,7 @@ const EnableEditor = qwik.component$((props) => {
|
|
|
204
205
|
const contentId = (_c2 = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c2.value;
|
|
205
206
|
const apiKeyProp = (_d2 = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d2.value;
|
|
206
207
|
index$1._track({
|
|
208
|
+
apiHost: props.apiHost,
|
|
207
209
|
type: "impression",
|
|
208
210
|
canTrack: true,
|
|
209
211
|
contentId,
|
|
@@ -78,6 +78,7 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
|
|
|
78
78
|
const variationId = (_a = props.builderContextSignal.content) == null ? void 0 : _a.testVariationId;
|
|
79
79
|
const contentId = (_b = props.builderContextSignal.content) == null ? void 0 : _b.id;
|
|
80
80
|
_track({
|
|
81
|
+
apiHost: props.apiHost,
|
|
81
82
|
type: "click",
|
|
82
83
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
83
84
|
contentId,
|
|
@@ -191,7 +192,7 @@ const EnableEditor = component$((props) => {
|
|
|
191
192
|
useOn("qvisible", $((event, element) => {
|
|
192
193
|
var _a2, _b2, _c2, _d2;
|
|
193
194
|
if (isBrowser()) {
|
|
194
|
-
if (isEditing()) {
|
|
195
|
+
if (isEditing() && !props.isNestedRender) {
|
|
195
196
|
if (element) {
|
|
196
197
|
element.dispatchEvent(new CustomEvent("initeditingbldr"));
|
|
197
198
|
}
|
|
@@ -202,6 +203,7 @@ const EnableEditor = component$((props) => {
|
|
|
202
203
|
const contentId = (_c2 = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c2.value;
|
|
203
204
|
const apiKeyProp = (_d2 = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d2.value;
|
|
204
205
|
_track({
|
|
206
|
+
apiHost: props.apiHost,
|
|
205
207
|
type: "impression",
|
|
206
208
|
canTrack: true,
|
|
207
209
|
contentId,
|
|
@@ -99,6 +99,7 @@ const ContentComponent = qwik.component$((props) => {
|
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
return /* @__PURE__ */ jsxRuntime.jsxs(enableEditor.EnableEditor, {
|
|
102
|
+
apiHost: props.apiHost,
|
|
102
103
|
nonce: props.nonce,
|
|
103
104
|
content: props.content,
|
|
104
105
|
data: props.data,
|
|
@@ -113,6 +114,7 @@ const ContentComponent = qwik.component$((props) => {
|
|
|
113
114
|
contentWrapper: props.contentWrapper,
|
|
114
115
|
contentWrapperProps: props.contentWrapperProps,
|
|
115
116
|
trustedHosts: props.trustedHosts,
|
|
117
|
+
isNestedRender: props.isNestedRender,
|
|
116
118
|
children: [
|
|
117
119
|
props.isSsrAbTest ? /* @__PURE__ */ jsxRuntime.jsx(inlinedScript.InlinedScript, {
|
|
118
120
|
id: "builderio-variant-visibility",
|
|
@@ -97,6 +97,7 @@ const ContentComponent = component$((props) => {
|
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
return /* @__PURE__ */ jsxs(EnableEditor, {
|
|
100
|
+
apiHost: props.apiHost,
|
|
100
101
|
nonce: props.nonce,
|
|
101
102
|
content: props.content,
|
|
102
103
|
data: props.data,
|
|
@@ -111,6 +112,7 @@ const ContentComponent = component$((props) => {
|
|
|
111
112
|
contentWrapper: props.contentWrapper,
|
|
112
113
|
contentWrapperProps: props.contentWrapperProps,
|
|
113
114
|
trustedHosts: props.trustedHosts,
|
|
115
|
+
isNestedRender: props.isNestedRender,
|
|
114
116
|
children: [
|
|
115
117
|
props.isSsrAbTest ? /* @__PURE__ */ jsx(InlinedScript, {
|
|
116
118
|
id: "builderio-variant-visibility",
|
|
@@ -57,6 +57,7 @@ const ContentVariants = qwik.component$((props) => {
|
|
|
57
57
|
}),
|
|
58
58
|
(helpers.getVariants(props.content) || []).map((variant) => {
|
|
59
59
|
return /* @__PURE__ */ jsxRuntime.jsx(content.ContentComponent, {
|
|
60
|
+
apiHost: props.apiHost,
|
|
60
61
|
isNestedRender: props.isNestedRender,
|
|
61
62
|
nonce: props.nonce,
|
|
62
63
|
content: variant,
|
|
@@ -82,6 +83,7 @@ const ContentVariants = qwik.component$((props) => {
|
|
|
82
83
|
]
|
|
83
84
|
}) : null,
|
|
84
85
|
/* @__PURE__ */ jsxRuntime.jsx(content.ContentComponent, {
|
|
86
|
+
apiHost: props.apiHost,
|
|
85
87
|
nonce: props.nonce,
|
|
86
88
|
isNestedRender: props.isNestedRender,
|
|
87
89
|
content: defaultContent.value,
|
|
@@ -55,6 +55,7 @@ const ContentVariants = component$((props) => {
|
|
|
55
55
|
}),
|
|
56
56
|
(getVariants(props.content) || []).map((variant) => {
|
|
57
57
|
return /* @__PURE__ */ jsx(ContentComponent, {
|
|
58
|
+
apiHost: props.apiHost,
|
|
58
59
|
isNestedRender: props.isNestedRender,
|
|
59
60
|
nonce: props.nonce,
|
|
60
61
|
content: variant,
|
|
@@ -80,6 +81,7 @@ const ContentVariants = component$((props) => {
|
|
|
80
81
|
]
|
|
81
82
|
}) : null,
|
|
82
83
|
/* @__PURE__ */ jsx(ContentComponent, {
|
|
84
|
+
apiHost: props.apiHost,
|
|
83
85
|
nonce: props.nonce,
|
|
84
86
|
isNestedRender: props.isNestedRender,
|
|
85
87
|
content: defaultContent.value,
|
|
@@ -6,7 +6,7 @@ const apiVersion = require("../../types/api-version.qwik.cjs");
|
|
|
6
6
|
const index = require("../get-builder-search-params/index.qwik.cjs");
|
|
7
7
|
const isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
8
8
|
const generateContentUrl = (options) => {
|
|
9
|
-
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion: apiVersion$1 = apiVersion.DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
9
|
+
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion: apiVersion$1 = apiVersion.DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished, apiHost } = options;
|
|
10
10
|
if (!apiKey) {
|
|
11
11
|
throw new Error("Missing API key");
|
|
12
12
|
}
|
|
@@ -16,7 +16,8 @@ const generateContentUrl = (options) => {
|
|
|
16
16
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion$1}'`);
|
|
17
17
|
}
|
|
18
18
|
const noTraverse = limit !== 1;
|
|
19
|
-
const
|
|
19
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
20
|
+
const url = new URL(`${baseUrl}/api/${apiVersion$1}/content/${model}`);
|
|
20
21
|
url.searchParams.set("apiKey", apiKey);
|
|
21
22
|
url.searchParams.set("limit", String(limit));
|
|
22
23
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -4,7 +4,7 @@ import { DEFAULT_API_VERSION } from "../../types/api-version.qwik.mjs";
|
|
|
4
4
|
import { getBuilderSearchParamsFromWindow } from "../get-builder-search-params/index.qwik.mjs";
|
|
5
5
|
const isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
|
|
6
6
|
const generateContentUrl = (options) => {
|
|
7
|
-
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
|
|
7
|
+
const { limit = 30, userAttributes, query, model, apiKey, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished, apiHost } = options;
|
|
8
8
|
if (!apiKey) {
|
|
9
9
|
throw new Error("Missing API key");
|
|
10
10
|
}
|
|
@@ -14,7 +14,8 @@ const generateContentUrl = (options) => {
|
|
|
14
14
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
15
15
|
}
|
|
16
16
|
const noTraverse = limit !== 1;
|
|
17
|
-
const
|
|
17
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
18
|
+
const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
|
|
18
19
|
url.searchParams.set("apiKey", apiKey);
|
|
19
20
|
url.searchParams.set("limit", String(limit));
|
|
20
21
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -41,7 +41,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
|
|
|
41
41
|
ownerId: apiKey
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
-
async function _track(eventProps) {
|
|
44
|
+
async function _track({ apiHost, ...eventProps }) {
|
|
45
45
|
if (!eventProps.apiKey) {
|
|
46
46
|
logger.logger.error("Missing API key for track call. Please provide your API key.");
|
|
47
47
|
return;
|
|
@@ -55,7 +55,8 @@ async function _track(eventProps) {
|
|
|
55
55
|
if (!(isBrowser.isBrowser() || target.TARGET === "reactNative")) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
59
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
59
60
|
method: "POST",
|
|
60
61
|
body: JSON.stringify({
|
|
61
62
|
events: [
|
|
@@ -39,7 +39,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
|
|
|
39
39
|
ownerId: apiKey
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
async function _track(eventProps) {
|
|
42
|
+
async function _track({ apiHost, ...eventProps }) {
|
|
43
43
|
if (!eventProps.apiKey) {
|
|
44
44
|
logger.error("Missing API key for track call. Please provide your API key.");
|
|
45
45
|
return;
|
|
@@ -53,7 +53,8 @@ async function _track(eventProps) {
|
|
|
53
53
|
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
57
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
57
58
|
method: "POST",
|
|
58
59
|
body: JSON.stringify({
|
|
59
60
|
events: [
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { BuilderContextInterface } from "../../../context/types";
|
|
|
2
2
|
import { BuilderContent } from "../../../types/builder-content";
|
|
3
3
|
import { Dictionary } from "../../../types/typescript";
|
|
4
4
|
import { ContentProps } from "../content.types";
|
|
5
|
-
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "
|
|
5
|
+
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "linkComponent"> & {
|
|
6
6
|
builderContextSignal: BuilderContextInterface;
|
|
7
7
|
setBuilderContextSignal?: (signal: any) => any;
|
|
8
8
|
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 {};
|