@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/edge/dev.js
CHANGED
|
@@ -132,6 +132,15 @@ function getBlockComponentOptions(block) {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
// src/helpers/omit.ts
|
|
136
|
+
function omit(obj, ...values) {
|
|
137
|
+
const newObject = Object.assign({}, obj);
|
|
138
|
+
for (const key of values) {
|
|
139
|
+
delete newObject[key];
|
|
140
|
+
}
|
|
141
|
+
return newObject;
|
|
142
|
+
}
|
|
143
|
+
|
|
135
144
|
// src/helpers/logger.ts
|
|
136
145
|
var MSG_PREFIX = "[Builder.io]: ";
|
|
137
146
|
var logger = {
|
|
@@ -3490,6 +3499,7 @@ var shouldForceBrowserRuntimeInNode = () => {
|
|
|
3490
3499
|
var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
|
|
3491
3500
|
|
|
3492
3501
|
// src/functions/evaluate/evaluate.ts
|
|
3502
|
+
var DISABLE_CACHE = true;
|
|
3493
3503
|
var EvalCache = class _EvalCache {
|
|
3494
3504
|
static cacheLimit = 20;
|
|
3495
3505
|
static cache = /* @__PURE__ */ new Map();
|
|
@@ -3538,7 +3548,7 @@ function evaluate({
|
|
|
3538
3548
|
rootState,
|
|
3539
3549
|
localState
|
|
3540
3550
|
};
|
|
3541
|
-
if (enableCache) {
|
|
3551
|
+
if (enableCache && !DISABLE_CACHE) {
|
|
3542
3552
|
const cacheKey = EvalCache.getCacheKey(args);
|
|
3543
3553
|
const cachedValue = EvalCache.getCachedValue(cacheKey);
|
|
3544
3554
|
if (cachedValue) {
|
|
@@ -3569,6 +3579,53 @@ function transformBlock(block) {
|
|
|
3569
3579
|
}
|
|
3570
3580
|
|
|
3571
3581
|
// src/functions/get-processed-block.ts
|
|
3582
|
+
function deepCloneWithConditions(obj) {
|
|
3583
|
+
if (obj === null || typeof obj !== "object") {
|
|
3584
|
+
return obj;
|
|
3585
|
+
}
|
|
3586
|
+
if (Array.isArray(obj)) {
|
|
3587
|
+
return obj.map((item) => deepCloneWithConditions(item));
|
|
3588
|
+
}
|
|
3589
|
+
if (obj["@type"] === "@builder.io/sdk:Element") {
|
|
3590
|
+
return obj;
|
|
3591
|
+
}
|
|
3592
|
+
const clonedObj = {};
|
|
3593
|
+
for (const key in obj) {
|
|
3594
|
+
if (key !== "meta" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
3595
|
+
clonedObj[key] = deepCloneWithConditions(obj[key]);
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
return clonedObj;
|
|
3599
|
+
}
|
|
3600
|
+
var IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK = ["svelte", "vue", "angular", "qwik", "solid"].includes(TARGET);
|
|
3601
|
+
var getCopy = (block) => {
|
|
3602
|
+
if (IS_SDK_WITHOUT_CACHED_PROCESSED_BLOCK) {
|
|
3603
|
+
const copy = fastClone(block);
|
|
3604
|
+
const copied = {
|
|
3605
|
+
...copy,
|
|
3606
|
+
properties: {
|
|
3607
|
+
...copy.properties
|
|
3608
|
+
},
|
|
3609
|
+
actions: {
|
|
3610
|
+
...copy.actions
|
|
3611
|
+
}
|
|
3612
|
+
};
|
|
3613
|
+
return copied;
|
|
3614
|
+
} else {
|
|
3615
|
+
const copy = deepCloneWithConditions(omit(block, "children", "meta"));
|
|
3616
|
+
return {
|
|
3617
|
+
...copy,
|
|
3618
|
+
properties: {
|
|
3619
|
+
...copy.properties
|
|
3620
|
+
},
|
|
3621
|
+
actions: {
|
|
3622
|
+
...copy.actions
|
|
3623
|
+
},
|
|
3624
|
+
children: block.children,
|
|
3625
|
+
meta: block.meta
|
|
3626
|
+
};
|
|
3627
|
+
}
|
|
3628
|
+
};
|
|
3572
3629
|
var evaluateBindings = ({
|
|
3573
3630
|
block,
|
|
3574
3631
|
context,
|
|
@@ -3579,16 +3636,7 @@ var evaluateBindings = ({
|
|
|
3579
3636
|
if (!block.bindings) {
|
|
3580
3637
|
return block;
|
|
3581
3638
|
}
|
|
3582
|
-
const
|
|
3583
|
-
const copied = {
|
|
3584
|
-
...copy,
|
|
3585
|
-
properties: {
|
|
3586
|
-
...copy.properties
|
|
3587
|
-
},
|
|
3588
|
-
actions: {
|
|
3589
|
-
...copy.actions
|
|
3590
|
-
}
|
|
3591
|
-
};
|
|
3639
|
+
const copied = getCopy(block);
|
|
3592
3640
|
for (const binding in block.bindings) {
|
|
3593
3641
|
const expression = block.bindings[binding];
|
|
3594
3642
|
const value = evaluate({
|
|
@@ -3871,17 +3919,9 @@ function mapStyleObjToStrIfNeeded(style) {
|
|
|
3871
3919
|
// src/components/block/block.helpers.ts
|
|
3872
3920
|
var getComponent = ({
|
|
3873
3921
|
block,
|
|
3874
|
-
context,
|
|
3875
3922
|
registeredComponents
|
|
3876
3923
|
}) => {
|
|
3877
|
-
const componentName =
|
|
3878
|
-
block,
|
|
3879
|
-
localState: context.localState,
|
|
3880
|
-
rootState: context.rootState,
|
|
3881
|
-
rootSetState: context.rootSetState,
|
|
3882
|
-
context: context.context,
|
|
3883
|
-
shouldEvaluateBindings: false
|
|
3884
|
-
}).component?.name;
|
|
3924
|
+
const componentName = block.component?.name;
|
|
3885
3925
|
if (!componentName) {
|
|
3886
3926
|
return null;
|
|
3887
3927
|
}
|
|
@@ -4034,14 +4074,7 @@ var inlined_styles_default = InlinedStyles;
|
|
|
4034
4074
|
// src/components/block/components/block-styles.tsx
|
|
4035
4075
|
function BlockStyles(props) {
|
|
4036
4076
|
const canShowBlock = createMemo(() => {
|
|
4037
|
-
const processedBlock =
|
|
4038
|
-
block: props.block,
|
|
4039
|
-
localState: props.context.localState,
|
|
4040
|
-
rootState: props.context.rootState,
|
|
4041
|
-
rootSetState: props.context.rootSetState,
|
|
4042
|
-
context: props.context.context,
|
|
4043
|
-
shouldEvaluateBindings: true
|
|
4044
|
-
});
|
|
4077
|
+
const processedBlock = props.block;
|
|
4045
4078
|
if (checkIsDefined(processedBlock.hide)) {
|
|
4046
4079
|
return !processedBlock.hide;
|
|
4047
4080
|
}
|
|
@@ -4051,14 +4084,7 @@ function BlockStyles(props) {
|
|
|
4051
4084
|
return true;
|
|
4052
4085
|
});
|
|
4053
4086
|
const css = createMemo(() => {
|
|
4054
|
-
const processedBlock =
|
|
4055
|
-
block: props.block,
|
|
4056
|
-
localState: props.context.localState,
|
|
4057
|
-
rootState: props.context.rootState,
|
|
4058
|
-
rootSetState: props.context.rootSetState,
|
|
4059
|
-
context: props.context.context,
|
|
4060
|
-
shouldEvaluateBindings: true
|
|
4061
|
-
});
|
|
4087
|
+
const processedBlock = props.block;
|
|
4062
4088
|
const styles = processedBlock.responsiveStyles;
|
|
4063
4089
|
const content = props.context.content;
|
|
4064
4090
|
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
|
|
@@ -4364,12 +4390,9 @@ var repeated_block_default = RepeatedBlock;
|
|
|
4364
4390
|
|
|
4365
4391
|
// src/components/block/block.tsx
|
|
4366
4392
|
function Block(props) {
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
context: props.context,
|
|
4371
|
-
registeredComponents: props.registeredComponents
|
|
4372
|
-
});
|
|
4393
|
+
createSignal({
|
|
4394
|
+
value: null,
|
|
4395
|
+
update: false
|
|
4373
4396
|
});
|
|
4374
4397
|
const repeatItem = createMemo(() => {
|
|
4375
4398
|
return getRepeatItemData({
|
|
@@ -4378,7 +4401,7 @@ function Block(props) {
|
|
|
4378
4401
|
});
|
|
4379
4402
|
});
|
|
4380
4403
|
const processedBlock = createMemo(() => {
|
|
4381
|
-
|
|
4404
|
+
const blockToUse = props.block.repeat?.collection ? props.block : getProcessedBlock({
|
|
4382
4405
|
block: props.block,
|
|
4383
4406
|
localState: props.context.localState,
|
|
4384
4407
|
rootState: props.context.rootState,
|
|
@@ -4386,6 +4409,13 @@ function Block(props) {
|
|
|
4386
4409
|
context: props.context.context,
|
|
4387
4410
|
shouldEvaluateBindings: true
|
|
4388
4411
|
});
|
|
4412
|
+
return blockToUse;
|
|
4413
|
+
});
|
|
4414
|
+
const blockComponent = createMemo(() => {
|
|
4415
|
+
return getComponent({
|
|
4416
|
+
block: processedBlock(),
|
|
4417
|
+
registeredComponents: props.registeredComponents
|
|
4418
|
+
});
|
|
4389
4419
|
});
|
|
4390
4420
|
const Tag = createMemo(() => {
|
|
4391
4421
|
const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
|
|
@@ -4444,40 +4474,72 @@ function Block(props) {
|
|
|
4444
4474
|
get children() {
|
|
4445
4475
|
return [createComponent(block_styles_default, {
|
|
4446
4476
|
get block() {
|
|
4447
|
-
return
|
|
4477
|
+
return processedBlock();
|
|
4448
4478
|
},
|
|
4449
4479
|
get context() {
|
|
4450
4480
|
return props.context;
|
|
4451
4481
|
}
|
|
4452
4482
|
}), createComponent(Show, {
|
|
4453
4483
|
get fallback() {
|
|
4454
|
-
return createComponent(
|
|
4455
|
-
get
|
|
4456
|
-
return
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4484
|
+
return createComponent(Show, {
|
|
4485
|
+
get fallback() {
|
|
4486
|
+
return createComponent(For, {
|
|
4487
|
+
get each() {
|
|
4488
|
+
return repeatItem();
|
|
4489
|
+
},
|
|
4490
|
+
children: (data, _index) => {
|
|
4491
|
+
const index = _index();
|
|
4492
|
+
return createComponent(repeated_block_default, {
|
|
4493
|
+
key: index,
|
|
4494
|
+
get repeatContext() {
|
|
4495
|
+
return data.context;
|
|
4496
|
+
},
|
|
4497
|
+
get block() {
|
|
4498
|
+
return data.block;
|
|
4499
|
+
},
|
|
4500
|
+
get registeredComponents() {
|
|
4501
|
+
return props.registeredComponents;
|
|
4502
|
+
},
|
|
4503
|
+
get linkComponent() {
|
|
4504
|
+
return props.linkComponent;
|
|
4505
|
+
}
|
|
4506
|
+
});
|
|
4507
|
+
}
|
|
4508
|
+
});
|
|
4475
4509
|
},
|
|
4476
|
-
get
|
|
4477
|
-
return
|
|
4510
|
+
get when() {
|
|
4511
|
+
return !repeatItem();
|
|
4478
4512
|
},
|
|
4479
|
-
get
|
|
4480
|
-
return
|
|
4513
|
+
get children() {
|
|
4514
|
+
return createComponent(component_ref_default, {
|
|
4515
|
+
get componentRef() {
|
|
4516
|
+
return componentRefProps().componentRef;
|
|
4517
|
+
},
|
|
4518
|
+
get componentOptions() {
|
|
4519
|
+
return componentRefProps().componentOptions;
|
|
4520
|
+
},
|
|
4521
|
+
get blockChildren() {
|
|
4522
|
+
return componentRefProps().blockChildren;
|
|
4523
|
+
},
|
|
4524
|
+
get context() {
|
|
4525
|
+
return componentRefProps().context;
|
|
4526
|
+
},
|
|
4527
|
+
get registeredComponents() {
|
|
4528
|
+
return componentRefProps().registeredComponents;
|
|
4529
|
+
},
|
|
4530
|
+
get linkComponent() {
|
|
4531
|
+
return componentRefProps().linkComponent;
|
|
4532
|
+
},
|
|
4533
|
+
get builderBlock() {
|
|
4534
|
+
return componentRefProps().builderBlock;
|
|
4535
|
+
},
|
|
4536
|
+
get includeBlockProps() {
|
|
4537
|
+
return componentRefProps().includeBlockProps;
|
|
4538
|
+
},
|
|
4539
|
+
get isInteractive() {
|
|
4540
|
+
return componentRefProps().isInteractive;
|
|
4541
|
+
}
|
|
4542
|
+
});
|
|
4481
4543
|
}
|
|
4482
4544
|
});
|
|
4483
4545
|
},
|
|
@@ -4587,7 +4649,7 @@ function Block(props) {
|
|
|
4587
4649
|
});
|
|
4588
4650
|
}
|
|
4589
4651
|
var block_default = Block;
|
|
4590
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
4652
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-4da8c6f4 {
|
|
4591
4653
|
display: flex;
|
|
4592
4654
|
flex-direction: column;
|
|
4593
4655
|
align-items: stretch;
|
|
@@ -4618,9 +4680,16 @@ function BlocksWrapper(props) {
|
|
|
4618
4680
|
}, "*");
|
|
4619
4681
|
}
|
|
4620
4682
|
}
|
|
4683
|
+
let blocksWrapperRef;
|
|
4684
|
+
onMount(() => {
|
|
4685
|
+
});
|
|
4621
4686
|
return [createComponent(Dynamic, mergeProps({
|
|
4622
4687
|
get ["class"]() {
|
|
4623
|
-
return className() + " dynamic-
|
|
4688
|
+
return className() + " dynamic-4da8c6f4";
|
|
4689
|
+
},
|
|
4690
|
+
ref(r$) {
|
|
4691
|
+
const _ref$ = blocksWrapperRef;
|
|
4692
|
+
typeof _ref$ === "function" ? _ref$(r$) : blocksWrapperRef = r$;
|
|
4624
4693
|
},
|
|
4625
4694
|
get ["builder-path"]() {
|
|
4626
4695
|
return props.path;
|
|
@@ -6084,7 +6153,8 @@ var componentInfo7 = {
|
|
|
6084
6153
|
defaultValue: "children"
|
|
6085
6154
|
}],
|
|
6086
6155
|
shouldReceiveBuilderProps: {
|
|
6087
|
-
builderContext: true
|
|
6156
|
+
builderContext: true,
|
|
6157
|
+
builderComponents: true
|
|
6088
6158
|
}
|
|
6089
6159
|
};
|
|
6090
6160
|
var _tmpl$8 = /* @__PURE__ */ template(`<div>`);
|
|
@@ -6105,6 +6175,9 @@ function Slot(props) {
|
|
|
6105
6175
|
get context() {
|
|
6106
6176
|
return props.builderContext;
|
|
6107
6177
|
},
|
|
6178
|
+
get registeredComponents() {
|
|
6179
|
+
return props.builderComponents;
|
|
6180
|
+
},
|
|
6108
6181
|
get blocks() {
|
|
6109
6182
|
return props.builderContext.rootState?.[props.name];
|
|
6110
6183
|
}
|
|
@@ -7738,14 +7811,14 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
7738
7811
|
// src/functions/register-component.ts
|
|
7739
7812
|
var createRegisterComponentMessage = (info) => ({
|
|
7740
7813
|
type: "builder.registerComponent",
|
|
7741
|
-
data:
|
|
7814
|
+
data: serializeIncludingFunctions(info)
|
|
7742
7815
|
});
|
|
7743
7816
|
var serializeFn = (fnValue) => {
|
|
7744
7817
|
const fnStr = fnValue.toString().trim();
|
|
7745
7818
|
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
7746
7819
|
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
7747
7820
|
};
|
|
7748
|
-
function
|
|
7821
|
+
function serializeIncludingFunctions(info) {
|
|
7749
7822
|
return JSON.parse(JSON.stringify(info, (key, value) => {
|
|
7750
7823
|
if (typeof value === "function") {
|
|
7751
7824
|
return serializeFn(value);
|
|
@@ -7922,7 +7995,7 @@ var generateContentUrl = (options) => {
|
|
|
7922
7995
|
locale,
|
|
7923
7996
|
apiVersion = DEFAULT_API_VERSION,
|
|
7924
7997
|
fields,
|
|
7925
|
-
omit,
|
|
7998
|
+
omit: omit2,
|
|
7926
7999
|
offset,
|
|
7927
8000
|
cacheSeconds,
|
|
7928
8001
|
staleCacheSeconds,
|
|
@@ -7945,7 +8018,7 @@ var generateContentUrl = (options) => {
|
|
|
7945
8018
|
url.searchParams.set("locale", locale);
|
|
7946
8019
|
if (enrich)
|
|
7947
8020
|
url.searchParams.set("enrich", String(enrich));
|
|
7948
|
-
url.searchParams.set("omit",
|
|
8021
|
+
url.searchParams.set("omit", omit2 || "meta.componentsUsed");
|
|
7949
8022
|
if (fields) {
|
|
7950
8023
|
url.searchParams.set("fields", fields);
|
|
7951
8024
|
}
|
|
@@ -8318,11 +8391,14 @@ function isFromTrustedHost(trustedHosts, e) {
|
|
|
8318
8391
|
}
|
|
8319
8392
|
|
|
8320
8393
|
// src/constants/sdk-version.ts
|
|
8321
|
-
var SDK_VERSION = "2.0.
|
|
8394
|
+
var SDK_VERSION = "2.0.13";
|
|
8322
8395
|
|
|
8323
8396
|
// src/functions/register.ts
|
|
8324
8397
|
var registry = {};
|
|
8325
8398
|
function register(type, info) {
|
|
8399
|
+
if (type === "plugin") {
|
|
8400
|
+
info = serializeIncludingFunctions(info);
|
|
8401
|
+
}
|
|
8326
8402
|
let typeList = registry[type];
|
|
8327
8403
|
if (!typeList) {
|
|
8328
8404
|
typeList = registry[type] = [];
|
|
@@ -8968,7 +9044,7 @@ function ContentComponent(props) {
|
|
|
8968
9044
|
...acc,
|
|
8969
9045
|
[info.name]: {
|
|
8970
9046
|
component,
|
|
8971
|
-
...
|
|
9047
|
+
...serializeIncludingFunctions(info)
|
|
8972
9048
|
}
|
|
8973
9049
|
}), {}));
|
|
8974
9050
|
const [builderContextSignal, setBuilderContextSignal] = createSignal({
|
|
@@ -9000,7 +9076,7 @@ function ContentComponent(props) {
|
|
|
9000
9076
|
...info
|
|
9001
9077
|
}) => ({
|
|
9002
9078
|
...acc,
|
|
9003
|
-
[info.name]:
|
|
9079
|
+
[info.name]: serializeIncludingFunctions(info)
|
|
9004
9080
|
}), {}),
|
|
9005
9081
|
inheritedStyles: {},
|
|
9006
9082
|
BlocksWrapper: props.blocksWrapper || "div",
|