@builder.io/sdk-qwik 0.16.17 → 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.
Files changed (55) hide show
  1. package/lib/browser/components/content/components/enable-editor.qwik.cjs +3 -1
  2. package/lib/browser/components/content/components/enable-editor.qwik.mjs +3 -1
  3. package/lib/browser/components/content/content.qwik.cjs +2 -0
  4. package/lib/browser/components/content/content.qwik.mjs +2 -0
  5. package/lib/browser/components/content-variants/content-variants.qwik.cjs +2 -0
  6. package/lib/browser/components/content-variants/content-variants.qwik.mjs +2 -0
  7. package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
  8. package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
  9. package/lib/browser/functions/get-content/generate-content-url.qwik.cjs +3 -2
  10. package/lib/browser/functions/get-content/generate-content-url.qwik.mjs +3 -2
  11. package/lib/browser/functions/get-content/index.qwik.cjs +10 -1
  12. package/lib/browser/functions/get-content/index.qwik.mjs +10 -1
  13. package/lib/browser/functions/track/index.qwik.cjs +6 -3
  14. package/lib/browser/functions/track/index.qwik.mjs +6 -3
  15. package/lib/browser/helpers/sdk-headers.qwik.cjs +10 -0
  16. package/lib/browser/helpers/sdk-headers.qwik.mjs +10 -0
  17. package/lib/edge/components/content/components/enable-editor.qwik.cjs +3 -1
  18. package/lib/edge/components/content/components/enable-editor.qwik.mjs +3 -1
  19. package/lib/edge/components/content/content.qwik.cjs +2 -0
  20. package/lib/edge/components/content/content.qwik.mjs +2 -0
  21. package/lib/edge/components/content-variants/content-variants.qwik.cjs +2 -0
  22. package/lib/edge/components/content-variants/content-variants.qwik.mjs +2 -0
  23. package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
  24. package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
  25. package/lib/edge/functions/get-content/generate-content-url.qwik.cjs +3 -2
  26. package/lib/edge/functions/get-content/generate-content-url.qwik.mjs +3 -2
  27. package/lib/edge/functions/get-content/index.qwik.cjs +10 -1
  28. package/lib/edge/functions/get-content/index.qwik.mjs +10 -1
  29. package/lib/edge/functions/track/index.qwik.cjs +6 -3
  30. package/lib/edge/functions/track/index.qwik.mjs +6 -3
  31. package/lib/edge/helpers/sdk-headers.qwik.cjs +10 -0
  32. package/lib/edge/helpers/sdk-headers.qwik.mjs +10 -0
  33. package/lib/node/components/content/components/enable-editor.qwik.cjs +3 -1
  34. package/lib/node/components/content/components/enable-editor.qwik.mjs +3 -1
  35. package/lib/node/components/content/content.qwik.cjs +2 -0
  36. package/lib/node/components/content/content.qwik.mjs +2 -0
  37. package/lib/node/components/content-variants/content-variants.qwik.cjs +2 -0
  38. package/lib/node/components/content-variants/content-variants.qwik.mjs +2 -0
  39. package/lib/node/constants/sdk-version.qwik.cjs +1 -1
  40. package/lib/node/constants/sdk-version.qwik.mjs +1 -1
  41. package/lib/node/functions/get-content/generate-content-url.qwik.cjs +3 -2
  42. package/lib/node/functions/get-content/generate-content-url.qwik.mjs +3 -2
  43. package/lib/node/functions/get-content/index.qwik.cjs +10 -1
  44. package/lib/node/functions/get-content/index.qwik.mjs +10 -1
  45. package/lib/node/functions/track/index.qwik.cjs +6 -3
  46. package/lib/node/functions/track/index.qwik.mjs +6 -3
  47. package/lib/node/helpers/sdk-headers.qwik.cjs +10 -0
  48. package/lib/node/helpers/sdk-headers.qwik.mjs +10 -0
  49. package/package.json +1 -1
  50. package/types/src/components/content/components/enable-editor.d.ts +1 -1
  51. package/types/src/components/content-variants/content-variants.types.d.ts +4 -0
  52. package/types/src/constants/sdk-version.d.ts +1 -1
  53. package/types/src/functions/get-content/types.d.ts +4 -0
  54. package/types/src/functions/track/index.d.ts +3 -1
  55. package/types/src/helpers/sdk-headers.d.ts +5 -0
@@ -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,
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.16.17";
3
+ const SDK_VERSION = "0.16.19";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.16.17";
1
+ const SDK_VERSION = "0.16.19";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -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 url = new URL(`https://cdn.builder.io/api/${apiVersion$1}/content/${model}`);
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 url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
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));
@@ -4,6 +4,7 @@ const target = require("../../constants/target.qwik.cjs");
4
4
  const abTests = require("../../helpers/ab-tests.qwik.cjs");
5
5
  const canTrack = require("../../helpers/canTrack.qwik.cjs");
6
6
  const logger = require("../../helpers/logger.qwik.cjs");
7
+ const sdkHeaders = require("../../helpers/sdk-headers.qwik.cjs");
7
8
  const getFetch = require("../get-fetch.qwik.cjs");
8
9
  const isBrowser = require("../is-browser.qwik.cjs");
9
10
  const generateContentUrl = require("./generate-content-url.qwik.cjs");
@@ -19,9 +20,17 @@ async function fetchOneEntry(options) {
19
20
  return null;
20
21
  }
21
22
  const _fetchContent = async (options) => {
23
+ var _a;
22
24
  const url = generateContentUrl.generateContentUrl(options);
23
25
  const _fetch = options.fetch ?? getFetch.fetch;
24
- const res = await _fetch(url.href, options.fetchOptions);
26
+ const fetchOptions = {
27
+ ...options.fetchOptions,
28
+ headers: {
29
+ ...(_a = options.fetchOptions) == null ? void 0 : _a.headers,
30
+ ...sdkHeaders.getSdkHeaders()
31
+ }
32
+ };
33
+ const res = await _fetch(url.href, fetchOptions);
25
34
  const content = await res.json();
26
35
  return content;
27
36
  };
@@ -2,6 +2,7 @@ import { TARGET } from "../../constants/target.qwik.mjs";
2
2
  import { handleABTesting } from "../../helpers/ab-tests.qwik.mjs";
3
3
  import { getDefaultCanTrack } from "../../helpers/canTrack.qwik.mjs";
4
4
  import { logger } from "../../helpers/logger.qwik.mjs";
5
+ import { getSdkHeaders } from "../../helpers/sdk-headers.qwik.mjs";
5
6
  import { fetch } from "../get-fetch.qwik.mjs";
6
7
  import { isBrowser } from "../is-browser.qwik.mjs";
7
8
  import { generateContentUrl } from "./generate-content-url.qwik.mjs";
@@ -17,9 +18,17 @@ async function fetchOneEntry(options) {
17
18
  return null;
18
19
  }
19
20
  const _fetchContent = async (options) => {
21
+ var _a;
20
22
  const url = generateContentUrl(options);
21
23
  const _fetch = options.fetch ?? fetch;
22
- const res = await _fetch(url.href, options.fetchOptions);
24
+ const fetchOptions = {
25
+ ...options.fetchOptions,
26
+ headers: {
27
+ ...(_a = options.fetchOptions) == null ? void 0 : _a.headers,
28
+ ...getSdkHeaders()
29
+ }
30
+ };
31
+ const res = await _fetch(url.href, fetchOptions);
23
32
  const content = await res.json();
24
33
  return content;
25
34
  };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const target = require("../../constants/target.qwik.cjs");
4
4
  const logger = require("../../helpers/logger.qwik.cjs");
5
+ const sdkHeaders = require("../../helpers/sdk-headers.qwik.cjs");
5
6
  const sessionId = require("../../helpers/sessionId.qwik.cjs");
6
7
  const visitorId = require("../../helpers/visitorId.qwik.cjs");
7
8
  const isBrowser = require("../is-browser.qwik.cjs");
@@ -40,7 +41,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
40
41
  ownerId: apiKey
41
42
  }
42
43
  });
43
- async function _track(eventProps) {
44
+ async function _track({ apiHost, ...eventProps }) {
44
45
  if (!eventProps.apiKey) {
45
46
  logger.logger.error("Missing API key for track call. Please provide your API key.");
46
47
  return;
@@ -54,7 +55,8 @@ async function _track(eventProps) {
54
55
  if (!(isBrowser.isBrowser() || target.TARGET === "reactNative")) {
55
56
  return;
56
57
  }
57
- return fetch(`https://cdn.builder.io/api/v1/track`, {
58
+ const baseUrl = apiHost || "https://cdn.builder.io";
59
+ return fetch(`${baseUrl}/api/v1/track`, {
58
60
  method: "POST",
59
61
  body: JSON.stringify({
60
62
  events: [
@@ -62,7 +64,8 @@ async function _track(eventProps) {
62
64
  ]
63
65
  }),
64
66
  headers: {
65
- "content-type": "application/json"
67
+ "content-type": "application/json",
68
+ ...sdkHeaders.getSdkHeaders()
66
69
  },
67
70
  mode: "cors"
68
71
  }).catch((err) => {
@@ -1,5 +1,6 @@
1
1
  import { TARGET } from "../../constants/target.qwik.mjs";
2
2
  import { logger } from "../../helpers/logger.qwik.mjs";
3
+ import { getSdkHeaders } from "../../helpers/sdk-headers.qwik.mjs";
3
4
  import { getSessionId } from "../../helpers/sessionId.qwik.mjs";
4
5
  import { getVisitorId } from "../../helpers/visitorId.qwik.mjs";
5
6
  import { isBrowser } from "../is-browser.qwik.mjs";
@@ -38,7 +39,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
38
39
  ownerId: apiKey
39
40
  }
40
41
  });
41
- async function _track(eventProps) {
42
+ async function _track({ apiHost, ...eventProps }) {
42
43
  if (!eventProps.apiKey) {
43
44
  logger.error("Missing API key for track call. Please provide your API key.");
44
45
  return;
@@ -52,7 +53,8 @@ async function _track(eventProps) {
52
53
  if (!(isBrowser() || TARGET === "reactNative")) {
53
54
  return;
54
55
  }
55
- return fetch(`https://cdn.builder.io/api/v1/track`, {
56
+ const baseUrl = apiHost || "https://cdn.builder.io";
57
+ return fetch(`${baseUrl}/api/v1/track`, {
56
58
  method: "POST",
57
59
  body: JSON.stringify({
58
60
  events: [
@@ -60,7 +62,8 @@ async function _track(eventProps) {
60
62
  ]
61
63
  }),
62
64
  headers: {
63
- "content-type": "application/json"
65
+ "content-type": "application/json",
66
+ ...getSdkHeaders()
64
67
  },
65
68
  mode: "cors"
66
69
  }).catch((err) => {
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sdkVersion = require("../constants/sdk-version.qwik.cjs");
4
+ const target = require("../constants/target.qwik.cjs");
5
+ const getSdkHeaders = () => ({
6
+ "X-Builder-SDK": target.TARGET,
7
+ "X-Builder-SDK-GEN": "2",
8
+ "X-Builder-SDK-Version": sdkVersion.SDK_VERSION
9
+ });
10
+ exports.getSdkHeaders = getSdkHeaders;
@@ -0,0 +1,10 @@
1
+ import { SDK_VERSION } from "../constants/sdk-version.qwik.mjs";
2
+ import { TARGET } from "../constants/target.qwik.mjs";
3
+ const getSdkHeaders = () => ({
4
+ "X-Builder-SDK": TARGET,
5
+ "X-Builder-SDK-GEN": "2",
6
+ "X-Builder-SDK-Version": SDK_VERSION
7
+ });
8
+ export {
9
+ getSdkHeaders
10
+ };
@@ -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,
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.16.17";
3
+ const SDK_VERSION = "0.16.19";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.16.17";
1
+ const SDK_VERSION = "0.16.19";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -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 url = new URL(`https://cdn.builder.io/api/${apiVersion$1}/content/${model}`);
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 url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
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));
@@ -4,6 +4,7 @@ const target = require("../../constants/target.qwik.cjs");
4
4
  const abTests = require("../../helpers/ab-tests.qwik.cjs");
5
5
  const canTrack = require("../../helpers/canTrack.qwik.cjs");
6
6
  const logger = require("../../helpers/logger.qwik.cjs");
7
+ const sdkHeaders = require("../../helpers/sdk-headers.qwik.cjs");
7
8
  const getFetch = require("../get-fetch.qwik.cjs");
8
9
  const isBrowser = require("../is-browser.qwik.cjs");
9
10
  const generateContentUrl = require("./generate-content-url.qwik.cjs");
@@ -19,9 +20,17 @@ async function fetchOneEntry(options) {
19
20
  return null;
20
21
  }
21
22
  const _fetchContent = async (options) => {
23
+ var _a;
22
24
  const url = generateContentUrl.generateContentUrl(options);
23
25
  const _fetch = options.fetch ?? getFetch.fetch;
24
- const res = await _fetch(url.href, options.fetchOptions);
26
+ const fetchOptions = {
27
+ ...options.fetchOptions,
28
+ headers: {
29
+ ...(_a = options.fetchOptions) == null ? void 0 : _a.headers,
30
+ ...sdkHeaders.getSdkHeaders()
31
+ }
32
+ };
33
+ const res = await _fetch(url.href, fetchOptions);
25
34
  const content = await res.json();
26
35
  return content;
27
36
  };
@@ -2,6 +2,7 @@ import { TARGET } from "../../constants/target.qwik.mjs";
2
2
  import { handleABTesting } from "../../helpers/ab-tests.qwik.mjs";
3
3
  import { getDefaultCanTrack } from "../../helpers/canTrack.qwik.mjs";
4
4
  import { logger } from "../../helpers/logger.qwik.mjs";
5
+ import { getSdkHeaders } from "../../helpers/sdk-headers.qwik.mjs";
5
6
  import { fetch } from "../get-fetch.qwik.mjs";
6
7
  import { isBrowser } from "../is-browser.qwik.mjs";
7
8
  import { generateContentUrl } from "./generate-content-url.qwik.mjs";
@@ -17,9 +18,17 @@ async function fetchOneEntry(options) {
17
18
  return null;
18
19
  }
19
20
  const _fetchContent = async (options) => {
21
+ var _a;
20
22
  const url = generateContentUrl(options);
21
23
  const _fetch = options.fetch ?? fetch;
22
- const res = await _fetch(url.href, options.fetchOptions);
24
+ const fetchOptions = {
25
+ ...options.fetchOptions,
26
+ headers: {
27
+ ...(_a = options.fetchOptions) == null ? void 0 : _a.headers,
28
+ ...getSdkHeaders()
29
+ }
30
+ };
31
+ const res = await _fetch(url.href, fetchOptions);
23
32
  const content = await res.json();
24
33
  return content;
25
34
  };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const target = require("../../constants/target.qwik.cjs");
4
4
  const logger = require("../../helpers/logger.qwik.cjs");
5
+ const sdkHeaders = require("../../helpers/sdk-headers.qwik.cjs");
5
6
  const sessionId = require("../../helpers/sessionId.qwik.cjs");
6
7
  const visitorId = require("../../helpers/visitorId.qwik.cjs");
7
8
  const isBrowser = require("../is-browser.qwik.cjs");
@@ -40,7 +41,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
40
41
  ownerId: apiKey
41
42
  }
42
43
  });
43
- async function _track(eventProps) {
44
+ async function _track({ apiHost, ...eventProps }) {
44
45
  if (!eventProps.apiKey) {
45
46
  logger.logger.error("Missing API key for track call. Please provide your API key.");
46
47
  return;
@@ -54,7 +55,8 @@ async function _track(eventProps) {
54
55
  if (!(isBrowser.isBrowser() || target.TARGET === "reactNative")) {
55
56
  return;
56
57
  }
57
- return fetch(`https://cdn.builder.io/api/v1/track`, {
58
+ const baseUrl = apiHost || "https://cdn.builder.io";
59
+ return fetch(`${baseUrl}/api/v1/track`, {
58
60
  method: "POST",
59
61
  body: JSON.stringify({
60
62
  events: [
@@ -62,7 +64,8 @@ async function _track(eventProps) {
62
64
  ]
63
65
  }),
64
66
  headers: {
65
- "content-type": "application/json"
67
+ "content-type": "application/json",
68
+ ...sdkHeaders.getSdkHeaders()
66
69
  },
67
70
  mode: "cors"
68
71
  }).catch((err) => {
@@ -1,5 +1,6 @@
1
1
  import { TARGET } from "../../constants/target.qwik.mjs";
2
2
  import { logger } from "../../helpers/logger.qwik.mjs";
3
+ import { getSdkHeaders } from "../../helpers/sdk-headers.qwik.mjs";
3
4
  import { getSessionId } from "../../helpers/sessionId.qwik.mjs";
4
5
  import { getVisitorId } from "../../helpers/visitorId.qwik.mjs";
5
6
  import { isBrowser } from "../is-browser.qwik.mjs";
@@ -38,7 +39,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
38
39
  ownerId: apiKey
39
40
  }
40
41
  });
41
- async function _track(eventProps) {
42
+ async function _track({ apiHost, ...eventProps }) {
42
43
  if (!eventProps.apiKey) {
43
44
  logger.error("Missing API key for track call. Please provide your API key.");
44
45
  return;
@@ -52,7 +53,8 @@ async function _track(eventProps) {
52
53
  if (!(isBrowser() || TARGET === "reactNative")) {
53
54
  return;
54
55
  }
55
- return fetch(`https://cdn.builder.io/api/v1/track`, {
56
+ const baseUrl = apiHost || "https://cdn.builder.io";
57
+ return fetch(`${baseUrl}/api/v1/track`, {
56
58
  method: "POST",
57
59
  body: JSON.stringify({
58
60
  events: [
@@ -60,7 +62,8 @@ async function _track(eventProps) {
60
62
  ]
61
63
  }),
62
64
  headers: {
63
- "content-type": "application/json"
65
+ "content-type": "application/json",
66
+ ...getSdkHeaders()
64
67
  },
65
68
  mode: "cors"
66
69
  }).catch((err) => {
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sdkVersion = require("../constants/sdk-version.qwik.cjs");
4
+ const target = require("../constants/target.qwik.cjs");
5
+ const getSdkHeaders = () => ({
6
+ "X-Builder-SDK": target.TARGET,
7
+ "X-Builder-SDK-GEN": "2",
8
+ "X-Builder-SDK-Version": sdkVersion.SDK_VERSION
9
+ });
10
+ exports.getSdkHeaders = getSdkHeaders;
@@ -0,0 +1,10 @@
1
+ import { SDK_VERSION } from "../constants/sdk-version.qwik.mjs";
2
+ import { TARGET } from "../constants/target.qwik.mjs";
3
+ const getSdkHeaders = () => ({
4
+ "X-Builder-SDK": TARGET,
5
+ "X-Builder-SDK-GEN": "2",
6
+ "X-Builder-SDK-Version": SDK_VERSION
7
+ });
8
+ export {
9
+ getSdkHeaders
10
+ };
@@ -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,
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.16.17";
3
+ const SDK_VERSION = "0.16.19";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.16.17";
1
+ const SDK_VERSION = "0.16.19";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -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 url = new URL(`https://cdn.builder.io/api/${apiVersion$1}/content/${model}`);
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 url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
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));
@@ -4,6 +4,7 @@ const target = require("../../constants/target.qwik.cjs");
4
4
  const abTests = require("../../helpers/ab-tests.qwik.cjs");
5
5
  const canTrack = require("../../helpers/canTrack.qwik.cjs");
6
6
  const logger = require("../../helpers/logger.qwik.cjs");
7
+ const sdkHeaders = require("../../helpers/sdk-headers.qwik.cjs");
7
8
  const getFetch = require("../get-fetch.qwik.cjs");
8
9
  const isBrowser = require("../is-browser.qwik.cjs");
9
10
  const generateContentUrl = require("./generate-content-url.qwik.cjs");
@@ -19,9 +20,17 @@ async function fetchOneEntry(options) {
19
20
  return null;
20
21
  }
21
22
  const _fetchContent = async (options) => {
23
+ var _a;
22
24
  const url = generateContentUrl.generateContentUrl(options);
23
25
  const _fetch = options.fetch ?? getFetch.fetch;
24
- const res = await _fetch(url.href, options.fetchOptions);
26
+ const fetchOptions = {
27
+ ...options.fetchOptions,
28
+ headers: {
29
+ ...(_a = options.fetchOptions) == null ? void 0 : _a.headers,
30
+ ...sdkHeaders.getSdkHeaders()
31
+ }
32
+ };
33
+ const res = await _fetch(url.href, fetchOptions);
25
34
  const content = await res.json();
26
35
  return content;
27
36
  };
@@ -2,6 +2,7 @@ import { TARGET } from "../../constants/target.qwik.mjs";
2
2
  import { handleABTesting } from "../../helpers/ab-tests.qwik.mjs";
3
3
  import { getDefaultCanTrack } from "../../helpers/canTrack.qwik.mjs";
4
4
  import { logger } from "../../helpers/logger.qwik.mjs";
5
+ import { getSdkHeaders } from "../../helpers/sdk-headers.qwik.mjs";
5
6
  import { fetch } from "../get-fetch.qwik.mjs";
6
7
  import { isBrowser } from "../is-browser.qwik.mjs";
7
8
  import { generateContentUrl } from "./generate-content-url.qwik.mjs";
@@ -17,9 +18,17 @@ async function fetchOneEntry(options) {
17
18
  return null;
18
19
  }
19
20
  const _fetchContent = async (options) => {
21
+ var _a;
20
22
  const url = generateContentUrl(options);
21
23
  const _fetch = options.fetch ?? fetch;
22
- const res = await _fetch(url.href, options.fetchOptions);
24
+ const fetchOptions = {
25
+ ...options.fetchOptions,
26
+ headers: {
27
+ ...(_a = options.fetchOptions) == null ? void 0 : _a.headers,
28
+ ...getSdkHeaders()
29
+ }
30
+ };
31
+ const res = await _fetch(url.href, fetchOptions);
23
32
  const content = await res.json();
24
33
  return content;
25
34
  };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const target = require("../../constants/target.qwik.cjs");
4
4
  const logger = require("../../helpers/logger.qwik.cjs");
5
+ const sdkHeaders = require("../../helpers/sdk-headers.qwik.cjs");
5
6
  const sessionId = require("../../helpers/sessionId.qwik.cjs");
6
7
  const visitorId = require("../../helpers/visitorId.qwik.cjs");
7
8
  const isBrowser = require("../is-browser.qwik.cjs");
@@ -40,7 +41,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
40
41
  ownerId: apiKey
41
42
  }
42
43
  });
43
- async function _track(eventProps) {
44
+ async function _track({ apiHost, ...eventProps }) {
44
45
  if (!eventProps.apiKey) {
45
46
  logger.logger.error("Missing API key for track call. Please provide your API key.");
46
47
  return;
@@ -54,7 +55,8 @@ async function _track(eventProps) {
54
55
  if (!(isBrowser.isBrowser() || target.TARGET === "reactNative")) {
55
56
  return;
56
57
  }
57
- return fetch(`https://cdn.builder.io/api/v1/track`, {
58
+ const baseUrl = apiHost || "https://cdn.builder.io";
59
+ return fetch(`${baseUrl}/api/v1/track`, {
58
60
  method: "POST",
59
61
  body: JSON.stringify({
60
62
  events: [
@@ -62,7 +64,8 @@ async function _track(eventProps) {
62
64
  ]
63
65
  }),
64
66
  headers: {
65
- "content-type": "application/json"
67
+ "content-type": "application/json",
68
+ ...sdkHeaders.getSdkHeaders()
66
69
  },
67
70
  mode: "cors"
68
71
  }).catch((err) => {
@@ -1,5 +1,6 @@
1
1
  import { TARGET } from "../../constants/target.qwik.mjs";
2
2
  import { logger } from "../../helpers/logger.qwik.mjs";
3
+ import { getSdkHeaders } from "../../helpers/sdk-headers.qwik.mjs";
3
4
  import { getSessionId } from "../../helpers/sessionId.qwik.mjs";
4
5
  import { getVisitorId } from "../../helpers/visitorId.qwik.mjs";
5
6
  import { isBrowser } from "../is-browser.qwik.mjs";
@@ -38,7 +39,7 @@ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...pro
38
39
  ownerId: apiKey
39
40
  }
40
41
  });
41
- async function _track(eventProps) {
42
+ async function _track({ apiHost, ...eventProps }) {
42
43
  if (!eventProps.apiKey) {
43
44
  logger.error("Missing API key for track call. Please provide your API key.");
44
45
  return;
@@ -52,7 +53,8 @@ async function _track(eventProps) {
52
53
  if (!(isBrowser() || TARGET === "reactNative")) {
53
54
  return;
54
55
  }
55
- return fetch(`https://cdn.builder.io/api/v1/track`, {
56
+ const baseUrl = apiHost || "https://cdn.builder.io";
57
+ return fetch(`${baseUrl}/api/v1/track`, {
56
58
  method: "POST",
57
59
  body: JSON.stringify({
58
60
  events: [
@@ -60,7 +62,8 @@ async function _track(eventProps) {
60
62
  ]
61
63
  }),
62
64
  headers: {
63
- "content-type": "application/json"
65
+ "content-type": "application/json",
66
+ ...getSdkHeaders()
64
67
  },
65
68
  mode: "cors"
66
69
  }).catch((err) => {
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sdkVersion = require("../constants/sdk-version.qwik.cjs");
4
+ const target = require("../constants/target.qwik.cjs");
5
+ const getSdkHeaders = () => ({
6
+ "X-Builder-SDK": target.TARGET,
7
+ "X-Builder-SDK-GEN": "2",
8
+ "X-Builder-SDK-Version": sdkVersion.SDK_VERSION
9
+ });
10
+ exports.getSdkHeaders = getSdkHeaders;
@@ -0,0 +1,10 @@
1
+ import { SDK_VERSION } from "../constants/sdk-version.qwik.mjs";
2
+ import { TARGET } from "../constants/target.qwik.mjs";
3
+ const getSdkHeaders = () => ({
4
+ "X-Builder-SDK": TARGET,
5
+ "X-Builder-SDK-GEN": "2",
6
+ "X-Builder-SDK-Version": SDK_VERSION
7
+ });
8
+ export {
9
+ getSdkHeaders
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.16.17",
3
+ "version": "0.16.19",
4
4
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/qwik",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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" | "isNestedRender" | "linkComponent"> & {
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.17";
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): Promise<void | Response>;
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 {};
@@ -0,0 +1,5 @@
1
+ export declare const getSdkHeaders: () => {
2
+ 'X-Builder-SDK': import("../types/targets").Target;
3
+ 'X-Builder-SDK-GEN': string;
4
+ 'X-Builder-SDK-Version': string;
5
+ };