@builder.io/sdk-qwik 0.19.3 → 0.20.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.
Files changed (34) hide show
  1. package/lib/browser/blocks/form/form/form.qwik.cjs +2 -2
  2. package/lib/browser/blocks/form/form/form.qwik.mjs +2 -2
  3. package/lib/browser/components/content/components/enable-editor.qwik.cjs +20 -5
  4. package/lib/browser/components/content/components/enable-editor.qwik.mjs +20 -5
  5. package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
  6. package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
  7. package/lib/browser/functions/register.qwik.cjs +13 -0
  8. package/lib/browser/functions/register.qwik.mjs +14 -1
  9. package/lib/browser/index.qwik.cjs +1 -0
  10. package/lib/browser/index.qwik.mjs +2 -1
  11. package/lib/edge/blocks/form/form/form.qwik.cjs +2 -2
  12. package/lib/edge/blocks/form/form/form.qwik.mjs +2 -2
  13. package/lib/edge/components/content/components/enable-editor.qwik.cjs +20 -5
  14. package/lib/edge/components/content/components/enable-editor.qwik.mjs +20 -5
  15. package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
  16. package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
  17. package/lib/edge/functions/register.qwik.cjs +13 -0
  18. package/lib/edge/functions/register.qwik.mjs +14 -1
  19. package/lib/edge/index.qwik.cjs +1 -0
  20. package/lib/edge/index.qwik.mjs +2 -1
  21. package/lib/node/blocks/form/form/form.qwik.cjs +2 -2
  22. package/lib/node/blocks/form/form/form.qwik.mjs +2 -2
  23. package/lib/node/components/content/components/enable-editor.qwik.cjs +20 -5
  24. package/lib/node/components/content/components/enable-editor.qwik.mjs +20 -5
  25. package/lib/node/constants/sdk-version.qwik.cjs +1 -1
  26. package/lib/node/constants/sdk-version.qwik.mjs +1 -1
  27. package/lib/node/functions/register.qwik.cjs +13 -0
  28. package/lib/node/functions/register.qwik.mjs +14 -1
  29. package/lib/node/index.qwik.cjs +1 -0
  30. package/lib/node/index.qwik.mjs +2 -1
  31. package/package.json +1 -1
  32. package/types/src/constants/sdk-version.d.ts +1 -1
  33. package/types/src/functions/register.d.ts +18 -0
  34. package/types/src/server-index.d.ts +1 -1
@@ -36,13 +36,13 @@ const onSubmit = function onSubmit2(props, state, formRef, event) {
36
36
  const headers = props.customHeaders || {};
37
37
  let body;
38
38
  const formData = new FormData(el);
39
- const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
39
+ const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).filter((el2) => !!el2.name && (el2.type !== "radio" || el2.checked)).map((el2) => {
40
40
  let value;
41
41
  const key = el2.name;
42
42
  if (el2 instanceof HTMLInputElement) {
43
43
  if (el2.type === "radio") {
44
44
  if (el2.checked) {
45
- value = el2.name;
45
+ value = el2.value;
46
46
  return {
47
47
  key,
48
48
  value
@@ -34,13 +34,13 @@ const onSubmit = function onSubmit2(props, state, formRef, event) {
34
34
  const headers = props.customHeaders || {};
35
35
  let body;
36
36
  const formData = new FormData(el);
37
- const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
37
+ const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).filter((el2) => !!el2.name && (el2.type !== "radio" || el2.checked)).map((el2) => {
38
38
  let value;
39
39
  const key = el2.name;
40
40
  if (el2 instanceof HTMLInputElement) {
41
41
  if (el2.type === "radio") {
42
42
  if (el2.checked) {
43
- value = el2.name;
43
+ value = el2.value;
44
44
  return {
45
45
  key,
46
46
  value
@@ -99,13 +99,15 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
99
99
  const runHttpRequests = function runHttpRequests2(props, state, showContentProps, elementRef) {
100
100
  var _a, _b;
101
101
  const requests = ((_b = (_a = props.builderContextSignal.content) == null ? void 0 : _a.data) == null ? void 0 : _b.httpRequests) ?? {};
102
- Object.entries(requests).forEach(([key, url]) => {
103
- if (!url)
102
+ Object.entries(requests).forEach(([key, httpRequest]) => {
103
+ if (!httpRequest)
104
104
  return;
105
+ const isCoreRequest = typeof httpRequest === "object" && httpRequest["@type"] === "@builder.io/core:Request";
105
106
  if (state.httpReqsPending[key])
106
107
  return;
107
108
  if (state.httpReqsData[key] && !isEditing.isEditing())
108
109
  return;
110
+ const url = isCoreRequest ? httpRequest.request.url : httpRequest;
109
111
  state.httpReqsPending[key] = true;
110
112
  const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate.evaluate({
111
113
  code: group,
@@ -114,14 +116,27 @@ const runHttpRequests = function runHttpRequests2(props, state, showContentProps
114
116
  rootState: props.builderContextSignal.rootState,
115
117
  rootSetState: props.builderContextSignal.rootSetState
116
118
  })));
117
- logFetch.logFetch(evaluatedUrl);
118
- fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
119
+ const fetchRequestObj = isCoreRequest ? {
120
+ url: evaluatedUrl,
121
+ method: httpRequest.request.method,
122
+ headers: httpRequest.request.headers,
123
+ body: httpRequest.request.body
124
+ } : {
125
+ url: evaluatedUrl,
126
+ method: "GET"
127
+ };
128
+ logFetch.logFetch(JSON.stringify(fetchRequestObj));
129
+ fetch(fetchRequestObj.url, {
130
+ method: fetchRequestObj.method,
131
+ headers: fetchRequestObj.headers,
132
+ body: fetchRequestObj.body
133
+ }).then((response) => response.json()).then((json) => {
119
134
  mergeNewRootState(props, state, showContentProps, elementRef, {
120
135
  [key]: json
121
136
  });
122
137
  state.httpReqsData[key] = true;
123
138
  }).catch((err) => {
124
- console.error("error fetching dynamic data", url, err);
139
+ console.error("error fetching dynamic data", JSON.stringify(httpRequest), err);
125
140
  }).finally(() => {
126
141
  state.httpReqsPending[key] = false;
127
142
  });
@@ -97,13 +97,15 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
97
97
  const runHttpRequests = function runHttpRequests2(props, state, showContentProps, elementRef) {
98
98
  var _a, _b;
99
99
  const requests = ((_b = (_a = props.builderContextSignal.content) == null ? void 0 : _a.data) == null ? void 0 : _b.httpRequests) ?? {};
100
- Object.entries(requests).forEach(([key, url]) => {
101
- if (!url)
100
+ Object.entries(requests).forEach(([key, httpRequest]) => {
101
+ if (!httpRequest)
102
102
  return;
103
+ const isCoreRequest = typeof httpRequest === "object" && httpRequest["@type"] === "@builder.io/core:Request";
103
104
  if (state.httpReqsPending[key])
104
105
  return;
105
106
  if (state.httpReqsData[key] && !isEditing())
106
107
  return;
108
+ const url = isCoreRequest ? httpRequest.request.url : httpRequest;
107
109
  state.httpReqsPending[key] = true;
108
110
  const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
109
111
  code: group,
@@ -112,14 +114,27 @@ const runHttpRequests = function runHttpRequests2(props, state, showContentProps
112
114
  rootState: props.builderContextSignal.rootState,
113
115
  rootSetState: props.builderContextSignal.rootSetState
114
116
  })));
115
- logFetch(evaluatedUrl);
116
- fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
117
+ const fetchRequestObj = isCoreRequest ? {
118
+ url: evaluatedUrl,
119
+ method: httpRequest.request.method,
120
+ headers: httpRequest.request.headers,
121
+ body: httpRequest.request.body
122
+ } : {
123
+ url: evaluatedUrl,
124
+ method: "GET"
125
+ };
126
+ logFetch(JSON.stringify(fetchRequestObj));
127
+ fetch(fetchRequestObj.url, {
128
+ method: fetchRequestObj.method,
129
+ headers: fetchRequestObj.headers,
130
+ body: fetchRequestObj.body
131
+ }).then((response) => response.json()).then((json) => {
117
132
  mergeNewRootState(props, state, showContentProps, elementRef, {
118
133
  [key]: json
119
134
  });
120
135
  state.httpReqsData[key] = true;
121
136
  }).catch((err) => {
122
- console.error("error fetching dynamic data", url, err);
137
+ console.error("error fetching dynamic data", JSON.stringify(httpRequest), err);
123
138
  }).finally(() => {
124
139
  state.httpReqsPending[key] = false;
125
140
  });
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.19.3";
3
+ const SDK_VERSION = "0.20.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.19.3";
1
+ const SDK_VERSION = "0.20.1";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -27,4 +27,17 @@ function register(type, info) {
27
27
  }
28
28
  }
29
29
  }
30
+ function registerAction(action) {
31
+ var _a;
32
+ if (isBrowser.isBrowser()) {
33
+ const actionClone = JSON.parse(JSON.stringify(action));
34
+ if (action.action)
35
+ actionClone.action = action.action.toString();
36
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
37
+ type: "builder.registerAction",
38
+ data: actionClone
39
+ }, "*");
40
+ }
41
+ }
30
42
  exports.register = register;
43
+ exports.registerAction = registerAction;
@@ -25,6 +25,19 @@ function register(type, info) {
25
25
  }
26
26
  }
27
27
  }
28
+ function registerAction(action) {
29
+ var _a;
30
+ if (isBrowser()) {
31
+ const actionClone = JSON.parse(JSON.stringify(action));
32
+ if (action.action)
33
+ actionClone.action = action.action.toString();
34
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
35
+ type: "builder.registerAction",
36
+ data: actionClone
37
+ }, "*");
38
+ }
39
+ }
28
40
  export {
29
- register
41
+ register,
42
+ registerAction
30
43
  };
@@ -38,6 +38,7 @@ exports.isEditing = isEditing.isEditing;
38
38
  exports.isPreviewing = isPreviewing.isPreviewing;
39
39
  exports.createRegisterComponentMessage = registerComponent.createRegisterComponentMessage;
40
40
  exports.register = register.register;
41
+ exports.registerAction = register.registerAction;
41
42
  exports.setEditorSettings = setEditorSettings.setEditorSettings;
42
43
  exports.getBuilderSearchParams = index.getBuilderSearchParams;
43
44
  exports.track = index$1.track;
@@ -13,7 +13,7 @@ import { setClientUserAttributes } from "./helpers/user-attributes.qwik.mjs";
13
13
  import { isEditing } from "./functions/is-editing.qwik.mjs";
14
14
  import { isPreviewing } from "./functions/is-previewing.qwik.mjs";
15
15
  import { createRegisterComponentMessage } from "./functions/register-component.qwik.mjs";
16
- import { register } from "./functions/register.qwik.mjs";
16
+ import { register, registerAction } from "./functions/register.qwik.mjs";
17
17
  import { setEditorSettings } from "./functions/set-editor-settings.qwik.mjs";
18
18
  import { getBuilderSearchParams } from "./functions/get-builder-search-params/index.qwik.mjs";
19
19
  import { track } from "./functions/track/index.qwik.mjs";
@@ -41,6 +41,7 @@ export {
41
41
  isEditing,
42
42
  isPreviewing,
43
43
  register,
44
+ registerAction,
44
45
  setClientUserAttributes,
45
46
  setEditorSettings,
46
47
  subscribeToEditor,
@@ -36,13 +36,13 @@ const onSubmit = function onSubmit2(props, state, formRef, event) {
36
36
  const headers = props.customHeaders || {};
37
37
  let body;
38
38
  const formData = new FormData(el);
39
- const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
39
+ const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).filter((el2) => !!el2.name && (el2.type !== "radio" || el2.checked)).map((el2) => {
40
40
  let value;
41
41
  const key = el2.name;
42
42
  if (el2 instanceof HTMLInputElement) {
43
43
  if (el2.type === "radio") {
44
44
  if (el2.checked) {
45
- value = el2.name;
45
+ value = el2.value;
46
46
  return {
47
47
  key,
48
48
  value
@@ -34,13 +34,13 @@ const onSubmit = function onSubmit2(props, state, formRef, event) {
34
34
  const headers = props.customHeaders || {};
35
35
  let body;
36
36
  const formData = new FormData(el);
37
- const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
37
+ const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).filter((el2) => !!el2.name && (el2.type !== "radio" || el2.checked)).map((el2) => {
38
38
  let value;
39
39
  const key = el2.name;
40
40
  if (el2 instanceof HTMLInputElement) {
41
41
  if (el2.type === "radio") {
42
42
  if (el2.checked) {
43
- value = el2.name;
43
+ value = el2.value;
44
44
  return {
45
45
  key,
46
46
  value
@@ -99,13 +99,15 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
99
99
  const runHttpRequests = function runHttpRequests2(props, state, showContentProps, elementRef) {
100
100
  var _a, _b;
101
101
  const requests = ((_b = (_a = props.builderContextSignal.content) == null ? void 0 : _a.data) == null ? void 0 : _b.httpRequests) ?? {};
102
- Object.entries(requests).forEach(([key, url]) => {
103
- if (!url)
102
+ Object.entries(requests).forEach(([key, httpRequest]) => {
103
+ if (!httpRequest)
104
104
  return;
105
+ const isCoreRequest = typeof httpRequest === "object" && httpRequest["@type"] === "@builder.io/core:Request";
105
106
  if (state.httpReqsPending[key])
106
107
  return;
107
108
  if (state.httpReqsData[key] && !isEditing.isEditing())
108
109
  return;
110
+ const url = isCoreRequest ? httpRequest.request.url : httpRequest;
109
111
  state.httpReqsPending[key] = true;
110
112
  const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate.evaluate({
111
113
  code: group,
@@ -114,14 +116,27 @@ const runHttpRequests = function runHttpRequests2(props, state, showContentProps
114
116
  rootState: props.builderContextSignal.rootState,
115
117
  rootSetState: props.builderContextSignal.rootSetState
116
118
  })));
117
- logFetch.logFetch(evaluatedUrl);
118
- fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
119
+ const fetchRequestObj = isCoreRequest ? {
120
+ url: evaluatedUrl,
121
+ method: httpRequest.request.method,
122
+ headers: httpRequest.request.headers,
123
+ body: httpRequest.request.body
124
+ } : {
125
+ url: evaluatedUrl,
126
+ method: "GET"
127
+ };
128
+ logFetch.logFetch(JSON.stringify(fetchRequestObj));
129
+ fetch(fetchRequestObj.url, {
130
+ method: fetchRequestObj.method,
131
+ headers: fetchRequestObj.headers,
132
+ body: fetchRequestObj.body
133
+ }).then((response) => response.json()).then((json) => {
119
134
  mergeNewRootState(props, state, showContentProps, elementRef, {
120
135
  [key]: json
121
136
  });
122
137
  state.httpReqsData[key] = true;
123
138
  }).catch((err) => {
124
- console.error("error fetching dynamic data", url, err);
139
+ console.error("error fetching dynamic data", JSON.stringify(httpRequest), err);
125
140
  }).finally(() => {
126
141
  state.httpReqsPending[key] = false;
127
142
  });
@@ -97,13 +97,15 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
97
97
  const runHttpRequests = function runHttpRequests2(props, state, showContentProps, elementRef) {
98
98
  var _a, _b;
99
99
  const requests = ((_b = (_a = props.builderContextSignal.content) == null ? void 0 : _a.data) == null ? void 0 : _b.httpRequests) ?? {};
100
- Object.entries(requests).forEach(([key, url]) => {
101
- if (!url)
100
+ Object.entries(requests).forEach(([key, httpRequest]) => {
101
+ if (!httpRequest)
102
102
  return;
103
+ const isCoreRequest = typeof httpRequest === "object" && httpRequest["@type"] === "@builder.io/core:Request";
103
104
  if (state.httpReqsPending[key])
104
105
  return;
105
106
  if (state.httpReqsData[key] && !isEditing())
106
107
  return;
108
+ const url = isCoreRequest ? httpRequest.request.url : httpRequest;
107
109
  state.httpReqsPending[key] = true;
108
110
  const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
109
111
  code: group,
@@ -112,14 +114,27 @@ const runHttpRequests = function runHttpRequests2(props, state, showContentProps
112
114
  rootState: props.builderContextSignal.rootState,
113
115
  rootSetState: props.builderContextSignal.rootSetState
114
116
  })));
115
- logFetch(evaluatedUrl);
116
- fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
117
+ const fetchRequestObj = isCoreRequest ? {
118
+ url: evaluatedUrl,
119
+ method: httpRequest.request.method,
120
+ headers: httpRequest.request.headers,
121
+ body: httpRequest.request.body
122
+ } : {
123
+ url: evaluatedUrl,
124
+ method: "GET"
125
+ };
126
+ logFetch(JSON.stringify(fetchRequestObj));
127
+ fetch(fetchRequestObj.url, {
128
+ method: fetchRequestObj.method,
129
+ headers: fetchRequestObj.headers,
130
+ body: fetchRequestObj.body
131
+ }).then((response) => response.json()).then((json) => {
117
132
  mergeNewRootState(props, state, showContentProps, elementRef, {
118
133
  [key]: json
119
134
  });
120
135
  state.httpReqsData[key] = true;
121
136
  }).catch((err) => {
122
- console.error("error fetching dynamic data", url, err);
137
+ console.error("error fetching dynamic data", JSON.stringify(httpRequest), err);
123
138
  }).finally(() => {
124
139
  state.httpReqsPending[key] = false;
125
140
  });
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.19.3";
3
+ const SDK_VERSION = "0.20.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.19.3";
1
+ const SDK_VERSION = "0.20.1";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -27,4 +27,17 @@ function register(type, info) {
27
27
  }
28
28
  }
29
29
  }
30
+ function registerAction(action) {
31
+ var _a;
32
+ if (isBrowser.isBrowser()) {
33
+ const actionClone = JSON.parse(JSON.stringify(action));
34
+ if (action.action)
35
+ actionClone.action = action.action.toString();
36
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
37
+ type: "builder.registerAction",
38
+ data: actionClone
39
+ }, "*");
40
+ }
41
+ }
30
42
  exports.register = register;
43
+ exports.registerAction = registerAction;
@@ -25,6 +25,19 @@ function register(type, info) {
25
25
  }
26
26
  }
27
27
  }
28
+ function registerAction(action) {
29
+ var _a;
30
+ if (isBrowser()) {
31
+ const actionClone = JSON.parse(JSON.stringify(action));
32
+ if (action.action)
33
+ actionClone.action = action.action.toString();
34
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
35
+ type: "builder.registerAction",
36
+ data: actionClone
37
+ }, "*");
38
+ }
39
+ }
28
40
  export {
29
- register
41
+ register,
42
+ registerAction
30
43
  };
@@ -38,6 +38,7 @@ exports.isEditing = isEditing.isEditing;
38
38
  exports.isPreviewing = isPreviewing.isPreviewing;
39
39
  exports.createRegisterComponentMessage = registerComponent.createRegisterComponentMessage;
40
40
  exports.register = register.register;
41
+ exports.registerAction = register.registerAction;
41
42
  exports.setEditorSettings = setEditorSettings.setEditorSettings;
42
43
  exports.getBuilderSearchParams = index.getBuilderSearchParams;
43
44
  exports.track = index$1.track;
@@ -13,7 +13,7 @@ import { setClientUserAttributes } from "./helpers/user-attributes.qwik.mjs";
13
13
  import { isEditing } from "./functions/is-editing.qwik.mjs";
14
14
  import { isPreviewing } from "./functions/is-previewing.qwik.mjs";
15
15
  import { createRegisterComponentMessage } from "./functions/register-component.qwik.mjs";
16
- import { register } from "./functions/register.qwik.mjs";
16
+ import { register, registerAction } from "./functions/register.qwik.mjs";
17
17
  import { setEditorSettings } from "./functions/set-editor-settings.qwik.mjs";
18
18
  import { getBuilderSearchParams } from "./functions/get-builder-search-params/index.qwik.mjs";
19
19
  import { track } from "./functions/track/index.qwik.mjs";
@@ -41,6 +41,7 @@ export {
41
41
  isEditing,
42
42
  isPreviewing,
43
43
  register,
44
+ registerAction,
44
45
  setClientUserAttributes,
45
46
  setEditorSettings,
46
47
  subscribeToEditor,
@@ -36,13 +36,13 @@ const onSubmit = function onSubmit2(props, state, formRef, event) {
36
36
  const headers = props.customHeaders || {};
37
37
  let body;
38
38
  const formData = new FormData(el);
39
- const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
39
+ const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).filter((el2) => !!el2.name && (el2.type !== "radio" || el2.checked)).map((el2) => {
40
40
  let value;
41
41
  const key = el2.name;
42
42
  if (el2 instanceof HTMLInputElement) {
43
43
  if (el2.type === "radio") {
44
44
  if (el2.checked) {
45
- value = el2.name;
45
+ value = el2.value;
46
46
  return {
47
47
  key,
48
48
  value
@@ -34,13 +34,13 @@ const onSubmit = function onSubmit2(props, state, formRef, event) {
34
34
  const headers = props.customHeaders || {};
35
35
  let body;
36
36
  const formData = new FormData(el);
37
- const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).map((el2) => {
37
+ const formPairs = Array.from(el.querySelectorAll("input,select,textarea")).filter((el2) => !!el2.name).filter((el2) => !!el2.name && (el2.type !== "radio" || el2.checked)).map((el2) => {
38
38
  let value;
39
39
  const key = el2.name;
40
40
  if (el2 instanceof HTMLInputElement) {
41
41
  if (el2.type === "radio") {
42
42
  if (el2.checked) {
43
- value = el2.name;
43
+ value = el2.value;
44
44
  return {
45
45
  key,
46
46
  value
@@ -99,13 +99,15 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
99
99
  const runHttpRequests = function runHttpRequests2(props, state, showContentProps, elementRef) {
100
100
  var _a, _b;
101
101
  const requests = ((_b = (_a = props.builderContextSignal.content) == null ? void 0 : _a.data) == null ? void 0 : _b.httpRequests) ?? {};
102
- Object.entries(requests).forEach(([key, url]) => {
103
- if (!url)
102
+ Object.entries(requests).forEach(([key, httpRequest]) => {
103
+ if (!httpRequest)
104
104
  return;
105
+ const isCoreRequest = typeof httpRequest === "object" && httpRequest["@type"] === "@builder.io/core:Request";
105
106
  if (state.httpReqsPending[key])
106
107
  return;
107
108
  if (state.httpReqsData[key] && !isEditing.isEditing())
108
109
  return;
110
+ const url = isCoreRequest ? httpRequest.request.url : httpRequest;
109
111
  state.httpReqsPending[key] = true;
110
112
  const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate.evaluate({
111
113
  code: group,
@@ -114,14 +116,27 @@ const runHttpRequests = function runHttpRequests2(props, state, showContentProps
114
116
  rootState: props.builderContextSignal.rootState,
115
117
  rootSetState: props.builderContextSignal.rootSetState
116
118
  })));
117
- logFetch.logFetch(evaluatedUrl);
118
- fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
119
+ const fetchRequestObj = isCoreRequest ? {
120
+ url: evaluatedUrl,
121
+ method: httpRequest.request.method,
122
+ headers: httpRequest.request.headers,
123
+ body: httpRequest.request.body
124
+ } : {
125
+ url: evaluatedUrl,
126
+ method: "GET"
127
+ };
128
+ logFetch.logFetch(JSON.stringify(fetchRequestObj));
129
+ fetch(fetchRequestObj.url, {
130
+ method: fetchRequestObj.method,
131
+ headers: fetchRequestObj.headers,
132
+ body: fetchRequestObj.body
133
+ }).then((response) => response.json()).then((json) => {
119
134
  mergeNewRootState(props, state, showContentProps, elementRef, {
120
135
  [key]: json
121
136
  });
122
137
  state.httpReqsData[key] = true;
123
138
  }).catch((err) => {
124
- console.error("error fetching dynamic data", url, err);
139
+ console.error("error fetching dynamic data", JSON.stringify(httpRequest), err);
125
140
  }).finally(() => {
126
141
  state.httpReqsPending[key] = false;
127
142
  });
@@ -97,13 +97,15 @@ const onClick = function onClick2(props, state, showContentProps, elementRef, ev
97
97
  const runHttpRequests = function runHttpRequests2(props, state, showContentProps, elementRef) {
98
98
  var _a, _b;
99
99
  const requests = ((_b = (_a = props.builderContextSignal.content) == null ? void 0 : _a.data) == null ? void 0 : _b.httpRequests) ?? {};
100
- Object.entries(requests).forEach(([key, url]) => {
101
- if (!url)
100
+ Object.entries(requests).forEach(([key, httpRequest]) => {
101
+ if (!httpRequest)
102
102
  return;
103
+ const isCoreRequest = typeof httpRequest === "object" && httpRequest["@type"] === "@builder.io/core:Request";
103
104
  if (state.httpReqsPending[key])
104
105
  return;
105
106
  if (state.httpReqsData[key] && !isEditing())
106
107
  return;
108
+ const url = isCoreRequest ? httpRequest.request.url : httpRequest;
107
109
  state.httpReqsPending[key] = true;
108
110
  const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
109
111
  code: group,
@@ -112,14 +114,27 @@ const runHttpRequests = function runHttpRequests2(props, state, showContentProps
112
114
  rootState: props.builderContextSignal.rootState,
113
115
  rootSetState: props.builderContextSignal.rootSetState
114
116
  })));
115
- logFetch(evaluatedUrl);
116
- fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
117
+ const fetchRequestObj = isCoreRequest ? {
118
+ url: evaluatedUrl,
119
+ method: httpRequest.request.method,
120
+ headers: httpRequest.request.headers,
121
+ body: httpRequest.request.body
122
+ } : {
123
+ url: evaluatedUrl,
124
+ method: "GET"
125
+ };
126
+ logFetch(JSON.stringify(fetchRequestObj));
127
+ fetch(fetchRequestObj.url, {
128
+ method: fetchRequestObj.method,
129
+ headers: fetchRequestObj.headers,
130
+ body: fetchRequestObj.body
131
+ }).then((response) => response.json()).then((json) => {
117
132
  mergeNewRootState(props, state, showContentProps, elementRef, {
118
133
  [key]: json
119
134
  });
120
135
  state.httpReqsData[key] = true;
121
136
  }).catch((err) => {
122
- console.error("error fetching dynamic data", url, err);
137
+ console.error("error fetching dynamic data", JSON.stringify(httpRequest), err);
123
138
  }).finally(() => {
124
139
  state.httpReqsPending[key] = false;
125
140
  });
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.19.3";
3
+ const SDK_VERSION = "0.20.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.19.3";
1
+ const SDK_VERSION = "0.20.1";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -27,4 +27,17 @@ function register(type, info) {
27
27
  }
28
28
  }
29
29
  }
30
+ function registerAction(action) {
31
+ var _a;
32
+ if (isBrowser.isBrowser()) {
33
+ const actionClone = JSON.parse(JSON.stringify(action));
34
+ if (action.action)
35
+ actionClone.action = action.action.toString();
36
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
37
+ type: "builder.registerAction",
38
+ data: actionClone
39
+ }, "*");
40
+ }
41
+ }
30
42
  exports.register = register;
43
+ exports.registerAction = registerAction;
@@ -25,6 +25,19 @@ function register(type, info) {
25
25
  }
26
26
  }
27
27
  }
28
+ function registerAction(action) {
29
+ var _a;
30
+ if (isBrowser()) {
31
+ const actionClone = JSON.parse(JSON.stringify(action));
32
+ if (action.action)
33
+ actionClone.action = action.action.toString();
34
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
35
+ type: "builder.registerAction",
36
+ data: actionClone
37
+ }, "*");
38
+ }
39
+ }
28
40
  export {
29
- register
41
+ register,
42
+ registerAction
30
43
  };
@@ -38,6 +38,7 @@ exports.isEditing = isEditing.isEditing;
38
38
  exports.isPreviewing = isPreviewing.isPreviewing;
39
39
  exports.createRegisterComponentMessage = registerComponent.createRegisterComponentMessage;
40
40
  exports.register = register.register;
41
+ exports.registerAction = register.registerAction;
41
42
  exports.setEditorSettings = setEditorSettings.setEditorSettings;
42
43
  exports.getBuilderSearchParams = index.getBuilderSearchParams;
43
44
  exports.track = index$1.track;
@@ -13,7 +13,7 @@ import { setClientUserAttributes } from "./helpers/user-attributes.qwik.mjs";
13
13
  import { isEditing } from "./functions/is-editing.qwik.mjs";
14
14
  import { isPreviewing } from "./functions/is-previewing.qwik.mjs";
15
15
  import { createRegisterComponentMessage } from "./functions/register-component.qwik.mjs";
16
- import { register } from "./functions/register.qwik.mjs";
16
+ import { register, registerAction } from "./functions/register.qwik.mjs";
17
17
  import { setEditorSettings } from "./functions/set-editor-settings.qwik.mjs";
18
18
  import { getBuilderSearchParams } from "./functions/get-builder-search-params/index.qwik.mjs";
19
19
  import { track } from "./functions/track/index.qwik.mjs";
@@ -41,6 +41,7 @@ export {
41
41
  isEditing,
42
42
  isPreviewing,
43
43
  register,
44
+ registerAction,
44
45
  setClientUserAttributes,
45
46
  setEditorSettings,
46
47
  subscribeToEditor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.19.3",
3
+ "version": "0.20.1",
4
4
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/qwik",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.19.3";
1
+ export declare const SDK_VERSION = "0.20.1";
@@ -1,5 +1,22 @@
1
1
  import type { BuilderBlock } from '../types/builder-block';
2
2
  import type { DeepPartial } from '../types/deep-partial';
3
+ import type { Input } from '../types/input';
4
+ export interface Action {
5
+ name: string;
6
+ inputs?: readonly Input[];
7
+ returnType?: Input;
8
+ action: (options: Record<string, any>) => string;
9
+ /**
10
+ * Is an action for expression (e.g. calculating a binding like a formula
11
+ * to fill a value based on locale) or a function (e.g. something to trigger
12
+ * on an event like add to cart) or either (e.g. a custom code block)
13
+ */
14
+ kind: 'expression' | 'function' | 'any';
15
+ /**
16
+ * Globally unique ID for an action, e.g. "@builder.io:setState"
17
+ */
18
+ id: string;
19
+ }
3
20
  export interface InsertMenuItem {
4
21
  name: string;
5
22
  icon?: string;
@@ -14,3 +31,4 @@ export interface InsertMenuConfig {
14
31
  }
15
32
  export declare function register(type: 'insertMenu', info: InsertMenuConfig): void;
16
33
  export declare function register(type: string, info: any): void;
34
+ export declare function registerAction(action: Action): void;
@@ -25,7 +25,7 @@ export type { ComponentInfo } from './types/components';
25
25
  export { isEditing } from './functions/is-editing';
26
26
  export { isPreviewing } from './functions/is-previewing';
27
27
  export { createRegisterComponentMessage } from './functions/register-component';
28
- export { register } from './functions/register';
28
+ export { register, registerAction } from './functions/register';
29
29
  export type { InsertMenuConfig, InsertMenuItem } from './functions/register';
30
30
  export { setEditorSettings } from './functions/set-editor-settings';
31
31
  export type { Settings } from './functions/set-editor-settings';