@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/dist/index.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ type BlocksWrapperProps = {
|
|
|
98
98
|
*/
|
|
99
99
|
BlocksWrapperProps: any;
|
|
100
100
|
children?: any;
|
|
101
|
+
classNameProp?: string;
|
|
101
102
|
};
|
|
102
103
|
|
|
103
104
|
type ApiVersion = 'v3';
|
|
@@ -650,10 +651,11 @@ interface VideoProps {
|
|
|
650
651
|
|
|
651
652
|
declare function Video(props: VideoProps): solid_js.JSX.Element;
|
|
652
653
|
|
|
653
|
-
type BlocksProps = Partial<Omit<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps'>> & {
|
|
654
|
+
type BlocksProps = Partial<Omit<BlocksWrapperProps, 'BlocksWrapper' | 'BlocksWrapperProps' | 'classNameProp'>> & {
|
|
654
655
|
context?: BuilderContextInterface;
|
|
655
656
|
registeredComponents?: RegisteredComponents;
|
|
656
657
|
linkComponent?: any;
|
|
658
|
+
className?: string;
|
|
657
659
|
};
|
|
658
660
|
|
|
659
661
|
declare function Blocks(props: BlocksProps): solid_js.JSX.Element;
|
package/lib/browser/dev.js
CHANGED
|
@@ -144,6 +144,12 @@ var logger = {
|
|
|
144
144
|
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
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";
|
|
@@ -349,30 +355,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
|
|
|
349
355
|
}) ? runInBrowser(args) : runInBrowser(args);
|
|
350
356
|
|
|
351
357
|
// src/functions/evaluate/evaluate.ts
|
|
352
|
-
var
|
|
353
|
-
var
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
static getCacheKey(args) {
|
|
357
|
-
return JSON.stringify({
|
|
358
|
-
...args,
|
|
359
|
-
// replace the event with a random number to break cache
|
|
360
|
-
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
361
|
-
event: args.event ? Math.random() : void 0
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
static getCachedValue(key) {
|
|
365
|
-
const cachedVal = _EvalCache.cache.get(key);
|
|
366
|
-
return cachedVal;
|
|
367
|
-
}
|
|
368
|
-
static setCachedValue(key, value) {
|
|
369
|
-
if (_EvalCache.cache.size > 20) {
|
|
370
|
-
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
371
|
-
}
|
|
372
|
-
_EvalCache.cache.set(key, {
|
|
373
|
-
value
|
|
374
|
-
});
|
|
375
|
-
}
|
|
358
|
+
var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
|
|
359
|
+
var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
|
|
360
|
+
var getSimpleExpressionGetPath = (code) => {
|
|
361
|
+
return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
|
|
376
362
|
};
|
|
377
363
|
function evaluate({
|
|
378
364
|
code,
|
|
@@ -381,12 +367,18 @@ function evaluate({
|
|
|
381
367
|
rootState,
|
|
382
368
|
rootSetState,
|
|
383
369
|
event,
|
|
384
|
-
isExpression = true
|
|
385
|
-
enableCache
|
|
370
|
+
isExpression = true
|
|
386
371
|
}) {
|
|
387
|
-
if (code === "") {
|
|
372
|
+
if (code.trim() === "") {
|
|
388
373
|
return void 0;
|
|
389
374
|
}
|
|
375
|
+
const getPath = getSimpleExpressionGetPath(code.trim());
|
|
376
|
+
if (getPath) {
|
|
377
|
+
return get({
|
|
378
|
+
...rootState,
|
|
379
|
+
...localState
|
|
380
|
+
}, getPath);
|
|
381
|
+
}
|
|
390
382
|
const args = {
|
|
391
383
|
code: parseCode(code, {
|
|
392
384
|
isExpression
|
|
@@ -398,19 +390,8 @@ function evaluate({
|
|
|
398
390
|
rootState,
|
|
399
391
|
localState
|
|
400
392
|
};
|
|
401
|
-
if (enableCache && !DISABLE_CACHE) {
|
|
402
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
403
|
-
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
404
|
-
if (cachedValue) {
|
|
405
|
-
return cachedValue.value;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
393
|
try {
|
|
409
394
|
const newEval = chooseBrowserOrServerEval(args);
|
|
410
|
-
if (enableCache) {
|
|
411
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
412
|
-
EvalCache.setCachedValue(cacheKey, newEval);
|
|
413
|
-
}
|
|
414
395
|
return newEval;
|
|
415
396
|
} catch (e) {
|
|
416
397
|
logger.error("Failed code evaluation: " + e.message, {
|
|
@@ -504,8 +485,7 @@ var evaluateBindings = ({
|
|
|
504
485
|
localState,
|
|
505
486
|
rootState,
|
|
506
487
|
rootSetState,
|
|
507
|
-
context
|
|
508
|
-
enableCache: true
|
|
488
|
+
context
|
|
509
489
|
});
|
|
510
490
|
set(copied, binding, value);
|
|
511
491
|
}
|
|
@@ -811,8 +791,7 @@ var getRepeatItemData = ({
|
|
|
811
791
|
localState: context.localState,
|
|
812
792
|
rootState: context.rootState,
|
|
813
793
|
rootSetState: context.rootSetState,
|
|
814
|
-
context: context.context
|
|
815
|
-
enableCache: true
|
|
794
|
+
context: context.context
|
|
816
795
|
});
|
|
817
796
|
if (!Array.isArray(itemsArray)) {
|
|
818
797
|
return void 0;
|
|
@@ -1017,8 +996,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
1017
996
|
rootState: options.rootState,
|
|
1018
997
|
rootSetState: options.rootSetState,
|
|
1019
998
|
event,
|
|
1020
|
-
isExpression: false
|
|
1021
|
-
enableCache: true
|
|
999
|
+
isExpression: false
|
|
1022
1000
|
});
|
|
1023
1001
|
|
|
1024
1002
|
// src/functions/get-block-actions.ts
|
|
@@ -1543,14 +1521,14 @@ function Block(props) {
|
|
|
1543
1521
|
});
|
|
1544
1522
|
}
|
|
1545
1523
|
var block_default = Block;
|
|
1546
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1524
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-6567ee94 {
|
|
1547
1525
|
display: flex;
|
|
1548
1526
|
flex-direction: column;
|
|
1549
1527
|
align-items: stretch;
|
|
1550
1528
|
}`);
|
|
1551
1529
|
function BlocksWrapper(props) {
|
|
1552
1530
|
const className = createMemo(() => {
|
|
1553
|
-
return "builder-blocks"
|
|
1531
|
+
return ["builder-blocks", !props.blocks?.length ? "no-blocks" : "", props.classNameProp].filter(Boolean).join(" ");
|
|
1554
1532
|
});
|
|
1555
1533
|
function onClick() {
|
|
1556
1534
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -1579,7 +1557,7 @@ function BlocksWrapper(props) {
|
|
|
1579
1557
|
});
|
|
1580
1558
|
return [createComponent(Dynamic, mergeProps({
|
|
1581
1559
|
get ["class"]() {
|
|
1582
|
-
return className() + " dynamic-
|
|
1560
|
+
return className() + " dynamic-6567ee94";
|
|
1583
1561
|
},
|
|
1584
1562
|
ref(r$) {
|
|
1585
1563
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1626,11 +1604,14 @@ function Blocks(props) {
|
|
|
1626
1604
|
get styleProp() {
|
|
1627
1605
|
return props.styleProp;
|
|
1628
1606
|
},
|
|
1607
|
+
get classNameProp() {
|
|
1608
|
+
return props.className;
|
|
1609
|
+
},
|
|
1629
1610
|
get BlocksWrapper() {
|
|
1630
|
-
return props.context?.BlocksWrapper || builderContext
|
|
1611
|
+
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1631
1612
|
},
|
|
1632
1613
|
get BlocksWrapperProps() {
|
|
1633
|
-
return props.context?.BlocksWrapperProps || builderContext
|
|
1614
|
+
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1634
1615
|
},
|
|
1635
1616
|
get children() {
|
|
1636
1617
|
return createComponent(Show, {
|
|
@@ -1656,7 +1637,7 @@ function Blocks(props) {
|
|
|
1656
1637
|
return props.context || builderContext;
|
|
1657
1638
|
},
|
|
1658
1639
|
get registeredComponents() {
|
|
1659
|
-
return props.registeredComponents || componentsContext
|
|
1640
|
+
return props.registeredComponents || componentsContext?.registeredComponents;
|
|
1660
1641
|
}
|
|
1661
1642
|
});
|
|
1662
1643
|
}
|
|
@@ -3406,8 +3387,7 @@ function Text(props) {
|
|
|
3406
3387
|
context: contextContext,
|
|
3407
3388
|
localState,
|
|
3408
3389
|
rootState,
|
|
3409
|
-
rootSetState
|
|
3410
|
-
enableCache: false
|
|
3390
|
+
rootSetState
|
|
3411
3391
|
}));
|
|
3412
3392
|
});
|
|
3413
3393
|
return (() => {
|
|
@@ -3812,12 +3792,6 @@ var getEnv = () => {
|
|
|
3812
3792
|
return validEnvList.includes(env) ? env : "production";
|
|
3813
3793
|
};
|
|
3814
3794
|
|
|
3815
|
-
// src/functions/get.ts
|
|
3816
|
-
var get = (obj, path, defaultValue) => {
|
|
3817
|
-
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
3818
|
-
return result === void 0 || result === obj ? defaultValue : result;
|
|
3819
|
-
};
|
|
3820
|
-
|
|
3821
3795
|
// src/blocks/form/form/form.tsx
|
|
3822
3796
|
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
|
|
3823
3797
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
@@ -5285,7 +5259,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5285
5259
|
}
|
|
5286
5260
|
|
|
5287
5261
|
// src/constants/sdk-version.ts
|
|
5288
|
-
var SDK_VERSION = "2.0.
|
|
5262
|
+
var SDK_VERSION = "2.0.24";
|
|
5289
5263
|
|
|
5290
5264
|
// src/functions/register.ts
|
|
5291
5265
|
var registry = {};
|
|
@@ -5672,8 +5646,7 @@ function EnableEditor(props) {
|
|
|
5672
5646
|
context: props.context || {},
|
|
5673
5647
|
localState: void 0,
|
|
5674
5648
|
rootState: props.builderContextSignal.rootState,
|
|
5675
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5676
|
-
enableCache: true
|
|
5649
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5677
5650
|
})));
|
|
5678
5651
|
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
5679
5652
|
mergeNewRootState({
|
|
@@ -5967,11 +5940,7 @@ function ContentComponent(props) {
|
|
|
5967
5940
|
rootState: newState
|
|
5968
5941
|
}));
|
|
5969
5942
|
},
|
|
5970
|
-
isExpression: false
|
|
5971
|
-
/**
|
|
5972
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5973
|
-
*/
|
|
5974
|
-
enableCache: false
|
|
5943
|
+
isExpression: false
|
|
5975
5944
|
});
|
|
5976
5945
|
}
|
|
5977
5946
|
return createComponent(components_context_default.Provider, {
|
package/lib/browser/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";
|
|
@@ -342,30 +348,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
|
|
|
342
348
|
}) ? runInBrowser(args) : runInBrowser(args);
|
|
343
349
|
|
|
344
350
|
// src/functions/evaluate/evaluate.ts
|
|
345
|
-
var
|
|
346
|
-
var
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
static getCacheKey(args) {
|
|
350
|
-
return JSON.stringify({
|
|
351
|
-
...args,
|
|
352
|
-
// replace the event with a random number to break cache
|
|
353
|
-
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
354
|
-
event: args.event ? Math.random() : void 0
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
static getCachedValue(key) {
|
|
358
|
-
const cachedVal = _EvalCache.cache.get(key);
|
|
359
|
-
return cachedVal;
|
|
360
|
-
}
|
|
361
|
-
static setCachedValue(key, value) {
|
|
362
|
-
if (_EvalCache.cache.size > 20) {
|
|
363
|
-
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
364
|
-
}
|
|
365
|
-
_EvalCache.cache.set(key, {
|
|
366
|
-
value
|
|
367
|
-
});
|
|
368
|
-
}
|
|
351
|
+
var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
|
|
352
|
+
var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
|
|
353
|
+
var getSimpleExpressionGetPath = (code) => {
|
|
354
|
+
return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
|
|
369
355
|
};
|
|
370
356
|
function evaluate({
|
|
371
357
|
code,
|
|
@@ -374,12 +360,18 @@ function evaluate({
|
|
|
374
360
|
rootState,
|
|
375
361
|
rootSetState,
|
|
376
362
|
event,
|
|
377
|
-
isExpression = true
|
|
378
|
-
enableCache
|
|
363
|
+
isExpression = true
|
|
379
364
|
}) {
|
|
380
|
-
if (code === "") {
|
|
365
|
+
if (code.trim() === "") {
|
|
381
366
|
return void 0;
|
|
382
367
|
}
|
|
368
|
+
const getPath = getSimpleExpressionGetPath(code.trim());
|
|
369
|
+
if (getPath) {
|
|
370
|
+
return get({
|
|
371
|
+
...rootState,
|
|
372
|
+
...localState
|
|
373
|
+
}, getPath);
|
|
374
|
+
}
|
|
383
375
|
const args = {
|
|
384
376
|
code: parseCode(code, {
|
|
385
377
|
isExpression
|
|
@@ -391,19 +383,8 @@ function evaluate({
|
|
|
391
383
|
rootState,
|
|
392
384
|
localState
|
|
393
385
|
};
|
|
394
|
-
if (enableCache && !DISABLE_CACHE) {
|
|
395
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
396
|
-
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
397
|
-
if (cachedValue) {
|
|
398
|
-
return cachedValue.value;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
386
|
try {
|
|
402
387
|
const newEval = chooseBrowserOrServerEval(args);
|
|
403
|
-
if (enableCache) {
|
|
404
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
405
|
-
EvalCache.setCachedValue(cacheKey, newEval);
|
|
406
|
-
}
|
|
407
388
|
return newEval;
|
|
408
389
|
} catch (e) {
|
|
409
390
|
logger.error("Failed code evaluation: " + e.message, {
|
|
@@ -497,8 +478,7 @@ var evaluateBindings = ({
|
|
|
497
478
|
localState,
|
|
498
479
|
rootState,
|
|
499
480
|
rootSetState,
|
|
500
|
-
context
|
|
501
|
-
enableCache: true
|
|
481
|
+
context
|
|
502
482
|
});
|
|
503
483
|
set(copied, binding, value);
|
|
504
484
|
}
|
|
@@ -804,8 +784,7 @@ var getRepeatItemData = ({
|
|
|
804
784
|
localState: context.localState,
|
|
805
785
|
rootState: context.rootState,
|
|
806
786
|
rootSetState: context.rootSetState,
|
|
807
|
-
context: context.context
|
|
808
|
-
enableCache: true
|
|
787
|
+
context: context.context
|
|
809
788
|
});
|
|
810
789
|
if (!Array.isArray(itemsArray)) {
|
|
811
790
|
return void 0;
|
|
@@ -1008,8 +987,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
1008
987
|
rootState: options.rootState,
|
|
1009
988
|
rootSetState: options.rootSetState,
|
|
1010
989
|
event,
|
|
1011
|
-
isExpression: false
|
|
1012
|
-
enableCache: true
|
|
990
|
+
isExpression: false
|
|
1013
991
|
});
|
|
1014
992
|
|
|
1015
993
|
// src/functions/get-block-actions.ts
|
|
@@ -1379,7 +1357,11 @@ import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
|
|
|
1379
1357
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1380
1358
|
function BlocksWrapper(props) {
|
|
1381
1359
|
const className = createMemo6(() => {
|
|
1382
|
-
return
|
|
1360
|
+
return [
|
|
1361
|
+
"builder-blocks",
|
|
1362
|
+
!props.blocks?.length ? "no-blocks" : "",
|
|
1363
|
+
props.classNameProp
|
|
1364
|
+
].filter(Boolean).join(" ");
|
|
1383
1365
|
});
|
|
1384
1366
|
function onClick() {
|
|
1385
1367
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -1414,7 +1396,7 @@ function BlocksWrapper(props) {
|
|
|
1414
1396
|
});
|
|
1415
1397
|
return <>
|
|
1416
1398
|
<Dynamic4
|
|
1417
|
-
class={className() + " dynamic-
|
|
1399
|
+
class={className() + " dynamic-6567ee94"}
|
|
1418
1400
|
ref={blocksWrapperRef}
|
|
1419
1401
|
builder-path={props.path}
|
|
1420
1402
|
builder-parent-id={props.parent}
|
|
@@ -1426,7 +1408,7 @@ function BlocksWrapper(props) {
|
|
|
1426
1408
|
{...props.BlocksWrapperProps}
|
|
1427
1409
|
component={props.BlocksWrapper}
|
|
1428
1410
|
>{props.children}</Dynamic4>
|
|
1429
|
-
<style>{`.dynamic-
|
|
1411
|
+
<style>{`.dynamic-6567ee94 {
|
|
1430
1412
|
display: flex;
|
|
1431
1413
|
flex-direction: column;
|
|
1432
1414
|
align-items: stretch;
|
|
@@ -1444,8 +1426,9 @@ function Blocks(props) {
|
|
|
1444
1426
|
parent={props.parent}
|
|
1445
1427
|
path={props.path}
|
|
1446
1428
|
styleProp={props.styleProp}
|
|
1447
|
-
|
|
1448
|
-
|
|
1429
|
+
classNameProp={props.className}
|
|
1430
|
+
BlocksWrapper={props.context?.BlocksWrapper || builderContext?.BlocksWrapper}
|
|
1431
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps}
|
|
1449
1432
|
><Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
1450
1433
|
const index = _index();
|
|
1451
1434
|
return <Block_default
|
|
@@ -1453,7 +1436,7 @@ function Blocks(props) {
|
|
|
1453
1436
|
block={block}
|
|
1454
1437
|
linkComponent={props.linkComponent}
|
|
1455
1438
|
context={props.context || builderContext}
|
|
1456
|
-
registeredComponents={props.registeredComponents || componentsContext
|
|
1439
|
+
registeredComponents={props.registeredComponents || componentsContext?.registeredComponents}
|
|
1457
1440
|
/>;
|
|
1458
1441
|
}}</For3></Show6></Blocks_wrapper_default></>;
|
|
1459
1442
|
}
|
|
@@ -3049,8 +3032,7 @@ function Text(props) {
|
|
|
3049
3032
|
context: contextContext,
|
|
3050
3033
|
localState,
|
|
3051
3034
|
rootState,
|
|
3052
|
-
rootSetState
|
|
3053
|
-
enableCache: false
|
|
3035
|
+
rootSetState
|
|
3054
3036
|
})
|
|
3055
3037
|
);
|
|
3056
3038
|
});
|
|
@@ -3454,12 +3436,6 @@ var getEnv = () => {
|
|
|
3454
3436
|
return validEnvList.includes(env) ? env : "production";
|
|
3455
3437
|
};
|
|
3456
3438
|
|
|
3457
|
-
// src/functions/get.ts
|
|
3458
|
-
var get = (obj, path, defaultValue) => {
|
|
3459
|
-
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
3460
|
-
return result === void 0 || result === obj ? defaultValue : result;
|
|
3461
|
-
};
|
|
3462
|
-
|
|
3463
3439
|
// src/blocks/form/form/form.tsx
|
|
3464
3440
|
function FormComponent(props) {
|
|
3465
3441
|
const [formState, setFormState] = createSignal14("unsubmitted");
|
|
@@ -4771,7 +4747,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4771
4747
|
}
|
|
4772
4748
|
|
|
4773
4749
|
// src/constants/sdk-version.ts
|
|
4774
|
-
var SDK_VERSION = "2.0.
|
|
4750
|
+
var SDK_VERSION = "2.0.24";
|
|
4775
4751
|
|
|
4776
4752
|
// src/functions/register.ts
|
|
4777
4753
|
var registry = {};
|
|
@@ -5160,8 +5136,7 @@ function EnableEditor(props) {
|
|
|
5160
5136
|
context: props.context || {},
|
|
5161
5137
|
localState: void 0,
|
|
5162
5138
|
rootState: props.builderContextSignal.rootState,
|
|
5163
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5164
|
-
enableCache: true
|
|
5139
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5165
5140
|
})
|
|
5166
5141
|
)
|
|
5167
5142
|
);
|
|
@@ -5461,11 +5436,7 @@ function ContentComponent(props) {
|
|
|
5461
5436
|
rootState: newState
|
|
5462
5437
|
}));
|
|
5463
5438
|
},
|
|
5464
|
-
isExpression: false
|
|
5465
|
-
/**
|
|
5466
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5467
|
-
*/
|
|
5468
|
-
enableCache: false
|
|
5439
|
+
isExpression: false
|
|
5469
5440
|
});
|
|
5470
5441
|
}
|
|
5471
5442
|
return <><components_context_default.Provider
|
package/lib/browser/index.js
CHANGED
|
@@ -143,6 +143,12 @@ var logger = {
|
|
|
143
143
|
debug: (...message) => void 0
|
|
144
144
|
};
|
|
145
145
|
|
|
146
|
+
// src/functions/get.ts
|
|
147
|
+
var get = (obj, path, defaultValue) => {
|
|
148
|
+
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
149
|
+
return result === void 0 || result === obj ? defaultValue : result;
|
|
150
|
+
};
|
|
151
|
+
|
|
146
152
|
// src/functions/is-browser.ts
|
|
147
153
|
function isBrowser() {
|
|
148
154
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
@@ -347,30 +353,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
|
|
|
347
353
|
}) ? runInBrowser(args) : runInBrowser(args);
|
|
348
354
|
|
|
349
355
|
// src/functions/evaluate/evaluate.ts
|
|
350
|
-
var
|
|
351
|
-
var
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
static getCacheKey(args) {
|
|
355
|
-
return JSON.stringify({
|
|
356
|
-
...args,
|
|
357
|
-
// replace the event with a random number to break cache
|
|
358
|
-
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
359
|
-
event: args.event ? Math.random() : void 0
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
static getCachedValue(key) {
|
|
363
|
-
const cachedVal = _EvalCache.cache.get(key);
|
|
364
|
-
return cachedVal;
|
|
365
|
-
}
|
|
366
|
-
static setCachedValue(key, value) {
|
|
367
|
-
if (_EvalCache.cache.size > 20) {
|
|
368
|
-
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
369
|
-
}
|
|
370
|
-
_EvalCache.cache.set(key, {
|
|
371
|
-
value
|
|
372
|
-
});
|
|
373
|
-
}
|
|
356
|
+
var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
|
|
357
|
+
var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
|
|
358
|
+
var getSimpleExpressionGetPath = (code) => {
|
|
359
|
+
return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
|
|
374
360
|
};
|
|
375
361
|
function evaluate({
|
|
376
362
|
code,
|
|
@@ -379,12 +365,18 @@ function evaluate({
|
|
|
379
365
|
rootState,
|
|
380
366
|
rootSetState,
|
|
381
367
|
event,
|
|
382
|
-
isExpression = true
|
|
383
|
-
enableCache
|
|
368
|
+
isExpression = true
|
|
384
369
|
}) {
|
|
385
|
-
if (code === "") {
|
|
370
|
+
if (code.trim() === "") {
|
|
386
371
|
return void 0;
|
|
387
372
|
}
|
|
373
|
+
const getPath = getSimpleExpressionGetPath(code.trim());
|
|
374
|
+
if (getPath) {
|
|
375
|
+
return get({
|
|
376
|
+
...rootState,
|
|
377
|
+
...localState
|
|
378
|
+
}, getPath);
|
|
379
|
+
}
|
|
388
380
|
const args = {
|
|
389
381
|
code: parseCode(code, {
|
|
390
382
|
isExpression
|
|
@@ -396,19 +388,8 @@ function evaluate({
|
|
|
396
388
|
rootState,
|
|
397
389
|
localState
|
|
398
390
|
};
|
|
399
|
-
if (enableCache && !DISABLE_CACHE) {
|
|
400
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
401
|
-
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
402
|
-
if (cachedValue) {
|
|
403
|
-
return cachedValue.value;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
391
|
try {
|
|
407
392
|
const newEval = chooseBrowserOrServerEval(args);
|
|
408
|
-
if (enableCache) {
|
|
409
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
410
|
-
EvalCache.setCachedValue(cacheKey, newEval);
|
|
411
|
-
}
|
|
412
393
|
return newEval;
|
|
413
394
|
} catch (e) {
|
|
414
395
|
logger.error("Failed code evaluation: " + e.message, {
|
|
@@ -502,8 +483,7 @@ var evaluateBindings = ({
|
|
|
502
483
|
localState,
|
|
503
484
|
rootState,
|
|
504
485
|
rootSetState,
|
|
505
|
-
context
|
|
506
|
-
enableCache: true
|
|
486
|
+
context
|
|
507
487
|
});
|
|
508
488
|
set(copied, binding, value);
|
|
509
489
|
}
|
|
@@ -805,8 +785,7 @@ var getRepeatItemData = ({
|
|
|
805
785
|
localState: context.localState,
|
|
806
786
|
rootState: context.rootState,
|
|
807
787
|
rootSetState: context.rootSetState,
|
|
808
|
-
context: context.context
|
|
809
|
-
enableCache: true
|
|
788
|
+
context: context.context
|
|
810
789
|
});
|
|
811
790
|
if (!Array.isArray(itemsArray)) {
|
|
812
791
|
return void 0;
|
|
@@ -1011,8 +990,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
1011
990
|
rootState: options.rootState,
|
|
1012
991
|
rootSetState: options.rootSetState,
|
|
1013
992
|
event,
|
|
1014
|
-
isExpression: false
|
|
1015
|
-
enableCache: true
|
|
993
|
+
isExpression: false
|
|
1016
994
|
});
|
|
1017
995
|
|
|
1018
996
|
// src/functions/get-block-actions.ts
|
|
@@ -1537,14 +1515,14 @@ function Block(props) {
|
|
|
1537
1515
|
});
|
|
1538
1516
|
}
|
|
1539
1517
|
var block_default = Block;
|
|
1540
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1518
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-6567ee94 {
|
|
1541
1519
|
display: flex;
|
|
1542
1520
|
flex-direction: column;
|
|
1543
1521
|
align-items: stretch;
|
|
1544
1522
|
}`);
|
|
1545
1523
|
function BlocksWrapper(props) {
|
|
1546
1524
|
const className = createMemo(() => {
|
|
1547
|
-
return "builder-blocks"
|
|
1525
|
+
return ["builder-blocks", !props.blocks?.length ? "no-blocks" : "", props.classNameProp].filter(Boolean).join(" ");
|
|
1548
1526
|
});
|
|
1549
1527
|
function onClick() {
|
|
1550
1528
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -1573,7 +1551,7 @@ function BlocksWrapper(props) {
|
|
|
1573
1551
|
});
|
|
1574
1552
|
return [createComponent(Dynamic, mergeProps({
|
|
1575
1553
|
get ["class"]() {
|
|
1576
|
-
return className() + " dynamic-
|
|
1554
|
+
return className() + " dynamic-6567ee94";
|
|
1577
1555
|
},
|
|
1578
1556
|
ref(r$) {
|
|
1579
1557
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1620,11 +1598,14 @@ function Blocks(props) {
|
|
|
1620
1598
|
get styleProp() {
|
|
1621
1599
|
return props.styleProp;
|
|
1622
1600
|
},
|
|
1601
|
+
get classNameProp() {
|
|
1602
|
+
return props.className;
|
|
1603
|
+
},
|
|
1623
1604
|
get BlocksWrapper() {
|
|
1624
|
-
return props.context?.BlocksWrapper || builderContext
|
|
1605
|
+
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1625
1606
|
},
|
|
1626
1607
|
get BlocksWrapperProps() {
|
|
1627
|
-
return props.context?.BlocksWrapperProps || builderContext
|
|
1608
|
+
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1628
1609
|
},
|
|
1629
1610
|
get children() {
|
|
1630
1611
|
return createComponent(Show, {
|
|
@@ -1650,7 +1631,7 @@ function Blocks(props) {
|
|
|
1650
1631
|
return props.context || builderContext;
|
|
1651
1632
|
},
|
|
1652
1633
|
get registeredComponents() {
|
|
1653
|
-
return props.registeredComponents || componentsContext
|
|
1634
|
+
return props.registeredComponents || componentsContext?.registeredComponents;
|
|
1654
1635
|
}
|
|
1655
1636
|
});
|
|
1656
1637
|
}
|
|
@@ -3398,8 +3379,7 @@ function Text(props) {
|
|
|
3398
3379
|
context: contextContext,
|
|
3399
3380
|
localState,
|
|
3400
3381
|
rootState,
|
|
3401
|
-
rootSetState
|
|
3402
|
-
enableCache: false
|
|
3382
|
+
rootSetState
|
|
3403
3383
|
}));
|
|
3404
3384
|
});
|
|
3405
3385
|
return (() => {
|
|
@@ -3802,12 +3782,6 @@ var getEnv = () => {
|
|
|
3802
3782
|
return validEnvList.includes(env) ? env : "production";
|
|
3803
3783
|
};
|
|
3804
3784
|
|
|
3805
|
-
// src/functions/get.ts
|
|
3806
|
-
var get = (obj, path, defaultValue) => {
|
|
3807
|
-
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
3808
|
-
return result === void 0 || result === obj ? defaultValue : result;
|
|
3809
|
-
};
|
|
3810
|
-
|
|
3811
3785
|
// src/blocks/form/form/form.tsx
|
|
3812
3786
|
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
|
|
3813
3787
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
@@ -5270,7 +5244,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5270
5244
|
}
|
|
5271
5245
|
|
|
5272
5246
|
// src/constants/sdk-version.ts
|
|
5273
|
-
var SDK_VERSION = "2.0.
|
|
5247
|
+
var SDK_VERSION = "2.0.24";
|
|
5274
5248
|
|
|
5275
5249
|
// src/functions/register.ts
|
|
5276
5250
|
var registry = {};
|
|
@@ -5656,8 +5630,7 @@ function EnableEditor(props) {
|
|
|
5656
5630
|
context: props.context || {},
|
|
5657
5631
|
localState: void 0,
|
|
5658
5632
|
rootState: props.builderContextSignal.rootState,
|
|
5659
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5660
|
-
enableCache: true
|
|
5633
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5661
5634
|
})));
|
|
5662
5635
|
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
5663
5636
|
mergeNewRootState({
|
|
@@ -5950,11 +5923,7 @@ function ContentComponent(props) {
|
|
|
5950
5923
|
rootState: newState
|
|
5951
5924
|
}));
|
|
5952
5925
|
},
|
|
5953
|
-
isExpression: false
|
|
5954
|
-
/**
|
|
5955
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5956
|
-
*/
|
|
5957
|
-
enableCache: false
|
|
5926
|
+
isExpression: false
|
|
5958
5927
|
});
|
|
5959
5928
|
}
|
|
5960
5929
|
return createComponent(components_context_default.Provider, {
|