@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 +8 -0
- package/lib/browser/dev.js +45 -10
- package/lib/browser/dev.jsx +37 -10
- package/lib/browser/index.js +45 -10
- package/lib/browser/index.jsx +37 -10
- package/lib/edge/dev.js +45 -10
- package/lib/edge/dev.jsx +37 -10
- package/lib/edge/index.js +45 -10
- package/lib/edge/index.jsx +37 -10
- package/lib/node/dev.js +45 -10
- package/lib/node/dev.jsx +37 -10
- package/lib/node/index.js +45 -10
- package/lib/node/index.jsx +37 -10
- package/package.json +1 -1
package/lib/node/dev.js
CHANGED
|
@@ -4935,6 +4935,16 @@ function getPreviewContent(_searchParams) {
|
|
|
4935
4935
|
return void 0;
|
|
4936
4936
|
}
|
|
4937
4937
|
|
|
4938
|
+
// src/constants/sdk-version.ts
|
|
4939
|
+
var SDK_VERSION = "2.0.26";
|
|
4940
|
+
|
|
4941
|
+
// src/helpers/sdk-headers.ts
|
|
4942
|
+
var getSdkHeaders = () => ({
|
|
4943
|
+
"X-Builder-SDK": TARGET,
|
|
4944
|
+
"X-Builder-SDK-GEN": "2",
|
|
4945
|
+
"X-Builder-SDK-Version": SDK_VERSION
|
|
4946
|
+
});
|
|
4947
|
+
|
|
4938
4948
|
// src/functions/get-global-this.ts
|
|
4939
4949
|
function getGlobalThis() {
|
|
4940
4950
|
if (typeof globalThis !== "undefined") {
|
|
@@ -5038,7 +5048,8 @@ var generateContentUrl = (options) => {
|
|
|
5038
5048
|
cacheSeconds,
|
|
5039
5049
|
staleCacheSeconds,
|
|
5040
5050
|
sort,
|
|
5041
|
-
includeUnpublished
|
|
5051
|
+
includeUnpublished,
|
|
5052
|
+
apiHost
|
|
5042
5053
|
} = options;
|
|
5043
5054
|
if (!apiKey) {
|
|
5044
5055
|
throw new Error("Missing API key");
|
|
@@ -5047,7 +5058,8 @@ var generateContentUrl = (options) => {
|
|
|
5047
5058
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
5048
5059
|
}
|
|
5049
5060
|
const noTraverse = limit !== 1;
|
|
5050
|
-
const
|
|
5061
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
5062
|
+
const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
|
|
5051
5063
|
url.searchParams.set("apiKey", apiKey);
|
|
5052
5064
|
url.searchParams.set("limit", String(limit));
|
|
5053
5065
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -5117,7 +5129,14 @@ async function fetchOneEntry(options) {
|
|
|
5117
5129
|
var _fetchContent = async (options) => {
|
|
5118
5130
|
const url = generateContentUrl(options);
|
|
5119
5131
|
const _fetch = options.fetch ?? fetch2;
|
|
5120
|
-
const
|
|
5132
|
+
const fetchOptions = {
|
|
5133
|
+
...options.fetchOptions,
|
|
5134
|
+
headers: {
|
|
5135
|
+
...options.fetchOptions?.headers,
|
|
5136
|
+
...getSdkHeaders()
|
|
5137
|
+
}
|
|
5138
|
+
};
|
|
5139
|
+
const res = await _fetch(url.href, fetchOptions);
|
|
5121
5140
|
const content = await res.json();
|
|
5122
5141
|
return content;
|
|
5123
5142
|
};
|
|
@@ -5328,7 +5347,10 @@ var createEvent = async ({
|
|
|
5328
5347
|
ownerId: apiKey
|
|
5329
5348
|
}
|
|
5330
5349
|
});
|
|
5331
|
-
async function _track(
|
|
5350
|
+
async function _track({
|
|
5351
|
+
apiHost,
|
|
5352
|
+
...eventProps
|
|
5353
|
+
}) {
|
|
5332
5354
|
if (!eventProps.apiKey) {
|
|
5333
5355
|
logger.error("Missing API key for track call. Please provide your API key.");
|
|
5334
5356
|
return;
|
|
@@ -5342,13 +5364,15 @@ async function _track(eventProps) {
|
|
|
5342
5364
|
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
5343
5365
|
return;
|
|
5344
5366
|
}
|
|
5345
|
-
|
|
5367
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
5368
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
5346
5369
|
method: "POST",
|
|
5347
5370
|
body: JSON.stringify({
|
|
5348
5371
|
events: [await createEvent(eventProps)]
|
|
5349
5372
|
}),
|
|
5350
5373
|
headers: {
|
|
5351
|
-
"content-type": "application/json"
|
|
5374
|
+
"content-type": "application/json",
|
|
5375
|
+
...getSdkHeaders()
|
|
5352
5376
|
},
|
|
5353
5377
|
mode: "cors"
|
|
5354
5378
|
}).catch((err) => {
|
|
@@ -5428,9 +5452,6 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5428
5452
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
5429
5453
|
}
|
|
5430
5454
|
|
|
5431
|
-
// src/constants/sdk-version.ts
|
|
5432
|
-
var SDK_VERSION = "2.0.24";
|
|
5433
|
-
|
|
5434
5455
|
// src/functions/register.ts
|
|
5435
5456
|
var registry = {};
|
|
5436
5457
|
function register(type, info) {
|
|
@@ -5788,6 +5809,7 @@ function EnableEditor(props) {
|
|
|
5788
5809
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
5789
5810
|
const contentId = props.builderContextSignal.content?.id;
|
|
5790
5811
|
_track({
|
|
5812
|
+
apiHost: props.apiHost,
|
|
5791
5813
|
type: "click",
|
|
5792
5814
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
5793
5815
|
contentId,
|
|
@@ -5847,7 +5869,7 @@ function EnableEditor(props) {
|
|
|
5847
5869
|
emitStateUpdate();
|
|
5848
5870
|
onMount(() => {
|
|
5849
5871
|
if (isBrowser()) {
|
|
5850
|
-
if (isEditing()) {
|
|
5872
|
+
if (isEditing() && !props.isNestedRender) {
|
|
5851
5873
|
window.addEventListener("message", processMessage);
|
|
5852
5874
|
registerInsertMenu();
|
|
5853
5875
|
setupBrowserForEditing({
|
|
@@ -5873,6 +5895,7 @@ function EnableEditor(props) {
|
|
|
5873
5895
|
const contentId = props.builderContextSignal.content?.id;
|
|
5874
5896
|
const apiKeyProp = props.apiKey;
|
|
5875
5897
|
_track({
|
|
5898
|
+
apiHost: props.apiHost,
|
|
5876
5899
|
type: "impression",
|
|
5877
5900
|
canTrack: true,
|
|
5878
5901
|
contentId,
|
|
@@ -6121,6 +6144,9 @@ function ContentComponent(props) {
|
|
|
6121
6144
|
},
|
|
6122
6145
|
get children() {
|
|
6123
6146
|
return createComponent(enable_editor_default, mergeProps({
|
|
6147
|
+
get apiHost() {
|
|
6148
|
+
return props.apiHost;
|
|
6149
|
+
},
|
|
6124
6150
|
get nonce() {
|
|
6125
6151
|
return props.nonce;
|
|
6126
6152
|
},
|
|
@@ -6162,6 +6188,9 @@ function ContentComponent(props) {
|
|
|
6162
6188
|
},
|
|
6163
6189
|
get trustedHosts() {
|
|
6164
6190
|
return props.trustedHosts;
|
|
6191
|
+
},
|
|
6192
|
+
get isNestedRender() {
|
|
6193
|
+
return props.isNestedRender;
|
|
6165
6194
|
}
|
|
6166
6195
|
}, {
|
|
6167
6196
|
setBuilderContextSignal
|
|
@@ -6294,6 +6323,9 @@ function ContentVariants(props) {
|
|
|
6294
6323
|
children: (variant, _index) => {
|
|
6295
6324
|
_index();
|
|
6296
6325
|
return createComponent(content_default, mergeProps({
|
|
6326
|
+
get apiHost() {
|
|
6327
|
+
return props.apiHost;
|
|
6328
|
+
},
|
|
6297
6329
|
get isNestedRender() {
|
|
6298
6330
|
return props.isNestedRender;
|
|
6299
6331
|
},
|
|
@@ -6358,6 +6390,9 @@ function ContentVariants(props) {
|
|
|
6358
6390
|
})];
|
|
6359
6391
|
}
|
|
6360
6392
|
}), createComponent(content_default, mergeProps({
|
|
6393
|
+
get apiHost() {
|
|
6394
|
+
return props.apiHost;
|
|
6395
|
+
},
|
|
6361
6396
|
get nonce() {
|
|
6362
6397
|
return props.nonce;
|
|
6363
6398
|
},
|
package/lib/node/dev.jsx
CHANGED
|
@@ -4425,6 +4425,16 @@ function getPreviewContent(_searchParams) {
|
|
|
4425
4425
|
return void 0;
|
|
4426
4426
|
}
|
|
4427
4427
|
|
|
4428
|
+
// src/constants/sdk-version.ts
|
|
4429
|
+
var SDK_VERSION = "2.0.26";
|
|
4430
|
+
|
|
4431
|
+
// src/helpers/sdk-headers.ts
|
|
4432
|
+
var getSdkHeaders = () => ({
|
|
4433
|
+
"X-Builder-SDK": TARGET,
|
|
4434
|
+
"X-Builder-SDK-GEN": "2",
|
|
4435
|
+
"X-Builder-SDK-Version": SDK_VERSION
|
|
4436
|
+
});
|
|
4437
|
+
|
|
4428
4438
|
// src/functions/get-global-this.ts
|
|
4429
4439
|
function getGlobalThis() {
|
|
4430
4440
|
if (typeof globalThis !== "undefined") {
|
|
@@ -4528,7 +4538,8 @@ var generateContentUrl = (options) => {
|
|
|
4528
4538
|
cacheSeconds,
|
|
4529
4539
|
staleCacheSeconds,
|
|
4530
4540
|
sort,
|
|
4531
|
-
includeUnpublished
|
|
4541
|
+
includeUnpublished,
|
|
4542
|
+
apiHost
|
|
4532
4543
|
} = options;
|
|
4533
4544
|
if (!apiKey) {
|
|
4534
4545
|
throw new Error("Missing API key");
|
|
@@ -4537,7 +4548,8 @@ var generateContentUrl = (options) => {
|
|
|
4537
4548
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
4538
4549
|
}
|
|
4539
4550
|
const noTraverse = limit !== 1;
|
|
4540
|
-
const
|
|
4551
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
4552
|
+
const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
|
|
4541
4553
|
url.searchParams.set("apiKey", apiKey);
|
|
4542
4554
|
url.searchParams.set("limit", String(limit));
|
|
4543
4555
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -4607,7 +4619,14 @@ async function fetchOneEntry(options) {
|
|
|
4607
4619
|
var _fetchContent = async (options) => {
|
|
4608
4620
|
const url = generateContentUrl(options);
|
|
4609
4621
|
const _fetch = options.fetch ?? fetch2;
|
|
4610
|
-
const
|
|
4622
|
+
const fetchOptions = {
|
|
4623
|
+
...options.fetchOptions,
|
|
4624
|
+
headers: {
|
|
4625
|
+
...options.fetchOptions?.headers,
|
|
4626
|
+
...getSdkHeaders()
|
|
4627
|
+
}
|
|
4628
|
+
};
|
|
4629
|
+
const res = await _fetch(url.href, fetchOptions);
|
|
4611
4630
|
const content = await res.json();
|
|
4612
4631
|
return content;
|
|
4613
4632
|
};
|
|
@@ -4818,7 +4837,10 @@ var createEvent = async ({
|
|
|
4818
4837
|
ownerId: apiKey
|
|
4819
4838
|
}
|
|
4820
4839
|
});
|
|
4821
|
-
async function _track(
|
|
4840
|
+
async function _track({
|
|
4841
|
+
apiHost,
|
|
4842
|
+
...eventProps
|
|
4843
|
+
}) {
|
|
4822
4844
|
if (!eventProps.apiKey) {
|
|
4823
4845
|
logger.error("Missing API key for track call. Please provide your API key.");
|
|
4824
4846
|
return;
|
|
@@ -4832,13 +4854,15 @@ async function _track(eventProps) {
|
|
|
4832
4854
|
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
4833
4855
|
return;
|
|
4834
4856
|
}
|
|
4835
|
-
|
|
4857
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
4858
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
4836
4859
|
method: "POST",
|
|
4837
4860
|
body: JSON.stringify({
|
|
4838
4861
|
events: [await createEvent(eventProps)]
|
|
4839
4862
|
}),
|
|
4840
4863
|
headers: {
|
|
4841
|
-
"content-type": "application/json"
|
|
4864
|
+
"content-type": "application/json",
|
|
4865
|
+
...getSdkHeaders()
|
|
4842
4866
|
},
|
|
4843
4867
|
mode: "cors"
|
|
4844
4868
|
}).catch((err) => {
|
|
@@ -4918,9 +4942,6 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4918
4942
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
4919
4943
|
}
|
|
4920
4944
|
|
|
4921
|
-
// src/constants/sdk-version.ts
|
|
4922
|
-
var SDK_VERSION = "2.0.24";
|
|
4923
|
-
|
|
4924
4945
|
// src/functions/register.ts
|
|
4925
4946
|
var registry = {};
|
|
4926
4947
|
function register(type, info) {
|
|
@@ -5277,6 +5298,7 @@ function EnableEditor(props) {
|
|
|
5277
5298
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
5278
5299
|
const contentId = props.builderContextSignal.content?.id;
|
|
5279
5300
|
_track({
|
|
5301
|
+
apiHost: props.apiHost,
|
|
5280
5302
|
type: "click",
|
|
5281
5303
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
5282
5304
|
contentId,
|
|
@@ -5346,7 +5368,7 @@ function EnableEditor(props) {
|
|
|
5346
5368
|
emitStateUpdate();
|
|
5347
5369
|
onMount6(() => {
|
|
5348
5370
|
if (isBrowser()) {
|
|
5349
|
-
if (isEditing()) {
|
|
5371
|
+
if (isEditing() && !props.isNestedRender) {
|
|
5350
5372
|
window.addEventListener("message", processMessage);
|
|
5351
5373
|
registerInsertMenu();
|
|
5352
5374
|
setupBrowserForEditing({
|
|
@@ -5377,6 +5399,7 @@ function EnableEditor(props) {
|
|
|
5377
5399
|
const contentId = props.builderContextSignal.content?.id;
|
|
5378
5400
|
const apiKeyProp = props.apiKey;
|
|
5379
5401
|
_track({
|
|
5402
|
+
apiHost: props.apiHost,
|
|
5380
5403
|
type: "impression",
|
|
5381
5404
|
canTrack: true,
|
|
5382
5405
|
contentId,
|
|
@@ -5616,6 +5639,7 @@ function ContentComponent(props) {
|
|
|
5616
5639
|
registeredComponents: registeredComponents()
|
|
5617
5640
|
}}
|
|
5618
5641
|
><Enable_editor_default
|
|
5642
|
+
apiHost={props.apiHost}
|
|
5619
5643
|
nonce={props.nonce}
|
|
5620
5644
|
content={props.content}
|
|
5621
5645
|
data={props.data}
|
|
@@ -5630,6 +5654,7 @@ function ContentComponent(props) {
|
|
|
5630
5654
|
contentWrapper={props.contentWrapper}
|
|
5631
5655
|
contentWrapperProps={props.contentWrapperProps}
|
|
5632
5656
|
trustedHosts={props.trustedHosts}
|
|
5657
|
+
isNestedRender={props.isNestedRender}
|
|
5633
5658
|
{...{
|
|
5634
5659
|
setBuilderContextSignal
|
|
5635
5660
|
}}
|
|
@@ -5708,6 +5733,7 @@ function ContentVariants(props) {
|
|
|
5708
5733
|
<For9 each={getVariants(props.content)}>{(variant, _index) => {
|
|
5709
5734
|
const index = _index();
|
|
5710
5735
|
return <Content_default
|
|
5736
|
+
apiHost={props.apiHost}
|
|
5711
5737
|
isNestedRender={props.isNestedRender}
|
|
5712
5738
|
key={variant.testVariationId}
|
|
5713
5739
|
nonce={props.nonce}
|
|
@@ -5734,6 +5760,7 @@ function ContentVariants(props) {
|
|
|
5734
5760
|
}}</For9>
|
|
5735
5761
|
</Show15>
|
|
5736
5762
|
<Content_default
|
|
5763
|
+
apiHost={props.apiHost}
|
|
5737
5764
|
nonce={props.nonce}
|
|
5738
5765
|
isNestedRender={props.isNestedRender}
|
|
5739
5766
|
{...{}}
|
package/lib/node/index.js
CHANGED
|
@@ -4925,6 +4925,16 @@ function getPreviewContent(_searchParams) {
|
|
|
4925
4925
|
return void 0;
|
|
4926
4926
|
}
|
|
4927
4927
|
|
|
4928
|
+
// src/constants/sdk-version.ts
|
|
4929
|
+
var SDK_VERSION = "2.0.26";
|
|
4930
|
+
|
|
4931
|
+
// src/helpers/sdk-headers.ts
|
|
4932
|
+
var getSdkHeaders = () => ({
|
|
4933
|
+
"X-Builder-SDK": TARGET,
|
|
4934
|
+
"X-Builder-SDK-GEN": "2",
|
|
4935
|
+
"X-Builder-SDK-Version": SDK_VERSION
|
|
4936
|
+
});
|
|
4937
|
+
|
|
4928
4938
|
// src/functions/get-global-this.ts
|
|
4929
4939
|
function getGlobalThis() {
|
|
4930
4940
|
if (typeof globalThis !== "undefined") {
|
|
@@ -5026,7 +5036,8 @@ var generateContentUrl = (options) => {
|
|
|
5026
5036
|
cacheSeconds,
|
|
5027
5037
|
staleCacheSeconds,
|
|
5028
5038
|
sort,
|
|
5029
|
-
includeUnpublished
|
|
5039
|
+
includeUnpublished,
|
|
5040
|
+
apiHost
|
|
5030
5041
|
} = options;
|
|
5031
5042
|
if (!apiKey) {
|
|
5032
5043
|
throw new Error("Missing API key");
|
|
@@ -5035,7 +5046,8 @@ var generateContentUrl = (options) => {
|
|
|
5035
5046
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
5036
5047
|
}
|
|
5037
5048
|
const noTraverse = limit !== 1;
|
|
5038
|
-
const
|
|
5049
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
5050
|
+
const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
|
|
5039
5051
|
url.searchParams.set("apiKey", apiKey);
|
|
5040
5052
|
url.searchParams.set("limit", String(limit));
|
|
5041
5053
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -5105,7 +5117,14 @@ async function fetchOneEntry(options) {
|
|
|
5105
5117
|
var _fetchContent = async (options) => {
|
|
5106
5118
|
const url = generateContentUrl(options);
|
|
5107
5119
|
const _fetch = options.fetch ?? fetch2;
|
|
5108
|
-
const
|
|
5120
|
+
const fetchOptions = {
|
|
5121
|
+
...options.fetchOptions,
|
|
5122
|
+
headers: {
|
|
5123
|
+
...options.fetchOptions?.headers,
|
|
5124
|
+
...getSdkHeaders()
|
|
5125
|
+
}
|
|
5126
|
+
};
|
|
5127
|
+
const res = await _fetch(url.href, fetchOptions);
|
|
5109
5128
|
const content = await res.json();
|
|
5110
5129
|
return content;
|
|
5111
5130
|
};
|
|
@@ -5314,7 +5333,10 @@ var createEvent = async ({
|
|
|
5314
5333
|
ownerId: apiKey
|
|
5315
5334
|
}
|
|
5316
5335
|
});
|
|
5317
|
-
async function _track(
|
|
5336
|
+
async function _track({
|
|
5337
|
+
apiHost,
|
|
5338
|
+
...eventProps
|
|
5339
|
+
}) {
|
|
5318
5340
|
if (!eventProps.apiKey) {
|
|
5319
5341
|
logger.error("Missing API key for track call. Please provide your API key.");
|
|
5320
5342
|
return;
|
|
@@ -5328,13 +5350,15 @@ async function _track(eventProps) {
|
|
|
5328
5350
|
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
5329
5351
|
return;
|
|
5330
5352
|
}
|
|
5331
|
-
|
|
5353
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
5354
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
5332
5355
|
method: "POST",
|
|
5333
5356
|
body: JSON.stringify({
|
|
5334
5357
|
events: [await createEvent(eventProps)]
|
|
5335
5358
|
}),
|
|
5336
5359
|
headers: {
|
|
5337
|
-
"content-type": "application/json"
|
|
5360
|
+
"content-type": "application/json",
|
|
5361
|
+
...getSdkHeaders()
|
|
5338
5362
|
},
|
|
5339
5363
|
mode: "cors"
|
|
5340
5364
|
}).catch((err) => {
|
|
@@ -5413,9 +5437,6 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5413
5437
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
5414
5438
|
}
|
|
5415
5439
|
|
|
5416
|
-
// src/constants/sdk-version.ts
|
|
5417
|
-
var SDK_VERSION = "2.0.24";
|
|
5418
|
-
|
|
5419
5440
|
// src/functions/register.ts
|
|
5420
5441
|
var registry = {};
|
|
5421
5442
|
function register(type, info) {
|
|
@@ -5772,6 +5793,7 @@ function EnableEditor(props) {
|
|
|
5772
5793
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
5773
5794
|
const contentId = props.builderContextSignal.content?.id;
|
|
5774
5795
|
_track({
|
|
5796
|
+
apiHost: props.apiHost,
|
|
5775
5797
|
type: "click",
|
|
5776
5798
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
5777
5799
|
contentId,
|
|
@@ -5830,7 +5852,7 @@ function EnableEditor(props) {
|
|
|
5830
5852
|
emitStateUpdate();
|
|
5831
5853
|
onMount(() => {
|
|
5832
5854
|
if (isBrowser()) {
|
|
5833
|
-
if (isEditing()) {
|
|
5855
|
+
if (isEditing() && !props.isNestedRender) {
|
|
5834
5856
|
window.addEventListener("message", processMessage);
|
|
5835
5857
|
registerInsertMenu();
|
|
5836
5858
|
setupBrowserForEditing({
|
|
@@ -5856,6 +5878,7 @@ function EnableEditor(props) {
|
|
|
5856
5878
|
const contentId = props.builderContextSignal.content?.id;
|
|
5857
5879
|
const apiKeyProp = props.apiKey;
|
|
5858
5880
|
_track({
|
|
5881
|
+
apiHost: props.apiHost,
|
|
5859
5882
|
type: "impression",
|
|
5860
5883
|
canTrack: true,
|
|
5861
5884
|
contentId,
|
|
@@ -6104,6 +6127,9 @@ function ContentComponent(props) {
|
|
|
6104
6127
|
},
|
|
6105
6128
|
get children() {
|
|
6106
6129
|
return createComponent(enable_editor_default, mergeProps({
|
|
6130
|
+
get apiHost() {
|
|
6131
|
+
return props.apiHost;
|
|
6132
|
+
},
|
|
6107
6133
|
get nonce() {
|
|
6108
6134
|
return props.nonce;
|
|
6109
6135
|
},
|
|
@@ -6145,6 +6171,9 @@ function ContentComponent(props) {
|
|
|
6145
6171
|
},
|
|
6146
6172
|
get trustedHosts() {
|
|
6147
6173
|
return props.trustedHosts;
|
|
6174
|
+
},
|
|
6175
|
+
get isNestedRender() {
|
|
6176
|
+
return props.isNestedRender;
|
|
6148
6177
|
}
|
|
6149
6178
|
}, {
|
|
6150
6179
|
setBuilderContextSignal
|
|
@@ -6277,6 +6306,9 @@ function ContentVariants(props) {
|
|
|
6277
6306
|
children: (variant, _index) => {
|
|
6278
6307
|
_index();
|
|
6279
6308
|
return createComponent(content_default, mergeProps({
|
|
6309
|
+
get apiHost() {
|
|
6310
|
+
return props.apiHost;
|
|
6311
|
+
},
|
|
6280
6312
|
get isNestedRender() {
|
|
6281
6313
|
return props.isNestedRender;
|
|
6282
6314
|
},
|
|
@@ -6341,6 +6373,9 @@ function ContentVariants(props) {
|
|
|
6341
6373
|
})];
|
|
6342
6374
|
}
|
|
6343
6375
|
}), createComponent(content_default, mergeProps({
|
|
6376
|
+
get apiHost() {
|
|
6377
|
+
return props.apiHost;
|
|
6378
|
+
},
|
|
6344
6379
|
get nonce() {
|
|
6345
6380
|
return props.nonce;
|
|
6346
6381
|
},
|
package/lib/node/index.jsx
CHANGED
|
@@ -4415,6 +4415,16 @@ function getPreviewContent(_searchParams) {
|
|
|
4415
4415
|
return void 0;
|
|
4416
4416
|
}
|
|
4417
4417
|
|
|
4418
|
+
// src/constants/sdk-version.ts
|
|
4419
|
+
var SDK_VERSION = "2.0.26";
|
|
4420
|
+
|
|
4421
|
+
// src/helpers/sdk-headers.ts
|
|
4422
|
+
var getSdkHeaders = () => ({
|
|
4423
|
+
"X-Builder-SDK": TARGET,
|
|
4424
|
+
"X-Builder-SDK-GEN": "2",
|
|
4425
|
+
"X-Builder-SDK-Version": SDK_VERSION
|
|
4426
|
+
});
|
|
4427
|
+
|
|
4418
4428
|
// src/functions/get-global-this.ts
|
|
4419
4429
|
function getGlobalThis() {
|
|
4420
4430
|
if (typeof globalThis !== "undefined") {
|
|
@@ -4516,7 +4526,8 @@ var generateContentUrl = (options) => {
|
|
|
4516
4526
|
cacheSeconds,
|
|
4517
4527
|
staleCacheSeconds,
|
|
4518
4528
|
sort,
|
|
4519
|
-
includeUnpublished
|
|
4529
|
+
includeUnpublished,
|
|
4530
|
+
apiHost
|
|
4520
4531
|
} = options;
|
|
4521
4532
|
if (!apiKey) {
|
|
4522
4533
|
throw new Error("Missing API key");
|
|
@@ -4525,7 +4536,8 @@ var generateContentUrl = (options) => {
|
|
|
4525
4536
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${apiVersion}'`);
|
|
4526
4537
|
}
|
|
4527
4538
|
const noTraverse = limit !== 1;
|
|
4528
|
-
const
|
|
4539
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
4540
|
+
const url = new URL(`${baseUrl}/api/${apiVersion}/content/${model}`);
|
|
4529
4541
|
url.searchParams.set("apiKey", apiKey);
|
|
4530
4542
|
url.searchParams.set("limit", String(limit));
|
|
4531
4543
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
@@ -4595,7 +4607,14 @@ async function fetchOneEntry(options) {
|
|
|
4595
4607
|
var _fetchContent = async (options) => {
|
|
4596
4608
|
const url = generateContentUrl(options);
|
|
4597
4609
|
const _fetch = options.fetch ?? fetch2;
|
|
4598
|
-
const
|
|
4610
|
+
const fetchOptions = {
|
|
4611
|
+
...options.fetchOptions,
|
|
4612
|
+
headers: {
|
|
4613
|
+
...options.fetchOptions?.headers,
|
|
4614
|
+
...getSdkHeaders()
|
|
4615
|
+
}
|
|
4616
|
+
};
|
|
4617
|
+
const res = await _fetch(url.href, fetchOptions);
|
|
4599
4618
|
const content = await res.json();
|
|
4600
4619
|
return content;
|
|
4601
4620
|
};
|
|
@@ -4804,7 +4823,10 @@ var createEvent = async ({
|
|
|
4804
4823
|
ownerId: apiKey
|
|
4805
4824
|
}
|
|
4806
4825
|
});
|
|
4807
|
-
async function _track(
|
|
4826
|
+
async function _track({
|
|
4827
|
+
apiHost,
|
|
4828
|
+
...eventProps
|
|
4829
|
+
}) {
|
|
4808
4830
|
if (!eventProps.apiKey) {
|
|
4809
4831
|
logger.error("Missing API key for track call. Please provide your API key.");
|
|
4810
4832
|
return;
|
|
@@ -4818,13 +4840,15 @@ async function _track(eventProps) {
|
|
|
4818
4840
|
if (!(isBrowser() || TARGET === "reactNative")) {
|
|
4819
4841
|
return;
|
|
4820
4842
|
}
|
|
4821
|
-
|
|
4843
|
+
const baseUrl = apiHost || "https://cdn.builder.io";
|
|
4844
|
+
return fetch(`${baseUrl}/api/v1/track`, {
|
|
4822
4845
|
method: "POST",
|
|
4823
4846
|
body: JSON.stringify({
|
|
4824
4847
|
events: [await createEvent(eventProps)]
|
|
4825
4848
|
}),
|
|
4826
4849
|
headers: {
|
|
4827
|
-
"content-type": "application/json"
|
|
4850
|
+
"content-type": "application/json",
|
|
4851
|
+
...getSdkHeaders()
|
|
4828
4852
|
},
|
|
4829
4853
|
mode: "cors"
|
|
4830
4854
|
}).catch((err) => {
|
|
@@ -4903,9 +4927,6 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4903
4927
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
4904
4928
|
}
|
|
4905
4929
|
|
|
4906
|
-
// src/constants/sdk-version.ts
|
|
4907
|
-
var SDK_VERSION = "2.0.24";
|
|
4908
|
-
|
|
4909
4930
|
// src/functions/register.ts
|
|
4910
4931
|
var registry = {};
|
|
4911
4932
|
function register(type, info) {
|
|
@@ -5261,6 +5282,7 @@ function EnableEditor(props) {
|
|
|
5261
5282
|
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
5262
5283
|
const contentId = props.builderContextSignal.content?.id;
|
|
5263
5284
|
_track({
|
|
5285
|
+
apiHost: props.apiHost,
|
|
5264
5286
|
type: "click",
|
|
5265
5287
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
5266
5288
|
contentId,
|
|
@@ -5329,7 +5351,7 @@ function EnableEditor(props) {
|
|
|
5329
5351
|
emitStateUpdate();
|
|
5330
5352
|
onMount6(() => {
|
|
5331
5353
|
if (isBrowser()) {
|
|
5332
|
-
if (isEditing()) {
|
|
5354
|
+
if (isEditing() && !props.isNestedRender) {
|
|
5333
5355
|
window.addEventListener("message", processMessage);
|
|
5334
5356
|
registerInsertMenu();
|
|
5335
5357
|
setupBrowserForEditing({
|
|
@@ -5360,6 +5382,7 @@ function EnableEditor(props) {
|
|
|
5360
5382
|
const contentId = props.builderContextSignal.content?.id;
|
|
5361
5383
|
const apiKeyProp = props.apiKey;
|
|
5362
5384
|
_track({
|
|
5385
|
+
apiHost: props.apiHost,
|
|
5363
5386
|
type: "impression",
|
|
5364
5387
|
canTrack: true,
|
|
5365
5388
|
contentId,
|
|
@@ -5599,6 +5622,7 @@ function ContentComponent(props) {
|
|
|
5599
5622
|
registeredComponents: registeredComponents()
|
|
5600
5623
|
}}
|
|
5601
5624
|
><Enable_editor_default
|
|
5625
|
+
apiHost={props.apiHost}
|
|
5602
5626
|
nonce={props.nonce}
|
|
5603
5627
|
content={props.content}
|
|
5604
5628
|
data={props.data}
|
|
@@ -5613,6 +5637,7 @@ function ContentComponent(props) {
|
|
|
5613
5637
|
contentWrapper={props.contentWrapper}
|
|
5614
5638
|
contentWrapperProps={props.contentWrapperProps}
|
|
5615
5639
|
trustedHosts={props.trustedHosts}
|
|
5640
|
+
isNestedRender={props.isNestedRender}
|
|
5616
5641
|
{...{
|
|
5617
5642
|
setBuilderContextSignal
|
|
5618
5643
|
}}
|
|
@@ -5691,6 +5716,7 @@ function ContentVariants(props) {
|
|
|
5691
5716
|
<For9 each={getVariants(props.content)}>{(variant, _index) => {
|
|
5692
5717
|
const index = _index();
|
|
5693
5718
|
return <Content_default
|
|
5719
|
+
apiHost={props.apiHost}
|
|
5694
5720
|
isNestedRender={props.isNestedRender}
|
|
5695
5721
|
key={variant.testVariationId}
|
|
5696
5722
|
nonce={props.nonce}
|
|
@@ -5717,6 +5743,7 @@ function ContentVariants(props) {
|
|
|
5717
5743
|
}}</For9>
|
|
5718
5744
|
</Show15>
|
|
5719
5745
|
<Content_default
|
|
5746
|
+
apiHost={props.apiHost}
|
|
5720
5747
|
nonce={props.nonce}
|
|
5721
5748
|
isNestedRender={props.isNestedRender}
|
|
5722
5749
|
{...{}}
|