@builder.io/sdk-solid 2.0.22 → 2.0.24
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 +3 -1
- package/lib/browser/dev.js +35 -66
- package/lib/browser/dev.jsx +37 -66
- package/lib/browser/index.js +35 -66
- package/lib/browser/index.jsx +37 -66
- package/lib/edge/dev.js +35 -66
- package/lib/edge/dev.jsx +37 -66
- package/lib/edge/index.js +35 -66
- package/lib/edge/index.jsx +37 -66
- package/lib/node/dev.js +35 -66
- package/lib/node/dev.jsx +37 -66
- package/lib/node/index.js +35 -66
- package/lib/node/index.jsx +37 -66
- package/package.json +1 -1
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
|
|
3534
|
-
var
|
|
3535
|
-
|
|
3536
|
-
|
|
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
|
|
@@ -4720,14 +4698,14 @@ function Block(props) {
|
|
|
4720
4698
|
});
|
|
4721
4699
|
}
|
|
4722
4700
|
var block_default = Block;
|
|
4723
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4701
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-6567ee94 {
|
|
4724
4702
|
display: flex;
|
|
4725
4703
|
flex-direction: column;
|
|
4726
4704
|
align-items: stretch;
|
|
4727
4705
|
}`);
|
|
4728
4706
|
function BlocksWrapper(props) {
|
|
4729
4707
|
const className = createMemo(() => {
|
|
4730
|
-
return "builder-blocks"
|
|
4708
|
+
return ["builder-blocks", !props.blocks?.length ? "no-blocks" : "", props.classNameProp].filter(Boolean).join(" ");
|
|
4731
4709
|
});
|
|
4732
4710
|
function onClick() {
|
|
4733
4711
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -4756,7 +4734,7 @@ function BlocksWrapper(props) {
|
|
|
4756
4734
|
});
|
|
4757
4735
|
return [createComponent(Dynamic, mergeProps({
|
|
4758
4736
|
get ["class"]() {
|
|
4759
|
-
return className() + " dynamic-
|
|
4737
|
+
return className() + " dynamic-6567ee94";
|
|
4760
4738
|
},
|
|
4761
4739
|
ref(r$) {
|
|
4762
4740
|
const _ref$ = blocksWrapperRef;
|
|
@@ -4803,11 +4781,14 @@ function Blocks(props) {
|
|
|
4803
4781
|
get styleProp() {
|
|
4804
4782
|
return props.styleProp;
|
|
4805
4783
|
},
|
|
4784
|
+
get classNameProp() {
|
|
4785
|
+
return props.className;
|
|
4786
|
+
},
|
|
4806
4787
|
get BlocksWrapper() {
|
|
4807
|
-
return props.context?.BlocksWrapper || builderContext
|
|
4788
|
+
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
4808
4789
|
},
|
|
4809
4790
|
get BlocksWrapperProps() {
|
|
4810
|
-
return props.context?.BlocksWrapperProps || builderContext
|
|
4791
|
+
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
4811
4792
|
},
|
|
4812
4793
|
get children() {
|
|
4813
4794
|
return createComponent(Show, {
|
|
@@ -4833,7 +4814,7 @@ function Blocks(props) {
|
|
|
4833
4814
|
return props.context || builderContext;
|
|
4834
4815
|
},
|
|
4835
4816
|
get registeredComponents() {
|
|
4836
|
-
return props.registeredComponents || componentsContext
|
|
4817
|
+
return props.registeredComponents || componentsContext?.registeredComponents;
|
|
4837
4818
|
}
|
|
4838
4819
|
});
|
|
4839
4820
|
}
|
|
@@ -6581,8 +6562,7 @@ function Text(props) {
|
|
|
6581
6562
|
context: contextContext,
|
|
6582
6563
|
localState,
|
|
6583
6564
|
rootState,
|
|
6584
|
-
rootSetState
|
|
6585
|
-
enableCache: false
|
|
6565
|
+
rootSetState
|
|
6586
6566
|
}));
|
|
6587
6567
|
});
|
|
6588
6568
|
return (() => {
|
|
@@ -6985,12 +6965,6 @@ var getEnv = () => {
|
|
|
6985
6965
|
return validEnvList.includes(env) ? env : "production";
|
|
6986
6966
|
};
|
|
6987
6967
|
|
|
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
6968
|
// src/blocks/form/form/form.tsx
|
|
6995
6969
|
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
|
|
6996
6970
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
@@ -8453,7 +8427,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
8453
8427
|
}
|
|
8454
8428
|
|
|
8455
8429
|
// src/constants/sdk-version.ts
|
|
8456
|
-
var SDK_VERSION = "2.0.
|
|
8430
|
+
var SDK_VERSION = "2.0.24";
|
|
8457
8431
|
|
|
8458
8432
|
// src/functions/register.ts
|
|
8459
8433
|
var registry = {};
|
|
@@ -8839,8 +8813,7 @@ function EnableEditor(props) {
|
|
|
8839
8813
|
context: props.context || {},
|
|
8840
8814
|
localState: void 0,
|
|
8841
8815
|
rootState: props.builderContextSignal.rootState,
|
|
8842
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
8843
|
-
enableCache: true
|
|
8816
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
8844
8817
|
})));
|
|
8845
8818
|
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
8846
8819
|
mergeNewRootState({
|
|
@@ -9133,11 +9106,7 @@ function ContentComponent(props) {
|
|
|
9133
9106
|
rootState: newState
|
|
9134
9107
|
}));
|
|
9135
9108
|
},
|
|
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
|
|
9109
|
+
isExpression: false
|
|
9141
9110
|
});
|
|
9142
9111
|
}
|
|
9143
9112
|
return createComponent(components_context_default.Provider, {
|
package/lib/edge/index.jsx
CHANGED
|
@@ -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
|
|
3529
|
-
var
|
|
3530
|
-
|
|
3531
|
-
|
|
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
|
|
@@ -4558,7 +4536,11 @@ import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
|
|
|
4558
4536
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
4559
4537
|
function BlocksWrapper(props) {
|
|
4560
4538
|
const className = createMemo6(() => {
|
|
4561
|
-
return
|
|
4539
|
+
return [
|
|
4540
|
+
"builder-blocks",
|
|
4541
|
+
!props.blocks?.length ? "no-blocks" : "",
|
|
4542
|
+
props.classNameProp
|
|
4543
|
+
].filter(Boolean).join(" ");
|
|
4562
4544
|
});
|
|
4563
4545
|
function onClick() {
|
|
4564
4546
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -4593,7 +4575,7 @@ function BlocksWrapper(props) {
|
|
|
4593
4575
|
});
|
|
4594
4576
|
return <>
|
|
4595
4577
|
<Dynamic4
|
|
4596
|
-
class={className() + " dynamic-
|
|
4578
|
+
class={className() + " dynamic-6567ee94"}
|
|
4597
4579
|
ref={blocksWrapperRef}
|
|
4598
4580
|
builder-path={props.path}
|
|
4599
4581
|
builder-parent-id={props.parent}
|
|
@@ -4605,7 +4587,7 @@ function BlocksWrapper(props) {
|
|
|
4605
4587
|
{...props.BlocksWrapperProps}
|
|
4606
4588
|
component={props.BlocksWrapper}
|
|
4607
4589
|
>{props.children}</Dynamic4>
|
|
4608
|
-
<style>{`.dynamic-
|
|
4590
|
+
<style>{`.dynamic-6567ee94 {
|
|
4609
4591
|
display: flex;
|
|
4610
4592
|
flex-direction: column;
|
|
4611
4593
|
align-items: stretch;
|
|
@@ -4623,8 +4605,9 @@ function Blocks(props) {
|
|
|
4623
4605
|
parent={props.parent}
|
|
4624
4606
|
path={props.path}
|
|
4625
4607
|
styleProp={props.styleProp}
|
|
4626
|
-
|
|
4627
|
-
|
|
4608
|
+
classNameProp={props.className}
|
|
4609
|
+
BlocksWrapper={props.context?.BlocksWrapper || builderContext?.BlocksWrapper}
|
|
4610
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps}
|
|
4628
4611
|
><Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
4629
4612
|
const index = _index();
|
|
4630
4613
|
return <Block_default
|
|
@@ -4632,7 +4615,7 @@ function Blocks(props) {
|
|
|
4632
4615
|
block={block}
|
|
4633
4616
|
linkComponent={props.linkComponent}
|
|
4634
4617
|
context={props.context || builderContext}
|
|
4635
|
-
registeredComponents={props.registeredComponents || componentsContext
|
|
4618
|
+
registeredComponents={props.registeredComponents || componentsContext?.registeredComponents}
|
|
4636
4619
|
/>;
|
|
4637
4620
|
}}</For3></Show6></Blocks_wrapper_default></>;
|
|
4638
4621
|
}
|
|
@@ -6226,8 +6209,7 @@ function Text(props) {
|
|
|
6226
6209
|
context: contextContext,
|
|
6227
6210
|
localState,
|
|
6228
6211
|
rootState,
|
|
6229
|
-
rootSetState
|
|
6230
|
-
enableCache: false
|
|
6212
|
+
rootSetState
|
|
6231
6213
|
})
|
|
6232
6214
|
);
|
|
6233
6215
|
});
|
|
@@ -6629,12 +6611,6 @@ var getEnv = () => {
|
|
|
6629
6611
|
return validEnvList.includes(env) ? env : "production";
|
|
6630
6612
|
};
|
|
6631
6613
|
|
|
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
6614
|
// src/blocks/form/form/form.tsx
|
|
6639
6615
|
function FormComponent(props) {
|
|
6640
6616
|
const [formState, setFormState] = createSignal14("unsubmitted");
|
|
@@ -7941,7 +7917,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
7941
7917
|
}
|
|
7942
7918
|
|
|
7943
7919
|
// src/constants/sdk-version.ts
|
|
7944
|
-
var SDK_VERSION = "2.0.
|
|
7920
|
+
var SDK_VERSION = "2.0.24";
|
|
7945
7921
|
|
|
7946
7922
|
// src/functions/register.ts
|
|
7947
7923
|
var registry = {};
|
|
@@ -8329,8 +8305,7 @@ function EnableEditor(props) {
|
|
|
8329
8305
|
context: props.context || {},
|
|
8330
8306
|
localState: void 0,
|
|
8331
8307
|
rootState: props.builderContextSignal.rootState,
|
|
8332
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
8333
|
-
enableCache: true
|
|
8308
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
8334
8309
|
})
|
|
8335
8310
|
)
|
|
8336
8311
|
);
|
|
@@ -8629,11 +8604,7 @@ function ContentComponent(props) {
|
|
|
8629
8604
|
rootState: newState
|
|
8630
8605
|
}));
|
|
8631
8606
|
},
|
|
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
|
|
8607
|
+
isExpression: false
|
|
8637
8608
|
});
|
|
8638
8609
|
}
|
|
8639
8610
|
return <><components_context_default.Provider
|
package/lib/node/dev.js
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";
|
|
@@ -532,30 +538,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
|
|
|
532
538
|
}) ? runInBrowser(args) : runInNode(args);
|
|
533
539
|
|
|
534
540
|
// src/functions/evaluate/evaluate.ts
|
|
535
|
-
var
|
|
536
|
-
var
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
static getCacheKey(args) {
|
|
540
|
-
return JSON.stringify({
|
|
541
|
-
...args,
|
|
542
|
-
// replace the event with a random number to break cache
|
|
543
|
-
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
544
|
-
event: args.event ? Math.random() : void 0
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
static getCachedValue(key) {
|
|
548
|
-
const cachedVal = _EvalCache.cache.get(key);
|
|
549
|
-
return cachedVal;
|
|
550
|
-
}
|
|
551
|
-
static setCachedValue(key, value) {
|
|
552
|
-
if (_EvalCache.cache.size > 20) {
|
|
553
|
-
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
554
|
-
}
|
|
555
|
-
_EvalCache.cache.set(key, {
|
|
556
|
-
value
|
|
557
|
-
});
|
|
558
|
-
}
|
|
541
|
+
var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
|
|
542
|
+
var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
|
|
543
|
+
var getSimpleExpressionGetPath = (code) => {
|
|
544
|
+
return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
|
|
559
545
|
};
|
|
560
546
|
function evaluate({
|
|
561
547
|
code,
|
|
@@ -564,12 +550,18 @@ function evaluate({
|
|
|
564
550
|
rootState,
|
|
565
551
|
rootSetState,
|
|
566
552
|
event,
|
|
567
|
-
isExpression = true
|
|
568
|
-
enableCache
|
|
553
|
+
isExpression = true
|
|
569
554
|
}) {
|
|
570
|
-
if (code === "") {
|
|
555
|
+
if (code.trim() === "") {
|
|
571
556
|
return void 0;
|
|
572
557
|
}
|
|
558
|
+
const getPath = getSimpleExpressionGetPath(code.trim());
|
|
559
|
+
if (getPath) {
|
|
560
|
+
return get({
|
|
561
|
+
...rootState,
|
|
562
|
+
...localState
|
|
563
|
+
}, getPath);
|
|
564
|
+
}
|
|
573
565
|
const args = {
|
|
574
566
|
code: parseCode(code, {
|
|
575
567
|
isExpression
|
|
@@ -581,19 +573,8 @@ function evaluate({
|
|
|
581
573
|
rootState,
|
|
582
574
|
localState
|
|
583
575
|
};
|
|
584
|
-
if (enableCache && !DISABLE_CACHE) {
|
|
585
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
586
|
-
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
587
|
-
if (cachedValue) {
|
|
588
|
-
return cachedValue.value;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
576
|
try {
|
|
592
577
|
const newEval = chooseBrowserOrServerEval(args);
|
|
593
|
-
if (enableCache) {
|
|
594
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
595
|
-
EvalCache.setCachedValue(cacheKey, newEval);
|
|
596
|
-
}
|
|
597
578
|
return newEval;
|
|
598
579
|
} catch (e) {
|
|
599
580
|
logger.error("Failed code evaluation: " + e.message, {
|
|
@@ -674,8 +655,7 @@ var evaluateBindings = ({
|
|
|
674
655
|
localState,
|
|
675
656
|
rootState,
|
|
676
657
|
rootSetState,
|
|
677
|
-
context
|
|
678
|
-
enableCache: true
|
|
658
|
+
context
|
|
679
659
|
});
|
|
680
660
|
set(copied, binding, value);
|
|
681
661
|
}
|
|
@@ -981,8 +961,7 @@ var getRepeatItemData = ({
|
|
|
981
961
|
localState: context.localState,
|
|
982
962
|
rootState: context.rootState,
|
|
983
963
|
rootSetState: context.rootSetState,
|
|
984
|
-
context: context.context
|
|
985
|
-
enableCache: true
|
|
964
|
+
context: context.context
|
|
986
965
|
});
|
|
987
966
|
if (!Array.isArray(itemsArray)) {
|
|
988
967
|
return void 0;
|
|
@@ -1187,8 +1166,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
1187
1166
|
rootState: options.rootState,
|
|
1188
1167
|
rootSetState: options.rootSetState,
|
|
1189
1168
|
event,
|
|
1190
|
-
isExpression: false
|
|
1191
|
-
enableCache: true
|
|
1169
|
+
isExpression: false
|
|
1192
1170
|
});
|
|
1193
1171
|
|
|
1194
1172
|
// src/functions/get-block-actions.ts
|
|
@@ -1713,14 +1691,14 @@ function Block(props) {
|
|
|
1713
1691
|
});
|
|
1714
1692
|
}
|
|
1715
1693
|
var block_default = Block;
|
|
1716
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1694
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-6567ee94 {
|
|
1717
1695
|
display: flex;
|
|
1718
1696
|
flex-direction: column;
|
|
1719
1697
|
align-items: stretch;
|
|
1720
1698
|
}`);
|
|
1721
1699
|
function BlocksWrapper(props) {
|
|
1722
1700
|
const className = createMemo(() => {
|
|
1723
|
-
return "builder-blocks"
|
|
1701
|
+
return ["builder-blocks", !props.blocks?.length ? "no-blocks" : "", props.classNameProp].filter(Boolean).join(" ");
|
|
1724
1702
|
});
|
|
1725
1703
|
function onClick() {
|
|
1726
1704
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -1749,7 +1727,7 @@ function BlocksWrapper(props) {
|
|
|
1749
1727
|
});
|
|
1750
1728
|
return [createComponent(Dynamic, mergeProps({
|
|
1751
1729
|
get ["class"]() {
|
|
1752
|
-
return className() + " dynamic-
|
|
1730
|
+
return className() + " dynamic-6567ee94";
|
|
1753
1731
|
},
|
|
1754
1732
|
ref(r$) {
|
|
1755
1733
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1796,11 +1774,14 @@ function Blocks(props) {
|
|
|
1796
1774
|
get styleProp() {
|
|
1797
1775
|
return props.styleProp;
|
|
1798
1776
|
},
|
|
1777
|
+
get classNameProp() {
|
|
1778
|
+
return props.className;
|
|
1779
|
+
},
|
|
1799
1780
|
get BlocksWrapper() {
|
|
1800
|
-
return props.context?.BlocksWrapper || builderContext
|
|
1781
|
+
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1801
1782
|
},
|
|
1802
1783
|
get BlocksWrapperProps() {
|
|
1803
|
-
return props.context?.BlocksWrapperProps || builderContext
|
|
1784
|
+
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1804
1785
|
},
|
|
1805
1786
|
get children() {
|
|
1806
1787
|
return createComponent(Show, {
|
|
@@ -1826,7 +1807,7 @@ function Blocks(props) {
|
|
|
1826
1807
|
return props.context || builderContext;
|
|
1827
1808
|
},
|
|
1828
1809
|
get registeredComponents() {
|
|
1829
|
-
return props.registeredComponents || componentsContext
|
|
1810
|
+
return props.registeredComponents || componentsContext?.registeredComponents;
|
|
1830
1811
|
}
|
|
1831
1812
|
});
|
|
1832
1813
|
}
|
|
@@ -3576,8 +3557,7 @@ function Text(props) {
|
|
|
3576
3557
|
context: contextContext,
|
|
3577
3558
|
localState,
|
|
3578
3559
|
rootState,
|
|
3579
|
-
rootSetState
|
|
3580
|
-
enableCache: false
|
|
3560
|
+
rootSetState
|
|
3581
3561
|
}));
|
|
3582
3562
|
});
|
|
3583
3563
|
return (() => {
|
|
@@ -3982,12 +3962,6 @@ var getEnv = () => {
|
|
|
3982
3962
|
return validEnvList.includes(env) ? env : "production";
|
|
3983
3963
|
};
|
|
3984
3964
|
|
|
3985
|
-
// src/functions/get.ts
|
|
3986
|
-
var get = (obj, path, defaultValue) => {
|
|
3987
|
-
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
3988
|
-
return result === void 0 || result === obj ? defaultValue : result;
|
|
3989
|
-
};
|
|
3990
|
-
|
|
3991
3965
|
// src/blocks/form/form/form.tsx
|
|
3992
3966
|
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
|
|
3993
3967
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
@@ -5455,7 +5429,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5455
5429
|
}
|
|
5456
5430
|
|
|
5457
5431
|
// src/constants/sdk-version.ts
|
|
5458
|
-
var SDK_VERSION = "2.0.
|
|
5432
|
+
var SDK_VERSION = "2.0.24";
|
|
5459
5433
|
|
|
5460
5434
|
// src/functions/register.ts
|
|
5461
5435
|
var registry = {};
|
|
@@ -5842,8 +5816,7 @@ function EnableEditor(props) {
|
|
|
5842
5816
|
context: props.context || {},
|
|
5843
5817
|
localState: void 0,
|
|
5844
5818
|
rootState: props.builderContextSignal.rootState,
|
|
5845
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5846
|
-
enableCache: true
|
|
5819
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5847
5820
|
})));
|
|
5848
5821
|
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
5849
5822
|
mergeNewRootState({
|
|
@@ -6137,11 +6110,7 @@ function ContentComponent(props) {
|
|
|
6137
6110
|
rootState: newState
|
|
6138
6111
|
}));
|
|
6139
6112
|
},
|
|
6140
|
-
isExpression: false
|
|
6141
|
-
/**
|
|
6142
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
6143
|
-
*/
|
|
6144
|
-
enableCache: false
|
|
6113
|
+
isExpression: false
|
|
6145
6114
|
});
|
|
6146
6115
|
}
|
|
6147
6116
|
return createComponent(components_context_default.Provider, {
|