@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/node/dev.jsx
CHANGED
|
@@ -137,6 +137,12 @@ var logger = {
|
|
|
137
137
|
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
+
// src/functions/get.ts
|
|
141
|
+
var get = (obj, path, defaultValue) => {
|
|
142
|
+
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
143
|
+
return result === void 0 || result === obj ? defaultValue : result;
|
|
144
|
+
};
|
|
145
|
+
|
|
140
146
|
// src/functions/is-browser.ts
|
|
141
147
|
function isBrowser() {
|
|
142
148
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
@@ -527,30 +533,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
|
|
|
527
533
|
}) ? runInBrowser(args) : runInNode(args);
|
|
528
534
|
|
|
529
535
|
// src/functions/evaluate/evaluate.ts
|
|
530
|
-
var
|
|
531
|
-
var
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
static getCacheKey(args) {
|
|
535
|
-
return JSON.stringify({
|
|
536
|
-
...args,
|
|
537
|
-
// replace the event with a random number to break cache
|
|
538
|
-
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
539
|
-
event: args.event ? Math.random() : void 0
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
static getCachedValue(key) {
|
|
543
|
-
const cachedVal = _EvalCache.cache.get(key);
|
|
544
|
-
return cachedVal;
|
|
545
|
-
}
|
|
546
|
-
static setCachedValue(key, value) {
|
|
547
|
-
if (_EvalCache.cache.size > 20) {
|
|
548
|
-
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
549
|
-
}
|
|
550
|
-
_EvalCache.cache.set(key, {
|
|
551
|
-
value
|
|
552
|
-
});
|
|
553
|
-
}
|
|
536
|
+
var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
|
|
537
|
+
var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
|
|
538
|
+
var getSimpleExpressionGetPath = (code) => {
|
|
539
|
+
return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
|
|
554
540
|
};
|
|
555
541
|
function evaluate({
|
|
556
542
|
code,
|
|
@@ -559,12 +545,18 @@ function evaluate({
|
|
|
559
545
|
rootState,
|
|
560
546
|
rootSetState,
|
|
561
547
|
event,
|
|
562
|
-
isExpression = true
|
|
563
|
-
enableCache
|
|
548
|
+
isExpression = true
|
|
564
549
|
}) {
|
|
565
|
-
if (code === "") {
|
|
550
|
+
if (code.trim() === "") {
|
|
566
551
|
return void 0;
|
|
567
552
|
}
|
|
553
|
+
const getPath = getSimpleExpressionGetPath(code.trim());
|
|
554
|
+
if (getPath) {
|
|
555
|
+
return get({
|
|
556
|
+
...rootState,
|
|
557
|
+
...localState
|
|
558
|
+
}, getPath);
|
|
559
|
+
}
|
|
568
560
|
const args = {
|
|
569
561
|
code: parseCode(code, {
|
|
570
562
|
isExpression
|
|
@@ -576,19 +568,8 @@ function evaluate({
|
|
|
576
568
|
rootState,
|
|
577
569
|
localState
|
|
578
570
|
};
|
|
579
|
-
if (enableCache && !DISABLE_CACHE) {
|
|
580
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
581
|
-
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
582
|
-
if (cachedValue) {
|
|
583
|
-
return cachedValue.value;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
571
|
try {
|
|
587
572
|
const newEval = chooseBrowserOrServerEval(args);
|
|
588
|
-
if (enableCache) {
|
|
589
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
590
|
-
EvalCache.setCachedValue(cacheKey, newEval);
|
|
591
|
-
}
|
|
592
573
|
return newEval;
|
|
593
574
|
} catch (e) {
|
|
594
575
|
logger.error("Failed code evaluation: " + e.message, {
|
|
@@ -669,8 +650,7 @@ var evaluateBindings = ({
|
|
|
669
650
|
localState,
|
|
670
651
|
rootState,
|
|
671
652
|
rootSetState,
|
|
672
|
-
context
|
|
673
|
-
enableCache: true
|
|
653
|
+
context
|
|
674
654
|
});
|
|
675
655
|
set(copied, binding, value);
|
|
676
656
|
}
|
|
@@ -976,8 +956,7 @@ var getRepeatItemData = ({
|
|
|
976
956
|
localState: context.localState,
|
|
977
957
|
rootState: context.rootState,
|
|
978
958
|
rootSetState: context.rootSetState,
|
|
979
|
-
context: context.context
|
|
980
|
-
enableCache: true
|
|
959
|
+
context: context.context
|
|
981
960
|
});
|
|
982
961
|
if (!Array.isArray(itemsArray)) {
|
|
983
962
|
return void 0;
|
|
@@ -1180,8 +1159,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
1180
1159
|
rootState: options.rootState,
|
|
1181
1160
|
rootSetState: options.rootSetState,
|
|
1182
1161
|
event,
|
|
1183
|
-
isExpression: false
|
|
1184
|
-
enableCache: true
|
|
1162
|
+
isExpression: false
|
|
1185
1163
|
});
|
|
1186
1164
|
|
|
1187
1165
|
// src/functions/get-block-actions.ts
|
|
@@ -1551,7 +1529,11 @@ import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
|
|
|
1551
1529
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1552
1530
|
function BlocksWrapper(props) {
|
|
1553
1531
|
const className = createMemo6(() => {
|
|
1554
|
-
return
|
|
1532
|
+
return [
|
|
1533
|
+
"builder-blocks",
|
|
1534
|
+
!props.blocks?.length ? "no-blocks" : "",
|
|
1535
|
+
props.classNameProp
|
|
1536
|
+
].filter(Boolean).join(" ");
|
|
1555
1537
|
});
|
|
1556
1538
|
function onClick() {
|
|
1557
1539
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -1586,7 +1568,7 @@ function BlocksWrapper(props) {
|
|
|
1586
1568
|
});
|
|
1587
1569
|
return <>
|
|
1588
1570
|
<Dynamic4
|
|
1589
|
-
class={className() + " dynamic-
|
|
1571
|
+
class={className() + " dynamic-6567ee94"}
|
|
1590
1572
|
ref={blocksWrapperRef}
|
|
1591
1573
|
builder-path={props.path}
|
|
1592
1574
|
builder-parent-id={props.parent}
|
|
@@ -1598,7 +1580,7 @@ function BlocksWrapper(props) {
|
|
|
1598
1580
|
{...props.BlocksWrapperProps}
|
|
1599
1581
|
component={props.BlocksWrapper}
|
|
1600
1582
|
>{props.children}</Dynamic4>
|
|
1601
|
-
<style>{`.dynamic-
|
|
1583
|
+
<style>{`.dynamic-6567ee94 {
|
|
1602
1584
|
display: flex;
|
|
1603
1585
|
flex-direction: column;
|
|
1604
1586
|
align-items: stretch;
|
|
@@ -1616,8 +1598,9 @@ function Blocks(props) {
|
|
|
1616
1598
|
parent={props.parent}
|
|
1617
1599
|
path={props.path}
|
|
1618
1600
|
styleProp={props.styleProp}
|
|
1619
|
-
|
|
1620
|
-
|
|
1601
|
+
classNameProp={props.className}
|
|
1602
|
+
BlocksWrapper={props.context?.BlocksWrapper || builderContext?.BlocksWrapper}
|
|
1603
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps}
|
|
1621
1604
|
><Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
1622
1605
|
const index = _index();
|
|
1623
1606
|
return <Block_default
|
|
@@ -1625,7 +1608,7 @@ function Blocks(props) {
|
|
|
1625
1608
|
block={block}
|
|
1626
1609
|
linkComponent={props.linkComponent}
|
|
1627
1610
|
context={props.context || builderContext}
|
|
1628
|
-
registeredComponents={props.registeredComponents || componentsContext
|
|
1611
|
+
registeredComponents={props.registeredComponents || componentsContext?.registeredComponents}
|
|
1629
1612
|
/>;
|
|
1630
1613
|
}}</For3></Show6></Blocks_wrapper_default></>;
|
|
1631
1614
|
}
|
|
@@ -3221,8 +3204,7 @@ function Text(props) {
|
|
|
3221
3204
|
context: contextContext,
|
|
3222
3205
|
localState,
|
|
3223
3206
|
rootState,
|
|
3224
|
-
rootSetState
|
|
3225
|
-
enableCache: false
|
|
3207
|
+
rootSetState
|
|
3226
3208
|
})
|
|
3227
3209
|
);
|
|
3228
3210
|
});
|
|
@@ -3626,12 +3608,6 @@ var getEnv = () => {
|
|
|
3626
3608
|
return validEnvList.includes(env) ? env : "production";
|
|
3627
3609
|
};
|
|
3628
3610
|
|
|
3629
|
-
// src/functions/get.ts
|
|
3630
|
-
var get = (obj, path, defaultValue) => {
|
|
3631
|
-
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
3632
|
-
return result === void 0 || result === obj ? defaultValue : result;
|
|
3633
|
-
};
|
|
3634
|
-
|
|
3635
3611
|
// src/blocks/form/form/form.tsx
|
|
3636
3612
|
function FormComponent(props) {
|
|
3637
3613
|
const [formState, setFormState] = createSignal14("unsubmitted");
|
|
@@ -4943,7 +4919,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4943
4919
|
}
|
|
4944
4920
|
|
|
4945
4921
|
// src/constants/sdk-version.ts
|
|
4946
|
-
var SDK_VERSION = "2.0.
|
|
4922
|
+
var SDK_VERSION = "2.0.24";
|
|
4947
4923
|
|
|
4948
4924
|
// src/functions/register.ts
|
|
4949
4925
|
var registry = {};
|
|
@@ -5332,8 +5308,7 @@ function EnableEditor(props) {
|
|
|
5332
5308
|
context: props.context || {},
|
|
5333
5309
|
localState: void 0,
|
|
5334
5310
|
rootState: props.builderContextSignal.rootState,
|
|
5335
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5336
|
-
enableCache: true
|
|
5311
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5337
5312
|
})
|
|
5338
5313
|
)
|
|
5339
5314
|
);
|
|
@@ -5633,11 +5608,7 @@ function ContentComponent(props) {
|
|
|
5633
5608
|
rootState: newState
|
|
5634
5609
|
}));
|
|
5635
5610
|
},
|
|
5636
|
-
isExpression: false
|
|
5637
|
-
/**
|
|
5638
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5639
|
-
*/
|
|
5640
|
-
enableCache: false
|
|
5611
|
+
isExpression: false
|
|
5641
5612
|
});
|
|
5642
5613
|
}
|
|
5643
5614
|
return <><components_context_default.Provider
|
package/lib/node/index.js
CHANGED
|
@@ -145,6 +145,12 @@ var logger = {
|
|
|
145
145
|
debug: (...message) => void 0
|
|
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";
|
|
@@ -530,30 +536,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
|
|
|
530
536
|
}) ? runInBrowser(args) : runInNode(args);
|
|
531
537
|
|
|
532
538
|
// src/functions/evaluate/evaluate.ts
|
|
533
|
-
var
|
|
534
|
-
var
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
static getCacheKey(args) {
|
|
538
|
-
return JSON.stringify({
|
|
539
|
-
...args,
|
|
540
|
-
// replace the event with a random number to break cache
|
|
541
|
-
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
542
|
-
event: args.event ? Math.random() : void 0
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
static getCachedValue(key) {
|
|
546
|
-
const cachedVal = _EvalCache.cache.get(key);
|
|
547
|
-
return cachedVal;
|
|
548
|
-
}
|
|
549
|
-
static setCachedValue(key, value) {
|
|
550
|
-
if (_EvalCache.cache.size > 20) {
|
|
551
|
-
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
552
|
-
}
|
|
553
|
-
_EvalCache.cache.set(key, {
|
|
554
|
-
value
|
|
555
|
-
});
|
|
556
|
-
}
|
|
539
|
+
var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
|
|
540
|
+
var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
|
|
541
|
+
var getSimpleExpressionGetPath = (code) => {
|
|
542
|
+
return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
|
|
557
543
|
};
|
|
558
544
|
function evaluate({
|
|
559
545
|
code,
|
|
@@ -562,12 +548,18 @@ function evaluate({
|
|
|
562
548
|
rootState,
|
|
563
549
|
rootSetState,
|
|
564
550
|
event,
|
|
565
|
-
isExpression = true
|
|
566
|
-
enableCache
|
|
551
|
+
isExpression = true
|
|
567
552
|
}) {
|
|
568
|
-
if (code === "") {
|
|
553
|
+
if (code.trim() === "") {
|
|
569
554
|
return void 0;
|
|
570
555
|
}
|
|
556
|
+
const getPath = getSimpleExpressionGetPath(code.trim());
|
|
557
|
+
if (getPath) {
|
|
558
|
+
return get({
|
|
559
|
+
...rootState,
|
|
560
|
+
...localState
|
|
561
|
+
}, getPath);
|
|
562
|
+
}
|
|
571
563
|
const args = {
|
|
572
564
|
code: parseCode(code, {
|
|
573
565
|
isExpression
|
|
@@ -579,19 +571,8 @@ function evaluate({
|
|
|
579
571
|
rootState,
|
|
580
572
|
localState
|
|
581
573
|
};
|
|
582
|
-
if (enableCache && !DISABLE_CACHE) {
|
|
583
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
584
|
-
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
585
|
-
if (cachedValue) {
|
|
586
|
-
return cachedValue.value;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
574
|
try {
|
|
590
575
|
const newEval = chooseBrowserOrServerEval(args);
|
|
591
|
-
if (enableCache) {
|
|
592
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
593
|
-
EvalCache.setCachedValue(cacheKey, newEval);
|
|
594
|
-
}
|
|
595
576
|
return newEval;
|
|
596
577
|
} catch (e) {
|
|
597
578
|
logger.error("Failed code evaluation: " + e.message, {
|
|
@@ -672,8 +653,7 @@ var evaluateBindings = ({
|
|
|
672
653
|
localState,
|
|
673
654
|
rootState,
|
|
674
655
|
rootSetState,
|
|
675
|
-
context
|
|
676
|
-
enableCache: true
|
|
656
|
+
context
|
|
677
657
|
});
|
|
678
658
|
set(copied, binding, value);
|
|
679
659
|
}
|
|
@@ -975,8 +955,7 @@ var getRepeatItemData = ({
|
|
|
975
955
|
localState: context.localState,
|
|
976
956
|
rootState: context.rootState,
|
|
977
957
|
rootSetState: context.rootSetState,
|
|
978
|
-
context: context.context
|
|
979
|
-
enableCache: true
|
|
958
|
+
context: context.context
|
|
980
959
|
});
|
|
981
960
|
if (!Array.isArray(itemsArray)) {
|
|
982
961
|
return void 0;
|
|
@@ -1181,8 +1160,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
1181
1160
|
rootState: options.rootState,
|
|
1182
1161
|
rootSetState: options.rootSetState,
|
|
1183
1162
|
event,
|
|
1184
|
-
isExpression: false
|
|
1185
|
-
enableCache: true
|
|
1163
|
+
isExpression: false
|
|
1186
1164
|
});
|
|
1187
1165
|
|
|
1188
1166
|
// src/functions/get-block-actions.ts
|
|
@@ -1707,14 +1685,14 @@ function Block(props) {
|
|
|
1707
1685
|
});
|
|
1708
1686
|
}
|
|
1709
1687
|
var block_default = Block;
|
|
1710
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1688
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-6567ee94 {
|
|
1711
1689
|
display: flex;
|
|
1712
1690
|
flex-direction: column;
|
|
1713
1691
|
align-items: stretch;
|
|
1714
1692
|
}`);
|
|
1715
1693
|
function BlocksWrapper(props) {
|
|
1716
1694
|
const className = createMemo(() => {
|
|
1717
|
-
return "builder-blocks"
|
|
1695
|
+
return ["builder-blocks", !props.blocks?.length ? "no-blocks" : "", props.classNameProp].filter(Boolean).join(" ");
|
|
1718
1696
|
});
|
|
1719
1697
|
function onClick() {
|
|
1720
1698
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -1743,7 +1721,7 @@ function BlocksWrapper(props) {
|
|
|
1743
1721
|
});
|
|
1744
1722
|
return [createComponent(Dynamic, mergeProps({
|
|
1745
1723
|
get ["class"]() {
|
|
1746
|
-
return className() + " dynamic-
|
|
1724
|
+
return className() + " dynamic-6567ee94";
|
|
1747
1725
|
},
|
|
1748
1726
|
ref(r$) {
|
|
1749
1727
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1790,11 +1768,14 @@ function Blocks(props) {
|
|
|
1790
1768
|
get styleProp() {
|
|
1791
1769
|
return props.styleProp;
|
|
1792
1770
|
},
|
|
1771
|
+
get classNameProp() {
|
|
1772
|
+
return props.className;
|
|
1773
|
+
},
|
|
1793
1774
|
get BlocksWrapper() {
|
|
1794
|
-
return props.context?.BlocksWrapper || builderContext
|
|
1775
|
+
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1795
1776
|
},
|
|
1796
1777
|
get BlocksWrapperProps() {
|
|
1797
|
-
return props.context?.BlocksWrapperProps || builderContext
|
|
1778
|
+
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1798
1779
|
},
|
|
1799
1780
|
get children() {
|
|
1800
1781
|
return createComponent(Show, {
|
|
@@ -1820,7 +1801,7 @@ function Blocks(props) {
|
|
|
1820
1801
|
return props.context || builderContext;
|
|
1821
1802
|
},
|
|
1822
1803
|
get registeredComponents() {
|
|
1823
|
-
return props.registeredComponents || componentsContext
|
|
1804
|
+
return props.registeredComponents || componentsContext?.registeredComponents;
|
|
1824
1805
|
}
|
|
1825
1806
|
});
|
|
1826
1807
|
}
|
|
@@ -3568,8 +3549,7 @@ function Text(props) {
|
|
|
3568
3549
|
context: contextContext,
|
|
3569
3550
|
localState,
|
|
3570
3551
|
rootState,
|
|
3571
|
-
rootSetState
|
|
3572
|
-
enableCache: false
|
|
3552
|
+
rootSetState
|
|
3573
3553
|
}));
|
|
3574
3554
|
});
|
|
3575
3555
|
return (() => {
|
|
@@ -3972,12 +3952,6 @@ var getEnv = () => {
|
|
|
3972
3952
|
return validEnvList.includes(env) ? env : "production";
|
|
3973
3953
|
};
|
|
3974
3954
|
|
|
3975
|
-
// src/functions/get.ts
|
|
3976
|
-
var get = (obj, path, defaultValue) => {
|
|
3977
|
-
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
3978
|
-
return result === void 0 || result === obj ? defaultValue : result;
|
|
3979
|
-
};
|
|
3980
|
-
|
|
3981
3955
|
// src/blocks/form/form/form.tsx
|
|
3982
3956
|
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
|
|
3983
3957
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
@@ -5440,7 +5414,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5440
5414
|
}
|
|
5441
5415
|
|
|
5442
5416
|
// src/constants/sdk-version.ts
|
|
5443
|
-
var SDK_VERSION = "2.0.
|
|
5417
|
+
var SDK_VERSION = "2.0.24";
|
|
5444
5418
|
|
|
5445
5419
|
// src/functions/register.ts
|
|
5446
5420
|
var registry = {};
|
|
@@ -5826,8 +5800,7 @@ function EnableEditor(props) {
|
|
|
5826
5800
|
context: props.context || {},
|
|
5827
5801
|
localState: void 0,
|
|
5828
5802
|
rootState: props.builderContextSignal.rootState,
|
|
5829
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5830
|
-
enableCache: true
|
|
5803
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5831
5804
|
})));
|
|
5832
5805
|
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
5833
5806
|
mergeNewRootState({
|
|
@@ -6120,11 +6093,7 @@ function ContentComponent(props) {
|
|
|
6120
6093
|
rootState: newState
|
|
6121
6094
|
}));
|
|
6122
6095
|
},
|
|
6123
|
-
isExpression: false
|
|
6124
|
-
/**
|
|
6125
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
6126
|
-
*/
|
|
6127
|
-
enableCache: false
|
|
6096
|
+
isExpression: false
|
|
6128
6097
|
});
|
|
6129
6098
|
}
|
|
6130
6099
|
return createComponent(components_context_default.Provider, {
|
package/lib/node/index.jsx
CHANGED
|
@@ -137,6 +137,12 @@ var logger = {
|
|
|
137
137
|
debug: (...message) => void 0
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
+
// src/functions/get.ts
|
|
141
|
+
var get = (obj, path, defaultValue) => {
|
|
142
|
+
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
143
|
+
return result === void 0 || result === obj ? defaultValue : result;
|
|
144
|
+
};
|
|
145
|
+
|
|
140
146
|
// src/functions/is-browser.ts
|
|
141
147
|
function isBrowser() {
|
|
142
148
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
@@ -525,30 +531,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
|
|
|
525
531
|
}) ? runInBrowser(args) : runInNode(args);
|
|
526
532
|
|
|
527
533
|
// src/functions/evaluate/evaluate.ts
|
|
528
|
-
var
|
|
529
|
-
var
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
static getCacheKey(args) {
|
|
533
|
-
return JSON.stringify({
|
|
534
|
-
...args,
|
|
535
|
-
// replace the event with a random number to break cache
|
|
536
|
-
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
537
|
-
event: args.event ? Math.random() : void 0
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
static getCachedValue(key) {
|
|
541
|
-
const cachedVal = _EvalCache.cache.get(key);
|
|
542
|
-
return cachedVal;
|
|
543
|
-
}
|
|
544
|
-
static setCachedValue(key, value) {
|
|
545
|
-
if (_EvalCache.cache.size > 20) {
|
|
546
|
-
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
547
|
-
}
|
|
548
|
-
_EvalCache.cache.set(key, {
|
|
549
|
-
value
|
|
550
|
-
});
|
|
551
|
-
}
|
|
534
|
+
var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
|
|
535
|
+
var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
|
|
536
|
+
var getSimpleExpressionGetPath = (code) => {
|
|
537
|
+
return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
|
|
552
538
|
};
|
|
553
539
|
function evaluate({
|
|
554
540
|
code,
|
|
@@ -557,12 +543,18 @@ function evaluate({
|
|
|
557
543
|
rootState,
|
|
558
544
|
rootSetState,
|
|
559
545
|
event,
|
|
560
|
-
isExpression = true
|
|
561
|
-
enableCache
|
|
546
|
+
isExpression = true
|
|
562
547
|
}) {
|
|
563
|
-
if (code === "") {
|
|
548
|
+
if (code.trim() === "") {
|
|
564
549
|
return void 0;
|
|
565
550
|
}
|
|
551
|
+
const getPath = getSimpleExpressionGetPath(code.trim());
|
|
552
|
+
if (getPath) {
|
|
553
|
+
return get({
|
|
554
|
+
...rootState,
|
|
555
|
+
...localState
|
|
556
|
+
}, getPath);
|
|
557
|
+
}
|
|
566
558
|
const args = {
|
|
567
559
|
code: parseCode(code, {
|
|
568
560
|
isExpression
|
|
@@ -574,19 +566,8 @@ function evaluate({
|
|
|
574
566
|
rootState,
|
|
575
567
|
localState
|
|
576
568
|
};
|
|
577
|
-
if (enableCache && !DISABLE_CACHE) {
|
|
578
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
579
|
-
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
580
|
-
if (cachedValue) {
|
|
581
|
-
return cachedValue.value;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
569
|
try {
|
|
585
570
|
const newEval = chooseBrowserOrServerEval(args);
|
|
586
|
-
if (enableCache) {
|
|
587
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
588
|
-
EvalCache.setCachedValue(cacheKey, newEval);
|
|
589
|
-
}
|
|
590
571
|
return newEval;
|
|
591
572
|
} catch (e) {
|
|
592
573
|
logger.error("Failed code evaluation: " + e.message, {
|
|
@@ -667,8 +648,7 @@ var evaluateBindings = ({
|
|
|
667
648
|
localState,
|
|
668
649
|
rootState,
|
|
669
650
|
rootSetState,
|
|
670
|
-
context
|
|
671
|
-
enableCache: true
|
|
651
|
+
context
|
|
672
652
|
});
|
|
673
653
|
set(copied, binding, value);
|
|
674
654
|
}
|
|
@@ -970,8 +950,7 @@ var getRepeatItemData = ({
|
|
|
970
950
|
localState: context.localState,
|
|
971
951
|
rootState: context.rootState,
|
|
972
952
|
rootSetState: context.rootSetState,
|
|
973
|
-
context: context.context
|
|
974
|
-
enableCache: true
|
|
953
|
+
context: context.context
|
|
975
954
|
});
|
|
976
955
|
if (!Array.isArray(itemsArray)) {
|
|
977
956
|
return void 0;
|
|
@@ -1174,8 +1153,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
1174
1153
|
rootState: options.rootState,
|
|
1175
1154
|
rootSetState: options.rootSetState,
|
|
1176
1155
|
event,
|
|
1177
|
-
isExpression: false
|
|
1178
|
-
enableCache: true
|
|
1156
|
+
isExpression: false
|
|
1179
1157
|
});
|
|
1180
1158
|
|
|
1181
1159
|
// src/functions/get-block-actions.ts
|
|
@@ -1545,7 +1523,11 @@ import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
|
|
|
1545
1523
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1546
1524
|
function BlocksWrapper(props) {
|
|
1547
1525
|
const className = createMemo6(() => {
|
|
1548
|
-
return
|
|
1526
|
+
return [
|
|
1527
|
+
"builder-blocks",
|
|
1528
|
+
!props.blocks?.length ? "no-blocks" : "",
|
|
1529
|
+
props.classNameProp
|
|
1530
|
+
].filter(Boolean).join(" ");
|
|
1549
1531
|
});
|
|
1550
1532
|
function onClick() {
|
|
1551
1533
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -1580,7 +1562,7 @@ function BlocksWrapper(props) {
|
|
|
1580
1562
|
});
|
|
1581
1563
|
return <>
|
|
1582
1564
|
<Dynamic4
|
|
1583
|
-
class={className() + " dynamic-
|
|
1565
|
+
class={className() + " dynamic-6567ee94"}
|
|
1584
1566
|
ref={blocksWrapperRef}
|
|
1585
1567
|
builder-path={props.path}
|
|
1586
1568
|
builder-parent-id={props.parent}
|
|
@@ -1592,7 +1574,7 @@ function BlocksWrapper(props) {
|
|
|
1592
1574
|
{...props.BlocksWrapperProps}
|
|
1593
1575
|
component={props.BlocksWrapper}
|
|
1594
1576
|
>{props.children}</Dynamic4>
|
|
1595
|
-
<style>{`.dynamic-
|
|
1577
|
+
<style>{`.dynamic-6567ee94 {
|
|
1596
1578
|
display: flex;
|
|
1597
1579
|
flex-direction: column;
|
|
1598
1580
|
align-items: stretch;
|
|
@@ -1610,8 +1592,9 @@ function Blocks(props) {
|
|
|
1610
1592
|
parent={props.parent}
|
|
1611
1593
|
path={props.path}
|
|
1612
1594
|
styleProp={props.styleProp}
|
|
1613
|
-
|
|
1614
|
-
|
|
1595
|
+
classNameProp={props.className}
|
|
1596
|
+
BlocksWrapper={props.context?.BlocksWrapper || builderContext?.BlocksWrapper}
|
|
1597
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps}
|
|
1615
1598
|
><Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
1616
1599
|
const index = _index();
|
|
1617
1600
|
return <Block_default
|
|
@@ -1619,7 +1602,7 @@ function Blocks(props) {
|
|
|
1619
1602
|
block={block}
|
|
1620
1603
|
linkComponent={props.linkComponent}
|
|
1621
1604
|
context={props.context || builderContext}
|
|
1622
|
-
registeredComponents={props.registeredComponents || componentsContext
|
|
1605
|
+
registeredComponents={props.registeredComponents || componentsContext?.registeredComponents}
|
|
1623
1606
|
/>;
|
|
1624
1607
|
}}</For3></Show6></Blocks_wrapper_default></>;
|
|
1625
1608
|
}
|
|
@@ -3213,8 +3196,7 @@ function Text(props) {
|
|
|
3213
3196
|
context: contextContext,
|
|
3214
3197
|
localState,
|
|
3215
3198
|
rootState,
|
|
3216
|
-
rootSetState
|
|
3217
|
-
enableCache: false
|
|
3199
|
+
rootSetState
|
|
3218
3200
|
})
|
|
3219
3201
|
);
|
|
3220
3202
|
});
|
|
@@ -3616,12 +3598,6 @@ var getEnv = () => {
|
|
|
3616
3598
|
return validEnvList.includes(env) ? env : "production";
|
|
3617
3599
|
};
|
|
3618
3600
|
|
|
3619
|
-
// src/functions/get.ts
|
|
3620
|
-
var get = (obj, path, defaultValue) => {
|
|
3621
|
-
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
3622
|
-
return result === void 0 || result === obj ? defaultValue : result;
|
|
3623
|
-
};
|
|
3624
|
-
|
|
3625
3601
|
// src/blocks/form/form/form.tsx
|
|
3626
3602
|
function FormComponent(props) {
|
|
3627
3603
|
const [formState, setFormState] = createSignal14("unsubmitted");
|
|
@@ -4928,7 +4904,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4928
4904
|
}
|
|
4929
4905
|
|
|
4930
4906
|
// src/constants/sdk-version.ts
|
|
4931
|
-
var SDK_VERSION = "2.0.
|
|
4907
|
+
var SDK_VERSION = "2.0.24";
|
|
4932
4908
|
|
|
4933
4909
|
// src/functions/register.ts
|
|
4934
4910
|
var registry = {};
|
|
@@ -5316,8 +5292,7 @@ function EnableEditor(props) {
|
|
|
5316
5292
|
context: props.context || {},
|
|
5317
5293
|
localState: void 0,
|
|
5318
5294
|
rootState: props.builderContextSignal.rootState,
|
|
5319
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5320
|
-
enableCache: true
|
|
5295
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5321
5296
|
})
|
|
5322
5297
|
)
|
|
5323
5298
|
);
|
|
@@ -5616,11 +5591,7 @@ function ContentComponent(props) {
|
|
|
5616
5591
|
rootState: newState
|
|
5617
5592
|
}));
|
|
5618
5593
|
},
|
|
5619
|
-
isExpression: false
|
|
5620
|
-
/**
|
|
5621
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5622
|
-
*/
|
|
5623
|
-
enableCache: false
|
|
5594
|
+
isExpression: false
|
|
5624
5595
|
});
|
|
5625
5596
|
}
|
|
5626
5597
|
return <><components_context_default.Provider
|