@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
 
@@ -185,6 +185,19 @@ var getFunctionArguments = ({
185
185
  event
186
186
  });
187
187
  };
188
+ var getBuilderGlobals = () => ({
189
+ isEditing: isEditing(),
190
+ isBrowser: isBrowser(),
191
+ isServer: !isBrowser(),
192
+ getUserAttributes: () => getUserAttributes()
193
+ });
194
+ var parseCode = (code, {
195
+ isExpression = true
196
+ }) => {
197
+ const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
198
+ const useCode = useReturn ? `return (${code});` : code;
199
+ return useCode;
200
+ };
188
201
 
189
202
  // src/functions/evaluate/browser-runtime/browser.js
190
203
  var runInBrowser = ({
@@ -226,6 +239,9 @@ function flattenState(rootState, localState, rootSetState) {
226
239
  });
227
240
  }
228
241
 
242
+ // src/functions/evaluate/choose-eval.js
243
+ var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInBrowser(args);
244
+
229
245
  // src/functions/evaluate/evaluate.js
230
246
  function evaluate({
231
247
  code,
@@ -240,17 +256,11 @@ function evaluate({
240
256
  logger.warn("Skipping evaluation of empty code block.");
241
257
  return;
242
258
  }
243
- const builder = {
244
- isEditing: isEditing(),
245
- isBrowser: isBrowser(),
246
- isServer: !isBrowser(),
247
- getUserAttributes: () => getUserAttributes()
248
- };
249
- const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
250
- const useCode = useReturn ? `return (${code});` : code;
251
259
  const args = {
252
- code: useCode,
253
- builder,
260
+ code: parseCode(code, {
261
+ isExpression
262
+ }),
263
+ builder: getBuilderGlobals(),
254
264
  context,
255
265
  event,
256
266
  rootSetState,
@@ -258,7 +268,7 @@ function evaluate({
258
268
  localState
259
269
  };
260
270
  try {
261
- return runInBrowser(args);
271
+ return chooseBrowserOrServerEval(args);
262
272
  } catch (e) {
263
273
  logger.error("Failed code evaluation: " + e.message, {
264
274
  code
@@ -2683,42 +2693,40 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
2683
2693
  function CustomCode(props) {
2684
2694
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
2685
2695
  const [scriptsRun, setScriptsRun] = createSignal([]);
2686
- function findAndRunScripts() {
2687
- if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
2688
- const scripts = elem.getElementsByTagName("script");
2689
- for (let i = 0; i < scripts.length; i++) {
2690
- const script = scripts[i];
2691
- if (script.src) {
2692
- if (scriptsInserted().includes(script.src)) {
2693
- continue;
2694
- }
2695
- scriptsInserted().push(script.src);
2696
- const newScript = document.createElement("script");
2697
- newScript.async = true;
2698
- newScript.src = script.src;
2699
- document.head.appendChild(newScript);
2700
- } else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
2701
- if (scriptsRun().includes(script.innerText)) {
2702
- continue;
2703
- }
2704
- try {
2705
- scriptsRun().push(script.innerText);
2706
- new Function(script.innerText)();
2707
- } catch (error) {
2708
- console.warn("`CustomCode`: Error running script:", error);
2709
- }
2696
+ let elementRef;
2697
+ onMount(() => {
2698
+ if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
2699
+ return;
2700
+ }
2701
+ const scripts = elementRef.getElementsByTagName("script");
2702
+ for (let i = 0; i < scripts.length; i++) {
2703
+ const script = scripts[i];
2704
+ if (script.src) {
2705
+ if (scriptsInserted().includes(script.src)) {
2706
+ continue;
2707
+ }
2708
+ scriptsInserted().push(script.src);
2709
+ const newScript = document.createElement("script");
2710
+ newScript.async = true;
2711
+ newScript.src = script.src;
2712
+ document.head.appendChild(newScript);
2713
+ } else if (!script.type || ["text/javascript", "application/javascript", "application/ecmascript"].includes(script.type)) {
2714
+ if (scriptsRun().includes(script.innerText)) {
2715
+ continue;
2716
+ }
2717
+ try {
2718
+ scriptsRun().push(script.innerText);
2719
+ new Function(script.innerText)();
2720
+ } catch (error) {
2721
+ console.warn("`CustomCode`: Error running script:", error);
2710
2722
  }
2711
2723
  }
2712
2724
  }
2713
- }
2714
- let elem;
2715
- onMount(() => {
2716
- findAndRunScripts();
2717
2725
  });
2718
2726
  return (() => {
2719
2727
  const _el$ = _tmpl$13();
2720
- const _ref$ = elem;
2721
- typeof _ref$ === "function" ? use(_ref$, _el$) : elem = _el$;
2728
+ const _ref$ = elementRef;
2729
+ typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
2722
2730
  effect((_p$) => {
2723
2731
  const _v$ = "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""), _v$2 = props.code;
2724
2732
  _v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
@@ -3381,7 +3389,7 @@ var track = (args) => _track(__spreadProps9(__spreadValues12({}, args), {
3381
3389
  }));
3382
3390
 
3383
3391
  // src/constants/sdk-version.js
3384
- var SDK_VERSION = "0.6.4";
3392
+ var SDK_VERSION = "0.7.1-0";
3385
3393
 
3386
3394
  // src/functions/register.js
3387
3395
  var registry = {};
@@ -3835,18 +3843,28 @@ var __spreadValues15 = (a, b) => {
3835
3843
  }
3836
3844
  return a;
3837
3845
  };
3846
+ var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
3838
3847
  var generateContentUrl = (options) => {
3848
+ let {
3849
+ noTraverse = false
3850
+ } = options;
3839
3851
  const {
3840
3852
  limit = 30,
3841
3853
  userAttributes,
3842
3854
  query,
3843
- noTraverse = false,
3844
3855
  model,
3845
3856
  apiKey,
3846
3857
  includeRefs = true,
3847
3858
  enrich,
3848
3859
  locale,
3849
- apiVersion = DEFAULT_API_VERSION
3860
+ apiVersion = DEFAULT_API_VERSION,
3861
+ fields,
3862
+ omit,
3863
+ offset,
3864
+ cacheSeconds,
3865
+ staleCacheSeconds,
3866
+ sort,
3867
+ includeUnpublished
3850
3868
  } = options;
3851
3869
  if (!apiKey) {
3852
3870
  throw new Error("Missing API key");
@@ -3854,7 +3872,34 @@ var generateContentUrl = (options) => {
3854
3872
  if (!["v2", "v3"].includes(apiVersion)) {
3855
3873
  throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
3856
3874
  }
3875
+ if ((options.limit === void 0 || options.limit > 1) && !("noTraverse" in options)) {
3876
+ noTraverse = true;
3877
+ }
3857
3878
  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}` : ""}`);
3879
+ url.searchParams.set("omit", omit || "meta.componentsUsed");
3880
+ if (fields) {
3881
+ url.searchParams.set("fields", fields);
3882
+ }
3883
+ if (Number.isFinite(offset) && offset > -1) {
3884
+ url.searchParams.set("offset", String(Math.floor(offset)));
3885
+ }
3886
+ if (typeof includeUnpublished === "boolean") {
3887
+ url.searchParams.set("includeUnpublished", String(includeUnpublished));
3888
+ }
3889
+ if (cacheSeconds && isPositiveNumber(cacheSeconds)) {
3890
+ url.searchParams.set("cacheSeconds", String(cacheSeconds));
3891
+ }
3892
+ if (staleCacheSeconds && isPositiveNumber(staleCacheSeconds)) {
3893
+ url.searchParams.set("staleCacheSeconds", String(staleCacheSeconds));
3894
+ }
3895
+ if (sort) {
3896
+ const flattened2 = flatten({
3897
+ sort
3898
+ });
3899
+ for (const key in flattened2) {
3900
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
3901
+ }
3902
+ }
3858
3903
  const queryOptions = __spreadValues15(__spreadValues15({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
3859
3904
  const flattened = flatten(queryOptions);
3860
3905
  for (const key in flattened) {
@@ -4003,7 +4048,6 @@ function isPreviewing() {
4003
4048
  // src/components/content/components/enable-editor.jsx
4004
4049
  var _tmpl$14 = /* @__PURE__ */ template(`<div>`);
4005
4050
  function EnableEditor(props) {
4006
- const [canTrackToUse, setCanTrackToUse] = createSignal(checkIsDefined(props.canTrack) ? props.canTrack : true);
4007
4051
  const [forceReRenderCount, setForceReRenderCount] = createSignal(0);
4008
4052
  createSignal(0);
4009
4053
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal(false);
@@ -4084,7 +4128,7 @@ function EnableEditor(props) {
4084
4128
  const contentId = props.builderContextSignal.content?.id;
4085
4129
  _track({
4086
4130
  type: "click",
4087
- canTrack: canTrackToUse(),
4131
+ canTrack: getDefaultCanTrack(props.canTrack),
4088
4132
  contentId,
4089
4133
  apiKey: props.apiKey,
4090
4134
  variationId: variationId !== contentId ? variationId : void 0,
@@ -4146,11 +4190,8 @@ function EnableEditor(props) {
4146
4190
  }
4147
4191
  let elementRef;
4148
4192
  onMount(() => {
4149
- if (!props.apiKey) {
4150
- logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
4151
- }
4152
4193
  if (isBrowser()) {
4153
- if (isEditing()) {
4194
+ if (isEditing() && true) {
4154
4195
  setForceReRenderCount(forceReRenderCount() + 1);
4155
4196
  window.addEventListener("message", processMessage);
4156
4197
  registerInsertMenu();
@@ -4171,18 +4212,20 @@ function EnableEditor(props) {
4171
4212
  });
4172
4213
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
4173
4214
  }
4174
- if (props.builderContextSignal.content) {
4215
+ const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
4216
+ if (shouldTrackImpression) {
4175
4217
  const variationId = props.builderContextSignal.content?.testVariationId;
4176
4218
  const contentId = props.builderContextSignal.content?.id;
4219
+ const apiKeyProp = props.apiKey;
4177
4220
  _track({
4178
4221
  type: "impression",
4179
- canTrack: canTrackToUse(),
4222
+ canTrack: true,
4180
4223
  contentId,
4181
- apiKey: props.apiKey,
4224
+ apiKey: apiKeyProp,
4182
4225
  variationId: variationId !== contentId ? variationId : void 0
4183
4226
  });
4184
4227
  }
4185
- if (isPreviewing()) {
4228
+ if (isPreviewing() && true) {
4186
4229
  const searchParams = new URL(location.href).searchParams;
4187
4230
  const searchParamPreviewModel = searchParams.get("builder.preview");
4188
4231
  const searchParamPreviewId = searchParams.get(`builder.preview.${searchParamPreviewModel}`);
@@ -4199,11 +4242,16 @@ function EnableEditor(props) {
4199
4242
  });
4200
4243
  }
4201
4244
  }
4202
- evaluateJsCode();
4203
- runHttpRequests();
4204
- emitStateUpdate();
4205
4245
  }
4206
4246
  });
4247
+ onMount(() => {
4248
+ if (!props.apiKey) {
4249
+ logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
4250
+ }
4251
+ evaluateJsCode();
4252
+ runHttpRequests();
4253
+ emitStateUpdate();
4254
+ });
4207
4255
  function onUpdateFn_0() {
4208
4256
  if (props.content) {
4209
4257
  mergeNewContent(props.content);
@@ -4236,16 +4284,17 @@ function EnableEditor(props) {
4236
4284
  },
4237
4285
  get children() {
4238
4286
  const _el$ = _tmpl$14();
4239
- _el$.$$click = (event) => onClick(event);
4240
4287
  const _ref$ = elementRef;
4241
4288
  typeof _ref$ === "function" ? use(_ref$, _el$) : elementRef = _el$;
4242
4289
  spread(_el$, mergeProps({
4243
4290
  get ["class"]() {
4244
4291
  return props.classNameProp;
4245
- },
4292
+ }
4293
+ }, {}, {
4246
4294
  get key() {
4247
4295
  return forceReRenderCount();
4248
4296
  },
4297
+ "onClick": (event) => onClick(event),
4249
4298
  get ["builder-content-id"]() {
4250
4299
  return props.builderContextSignal.content?.id;
4251
4300
  },
@@ -4264,7 +4313,6 @@ function EnableEditor(props) {
4264
4313
  });
4265
4314
  }
4266
4315
  var enable_editor_default = EnableEditor;
4267
- delegateEvents(["click"]);
4268
4316
  var _tmpl$15 = /* @__PURE__ */ template(`<script>`);
4269
4317
  function InlinedScript(props) {
4270
4318
  return (() => {
@@ -172,6 +172,19 @@ var getFunctionArguments = ({
172
172
  event
173
173
  });
174
174
  };
175
+ var getBuilderGlobals = () => ({
176
+ isEditing: isEditing(),
177
+ isBrowser: isBrowser(),
178
+ isServer: !isBrowser(),
179
+ getUserAttributes: () => getUserAttributes()
180
+ });
181
+ var parseCode = (code, {
182
+ isExpression = true
183
+ }) => {
184
+ const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
185
+ const useCode = useReturn ? `return (${code});` : code;
186
+ return useCode;
187
+ };
175
188
 
176
189
  // src/functions/evaluate/browser-runtime/browser.js
177
190
  var runInBrowser = ({
@@ -213,6 +226,9 @@ function flattenState(rootState, localState, rootSetState) {
213
226
  });
214
227
  }
215
228
 
229
+ // src/functions/evaluate/choose-eval.js
230
+ var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInBrowser(args);
231
+
216
232
  // src/functions/evaluate/evaluate.js
217
233
  function evaluate({
218
234
  code,
@@ -227,17 +243,11 @@ function evaluate({
227
243
  logger.warn("Skipping evaluation of empty code block.");
228
244
  return;
229
245
  }
230
- const builder = {
231
- isEditing: isEditing(),
232
- isBrowser: isBrowser(),
233
- isServer: !isBrowser(),
234
- getUserAttributes: () => getUserAttributes()
235
- };
236
- const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
237
- const useCode = useReturn ? `return (${code});` : code;
238
246
  const args = {
239
- code: useCode,
240
- builder,
247
+ code: parseCode(code, {
248
+ isExpression
249
+ }),
250
+ builder: getBuilderGlobals(),
241
251
  context,
242
252
  event,
243
253
  rootSetState,
@@ -245,7 +255,7 @@ function evaluate({
245
255
  localState
246
256
  };
247
257
  try {
248
- return runInBrowser(args);
258
+ return chooseBrowserOrServerEval(args);
249
259
  } catch (e) {
250
260
  logger.error("Failed code evaluation: " + e.message, {
251
261
  code
@@ -2412,45 +2422,43 @@ import { onMount, createSignal as createSignal10 } from "solid-js";
2412
2422
  function CustomCode(props) {
2413
2423
  const [scriptsInserted, setScriptsInserted] = createSignal10([]);
2414
2424
  const [scriptsRun, setScriptsRun] = createSignal10([]);
2415
- function findAndRunScripts() {
2416
- if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
2417
- const scripts = elem.getElementsByTagName("script");
2418
- for (let i = 0; i < scripts.length; i++) {
2419
- const script = scripts[i];
2420
- if (script.src) {
2421
- if (scriptsInserted().includes(script.src)) {
2422
- continue;
2423
- }
2424
- scriptsInserted().push(script.src);
2425
- const newScript = document.createElement("script");
2426
- newScript.async = true;
2427
- newScript.src = script.src;
2428
- document.head.appendChild(newScript);
2429
- } else if (!script.type || [
2430
- "text/javascript",
2431
- "application/javascript",
2432
- "application/ecmascript"
2433
- ].includes(script.type)) {
2434
- if (scriptsRun().includes(script.innerText)) {
2435
- continue;
2436
- }
2437
- try {
2438
- scriptsRun().push(script.innerText);
2439
- new Function(script.innerText)();
2440
- } catch (error) {
2441
- console.warn("`CustomCode`: Error running script:", error);
2442
- }
2425
+ let elementRef;
2426
+ onMount(() => {
2427
+ if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
2428
+ return;
2429
+ }
2430
+ const scripts = elementRef.getElementsByTagName("script");
2431
+ for (let i = 0; i < scripts.length; i++) {
2432
+ const script = scripts[i];
2433
+ if (script.src) {
2434
+ if (scriptsInserted().includes(script.src)) {
2435
+ continue;
2436
+ }
2437
+ scriptsInserted().push(script.src);
2438
+ const newScript = document.createElement("script");
2439
+ newScript.async = true;
2440
+ newScript.src = script.src;
2441
+ document.head.appendChild(newScript);
2442
+ } else if (!script.type || [
2443
+ "text/javascript",
2444
+ "application/javascript",
2445
+ "application/ecmascript"
2446
+ ].includes(script.type)) {
2447
+ if (scriptsRun().includes(script.innerText)) {
2448
+ continue;
2449
+ }
2450
+ try {
2451
+ scriptsRun().push(script.innerText);
2452
+ new Function(script.innerText)();
2453
+ } catch (error) {
2454
+ console.warn("`CustomCode`: Error running script:", error);
2443
2455
  }
2444
2456
  }
2445
2457
  }
2446
- }
2447
- let elem;
2448
- onMount(() => {
2449
- findAndRunScripts();
2450
2458
  });
2451
2459
  return <div
2452
2460
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
2453
- ref={elem}
2461
+ ref={elementRef}
2454
2462
  innerHTML={props.code}
2455
2463
  />;
2456
2464
  }
@@ -3108,7 +3116,7 @@ var track = (args) => _track(__spreadProps9(__spreadValues12({}, args), {
3108
3116
  }));
3109
3117
 
3110
3118
  // src/constants/sdk-version.js
3111
- var SDK_VERSION = "0.6.4";
3119
+ var SDK_VERSION = "0.7.1-0";
3112
3120
 
3113
3121
  // src/functions/register.js
3114
3122
  var registry = {};
@@ -3562,18 +3570,28 @@ var __spreadValues15 = (a, b) => {
3562
3570
  }
3563
3571
  return a;
3564
3572
  };
3573
+ var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
3565
3574
  var generateContentUrl = (options) => {
3575
+ let {
3576
+ noTraverse = false
3577
+ } = options;
3566
3578
  const {
3567
3579
  limit = 30,
3568
3580
  userAttributes,
3569
3581
  query,
3570
- noTraverse = false,
3571
3582
  model,
3572
3583
  apiKey,
3573
3584
  includeRefs = true,
3574
3585
  enrich,
3575
3586
  locale,
3576
- apiVersion = DEFAULT_API_VERSION
3587
+ apiVersion = DEFAULT_API_VERSION,
3588
+ fields,
3589
+ omit,
3590
+ offset,
3591
+ cacheSeconds,
3592
+ staleCacheSeconds,
3593
+ sort,
3594
+ includeUnpublished
3577
3595
  } = options;
3578
3596
  if (!apiKey) {
3579
3597
  throw new Error("Missing API key");
@@ -3581,7 +3599,34 @@ var generateContentUrl = (options) => {
3581
3599
  if (!["v2", "v3"].includes(apiVersion)) {
3582
3600
  throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
3583
3601
  }
3602
+ if ((options.limit === void 0 || options.limit > 1) && !("noTraverse" in options)) {
3603
+ noTraverse = true;
3604
+ }
3584
3605
  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}` : ""}`);
3606
+ url.searchParams.set("omit", omit || "meta.componentsUsed");
3607
+ if (fields) {
3608
+ url.searchParams.set("fields", fields);
3609
+ }
3610
+ if (Number.isFinite(offset) && offset > -1) {
3611
+ url.searchParams.set("offset", String(Math.floor(offset)));
3612
+ }
3613
+ if (typeof includeUnpublished === "boolean") {
3614
+ url.searchParams.set("includeUnpublished", String(includeUnpublished));
3615
+ }
3616
+ if (cacheSeconds && isPositiveNumber(cacheSeconds)) {
3617
+ url.searchParams.set("cacheSeconds", String(cacheSeconds));
3618
+ }
3619
+ if (staleCacheSeconds && isPositiveNumber(staleCacheSeconds)) {
3620
+ url.searchParams.set("staleCacheSeconds", String(staleCacheSeconds));
3621
+ }
3622
+ if (sort) {
3623
+ const flattened2 = flatten({
3624
+ sort
3625
+ });
3626
+ for (const key in flattened2) {
3627
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
3628
+ }
3629
+ }
3585
3630
  const queryOptions = __spreadValues15(__spreadValues15({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
3586
3631
  const flattened = flatten(queryOptions);
3587
3632
  for (const key in flattened) {
@@ -3729,9 +3774,6 @@ function isPreviewing() {
3729
3774
 
3730
3775
  // src/components/content/components/enable-editor.jsx
3731
3776
  function EnableEditor(props) {
3732
- const [canTrackToUse, setCanTrackToUse] = createSignal12(
3733
- checkIsDefined(props.canTrack) ? props.canTrack : true
3734
- );
3735
3777
  const [forceReRenderCount, setForceReRenderCount] = createSignal12(0);
3736
3778
  const [lastUpdated, setLastUpdated] = createSignal12(0);
3737
3779
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal12(false);
@@ -3807,7 +3849,7 @@ function EnableEditor(props) {
3807
3849
  const contentId = props.builderContextSignal.content?.id;
3808
3850
  _track({
3809
3851
  type: "click",
3810
- canTrack: canTrackToUse(),
3852
+ canTrack: getDefaultCanTrack(props.canTrack),
3811
3853
  contentId,
3812
3854
  apiKey: props.apiKey,
3813
3855
  variationId: variationId !== contentId ? variationId : void 0,
@@ -3871,13 +3913,8 @@ function EnableEditor(props) {
3871
3913
  }
3872
3914
  let elementRef;
3873
3915
  onMount2(() => {
3874
- if (!props.apiKey) {
3875
- logger.error(
3876
- "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
3877
- );
3878
- }
3879
3916
  if (isBrowser()) {
3880
- if (isEditing()) {
3917
+ if (isEditing() && true) {
3881
3918
  setForceReRenderCount(forceReRenderCount() + 1);
3882
3919
  window.addEventListener("message", processMessage);
3883
3920
  registerInsertMenu();
@@ -3903,18 +3940,20 @@ function EnableEditor(props) {
3903
3940
  emitStateUpdate
3904
3941
  );
3905
3942
  }
3906
- if (props.builderContextSignal.content) {
3943
+ const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
3944
+ if (shouldTrackImpression) {
3907
3945
  const variationId = props.builderContextSignal.content?.testVariationId;
3908
3946
  const contentId = props.builderContextSignal.content?.id;
3947
+ const apiKeyProp = props.apiKey;
3909
3948
  _track({
3910
3949
  type: "impression",
3911
- canTrack: canTrackToUse(),
3950
+ canTrack: true,
3912
3951
  contentId,
3913
- apiKey: props.apiKey,
3952
+ apiKey: apiKeyProp,
3914
3953
  variationId: variationId !== contentId ? variationId : void 0
3915
3954
  });
3916
3955
  }
3917
- if (isPreviewing()) {
3956
+ if (isPreviewing() && true) {
3918
3957
  const searchParams = new URL(location.href).searchParams;
3919
3958
  const searchParamPreviewModel = searchParams.get("builder.preview");
3920
3959
  const searchParamPreviewId = searchParams.get(
@@ -3933,11 +3972,18 @@ function EnableEditor(props) {
3933
3972
  });
3934
3973
  }
3935
3974
  }
3936
- evaluateJsCode();
3937
- runHttpRequests();
3938
- emitStateUpdate();
3939
3975
  }
3940
3976
  });
3977
+ onMount2(() => {
3978
+ if (!props.apiKey) {
3979
+ logger.error(
3980
+ "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
3981
+ );
3982
+ }
3983
+ evaluateJsCode();
3984
+ runHttpRequests();
3985
+ emitStateUpdate();
3986
+ });
3941
3987
  function onUpdateFn_0() {
3942
3988
  if (props.content) {
3943
3989
  mergeNewContent(props.content);
@@ -3974,6 +4020,7 @@ function EnableEditor(props) {
3974
4020
  createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
3975
4021
  return <stdin_default.Provider value={props.builderContextSignal}><Show9 when={props.builderContextSignal.content}><div
3976
4022
  class={props.classNameProp}
4023
+ {...{}}
3977
4024
  key={forceReRenderCount()}
3978
4025
  ref={elementRef}
3979
4026
  onClick={(event) => onClick(event)}