@builder.io/sdk-solid 2.0.8 → 2.0.13
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 +155 -79
- package/lib/browser/dev.jsx +144 -84
- package/lib/browser/index.js +155 -79
- package/lib/browser/index.jsx +144 -84
- package/lib/edge/dev.js +155 -79
- package/lib/edge/dev.jsx +144 -84
- package/lib/edge/index.js +155 -79
- package/lib/edge/index.jsx +144 -84
- package/lib/node/dev.js +157 -81
- package/lib/node/dev.jsx +146 -86
- package/lib/node/index.js +157 -81
- package/lib/node/index.jsx +146 -86
- package/package.json +3 -3
package/lib/node/index.js
CHANGED
|
@@ -127,6 +127,15 @@ function getBlockComponentOptions(block) {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
// src/helpers/omit.ts
|
|
131
|
+
function omit(obj, ...values) {
|
|
132
|
+
const newObject = Object.assign({}, obj);
|
|
133
|
+
for (const key of values) {
|
|
134
|
+
delete newObject[key];
|
|
135
|
+
}
|
|
136
|
+
return newObject;
|
|
137
|
+
}
|
|
138
|
+
|
|
130
139
|
// src/helpers/logger.ts
|
|
131
140
|
var MSG_PREFIX = "[Builder.io]: ";
|
|
132
141
|
var logger = {
|
|
@@ -396,7 +405,7 @@ if (typeof output === 'object' && output !== null) {
|
|
|
396
405
|
};
|
|
397
406
|
var IVM_INSTANCE = null;
|
|
398
407
|
var IVM_CONTEXT = null;
|
|
399
|
-
var SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react";
|
|
408
|
+
var SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react" || SDK_NAME === "@builder.io/sdk-qwik";
|
|
400
409
|
var getIvm = () => {
|
|
401
410
|
try {
|
|
402
411
|
if (IVM_INSTANCE)
|
|
@@ -411,7 +420,7 @@ var getIvm = () => {
|
|
|
411
420
|
|
|
412
421
|
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
413
422
|
|
|
414
|
-
${SHOULD_MENTION_INITIALIZE_SCRIPT ?
|
|
423
|
+
${SHOULD_MENTION_INITIALIZE_SCRIPT ? `- import and call \`initializeNodeRuntime()\` from "${SDK_NAME}/node/init".` : ""}
|
|
415
424
|
- add the following import: \`await import('isolated-vm')\`.
|
|
416
425
|
|
|
417
426
|
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
@@ -515,6 +524,7 @@ var shouldForceBrowserRuntimeInNode = () => {
|
|
|
515
524
|
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInNode(args);
|
|
516
525
|
|
|
517
526
|
// src/functions/evaluate/evaluate.ts
|
|
527
|
+
var DISABLE_CACHE = true;
|
|
518
528
|
var EvalCache = class _EvalCache {
|
|
519
529
|
static cacheLimit = 20;
|
|
520
530
|
static cache = /* @__PURE__ */ new Map();
|
|
@@ -563,7 +573,7 @@ function evaluate({
|
|
|
563
573
|
rootState,
|
|
564
574
|
localState
|
|
565
575
|
};
|
|
566
|
-
if (enableCache) {
|
|
576
|
+
if (enableCache && !DISABLE_CACHE) {
|
|
567
577
|
const cacheKey = EvalCache.getCacheKey(args);
|
|
568
578
|
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
569
579
|
if (cachedValue) {
|
|
@@ -591,6 +601,53 @@ function transformBlock(block) {
|
|
|
591
601
|
}
|
|
592
602
|
|
|
593
603
|
// src/functions/get-processed-block.ts
|
|
604
|
+
function deepCloneWithConditions(obj) {
|
|
605
|
+
if (obj === null || typeof obj !== "object") {
|
|
606
|
+
return obj;
|
|
607
|
+
}
|
|
608
|
+
if (Array.isArray(obj)) {
|
|
609
|
+
return obj.map((item) => deepCloneWithConditions(item));
|
|
610
|
+
}
|
|
611
|
+
if (obj["@type"] === "@builder.io/sdk:Element") {
|
|
612
|
+
return obj;
|
|
613
|
+
}
|
|
614
|
+
const clonedObj = {};
|
|
615
|
+
for (const key in obj) {
|
|
616
|
+
if (key !== "meta" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
617
|
+
clonedObj[key] = deepCloneWithConditions(obj[key]);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return clonedObj;
|
|
621
|
+
}
|
|
622
|
+
var IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK = ["svelte", "vue", "angular", "qwik", "solid"].includes(TARGET);
|
|
623
|
+
var getCopy = (block) => {
|
|
624
|
+
if (IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK) {
|
|
625
|
+
const copy = fastClone(block);
|
|
626
|
+
const copied = {
|
|
627
|
+
...copy,
|
|
628
|
+
properties: {
|
|
629
|
+
...copy.properties
|
|
630
|
+
},
|
|
631
|
+
actions: {
|
|
632
|
+
...copy.actions
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
return copied;
|
|
636
|
+
} else {
|
|
637
|
+
const copy = deepCloneWithConditions(omit(block, "children", "meta"));
|
|
638
|
+
return {
|
|
639
|
+
...copy,
|
|
640
|
+
properties: {
|
|
641
|
+
...copy.properties
|
|
642
|
+
},
|
|
643
|
+
actions: {
|
|
644
|
+
...copy.actions
|
|
645
|
+
},
|
|
646
|
+
children: block.children,
|
|
647
|
+
meta: block.meta
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
};
|
|
594
651
|
var evaluateBindings = ({
|
|
595
652
|
block,
|
|
596
653
|
context,
|
|
@@ -601,16 +658,7 @@ var evaluateBindings = ({
|
|
|
601
658
|
if (!block.bindings) {
|
|
602
659
|
return block;
|
|
603
660
|
}
|
|
604
|
-
const
|
|
605
|
-
const copied = {
|
|
606
|
-
...copy,
|
|
607
|
-
properties: {
|
|
608
|
-
...copy.properties
|
|
609
|
-
},
|
|
610
|
-
actions: {
|
|
611
|
-
...copy.actions
|
|
612
|
-
}
|
|
613
|
-
};
|
|
661
|
+
const copied = getCopy(block);
|
|
614
662
|
for (const binding in block.bindings) {
|
|
615
663
|
const expression = block.bindings[binding];
|
|
616
664
|
const value = evaluate({
|
|
@@ -892,17 +940,9 @@ function mapStyleObjToStrIfNeeded(style) {
|
|
|
892
940
|
// src/components/block/block.helpers.ts
|
|
893
941
|
var getComponent = ({
|
|
894
942
|
block,
|
|
895
|
-
context,
|
|
896
943
|
registeredComponents
|
|
897
944
|
}) => {
|
|
898
|
-
const componentName =
|
|
899
|
-
block,
|
|
900
|
-
localState: context.localState,
|
|
901
|
-
rootState: context.rootState,
|
|
902
|
-
rootSetState: context.rootSetState,
|
|
903
|
-
context: context.context,
|
|
904
|
-
shouldEvaluateBindings: false
|
|
905
|
-
}).component?.name;
|
|
945
|
+
const componentName = block.component?.name;
|
|
906
946
|
if (!componentName) {
|
|
907
947
|
return null;
|
|
908
948
|
}
|
|
@@ -1052,14 +1092,7 @@ var inlined_styles_default = InlinedStyles;
|
|
|
1052
1092
|
// src/components/block/components/block-styles.tsx
|
|
1053
1093
|
function BlockStyles(props) {
|
|
1054
1094
|
const canShowBlock = createMemo(() => {
|
|
1055
|
-
const processedBlock =
|
|
1056
|
-
block: props.block,
|
|
1057
|
-
localState: props.context.localState,
|
|
1058
|
-
rootState: props.context.rootState,
|
|
1059
|
-
rootSetState: props.context.rootSetState,
|
|
1060
|
-
context: props.context.context,
|
|
1061
|
-
shouldEvaluateBindings: true
|
|
1062
|
-
});
|
|
1095
|
+
const processedBlock = props.block;
|
|
1063
1096
|
if (checkIsDefined(processedBlock.hide)) {
|
|
1064
1097
|
return !processedBlock.hide;
|
|
1065
1098
|
}
|
|
@@ -1069,14 +1102,7 @@ function BlockStyles(props) {
|
|
|
1069
1102
|
return true;
|
|
1070
1103
|
});
|
|
1071
1104
|
const css = createMemo(() => {
|
|
1072
|
-
const processedBlock =
|
|
1073
|
-
block: props.block,
|
|
1074
|
-
localState: props.context.localState,
|
|
1075
|
-
rootState: props.context.rootState,
|
|
1076
|
-
rootSetState: props.context.rootSetState,
|
|
1077
|
-
context: props.context.context,
|
|
1078
|
-
shouldEvaluateBindings: true
|
|
1079
|
-
});
|
|
1105
|
+
const processedBlock = props.block;
|
|
1080
1106
|
const styles = processedBlock.responsiveStyles;
|
|
1081
1107
|
const content = props.context.content;
|
|
1082
1108
|
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
|
|
@@ -1382,12 +1408,9 @@ var repeated_block_default = RepeatedBlock;
|
|
|
1382
1408
|
|
|
1383
1409
|
// src/components/block/block.tsx
|
|
1384
1410
|
function Block(props) {
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
context: props.context,
|
|
1389
|
-
registeredComponents: props.registeredComponents
|
|
1390
|
-
});
|
|
1411
|
+
createSignal({
|
|
1412
|
+
value: null,
|
|
1413
|
+
update: false
|
|
1391
1414
|
});
|
|
1392
1415
|
const repeatItem = createMemo(() => {
|
|
1393
1416
|
return getRepeatItemData({
|
|
@@ -1396,7 +1419,7 @@ function Block(props) {
|
|
|
1396
1419
|
});
|
|
1397
1420
|
});
|
|
1398
1421
|
const processedBlock = createMemo(() => {
|
|
1399
|
-
|
|
1422
|
+
const blockToUse = props.block.repeat?.collection ? props.block : getProcessedBlock({
|
|
1400
1423
|
block: props.block,
|
|
1401
1424
|
localState: props.context.localState,
|
|
1402
1425
|
rootState: props.context.rootState,
|
|
@@ -1404,6 +1427,13 @@ function Block(props) {
|
|
|
1404
1427
|
context: props.context.context,
|
|
1405
1428
|
shouldEvaluateBindings: true
|
|
1406
1429
|
});
|
|
1430
|
+
return blockToUse;
|
|
1431
|
+
});
|
|
1432
|
+
const blockComponent = createMemo(() => {
|
|
1433
|
+
return getComponent({
|
|
1434
|
+
block: processedBlock(),
|
|
1435
|
+
registeredComponents: props.registeredComponents
|
|
1436
|
+
});
|
|
1407
1437
|
});
|
|
1408
1438
|
const Tag = createMemo(() => {
|
|
1409
1439
|
const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
|
|
@@ -1462,40 +1492,72 @@ function Block(props) {
|
|
|
1462
1492
|
get children() {
|
|
1463
1493
|
return [createComponent(block_styles_default, {
|
|
1464
1494
|
get block() {
|
|
1465
|
-
return
|
|
1495
|
+
return processedBlock();
|
|
1466
1496
|
},
|
|
1467
1497
|
get context() {
|
|
1468
1498
|
return props.context;
|
|
1469
1499
|
}
|
|
1470
1500
|
}), createComponent(Show, {
|
|
1471
1501
|
get fallback() {
|
|
1472
|
-
return createComponent(
|
|
1473
|
-
get
|
|
1474
|
-
return
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1502
|
+
return createComponent(Show, {
|
|
1503
|
+
get fallback() {
|
|
1504
|
+
return createComponent(For, {
|
|
1505
|
+
get each() {
|
|
1506
|
+
return repeatItem();
|
|
1507
|
+
},
|
|
1508
|
+
children: (data, _index) => {
|
|
1509
|
+
const index = _index();
|
|
1510
|
+
return createComponent(repeated_block_default, {
|
|
1511
|
+
key: index,
|
|
1512
|
+
get repeatContext() {
|
|
1513
|
+
return data.context;
|
|
1514
|
+
},
|
|
1515
|
+
get block() {
|
|
1516
|
+
return data.block;
|
|
1517
|
+
},
|
|
1518
|
+
get registeredComponents() {
|
|
1519
|
+
return props.registeredComponents;
|
|
1520
|
+
},
|
|
1521
|
+
get linkComponent() {
|
|
1522
|
+
return props.linkComponent;
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1493
1527
|
},
|
|
1494
|
-
get
|
|
1495
|
-
return
|
|
1528
|
+
get when() {
|
|
1529
|
+
return !repeatItem();
|
|
1496
1530
|
},
|
|
1497
|
-
get
|
|
1498
|
-
return
|
|
1531
|
+
get children() {
|
|
1532
|
+
return createComponent(component_ref_default, {
|
|
1533
|
+
get componentRef() {
|
|
1534
|
+
return componentRefProps().componentRef;
|
|
1535
|
+
},
|
|
1536
|
+
get componentOptions() {
|
|
1537
|
+
return componentRefProps().componentOptions;
|
|
1538
|
+
},
|
|
1539
|
+
get blockChildren() {
|
|
1540
|
+
return componentRefProps().blockChildren;
|
|
1541
|
+
},
|
|
1542
|
+
get context() {
|
|
1543
|
+
return componentRefProps().context;
|
|
1544
|
+
},
|
|
1545
|
+
get registeredComponents() {
|
|
1546
|
+
return componentRefProps().registeredComponents;
|
|
1547
|
+
},
|
|
1548
|
+
get linkComponent() {
|
|
1549
|
+
return componentRefProps().linkComponent;
|
|
1550
|
+
},
|
|
1551
|
+
get builderBlock() {
|
|
1552
|
+
return componentRefProps().builderBlock;
|
|
1553
|
+
},
|
|
1554
|
+
get includeBlockProps() {
|
|
1555
|
+
return componentRefProps().includeBlockProps;
|
|
1556
|
+
},
|
|
1557
|
+
get isInteractive() {
|
|
1558
|
+
return componentRefProps().isInteractive;
|
|
1559
|
+
}
|
|
1560
|
+
});
|
|
1499
1561
|
}
|
|
1500
1562
|
});
|
|
1501
1563
|
},
|
|
@@ -1605,7 +1667,7 @@ function Block(props) {
|
|
|
1605
1667
|
});
|
|
1606
1668
|
}
|
|
1607
1669
|
var block_default = Block;
|
|
1608
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1670
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-4da8c6f4 {
|
|
1609
1671
|
display: flex;
|
|
1610
1672
|
flex-direction: column;
|
|
1611
1673
|
align-items: stretch;
|
|
@@ -1636,9 +1698,16 @@ function BlocksWrapper(props) {
|
|
|
1636
1698
|
}, "*");
|
|
1637
1699
|
}
|
|
1638
1700
|
}
|
|
1701
|
+
let blocksWrapperRef;
|
|
1702
|
+
onMount(() => {
|
|
1703
|
+
});
|
|
1639
1704
|
return [createComponent(Dynamic, mergeProps({
|
|
1640
1705
|
get ["class"]() {
|
|
1641
|
-
return className() + " dynamic-
|
|
1706
|
+
return className() + " dynamic-4da8c6f4";
|
|
1707
|
+
},
|
|
1708
|
+
ref(r$) {
|
|
1709
|
+
const _ref$ = blocksWrapperRef;
|
|
1710
|
+
typeof _ref$ === "function" ? _ref$(r$) : blocksWrapperRef = r$;
|
|
1642
1711
|
},
|
|
1643
1712
|
get ["builder-path"]() {
|
|
1644
1713
|
return props.path;
|
|
@@ -3100,7 +3169,8 @@ var componentInfo7 = {
|
|
|
3100
3169
|
defaultValue: "children"
|
|
3101
3170
|
}],
|
|
3102
3171
|
shouldReceiveBuilderProps: {
|
|
3103
|
-
builderContext: true
|
|
3172
|
+
builderContext: true,
|
|
3173
|
+
builderComponents: true
|
|
3104
3174
|
}
|
|
3105
3175
|
};
|
|
3106
3176
|
var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
|
|
@@ -3121,6 +3191,9 @@ function Slot(props) {
|
|
|
3121
3191
|
get context() {
|
|
3122
3192
|
return props.builderContext;
|
|
3123
3193
|
},
|
|
3194
|
+
get registeredComponents() {
|
|
3195
|
+
return props.builderComponents;
|
|
3196
|
+
},
|
|
3124
3197
|
get blocks() {
|
|
3125
3198
|
return props.builderContext.rootState?.[props.name];
|
|
3126
3199
|
}
|
|
@@ -4752,14 +4825,14 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
4752
4825
|
// src/functions/register-component.ts
|
|
4753
4826
|
var createRegisterComponentMessage = (info) => ({
|
|
4754
4827
|
type: "builder.registerComponent",
|
|
4755
|
-
data:
|
|
4828
|
+
data: serializeIncludingFunctions(info)
|
|
4756
4829
|
});
|
|
4757
4830
|
var serializeFn = (fnValue) => {
|
|
4758
4831
|
const fnStr = fnValue.toString().trim();
|
|
4759
4832
|
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
4760
4833
|
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
4761
4834
|
};
|
|
4762
|
-
function
|
|
4835
|
+
function serializeIncludingFunctions(info) {
|
|
4763
4836
|
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
4764
4837
|
if (typeof value === "function") {
|
|
4765
4838
|
return serializeFn(value);
|
|
@@ -4934,7 +5007,7 @@ var generateContentUrl = (options) => {
|
|
|
4934
5007
|
locale,
|
|
4935
5008
|
apiVersion = DEFAULT_API_VERSION,
|
|
4936
5009
|
fields,
|
|
4937
|
-
omit,
|
|
5010
|
+
omit: omit2,
|
|
4938
5011
|
offset,
|
|
4939
5012
|
cacheSeconds,
|
|
4940
5013
|
staleCacheSeconds,
|
|
@@ -4957,7 +5030,7 @@ var generateContentUrl = (options) => {
|
|
|
4957
5030
|
url.searchParams.set("locale", locale);
|
|
4958
5031
|
if (enrich)
|
|
4959
5032
|
url.searchParams.set("enrich", String(enrich));
|
|
4960
|
-
url.searchParams.set("omit",
|
|
5033
|
+
url.searchParams.set("omit", omit2 || "meta.componentsUsed");
|
|
4961
5034
|
if (fields) {
|
|
4962
5035
|
url.searchParams.set("fields", fields);
|
|
4963
5036
|
}
|
|
@@ -5327,11 +5400,14 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
5327
5400
|
}
|
|
5328
5401
|
|
|
5329
5402
|
// src/constants/sdk-version.ts
|
|
5330
|
-
var SDK_VERSION = "2.0.
|
|
5403
|
+
var SDK_VERSION = "2.0.13";
|
|
5331
5404
|
|
|
5332
5405
|
// src/functions/register.ts
|
|
5333
5406
|
var registry = {};
|
|
5334
5407
|
function register(type, info) {
|
|
5408
|
+
if (type === "plugin") {
|
|
5409
|
+
info = serializeIncludingFunctions(info);
|
|
5410
|
+
}
|
|
5335
5411
|
let typeList = registry[type];
|
|
5336
5412
|
if (!typeList) {
|
|
5337
5413
|
typeList = registry[type] = [];
|
|
@@ -5975,7 +6051,7 @@ function ContentComponent(props) {
|
|
|
5975
6051
|
...acc,
|
|
5976
6052
|
[info.name]: {
|
|
5977
6053
|
component,
|
|
5978
|
-
...
|
|
6054
|
+
...serializeIncludingFunctions(info)
|
|
5979
6055
|
}
|
|
5980
6056
|
}), {}));
|
|
5981
6057
|
const [builderContextSignal, setBuilderContextSignal] = createSignal({
|
|
@@ -6007,7 +6083,7 @@ function ContentComponent(props) {
|
|
|
6007
6083
|
...info
|
|
6008
6084
|
}) => ({
|
|
6009
6085
|
...acc,
|
|
6010
|
-
[info.name]:
|
|
6086
|
+
[info.name]: serializeIncludingFunctions(info)
|
|
6011
6087
|
}), {}),
|
|
6012
6088
|
inheritedStyles: {},
|
|
6013
6089
|
BlocksWrapper: props.blocksWrapper || "div",
|