@builder.io/sdk-solid 2.0.25 → 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'> & {
@@ -4766,7 +4766,7 @@ function getPreviewContent(_searchParams) {
4766
4766
  }
4767
4767
 
4768
4768
  // src/constants/sdk-version.ts
4769
- var SDK_VERSION = "2.0.25";
4769
+ var SDK_VERSION = "2.0.26";
4770
4770
 
4771
4771
  // src/helpers/sdk-headers.ts
4772
4772
  var getSdkHeaders = () => ({
@@ -4878,7 +4878,8 @@ var generateContentUrl = (options) => {
4878
4878
  cacheSeconds,
4879
4879
  staleCacheSeconds,
4880
4880
  sort,
4881
- includeUnpublished
4881
+ includeUnpublished,
4882
+ apiHost
4882
4883
  } = options;
4883
4884
  if (!apiKey) {
4884
4885
  throw new Error("Missing API key");
@@ -4887,7 +4888,8 @@ var generateContentUrl = (options) => {
4887
4888
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4888
4889
  }
4889
4890
  const noTraverse = limit !== 1;
4890
- 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}`);
4891
4893
  url.searchParams.set("apiKey", apiKey);
4892
4894
  url.searchParams.set("limit", String(limit));
4893
4895
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -5175,7 +5177,10 @@ var createEvent = async ({
5175
5177
  ownerId: apiKey
5176
5178
  }
5177
5179
  });
5178
- async function _track(eventProps) {
5180
+ async function _track({
5181
+ apiHost,
5182
+ ...eventProps
5183
+ }) {
5179
5184
  if (!eventProps.apiKey) {
5180
5185
  logger.error("Missing API key for track call. Please provide your API key.");
5181
5186
  return;
@@ -5189,7 +5194,8 @@ async function _track(eventProps) {
5189
5194
  if (!(isBrowser() || TARGET === "reactNative")) {
5190
5195
  return;
5191
5196
  }
5192
- return fetch(`https://cdn.builder.io/api/v1/track`, {
5197
+ const baseUrl = apiHost || "https://cdn.builder.io";
5198
+ return fetch(`${baseUrl}/api/v1/track`, {
5193
5199
  method: "POST",
5194
5200
  body: JSON.stringify({
5195
5201
  events: [await createEvent(eventProps)]
@@ -5633,6 +5639,7 @@ function EnableEditor(props) {
5633
5639
  const variationId = props.builderContextSignal.content?.testVariationId;
5634
5640
  const contentId = props.builderContextSignal.content?.id;
5635
5641
  _track({
5642
+ apiHost: props.apiHost,
5636
5643
  type: "click",
5637
5644
  canTrack: getDefaultCanTrack(props.canTrack),
5638
5645
  contentId,
@@ -5692,7 +5699,7 @@ function EnableEditor(props) {
5692
5699
  emitStateUpdate();
5693
5700
  onMount(() => {
5694
5701
  if (isBrowser()) {
5695
- if (isEditing()) {
5702
+ if (isEditing() && !props.isNestedRender) {
5696
5703
  window.addEventListener("message", processMessage);
5697
5704
  registerInsertMenu();
5698
5705
  setupBrowserForEditing({
@@ -5718,6 +5725,7 @@ function EnableEditor(props) {
5718
5725
  const contentId = props.builderContextSignal.content?.id;
5719
5726
  const apiKeyProp = props.apiKey;
5720
5727
  _track({
5728
+ apiHost: props.apiHost,
5721
5729
  type: "impression",
5722
5730
  canTrack: true,
5723
5731
  contentId,
@@ -5966,6 +5974,9 @@ function ContentComponent(props) {
5966
5974
  },
5967
5975
  get children() {
5968
5976
  return createComponent(enable_editor_default, mergeProps({
5977
+ get apiHost() {
5978
+ return props.apiHost;
5979
+ },
5969
5980
  get nonce() {
5970
5981
  return props.nonce;
5971
5982
  },
@@ -6007,6 +6018,9 @@ function ContentComponent(props) {
6007
6018
  },
6008
6019
  get trustedHosts() {
6009
6020
  return props.trustedHosts;
6021
+ },
6022
+ get isNestedRender() {
6023
+ return props.isNestedRender;
6010
6024
  }
6011
6025
  }, {
6012
6026
  setBuilderContextSignal
@@ -6139,6 +6153,9 @@ function ContentVariants(props) {
6139
6153
  children: (variant, _index) => {
6140
6154
  _index();
6141
6155
  return createComponent(content_default, mergeProps({
6156
+ get apiHost() {
6157
+ return props.apiHost;
6158
+ },
6142
6159
  get isNestedRender() {
6143
6160
  return props.isNestedRender;
6144
6161
  },
@@ -6203,6 +6220,9 @@ function ContentVariants(props) {
6203
6220
  })];
6204
6221
  }
6205
6222
  }), createComponent(content_default, mergeProps({
6223
+ get apiHost() {
6224
+ return props.apiHost;
6225
+ },
6206
6226
  get nonce() {
6207
6227
  return props.nonce;
6208
6228
  },
@@ -4254,7 +4254,7 @@ function getPreviewContent(_searchParams) {
4254
4254
  }
4255
4255
 
4256
4256
  // src/constants/sdk-version.ts
4257
- var SDK_VERSION = "2.0.25";
4257
+ var SDK_VERSION = "2.0.26";
4258
4258
 
4259
4259
  // src/helpers/sdk-headers.ts
4260
4260
  var getSdkHeaders = () => ({
@@ -4366,7 +4366,8 @@ var generateContentUrl = (options) => {
4366
4366
  cacheSeconds,
4367
4367
  staleCacheSeconds,
4368
4368
  sort,
4369
- includeUnpublished
4369
+ includeUnpublished,
4370
+ apiHost
4370
4371
  } = options;
4371
4372
  if (!apiKey) {
4372
4373
  throw new Error("Missing API key");
@@ -4375,7 +4376,8 @@ var generateContentUrl = (options) => {
4375
4376
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4376
4377
  }
4377
4378
  const noTraverse = limit !== 1;
4378
- 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}`);
4379
4381
  url.searchParams.set("apiKey", apiKey);
4380
4382
  url.searchParams.set("limit", String(limit));
4381
4383
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -4663,7 +4665,10 @@ var createEvent = async ({
4663
4665
  ownerId: apiKey
4664
4666
  }
4665
4667
  });
4666
- async function _track(eventProps) {
4668
+ async function _track({
4669
+ apiHost,
4670
+ ...eventProps
4671
+ }) {
4667
4672
  if (!eventProps.apiKey) {
4668
4673
  logger.error("Missing API key for track call. Please provide your API key.");
4669
4674
  return;
@@ -4677,7 +4682,8 @@ async function _track(eventProps) {
4677
4682
  if (!(isBrowser() || TARGET === "reactNative")) {
4678
4683
  return;
4679
4684
  }
4680
- return fetch(`https://cdn.builder.io/api/v1/track`, {
4685
+ const baseUrl = apiHost || "https://cdn.builder.io";
4686
+ return fetch(`${baseUrl}/api/v1/track`, {
4681
4687
  method: "POST",
4682
4688
  body: JSON.stringify({
4683
4689
  events: [await createEvent(eventProps)]
@@ -5120,6 +5126,7 @@ function EnableEditor(props) {
5120
5126
  const variationId = props.builderContextSignal.content?.testVariationId;
5121
5127
  const contentId = props.builderContextSignal.content?.id;
5122
5128
  _track({
5129
+ apiHost: props.apiHost,
5123
5130
  type: "click",
5124
5131
  canTrack: getDefaultCanTrack(props.canTrack),
5125
5132
  contentId,
@@ -5189,7 +5196,7 @@ function EnableEditor(props) {
5189
5196
  emitStateUpdate();
5190
5197
  onMount6(() => {
5191
5198
  if (isBrowser()) {
5192
- if (isEditing()) {
5199
+ if (isEditing() && !props.isNestedRender) {
5193
5200
  window.addEventListener("message", processMessage);
5194
5201
  registerInsertMenu();
5195
5202
  setupBrowserForEditing({
@@ -5220,6 +5227,7 @@ function EnableEditor(props) {
5220
5227
  const contentId = props.builderContextSignal.content?.id;
5221
5228
  const apiKeyProp = props.apiKey;
5222
5229
  _track({
5230
+ apiHost: props.apiHost,
5223
5231
  type: "impression",
5224
5232
  canTrack: true,
5225
5233
  contentId,
@@ -5459,6 +5467,7 @@ function ContentComponent(props) {
5459
5467
  registeredComponents: registeredComponents()
5460
5468
  }}
5461
5469
  ><Enable_editor_default
5470
+ apiHost={props.apiHost}
5462
5471
  nonce={props.nonce}
5463
5472
  content={props.content}
5464
5473
  data={props.data}
@@ -5473,6 +5482,7 @@ function ContentComponent(props) {
5473
5482
  contentWrapper={props.contentWrapper}
5474
5483
  contentWrapperProps={props.contentWrapperProps}
5475
5484
  trustedHosts={props.trustedHosts}
5485
+ isNestedRender={props.isNestedRender}
5476
5486
  {...{
5477
5487
  setBuilderContextSignal
5478
5488
  }}
@@ -5551,6 +5561,7 @@ function ContentVariants(props) {
5551
5561
  <For9 each={getVariants(props.content)}>{(variant, _index) => {
5552
5562
  const index = _index();
5553
5563
  return <Content_default
5564
+ apiHost={props.apiHost}
5554
5565
  isNestedRender={props.isNestedRender}
5555
5566
  key={variant.testVariationId}
5556
5567
  nonce={props.nonce}
@@ -5577,6 +5588,7 @@ function ContentVariants(props) {
5577
5588
  }}</For9>
5578
5589
  </Show15>
5579
5590
  <Content_default
5591
+ apiHost={props.apiHost}
5580
5592
  nonce={props.nonce}
5581
5593
  isNestedRender={props.isNestedRender}
5582
5594
  {...{}}
@@ -4756,7 +4756,7 @@ function getPreviewContent(_searchParams) {
4756
4756
  }
4757
4757
 
4758
4758
  // src/constants/sdk-version.ts
4759
- var SDK_VERSION = "2.0.25";
4759
+ var SDK_VERSION = "2.0.26";
4760
4760
 
4761
4761
  // src/helpers/sdk-headers.ts
4762
4762
  var getSdkHeaders = () => ({
@@ -4866,7 +4866,8 @@ var generateContentUrl = (options) => {
4866
4866
  cacheSeconds,
4867
4867
  staleCacheSeconds,
4868
4868
  sort,
4869
- includeUnpublished
4869
+ includeUnpublished,
4870
+ apiHost
4870
4871
  } = options;
4871
4872
  if (!apiKey) {
4872
4873
  throw new Error("Missing API key");
@@ -4875,7 +4876,8 @@ var generateContentUrl = (options) => {
4875
4876
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4876
4877
  }
4877
4878
  const noTraverse = limit !== 1;
4878
- 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}`);
4879
4881
  url.searchParams.set("apiKey", apiKey);
4880
4882
  url.searchParams.set("limit", String(limit));
4881
4883
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -5161,7 +5163,10 @@ var createEvent = async ({
5161
5163
  ownerId: apiKey
5162
5164
  }
5163
5165
  });
5164
- async function _track(eventProps) {
5166
+ async function _track({
5167
+ apiHost,
5168
+ ...eventProps
5169
+ }) {
5165
5170
  if (!eventProps.apiKey) {
5166
5171
  logger.error("Missing API key for track call. Please provide your API key.");
5167
5172
  return;
@@ -5175,7 +5180,8 @@ async function _track(eventProps) {
5175
5180
  if (!(isBrowser() || TARGET === "reactNative")) {
5176
5181
  return;
5177
5182
  }
5178
- return fetch(`https://cdn.builder.io/api/v1/track`, {
5183
+ const baseUrl = apiHost || "https://cdn.builder.io";
5184
+ return fetch(`${baseUrl}/api/v1/track`, {
5179
5185
  method: "POST",
5180
5186
  body: JSON.stringify({
5181
5187
  events: [await createEvent(eventProps)]
@@ -5617,6 +5623,7 @@ function EnableEditor(props) {
5617
5623
  const variationId = props.builderContextSignal.content?.testVariationId;
5618
5624
  const contentId = props.builderContextSignal.content?.id;
5619
5625
  _track({
5626
+ apiHost: props.apiHost,
5620
5627
  type: "click",
5621
5628
  canTrack: getDefaultCanTrack(props.canTrack),
5622
5629
  contentId,
@@ -5675,7 +5682,7 @@ function EnableEditor(props) {
5675
5682
  emitStateUpdate();
5676
5683
  onMount(() => {
5677
5684
  if (isBrowser()) {
5678
- if (isEditing()) {
5685
+ if (isEditing() && !props.isNestedRender) {
5679
5686
  window.addEventListener("message", processMessage);
5680
5687
  registerInsertMenu();
5681
5688
  setupBrowserForEditing({
@@ -5701,6 +5708,7 @@ function EnableEditor(props) {
5701
5708
  const contentId = props.builderContextSignal.content?.id;
5702
5709
  const apiKeyProp = props.apiKey;
5703
5710
  _track({
5711
+ apiHost: props.apiHost,
5704
5712
  type: "impression",
5705
5713
  canTrack: true,
5706
5714
  contentId,
@@ -5949,6 +5957,9 @@ function ContentComponent(props) {
5949
5957
  },
5950
5958
  get children() {
5951
5959
  return createComponent(enable_editor_default, mergeProps({
5960
+ get apiHost() {
5961
+ return props.apiHost;
5962
+ },
5952
5963
  get nonce() {
5953
5964
  return props.nonce;
5954
5965
  },
@@ -5990,6 +6001,9 @@ function ContentComponent(props) {
5990
6001
  },
5991
6002
  get trustedHosts() {
5992
6003
  return props.trustedHosts;
6004
+ },
6005
+ get isNestedRender() {
6006
+ return props.isNestedRender;
5993
6007
  }
5994
6008
  }, {
5995
6009
  setBuilderContextSignal
@@ -6122,6 +6136,9 @@ function ContentVariants(props) {
6122
6136
  children: (variant, _index) => {
6123
6137
  _index();
6124
6138
  return createComponent(content_default, mergeProps({
6139
+ get apiHost() {
6140
+ return props.apiHost;
6141
+ },
6125
6142
  get isNestedRender() {
6126
6143
  return props.isNestedRender;
6127
6144
  },
@@ -6186,6 +6203,9 @@ function ContentVariants(props) {
6186
6203
  })];
6187
6204
  }
6188
6205
  }), createComponent(content_default, mergeProps({
6206
+ get apiHost() {
6207
+ return props.apiHost;
6208
+ },
6189
6209
  get nonce() {
6190
6210
  return props.nonce;
6191
6211
  },
@@ -4244,7 +4244,7 @@ function getPreviewContent(_searchParams) {
4244
4244
  }
4245
4245
 
4246
4246
  // src/constants/sdk-version.ts
4247
- var SDK_VERSION = "2.0.25";
4247
+ var SDK_VERSION = "2.0.26";
4248
4248
 
4249
4249
  // src/helpers/sdk-headers.ts
4250
4250
  var getSdkHeaders = () => ({
@@ -4354,7 +4354,8 @@ var generateContentUrl = (options) => {
4354
4354
  cacheSeconds,
4355
4355
  staleCacheSeconds,
4356
4356
  sort,
4357
- includeUnpublished
4357
+ includeUnpublished,
4358
+ apiHost
4358
4359
  } = options;
4359
4360
  if (!apiKey) {
4360
4361
  throw new Error("Missing API key");
@@ -4363,7 +4364,8 @@ var generateContentUrl = (options) => {
4363
4364
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4364
4365
  }
4365
4366
  const noTraverse = limit !== 1;
4366
- 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}`);
4367
4369
  url.searchParams.set("apiKey", apiKey);
4368
4370
  url.searchParams.set("limit", String(limit));
4369
4371
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -4649,7 +4651,10 @@ var createEvent = async ({
4649
4651
  ownerId: apiKey
4650
4652
  }
4651
4653
  });
4652
- async function _track(eventProps) {
4654
+ async function _track({
4655
+ apiHost,
4656
+ ...eventProps
4657
+ }) {
4653
4658
  if (!eventProps.apiKey) {
4654
4659
  logger.error("Missing API key for track call. Please provide your API key.");
4655
4660
  return;
@@ -4663,7 +4668,8 @@ async function _track(eventProps) {
4663
4668
  if (!(isBrowser() || TARGET === "reactNative")) {
4664
4669
  return;
4665
4670
  }
4666
- return fetch(`https://cdn.builder.io/api/v1/track`, {
4671
+ const baseUrl = apiHost || "https://cdn.builder.io";
4672
+ return fetch(`${baseUrl}/api/v1/track`, {
4667
4673
  method: "POST",
4668
4674
  body: JSON.stringify({
4669
4675
  events: [await createEvent(eventProps)]
@@ -5104,6 +5110,7 @@ function EnableEditor(props) {
5104
5110
  const variationId = props.builderContextSignal.content?.testVariationId;
5105
5111
  const contentId = props.builderContextSignal.content?.id;
5106
5112
  _track({
5113
+ apiHost: props.apiHost,
5107
5114
  type: "click",
5108
5115
  canTrack: getDefaultCanTrack(props.canTrack),
5109
5116
  contentId,
@@ -5172,7 +5179,7 @@ function EnableEditor(props) {
5172
5179
  emitStateUpdate();
5173
5180
  onMount6(() => {
5174
5181
  if (isBrowser()) {
5175
- if (isEditing()) {
5182
+ if (isEditing() && !props.isNestedRender) {
5176
5183
  window.addEventListener("message", processMessage);
5177
5184
  registerInsertMenu();
5178
5185
  setupBrowserForEditing({
@@ -5203,6 +5210,7 @@ function EnableEditor(props) {
5203
5210
  const contentId = props.builderContextSignal.content?.id;
5204
5211
  const apiKeyProp = props.apiKey;
5205
5212
  _track({
5213
+ apiHost: props.apiHost,
5206
5214
  type: "impression",
5207
5215
  canTrack: true,
5208
5216
  contentId,
@@ -5442,6 +5450,7 @@ function ContentComponent(props) {
5442
5450
  registeredComponents: registeredComponents()
5443
5451
  }}
5444
5452
  ><Enable_editor_default
5453
+ apiHost={props.apiHost}
5445
5454
  nonce={props.nonce}
5446
5455
  content={props.content}
5447
5456
  data={props.data}
@@ -5456,6 +5465,7 @@ function ContentComponent(props) {
5456
5465
  contentWrapper={props.contentWrapper}
5457
5466
  contentWrapperProps={props.contentWrapperProps}
5458
5467
  trustedHosts={props.trustedHosts}
5468
+ isNestedRender={props.isNestedRender}
5459
5469
  {...{
5460
5470
  setBuilderContextSignal
5461
5471
  }}
@@ -5534,6 +5544,7 @@ function ContentVariants(props) {
5534
5544
  <For9 each={getVariants(props.content)}>{(variant, _index) => {
5535
5545
  const index = _index();
5536
5546
  return <Content_default
5547
+ apiHost={props.apiHost}
5537
5548
  isNestedRender={props.isNestedRender}
5538
5549
  key={variant.testVariationId}
5539
5550
  nonce={props.nonce}
@@ -5560,6 +5571,7 @@ function ContentVariants(props) {
5560
5571
  }}</For9>
5561
5572
  </Show15>
5562
5573
  <Content_default
5574
+ apiHost={props.apiHost}
5563
5575
  nonce={props.nonce}
5564
5576
  isNestedRender={props.isNestedRender}
5565
5577
  {...{}}
package/lib/edge/dev.js CHANGED
@@ -7949,7 +7949,7 @@ function getPreviewContent(_searchParams) {
7949
7949
  }
7950
7950
 
7951
7951
  // src/constants/sdk-version.ts
7952
- var SDK_VERSION = "2.0.25";
7952
+ var SDK_VERSION = "2.0.26";
7953
7953
 
7954
7954
  // src/helpers/sdk-headers.ts
7955
7955
  var getSdkHeaders = () => ({
@@ -8061,7 +8061,8 @@ var generateContentUrl = (options) => {
8061
8061
  cacheSeconds,
8062
8062
  staleCacheSeconds,
8063
8063
  sort,
8064
- includeUnpublished
8064
+ includeUnpublished,
8065
+ apiHost
8065
8066
  } = options;
8066
8067
  if (!apiKey) {
8067
8068
  throw new Error("Missing API key");
@@ -8070,7 +8071,8 @@ var generateContentUrl = (options) => {
8070
8071
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
8071
8072
  }
8072
8073
  const noTraverse = limit !== 1;
8073
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
8074
+ const baseUrl = apiHost || "https://cdn.builder.io";
8075
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
8074
8076
  url.searchParams.set("apiKey", apiKey);
8075
8077
  url.searchParams.set("limit", String(limit));
8076
8078
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -8358,7 +8360,10 @@ var createEvent = async ({
8358
8360
  ownerId: apiKey
8359
8361
  }
8360
8362
  });
8361
- async function _track(eventProps) {
8363
+ async function _track({
8364
+ apiHost,
8365
+ ...eventProps
8366
+ }) {
8362
8367
  if (!eventProps.apiKey) {
8363
8368
  logger.error("Missing API key for track call. Please provide your API key.");
8364
8369
  return;
@@ -8372,7 +8377,8 @@ async function _track(eventProps) {
8372
8377
  if (!(isBrowser() || TARGET === "reactNative")) {
8373
8378
  return;
8374
8379
  }
8375
- return fetch(`https://cdn.builder.io/api/v1/track`, {
8380
+ const baseUrl = apiHost || "https://cdn.builder.io";
8381
+ return fetch(`${baseUrl}/api/v1/track`, {
8376
8382
  method: "POST",
8377
8383
  body: JSON.stringify({
8378
8384
  events: [await createEvent(eventProps)]
@@ -8816,6 +8822,7 @@ function EnableEditor(props) {
8816
8822
  const variationId = props.builderContextSignal.content?.testVariationId;
8817
8823
  const contentId = props.builderContextSignal.content?.id;
8818
8824
  _track({
8825
+ apiHost: props.apiHost,
8819
8826
  type: "click",
8820
8827
  canTrack: getDefaultCanTrack(props.canTrack),
8821
8828
  contentId,
@@ -8875,7 +8882,7 @@ function EnableEditor(props) {
8875
8882
  emitStateUpdate();
8876
8883
  onMount(() => {
8877
8884
  if (isBrowser()) {
8878
- if (isEditing()) {
8885
+ if (isEditing() && !props.isNestedRender) {
8879
8886
  window.addEventListener("message", processMessage);
8880
8887
  registerInsertMenu();
8881
8888
  setupBrowserForEditing({
@@ -8901,6 +8908,7 @@ function EnableEditor(props) {
8901
8908
  const contentId = props.builderContextSignal.content?.id;
8902
8909
  const apiKeyProp = props.apiKey;
8903
8910
  _track({
8911
+ apiHost: props.apiHost,
8904
8912
  type: "impression",
8905
8913
  canTrack: true,
8906
8914
  contentId,
@@ -9149,6 +9157,9 @@ function ContentComponent(props) {
9149
9157
  },
9150
9158
  get children() {
9151
9159
  return createComponent(enable_editor_default, mergeProps({
9160
+ get apiHost() {
9161
+ return props.apiHost;
9162
+ },
9152
9163
  get nonce() {
9153
9164
  return props.nonce;
9154
9165
  },
@@ -9190,6 +9201,9 @@ function ContentComponent(props) {
9190
9201
  },
9191
9202
  get trustedHosts() {
9192
9203
  return props.trustedHosts;
9204
+ },
9205
+ get isNestedRender() {
9206
+ return props.isNestedRender;
9193
9207
  }
9194
9208
  }, {
9195
9209
  setBuilderContextSignal
@@ -9322,6 +9336,9 @@ function ContentVariants(props) {
9322
9336
  children: (variant, _index) => {
9323
9337
  _index();
9324
9338
  return createComponent(content_default, mergeProps({
9339
+ get apiHost() {
9340
+ return props.apiHost;
9341
+ },
9325
9342
  get isNestedRender() {
9326
9343
  return props.isNestedRender;
9327
9344
  },
@@ -9386,6 +9403,9 @@ function ContentVariants(props) {
9386
9403
  })];
9387
9404
  }
9388
9405
  }), createComponent(content_default, mergeProps({
9406
+ get apiHost() {
9407
+ return props.apiHost;
9408
+ },
9389
9409
  get nonce() {
9390
9410
  return props.nonce;
9391
9411
  },
package/lib/edge/dev.jsx CHANGED
@@ -7439,7 +7439,7 @@ function getPreviewContent(_searchParams) {
7439
7439
  }
7440
7440
 
7441
7441
  // src/constants/sdk-version.ts
7442
- var SDK_VERSION = "2.0.25";
7442
+ var SDK_VERSION = "2.0.26";
7443
7443
 
7444
7444
  // src/helpers/sdk-headers.ts
7445
7445
  var getSdkHeaders = () => ({
@@ -7551,7 +7551,8 @@ var generateContentUrl = (options) => {
7551
7551
  cacheSeconds,
7552
7552
  staleCacheSeconds,
7553
7553
  sort,
7554
- includeUnpublished
7554
+ includeUnpublished,
7555
+ apiHost
7555
7556
  } = options;
7556
7557
  if (!apiKey) {
7557
7558
  throw new Error("Missing API key");
@@ -7560,7 +7561,8 @@ var generateContentUrl = (options) => {
7560
7561
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
7561
7562
  }
7562
7563
  const noTraverse = limit !== 1;
7563
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
7564
+ const baseUrl = apiHost || "https://cdn.builder.io";
7565
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
7564
7566
  url.searchParams.set("apiKey", apiKey);
7565
7567
  url.searchParams.set("limit", String(limit));
7566
7568
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -7848,7 +7850,10 @@ var createEvent = async ({
7848
7850
  ownerId: apiKey
7849
7851
  }
7850
7852
  });
7851
- async function _track(eventProps) {
7853
+ async function _track({
7854
+ apiHost,
7855
+ ...eventProps
7856
+ }) {
7852
7857
  if (!eventProps.apiKey) {
7853
7858
  logger.error("Missing API key for track call. Please provide your API key.");
7854
7859
  return;
@@ -7862,7 +7867,8 @@ async function _track(eventProps) {
7862
7867
  if (!(isBrowser() || TARGET === "reactNative")) {
7863
7868
  return;
7864
7869
  }
7865
- return fetch(`https://cdn.builder.io/api/v1/track`, {
7870
+ const baseUrl = apiHost || "https://cdn.builder.io";
7871
+ return fetch(`${baseUrl}/api/v1/track`, {
7866
7872
  method: "POST",
7867
7873
  body: JSON.stringify({
7868
7874
  events: [await createEvent(eventProps)]
@@ -8305,6 +8311,7 @@ function EnableEditor(props) {
8305
8311
  const variationId = props.builderContextSignal.content?.testVariationId;
8306
8312
  const contentId = props.builderContextSignal.content?.id;
8307
8313
  _track({
8314
+ apiHost: props.apiHost,
8308
8315
  type: "click",
8309
8316
  canTrack: getDefaultCanTrack(props.canTrack),
8310
8317
  contentId,
@@ -8374,7 +8381,7 @@ function EnableEditor(props) {
8374
8381
  emitStateUpdate();
8375
8382
  onMount6(() => {
8376
8383
  if (isBrowser()) {
8377
- if (isEditing()) {
8384
+ if (isEditing() && !props.isNestedRender) {
8378
8385
  window.addEventListener("message", processMessage);
8379
8386
  registerInsertMenu();
8380
8387
  setupBrowserForEditing({
@@ -8405,6 +8412,7 @@ function EnableEditor(props) {
8405
8412
  const contentId = props.builderContextSignal.content?.id;
8406
8413
  const apiKeyProp = props.apiKey;
8407
8414
  _track({
8415
+ apiHost: props.apiHost,
8408
8416
  type: "impression",
8409
8417
  canTrack: true,
8410
8418
  contentId,
@@ -8644,6 +8652,7 @@ function ContentComponent(props) {
8644
8652
  registeredComponents: registeredComponents()
8645
8653
  }}
8646
8654
  ><Enable_editor_default
8655
+ apiHost={props.apiHost}
8647
8656
  nonce={props.nonce}
8648
8657
  content={props.content}
8649
8658
  data={props.data}
@@ -8658,6 +8667,7 @@ function ContentComponent(props) {
8658
8667
  contentWrapper={props.contentWrapper}
8659
8668
  contentWrapperProps={props.contentWrapperProps}
8660
8669
  trustedHosts={props.trustedHosts}
8670
+ isNestedRender={props.isNestedRender}
8661
8671
  {...{
8662
8672
  setBuilderContextSignal
8663
8673
  }}
@@ -8736,6 +8746,7 @@ function ContentVariants(props) {
8736
8746
  <For9 each={getVariants(props.content)}>{(variant, _index) => {
8737
8747
  const index = _index();
8738
8748
  return <Content_default
8749
+ apiHost={props.apiHost}
8739
8750
  isNestedRender={props.isNestedRender}
8740
8751
  key={variant.testVariationId}
8741
8752
  nonce={props.nonce}
@@ -8762,6 +8773,7 @@ function ContentVariants(props) {
8762
8773
  }}</For9>
8763
8774
  </Show15>
8764
8775
  <Content_default
8776
+ apiHost={props.apiHost}
8765
8777
  nonce={props.nonce}
8766
8778
  isNestedRender={props.isNestedRender}
8767
8779
  {...{}}
package/lib/edge/index.js CHANGED
@@ -7939,7 +7939,7 @@ function getPreviewContent(_searchParams) {
7939
7939
  }
7940
7940
 
7941
7941
  // src/constants/sdk-version.ts
7942
- var SDK_VERSION = "2.0.25";
7942
+ var SDK_VERSION = "2.0.26";
7943
7943
 
7944
7944
  // src/helpers/sdk-headers.ts
7945
7945
  var getSdkHeaders = () => ({
@@ -8049,7 +8049,8 @@ var generateContentUrl = (options) => {
8049
8049
  cacheSeconds,
8050
8050
  staleCacheSeconds,
8051
8051
  sort,
8052
- includeUnpublished
8052
+ includeUnpublished,
8053
+ apiHost
8053
8054
  } = options;
8054
8055
  if (!apiKey) {
8055
8056
  throw new Error("Missing API key");
@@ -8058,7 +8059,8 @@ var generateContentUrl = (options) => {
8058
8059
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
8059
8060
  }
8060
8061
  const noTraverse = limit !== 1;
8061
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
8062
+ const baseUrl = apiHost || "https://cdn.builder.io";
8063
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
8062
8064
  url.searchParams.set("apiKey", apiKey);
8063
8065
  url.searchParams.set("limit", String(limit));
8064
8066
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -8344,7 +8346,10 @@ var createEvent = async ({
8344
8346
  ownerId: apiKey
8345
8347
  }
8346
8348
  });
8347
- async function _track(eventProps) {
8349
+ async function _track({
8350
+ apiHost,
8351
+ ...eventProps
8352
+ }) {
8348
8353
  if (!eventProps.apiKey) {
8349
8354
  logger.error("Missing API key for track call. Please provide your API key.");
8350
8355
  return;
@@ -8358,7 +8363,8 @@ async function _track(eventProps) {
8358
8363
  if (!(isBrowser() || TARGET === "reactNative")) {
8359
8364
  return;
8360
8365
  }
8361
- return fetch(`https://cdn.builder.io/api/v1/track`, {
8366
+ const baseUrl = apiHost || "https://cdn.builder.io";
8367
+ return fetch(`${baseUrl}/api/v1/track`, {
8362
8368
  method: "POST",
8363
8369
  body: JSON.stringify({
8364
8370
  events: [await createEvent(eventProps)]
@@ -8800,6 +8806,7 @@ function EnableEditor(props) {
8800
8806
  const variationId = props.builderContextSignal.content?.testVariationId;
8801
8807
  const contentId = props.builderContextSignal.content?.id;
8802
8808
  _track({
8809
+ apiHost: props.apiHost,
8803
8810
  type: "click",
8804
8811
  canTrack: getDefaultCanTrack(props.canTrack),
8805
8812
  contentId,
@@ -8858,7 +8865,7 @@ function EnableEditor(props) {
8858
8865
  emitStateUpdate();
8859
8866
  onMount(() => {
8860
8867
  if (isBrowser()) {
8861
- if (isEditing()) {
8868
+ if (isEditing() && !props.isNestedRender) {
8862
8869
  window.addEventListener("message", processMessage);
8863
8870
  registerInsertMenu();
8864
8871
  setupBrowserForEditing({
@@ -8884,6 +8891,7 @@ function EnableEditor(props) {
8884
8891
  const contentId = props.builderContextSignal.content?.id;
8885
8892
  const apiKeyProp = props.apiKey;
8886
8893
  _track({
8894
+ apiHost: props.apiHost,
8887
8895
  type: "impression",
8888
8896
  canTrack: true,
8889
8897
  contentId,
@@ -9132,6 +9140,9 @@ function ContentComponent(props) {
9132
9140
  },
9133
9141
  get children() {
9134
9142
  return createComponent(enable_editor_default, mergeProps({
9143
+ get apiHost() {
9144
+ return props.apiHost;
9145
+ },
9135
9146
  get nonce() {
9136
9147
  return props.nonce;
9137
9148
  },
@@ -9173,6 +9184,9 @@ function ContentComponent(props) {
9173
9184
  },
9174
9185
  get trustedHosts() {
9175
9186
  return props.trustedHosts;
9187
+ },
9188
+ get isNestedRender() {
9189
+ return props.isNestedRender;
9176
9190
  }
9177
9191
  }, {
9178
9192
  setBuilderContextSignal
@@ -9305,6 +9319,9 @@ function ContentVariants(props) {
9305
9319
  children: (variant, _index) => {
9306
9320
  _index();
9307
9321
  return createComponent(content_default, mergeProps({
9322
+ get apiHost() {
9323
+ return props.apiHost;
9324
+ },
9308
9325
  get isNestedRender() {
9309
9326
  return props.isNestedRender;
9310
9327
  },
@@ -9369,6 +9386,9 @@ function ContentVariants(props) {
9369
9386
  })];
9370
9387
  }
9371
9388
  }), createComponent(content_default, mergeProps({
9389
+ get apiHost() {
9390
+ return props.apiHost;
9391
+ },
9372
9392
  get nonce() {
9373
9393
  return props.nonce;
9374
9394
  },
@@ -7429,7 +7429,7 @@ function getPreviewContent(_searchParams) {
7429
7429
  }
7430
7430
 
7431
7431
  // src/constants/sdk-version.ts
7432
- var SDK_VERSION = "2.0.25";
7432
+ var SDK_VERSION = "2.0.26";
7433
7433
 
7434
7434
  // src/helpers/sdk-headers.ts
7435
7435
  var getSdkHeaders = () => ({
@@ -7539,7 +7539,8 @@ var generateContentUrl = (options) => {
7539
7539
  cacheSeconds,
7540
7540
  staleCacheSeconds,
7541
7541
  sort,
7542
- includeUnpublished
7542
+ includeUnpublished,
7543
+ apiHost
7543
7544
  } = options;
7544
7545
  if (!apiKey) {
7545
7546
  throw new Error("Missing API key");
@@ -7548,7 +7549,8 @@ var generateContentUrl = (options) => {
7548
7549
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
7549
7550
  }
7550
7551
  const noTraverse = limit !== 1;
7551
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
7552
+ const baseUrl = apiHost || "https://cdn.builder.io";
7553
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
7552
7554
  url.searchParams.set("apiKey", apiKey);
7553
7555
  url.searchParams.set("limit", String(limit));
7554
7556
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -7834,7 +7836,10 @@ var createEvent = async ({
7834
7836
  ownerId: apiKey
7835
7837
  }
7836
7838
  });
7837
- async function _track(eventProps) {
7839
+ async function _track({
7840
+ apiHost,
7841
+ ...eventProps
7842
+ }) {
7838
7843
  if (!eventProps.apiKey) {
7839
7844
  logger.error("Missing API key for track call. Please provide your API key.");
7840
7845
  return;
@@ -7848,7 +7853,8 @@ async function _track(eventProps) {
7848
7853
  if (!(isBrowser() || TARGET === "reactNative")) {
7849
7854
  return;
7850
7855
  }
7851
- return fetch(`https://cdn.builder.io/api/v1/track`, {
7856
+ const baseUrl = apiHost || "https://cdn.builder.io";
7857
+ return fetch(`${baseUrl}/api/v1/track`, {
7852
7858
  method: "POST",
7853
7859
  body: JSON.stringify({
7854
7860
  events: [await createEvent(eventProps)]
@@ -8289,6 +8295,7 @@ function EnableEditor(props) {
8289
8295
  const variationId = props.builderContextSignal.content?.testVariationId;
8290
8296
  const contentId = props.builderContextSignal.content?.id;
8291
8297
  _track({
8298
+ apiHost: props.apiHost,
8292
8299
  type: "click",
8293
8300
  canTrack: getDefaultCanTrack(props.canTrack),
8294
8301
  contentId,
@@ -8357,7 +8364,7 @@ function EnableEditor(props) {
8357
8364
  emitStateUpdate();
8358
8365
  onMount6(() => {
8359
8366
  if (isBrowser()) {
8360
- if (isEditing()) {
8367
+ if (isEditing() && !props.isNestedRender) {
8361
8368
  window.addEventListener("message", processMessage);
8362
8369
  registerInsertMenu();
8363
8370
  setupBrowserForEditing({
@@ -8388,6 +8395,7 @@ function EnableEditor(props) {
8388
8395
  const contentId = props.builderContextSignal.content?.id;
8389
8396
  const apiKeyProp = props.apiKey;
8390
8397
  _track({
8398
+ apiHost: props.apiHost,
8391
8399
  type: "impression",
8392
8400
  canTrack: true,
8393
8401
  contentId,
@@ -8627,6 +8635,7 @@ function ContentComponent(props) {
8627
8635
  registeredComponents: registeredComponents()
8628
8636
  }}
8629
8637
  ><Enable_editor_default
8638
+ apiHost={props.apiHost}
8630
8639
  nonce={props.nonce}
8631
8640
  content={props.content}
8632
8641
  data={props.data}
@@ -8641,6 +8650,7 @@ function ContentComponent(props) {
8641
8650
  contentWrapper={props.contentWrapper}
8642
8651
  contentWrapperProps={props.contentWrapperProps}
8643
8652
  trustedHosts={props.trustedHosts}
8653
+ isNestedRender={props.isNestedRender}
8644
8654
  {...{
8645
8655
  setBuilderContextSignal
8646
8656
  }}
@@ -8719,6 +8729,7 @@ function ContentVariants(props) {
8719
8729
  <For9 each={getVariants(props.content)}>{(variant, _index) => {
8720
8730
  const index = _index();
8721
8731
  return <Content_default
8732
+ apiHost={props.apiHost}
8722
8733
  isNestedRender={props.isNestedRender}
8723
8734
  key={variant.testVariationId}
8724
8735
  nonce={props.nonce}
@@ -8745,6 +8756,7 @@ function ContentVariants(props) {
8745
8756
  }}</For9>
8746
8757
  </Show15>
8747
8758
  <Content_default
8759
+ apiHost={props.apiHost}
8748
8760
  nonce={props.nonce}
8749
8761
  isNestedRender={props.isNestedRender}
8750
8762
  {...{}}
package/lib/node/dev.js CHANGED
@@ -4936,7 +4936,7 @@ function getPreviewContent(_searchParams) {
4936
4936
  }
4937
4937
 
4938
4938
  // src/constants/sdk-version.ts
4939
- var SDK_VERSION = "2.0.25";
4939
+ var SDK_VERSION = "2.0.26";
4940
4940
 
4941
4941
  // src/helpers/sdk-headers.ts
4942
4942
  var getSdkHeaders = () => ({
@@ -5048,7 +5048,8 @@ var generateContentUrl = (options) => {
5048
5048
  cacheSeconds,
5049
5049
  staleCacheSeconds,
5050
5050
  sort,
5051
- includeUnpublished
5051
+ includeUnpublished,
5052
+ apiHost
5052
5053
  } = options;
5053
5054
  if (!apiKey) {
5054
5055
  throw new Error("Missing API key");
@@ -5057,7 +5058,8 @@ var generateContentUrl = (options) => {
5057
5058
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
5058
5059
  }
5059
5060
  const noTraverse = limit !== 1;
5060
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
5061
+ const baseUrl = apiHost || "https://cdn.builder.io";
5062
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
5061
5063
  url.searchParams.set("apiKey", apiKey);
5062
5064
  url.searchParams.set("limit", String(limit));
5063
5065
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -5345,7 +5347,10 @@ var createEvent = async ({
5345
5347
  ownerId: apiKey
5346
5348
  }
5347
5349
  });
5348
- async function _track(eventProps) {
5350
+ async function _track({
5351
+ apiHost,
5352
+ ...eventProps
5353
+ }) {
5349
5354
  if (!eventProps.apiKey) {
5350
5355
  logger.error("Missing API key for track call. Please provide your API key.");
5351
5356
  return;
@@ -5359,7 +5364,8 @@ async function _track(eventProps) {
5359
5364
  if (!(isBrowser() || TARGET === "reactNative")) {
5360
5365
  return;
5361
5366
  }
5362
- return fetch(`https://cdn.builder.io/api/v1/track`, {
5367
+ const baseUrl = apiHost || "https://cdn.builder.io";
5368
+ return fetch(`${baseUrl}/api/v1/track`, {
5363
5369
  method: "POST",
5364
5370
  body: JSON.stringify({
5365
5371
  events: [await createEvent(eventProps)]
@@ -5803,6 +5809,7 @@ function EnableEditor(props) {
5803
5809
  const variationId = props.builderContextSignal.content?.testVariationId;
5804
5810
  const contentId = props.builderContextSignal.content?.id;
5805
5811
  _track({
5812
+ apiHost: props.apiHost,
5806
5813
  type: "click",
5807
5814
  canTrack: getDefaultCanTrack(props.canTrack),
5808
5815
  contentId,
@@ -5862,7 +5869,7 @@ function EnableEditor(props) {
5862
5869
  emitStateUpdate();
5863
5870
  onMount(() => {
5864
5871
  if (isBrowser()) {
5865
- if (isEditing()) {
5872
+ if (isEditing() && !props.isNestedRender) {
5866
5873
  window.addEventListener("message", processMessage);
5867
5874
  registerInsertMenu();
5868
5875
  setupBrowserForEditing({
@@ -5888,6 +5895,7 @@ function EnableEditor(props) {
5888
5895
  const contentId = props.builderContextSignal.content?.id;
5889
5896
  const apiKeyProp = props.apiKey;
5890
5897
  _track({
5898
+ apiHost: props.apiHost,
5891
5899
  type: "impression",
5892
5900
  canTrack: true,
5893
5901
  contentId,
@@ -6136,6 +6144,9 @@ function ContentComponent(props) {
6136
6144
  },
6137
6145
  get children() {
6138
6146
  return createComponent(enable_editor_default, mergeProps({
6147
+ get apiHost() {
6148
+ return props.apiHost;
6149
+ },
6139
6150
  get nonce() {
6140
6151
  return props.nonce;
6141
6152
  },
@@ -6177,6 +6188,9 @@ function ContentComponent(props) {
6177
6188
  },
6178
6189
  get trustedHosts() {
6179
6190
  return props.trustedHosts;
6191
+ },
6192
+ get isNestedRender() {
6193
+ return props.isNestedRender;
6180
6194
  }
6181
6195
  }, {
6182
6196
  setBuilderContextSignal
@@ -6309,6 +6323,9 @@ function ContentVariants(props) {
6309
6323
  children: (variant, _index) => {
6310
6324
  _index();
6311
6325
  return createComponent(content_default, mergeProps({
6326
+ get apiHost() {
6327
+ return props.apiHost;
6328
+ },
6312
6329
  get isNestedRender() {
6313
6330
  return props.isNestedRender;
6314
6331
  },
@@ -6373,6 +6390,9 @@ function ContentVariants(props) {
6373
6390
  })];
6374
6391
  }
6375
6392
  }), createComponent(content_default, mergeProps({
6393
+ get apiHost() {
6394
+ return props.apiHost;
6395
+ },
6376
6396
  get nonce() {
6377
6397
  return props.nonce;
6378
6398
  },
package/lib/node/dev.jsx CHANGED
@@ -4426,7 +4426,7 @@ function getPreviewContent(_searchParams) {
4426
4426
  }
4427
4427
 
4428
4428
  // src/constants/sdk-version.ts
4429
- var SDK_VERSION = "2.0.25";
4429
+ var SDK_VERSION = "2.0.26";
4430
4430
 
4431
4431
  // src/helpers/sdk-headers.ts
4432
4432
  var getSdkHeaders = () => ({
@@ -4538,7 +4538,8 @@ var generateContentUrl = (options) => {
4538
4538
  cacheSeconds,
4539
4539
  staleCacheSeconds,
4540
4540
  sort,
4541
- includeUnpublished
4541
+ includeUnpublished,
4542
+ apiHost
4542
4543
  } = options;
4543
4544
  if (!apiKey) {
4544
4545
  throw new Error("Missing API key");
@@ -4547,7 +4548,8 @@ var generateContentUrl = (options) => {
4547
4548
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4548
4549
  }
4549
4550
  const noTraverse = limit !== 1;
4550
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
4551
+ const baseUrl = apiHost || "https://cdn.builder.io";
4552
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
4551
4553
  url.searchParams.set("apiKey", apiKey);
4552
4554
  url.searchParams.set("limit", String(limit));
4553
4555
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -4835,7 +4837,10 @@ var createEvent = async ({
4835
4837
  ownerId: apiKey
4836
4838
  }
4837
4839
  });
4838
- async function _track(eventProps) {
4840
+ async function _track({
4841
+ apiHost,
4842
+ ...eventProps
4843
+ }) {
4839
4844
  if (!eventProps.apiKey) {
4840
4845
  logger.error("Missing API key for track call. Please provide your API key.");
4841
4846
  return;
@@ -4849,7 +4854,8 @@ async function _track(eventProps) {
4849
4854
  if (!(isBrowser() || TARGET === "reactNative")) {
4850
4855
  return;
4851
4856
  }
4852
- return fetch(`https://cdn.builder.io/api/v1/track`, {
4857
+ const baseUrl = apiHost || "https://cdn.builder.io";
4858
+ return fetch(`${baseUrl}/api/v1/track`, {
4853
4859
  method: "POST",
4854
4860
  body: JSON.stringify({
4855
4861
  events: [await createEvent(eventProps)]
@@ -5292,6 +5298,7 @@ function EnableEditor(props) {
5292
5298
  const variationId = props.builderContextSignal.content?.testVariationId;
5293
5299
  const contentId = props.builderContextSignal.content?.id;
5294
5300
  _track({
5301
+ apiHost: props.apiHost,
5295
5302
  type: "click",
5296
5303
  canTrack: getDefaultCanTrack(props.canTrack),
5297
5304
  contentId,
@@ -5361,7 +5368,7 @@ function EnableEditor(props) {
5361
5368
  emitStateUpdate();
5362
5369
  onMount6(() => {
5363
5370
  if (isBrowser()) {
5364
- if (isEditing()) {
5371
+ if (isEditing() && !props.isNestedRender) {
5365
5372
  window.addEventListener("message", processMessage);
5366
5373
  registerInsertMenu();
5367
5374
  setupBrowserForEditing({
@@ -5392,6 +5399,7 @@ function EnableEditor(props) {
5392
5399
  const contentId = props.builderContextSignal.content?.id;
5393
5400
  const apiKeyProp = props.apiKey;
5394
5401
  _track({
5402
+ apiHost: props.apiHost,
5395
5403
  type: "impression",
5396
5404
  canTrack: true,
5397
5405
  contentId,
@@ -5631,6 +5639,7 @@ function ContentComponent(props) {
5631
5639
  registeredComponents: registeredComponents()
5632
5640
  }}
5633
5641
  ><Enable_editor_default
5642
+ apiHost={props.apiHost}
5634
5643
  nonce={props.nonce}
5635
5644
  content={props.content}
5636
5645
  data={props.data}
@@ -5645,6 +5654,7 @@ function ContentComponent(props) {
5645
5654
  contentWrapper={props.contentWrapper}
5646
5655
  contentWrapperProps={props.contentWrapperProps}
5647
5656
  trustedHosts={props.trustedHosts}
5657
+ isNestedRender={props.isNestedRender}
5648
5658
  {...{
5649
5659
  setBuilderContextSignal
5650
5660
  }}
@@ -5723,6 +5733,7 @@ function ContentVariants(props) {
5723
5733
  <For9 each={getVariants(props.content)}>{(variant, _index) => {
5724
5734
  const index = _index();
5725
5735
  return <Content_default
5736
+ apiHost={props.apiHost}
5726
5737
  isNestedRender={props.isNestedRender}
5727
5738
  key={variant.testVariationId}
5728
5739
  nonce={props.nonce}
@@ -5749,6 +5760,7 @@ function ContentVariants(props) {
5749
5760
  }}</For9>
5750
5761
  </Show15>
5751
5762
  <Content_default
5763
+ apiHost={props.apiHost}
5752
5764
  nonce={props.nonce}
5753
5765
  isNestedRender={props.isNestedRender}
5754
5766
  {...{}}
package/lib/node/index.js CHANGED
@@ -4926,7 +4926,7 @@ function getPreviewContent(_searchParams) {
4926
4926
  }
4927
4927
 
4928
4928
  // src/constants/sdk-version.ts
4929
- var SDK_VERSION = "2.0.25";
4929
+ var SDK_VERSION = "2.0.26";
4930
4930
 
4931
4931
  // src/helpers/sdk-headers.ts
4932
4932
  var getSdkHeaders = () => ({
@@ -5036,7 +5036,8 @@ var generateContentUrl = (options) => {
5036
5036
  cacheSeconds,
5037
5037
  staleCacheSeconds,
5038
5038
  sort,
5039
- includeUnpublished
5039
+ includeUnpublished,
5040
+ apiHost
5040
5041
  } = options;
5041
5042
  if (!apiKey) {
5042
5043
  throw new Error("Missing API key");
@@ -5045,7 +5046,8 @@ var generateContentUrl = (options) => {
5045
5046
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
5046
5047
  }
5047
5048
  const noTraverse = limit !== 1;
5048
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
5049
+ const baseUrl = apiHost || "https://cdn.builder.io";
5050
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
5049
5051
  url.searchParams.set("apiKey", apiKey);
5050
5052
  url.searchParams.set("limit", String(limit));
5051
5053
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -5331,7 +5333,10 @@ var createEvent = async ({
5331
5333
  ownerId: apiKey
5332
5334
  }
5333
5335
  });
5334
- async function _track(eventProps) {
5336
+ async function _track({
5337
+ apiHost,
5338
+ ...eventProps
5339
+ }) {
5335
5340
  if (!eventProps.apiKey) {
5336
5341
  logger.error("Missing API key for track call. Please provide your API key.");
5337
5342
  return;
@@ -5345,7 +5350,8 @@ async function _track(eventProps) {
5345
5350
  if (!(isBrowser() || TARGET === "reactNative")) {
5346
5351
  return;
5347
5352
  }
5348
- return fetch(`https://cdn.builder.io/api/v1/track`, {
5353
+ const baseUrl = apiHost || "https://cdn.builder.io";
5354
+ return fetch(`${baseUrl}/api/v1/track`, {
5349
5355
  method: "POST",
5350
5356
  body: JSON.stringify({
5351
5357
  events: [await createEvent(eventProps)]
@@ -5787,6 +5793,7 @@ function EnableEditor(props) {
5787
5793
  const variationId = props.builderContextSignal.content?.testVariationId;
5788
5794
  const contentId = props.builderContextSignal.content?.id;
5789
5795
  _track({
5796
+ apiHost: props.apiHost,
5790
5797
  type: "click",
5791
5798
  canTrack: getDefaultCanTrack(props.canTrack),
5792
5799
  contentId,
@@ -5845,7 +5852,7 @@ function EnableEditor(props) {
5845
5852
  emitStateUpdate();
5846
5853
  onMount(() => {
5847
5854
  if (isBrowser()) {
5848
- if (isEditing()) {
5855
+ if (isEditing() && !props.isNestedRender) {
5849
5856
  window.addEventListener("message", processMessage);
5850
5857
  registerInsertMenu();
5851
5858
  setupBrowserForEditing({
@@ -5871,6 +5878,7 @@ function EnableEditor(props) {
5871
5878
  const contentId = props.builderContextSignal.content?.id;
5872
5879
  const apiKeyProp = props.apiKey;
5873
5880
  _track({
5881
+ apiHost: props.apiHost,
5874
5882
  type: "impression",
5875
5883
  canTrack: true,
5876
5884
  contentId,
@@ -6119,6 +6127,9 @@ function ContentComponent(props) {
6119
6127
  },
6120
6128
  get children() {
6121
6129
  return createComponent(enable_editor_default, mergeProps({
6130
+ get apiHost() {
6131
+ return props.apiHost;
6132
+ },
6122
6133
  get nonce() {
6123
6134
  return props.nonce;
6124
6135
  },
@@ -6160,6 +6171,9 @@ function ContentComponent(props) {
6160
6171
  },
6161
6172
  get trustedHosts() {
6162
6173
  return props.trustedHosts;
6174
+ },
6175
+ get isNestedRender() {
6176
+ return props.isNestedRender;
6163
6177
  }
6164
6178
  }, {
6165
6179
  setBuilderContextSignal
@@ -6292,6 +6306,9 @@ function ContentVariants(props) {
6292
6306
  children: (variant, _index) => {
6293
6307
  _index();
6294
6308
  return createComponent(content_default, mergeProps({
6309
+ get apiHost() {
6310
+ return props.apiHost;
6311
+ },
6295
6312
  get isNestedRender() {
6296
6313
  return props.isNestedRender;
6297
6314
  },
@@ -6356,6 +6373,9 @@ function ContentVariants(props) {
6356
6373
  })];
6357
6374
  }
6358
6375
  }), createComponent(content_default, mergeProps({
6376
+ get apiHost() {
6377
+ return props.apiHost;
6378
+ },
6359
6379
  get nonce() {
6360
6380
  return props.nonce;
6361
6381
  },
@@ -4416,7 +4416,7 @@ function getPreviewContent(_searchParams) {
4416
4416
  }
4417
4417
 
4418
4418
  // src/constants/sdk-version.ts
4419
- var SDK_VERSION = "2.0.25";
4419
+ var SDK_VERSION = "2.0.26";
4420
4420
 
4421
4421
  // src/helpers/sdk-headers.ts
4422
4422
  var getSdkHeaders = () => ({
@@ -4526,7 +4526,8 @@ var generateContentUrl = (options) => {
4526
4526
  cacheSeconds,
4527
4527
  staleCacheSeconds,
4528
4528
  sort,
4529
- includeUnpublished
4529
+ includeUnpublished,
4530
+ apiHost
4530
4531
  } = options;
4531
4532
  if (!apiKey) {
4532
4533
  throw new Error("Missing API key");
@@ -4535,7 +4536,8 @@ var generateContentUrl = (options) => {
4535
4536
  throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
4536
4537
  }
4537
4538
  const noTraverse = limit !== 1;
4538
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}`);
4539
+ const baseUrl = apiHost || "https://cdn.builder.io";
4540
+ const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
4539
4541
  url.searchParams.set("apiKey", apiKey);
4540
4542
  url.searchParams.set("limit", String(limit));
4541
4543
  url.searchParams.set("noTraverse", String(noTraverse));
@@ -4821,7 +4823,10 @@ var createEvent = async ({
4821
4823
  ownerId: apiKey
4822
4824
  }
4823
4825
  });
4824
- async function _track(eventProps) {
4826
+ async function _track({
4827
+ apiHost,
4828
+ ...eventProps
4829
+ }) {
4825
4830
  if (!eventProps.apiKey) {
4826
4831
  logger.error("Missing API key for track call. Please provide your API key.");
4827
4832
  return;
@@ -4835,7 +4840,8 @@ async function _track(eventProps) {
4835
4840
  if (!(isBrowser() || TARGET === "reactNative")) {
4836
4841
  return;
4837
4842
  }
4838
- return fetch(`https://cdn.builder.io/api/v1/track`, {
4843
+ const baseUrl = apiHost || "https://cdn.builder.io";
4844
+ return fetch(`${baseUrl}/api/v1/track`, {
4839
4845
  method: "POST",
4840
4846
  body: JSON.stringify({
4841
4847
  events: [await createEvent(eventProps)]
@@ -5276,6 +5282,7 @@ function EnableEditor(props) {
5276
5282
  const variationId = props.builderContextSignal.content?.testVariationId;
5277
5283
  const contentId = props.builderContextSignal.content?.id;
5278
5284
  _track({
5285
+ apiHost: props.apiHost,
5279
5286
  type: "click",
5280
5287
  canTrack: getDefaultCanTrack(props.canTrack),
5281
5288
  contentId,
@@ -5344,7 +5351,7 @@ function EnableEditor(props) {
5344
5351
  emitStateUpdate();
5345
5352
  onMount6(() => {
5346
5353
  if (isBrowser()) {
5347
- if (isEditing()) {
5354
+ if (isEditing() && !props.isNestedRender) {
5348
5355
  window.addEventListener("message", processMessage);
5349
5356
  registerInsertMenu();
5350
5357
  setupBrowserForEditing({
@@ -5375,6 +5382,7 @@ function EnableEditor(props) {
5375
5382
  const contentId = props.builderContextSignal.content?.id;
5376
5383
  const apiKeyProp = props.apiKey;
5377
5384
  _track({
5385
+ apiHost: props.apiHost,
5378
5386
  type: "impression",
5379
5387
  canTrack: true,
5380
5388
  contentId,
@@ -5614,6 +5622,7 @@ function ContentComponent(props) {
5614
5622
  registeredComponents: registeredComponents()
5615
5623
  }}
5616
5624
  ><Enable_editor_default
5625
+ apiHost={props.apiHost}
5617
5626
  nonce={props.nonce}
5618
5627
  content={props.content}
5619
5628
  data={props.data}
@@ -5628,6 +5637,7 @@ function ContentComponent(props) {
5628
5637
  contentWrapper={props.contentWrapper}
5629
5638
  contentWrapperProps={props.contentWrapperProps}
5630
5639
  trustedHosts={props.trustedHosts}
5640
+ isNestedRender={props.isNestedRender}
5631
5641
  {...{
5632
5642
  setBuilderContextSignal
5633
5643
  }}
@@ -5706,6 +5716,7 @@ function ContentVariants(props) {
5706
5716
  <For9 each={getVariants(props.content)}>{(variant, _index) => {
5707
5717
  const index = _index();
5708
5718
  return <Content_default
5719
+ apiHost={props.apiHost}
5709
5720
  isNestedRender={props.isNestedRender}
5710
5721
  key={variant.testVariationId}
5711
5722
  nonce={props.nonce}
@@ -5732,6 +5743,7 @@ function ContentVariants(props) {
5732
5743
  }}</For9>
5733
5744
  </Show15>
5734
5745
  <Content_default
5746
+ apiHost={props.apiHost}
5735
5747
  nonce={props.nonce}
5736
5748
  isNestedRender={props.isNestedRender}
5737
5749
  {...{}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "2.0.25",
3
+ "version": "2.0.26",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist",