@builder.io/sdk-solid 2.0.24 → 2.0.26

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/dist/index.d.ts CHANGED
@@ -686,6 +686,10 @@ interface ContentVariantsPrps extends ExtraFrameworkProps {
686
686
  * Your API Key: needed to enable visual editing, and to dynamically fetch symbols (required).
687
687
  */
688
688
  apiKey: string;
689
+ /**
690
+ * Sets the host of Builder API calls. (Defaults to global `https://cdn.builder.io`)
691
+ */
692
+ apiHost?: string;
689
693
  apiVersion?: ApiVersion;
690
694
  /**
691
695
  * An array of custom components to register (optional).
@@ -1012,6 +1016,10 @@ interface GetContentOptions {
1012
1016
  * Optional fetch options to be passed as the second argument to the `fetch` function.
1013
1017
  */
1014
1018
  fetchOptions?: object;
1019
+ /**
1020
+ * Sets the host of Builder API calls. (Defaults to global `https://cdn.builder.io`)
1021
+ */
1022
+ apiHost?: string;
1015
1023
  }
1016
1024
 
1017
1025
  type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
@@ -4765,6 +4765,16 @@ function getPreviewContent(_searchParams) {
4765
4765
  return void 0;
4766
4766
  }
4767
4767
 
4768
+ // src/constants/sdk-version.ts
4769
+ var SDK_VERSION = "2.0.26";
4770
+
4771
+ // src/helpers/sdk-headers.ts
4772
+ var getSdkHeaders = () => ({
4773
+ "X-Builder-SDK": TARGET,
4774
+ "X-Builder-SDK-GEN": "2",
4775
+ "X-Builder-SDK-Version": SDK_VERSION
4776
+ });
4777
+
4768
4778
  // src/functions/get-global-this.ts
4769
4779
  function getGlobalThis() {
4770
4780
  if (typeof globalThis !== "undefined") {
@@ -4868,7 +4878,8 @@ var generateContentUrl = (options) => {
4868
4878
  cacheSeconds,
4869
4879
  staleCacheSeconds,
4870
4880
  sort,
4871
- includeUnpublished
4881
+ includeUnpublished,
4882
+ apiHost
4872
4883
  } = options;
4873
4884
  if (!apiKey) {
4874
4885
  throw new Error("Missing API key");
@@ -4877,7 +4888,8 @@ var generateContentUrl = (options) => {
4877
4888
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4878
4889
  }
4879
4890
  const noTraverse = limit !== 1;
4880
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
4891
+ const baseUrl = apiHost || "https://cdn.builder.io";
4892
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
4881
4893
  url.searchParams.set("apiKey", apiKey);
4882
4894
  url.searchParams.set("limit", String(limit));
4883
4895
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -4947,7 +4959,14 @@ async function fetchOneEntry(options) {
4947
4959
  var _fetchContent = async (options) => {
4948
4960
  const url = generateContentUrl(options);
4949
4961
  const _fetch = options.fetch ?? fetch2;
4950
- const res = await _fetch(url.href, options.fetchOptions);
4962
+ const fetchOptions = {
4963
+ ...options.fetchOptions,
4964
+ headers: {
4965
+ ...options.fetchOptions?.headers,
4966
+ ...getSdkHeaders()
4967
+ }
4968
+ };
4969
+ const res = await _fetch(url.href, fetchOptions);
4951
4970
  const content = await res.json();
4952
4971
  return content;
4953
4972
  };
@@ -5158,7 +5177,10 @@ var createEvent = async ({
5158
5177
  ownerId: apiKey
5159
5178
  }
5160
5179
  });
5161
- async function _track(eventProps) {
5180
+ async function _track({
5181
+ apiHost,
5182
+ ...eventProps
5183
+ }) {
5162
5184
  if (!eventProps.apiKey) {
5163
5185
  logger.error("Missing API key for track call. Please provide your API key.");
5164
5186
  return;
@@ -5172,13 +5194,15 @@ async function _track(eventProps) {
5172
5194
  if (!(isBrowser() || TARGET === "reactNative")) {
5173
5195
  return;
5174
5196
  }
5175
- return fetch(`https://cdn.builder.io/api/v1/track`, {
5197
+ const baseUrl = apiHost || "https://cdn.builder.io";
5198
+ return fetch(`${baseUrl}/api/v1/track`, {
5176
5199
  method: "POST",
5177
5200
  body: JSON.stringify({
5178
5201
  events: [await createEvent(eventProps)]
5179
5202
  }),
5180
5203
  headers: {
5181
- "content-type": "application/json"
5204
+ "content-type": "application/json",
5205
+ ...getSdkHeaders()
5182
5206
  },
5183
5207
  mode: "cors"
5184
5208
  }).catch((err) => {
@@ -5258,9 +5282,6 @@ function isFromTrustedHost(trustedHosts, e) {
5258
5282
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
5259
5283
  }
5260
5284
 
5261
- // src/constants/sdk-version.ts
5262
- var SDK_VERSION = "2.0.24";
5263
-
5264
5285
  // src/functions/register.ts
5265
5286
  var registry = {};
5266
5287
  function register(type, info) {
@@ -5618,6 +5639,7 @@ function EnableEditor(props) {
5618
5639
  const variationId = props.builderContextSignal.content?.testVariationId;
5619
5640
  const contentId = props.builderContextSignal.content?.id;
5620
5641
  _track({
5642
+ apiHost: props.apiHost,
5621
5643
  type: "click",
5622
5644
  canTrack: getDefaultCanTrack(props.canTrack),
5623
5645
  contentId,
@@ -5677,7 +5699,7 @@ function EnableEditor(props) {
5677
5699
  emitStateUpdate();
5678
5700
  onMount(() => {
5679
5701
  if (isBrowser()) {
5680
- if (isEditing()) {
5702
+ if (isEditing() && !props.isNestedRender) {
5681
5703
  window.addEventListener("message", processMessage);
5682
5704
  registerInsertMenu();
5683
5705
  setupBrowserForEditing({
@@ -5703,6 +5725,7 @@ function EnableEditor(props) {
5703
5725
  const contentId = props.builderContextSignal.content?.id;
5704
5726
  const apiKeyProp = props.apiKey;
5705
5727
  _track({
5728
+ apiHost: props.apiHost,
5706
5729
  type: "impression",
5707
5730
  canTrack: true,
5708
5731
  contentId,
@@ -5951,6 +5974,9 @@ function ContentComponent(props) {
5951
5974
  },
5952
5975
  get children() {
5953
5976
  return createComponent(enable_editor_default, mergeProps({
5977
+ get apiHost() {
5978
+ return props.apiHost;
5979
+ },
5954
5980
  get nonce() {
5955
5981
  return props.nonce;
5956
5982
  },
@@ -5992,6 +6018,9 @@ function ContentComponent(props) {
5992
6018
  },
5993
6019
  get trustedHosts() {
5994
6020
  return props.trustedHosts;
6021
+ },
6022
+ get isNestedRender() {
6023
+ return props.isNestedRender;
5995
6024
  }
5996
6025
  }, {
5997
6026
  setBuilderContextSignal
@@ -6124,6 +6153,9 @@ function ContentVariants(props) {
6124
6153
  children: (variant, _index) => {
6125
6154
  _index();
6126
6155
  return createComponent(content_default, mergeProps({
6156
+ get apiHost() {
6157
+ return props.apiHost;
6158
+ },
6127
6159
  get isNestedRender() {
6128
6160
  return props.isNestedRender;
6129
6161
  },
@@ -6188,6 +6220,9 @@ function ContentVariants(props) {
6188
6220
  })];
6189
6221
  }
6190
6222
  }), createComponent(content_default, mergeProps({
6223
+ get apiHost() {
6224
+ return props.apiHost;
6225
+ },
6191
6226
  get nonce() {
6192
6227
  return props.nonce;
6193
6228
  },
@@ -4253,6 +4253,16 @@ function getPreviewContent(_searchParams) {
4253
4253
  return void 0;
4254
4254
  }
4255
4255
 
4256
+ // src/constants/sdk-version.ts
4257
+ var SDK_VERSION = "2.0.26";
4258
+
4259
+ // src/helpers/sdk-headers.ts
4260
+ var getSdkHeaders = () => ({
4261
+ "X-Builder-SDK": TARGET,
4262
+ "X-Builder-SDK-GEN": "2",
4263
+ "X-Builder-SDK-Version": SDK_VERSION
4264
+ });
4265
+
4256
4266
  // src/functions/get-global-this.ts
4257
4267
  function getGlobalThis() {
4258
4268
  if (typeof globalThis !== "undefined") {
@@ -4356,7 +4366,8 @@ var generateContentUrl = (options) => {
4356
4366
  cacheSeconds,
4357
4367
  staleCacheSeconds,
4358
4368
  sort,
4359
- includeUnpublished
4369
+ includeUnpublished,
4370
+ apiHost
4360
4371
  } = options;
4361
4372
  if (!apiKey) {
4362
4373
  throw new Error("Missing API key");
@@ -4365,7 +4376,8 @@ var generateContentUrl = (options) => {
4365
4376
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4366
4377
  }
4367
4378
  const noTraverse = limit !== 1;
4368
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
4379
+ const baseUrl = apiHost || "https://cdn.builder.io";
4380
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
4369
4381
  url.searchParams.set("apiKey", apiKey);
4370
4382
  url.searchParams.set("limit", String(limit));
4371
4383
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -4435,7 +4447,14 @@ async function fetchOneEntry(options) {
4435
4447
  var _fetchContent = async (options) => {
4436
4448
  const url = generateContentUrl(options);
4437
4449
  const _fetch = options.fetch ?? fetch2;
4438
- const res = await _fetch(url.href, options.fetchOptions);
4450
+ const fetchOptions = {
4451
+ ...options.fetchOptions,
4452
+ headers: {
4453
+ ...options.fetchOptions?.headers,
4454
+ ...getSdkHeaders()
4455
+ }
4456
+ };
4457
+ const res = await _fetch(url.href, fetchOptions);
4439
4458
  const content = await res.json();
4440
4459
  return content;
4441
4460
  };
@@ -4646,7 +4665,10 @@ var createEvent = async ({
4646
4665
  ownerId: apiKey
4647
4666
  }
4648
4667
  });
4649
- async function _track(eventProps) {
4668
+ async function _track({
4669
+ apiHost,
4670
+ ...eventProps
4671
+ }) {
4650
4672
  if (!eventProps.apiKey) {
4651
4673
  logger.error("Missing API key for track call. Please provide your API key.");
4652
4674
  return;
@@ -4660,13 +4682,15 @@ async function _track(eventProps) {
4660
4682
  if (!(isBrowser() || TARGET === "reactNative")) {
4661
4683
  return;
4662
4684
  }
4663
- return fetch(`https://cdn.builder.io/api/v1/track`, {
4685
+ const baseUrl = apiHost || "https://cdn.builder.io";
4686
+ return fetch(`${baseUrl}/api/v1/track`, {
4664
4687
  method: "POST",
4665
4688
  body: JSON.stringify({
4666
4689
  events: [await createEvent(eventProps)]
4667
4690
  }),
4668
4691
  headers: {
4669
- "content-type": "application/json"
4692
+ "content-type": "application/json",
4693
+ ...getSdkHeaders()
4670
4694
  },
4671
4695
  mode: "cors"
4672
4696
  }).catch((err) => {
@@ -4746,9 +4770,6 @@ function isFromTrustedHost(trustedHosts, e) {
4746
4770
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
4747
4771
  }
4748
4772
 
4749
- // src/constants/sdk-version.ts
4750
- var SDK_VERSION = "2.0.24";
4751
-
4752
4773
  // src/functions/register.ts
4753
4774
  var registry = {};
4754
4775
  function register(type, info) {
@@ -5105,6 +5126,7 @@ function EnableEditor(props) {
5105
5126
  const variationId = props.builderContextSignal.content?.testVariationId;
5106
5127
  const contentId = props.builderContextSignal.content?.id;
5107
5128
  _track({
5129
+ apiHost: props.apiHost,
5108
5130
  type: "click",
5109
5131
  canTrack: getDefaultCanTrack(props.canTrack),
5110
5132
  contentId,
@@ -5174,7 +5196,7 @@ function EnableEditor(props) {
5174
5196
  emitStateUpdate();
5175
5197
  onMount6(() => {
5176
5198
  if (isBrowser()) {
5177
- if (isEditing()) {
5199
+ if (isEditing() && !props.isNestedRender) {
5178
5200
  window.addEventListener("message", processMessage);
5179
5201
  registerInsertMenu();
5180
5202
  setupBrowserForEditing({
@@ -5205,6 +5227,7 @@ function EnableEditor(props) {
5205
5227
  const contentId = props.builderContextSignal.content?.id;
5206
5228
  const apiKeyProp = props.apiKey;
5207
5229
  _track({
5230
+ apiHost: props.apiHost,
5208
5231
  type: "impression",
5209
5232
  canTrack: true,
5210
5233
  contentId,
@@ -5444,6 +5467,7 @@ function ContentComponent(props) {
5444
5467
  registeredComponents: registeredComponents()
5445
5468
  }}
5446
5469
  ><Enable_editor_default
5470
+ apiHost={props.apiHost}
5447
5471
  nonce={props.nonce}
5448
5472
  content={props.content}
5449
5473
  data={props.data}
@@ -5458,6 +5482,7 @@ function ContentComponent(props) {
5458
5482
  contentWrapper={props.contentWrapper}
5459
5483
  contentWrapperProps={props.contentWrapperProps}
5460
5484
  trustedHosts={props.trustedHosts}
5485
+ isNestedRender={props.isNestedRender}
5461
5486
  {...{
5462
5487
  setBuilderContextSignal
5463
5488
  }}
@@ -5536,6 +5561,7 @@ function ContentVariants(props) {
5536
5561
  <For9 each={getVariants(props.content)}>{(variant, _index) => {
5537
5562
  const index = _index();
5538
5563
  return <Content_default
5564
+ apiHost={props.apiHost}
5539
5565
  isNestedRender={props.isNestedRender}
5540
5566
  key={variant.testVariationId}
5541
5567
  nonce={props.nonce}
@@ -5562,6 +5588,7 @@ function ContentVariants(props) {
5562
5588
  }}</For9>
5563
5589
  </Show15>
5564
5590
  <Content_default
5591
+ apiHost={props.apiHost}
5565
5592
  nonce={props.nonce}
5566
5593
  isNestedRender={props.isNestedRender}
5567
5594
  {...{}}
@@ -4755,6 +4755,16 @@ function getPreviewContent(_searchParams) {
4755
4755
  return void 0;
4756
4756
  }
4757
4757
 
4758
+ // src/constants/sdk-version.ts
4759
+ var SDK_VERSION = "2.0.26";
4760
+
4761
+ // src/helpers/sdk-headers.ts
4762
+ var getSdkHeaders = () => ({
4763
+ "X-Builder-SDK": TARGET,
4764
+ "X-Builder-SDK-GEN": "2",
4765
+ "X-Builder-SDK-Version": SDK_VERSION
4766
+ });
4767
+
4758
4768
  // src/functions/get-global-this.ts
4759
4769
  function getGlobalThis() {
4760
4770
  if (typeof globalThis !== "undefined") {
@@ -4856,7 +4866,8 @@ var generateContentUrl = (options) => {
4856
4866
  cacheSeconds,
4857
4867
  staleCacheSeconds,
4858
4868
  sort,
4859
- includeUnpublished
4869
+ includeUnpublished,
4870
+ apiHost
4860
4871
  } = options;
4861
4872
  if (!apiKey) {
4862
4873
  throw new Error("Missing API key");
@@ -4865,7 +4876,8 @@ var generateContentUrl = (options) => {
4865
4876
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4866
4877
  }
4867
4878
  const noTraverse = limit !== 1;
4868
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
4879
+ const baseUrl = apiHost || "https://cdn.builder.io";
4880
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
4869
4881
  url.searchParams.set("apiKey", apiKey);
4870
4882
  url.searchParams.set("limit", String(limit));
4871
4883
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -4935,7 +4947,14 @@ async function fetchOneEntry(options) {
4935
4947
  var _fetchContent = async (options) => {
4936
4948
  const url = generateContentUrl(options);
4937
4949
  const _fetch = options.fetch ?? fetch2;
4938
- const res = await _fetch(url.href, options.fetchOptions);
4950
+ const fetchOptions = {
4951
+ ...options.fetchOptions,
4952
+ headers: {
4953
+ ...options.fetchOptions?.headers,
4954
+ ...getSdkHeaders()
4955
+ }
4956
+ };
4957
+ const res = await _fetch(url.href, fetchOptions);
4939
4958
  const content = await res.json();
4940
4959
  return content;
4941
4960
  };
@@ -5144,7 +5163,10 @@ var createEvent = async ({
5144
5163
  ownerId: apiKey
5145
5164
  }
5146
5165
  });
5147
- async function _track(eventProps) {
5166
+ async function _track({
5167
+ apiHost,
5168
+ ...eventProps
5169
+ }) {
5148
5170
  if (!eventProps.apiKey) {
5149
5171
  logger.error("Missing API key for track call. Please provide your API key.");
5150
5172
  return;
@@ -5158,13 +5180,15 @@ async function _track(eventProps) {
5158
5180
  if (!(isBrowser() || TARGET === "reactNative")) {
5159
5181
  return;
5160
5182
  }
5161
- return fetch(`https://cdn.builder.io/api/v1/track`, {
5183
+ const baseUrl = apiHost || "https://cdn.builder.io";
5184
+ return fetch(`${baseUrl}/api/v1/track`, {
5162
5185
  method: "POST",
5163
5186
  body: JSON.stringify({
5164
5187
  events: [await createEvent(eventProps)]
5165
5188
  }),
5166
5189
  headers: {
5167
- "content-type": "application/json"
5190
+ "content-type": "application/json",
5191
+ ...getSdkHeaders()
5168
5192
  },
5169
5193
  mode: "cors"
5170
5194
  }).catch((err) => {
@@ -5243,9 +5267,6 @@ function isFromTrustedHost(trustedHosts, e) {
5243
5267
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
5244
5268
  }
5245
5269
 
5246
- // src/constants/sdk-version.ts
5247
- var SDK_VERSION = "2.0.24";
5248
-
5249
5270
  // src/functions/register.ts
5250
5271
  var registry = {};
5251
5272
  function register(type, info) {
@@ -5602,6 +5623,7 @@ function EnableEditor(props) {
5602
5623
  const variationId = props.builderContextSignal.content?.testVariationId;
5603
5624
  const contentId = props.builderContextSignal.content?.id;
5604
5625
  _track({
5626
+ apiHost: props.apiHost,
5605
5627
  type: "click",
5606
5628
  canTrack: getDefaultCanTrack(props.canTrack),
5607
5629
  contentId,
@@ -5660,7 +5682,7 @@ function EnableEditor(props) {
5660
5682
  emitStateUpdate();
5661
5683
  onMount(() => {
5662
5684
  if (isBrowser()) {
5663
- if (isEditing()) {
5685
+ if (isEditing() && !props.isNestedRender) {
5664
5686
  window.addEventListener("message", processMessage);
5665
5687
  registerInsertMenu();
5666
5688
  setupBrowserForEditing({
@@ -5686,6 +5708,7 @@ function EnableEditor(props) {
5686
5708
  const contentId = props.builderContextSignal.content?.id;
5687
5709
  const apiKeyProp = props.apiKey;
5688
5710
  _track({
5711
+ apiHost: props.apiHost,
5689
5712
  type: "impression",
5690
5713
  canTrack: true,
5691
5714
  contentId,
@@ -5934,6 +5957,9 @@ function ContentComponent(props) {
5934
5957
  },
5935
5958
  get children() {
5936
5959
  return createComponent(enable_editor_default, mergeProps({
5960
+ get apiHost() {
5961
+ return props.apiHost;
5962
+ },
5937
5963
  get nonce() {
5938
5964
  return props.nonce;
5939
5965
  },
@@ -5975,6 +6001,9 @@ function ContentComponent(props) {
5975
6001
  },
5976
6002
  get trustedHosts() {
5977
6003
  return props.trustedHosts;
6004
+ },
6005
+ get isNestedRender() {
6006
+ return props.isNestedRender;
5978
6007
  }
5979
6008
  }, {
5980
6009
  setBuilderContextSignal
@@ -6107,6 +6136,9 @@ function ContentVariants(props) {
6107
6136
  children: (variant, _index) => {
6108
6137
  _index();
6109
6138
  return createComponent(content_default, mergeProps({
6139
+ get apiHost() {
6140
+ return props.apiHost;
6141
+ },
6110
6142
  get isNestedRender() {
6111
6143
  return props.isNestedRender;
6112
6144
  },
@@ -6171,6 +6203,9 @@ function ContentVariants(props) {
6171
6203
  })];
6172
6204
  }
6173
6205
  }), createComponent(content_default, mergeProps({
6206
+ get apiHost() {
6207
+ return props.apiHost;
6208
+ },
6174
6209
  get nonce() {
6175
6210
  return props.nonce;
6176
6211
  },
@@ -4243,6 +4243,16 @@ function getPreviewContent(_searchParams) {
4243
4243
  return void 0;
4244
4244
  }
4245
4245
 
4246
+ // src/constants/sdk-version.ts
4247
+ var SDK_VERSION = "2.0.26";
4248
+
4249
+ // src/helpers/sdk-headers.ts
4250
+ var getSdkHeaders = () => ({
4251
+ "X-Builder-SDK": TARGET,
4252
+ "X-Builder-SDK-GEN": "2",
4253
+ "X-Builder-SDK-Version": SDK_VERSION
4254
+ });
4255
+
4246
4256
  // src/functions/get-global-this.ts
4247
4257
  function getGlobalThis() {
4248
4258
  if (typeof globalThis !== "undefined") {
@@ -4344,7 +4354,8 @@ var generateContentUrl = (options) => {
4344
4354
  cacheSeconds,
4345
4355
  staleCacheSeconds,
4346
4356
  sort,
4347
- includeUnpublished
4357
+ includeUnpublished,
4358
+ apiHost
4348
4359
  } = options;
4349
4360
  if (!apiKey) {
4350
4361
  throw new Error("Missing API key");
@@ -4353,7 +4364,8 @@ var generateContentUrl = (options) => {
4353
4364
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4354
4365
  }
4355
4366
  const noTraverse = limit !== 1;
4356
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
4367
+ const baseUrl = apiHost || "https://cdn.builder.io";
4368
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
4357
4369
  url.searchParams.set("apiKey", apiKey);
4358
4370
  url.searchParams.set("limit", String(limit));
4359
4371
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -4423,7 +4435,14 @@ async function fetchOneEntry(options) {
4423
4435
  var _fetchContent = async (options) => {
4424
4436
  const url = generateContentUrl(options);
4425
4437
  const _fetch = options.fetch ?? fetch2;
4426
- const res = await _fetch(url.href, options.fetchOptions);
4438
+ const fetchOptions = {
4439
+ ...options.fetchOptions,
4440
+ headers: {
4441
+ ...options.fetchOptions?.headers,
4442
+ ...getSdkHeaders()
4443
+ }
4444
+ };
4445
+ const res = await _fetch(url.href, fetchOptions);
4427
4446
  const content = await res.json();
4428
4447
  return content;
4429
4448
  };
@@ -4632,7 +4651,10 @@ var createEvent = async ({
4632
4651
  ownerId: apiKey
4633
4652
  }
4634
4653
  });
4635
- async function _track(eventProps) {
4654
+ async function _track({
4655
+ apiHost,
4656
+ ...eventProps
4657
+ }) {
4636
4658
  if (!eventProps.apiKey) {
4637
4659
  logger.error("Missing API key for track call. Please provide your API key.");
4638
4660
  return;
@@ -4646,13 +4668,15 @@ async function _track(eventProps) {
4646
4668
  if (!(isBrowser() || TARGET === "reactNative")) {
4647
4669
  return;
4648
4670
  }
4649
- return fetch(`https://cdn.builder.io/api/v1/track`, {
4671
+ const baseUrl = apiHost || "https://cdn.builder.io";
4672
+ return fetch(`${baseUrl}/api/v1/track`, {
4650
4673
  method: "POST",
4651
4674
  body: JSON.stringify({
4652
4675
  events: [await createEvent(eventProps)]
4653
4676
  }),
4654
4677
  headers: {
4655
- "content-type": "application/json"
4678
+ "content-type": "application/json",
4679
+ ...getSdkHeaders()
4656
4680
  },
4657
4681
  mode: "cors"
4658
4682
  }).catch((err) => {
@@ -4731,9 +4755,6 @@ function isFromTrustedHost(trustedHosts, e) {
4731
4755
  return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
4732
4756
  }
4733
4757
 
4734
- // src/constants/sdk-version.ts
4735
- var SDK_VERSION = "2.0.24";
4736
-
4737
4758
  // src/functions/register.ts
4738
4759
  var registry = {};
4739
4760
  function register(type, info) {
@@ -5089,6 +5110,7 @@ function EnableEditor(props) {
5089
5110
  const variationId = props.builderContextSignal.content?.testVariationId;
5090
5111
  const contentId = props.builderContextSignal.content?.id;
5091
5112
  _track({
5113
+ apiHost: props.apiHost,
5092
5114
  type: "click",
5093
5115
  canTrack: getDefaultCanTrack(props.canTrack),
5094
5116
  contentId,
@@ -5157,7 +5179,7 @@ function EnableEditor(props) {
5157
5179
  emitStateUpdate();
5158
5180
  onMount6(() => {
5159
5181
  if (isBrowser()) {
5160
- if (isEditing()) {
5182
+ if (isEditing() && !props.isNestedRender) {
5161
5183
  window.addEventListener("message", processMessage);
5162
5184
  registerInsertMenu();
5163
5185
  setupBrowserForEditing({
@@ -5188,6 +5210,7 @@ function EnableEditor(props) {
5188
5210
  const contentId = props.builderContextSignal.content?.id;
5189
5211
  const apiKeyProp = props.apiKey;
5190
5212
  _track({
5213
+ apiHost: props.apiHost,
5191
5214
  type: "impression",
5192
5215
  canTrack: true,
5193
5216
  contentId,
@@ -5427,6 +5450,7 @@ function ContentComponent(props) {
5427
5450
  registeredComponents: registeredComponents()
5428
5451
  }}
5429
5452
  ><Enable_editor_default
5453
+ apiHost={props.apiHost}
5430
5454
  nonce={props.nonce}
5431
5455
  content={props.content}
5432
5456
  data={props.data}
@@ -5441,6 +5465,7 @@ function ContentComponent(props) {
5441
5465
  contentWrapper={props.contentWrapper}
5442
5466
  contentWrapperProps={props.contentWrapperProps}
5443
5467
  trustedHosts={props.trustedHosts}
5468
+ isNestedRender={props.isNestedRender}
5444
5469
  {...{
5445
5470
  setBuilderContextSignal
5446
5471
  }}
@@ -5519,6 +5544,7 @@ function ContentVariants(props) {
5519
5544
  <For9 each={getVariants(props.content)}>{(variant, _index) => {
5520
5545
  const index = _index();
5521
5546
  return <Content_default
5547
+ apiHost={props.apiHost}
5522
5548
  isNestedRender={props.isNestedRender}
5523
5549
  key={variant.testVariationId}
5524
5550
  nonce={props.nonce}
@@ -5545,6 +5571,7 @@ function ContentVariants(props) {
5545
5571
  }}</For9>
5546
5572
  </Show15>
5547
5573
  <Content_default
5574
+ apiHost={props.apiHost}
5548
5575
  nonce={props.nonce}
5549
5576
  isNestedRender={props.isNestedRender}
5550
5577
  {...{}}