@builder.io/sdk-qwik 0.14.5 → 0.14.7
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/index.qwik.cjs +111 -72
- package/lib/browser/index.qwik.mjs +111 -72
- package/lib/edge/index.qwik.cjs +111 -72
- package/lib/edge/index.qwik.mjs +111 -72
- package/lib/node/index.qwik.cjs +111 -72
- package/lib/node/index.qwik.mjs +111 -72
- package/package.json +1 -1
- package/types/src/components/block/block.helpers.d.ts +4 -0
- package/types/src/constants/sdk-version.d.ts +1 -1
- package/types/src/functions/evaluate/evaluate.d.ts +3 -1
- package/types/src/functions/evaluate/helpers.d.ts +1 -0
package/lib/node/index.qwik.cjs
CHANGED
|
@@ -213,7 +213,7 @@ function flattenState({ rootState, localState, rootSetState }) {
|
|
|
213
213
|
if (localState && prop in localState)
|
|
214
214
|
return localState[prop];
|
|
215
215
|
const val = target[prop];
|
|
216
|
-
if (typeof val === "object")
|
|
216
|
+
if (typeof val === "object" && val !== null)
|
|
217
217
|
return flattenState({
|
|
218
218
|
rootState: val,
|
|
219
219
|
localState: void 0,
|
|
@@ -363,10 +363,34 @@ const shouldForceBrowserRuntimeInNode = () => {
|
|
|
363
363
|
return false;
|
|
364
364
|
};
|
|
365
365
|
const chooseBrowserOrServerEval = (args) => build.isBrowser || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInNode(args);
|
|
366
|
-
|
|
366
|
+
const _EvalCache = class _EvalCache2 {
|
|
367
|
+
static getCacheKey(args) {
|
|
368
|
+
return JSON.stringify({
|
|
369
|
+
...args,
|
|
370
|
+
// replace the event with a random number to break cache
|
|
371
|
+
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
372
|
+
event: args.event ? Math.random() : void 0
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
static getCachedValue(key) {
|
|
376
|
+
const cachedVal = _EvalCache2.cache.get(key);
|
|
377
|
+
return cachedVal;
|
|
378
|
+
}
|
|
379
|
+
static setCachedValue(key, value) {
|
|
380
|
+
if (_EvalCache2.cache.size > 20)
|
|
381
|
+
_EvalCache2.cache.delete(_EvalCache2.cache.keys().next().value);
|
|
382
|
+
_EvalCache2.cache.set(key, {
|
|
383
|
+
value
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
_EvalCache.cacheLimit = 20;
|
|
388
|
+
_EvalCache.cache = /* @__PURE__ */ new Map();
|
|
389
|
+
let EvalCache = _EvalCache;
|
|
390
|
+
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, enableCache }) {
|
|
367
391
|
if (code === "") {
|
|
368
392
|
logger.warn("Skipping evaluation of empty code block.");
|
|
369
|
-
return;
|
|
393
|
+
return void 0;
|
|
370
394
|
}
|
|
371
395
|
const args = {
|
|
372
396
|
code: parseCode(code, {
|
|
@@ -379,8 +403,19 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
|
|
|
379
403
|
rootState,
|
|
380
404
|
localState
|
|
381
405
|
};
|
|
406
|
+
if (enableCache) {
|
|
407
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
408
|
+
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
409
|
+
if (cachedValue)
|
|
410
|
+
return cachedValue.value;
|
|
411
|
+
}
|
|
382
412
|
try {
|
|
383
|
-
|
|
413
|
+
const newEval = chooseBrowserOrServerEval(args);
|
|
414
|
+
if (enableCache) {
|
|
415
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
416
|
+
EvalCache.setCachedValue(cacheKey, newEval);
|
|
417
|
+
}
|
|
418
|
+
return newEval;
|
|
384
419
|
} catch (e) {
|
|
385
420
|
logger.error("Failed code evaluation: " + e.message, {
|
|
386
421
|
code
|
|
@@ -411,7 +446,8 @@ const evaluateBindings = ({ block, context, localState, rootState, rootSetState
|
|
|
411
446
|
localState,
|
|
412
447
|
rootState,
|
|
413
448
|
rootSetState,
|
|
414
|
-
context
|
|
449
|
+
context,
|
|
450
|
+
enableCache: true
|
|
415
451
|
});
|
|
416
452
|
set(copied, binding, value);
|
|
417
453
|
}
|
|
@@ -625,6 +661,51 @@ function bindScrollInViewAnimation(animation) {
|
|
|
625
661
|
immediateOnScroll();
|
|
626
662
|
});
|
|
627
663
|
}
|
|
664
|
+
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
665
|
+
const convertStyleMapToCSSArray = (style) => {
|
|
666
|
+
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
667
|
+
if (typeof value === "string")
|
|
668
|
+
return `${camelToKebabCase(key)}: ${value};`;
|
|
669
|
+
else
|
|
670
|
+
return void 0;
|
|
671
|
+
});
|
|
672
|
+
return cssProps.filter(checkIsDefined);
|
|
673
|
+
};
|
|
674
|
+
const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
675
|
+
const createCssClass = ({ mediaQuery, className, styles }) => {
|
|
676
|
+
const cssClass = `.${className} {
|
|
677
|
+
${convertStyleMapToCSS(styles)}
|
|
678
|
+
}`;
|
|
679
|
+
if (mediaQuery)
|
|
680
|
+
return `${mediaQuery} {
|
|
681
|
+
${cssClass}
|
|
682
|
+
}`;
|
|
683
|
+
else
|
|
684
|
+
return cssClass;
|
|
685
|
+
};
|
|
686
|
+
function transformStyleProperty({ style }) {
|
|
687
|
+
return style;
|
|
688
|
+
}
|
|
689
|
+
const getStyle = ({ block, context }) => {
|
|
690
|
+
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
691
|
+
style: block.style || {},
|
|
692
|
+
context,
|
|
693
|
+
block
|
|
694
|
+
}));
|
|
695
|
+
};
|
|
696
|
+
function mapStyleObjToStrIfNeeded(style) {
|
|
697
|
+
switch (TARGET) {
|
|
698
|
+
case "svelte":
|
|
699
|
+
case "vue":
|
|
700
|
+
case "solid":
|
|
701
|
+
return convertStyleMapToCSSArray(style).join(" ");
|
|
702
|
+
case "qwik":
|
|
703
|
+
case "reactNative":
|
|
704
|
+
case "react":
|
|
705
|
+
case "rsc":
|
|
706
|
+
return style;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
628
709
|
const getComponent = ({ block, context, registeredComponents }) => {
|
|
629
710
|
var _a;
|
|
630
711
|
const componentName = (_a = getProcessedBlock({
|
|
@@ -655,7 +736,8 @@ const getRepeatItemData = ({ block, context }) => {
|
|
|
655
736
|
localState: context.localState,
|
|
656
737
|
rootState: context.rootState,
|
|
657
738
|
rootSetState: context.rootSetState,
|
|
658
|
-
context: context.context
|
|
739
|
+
context: context.context,
|
|
740
|
+
enableCache: true
|
|
659
741
|
});
|
|
660
742
|
if (!Array.isArray(itemsArray))
|
|
661
743
|
return void 0;
|
|
@@ -719,28 +801,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
719
801
|
};
|
|
720
802
|
return newSizes;
|
|
721
803
|
};
|
|
722
|
-
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
723
|
-
const convertStyleMapToCSSArray = (style) => {
|
|
724
|
-
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
725
|
-
if (typeof value === "string")
|
|
726
|
-
return `${camelToKebabCase(key)}: ${value};`;
|
|
727
|
-
else
|
|
728
|
-
return void 0;
|
|
729
|
-
});
|
|
730
|
-
return cssProps.filter(checkIsDefined);
|
|
731
|
-
};
|
|
732
|
-
const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
733
|
-
const createCssClass = ({ mediaQuery, className, styles }) => {
|
|
734
|
-
const cssClass = `.${className} {
|
|
735
|
-
${convertStyleMapToCSS(styles)}
|
|
736
|
-
}`;
|
|
737
|
-
if (mediaQuery)
|
|
738
|
-
return `${mediaQuery} {
|
|
739
|
-
${cssClass}
|
|
740
|
-
}`;
|
|
741
|
-
else
|
|
742
|
-
return cssClass;
|
|
743
|
-
};
|
|
744
804
|
const InlinedStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
|
|
745
805
|
return /* @__PURE__ */ qwik._jsxQ("style", null, {
|
|
746
806
|
dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.styles, [
|
|
@@ -839,7 +899,8 @@ function createEventHandler(value, options) {
|
|
|
839
899
|
localState: options2.localState,
|
|
840
900
|
rootState: options2.rootState,
|
|
841
901
|
rootSetState: options2.rootSetState,
|
|
842
|
-
event
|
|
902
|
+
event,
|
|
903
|
+
enableCache: true
|
|
843
904
|
});
|
|
844
905
|
}, "createEventHandler_7wCAiJVliNE", [
|
|
845
906
|
options,
|
|
@@ -867,29 +928,6 @@ function getBlockActions(options) {
|
|
|
867
928
|
}
|
|
868
929
|
return obj;
|
|
869
930
|
}
|
|
870
|
-
function transformStyleProperty({ style }) {
|
|
871
|
-
return style;
|
|
872
|
-
}
|
|
873
|
-
const getStyle = ({ block, context }) => {
|
|
874
|
-
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
875
|
-
style: block.style || {},
|
|
876
|
-
context,
|
|
877
|
-
block
|
|
878
|
-
}));
|
|
879
|
-
};
|
|
880
|
-
function mapStyleObjToStrIfNeeded(style) {
|
|
881
|
-
switch (TARGET) {
|
|
882
|
-
case "svelte":
|
|
883
|
-
case "vue":
|
|
884
|
-
case "solid":
|
|
885
|
-
return convertStyleMapToCSSArray(style).join(" ");
|
|
886
|
-
case "qwik":
|
|
887
|
-
case "reactNative":
|
|
888
|
-
case "react":
|
|
889
|
-
case "rsc":
|
|
890
|
-
return style;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
931
|
function transformBlockProperties({ properties }) {
|
|
894
932
|
return properties;
|
|
895
933
|
}
|
|
@@ -1069,9 +1107,6 @@ const RepeatedBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
|
|
|
1069
1107
|
const Block = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
|
|
1070
1108
|
var _a;
|
|
1071
1109
|
qwik._jsxBranch();
|
|
1072
|
-
const state = qwik.useStore({
|
|
1073
|
-
childrenContext: props.context
|
|
1074
|
-
});
|
|
1075
1110
|
const blockComponent = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
1076
1111
|
const [props2] = qwik.useLexicalScope();
|
|
1077
1112
|
return getComponent({
|
|
@@ -1144,7 +1179,7 @@ const Block = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
|
|
|
1144
1179
|
]));
|
|
1145
1180
|
const componentRefProps = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
1146
1181
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1147
|
-
const [blockComponent2, processedBlock2, props2
|
|
1182
|
+
const [blockComponent2, processedBlock2, props2] = qwik.useLexicalScope();
|
|
1148
1183
|
return {
|
|
1149
1184
|
blockChildren: processedBlock2.value.children ?? [],
|
|
1150
1185
|
componentRef: (_a2 = blockComponent2.value) == null ? void 0 : _a2.component,
|
|
@@ -1158,7 +1193,7 @@ const Block = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
|
|
|
1158
1193
|
builderComponents: props2.registeredComponents
|
|
1159
1194
|
} : {}
|
|
1160
1195
|
},
|
|
1161
|
-
context:
|
|
1196
|
+
context: props2.context,
|
|
1162
1197
|
linkComponent: props2.linkComponent,
|
|
1163
1198
|
registeredComponents: props2.registeredComponents,
|
|
1164
1199
|
builderBlock: processedBlock2.value,
|
|
@@ -1168,8 +1203,7 @@ const Block = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
|
|
|
1168
1203
|
}, "Block_component_componentRefProps_useComputed_Ikbl8VO04ho", [
|
|
1169
1204
|
blockComponent,
|
|
1170
1205
|
processedBlock,
|
|
1171
|
-
props
|
|
1172
|
-
state
|
|
1206
|
+
props
|
|
1173
1207
|
]));
|
|
1174
1208
|
qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
1175
1209
|
const [processedBlock2] = qwik.useLexicalScope();
|
|
@@ -1277,19 +1311,19 @@ const Block = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
|
|
|
1277
1311
|
(childrenWithoutParentComponent.value || []).map((child) => {
|
|
1278
1312
|
return /* @__PURE__ */ qwik._jsxC(Block, {
|
|
1279
1313
|
block: child,
|
|
1280
|
-
get context() {
|
|
1281
|
-
return state.childrenContext;
|
|
1282
|
-
},
|
|
1283
1314
|
get registeredComponents() {
|
|
1284
1315
|
return props.registeredComponents;
|
|
1285
1316
|
},
|
|
1286
1317
|
get linkComponent() {
|
|
1287
1318
|
return props.linkComponent;
|
|
1288
1319
|
},
|
|
1320
|
+
get context() {
|
|
1321
|
+
return props.context;
|
|
1322
|
+
},
|
|
1289
1323
|
[qwik._IMMUTABLE]: {
|
|
1290
|
-
context: qwik._fnSignal((p0) => p0.
|
|
1291
|
-
|
|
1292
|
-
], "p0.
|
|
1324
|
+
context: qwik._fnSignal((p0) => p0.context, [
|
|
1325
|
+
props
|
|
1326
|
+
], "p0.context"),
|
|
1293
1327
|
linkComponent: qwik._fnSignal((p0) => p0.linkComponent, [
|
|
1294
1328
|
props
|
|
1295
1329
|
], "p0.linkComponent"),
|
|
@@ -1883,9 +1917,9 @@ const Image = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
|
|
|
1883
1917
|
props
|
|
1884
1918
|
], '"builder-image"+(p0.className?" "+p0.className:"")+" img-Image"'),
|
|
1885
1919
|
loading: "lazy",
|
|
1886
|
-
role: qwik._fnSignal((p0) => p0.altText ? "presentation"
|
|
1920
|
+
role: qwik._fnSignal((p0) => p0.altText ? void 0 : "presentation", [
|
|
1887
1921
|
props
|
|
1888
|
-
], 'p0.altText?"presentation"
|
|
1922
|
+
], 'p0.altText?undefined:"presentation"'),
|
|
1889
1923
|
sizes: qwik._fnSignal((p0) => p0.sizes, [
|
|
1890
1924
|
props
|
|
1891
1925
|
], "p0.sizes"),
|
|
@@ -4462,7 +4496,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4462
4496
|
const url = new URL(e.origin), hostname = url.hostname;
|
|
4463
4497
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
4464
4498
|
}
|
|
4465
|
-
const SDK_VERSION = "0.14.
|
|
4499
|
+
const SDK_VERSION = "0.14.7";
|
|
4466
4500
|
const registry = {};
|
|
4467
4501
|
function register(type, info) {
|
|
4468
4502
|
let typeList = registry[type];
|
|
@@ -4711,7 +4745,11 @@ const evaluateJsCode = function evaluateJsCode2(props, state, elementRef) {
|
|
|
4711
4745
|
context: props.context || {},
|
|
4712
4746
|
localState: void 0,
|
|
4713
4747
|
rootState: props.builderContextSignal.rootState,
|
|
4714
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
4748
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
4749
|
+
/**
|
|
4750
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
4751
|
+
*/
|
|
4752
|
+
enableCache: false
|
|
4715
4753
|
});
|
|
4716
4754
|
};
|
|
4717
4755
|
const onClick = function onClick22(props, state, elementRef, event) {
|
|
@@ -4733,13 +4771,14 @@ const onClick = function onClick22(props, state, elementRef, event) {
|
|
|
4733
4771
|
state.clicked = true;
|
|
4734
4772
|
};
|
|
4735
4773
|
const evalExpression = function evalExpression2(props, state, elementRef, expression) {
|
|
4736
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
4774
|
+
return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
4737
4775
|
code: group,
|
|
4738
4776
|
context: props.context || {},
|
|
4739
4777
|
localState: void 0,
|
|
4740
4778
|
rootState: props.builderContextSignal.rootState,
|
|
4741
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
4742
|
-
|
|
4779
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
4780
|
+
enableCache: true
|
|
4781
|
+
})));
|
|
4743
4782
|
};
|
|
4744
4783
|
const handleRequest = function handleRequest2(props, state, elementRef, { url, key }) {
|
|
4745
4784
|
fetch$1(url).then((response) => response.json()).then((json) => {
|
package/lib/node/index.qwik.mjs
CHANGED
|
@@ -211,7 +211,7 @@ function flattenState({ rootState, localState, rootSetState }) {
|
|
|
211
211
|
if (localState && prop in localState)
|
|
212
212
|
return localState[prop];
|
|
213
213
|
const val = target[prop];
|
|
214
|
-
if (typeof val === "object")
|
|
214
|
+
if (typeof val === "object" && val !== null)
|
|
215
215
|
return flattenState({
|
|
216
216
|
rootState: val,
|
|
217
217
|
localState: void 0,
|
|
@@ -361,10 +361,34 @@ const shouldForceBrowserRuntimeInNode = () => {
|
|
|
361
361
|
return false;
|
|
362
362
|
};
|
|
363
363
|
const chooseBrowserOrServerEval = (args) => isBrowser$1 || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInNode(args);
|
|
364
|
-
|
|
364
|
+
const _EvalCache = class _EvalCache2 {
|
|
365
|
+
static getCacheKey(args) {
|
|
366
|
+
return JSON.stringify({
|
|
367
|
+
...args,
|
|
368
|
+
// replace the event with a random number to break cache
|
|
369
|
+
// thats because we can't serialize the event object due to circular refs in DOM node refs.
|
|
370
|
+
event: args.event ? Math.random() : void 0
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
static getCachedValue(key) {
|
|
374
|
+
const cachedVal = _EvalCache2.cache.get(key);
|
|
375
|
+
return cachedVal;
|
|
376
|
+
}
|
|
377
|
+
static setCachedValue(key, value) {
|
|
378
|
+
if (_EvalCache2.cache.size > 20)
|
|
379
|
+
_EvalCache2.cache.delete(_EvalCache2.cache.keys().next().value);
|
|
380
|
+
_EvalCache2.cache.set(key, {
|
|
381
|
+
value
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
_EvalCache.cacheLimit = 20;
|
|
386
|
+
_EvalCache.cache = /* @__PURE__ */ new Map();
|
|
387
|
+
let EvalCache = _EvalCache;
|
|
388
|
+
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, enableCache }) {
|
|
365
389
|
if (code === "") {
|
|
366
390
|
logger.warn("Skipping evaluation of empty code block.");
|
|
367
|
-
return;
|
|
391
|
+
return void 0;
|
|
368
392
|
}
|
|
369
393
|
const args = {
|
|
370
394
|
code: parseCode(code, {
|
|
@@ -377,8 +401,19 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
|
|
|
377
401
|
rootState,
|
|
378
402
|
localState
|
|
379
403
|
};
|
|
404
|
+
if (enableCache) {
|
|
405
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
406
|
+
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
407
|
+
if (cachedValue)
|
|
408
|
+
return cachedValue.value;
|
|
409
|
+
}
|
|
380
410
|
try {
|
|
381
|
-
|
|
411
|
+
const newEval = chooseBrowserOrServerEval(args);
|
|
412
|
+
if (enableCache) {
|
|
413
|
+
const cacheKey = EvalCache.getCacheKey(args);
|
|
414
|
+
EvalCache.setCachedValue(cacheKey, newEval);
|
|
415
|
+
}
|
|
416
|
+
return newEval;
|
|
382
417
|
} catch (e) {
|
|
383
418
|
logger.error("Failed code evaluation: " + e.message, {
|
|
384
419
|
code
|
|
@@ -409,7 +444,8 @@ const evaluateBindings = ({ block, context, localState, rootState, rootSetState
|
|
|
409
444
|
localState,
|
|
410
445
|
rootState,
|
|
411
446
|
rootSetState,
|
|
412
|
-
context
|
|
447
|
+
context,
|
|
448
|
+
enableCache: true
|
|
413
449
|
});
|
|
414
450
|
set(copied, binding, value);
|
|
415
451
|
}
|
|
@@ -623,6 +659,51 @@ function bindScrollInViewAnimation(animation) {
|
|
|
623
659
|
immediateOnScroll();
|
|
624
660
|
});
|
|
625
661
|
}
|
|
662
|
+
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
663
|
+
const convertStyleMapToCSSArray = (style) => {
|
|
664
|
+
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
665
|
+
if (typeof value === "string")
|
|
666
|
+
return `${camelToKebabCase(key)}: ${value};`;
|
|
667
|
+
else
|
|
668
|
+
return void 0;
|
|
669
|
+
});
|
|
670
|
+
return cssProps.filter(checkIsDefined);
|
|
671
|
+
};
|
|
672
|
+
const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
673
|
+
const createCssClass = ({ mediaQuery, className, styles }) => {
|
|
674
|
+
const cssClass = `.${className} {
|
|
675
|
+
${convertStyleMapToCSS(styles)}
|
|
676
|
+
}`;
|
|
677
|
+
if (mediaQuery)
|
|
678
|
+
return `${mediaQuery} {
|
|
679
|
+
${cssClass}
|
|
680
|
+
}`;
|
|
681
|
+
else
|
|
682
|
+
return cssClass;
|
|
683
|
+
};
|
|
684
|
+
function transformStyleProperty({ style }) {
|
|
685
|
+
return style;
|
|
686
|
+
}
|
|
687
|
+
const getStyle = ({ block, context }) => {
|
|
688
|
+
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
689
|
+
style: block.style || {},
|
|
690
|
+
context,
|
|
691
|
+
block
|
|
692
|
+
}));
|
|
693
|
+
};
|
|
694
|
+
function mapStyleObjToStrIfNeeded(style) {
|
|
695
|
+
switch (TARGET) {
|
|
696
|
+
case "svelte":
|
|
697
|
+
case "vue":
|
|
698
|
+
case "solid":
|
|
699
|
+
return convertStyleMapToCSSArray(style).join(" ");
|
|
700
|
+
case "qwik":
|
|
701
|
+
case "reactNative":
|
|
702
|
+
case "react":
|
|
703
|
+
case "rsc":
|
|
704
|
+
return style;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
626
707
|
const getComponent = ({ block, context, registeredComponents }) => {
|
|
627
708
|
var _a;
|
|
628
709
|
const componentName = (_a = getProcessedBlock({
|
|
@@ -653,7 +734,8 @@ const getRepeatItemData = ({ block, context }) => {
|
|
|
653
734
|
localState: context.localState,
|
|
654
735
|
rootState: context.rootState,
|
|
655
736
|
rootSetState: context.rootSetState,
|
|
656
|
-
context: context.context
|
|
737
|
+
context: context.context,
|
|
738
|
+
enableCache: true
|
|
657
739
|
});
|
|
658
740
|
if (!Array.isArray(itemsArray))
|
|
659
741
|
return void 0;
|
|
@@ -717,28 +799,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
717
799
|
};
|
|
718
800
|
return newSizes;
|
|
719
801
|
};
|
|
720
|
-
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
721
|
-
const convertStyleMapToCSSArray = (style) => {
|
|
722
|
-
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
723
|
-
if (typeof value === "string")
|
|
724
|
-
return `${camelToKebabCase(key)}: ${value};`;
|
|
725
|
-
else
|
|
726
|
-
return void 0;
|
|
727
|
-
});
|
|
728
|
-
return cssProps.filter(checkIsDefined);
|
|
729
|
-
};
|
|
730
|
-
const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
|
|
731
|
-
const createCssClass = ({ mediaQuery, className, styles }) => {
|
|
732
|
-
const cssClass = `.${className} {
|
|
733
|
-
${convertStyleMapToCSS(styles)}
|
|
734
|
-
}`;
|
|
735
|
-
if (mediaQuery)
|
|
736
|
-
return `${mediaQuery} {
|
|
737
|
-
${cssClass}
|
|
738
|
-
}`;
|
|
739
|
-
else
|
|
740
|
-
return cssClass;
|
|
741
|
-
};
|
|
742
802
|
const InlinedStyles = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
743
803
|
return /* @__PURE__ */ _jsxQ("style", null, {
|
|
744
804
|
dangerouslySetInnerHTML: _fnSignal((p0) => p0.styles, [
|
|
@@ -837,7 +897,8 @@ function createEventHandler(value, options) {
|
|
|
837
897
|
localState: options2.localState,
|
|
838
898
|
rootState: options2.rootState,
|
|
839
899
|
rootSetState: options2.rootSetState,
|
|
840
|
-
event
|
|
900
|
+
event,
|
|
901
|
+
enableCache: true
|
|
841
902
|
});
|
|
842
903
|
}, "createEventHandler_7wCAiJVliNE", [
|
|
843
904
|
options,
|
|
@@ -865,29 +926,6 @@ function getBlockActions(options) {
|
|
|
865
926
|
}
|
|
866
927
|
return obj;
|
|
867
928
|
}
|
|
868
|
-
function transformStyleProperty({ style }) {
|
|
869
|
-
return style;
|
|
870
|
-
}
|
|
871
|
-
const getStyle = ({ block, context }) => {
|
|
872
|
-
return mapStyleObjToStrIfNeeded(transformStyleProperty({
|
|
873
|
-
style: block.style || {},
|
|
874
|
-
context,
|
|
875
|
-
block
|
|
876
|
-
}));
|
|
877
|
-
};
|
|
878
|
-
function mapStyleObjToStrIfNeeded(style) {
|
|
879
|
-
switch (TARGET) {
|
|
880
|
-
case "svelte":
|
|
881
|
-
case "vue":
|
|
882
|
-
case "solid":
|
|
883
|
-
return convertStyleMapToCSSArray(style).join(" ");
|
|
884
|
-
case "qwik":
|
|
885
|
-
case "reactNative":
|
|
886
|
-
case "react":
|
|
887
|
-
case "rsc":
|
|
888
|
-
return style;
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
929
|
function transformBlockProperties({ properties }) {
|
|
892
930
|
return properties;
|
|
893
931
|
}
|
|
@@ -1067,9 +1105,6 @@ const RepeatedBlock = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((p
|
|
|
1067
1105
|
const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
1068
1106
|
var _a;
|
|
1069
1107
|
_jsxBranch();
|
|
1070
|
-
const state = useStore({
|
|
1071
|
-
childrenContext: props.context
|
|
1072
|
-
});
|
|
1073
1108
|
const blockComponent = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
1074
1109
|
const [props2] = useLexicalScope();
|
|
1075
1110
|
return getComponent({
|
|
@@ -1142,7 +1177,7 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
1142
1177
|
]));
|
|
1143
1178
|
const componentRefProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
1144
1179
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1145
|
-
const [blockComponent2, processedBlock2, props2
|
|
1180
|
+
const [blockComponent2, processedBlock2, props2] = useLexicalScope();
|
|
1146
1181
|
return {
|
|
1147
1182
|
blockChildren: processedBlock2.value.children ?? [],
|
|
1148
1183
|
componentRef: (_a2 = blockComponent2.value) == null ? void 0 : _a2.component,
|
|
@@ -1156,7 +1191,7 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
1156
1191
|
builderComponents: props2.registeredComponents
|
|
1157
1192
|
} : {}
|
|
1158
1193
|
},
|
|
1159
|
-
context:
|
|
1194
|
+
context: props2.context,
|
|
1160
1195
|
linkComponent: props2.linkComponent,
|
|
1161
1196
|
registeredComponents: props2.registeredComponents,
|
|
1162
1197
|
builderBlock: processedBlock2.value,
|
|
@@ -1166,8 +1201,7 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
1166
1201
|
}, "Block_component_componentRefProps_useComputed_Ikbl8VO04ho", [
|
|
1167
1202
|
blockComponent,
|
|
1168
1203
|
processedBlock,
|
|
1169
|
-
props
|
|
1170
|
-
state
|
|
1204
|
+
props
|
|
1171
1205
|
]));
|
|
1172
1206
|
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
1173
1207
|
const [processedBlock2] = useLexicalScope();
|
|
@@ -1275,19 +1309,19 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
1275
1309
|
(childrenWithoutParentComponent.value || []).map((child) => {
|
|
1276
1310
|
return /* @__PURE__ */ _jsxC(Block, {
|
|
1277
1311
|
block: child,
|
|
1278
|
-
get context() {
|
|
1279
|
-
return state.childrenContext;
|
|
1280
|
-
},
|
|
1281
1312
|
get registeredComponents() {
|
|
1282
1313
|
return props.registeredComponents;
|
|
1283
1314
|
},
|
|
1284
1315
|
get linkComponent() {
|
|
1285
1316
|
return props.linkComponent;
|
|
1286
1317
|
},
|
|
1318
|
+
get context() {
|
|
1319
|
+
return props.context;
|
|
1320
|
+
},
|
|
1287
1321
|
[_IMMUTABLE]: {
|
|
1288
|
-
context: _fnSignal((p0) => p0.
|
|
1289
|
-
|
|
1290
|
-
], "p0.
|
|
1322
|
+
context: _fnSignal((p0) => p0.context, [
|
|
1323
|
+
props
|
|
1324
|
+
], "p0.context"),
|
|
1291
1325
|
linkComponent: _fnSignal((p0) => p0.linkComponent, [
|
|
1292
1326
|
props
|
|
1293
1327
|
], "p0.linkComponent"),
|
|
@@ -1881,9 +1915,9 @@ const Image = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
1881
1915
|
props
|
|
1882
1916
|
], '"builder-image"+(p0.className?" "+p0.className:"")+" img-Image"'),
|
|
1883
1917
|
loading: "lazy",
|
|
1884
|
-
role: _fnSignal((p0) => p0.altText ? "presentation"
|
|
1918
|
+
role: _fnSignal((p0) => p0.altText ? void 0 : "presentation", [
|
|
1885
1919
|
props
|
|
1886
|
-
], 'p0.altText?"presentation"
|
|
1920
|
+
], 'p0.altText?undefined:"presentation"'),
|
|
1887
1921
|
sizes: _fnSignal((p0) => p0.sizes, [
|
|
1888
1922
|
props
|
|
1889
1923
|
], "p0.sizes"),
|
|
@@ -4460,7 +4494,7 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
4460
4494
|
const url = new URL(e.origin), hostname = url.hostname;
|
|
4461
4495
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
4462
4496
|
}
|
|
4463
|
-
const SDK_VERSION = "0.14.
|
|
4497
|
+
const SDK_VERSION = "0.14.7";
|
|
4464
4498
|
const registry = {};
|
|
4465
4499
|
function register(type, info) {
|
|
4466
4500
|
let typeList = registry[type];
|
|
@@ -4709,7 +4743,11 @@ const evaluateJsCode = function evaluateJsCode2(props, state, elementRef) {
|
|
|
4709
4743
|
context: props.context || {},
|
|
4710
4744
|
localState: void 0,
|
|
4711
4745
|
rootState: props.builderContextSignal.rootState,
|
|
4712
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
4746
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
4747
|
+
/**
|
|
4748
|
+
* We don't want to cache the result of the JS code, since it's arbitrary side effect code.
|
|
4749
|
+
*/
|
|
4750
|
+
enableCache: false
|
|
4713
4751
|
});
|
|
4714
4752
|
};
|
|
4715
4753
|
const onClick = function onClick22(props, state, elementRef, event) {
|
|
@@ -4731,13 +4769,14 @@ const onClick = function onClick22(props, state, elementRef, event) {
|
|
|
4731
4769
|
state.clicked = true;
|
|
4732
4770
|
};
|
|
4733
4771
|
const evalExpression = function evalExpression2(props, state, elementRef, expression) {
|
|
4734
|
-
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
4772
|
+
return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
|
|
4735
4773
|
code: group,
|
|
4736
4774
|
context: props.context || {},
|
|
4737
4775
|
localState: void 0,
|
|
4738
4776
|
rootState: props.builderContextSignal.rootState,
|
|
4739
|
-
rootSetState: props.builderContextSignal.rootSetState
|
|
4740
|
-
|
|
4777
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
4778
|
+
enableCache: true
|
|
4779
|
+
})));
|
|
4741
4780
|
};
|
|
4742
4781
|
const handleRequest = function handleRequest2(props, state, elementRef, { url, key }) {
|
|
4743
4782
|
fetch$1(url).then((response) => response.json()).then((json) => {
|
package/package.json
CHANGED
|
@@ -10,3 +10,7 @@ export declare const getRepeatItemData: ({ block, context }: {
|
|
|
10
10
|
block: BuilderBlock;
|
|
11
11
|
context: BuilderContextInterface;
|
|
12
12
|
}) => RepeatData[] | undefined;
|
|
13
|
+
export declare const getInheritedStyles: ({ block, context }: {
|
|
14
|
+
block: BuilderBlock;
|
|
15
|
+
context: BuilderContextInterface;
|
|
16
|
+
}) => Partial<CSSStyleDeclaration>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.14.
|
|
1
|
+
export declare const SDK_VERSION = "0.14.7";
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { EvaluatorArgs } from './helpers.js';
|
|
2
|
-
|
|
2
|
+
type EvalValue = unknown;
|
|
3
|
+
export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression, enableCache }: EvaluatorArgs): EvalValue;
|
|
4
|
+
export {};
|