@builder.io/sdk-solid 2.0.21 → 2.0.23

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/lib/edge/dev.js CHANGED
@@ -150,6 +150,12 @@ var logger = {
150
150
  debug: (...message) => console.debug(MSG_PREFIX, ...message)
151
151
  };
152
152
 
153
+ // src/functions/get.ts
154
+ var get = (obj, path, defaultValue) => {
155
+ const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
156
+ return result === void 0 || result === obj ? defaultValue : result;
157
+ };
158
+
153
159
  // src/functions/is-browser.ts
154
160
  function isBrowser() {
155
161
  return typeof window !== "undefined" && typeof document !== "undefined";
@@ -3532,30 +3538,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
3532
3538
  }) ? runInBrowser(args) : runInEdge(args);
3533
3539
 
3534
3540
  // src/functions/evaluate/evaluate.ts
3535
- var DISABLE_CACHE = true;
3536
- var EvalCache = class _EvalCache {
3537
- static cacheLimit = 20;
3538
- static cache = /* @__PURE__ */ new Map();
3539
- static getCacheKey(args) {
3540
- return JSON.stringify({
3541
- ...args,
3542
- // replace the event with a random number to break cache
3543
- // thats because we can't serialize the event object due to circular refs in DOM node refs.
3544
- event: args.event ? Math.random() : void 0
3545
- });
3546
- }
3547
- static getCachedValue(key) {
3548
- const cachedVal = _EvalCache.cache.get(key);
3549
- return cachedVal;
3550
- }
3551
- static setCachedValue(key, value) {
3552
- if (_EvalCache.cache.size > 20) {
3553
- _EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
3554
- }
3555
- _EvalCache.cache.set(key, {
3556
- value
3557
- });
3558
- }
3541
+ var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
3542
+ var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
3543
+ var getSimpleExpressionGetPath = (code) => {
3544
+ return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
3559
3545
  };
3560
3546
  function evaluate({
3561
3547
  code,
@@ -3564,12 +3550,18 @@ function evaluate({
3564
3550
  rootState,
3565
3551
  rootSetState,
3566
3552
  event,
3567
- isExpression = true,
3568
- enableCache
3553
+ isExpression = true
3569
3554
  }) {
3570
- if (code === "") {
3555
+ if (code.trim() === "") {
3571
3556
  return void 0;
3572
3557
  }
3558
+ const getPath = getSimpleExpressionGetPath(code.trim());
3559
+ if (getPath) {
3560
+ return get({
3561
+ ...rootState,
3562
+ ...localState
3563
+ }, getPath);
3564
+ }
3573
3565
  const args = {
3574
3566
  code: parseCode(code, {
3575
3567
  isExpression
@@ -3581,19 +3573,8 @@ function evaluate({
3581
3573
  rootState,
3582
3574
  localState
3583
3575
  };
3584
- if (enableCache && !DISABLE_CACHE) {
3585
- const cacheKey = EvalCache.getCacheKey(args);
3586
- const cachedValue = EvalCache.getCachedValue(cacheKey);
3587
- if (cachedValue) {
3588
- return cachedValue.value;
3589
- }
3590
- }
3591
3576
  try {
3592
3577
  const newEval = chooseBrowserOrServerEval(args);
3593
- if (enableCache) {
3594
- const cacheKey = EvalCache.getCacheKey(args);
3595
- EvalCache.setCachedValue(cacheKey, newEval);
3596
- }
3597
3578
  return newEval;
3598
3579
  } catch (e) {
3599
3580
  logger.error("Failed code evaluation: " + e.message, {
@@ -3687,8 +3668,7 @@ var evaluateBindings = ({
3687
3668
  localState,
3688
3669
  rootState,
3689
3670
  rootSetState,
3690
- context,
3691
- enableCache: true
3671
+ context
3692
3672
  });
3693
3673
  set(copied, binding, value);
3694
3674
  }
@@ -3994,8 +3974,7 @@ var getRepeatItemData = ({
3994
3974
  localState: context.localState,
3995
3975
  rootState: context.rootState,
3996
3976
  rootSetState: context.rootSetState,
3997
- context: context.context,
3998
- enableCache: true
3977
+ context: context.context
3999
3978
  });
4000
3979
  if (!Array.isArray(itemsArray)) {
4001
3980
  return void 0;
@@ -4200,8 +4179,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
4200
4179
  rootState: options.rootState,
4201
4180
  rootSetState: options.rootSetState,
4202
4181
  event,
4203
- isExpression: false,
4204
- enableCache: true
4182
+ isExpression: false
4205
4183
  });
4206
4184
 
4207
4185
  // src/functions/get-block-actions.ts
@@ -6589,8 +6567,7 @@ function Text(props) {
6589
6567
  context: contextContext,
6590
6568
  localState,
6591
6569
  rootState,
6592
- rootSetState,
6593
- enableCache: false
6570
+ rootSetState
6594
6571
  }));
6595
6572
  });
6596
6573
  return (() => {
@@ -6995,12 +6972,6 @@ var getEnv = () => {
6995
6972
  return validEnvList.includes(env) ? env : "production";
6996
6973
  };
6997
6974
 
6998
- // src/functions/get.ts
6999
- var get = (obj, path, defaultValue) => {
7000
- const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
7001
- return result === void 0 || result === obj ? defaultValue : result;
7002
- };
7003
-
7004
6975
  // src/blocks/form/form/form.tsx
7005
6976
  var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
7006
6977
  var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
@@ -8468,7 +8439,7 @@ function isFromTrustedHost(trustedHosts, e) {
8468
8439
  }
8469
8440
 
8470
8441
  // src/constants/sdk-version.ts
8471
- var SDK_VERSION = "2.0.21";
8442
+ var SDK_VERSION = "2.0.23";
8472
8443
 
8473
8444
  // src/functions/register.ts
8474
8445
  var registry = {};
@@ -8855,8 +8826,7 @@ function EnableEditor(props) {
8855
8826
  context: props.context || {},
8856
8827
  localState: void 0,
8857
8828
  rootState: props.builderContextSignal.rootState,
8858
- rootSetState: props.builderContextSignal.rootSetState,
8859
- enableCache: true
8829
+ rootSetState: props.builderContextSignal.rootSetState
8860
8830
  })));
8861
8831
  fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
8862
8832
  mergeNewRootState({
@@ -9150,11 +9120,7 @@ function ContentComponent(props) {
9150
9120
  rootState: newState
9151
9121
  }));
9152
9122
  },
9153
- isExpression: false,
9154
- /**
9155
- * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
9156
- */
9157
- enableCache: false
9123
+ isExpression: false
9158
9124
  });
9159
9125
  }
9160
9126
  return createComponent(components_context_default.Provider, {
package/lib/edge/dev.jsx CHANGED
@@ -145,6 +145,12 @@ var logger = {
145
145
  debug: (...message) => console.debug(MSG_PREFIX, ...message)
146
146
  };
147
147
 
148
+ // src/functions/get.ts
149
+ var get = (obj, path, defaultValue) => {
150
+ const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
151
+ return result === void 0 || result === obj ? defaultValue : result;
152
+ };
153
+
148
154
  // src/functions/is-browser.ts
149
155
  function isBrowser() {
150
156
  return typeof window !== "undefined" && typeof document !== "undefined";
@@ -3527,30 +3533,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
3527
3533
  }) ? runInBrowser(args) : runInEdge(args);
3528
3534
 
3529
3535
  // src/functions/evaluate/evaluate.ts
3530
- var DISABLE_CACHE = true;
3531
- var EvalCache = class _EvalCache {
3532
- static cacheLimit = 20;
3533
- static cache = /* @__PURE__ */ new Map();
3534
- static getCacheKey(args) {
3535
- return JSON.stringify({
3536
- ...args,
3537
- // replace the event with a random number to break cache
3538
- // thats because we can't serialize the event object due to circular refs in DOM node refs.
3539
- event: args.event ? Math.random() : void 0
3540
- });
3541
- }
3542
- static getCachedValue(key) {
3543
- const cachedVal = _EvalCache.cache.get(key);
3544
- return cachedVal;
3545
- }
3546
- static setCachedValue(key, value) {
3547
- if (_EvalCache.cache.size > 20) {
3548
- _EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
3549
- }
3550
- _EvalCache.cache.set(key, {
3551
- value
3552
- });
3553
- }
3536
+ var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
3537
+ var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
3538
+ var getSimpleExpressionGetPath = (code) => {
3539
+ return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
3554
3540
  };
3555
3541
  function evaluate({
3556
3542
  code,
@@ -3559,12 +3545,18 @@ function evaluate({
3559
3545
  rootState,
3560
3546
  rootSetState,
3561
3547
  event,
3562
- isExpression = true,
3563
- enableCache
3548
+ isExpression = true
3564
3549
  }) {
3565
- if (code === "") {
3550
+ if (code.trim() === "") {
3566
3551
  return void 0;
3567
3552
  }
3553
+ const getPath = getSimpleExpressionGetPath(code.trim());
3554
+ if (getPath) {
3555
+ return get({
3556
+ ...rootState,
3557
+ ...localState
3558
+ }, getPath);
3559
+ }
3568
3560
  const args = {
3569
3561
  code: parseCode(code, {
3570
3562
  isExpression
@@ -3576,19 +3568,8 @@ function evaluate({
3576
3568
  rootState,
3577
3569
  localState
3578
3570
  };
3579
- if (enableCache && !DISABLE_CACHE) {
3580
- const cacheKey = EvalCache.getCacheKey(args);
3581
- const cachedValue = EvalCache.getCachedValue(cacheKey);
3582
- if (cachedValue) {
3583
- return cachedValue.value;
3584
- }
3585
- }
3586
3571
  try {
3587
3572
  const newEval = chooseBrowserOrServerEval(args);
3588
- if (enableCache) {
3589
- const cacheKey = EvalCache.getCacheKey(args);
3590
- EvalCache.setCachedValue(cacheKey, newEval);
3591
- }
3592
3573
  return newEval;
3593
3574
  } catch (e) {
3594
3575
  logger.error("Failed code evaluation: " + e.message, {
@@ -3682,8 +3663,7 @@ var evaluateBindings = ({
3682
3663
  localState,
3683
3664
  rootState,
3684
3665
  rootSetState,
3685
- context,
3686
- enableCache: true
3666
+ context
3687
3667
  });
3688
3668
  set(copied, binding, value);
3689
3669
  }
@@ -3989,8 +3969,7 @@ var getRepeatItemData = ({
3989
3969
  localState: context.localState,
3990
3970
  rootState: context.rootState,
3991
3971
  rootSetState: context.rootSetState,
3992
- context: context.context,
3993
- enableCache: true
3972
+ context: context.context
3994
3973
  });
3995
3974
  if (!Array.isArray(itemsArray)) {
3996
3975
  return void 0;
@@ -4193,8 +4172,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
4193
4172
  rootState: options.rootState,
4194
4173
  rootSetState: options.rootSetState,
4195
4174
  event,
4196
- isExpression: false,
4197
- enableCache: true
4175
+ isExpression: false
4198
4176
  });
4199
4177
 
4200
4178
  // src/functions/get-block-actions.ts
@@ -6234,8 +6212,7 @@ function Text(props) {
6234
6212
  context: contextContext,
6235
6213
  localState,
6236
6214
  rootState,
6237
- rootSetState,
6238
- enableCache: false
6215
+ rootSetState
6239
6216
  })
6240
6217
  );
6241
6218
  });
@@ -6639,12 +6616,6 @@ var getEnv = () => {
6639
6616
  return validEnvList.includes(env) ? env : "production";
6640
6617
  };
6641
6618
 
6642
- // src/functions/get.ts
6643
- var get = (obj, path, defaultValue) => {
6644
- const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
6645
- return result === void 0 || result === obj ? defaultValue : result;
6646
- };
6647
-
6648
6619
  // src/blocks/form/form/form.tsx
6649
6620
  function FormComponent(props) {
6650
6621
  const [formState, setFormState] = createSignal14("unsubmitted");
@@ -7956,7 +7927,7 @@ function isFromTrustedHost(trustedHosts, e) {
7956
7927
  }
7957
7928
 
7958
7929
  // src/constants/sdk-version.ts
7959
- var SDK_VERSION = "2.0.21";
7930
+ var SDK_VERSION = "2.0.23";
7960
7931
 
7961
7932
  // src/functions/register.ts
7962
7933
  var registry = {};
@@ -8345,8 +8316,7 @@ function EnableEditor(props) {
8345
8316
  context: props.context || {},
8346
8317
  localState: void 0,
8347
8318
  rootState: props.builderContextSignal.rootState,
8348
- rootSetState: props.builderContextSignal.rootSetState,
8349
- enableCache: true
8319
+ rootSetState: props.builderContextSignal.rootSetState
8350
8320
  })
8351
8321
  )
8352
8322
  );
@@ -8646,11 +8616,7 @@ function ContentComponent(props) {
8646
8616
  rootState: newState
8647
8617
  }));
8648
8618
  },
8649
- isExpression: false,
8650
- /**
8651
- * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
8652
- */
8653
- enableCache: false
8619
+ isExpression: false
8654
8620
  });
8655
8621
  }
8656
8622
  return <><components_context_default.Provider
package/lib/edge/index.js CHANGED
@@ -149,6 +149,12 @@ var logger = {
149
149
  debug: (...message) => void 0
150
150
  };
151
151
 
152
+ // src/functions/get.ts
153
+ var get = (obj, path, defaultValue) => {
154
+ const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
155
+ return result === void 0 || result === obj ? defaultValue : result;
156
+ };
157
+
152
158
  // src/functions/is-browser.ts
153
159
  function isBrowser() {
154
160
  return typeof window !== "undefined" && typeof document !== "undefined";
@@ -3530,30 +3536,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
3530
3536
  }) ? runInBrowser(args) : runInEdge(args);
3531
3537
 
3532
3538
  // src/functions/evaluate/evaluate.ts
3533
- var DISABLE_CACHE = true;
3534
- var EvalCache = class _EvalCache {
3535
- static cacheLimit = 20;
3536
- static cache = /* @__PURE__ */ new Map();
3537
- static getCacheKey(args) {
3538
- return JSON.stringify({
3539
- ...args,
3540
- // replace the event with a random number to break cache
3541
- // thats because we can't serialize the event object due to circular refs in DOM node refs.
3542
- event: args.event ? Math.random() : void 0
3543
- });
3544
- }
3545
- static getCachedValue(key) {
3546
- const cachedVal = _EvalCache.cache.get(key);
3547
- return cachedVal;
3548
- }
3549
- static setCachedValue(key, value) {
3550
- if (_EvalCache.cache.size > 20) {
3551
- _EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
3552
- }
3553
- _EvalCache.cache.set(key, {
3554
- value
3555
- });
3556
- }
3539
+ var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
3540
+ var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
3541
+ var getSimpleExpressionGetPath = (code) => {
3542
+ return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
3557
3543
  };
3558
3544
  function evaluate({
3559
3545
  code,
@@ -3562,12 +3548,18 @@ function evaluate({
3562
3548
  rootState,
3563
3549
  rootSetState,
3564
3550
  event,
3565
- isExpression = true,
3566
- enableCache
3551
+ isExpression = true
3567
3552
  }) {
3568
- if (code === "") {
3553
+ if (code.trim() === "") {
3569
3554
  return void 0;
3570
3555
  }
3556
+ const getPath = getSimpleExpressionGetPath(code.trim());
3557
+ if (getPath) {
3558
+ return get({
3559
+ ...rootState,
3560
+ ...localState
3561
+ }, getPath);
3562
+ }
3571
3563
  const args = {
3572
3564
  code: parseCode(code, {
3573
3565
  isExpression
@@ -3579,19 +3571,8 @@ function evaluate({
3579
3571
  rootState,
3580
3572
  localState
3581
3573
  };
3582
- if (enableCache && !DISABLE_CACHE) {
3583
- const cacheKey = EvalCache.getCacheKey(args);
3584
- const cachedValue = EvalCache.getCachedValue(cacheKey);
3585
- if (cachedValue) {
3586
- return cachedValue.value;
3587
- }
3588
- }
3589
3574
  try {
3590
3575
  const newEval = chooseBrowserOrServerEval(args);
3591
- if (enableCache) {
3592
- const cacheKey = EvalCache.getCacheKey(args);
3593
- EvalCache.setCachedValue(cacheKey, newEval);
3594
- }
3595
3576
  return newEval;
3596
3577
  } catch (e) {
3597
3578
  logger.error("Failed code evaluation: " + e.message, {
@@ -3685,8 +3666,7 @@ var evaluateBindings = ({
3685
3666
  localState,
3686
3667
  rootState,
3687
3668
  rootSetState,
3688
- context,
3689
- enableCache: true
3669
+ context
3690
3670
  });
3691
3671
  set(copied, binding, value);
3692
3672
  }
@@ -3988,8 +3968,7 @@ var getRepeatItemData = ({
3988
3968
  localState: context.localState,
3989
3969
  rootState: context.rootState,
3990
3970
  rootSetState: context.rootSetState,
3991
- context: context.context,
3992
- enableCache: true
3971
+ context: context.context
3993
3972
  });
3994
3973
  if (!Array.isArray(itemsArray)) {
3995
3974
  return void 0;
@@ -4194,8 +4173,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
4194
4173
  rootState: options.rootState,
4195
4174
  rootSetState: options.rootSetState,
4196
4175
  event,
4197
- isExpression: false,
4198
- enableCache: true
4176
+ isExpression: false
4199
4177
  });
4200
4178
 
4201
4179
  // src/functions/get-block-actions.ts
@@ -6581,8 +6559,7 @@ function Text(props) {
6581
6559
  context: contextContext,
6582
6560
  localState,
6583
6561
  rootState,
6584
- rootSetState,
6585
- enableCache: false
6562
+ rootSetState
6586
6563
  }));
6587
6564
  });
6588
6565
  return (() => {
@@ -6985,12 +6962,6 @@ var getEnv = () => {
6985
6962
  return validEnvList.includes(env) ? env : "production";
6986
6963
  };
6987
6964
 
6988
- // src/functions/get.ts
6989
- var get = (obj, path, defaultValue) => {
6990
- const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
6991
- return result === void 0 || result === obj ? defaultValue : result;
6992
- };
6993
-
6994
6965
  // src/blocks/form/form/form.tsx
6995
6966
  var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
6996
6967
  var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
@@ -8453,7 +8424,7 @@ function isFromTrustedHost(trustedHosts, e) {
8453
8424
  }
8454
8425
 
8455
8426
  // src/constants/sdk-version.ts
8456
- var SDK_VERSION = "2.0.21";
8427
+ var SDK_VERSION = "2.0.23";
8457
8428
 
8458
8429
  // src/functions/register.ts
8459
8430
  var registry = {};
@@ -8839,8 +8810,7 @@ function EnableEditor(props) {
8839
8810
  context: props.context || {},
8840
8811
  localState: void 0,
8841
8812
  rootState: props.builderContextSignal.rootState,
8842
- rootSetState: props.builderContextSignal.rootSetState,
8843
- enableCache: true
8813
+ rootSetState: props.builderContextSignal.rootSetState
8844
8814
  })));
8845
8815
  fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
8846
8816
  mergeNewRootState({
@@ -9133,11 +9103,7 @@ function ContentComponent(props) {
9133
9103
  rootState: newState
9134
9104
  }));
9135
9105
  },
9136
- isExpression: false,
9137
- /**
9138
- * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
9139
- */
9140
- enableCache: false
9106
+ isExpression: false
9141
9107
  });
9142
9108
  }
9143
9109
  return createComponent(components_context_default.Provider, {
@@ -144,6 +144,12 @@ var logger = {
144
144
  debug: (...message) => void 0
145
145
  };
146
146
 
147
+ // src/functions/get.ts
148
+ var get = (obj, path, defaultValue) => {
149
+ const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
150
+ return result === void 0 || result === obj ? defaultValue : result;
151
+ };
152
+
147
153
  // src/functions/is-browser.ts
148
154
  function isBrowser() {
149
155
  return typeof window !== "undefined" && typeof document !== "undefined";
@@ -3525,30 +3531,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
3525
3531
  }) ? runInBrowser(args) : runInEdge(args);
3526
3532
 
3527
3533
  // src/functions/evaluate/evaluate.ts
3528
- var DISABLE_CACHE = true;
3529
- var EvalCache = class _EvalCache {
3530
- static cacheLimit = 20;
3531
- static cache = /* @__PURE__ */ new Map();
3532
- static getCacheKey(args) {
3533
- return JSON.stringify({
3534
- ...args,
3535
- // replace the event with a random number to break cache
3536
- // thats because we can't serialize the event object due to circular refs in DOM node refs.
3537
- event: args.event ? Math.random() : void 0
3538
- });
3539
- }
3540
- static getCachedValue(key) {
3541
- const cachedVal = _EvalCache.cache.get(key);
3542
- return cachedVal;
3543
- }
3544
- static setCachedValue(key, value) {
3545
- if (_EvalCache.cache.size > 20) {
3546
- _EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
3547
- }
3548
- _EvalCache.cache.set(key, {
3549
- value
3550
- });
3551
- }
3534
+ var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
3535
+ var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
3536
+ var getSimpleExpressionGetPath = (code) => {
3537
+ return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
3552
3538
  };
3553
3539
  function evaluate({
3554
3540
  code,
@@ -3557,12 +3543,18 @@ function evaluate({
3557
3543
  rootState,
3558
3544
  rootSetState,
3559
3545
  event,
3560
- isExpression = true,
3561
- enableCache
3546
+ isExpression = true
3562
3547
  }) {
3563
- if (code === "") {
3548
+ if (code.trim() === "") {
3564
3549
  return void 0;
3565
3550
  }
3551
+ const getPath = getSimpleExpressionGetPath(code.trim());
3552
+ if (getPath) {
3553
+ return get({
3554
+ ...rootState,
3555
+ ...localState
3556
+ }, getPath);
3557
+ }
3566
3558
  const args = {
3567
3559
  code: parseCode(code, {
3568
3560
  isExpression
@@ -3574,19 +3566,8 @@ function evaluate({
3574
3566
  rootState,
3575
3567
  localState
3576
3568
  };
3577
- if (enableCache && !DISABLE_CACHE) {
3578
- const cacheKey = EvalCache.getCacheKey(args);
3579
- const cachedValue = EvalCache.getCachedValue(cacheKey);
3580
- if (cachedValue) {
3581
- return cachedValue.value;
3582
- }
3583
- }
3584
3569
  try {
3585
3570
  const newEval = chooseBrowserOrServerEval(args);
3586
- if (enableCache) {
3587
- const cacheKey = EvalCache.getCacheKey(args);
3588
- EvalCache.setCachedValue(cacheKey, newEval);
3589
- }
3590
3571
  return newEval;
3591
3572
  } catch (e) {
3592
3573
  logger.error("Failed code evaluation: " + e.message, {
@@ -3680,8 +3661,7 @@ var evaluateBindings = ({
3680
3661
  localState,
3681
3662
  rootState,
3682
3663
  rootSetState,
3683
- context,
3684
- enableCache: true
3664
+ context
3685
3665
  });
3686
3666
  set(copied, binding, value);
3687
3667
  }
@@ -3983,8 +3963,7 @@ var getRepeatItemData = ({
3983
3963
  localState: context.localState,
3984
3964
  rootState: context.rootState,
3985
3965
  rootSetState: context.rootSetState,
3986
- context: context.context,
3987
- enableCache: true
3966
+ context: context.context
3988
3967
  });
3989
3968
  if (!Array.isArray(itemsArray)) {
3990
3969
  return void 0;
@@ -4187,8 +4166,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
4187
4166
  rootState: options.rootState,
4188
4167
  rootSetState: options.rootSetState,
4189
4168
  event,
4190
- isExpression: false,
4191
- enableCache: true
4169
+ isExpression: false
4192
4170
  });
4193
4171
 
4194
4172
  // src/functions/get-block-actions.ts
@@ -6226,8 +6204,7 @@ function Text(props) {
6226
6204
  context: contextContext,
6227
6205
  localState,
6228
6206
  rootState,
6229
- rootSetState,
6230
- enableCache: false
6207
+ rootSetState
6231
6208
  })
6232
6209
  );
6233
6210
  });
@@ -6629,12 +6606,6 @@ var getEnv = () => {
6629
6606
  return validEnvList.includes(env) ? env : "production";
6630
6607
  };
6631
6608
 
6632
- // src/functions/get.ts
6633
- var get = (obj, path, defaultValue) => {
6634
- const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
6635
- return result === void 0 || result === obj ? defaultValue : result;
6636
- };
6637
-
6638
6609
  // src/blocks/form/form/form.tsx
6639
6610
  function FormComponent(props) {
6640
6611
  const [formState, setFormState] = createSignal14("unsubmitted");
@@ -7941,7 +7912,7 @@ function isFromTrustedHost(trustedHosts, e) {
7941
7912
  }
7942
7913
 
7943
7914
  // src/constants/sdk-version.ts
7944
- var SDK_VERSION = "2.0.21";
7915
+ var SDK_VERSION = "2.0.23";
7945
7916
 
7946
7917
  // src/functions/register.ts
7947
7918
  var registry = {};
@@ -8329,8 +8300,7 @@ function EnableEditor(props) {
8329
8300
  context: props.context || {},
8330
8301
  localState: void 0,
8331
8302
  rootState: props.builderContextSignal.rootState,
8332
- rootSetState: props.builderContextSignal.rootSetState,
8333
- enableCache: true
8303
+ rootSetState: props.builderContextSignal.rootSetState
8334
8304
  })
8335
8305
  )
8336
8306
  );
@@ -8629,11 +8599,7 @@ function ContentComponent(props) {
8629
8599
  rootState: newState
8630
8600
  }));
8631
8601
  },
8632
- isExpression: false,
8633
- /**
8634
- * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
8635
- */
8636
- enableCache: false
8602
+ isExpression: false
8637
8603
  });
8638
8604
  }
8639
8605
  return <><components_context_default.Provider