@builder.io/sdk-solid 4.1.3 → 4.2.1

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/node/dev.jsx CHANGED
@@ -4323,13 +4323,15 @@ function FormComponent(props) {
4323
4323
  const headers = props.customHeaders || {};
4324
4324
  let body;
4325
4325
  const formData = new FormData(el);
4326
- const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
4326
+ const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).filter(
4327
+ (el2) => !!el2.name && (el2.type !== "radio" || el2.checked)
4328
+ ).map((el2) => {
4327
4329
  let value;
4328
4330
  const key = el2.name;
4329
4331
  if (el2 instanceof HTMLInputElement) {
4330
4332
  if (el2.type === "radio") {
4331
4333
  if (el2.checked) {
4332
- value = el2.name;
4334
+ value = el2.value;
4333
4335
  return {
4334
4336
  key,
4335
4337
  value
@@ -4522,14 +4524,14 @@ function FormComponent(props) {
4522
4524
  blocks={props.sendingMessage}
4523
4525
  context={props.builderContext}
4524
4526
  /></Show12>
4525
- <Show12 when={submissionState() === "error" && responseData()}><pre class="builder-form-error-text pre-7430044e">{JSON.stringify(responseData(), null, 2)}</pre></Show12>
4527
+ <Show12 when={submissionState() === "error" && responseData()}><pre class="builder-form-error-text pre-fdf23968">{JSON.stringify(responseData(), null, 2)}</pre></Show12>
4526
4528
  <Show12 when={submissionState() === "success"}><Blocks_default
4527
4529
  path="successMessage"
4528
4530
  blocks={props.successMessage}
4529
4531
  context={props.builderContext}
4530
4532
  /></Show12>
4531
4533
  </form>
4532
- <style>{`.pre-7430044e {
4534
+ <style>{`.pre-fdf23968 {
4533
4535
  padding: 10px;
4534
4536
  color: red;
4535
4537
  text-align: center;
@@ -5165,7 +5167,7 @@ function getPreviewContent(_searchParams) {
5165
5167
  }
5166
5168
 
5167
5169
  // src/constants/sdk-version.ts
5168
- var SDK_VERSION = "4.1.3";
5170
+ var SDK_VERSION = "4.2.1";
5169
5171
 
5170
5172
  // src/helpers/sdk-headers.ts
5171
5173
  var getSdkHeaders = () => ({
@@ -6070,38 +6072,59 @@ function EnableEditor(props) {
6070
6072
  }
6071
6073
  function runHttpRequests() {
6072
6074
  const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
6073
- Object.entries(requests).forEach(([key, url]) => {
6074
- if (!url)
6075
- return;
6076
- if (httpReqsPending()[key])
6077
- return;
6078
- if (httpReqsData()[key] && !isEditing())
6079
- return;
6080
- httpReqsPending()[key] = true;
6081
- const evaluatedUrl = url.replace(
6082
- /{{([^}]+)}}/g,
6083
- (_match, group) => String(
6084
- evaluate({
6085
- code: group,
6086
- context: props.context || {},
6087
- localState: void 0,
6088
- rootState: props.builderContextSignal.rootState,
6089
- rootSetState: props.builderContextSignal.rootSetState
6090
- })
6091
- )
6092
- );
6093
- logFetch(evaluatedUrl);
6094
- fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
6095
- mergeNewRootState({
6096
- [key]: json
6075
+ Object.entries(requests).forEach(
6076
+ ([key, httpRequest]) => {
6077
+ if (!httpRequest)
6078
+ return;
6079
+ const isCoreRequest = typeof httpRequest === "object" && httpRequest["@type"] === "@builder.io/core:Request";
6080
+ if (httpReqsPending()[key])
6081
+ return;
6082
+ if (httpReqsData()[key] && !isEditing())
6083
+ return;
6084
+ const url = isCoreRequest ? httpRequest.request.url : httpRequest;
6085
+ httpReqsPending()[key] = true;
6086
+ const evaluatedUrl = url.replace(
6087
+ /{{([^}]+)}}/g,
6088
+ (_match, group) => String(
6089
+ evaluate({
6090
+ code: group,
6091
+ context: props.context || {},
6092
+ localState: void 0,
6093
+ rootState: props.builderContextSignal.rootState,
6094
+ rootSetState: props.builderContextSignal.rootSetState
6095
+ })
6096
+ )
6097
+ );
6098
+ const fetchRequestObj = isCoreRequest ? {
6099
+ url: evaluatedUrl,
6100
+ method: httpRequest.request.method,
6101
+ headers: httpRequest.request.headers,
6102
+ body: httpRequest.request.body
6103
+ } : {
6104
+ url: evaluatedUrl,
6105
+ method: "GET"
6106
+ };
6107
+ logFetch(JSON.stringify(fetchRequestObj));
6108
+ fetch(fetchRequestObj.url, {
6109
+ method: fetchRequestObj.method,
6110
+ headers: fetchRequestObj.headers,
6111
+ body: fetchRequestObj.body
6112
+ }).then((response) => response.json()).then((json) => {
6113
+ mergeNewRootState({
6114
+ [key]: json
6115
+ });
6116
+ httpReqsData()[key] = true;
6117
+ }).catch((err) => {
6118
+ console.error(
6119
+ "error fetching dynamic data",
6120
+ JSON.stringify(httpRequest),
6121
+ err
6122
+ );
6123
+ }).finally(() => {
6124
+ httpReqsPending()[key] = false;
6097
6125
  });
6098
- httpReqsData()[key] = true;
6099
- }).catch((err) => {
6100
- console.error("error fetching dynamic data", url, err);
6101
- }).finally(() => {
6102
- httpReqsPending()[key] = false;
6103
- });
6104
- });
6126
+ }
6127
+ );
6105
6128
  }
6106
6129
  function emitStateUpdate() {
6107
6130
  if (isEditing()) {
@@ -6673,6 +6696,18 @@ function register(type, info) {
6673
6696
  }
6674
6697
  }
6675
6698
  }
6699
+ function registerAction(action) {
6700
+ if (isBrowser()) {
6701
+ const actionClone = JSON.parse(JSON.stringify(action));
6702
+ if (action.action) {
6703
+ actionClone.action = action.action.toString();
6704
+ }
6705
+ window.parent?.postMessage({
6706
+ type: "builder.registerAction",
6707
+ data: actionClone
6708
+ }, "*");
6709
+ }
6710
+ }
6676
6711
 
6677
6712
  // src/functions/set-editor-settings.ts
6678
6713
  var settings = {};
@@ -6729,6 +6764,7 @@ export {
6729
6764
  isEditing,
6730
6765
  isPreviewing,
6731
6766
  register,
6767
+ registerAction,
6732
6768
  setClientUserAttributes,
6733
6769
  setEditorSettings,
6734
6770
  subscribeToEditor,
package/lib/node/index.js CHANGED
@@ -4670,9 +4670,9 @@ function logFetch(url) {
4670
4670
  }
4671
4671
 
4672
4672
  // src/blocks/form/form/form.tsx
4673
- var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-7430044e">`);
4673
+ var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-fdf23968">`);
4674
4674
  var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
4675
- var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-7430044e {
4675
+ var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-fdf23968 {
4676
4676
  padding: 10px;
4677
4677
  color: red;
4678
4678
  text-align: center;
@@ -4709,13 +4709,13 @@ function FormComponent(props) {
4709
4709
  const headers = props.customHeaders || {};
4710
4710
  let body;
4711
4711
  const formData = new FormData(el);
4712
- const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
4712
+ const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).filter((el2) => !!el2.name && (el2.type !== "radio" || el2.checked)).map((el2) => {
4713
4713
  let value;
4714
4714
  const key = el2.name;
4715
4715
  if (el2 instanceof HTMLInputElement) {
4716
4716
  if (el2.type === "radio") {
4717
4717
  if (el2.checked) {
4718
- value = el2.name;
4718
+ value = el2.value;
4719
4719
  return {
4720
4720
  key,
4721
4721
  value
@@ -5658,7 +5658,7 @@ function getPreviewContent(_searchParams) {
5658
5658
  }
5659
5659
 
5660
5660
  // src/constants/sdk-version.ts
5661
- var SDK_VERSION = "4.1.3";
5661
+ var SDK_VERSION = "4.2.1";
5662
5662
 
5663
5663
  // src/helpers/sdk-headers.ts
5664
5664
  var getSdkHeaders = () => ({
@@ -6559,13 +6559,15 @@ function EnableEditor(props) {
6559
6559
  }
6560
6560
  function runHttpRequests() {
6561
6561
  const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
6562
- Object.entries(requests).forEach(([key, url]) => {
6563
- if (!url)
6562
+ Object.entries(requests).forEach(([key, httpRequest]) => {
6563
+ if (!httpRequest)
6564
6564
  return;
6565
+ const isCoreRequest = typeof httpRequest === "object" && httpRequest["@type"] === "@builder.io/core:Request";
6565
6566
  if (httpReqsPending()[key])
6566
6567
  return;
6567
6568
  if (httpReqsData()[key] && !isEditing())
6568
6569
  return;
6570
+ const url = isCoreRequest ? httpRequest.request.url : httpRequest;
6569
6571
  httpReqsPending()[key] = true;
6570
6572
  const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
6571
6573
  code: group,
@@ -6574,8 +6576,21 @@ function EnableEditor(props) {
6574
6576
  rootState: props.builderContextSignal.rootState,
6575
6577
  rootSetState: props.builderContextSignal.rootSetState
6576
6578
  })));
6577
- logFetch(evaluatedUrl);
6578
- fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
6579
+ const fetchRequestObj = isCoreRequest ? {
6580
+ url: evaluatedUrl,
6581
+ method: httpRequest.request.method,
6582
+ headers: httpRequest.request.headers,
6583
+ body: httpRequest.request.body
6584
+ } : {
6585
+ url: evaluatedUrl,
6586
+ method: "GET"
6587
+ };
6588
+ logFetch(JSON.stringify(fetchRequestObj));
6589
+ fetch(fetchRequestObj.url, {
6590
+ method: fetchRequestObj.method,
6591
+ headers: fetchRequestObj.headers,
6592
+ body: fetchRequestObj.body
6593
+ }).then((response) => response.json()).then((json) => {
6579
6594
  mergeNewRootState({
6580
6595
  [key]: json
6581
6596
  });
@@ -7351,6 +7366,18 @@ function register(type, info) {
7351
7366
  }
7352
7367
  }
7353
7368
  }
7369
+ function registerAction(action) {
7370
+ if (isBrowser()) {
7371
+ const actionClone = JSON.parse(JSON.stringify(action));
7372
+ if (action.action) {
7373
+ actionClone.action = action.action.toString();
7374
+ }
7375
+ window.parent?.postMessage({
7376
+ type: "builder.registerAction",
7377
+ data: actionClone
7378
+ }, "*");
7379
+ }
7380
+ }
7354
7381
 
7355
7382
  // src/functions/set-editor-settings.ts
7356
7383
  var settings = {};
@@ -7387,4 +7414,4 @@ var fetchBuilderProps = async (_args) => {
7387
7414
  };
7388
7415
  };
7389
7416
 
7390
- export { blocks_default as Blocks, builder_context_default as BuilderContext, button_default as Button, columns_default as Columns, content_variants_default as Content, fragment_default as Fragment, image_default as Image, section_default as Section, symbol_default as Symbol, text_default as Text, video_default as Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getBuilderSearchParams, isEditing, isPreviewing, register, setClientUserAttributes, setEditorSettings, subscribeToEditor, track };
7417
+ export { blocks_default as Blocks, builder_context_default as BuilderContext, button_default as Button, columns_default as Columns, content_variants_default as Content, fragment_default as Fragment, image_default as Image, section_default as Section, symbol_default as Symbol, text_default as Text, video_default as Video, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getBuilderSearchParams, isEditing, isPreviewing, register, registerAction, setClientUserAttributes, setEditorSettings, subscribeToEditor, track };
@@ -4314,13 +4314,15 @@ function FormComponent(props) {
4314
4314
  const headers = props.customHeaders || {};
4315
4315
  let body;
4316
4316
  const formData = new FormData(el);
4317
- const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
4317
+ const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).filter(
4318
+ (el2) => !!el2.name && (el2.type !== "radio" || el2.checked)
4319
+ ).map((el2) => {
4318
4320
  let value;
4319
4321
  const key = el2.name;
4320
4322
  if (el2 instanceof HTMLInputElement) {
4321
4323
  if (el2.type === "radio") {
4322
4324
  if (el2.checked) {
4323
- value = el2.name;
4325
+ value = el2.value;
4324
4326
  return {
4325
4327
  key,
4326
4328
  value
@@ -4512,14 +4514,14 @@ function FormComponent(props) {
4512
4514
  blocks={props.sendingMessage}
4513
4515
  context={props.builderContext}
4514
4516
  /></Show12>
4515
- <Show12 when={submissionState() === "error" && responseData()}><pre class="builder-form-error-text pre-7430044e">{JSON.stringify(responseData(), null, 2)}</pre></Show12>
4517
+ <Show12 when={submissionState() === "error" && responseData()}><pre class="builder-form-error-text pre-fdf23968">{JSON.stringify(responseData(), null, 2)}</pre></Show12>
4516
4518
  <Show12 when={submissionState() === "success"}><Blocks_default
4517
4519
  path="successMessage"
4518
4520
  blocks={props.successMessage}
4519
4521
  context={props.builderContext}
4520
4522
  /></Show12>
4521
4523
  </form>
4522
- <style>{`.pre-7430044e {
4524
+ <style>{`.pre-fdf23968 {
4523
4525
  padding: 10px;
4524
4526
  color: red;
4525
4527
  text-align: center;
@@ -5154,7 +5156,7 @@ function getPreviewContent(_searchParams) {
5154
5156
  }
5155
5157
 
5156
5158
  // src/constants/sdk-version.ts
5157
- var SDK_VERSION = "4.1.3";
5159
+ var SDK_VERSION = "4.2.1";
5158
5160
 
5159
5161
  // src/helpers/sdk-headers.ts
5160
5162
  var getSdkHeaders = () => ({
@@ -6054,37 +6056,54 @@ function EnableEditor(props) {
6054
6056
  }
6055
6057
  function runHttpRequests() {
6056
6058
  const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
6057
- Object.entries(requests).forEach(([key, url]) => {
6058
- if (!url)
6059
- return;
6060
- if (httpReqsPending()[key])
6061
- return;
6062
- if (httpReqsData()[key] && !isEditing())
6063
- return;
6064
- httpReqsPending()[key] = true;
6065
- const evaluatedUrl = url.replace(
6066
- /{{([^}]+)}}/g,
6067
- (_match, group) => String(
6068
- evaluate({
6069
- code: group,
6070
- context: props.context || {},
6071
- localState: void 0,
6072
- rootState: props.builderContextSignal.rootState,
6073
- rootSetState: props.builderContextSignal.rootSetState
6074
- })
6075
- )
6076
- );
6077
- logFetch(evaluatedUrl);
6078
- fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
6079
- mergeNewRootState({
6080
- [key]: json
6059
+ Object.entries(requests).forEach(
6060
+ ([key, httpRequest]) => {
6061
+ if (!httpRequest)
6062
+ return;
6063
+ const isCoreRequest = typeof httpRequest === "object" && httpRequest["@type"] === "@builder.io/core:Request";
6064
+ if (httpReqsPending()[key])
6065
+ return;
6066
+ if (httpReqsData()[key] && !isEditing())
6067
+ return;
6068
+ const url = isCoreRequest ? httpRequest.request.url : httpRequest;
6069
+ httpReqsPending()[key] = true;
6070
+ const evaluatedUrl = url.replace(
6071
+ /{{([^}]+)}}/g,
6072
+ (_match, group) => String(
6073
+ evaluate({
6074
+ code: group,
6075
+ context: props.context || {},
6076
+ localState: void 0,
6077
+ rootState: props.builderContextSignal.rootState,
6078
+ rootSetState: props.builderContextSignal.rootSetState
6079
+ })
6080
+ )
6081
+ );
6082
+ const fetchRequestObj = isCoreRequest ? {
6083
+ url: evaluatedUrl,
6084
+ method: httpRequest.request.method,
6085
+ headers: httpRequest.request.headers,
6086
+ body: httpRequest.request.body
6087
+ } : {
6088
+ url: evaluatedUrl,
6089
+ method: "GET"
6090
+ };
6091
+ logFetch(JSON.stringify(fetchRequestObj));
6092
+ fetch(fetchRequestObj.url, {
6093
+ method: fetchRequestObj.method,
6094
+ headers: fetchRequestObj.headers,
6095
+ body: fetchRequestObj.body
6096
+ }).then((response) => response.json()).then((json) => {
6097
+ mergeNewRootState({
6098
+ [key]: json
6099
+ });
6100
+ httpReqsData()[key] = true;
6101
+ }).catch((err) => {
6102
+ }).finally(() => {
6103
+ httpReqsPending()[key] = false;
6081
6104
  });
6082
- httpReqsData()[key] = true;
6083
- }).catch((err) => {
6084
- }).finally(() => {
6085
- httpReqsPending()[key] = false;
6086
- });
6087
- });
6105
+ }
6106
+ );
6088
6107
  }
6089
6108
  function emitStateUpdate() {
6090
6109
  if (isEditing()) {
@@ -6655,6 +6674,18 @@ function register(type, info) {
6655
6674
  }
6656
6675
  }
6657
6676
  }
6677
+ function registerAction(action) {
6678
+ if (isBrowser()) {
6679
+ const actionClone = JSON.parse(JSON.stringify(action));
6680
+ if (action.action) {
6681
+ actionClone.action = action.action.toString();
6682
+ }
6683
+ window.parent?.postMessage({
6684
+ type: "builder.registerAction",
6685
+ data: actionClone
6686
+ }, "*");
6687
+ }
6688
+ }
6658
6689
 
6659
6690
  // src/functions/set-editor-settings.ts
6660
6691
  var settings = {};
@@ -6711,6 +6742,7 @@ export {
6711
6742
  isEditing,
6712
6743
  isPreviewing,
6713
6744
  register,
6745
+ registerAction,
6714
6746
  setClientUserAttributes,
6715
6747
  setEditorSettings,
6716
6748
  subscribeToEditor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "4.1.3",
3
+ "version": "4.2.1",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist",