@builder.io/sdk-solid 0.6.4 → 0.7.1-0

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.
@@ -1,4 +1,4 @@
1
- import { delegateEvents, createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, memo, Dynamic, use } from 'solid-js/web';
1
+ import { createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, memo, Dynamic, use } from 'solid-js/web';
2
2
  import { createContext, Show, useContext, For, createSignal, onMount, createEffect, on } from 'solid-js';
3
3
  import { css } from 'solid-styled-components';
4
4
 
@@ -183,6 +183,19 @@ var getFunctionArguments = ({
183
183
  event
184
184
  });
185
185
  };
186
+ var getBuilderGlobals = () => ({
187
+ isEditing: isEditing(),
188
+ isBrowser: isBrowser(),
189
+ isServer: !isBrowser(),
190
+ getUserAttributes: () => getUserAttributes()
191
+ });
192
+ var parseCode = (code, {
193
+ isExpression = true
194
+ }) => {
195
+ const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
196
+ const useCode = useReturn ? `return (${code});` : code;
197
+ return useCode;
198
+ };
186
199
 
187
200
  // src/functions/evaluate/browser-runtime/browser.js
188
201
  var runInBrowser = ({
@@ -224,6 +237,9 @@ function flattenState(rootState, localState, rootSetState) {
224
237
  });
225
238
  }
226
239
 
240
+ // src/functions/evaluate/choose-eval.js
241
+ var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInBrowser(args);
242
+
227
243
  // src/functions/evaluate/evaluate.js
228
244
  function evaluate({
229
245
  code,
@@ -238,17 +254,11 @@ function evaluate({
238
254
  logger.warn("Skipping evaluation of empty code block.");
239
255
  return;
240
256
  }
241
- const builder = {
242
- isEditing: isEditing(),
243
- isBrowser: isBrowser(),
244
- isServer: !isBrowser(),
245
- getUserAttributes: () => getUserAttributes()
246
- };
247
- const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
248
- const useCode = useReturn ? `return (${code});` : code;
249
257
  const args = {
250
- code: useCode,
251
- builder,
258
+ code: parseCode(code, {
259
+ isExpression
260
+ }),
261
+ builder: getBuilderGlobals(),
252
262
  context,
253
263
  event,
254
264
  rootSetState,
@@ -256,7 +266,7 @@ function evaluate({
256
266
  localState
257
267
  };
258
268
  try {
259
- return runInBrowser(args);
269
+ return chooseBrowserOrServerEval(args);
260
270
  } catch (e) {
261
271
  logger.error("Failed code evaluation: " + e.message, {
262
272
  code
@@ -2668,41 +2678,39 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
2668
2678
  function CustomCode(props) {
2669
2679
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
2670
2680
  const [scriptsRun, setScriptsRun] = createSignal([]);
2671
- function findAndRunScripts() {
2672
- if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
2673
- const scripts = elem.getElementsByTagName("script");
2674
- for (let i = 0; i < scripts.length; i++) {
2675
- const script = scripts[i];
2676
- if (script.src) {
2677
- if (scriptsInserted().includes(script.src)) {
2678
- continue;
2679
- }
2680
- scriptsInserted().push(script.src);
2681
- const newScript = document.createElement("script");
2682
- newScript.async = true;
2683
- newScript.src = script.src;
2684
- document.head.appendChild(newScript);
2685
- } else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
2686
- if (scriptsRun().includes(script.innerText)) {
2687
- continue;
2688
- }
2689
- try {
2690
- scriptsRun().push(script.innerText);
2691
- new Function(script.innerText)();
2692
- } catch (error) {
2693
- }
2681
+ let elementRef;
2682
+ onMount(() => {
2683
+ if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
2684
+ return;
2685
+ }
2686
+ const scripts = elementRef.getElementsByTagName("script");
2687
+ for (let i = 0; i < scripts.length; i++) {
2688
+ const script = scripts[i];
2689
+ if (script.src) {
2690
+ if (scriptsInserted().includes(script.src)) {
2691
+ continue;
2692
+ }
2693
+ scriptsInserted().push(script.src);
2694
+ const newScript = document.createElement("script");
2695
+ newScript.async = true;
2696
+ newScript.src = script.src;
2697
+ document.head.appendChild(newScript);
2698
+ } else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
2699
+ if (scriptsRun().includes(script.innerText)) {
2700
+ continue;
2701
+ }
2702
+ try {
2703
+ scriptsRun().push(script.innerText);
2704
+ new Function(script.innerText)();
2705
+ } catch (error) {
2694
2706
  }
2695
2707
  }
2696
2708
  }
2697
- }
2698
- let elem;
2699
- onMount(() => {
2700
- findAndRunScripts();
2701
2709
  });
2702
2710
  return (() => {
2703
2711
  const _el$ = _tmpl$13();
2704
- const _ref$ = elem;
2705
- typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
2712
+ const _ref$ = elementRef;
2713
+ typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
2706
2714
  effect((_p$) => {
2707
2715
  const _v$ = "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""), _v$2 = props.code;
2708
2716
  _v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
@@ -3360,7 +3368,7 @@ var track = (args) => _track(__spreadProps9(__spreadValues12({}, args), {
3360
3368
  }));
3361
3369
 
3362
3370
  // src/constants/sdk-version.js
3363
- var SDK_VERSION = "0.6.4";
3371
+ var SDK_VERSION = "0.7.1-0";
3364
3372
 
3365
3373
  // src/functions/register.js
3366
3374
  var registry = {};
@@ -3813,18 +3821,28 @@ var __spreadValues15 = (a, b) => {
3813
3821
  }
3814
3822
  return a;
3815
3823
  };
3824
+ var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
3816
3825
  var generateContentUrl = (options) => {
3826
+ let {
3827
+ noTraverse = false
3828
+ } = options;
3817
3829
  const {
3818
3830
  limit = 30,
3819
3831
  userAttributes,
3820
3832
  query,
3821
- noTraverse = false,
3822
3833
  model,
3823
3834
  apiKey,
3824
3835
  includeRefs = true,
3825
3836
  enrich,
3826
3837
  locale,
3827
- apiVersion = DEFAULT_API_VERSION
3838
+ apiVersion = DEFAULT_API_VERSION,
3839
+ fields,
3840
+ omit,
3841
+ offset,
3842
+ cacheSeconds,
3843
+ staleCacheSeconds,
3844
+ sort,
3845
+ includeUnpublished
3828
3846
  } = options;
3829
3847
  if (!apiKey) {
3830
3848
  throw new Error("Missing API key");
@@ -3832,7 +3850,34 @@ var generateContentUrl = (options) => {
3832
3850
  if (!["v2", "v3"].includes(apiVersion)) {
3833
3851
  throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
3834
3852
  }
3853
+ if ((options.limit === void 0 || options.limit > 1) && !("noTraverse" in options)) {
3854
+ noTraverse = true;
3855
+ }
3835
3856
  const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}${enrich ? `&enrich=${enrich}` : ""}`);
3857
+ url.searchParams.set("omit", omit || "meta.componentsUsed");
3858
+ if (fields) {
3859
+ url.searchParams.set("fields", fields);
3860
+ }
3861
+ if (Number.isFinite(offset) && offset > -1) {
3862
+ url.searchParams.set("offset", String(Math.floor(offset)));
3863
+ }
3864
+ if (typeof includeUnpublished === "boolean") {
3865
+ url.searchParams.set("includeUnpublished", String(includeUnpublished));
3866
+ }
3867
+ if (cacheSeconds && isPositiveNumber(cacheSeconds)) {
3868
+ url.searchParams.set("cacheSeconds", String(cacheSeconds));
3869
+ }
3870
+ if (staleCacheSeconds && isPositiveNumber(staleCacheSeconds)) {
3871
+ url.searchParams.set("staleCacheSeconds", String(staleCacheSeconds));
3872
+ }
3873
+ if (sort) {
3874
+ const flattened2 = flatten({
3875
+ sort
3876
+ });
3877
+ for (const key in flattened2) {
3878
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
3879
+ }
3880
+ }
3836
3881
  const queryOptions = __spreadValues15(__spreadValues15({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
3837
3882
  const flattened = flatten(queryOptions);
3838
3883
  for (const key in flattened) {
@@ -3981,7 +4026,6 @@ function isPreviewing() {
3981
4026
  // src/components/content/components/enable-editor.jsx
3982
4027
  var _tmpl$14 = /* @__PURE__ */ template(`<div>`);
3983
4028
  function EnableEditor(props) {
3984
- const [canTrackToUse, setCanTrackToUse] = createSignal(checkIsDefined(props.canTrack) ? props.canTrack : true);
3985
4029
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
3986
4030
  createSignal(0);
3987
4031
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal(false);
@@ -4062,7 +4106,7 @@ function EnableEditor(props) {
4062
4106
  const contentId = props.builderContextSignal.content?.id;
4063
4107
  _track({
4064
4108
  type: "click",
4065
- canTrack: canTrackToUse(),
4109
+ canTrack: getDefaultCanTrack(props.canTrack),
4066
4110
  contentId,
4067
4111
  apiKey: props.apiKey,
4068
4112
  variationId: variationId !== contentId ? variationId : void 0,
@@ -4123,11 +4167,8 @@ function EnableEditor(props) {
4123
4167
  }
4124
4168
  let elementRef;
4125
4169
  onMount(() => {
4126
- if (!props.apiKey) {
4127
- logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
4128
- }
4129
4170
  if (isBrowser()) {
4130
- if (isEditing()) {
4171
+ if (isEditing() && true) {
4131
4172
  setForceReRenderCount(forceReRenderCount() + 1);
4132
4173
  window.addEventListener("message", processMessage);
4133
4174
  registerInsertMenu();
@@ -4148,18 +4189,20 @@ function EnableEditor(props) {
4148
4189
  });
4149
4190
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
4150
4191
  }
4151
- if (props.builderContextSignal.content) {
4192
+ const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
4193
+ if (shouldTrackImpression) {
4152
4194
  const variationId = props.builderContextSignal.content?.testVariationId;
4153
4195
  const contentId = props.builderContextSignal.content?.id;
4196
+ const apiKeyProp = props.apiKey;
4154
4197
  _track({
4155
4198
  type: "impression",
4156
- canTrack: canTrackToUse(),
4199
+ canTrack: true,
4157
4200
  contentId,
4158
- apiKey: props.apiKey,
4201
+ apiKey: apiKeyProp,
4159
4202
  variationId: variationId !== contentId ? variationId : void 0
4160
4203
  });
4161
4204
  }
4162
- if (isPreviewing()) {
4205
+ if (isPreviewing() && true) {
4163
4206
  const searchParams = new URL(location.href).searchParams;
4164
4207
  const searchParamPreviewModel = searchParams.get("builder.preview");
4165
4208
  const searchParamPreviewId = searchParams.get(`builder.preview.${searchParamPreviewModel}`);
@@ -4176,11 +4219,16 @@ function EnableEditor(props) {
4176
4219
  });
4177
4220
  }
4178
4221
  }
4179
- evaluateJsCode();
4180
- runHttpRequests();
4181
- emitStateUpdate();
4182
4222
  }
4183
4223
  });
4224
+ onMount(() => {
4225
+ if (!props.apiKey) {
4226
+ logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
4227
+ }
4228
+ evaluateJsCode();
4229
+ runHttpRequests();
4230
+ emitStateUpdate();
4231
+ });
4184
4232
  function onUpdateFn_0() {
4185
4233
  if (props.content) {
4186
4234
  mergeNewContent(props.content);
@@ -4213,16 +4261,17 @@ function EnableEditor(props) {
4213
4261
  },
4214
4262
  get children() {
4215
4263
  const _el$ = _tmpl$14();
4216
- _el$.$$click = (event) => onClick(event);
4217
4264
  const _ref$ = elementRef;
4218
4265
  typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
4219
4266
  spread(_el$, mergeProps({
4220
4267
  get ["class"]() {
4221
4268
  return props.classNameProp;
4222
- },
4269
+ }
4270
+ }, {}, {
4223
4271
  get key() {
4224
4272
  return forceReRenderCount();
4225
4273
  },
4274
+ "onClick": (event) => onClick(event),
4226
4275
  get ["builder-content-id"]() {
4227
4276
  return props.builderContextSignal.content?.id;
4228
4277
  },
@@ -4241,7 +4290,6 @@ function EnableEditor(props) {
4241
4290
  });
4242
4291
  }
4243
4292
  var enable_editor_default = EnableEditor;
4244
- delegateEvents(["click"]);
4245
4293
  var _tmpl$15 = /* @__PURE__ */ template(`<script>`);
4246
4294
  function InlinedScript(props) {
4247
4295
  return (() => {
@@ -170,6 +170,19 @@ var getFunctionArguments = ({
170
170
  event
171
171
  });
172
172
  };
173
+ var getBuilderGlobals = () => ({
174
+ isEditing: isEditing(),
175
+ isBrowser: isBrowser(),
176
+ isServer: !isBrowser(),
177
+ getUserAttributes: () => getUserAttributes()
178
+ });
179
+ var parseCode = (code, {
180
+ isExpression = true
181
+ }) => {
182
+ const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
183
+ const useCode = useReturn ? `return (${code});` : code;
184
+ return useCode;
185
+ };
173
186
 
174
187
  // src/functions/evaluate/browser-runtime/browser.js
175
188
  var runInBrowser = ({
@@ -211,6 +224,9 @@ function flattenState(rootState, localState, rootSetState) {
211
224
  });
212
225
  }
213
226
 
227
+ // src/functions/evaluate/choose-eval.js
228
+ var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInBrowser(args);
229
+
214
230
  // src/functions/evaluate/evaluate.js
215
231
  function evaluate({
216
232
  code,
@@ -225,17 +241,11 @@ function evaluate({
225
241
  logger.warn("Skipping evaluation of empty code block.");
226
242
  return;
227
243
  }
228
- const builder = {
229
- isEditing: isEditing(),
230
- isBrowser: isBrowser(),
231
- isServer: !isBrowser(),
232
- getUserAttributes: () => getUserAttributes()
233
- };
234
- const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
235
- const useCode = useReturn ? `return (${code});` : code;
236
244
  const args = {
237
- code: useCode,
238
- builder,
245
+ code: parseCode(code, {
246
+ isExpression
247
+ }),
248
+ builder: getBuilderGlobals(),
239
249
  context,
240
250
  event,
241
251
  rootSetState,
@@ -243,7 +253,7 @@ function evaluate({
243
253
  localState
244
254
  };
245
255
  try {
246
- return runInBrowser(args);
256
+ return chooseBrowserOrServerEval(args);
247
257
  } catch (e) {
248
258
  logger.error("Failed code evaluation: " + e.message, {
249
259
  code
@@ -2402,44 +2412,42 @@ import { onMount, createSignal as createSignal10 } from "solid-js";
2402
2412
  function CustomCode(props) {
2403
2413
  const [scriptsInserted, setScriptsInserted] = createSignal10([]);
2404
2414
  const [scriptsRun, setScriptsRun] = createSignal10([]);
2405
- function findAndRunScripts() {
2406
- if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
2407
- const scripts = elem.getElementsByTagName("script");
2408
- for (let i = 0; i < scripts.length; i++) {
2409
- const script = scripts[i];
2410
- if (script.src) {
2411
- if (scriptsInserted().includes(script.src)) {
2412
- continue;
2413
- }
2414
- scriptsInserted().push(script.src);
2415
- const newScript = document.createElement("script");
2416
- newScript.async = true;
2417
- newScript.src = script.src;
2418
- document.head.appendChild(newScript);
2419
- } else if (!script.type || [
2420
- "text/javascript",
2421
- "application/javascript",
2422
- "application/ecmascript"
2423
- ].includes(script.type)) {
2424
- if (scriptsRun().includes(script.innerText)) {
2425
- continue;
2426
- }
2427
- try {
2428
- scriptsRun().push(script.innerText);
2429
- new Function(script.innerText)();
2430
- } catch (error) {
2431
- }
2415
+ let elementRef;
2416
+ onMount(() => {
2417
+ if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
2418
+ return;
2419
+ }
2420
+ const scripts = elementRef.getElementsByTagName("script");
2421
+ for (let i = 0; i < scripts.length; i++) {
2422
+ const script = scripts[i];
2423
+ if (script.src) {
2424
+ if (scriptsInserted().includes(script.src)) {
2425
+ continue;
2426
+ }
2427
+ scriptsInserted().push(script.src);
2428
+ const newScript = document.createElement("script");
2429
+ newScript.async = true;
2430
+ newScript.src = script.src;
2431
+ document.head.appendChild(newScript);
2432
+ } else if (!script.type || [
2433
+ "text/javascript",
2434
+ "application/javascript",
2435
+ "application/ecmascript"
2436
+ ].includes(script.type)) {
2437
+ if (scriptsRun().includes(script.innerText)) {
2438
+ continue;
2439
+ }
2440
+ try {
2441
+ scriptsRun().push(script.innerText);
2442
+ new Function(script.innerText)();
2443
+ } catch (error) {
2432
2444
  }
2433
2445
  }
2434
2446
  }
2435
- }
2436
- let elem;
2437
- onMount(() => {
2438
- findAndRunScripts();
2439
2447
  });
2440
2448
  return <div
2441
2449
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
2442
- ref={elem}
2450
+ ref={elementRef}
2443
2451
  innerHTML={props.code}
2444
2452
  />;
2445
2453
  }
@@ -3092,7 +3100,7 @@ var track = (args) => _track(__spreadProps9(__spreadValues12({}, args), {
3092
3100
  }));
3093
3101
 
3094
3102
  // src/constants/sdk-version.js
3095
- var SDK_VERSION = "0.6.4";
3103
+ var SDK_VERSION = "0.7.1-0";
3096
3104
 
3097
3105
  // src/functions/register.js
3098
3106
  var registry = {};
@@ -3545,18 +3553,28 @@ var __spreadValues15 = (a, b) => {
3545
3553
  }
3546
3554
  return a;
3547
3555
  };
3556
+ var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
3548
3557
  var generateContentUrl = (options) => {
3558
+ let {
3559
+ noTraverse = false
3560
+ } = options;
3549
3561
  const {
3550
3562
  limit = 30,
3551
3563
  userAttributes,
3552
3564
  query,
3553
- noTraverse = false,
3554
3565
  model,
3555
3566
  apiKey,
3556
3567
  includeRefs = true,
3557
3568
  enrich,
3558
3569
  locale,
3559
- apiVersion = DEFAULT_API_VERSION
3570
+ apiVersion = DEFAULT_API_VERSION,
3571
+ fields,
3572
+ omit,
3573
+ offset,
3574
+ cacheSeconds,
3575
+ staleCacheSeconds,
3576
+ sort,
3577
+ includeUnpublished
3560
3578
  } = options;
3561
3579
  if (!apiKey) {
3562
3580
  throw new Error("Missing API key");
@@ -3564,7 +3582,34 @@ var generateContentUrl = (options) => {
3564
3582
  if (!["v2", "v3"].includes(apiVersion)) {
3565
3583
  throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
3566
3584
  }
3585
+ if ((options.limit === void 0 || options.limit > 1) && !("noTraverse" in options)) {
3586
+ noTraverse = true;
3587
+ }
3567
3588
  const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}${enrich ? `&enrich=${enrich}` : ""}`);
3589
+ url.searchParams.set("omit", omit || "meta.componentsUsed");
3590
+ if (fields) {
3591
+ url.searchParams.set("fields", fields);
3592
+ }
3593
+ if (Number.isFinite(offset) && offset > -1) {
3594
+ url.searchParams.set("offset", String(Math.floor(offset)));
3595
+ }
3596
+ if (typeof includeUnpublished === "boolean") {
3597
+ url.searchParams.set("includeUnpublished", String(includeUnpublished));
3598
+ }
3599
+ if (cacheSeconds && isPositiveNumber(cacheSeconds)) {
3600
+ url.searchParams.set("cacheSeconds", String(cacheSeconds));
3601
+ }
3602
+ if (staleCacheSeconds && isPositiveNumber(staleCacheSeconds)) {
3603
+ url.searchParams.set("staleCacheSeconds", String(staleCacheSeconds));
3604
+ }
3605
+ if (sort) {
3606
+ const flattened2 = flatten({
3607
+ sort
3608
+ });
3609
+ for (const key in flattened2) {
3610
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
3611
+ }
3612
+ }
3568
3613
  const queryOptions = __spreadValues15(__spreadValues15({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
3569
3614
  const flattened = flatten(queryOptions);
3570
3615
  for (const key in flattened) {
@@ -3712,9 +3757,6 @@ function isPreviewing() {
3712
3757
 
3713
3758
  // src/components/content/components/enable-editor.jsx
3714
3759
  function EnableEditor(props) {
3715
- const [canTrackToUse, setCanTrackToUse] = createSignal12(
3716
- checkIsDefined(props.canTrack) ? props.canTrack : true
3717
- );
3718
3760
  const [forceReRenderCount, setForceReRenderCount] = createSignal12(0);
3719
3761
  const [lastUpdated, setLastUpdated] = createSignal12(0);
3720
3762
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal12(false);
@@ -3790,7 +3832,7 @@ function EnableEditor(props) {
3790
3832
  const contentId = props.builderContextSignal.content?.id;
3791
3833
  _track({
3792
3834
  type: "click",
3793
- canTrack: canTrackToUse(),
3835
+ canTrack: getDefaultCanTrack(props.canTrack),
3794
3836
  contentId,
3795
3837
  apiKey: props.apiKey,
3796
3838
  variationId: variationId !== contentId ? variationId : void 0,
@@ -3853,13 +3895,8 @@ function EnableEditor(props) {
3853
3895
  }
3854
3896
  let elementRef;
3855
3897
  onMount2(() => {
3856
- if (!props.apiKey) {
3857
- logger.error(
3858
- "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
3859
- );
3860
- }
3861
3898
  if (isBrowser()) {
3862
- if (isEditing()) {
3899
+ if (isEditing() && true) {
3863
3900
  setForceReRenderCount(forceReRenderCount() + 1);
3864
3901
  window.addEventListener("message", processMessage);
3865
3902
  registerInsertMenu();
@@ -3885,18 +3922,20 @@ function EnableEditor(props) {
3885
3922
  emitStateUpdate
3886
3923
  );
3887
3924
  }
3888
- if (props.builderContextSignal.content) {
3925
+ const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
3926
+ if (shouldTrackImpression) {
3889
3927
  const variationId = props.builderContextSignal.content?.testVariationId;
3890
3928
  const contentId = props.builderContextSignal.content?.id;
3929
+ const apiKeyProp = props.apiKey;
3891
3930
  _track({
3892
3931
  type: "impression",
3893
- canTrack: canTrackToUse(),
3932
+ canTrack: true,
3894
3933
  contentId,
3895
- apiKey: props.apiKey,
3934
+ apiKey: apiKeyProp,
3896
3935
  variationId: variationId !== contentId ? variationId : void 0
3897
3936
  });
3898
3937
  }
3899
- if (isPreviewing()) {
3938
+ if (isPreviewing() && true) {
3900
3939
  const searchParams = new URL(location.href).searchParams;
3901
3940
  const searchParamPreviewModel = searchParams.get("builder.preview");
3902
3941
  const searchParamPreviewId = searchParams.get(
@@ -3915,11 +3954,18 @@ function EnableEditor(props) {
3915
3954
  });
3916
3955
  }
3917
3956
  }
3918
- evaluateJsCode();
3919
- runHttpRequests();
3920
- emitStateUpdate();
3921
3957
  }
3922
3958
  });
3959
+ onMount2(() => {
3960
+ if (!props.apiKey) {
3961
+ logger.error(
3962
+ "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
3963
+ );
3964
+ }
3965
+ evaluateJsCode();
3966
+ runHttpRequests();
3967
+ emitStateUpdate();
3968
+ });
3923
3969
  function onUpdateFn_0() {
3924
3970
  if (props.content) {
3925
3971
  mergeNewContent(props.content);
@@ -3956,6 +4002,7 @@ function EnableEditor(props) {
3956
4002
  createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
3957
4003
  return <stdin_default.Provider value={props.builderContextSignal}><Show9 when={props.builderContextSignal.content}><div
3958
4004
  class={props.classNameProp}
4005
+ {...{}}
3959
4006
  key={forceReRenderCount()}
3960
4007
  ref={elementRef}
3961
4008
  onClick={(event) => onClick(event)}