@builder.io/sdk-solid 2.0.22 → 2.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/dev.js +26 -60
- package/lib/browser/dev.jsx +26 -60
- package/lib/browser/index.js +26 -60
- package/lib/browser/index.jsx +26 -60
- package/lib/edge/dev.js +26 -60
- package/lib/edge/dev.jsx +26 -60
- package/lib/edge/index.js +26 -60
- package/lib/edge/index.jsx +26 -60
- package/lib/node/dev.js +26 -60
- package/lib/node/dev.jsx +26 -60
- package/lib/node/index.js +26 -60
- package/lib/node/index.jsx +26 -60
- package/package.json +1 -1
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
|
|
@@ -3406,8 +3384,7 @@ function Text(props) {
|
|
|
3406
3384
|
context: contextContext,
|
|
3407
3385
|
localState,
|
|
3408
3386
|
rootState,
|
|
3409
|
-
rootSetState
|
|
3410
|
-
enableCache: false
|
|
3387
|
+
rootSetState
|
|
3411
3388
|
}));
|
|
3412
3389
|
});
|
|
3413
3390
|
return (() => {
|
|
@@ -3812,12 +3789,6 @@ var getEnv = () => {
|
|
|
3812
3789
|
return validEnvList.includes(env) ? env : "production";
|
|
3813
3790
|
};
|
|
3814
3791
|
|
|
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
3792
|
// src/blocks/form/form/form.tsx
|
|
3822
3793
|
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
|
|
3823
3794
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
@@ -5285,7 +5256,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5285
5256
|
}
|
|
5286
5257
|
|
|
5287
5258
|
// src/constants/sdk-version.ts
|
|
5288
|
-
var SDK_VERSION = "2.0.
|
|
5259
|
+
var SDK_VERSION = "2.0.23";
|
|
5289
5260
|
|
|
5290
5261
|
// src/functions/register.ts
|
|
5291
5262
|
var registry = {};
|
|
@@ -5672,8 +5643,7 @@ function EnableEditor(props) {
|
|
|
5672
5643
|
context: props.context || {},
|
|
5673
5644
|
localState: void 0,
|
|
5674
5645
|
rootState: props.builderContextSignal.rootState,
|
|
5675
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5676
|
-
enableCache: true
|
|
5646
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5677
5647
|
})));
|
|
5678
5648
|
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
5679
5649
|
mergeNewRootState({
|
|
@@ -5967,11 +5937,7 @@ function ContentComponent(props) {
|
|
|
5967
5937
|
rootState: newState
|
|
5968
5938
|
}));
|
|
5969
5939
|
},
|
|
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
|
|
5940
|
+
isExpression: false
|
|
5975
5941
|
});
|
|
5976
5942
|
}
|
|
5977
5943
|
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
|
|
@@ -3049,8 +3027,7 @@ function Text(props) {
|
|
|
3049
3027
|
context: contextContext,
|
|
3050
3028
|
localState,
|
|
3051
3029
|
rootState,
|
|
3052
|
-
rootSetState
|
|
3053
|
-
enableCache: false
|
|
3030
|
+
rootSetState
|
|
3054
3031
|
})
|
|
3055
3032
|
);
|
|
3056
3033
|
});
|
|
@@ -3454,12 +3431,6 @@ var getEnv = () => {
|
|
|
3454
3431
|
return validEnvList.includes(env) ? env : "production";
|
|
3455
3432
|
};
|
|
3456
3433
|
|
|
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
3434
|
// src/blocks/form/form/form.tsx
|
|
3464
3435
|
function FormComponent(props) {
|
|
3465
3436
|
const [formState, setFormState] = createSignal14("unsubmitted");
|
|
@@ -4771,7 +4742,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4771
4742
|
}
|
|
4772
4743
|
|
|
4773
4744
|
// src/constants/sdk-version.ts
|
|
4774
|
-
var SDK_VERSION = "2.0.
|
|
4745
|
+
var SDK_VERSION = "2.0.23";
|
|
4775
4746
|
|
|
4776
4747
|
// src/functions/register.ts
|
|
4777
4748
|
var registry = {};
|
|
@@ -5160,8 +5131,7 @@ function EnableEditor(props) {
|
|
|
5160
5131
|
context: props.context || {},
|
|
5161
5132
|
localState: void 0,
|
|
5162
5133
|
rootState: props.builderContextSignal.rootState,
|
|
5163
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5164
|
-
enableCache: true
|
|
5134
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5165
5135
|
})
|
|
5166
5136
|
)
|
|
5167
5137
|
);
|
|
@@ -5461,11 +5431,7 @@ function ContentComponent(props) {
|
|
|
5461
5431
|
rootState: newState
|
|
5462
5432
|
}));
|
|
5463
5433
|
},
|
|
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
|
|
5434
|
+
isExpression: false
|
|
5469
5435
|
});
|
|
5470
5436
|
}
|
|
5471
5437
|
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
|
|
@@ -3398,8 +3376,7 @@ function Text(props) {
|
|
|
3398
3376
|
context: contextContext,
|
|
3399
3377
|
localState,
|
|
3400
3378
|
rootState,
|
|
3401
|
-
rootSetState
|
|
3402
|
-
enableCache: false
|
|
3379
|
+
rootSetState
|
|
3403
3380
|
}));
|
|
3404
3381
|
});
|
|
3405
3382
|
return (() => {
|
|
@@ -3802,12 +3779,6 @@ var getEnv = () => {
|
|
|
3802
3779
|
return validEnvList.includes(env) ? env : "production";
|
|
3803
3780
|
};
|
|
3804
3781
|
|
|
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
3782
|
// src/blocks/form/form/form.tsx
|
|
3812
3783
|
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-2e825338">`);
|
|
3813
3784
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
@@ -5270,7 +5241,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5270
5241
|
}
|
|
5271
5242
|
|
|
5272
5243
|
// src/constants/sdk-version.ts
|
|
5273
|
-
var SDK_VERSION = "2.0.
|
|
5244
|
+
var SDK_VERSION = "2.0.23";
|
|
5274
5245
|
|
|
5275
5246
|
// src/functions/register.ts
|
|
5276
5247
|
var registry = {};
|
|
@@ -5656,8 +5627,7 @@ function EnableEditor(props) {
|
|
|
5656
5627
|
context: props.context || {},
|
|
5657
5628
|
localState: void 0,
|
|
5658
5629
|
rootState: props.builderContextSignal.rootState,
|
|
5659
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5660
|
-
enableCache: true
|
|
5630
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5661
5631
|
})));
|
|
5662
5632
|
fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
|
|
5663
5633
|
mergeNewRootState({
|
|
@@ -5950,11 +5920,7 @@ function ContentComponent(props) {
|
|
|
5950
5920
|
rootState: newState
|
|
5951
5921
|
}));
|
|
5952
5922
|
},
|
|
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
|
|
5923
|
+
isExpression: false
|
|
5958
5924
|
});
|
|
5959
5925
|
}
|
|
5960
5926
|
return createComponent(components_context_default.Provider, {
|
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
|
|
@@ -3041,8 +3019,7 @@ function Text(props) {
|
|
|
3041
3019
|
context: contextContext,
|
|
3042
3020
|
localState,
|
|
3043
3021
|
rootState,
|
|
3044
|
-
rootSetState
|
|
3045
|
-
enableCache: false
|
|
3022
|
+
rootSetState
|
|
3046
3023
|
})
|
|
3047
3024
|
);
|
|
3048
3025
|
});
|
|
@@ -3444,12 +3421,6 @@ var getEnv = () => {
|
|
|
3444
3421
|
return validEnvList.includes(env) ? env : "production";
|
|
3445
3422
|
};
|
|
3446
3423
|
|
|
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
3424
|
// src/blocks/form/form/form.tsx
|
|
3454
3425
|
function FormComponent(props) {
|
|
3455
3426
|
const [formState, setFormState] = createSignal14("unsubmitted");
|
|
@@ -4756,7 +4727,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4756
4727
|
}
|
|
4757
4728
|
|
|
4758
4729
|
// src/constants/sdk-version.ts
|
|
4759
|
-
var SDK_VERSION = "2.0.
|
|
4730
|
+
var SDK_VERSION = "2.0.23";
|
|
4760
4731
|
|
|
4761
4732
|
// src/functions/register.ts
|
|
4762
4733
|
var registry = {};
|
|
@@ -5144,8 +5115,7 @@ function EnableEditor(props) {
|
|
|
5144
5115
|
context: props.context || {},
|
|
5145
5116
|
localState: void 0,
|
|
5146
5117
|
rootState: props.builderContextSignal.rootState,
|
|
5147
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
5148
|
-
enableCache: true
|
|
5118
|
+
rootSetState: props.builderContextSignal.rootSetState
|
|
5149
5119
|
})
|
|
5150
5120
|
)
|
|
5151
5121
|
);
|
|
@@ -5444,11 +5414,7 @@ function ContentComponent(props) {
|
|
|
5444
5414
|
rootState: newState
|
|
5445
5415
|
}));
|
|
5446
5416
|
},
|
|
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
|
|
5417
|
+
isExpression: false
|
|
5452
5418
|
});
|
|
5453
5419
|
}
|
|
5454
5420
|
return <><components_context_default.Provider
|