@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/browser/index.jsx
CHANGED
|
@@ -136,6 +136,12 @@ var logger = {
|
|
|
136
136
|
debug: (...message) => void 0
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
+
// src/functions/get.ts
|
|
140
|
+
var get = (obj, path, defaultValue) => {
|
|
141
|
+
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
142
|
+
return result === void 0 || result === obj ? defaultValue : result;
|
|
143
|
+
};
|
|
144
|
+
|
|
139
145
|
// src/functions/is-browser.ts
|
|
140
146
|
function isBrowser() {
|
|
141
147
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
@@ -340,30 +346,10 @@ var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRunti
|
|
|
340
346
|
}) ? runInBrowser(args) : runInBrowser(args);
|
|
341
347
|
|
|
342
348
|
// src/functions/evaluate/evaluate.ts
|
|
343
|
-
var
|
|
344
|
-
var
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
static getCacheKey(args) {
|
|
348
|
-
return JSON.stringify({
|
|
349
|
-
...args,
|
|
350
|
-
// replace the event with a random number to break cache
|
|
351
|
-
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
352
|
-
event: args.event ? Math.random() : void 0
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
static getCachedValue(key) {
|
|
356
|
-
const cachedVal = _EvalCache.cache.get(key);
|
|
357
|
-
return cachedVal;
|
|
358
|
-
}
|
|
359
|
-
static setCachedValue(key, value) {
|
|
360
|
-
if (_EvalCache.cache.size > 20) {
|
|
361
|
-
_EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
|
|
362
|
-
}
|
|
363
|
-
_EvalCache.cache.set(key, {
|
|
364
|
-
value
|
|
365
|
-
});
|
|
366
|
-
}
|
|
349
|
+
var STATE_GETTER_REGEX = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/;
|
|
350
|
+
var VIRTUAL_INDEX_REGEX = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/;
|
|
351
|
+
var getSimpleExpressionGetPath = (code) => {
|
|
352
|
+
return STATE_GETTER_REGEX.exec(code.trim())?.groups?.getPath?.slice(1) || VIRTUAL_INDEX_REGEX.exec(code.trim())?.groups?.getPath?.slice(1);
|
|
367
353
|
};
|
|
368
354
|
function evaluate({
|
|
369
355
|
code,
|
|
@@ -372,12 +358,18 @@ function evaluate({
|
|
|
372
358
|
rootState,
|
|
373
359
|
rootSetState,
|
|
374
360
|
event,
|
|
375
|
-
isExpression = true
|
|
376
|
-
enableCache
|
|
361
|
+
isExpression = true
|
|
377
362
|
}) {
|
|
378
|
-
if (code === "") {
|
|
363
|
+
if (code.trim() === "") {
|
|
379
364
|
return void 0;
|
|
380
365
|
}
|
|
366
|
+
const getPath = getSimpleExpressionGetPath(code.trim());
|
|
367
|
+
if (getPath) {
|
|
368
|
+
return get({
|
|
369
|
+
...rootState,
|
|
370
|
+
...localState
|
|
371
|
+
}, getPath);
|
|
372
|
+
}
|
|
381
373
|
const args = {
|
|
382
374
|
code: parseCode(code, {
|
|
383
375
|
isExpression
|
|
@@ -389,19 +381,8 @@ function evaluate({
|
|
|
389
381
|
rootState,
|
|
390
382
|
localState
|
|
391
383
|
};
|
|
392
|
-
if (enableCache && !DISABLE_CACHE) {
|
|
393
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
394
|
-
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
395
|
-
if (cachedValue) {
|
|
396
|
-
return cachedValue.value;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
384
|
try {
|
|
400
385
|
const newEval = chooseBrowserOrServerEval(args);
|
|
401
|
-
if (enableCache) {
|
|
402
|
-
const cacheKey = EvalCache.getCacheKey(args);
|
|
403
|
-
EvalCache.setCachedValue(cacheKey, newEval);
|
|
404
|
-
}
|
|
405
386
|
return newEval;
|
|
406
387
|
} catch (e) {
|
|
407
388
|
logger.error("Failed code evaluation: " + e.message, {
|
|
@@ -495,8 +476,7 @@ var evaluateBindings = ({
|
|
|
495
476
|
localState,
|
|
496
477
|
rootState,
|
|
497
478
|
rootSetState,
|
|
498
|
-
context
|
|
499
|
-
enableCache: true
|
|
479
|
+
context
|
|
500
480
|
});
|
|
501
481
|
set(copied, binding, value);
|
|
502
482
|
}
|
|
@@ -798,8 +778,7 @@ var getRepeatItemData = ({
|
|
|
798
778
|
localState: context.localState,
|
|
799
779
|
rootState: context.rootState,
|
|
800
780
|
rootSetState: context.rootSetState,
|
|
801
|
-
context: context.context
|
|
802
|
-
enableCache: true
|
|
781
|
+
context: context.context
|
|
803
782
|
});
|
|
804
783
|
if (!Array.isArray(itemsArray)) {
|
|
805
784
|
return void 0;
|
|
@@ -1002,8 +981,7 @@ var createEventHandler = (value, options) => (event) => evaluate({
|
|
|
1002
981
|
rootState: options.rootState,
|
|
1003
982
|
rootSetState: options.rootSetState,
|
|
1004
983
|
event,
|
|
1005
|
-
isExpression: false
|
|
1006
|
-
enableCache: true
|
|
984
|
+
isExpression: false
|
|
1007
985
|
});
|
|
1008
986
|
|
|
1009
987
|
// src/functions/get-block-actions.ts
|
|
@@ -1373,7 +1351,11 @@ import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
|
|
|
1373
1351
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1374
1352
|
function BlocksWrapper(props) {
|
|
1375
1353
|
const className = createMemo6(() => {
|
|
1376
|
-
return
|
|
1354
|
+
return [
|
|
1355
|
+
"builder-blocks",
|
|
1356
|
+
!props.blocks?.length ? "no-blocks" : "",
|
|
1357
|
+
props.classNameProp
|
|
1358
|
+
].filter(Boolean).join(" ");
|
|
1377
1359
|
});
|
|
1378
1360
|
function onClick() {
|
|
1379
1361
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -1408,7 +1390,7 @@ function BlocksWrapper(props) {
|
|
|
1408
1390
|
});
|
|
1409
1391
|
return <>
|
|
1410
1392
|
<Dynamic4
|
|
1411
|
-
class={className() + " dynamic-
|
|
1393
|
+
class={className() + " dynamic-6567ee94"}
|
|
1412
1394
|
ref={blocksWrapperRef}
|
|
1413
1395
|
builder-path={props.path}
|
|
1414
1396
|
builder-parent-id={props.parent}
|
|
@@ -1420,7 +1402,7 @@ function BlocksWrapper(props) {
|
|
|
1420
1402
|
{...props.BlocksWrapperProps}
|
|
1421
1403
|
component={props.BlocksWrapper}
|
|
1422
1404
|
>{props.children}</Dynamic4>
|
|
1423
|
-
<style>{`.dynamic-
|
|
1405
|
+
<style>{`.dynamic-6567ee94 {
|
|
1424
1406
|
display: flex;
|
|
1425
1407
|
flex-direction: column;
|
|
1426
1408
|
align-items: stretch;
|
|
@@ -1438,8 +1420,9 @@ function Blocks(props) {
|
|
|
1438
1420
|
parent={props.parent}
|
|
1439
1421
|
path={props.path}
|
|
1440
1422
|
styleProp={props.styleProp}
|
|
1441
|
-
|
|
1442
|
-
|
|
1423
|
+
classNameProp={props.className}
|
|
1424
|
+
BlocksWrapper={props.context?.BlocksWrapper || builderContext?.BlocksWrapper}
|
|
1425
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps}
|
|
1443
1426
|
><Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
1444
1427
|
const index = _index();
|
|
1445
1428
|
return <Block_default
|
|
@@ -1447,7 +1430,7 @@ function Blocks(props) {
|
|
|
1447
1430
|
block={block}
|
|
1448
1431
|
linkComponent={props.linkComponent}
|
|
1449
1432
|
context={props.context || builderContext}
|
|
1450
|
-
registeredComponents={props.registeredComponents || componentsContext
|
|
1433
|
+
registeredComponents={props.registeredComponents || componentsContext?.registeredComponents}
|
|
1451
1434
|
/>;
|
|
1452
1435
|
}}</For3></Show6></Blocks_wrapper_default></>;
|
|
1453
1436
|
}
|
|
@@ -3041,8 +3024,7 @@ function Text(props) {
|
|
|
3041
3024
|
context: contextContext,
|
|
3042
3025
|
localState,
|
|
3043
3026
|
rootState,
|
|
3044
|
-
rootSetState
|
|
3045
|
-
enableCache: false
|
|
3027
|
+
rootSetState
|
|
3046
3028
|
})
|
|
3047
3029
|
);
|
|
3048
3030
|
});
|
|
@@ -3444,12 +3426,6 @@ var getEnv = () => {
|
|
|
3444
3426
|
return validEnvList.includes(env) ? env : "production";
|
|
3445
3427
|
};
|
|
3446
3428
|
|
|
3447
|
-
// src/functions/get.ts
|
|
3448
|
-
var get = (obj, path, defaultValue) => {
|
|
3449
|
-
const result = String.prototype.split.call(path, /[,[\].]+?/).filter(Boolean).reduce((res, key) => res !== null && res !== void 0 ? res[key] : res, obj);
|
|
3450
|
-
return result === void 0 || result === obj ? defaultValue : result;
|
|
3451
|
-
};
|
|
3452
|
-
|
|
3453
3429
|
// src/blocks/form/form/form.tsx
|
|
3454
3430
|
function FormComponent(props) {
|
|
3455
3431
|
const [formState, setFormState] = createSignal14("unsubmitted");
|
|
@@ -4756,7 +4732,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4756
4732
|
}
|
|
4757
4733
|
|
|
4758
4734
|
// src/constants/sdk-version.ts
|
|
4759
|
-
var SDK_VERSION = "2.0.
|
|
4735
|
+
var SDK_VERSION = "2.0.24";
|
|
4760
4736
|
|
|
4761
4737
|
// src/functions/register.ts
|
|
4762
4738
|
var registry = {};
|
|
@@ -5144,8 +5120,7 @@ function EnableEditor(props) {
|
|
|
5144
5120
|
context: props.context || {},
|
|
5145
5121
|
localState: void 0,
|
|
5146
5122
|
rootState: props.builderContextSignal.rootState,
|
|
5147
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5148
|
-
enableCache: true
|
|
5123
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5149
5124
|
})
|
|
5150
5125
|
)
|
|
5151
5126
|
);
|
|
@@ -5444,11 +5419,7 @@ function ContentComponent(props) {
|
|
|
5444
5419
|
rootState: newState
|
|
5445
5420
|
}));
|
|
5446
5421
|
},
|
|
5447
|
-
isExpression: false
|
|
5448
|
-
/**
|
|
5449
|
-
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
5450
|
-
*/
|
|
5451
|
-
enableCache: false
|
|
5422
|
+
isExpression: false
|
|
5452
5423
|
});
|
|
5453
5424
|
}
|
|
5454
5425
|
return <><components_context_default.Provider
|
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
|
|
3536
|
-
var
|
|
3537
|
-
|
|
3538
|
-
|
|
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
|
|
@@ -4726,14 +4704,14 @@ function Block(props) {
|
|
|
4726
4704
|
});
|
|
4727
4705
|
}
|
|
4728
4706
|
var block_default = Block;
|
|
4729
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4707
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-6567ee94 {
|
|
4730
4708
|
display: flex;
|
|
4731
4709
|
flex-direction: column;
|
|
4732
4710
|
align-items: stretch;
|
|
4733
4711
|
}`);
|
|
4734
4712
|
function BlocksWrapper(props) {
|
|
4735
4713
|
const className = createMemo(() => {
|
|
4736
|
-
return "builder-blocks"
|
|
4714
|
+
return ["builder-blocks", !props.blocks?.length ? "no-blocks" : "", props.classNameProp].filter(Boolean).join(" ");
|
|
4737
4715
|
});
|
|
4738
4716
|
function onClick() {
|
|
4739
4717
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -4762,7 +4740,7 @@ function BlocksWrapper(props) {
|
|
|
4762
4740
|
});
|
|
4763
4741
|
return [createComponent(Dynamic, mergeProps({
|
|
4764
4742
|
get ["class"]() {
|
|
4765
|
-
return className() + " dynamic-
|
|
4743
|
+
return className() + " dynamic-6567ee94";
|
|
4766
4744
|
},
|
|
4767
4745
|
ref(r$) {
|
|
4768
4746
|
const _ref$ = blocksWrapperRef;
|
|
@@ -4809,11 +4787,14 @@ function Blocks(props) {
|
|
|
4809
4787
|
get styleProp() {
|
|
4810
4788
|
return props.styleProp;
|
|
4811
4789
|
},
|
|
4790
|
+
get classNameProp() {
|
|
4791
|
+
return props.className;
|
|
4792
|
+
},
|
|
4812
4793
|
get BlocksWrapper() {
|
|
4813
|
-
return props.context?.BlocksWrapper || builderContext
|
|
4794
|
+
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
4814
4795
|
},
|
|
4815
4796
|
get BlocksWrapperProps() {
|
|
4816
|
-
return props.context?.BlocksWrapperProps || builderContext
|
|
4797
|
+
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
4817
4798
|
},
|
|
4818
4799
|
get children() {
|
|
4819
4800
|
return createComponent(Show, {
|
|
@@ -4839,7 +4820,7 @@ function Blocks(props) {
|
|
|
4839
4820
|
return props.context || builderContext;
|
|
4840
4821
|
},
|
|
4841
4822
|
get registeredComponents() {
|
|
4842
|
-
return props.registeredComponents || componentsContext
|
|
4823
|
+
return props.registeredComponents || componentsContext?.registeredComponents;
|
|
4843
4824
|
}
|
|
4844
4825
|
});
|
|
4845
4826
|
}
|
|
@@ -6589,8 +6570,7 @@ function Text(props) {
|
|
|
6589
6570
|
context: contextContext,
|
|
6590
6571
|
localState,
|
|
6591
6572
|
rootState,
|
|
6592
|
-
rootSetState
|
|
6593
|
-
enableCache: false
|
|
6573
|
+
rootSetState
|
|
6594
6574
|
}));
|
|
6595
6575
|
});
|
|
6596
6576
|
return (() => {
|
|
@@ -6995,12 +6975,6 @@ var getEnv = () => {
|
|
|
6995
6975
|
return validEnvList.includes(env) ? env : "production";
|
|
6996
6976
|
};
|
|
6997
6977
|
|
|
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
6978
|
// src/blocks/form/form/form.tsx
|
|
7005
6979
|
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
|
|
7006
6980
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
@@ -8468,7 +8442,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
8468
8442
|
}
|
|
8469
8443
|
|
|
8470
8444
|
// src/constants/sdk-version.ts
|
|
8471
|
-
var SDK_VERSION = "2.0.
|
|
8445
|
+
var SDK_VERSION = "2.0.24";
|
|
8472
8446
|
|
|
8473
8447
|
// src/functions/register.ts
|
|
8474
8448
|
var registry = {};
|
|
@@ -8855,8 +8829,7 @@ function EnableEditor(props) {
|
|
|
8855
8829
|
context: props.context || {},
|
|
8856
8830
|
localState: void 0,
|
|
8857
8831
|
rootState: props.builderContextSignal.rootState,
|
|
8858
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
8859
|
-
enableCache: true
|
|
8832
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
8860
8833
|
})));
|
|
8861
8834
|
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
8862
8835
|
mergeNewRootState({
|
|
@@ -9150,11 +9123,7 @@ function ContentComponent(props) {
|
|
|
9150
9123
|
rootState: newState
|
|
9151
9124
|
}));
|
|
9152
9125
|
},
|
|
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
|
|
9126
|
+
isExpression: false
|
|
9158
9127
|
});
|
|
9159
9128
|
}
|
|
9160
9129
|
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
|
|
3531
|
-
var
|
|
3532
|
-
|
|
3533
|
-
|
|
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
|
|
@@ -4564,7 +4542,11 @@ import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
|
|
|
4564
4542
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
4565
4543
|
function BlocksWrapper(props) {
|
|
4566
4544
|
const className = createMemo6(() => {
|
|
4567
|
-
return
|
|
4545
|
+
return [
|
|
4546
|
+
"builder-blocks",
|
|
4547
|
+
!props.blocks?.length ? "no-blocks" : "",
|
|
4548
|
+
props.classNameProp
|
|
4549
|
+
].filter(Boolean).join(" ");
|
|
4568
4550
|
});
|
|
4569
4551
|
function onClick() {
|
|
4570
4552
|
if (isEditing() && !props.blocks?.length) {
|
|
@@ -4599,7 +4581,7 @@ function BlocksWrapper(props) {
|
|
|
4599
4581
|
});
|
|
4600
4582
|
return <>
|
|
4601
4583
|
<Dynamic4
|
|
4602
|
-
class={className() + " dynamic-
|
|
4584
|
+
class={className() + " dynamic-6567ee94"}
|
|
4603
4585
|
ref={blocksWrapperRef}
|
|
4604
4586
|
builder-path={props.path}
|
|
4605
4587
|
builder-parent-id={props.parent}
|
|
@@ -4611,7 +4593,7 @@ function BlocksWrapper(props) {
|
|
|
4611
4593
|
{...props.BlocksWrapperProps}
|
|
4612
4594
|
component={props.BlocksWrapper}
|
|
4613
4595
|
>{props.children}</Dynamic4>
|
|
4614
|
-
<style>{`.dynamic-
|
|
4596
|
+
<style>{`.dynamic-6567ee94 {
|
|
4615
4597
|
display: flex;
|
|
4616
4598
|
flex-direction: column;
|
|
4617
4599
|
align-items: stretch;
|
|
@@ -4629,8 +4611,9 @@ function Blocks(props) {
|
|
|
4629
4611
|
parent={props.parent}
|
|
4630
4612
|
path={props.path}
|
|
4631
4613
|
styleProp={props.styleProp}
|
|
4632
|
-
|
|
4633
|
-
|
|
4614
|
+
classNameProp={props.className}
|
|
4615
|
+
BlocksWrapper={props.context?.BlocksWrapper || builderContext?.BlocksWrapper}
|
|
4616
|
+
BlocksWrapperProps={props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps}
|
|
4634
4617
|
><Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
4635
4618
|
const index = _index();
|
|
4636
4619
|
return <Block_default
|
|
@@ -4638,7 +4621,7 @@ function Blocks(props) {
|
|
|
4638
4621
|
block={block}
|
|
4639
4622
|
linkComponent={props.linkComponent}
|
|
4640
4623
|
context={props.context || builderContext}
|
|
4641
|
-
registeredComponents={props.registeredComponents || componentsContext
|
|
4624
|
+
registeredComponents={props.registeredComponents || componentsContext?.registeredComponents}
|
|
4642
4625
|
/>;
|
|
4643
4626
|
}}</For3></Show6></Blocks_wrapper_default></>;
|
|
4644
4627
|
}
|
|
@@ -6234,8 +6217,7 @@ function Text(props) {
|
|
|
6234
6217
|
context: contextContext,
|
|
6235
6218
|
localState,
|
|
6236
6219
|
rootState,
|
|
6237
|
-
rootSetState
|
|
6238
|
-
enableCache: false
|
|
6220
|
+
rootSetState
|
|
6239
6221
|
})
|
|
6240
6222
|
);
|
|
6241
6223
|
});
|
|
@@ -6639,12 +6621,6 @@ var getEnv = () => {
|
|
|
6639
6621
|
return validEnvList.includes(env) ? env : "production";
|
|
6640
6622
|
};
|
|
6641
6623
|
|
|
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
6624
|
// src/blocks/form/form/form.tsx
|
|
6649
6625
|
function FormComponent(props) {
|
|
6650
6626
|
const [formState, setFormState] = createSignal14("unsubmitted");
|
|
@@ -7956,7 +7932,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
7956
7932
|
}
|
|
7957
7933
|
|
|
7958
7934
|
// src/constants/sdk-version.ts
|
|
7959
|
-
var SDK_VERSION = "2.0.
|
|
7935
|
+
var SDK_VERSION = "2.0.24";
|
|
7960
7936
|
|
|
7961
7937
|
// src/functions/register.ts
|
|
7962
7938
|
var registry = {};
|
|
@@ -8345,8 +8321,7 @@ function EnableEditor(props) {
|
|
|
8345
8321
|
context: props.context || {},
|
|
8346
8322
|
localState: void 0,
|
|
8347
8323
|
rootState: props.builderContextSignal.rootState,
|
|
8348
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
8349
|
-
enableCache: true
|
|
8324
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
8350
8325
|
})
|
|
8351
8326
|
)
|
|
8352
8327
|
);
|
|
@@ -8646,11 +8621,7 @@ function ContentComponent(props) {
|
|
|
8646
8621
|
rootState: newState
|
|
8647
8622
|
}));
|
|
8648
8623
|
},
|
|
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
|
|
8624
|
+
isExpression: false
|
|
8654
8625
|
});
|
|
8655
8626
|
}
|
|
8656
8627
|
return <><components_context_default.Provider
|