@builder.io/sdk-svelte 2.0.28 → 2.0.30

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 (43) hide show
  1. package/lib/browser/blocks/accordion/accordion.svelte +9 -7
  2. package/lib/browser/blocks/columns/columns.svelte +1 -1
  3. package/lib/browser/blocks/form/form/form.svelte +5 -2
  4. package/lib/browser/blocks/tabs/tabs.svelte +2 -2
  5. package/lib/browser/components/blocks/blocks-wrapper.svelte +11 -4
  6. package/lib/browser/components/content/components/enable-editor.svelte +2 -0
  7. package/lib/browser/constants/sdk-version.d.ts +1 -1
  8. package/lib/browser/constants/sdk-version.js +1 -1
  9. package/lib/browser/functions/log-fetch.d.ts +1 -0
  10. package/lib/browser/functions/log-fetch.js +8 -0
  11. package/lib/browser/functions/track/index.js +4 -1
  12. package/lib/edge/blocks/accordion/accordion.svelte +9 -7
  13. package/lib/edge/blocks/columns/columns.svelte +1 -1
  14. package/lib/edge/blocks/form/form/form.svelte +5 -2
  15. package/lib/edge/blocks/tabs/tabs.svelte +2 -2
  16. package/lib/edge/components/blocks/blocks-wrapper.svelte +11 -4
  17. package/lib/edge/components/content/components/enable-editor.svelte +2 -0
  18. package/lib/edge/constants/sdk-version.d.ts +1 -1
  19. package/lib/edge/constants/sdk-version.js +1 -1
  20. package/lib/edge/functions/log-fetch.d.ts +1 -0
  21. package/lib/edge/functions/log-fetch.js +8 -0
  22. package/lib/edge/functions/track/index.js +4 -1
  23. package/lib/node/blocks/accordion/accordion.svelte +9 -7
  24. package/lib/node/blocks/columns/columns.svelte +1 -1
  25. package/lib/node/blocks/form/form/form.svelte +5 -2
  26. package/lib/node/blocks/tabs/tabs.svelte +2 -2
  27. package/lib/node/components/blocks/blocks-wrapper.svelte +11 -4
  28. package/lib/node/components/content/components/enable-editor.svelte +2 -0
  29. package/lib/node/constants/sdk-version.d.ts +1 -1
  30. package/lib/node/constants/sdk-version.js +1 -1
  31. package/lib/node/functions/log-fetch.d.ts +1 -0
  32. package/lib/node/functions/log-fetch.js +8 -0
  33. package/lib/node/functions/track/index.js +4 -1
  34. package/package.json +1 -1
  35. package/src/blocks/accordion/accordion.svelte +9 -7
  36. package/src/blocks/columns/columns.svelte +1 -1
  37. package/src/blocks/form/form/form.svelte +10 -8
  38. package/src/blocks/tabs/tabs.svelte +2 -2
  39. package/src/components/blocks/blocks-wrapper.svelte +11 -4
  40. package/src/components/content/components/enable-editor.svelte +2 -0
  41. package/src/constants/sdk-version.ts +1 -1
  42. package/src/functions/log-fetch.ts +8 -0
  43. package/src/functions/track/index.ts +4 -1
@@ -117,13 +117,15 @@ let open = [];
117
117
  <div
118
118
  style={stringifyStyles({
119
119
  ...accordionTitleStyles(),
120
- width: grid ? gridRowWidth : undefined,
121
- ...{
122
- order:
123
- openGridItemOrder() !== null
124
- ? convertOrderNumberToString(index)
125
- : convertOrderNumberToString(index + 1),
126
- },
120
+ ...(grid && {
121
+ width: gridRowWidth,
122
+ ...{
123
+ order:
124
+ openGridItemOrder() !== null
125
+ ? convertOrderNumberToString(index)
126
+ : convertOrderNumberToString(index + 1),
127
+ },
128
+ }),
127
129
  })}
128
130
  class={getAccordionTitleClassName(index)}
129
131
  data-index={index}
@@ -168,7 +168,7 @@ $: flexDir = () => {
168
168
  actionAttributes={{}}
169
169
  attributes={getAttributes(column, index)}
170
170
  ><Blocks
171
- path={`component.options.columns.${index}.blocks`}
171
+ path={`columns.${index}.blocks`}
172
172
  parent={builderBlock.id}
173
173
  styleProp={{
174
174
  flexGrow: "1",
@@ -10,6 +10,7 @@ import { get } from "../../../functions/get";
10
10
  import { isEditing } from "../../../functions/is-editing";
11
11
  import { set } from "../../../functions/set";
12
12
  import { filterAttrs } from "../../helpers";
13
+ import { logFetch } from "../../../functions/log-fetch";
13
14
  import { setAttrs } from "../../helpers";
14
15
  export let builderContext;
15
16
  export let previewState = undefined;
@@ -148,9 +149,11 @@ function onSubmit(event) {
148
149
  }
149
150
  formState = "sending";
150
151
  const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${$builderContext.apiKey}&to=${btoa(sendSubmissionsToEmail || "")}&name=${encodeURIComponent(name || "")}`;
151
- fetch(sendSubmissionsTo === "email"
152
+ const url = sendSubmissionsTo === "email"
152
153
  ? formUrl
153
- : action /* TODO: throw error if no action URL */, {
154
+ : action; /* TODO: throw error if no action URL */
155
+ logFetch(url);
156
+ fetch(url, {
154
157
  body,
155
158
  headers,
156
159
  method: method || "post",
@@ -55,7 +55,7 @@ let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
55
55
  }}
56
56
  ><Blocks
57
57
  parent={builderBlock.id}
58
- path={`component.options.tabs.${index}.label`}
58
+ path={`tabs.${index}.label`}
59
59
  blocks={tab.label}
60
60
  context={builderContext}
61
61
  registeredComponents={builderComponents}
@@ -68,7 +68,7 @@ let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
68
68
  <div>
69
69
  <Blocks
70
70
  parent={builderBlock.id}
71
- path={`component.options.tabs.${activeTab}.content`}
71
+ path={`tabs.${activeTab}.content`}
72
72
  blocks={activeTabContent(activeTab)}
73
73
  context={builderContext}
74
74
  registeredComponents={builderComponents}
@@ -4,8 +4,8 @@
4
4
  import { isEditing } from "../../functions/is-editing";
5
5
  export let blocks;
6
6
  export let classNameProp = undefined;
7
- export let parent;
8
7
  export let path;
8
+ export let parent;
9
9
  export let styleProp;
10
10
  export let BlocksWrapperProps;
11
11
  export let BlocksWrapper;
@@ -25,7 +25,7 @@ function onClick() {
25
25
  type: "builder.clickEmptyBlocks",
26
26
  data: {
27
27
  parentElementId: parent,
28
- dataPath: path,
28
+ dataPath: dataPath(),
29
29
  },
30
30
  }, "*");
31
31
  }
@@ -36,7 +36,7 @@ function onMouseEnter() {
36
36
  type: "builder.hoverEmptyBlocks",
37
37
  data: {
38
38
  parentElementId: parent,
39
- dataPath: path,
39
+ dataPath: dataPath(),
40
40
  },
41
41
  }, "*");
42
42
  }
@@ -46,6 +46,13 @@ $: className = () => {
46
46
  .filter(Boolean)
47
47
  .join(" ");
48
48
  };
49
+ $: dataPath = () => {
50
+ if (!path) {
51
+ return undefined;
52
+ }
53
+ const pathPrefix = "component.options.";
54
+ return path.startsWith(pathPrefix) ? path : `${pathPrefix}${path || ""}`;
55
+ };
49
56
  let blocksWrapperRef;
50
57
  onMount(() => { });
51
58
  </script>
@@ -55,7 +62,7 @@ onMount(() => { });
55
62
  style={stringifyStyles(styleProp)}
56
63
  bind:this={blocksWrapperRef}
57
64
  class={className() + " svelte-element"}
58
- builder-path={path}
65
+ builder-path={dataPath()}
59
66
  builder-parent-id={parent}
60
67
  {...{}}
61
68
  on:click={(event) => {
@@ -8,6 +8,7 @@ import { fetchOneEntry } from "../../../functions/get-content/index";
8
8
  import { isBrowser } from "../../../functions/is-browser";
9
9
  import { isEditing } from "../../../functions/is-editing";
10
10
  import { isPreviewing } from "../../../functions/is-previewing";
11
+ import { logFetch } from "../../../functions/log-fetch";
11
12
  import { createRegisterComponentMessage } from "../../../functions/register-component";
12
13
  import { _track } from "../../../functions/track/index";
13
14
  import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
@@ -127,6 +128,7 @@ function runHttpRequests() {
127
128
  rootState: $builderContextSignal.rootState,
128
129
  rootSetState: $builderContextSignal.rootSetState,
129
130
  })));
131
+ logFetch(evaluatedUrl);
130
132
  fetch(evaluatedUrl)
131
133
  .then((response) => response.json())
132
134
  .then((json) => {
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.28";
1
+ export declare const SDK_VERSION = "2.0.30";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.28";
1
+ export const SDK_VERSION = "2.0.30";
@@ -0,0 +1 @@
1
+ export declare function logFetch(url: string): void;
@@ -0,0 +1,8 @@
1
+ import { logger } from '../helpers/logger';
2
+ export function logFetch(url) {
3
+ if (typeof process !== 'undefined' && process.env?.DEBUG) {
4
+ if (String(process.env.DEBUG) == 'true') {
5
+ logger.log(url);
6
+ }
7
+ }
8
+ }
@@ -5,6 +5,7 @@ import { getSessionId } from '../../helpers/sessionId';
5
5
  import { getVisitorId } from '../../helpers/visitorId';
6
6
  import { isBrowser } from '../is-browser';
7
7
  import { isEditing } from '../is-editing';
8
+ import { logFetch } from '../log-fetch';
8
9
  import { getUserAttributes } from './helpers';
9
10
  const getTrackingEventData = async ({ canTrack }) => {
10
11
  if (!canTrack) {
@@ -54,7 +55,9 @@ export async function _track({ apiHost, ...eventProps }) {
54
55
  return;
55
56
  }
56
57
  const baseUrl = apiHost || 'https://cdn.builder.io';
57
- return fetch(`${baseUrl}/api/v1/track`, {
58
+ const url = `${baseUrl}/api/v1/track`;
59
+ logFetch(url);
60
+ return fetch(url, {
58
61
  method: 'POST',
59
62
  body: JSON.stringify({
60
63
  events: [await createEvent(eventProps)]
@@ -117,13 +117,15 @@ let open = [];
117
117
  <div
118
118
  style={stringifyStyles({
119
119
  ...accordionTitleStyles(),
120
- width: grid ? gridRowWidth : undefined,
121
- ...{
122
- order:
123
- openGridItemOrder() !== null
124
- ? convertOrderNumberToString(index)
125
- : convertOrderNumberToString(index + 1),
126
- },
120
+ ...(grid && {
121
+ width: gridRowWidth,
122
+ ...{
123
+ order:
124
+ openGridItemOrder() !== null
125
+ ? convertOrderNumberToString(index)
126
+ : convertOrderNumberToString(index + 1),
127
+ },
128
+ }),
127
129
  })}
128
130
  class={getAccordionTitleClassName(index)}
129
131
  data-index={index}
@@ -168,7 +168,7 @@ $: flexDir = () => {
168
168
  actionAttributes={{}}
169
169
  attributes={getAttributes(column, index)}
170
170
  ><Blocks
171
- path={`component.options.columns.${index}.blocks`}
171
+ path={`columns.${index}.blocks`}
172
172
  parent={builderBlock.id}
173
173
  styleProp={{
174
174
  flexGrow: "1",
@@ -10,6 +10,7 @@ import { get } from "../../../functions/get";
10
10
  import { isEditing } from "../../../functions/is-editing";
11
11
  import { set } from "../../../functions/set";
12
12
  import { filterAttrs } from "../../helpers";
13
+ import { logFetch } from "../../../functions/log-fetch";
13
14
  import { setAttrs } from "../../helpers";
14
15
  export let builderContext;
15
16
  export let previewState = undefined;
@@ -148,9 +149,11 @@ function onSubmit(event) {
148
149
  }
149
150
  formState = "sending";
150
151
  const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${$builderContext.apiKey}&to=${btoa(sendSubmissionsToEmail || "")}&name=${encodeURIComponent(name || "")}`;
151
- fetch(sendSubmissionsTo === "email"
152
+ const url = sendSubmissionsTo === "email"
152
153
  ? formUrl
153
- : action /* TODO: throw error if no action URL */, {
154
+ : action; /* TODO: throw error if no action URL */
155
+ logFetch(url);
156
+ fetch(url, {
154
157
  body,
155
158
  headers,
156
159
  method: method || "post",
@@ -55,7 +55,7 @@ let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
55
55
  }}
56
56
  ><Blocks
57
57
  parent={builderBlock.id}
58
- path={`component.options.tabs.${index}.label`}
58
+ path={`tabs.${index}.label`}
59
59
  blocks={tab.label}
60
60
  context={builderContext}
61
61
  registeredComponents={builderComponents}
@@ -68,7 +68,7 @@ let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
68
68
  <div>
69
69
  <Blocks
70
70
  parent={builderBlock.id}
71
- path={`component.options.tabs.${activeTab}.content`}
71
+ path={`tabs.${activeTab}.content`}
72
72
  blocks={activeTabContent(activeTab)}
73
73
  context={builderContext}
74
74
  registeredComponents={builderComponents}
@@ -4,8 +4,8 @@
4
4
  import { isEditing } from "../../functions/is-editing";
5
5
  export let blocks;
6
6
  export let classNameProp = undefined;
7
- export let parent;
8
7
  export let path;
8
+ export let parent;
9
9
  export let styleProp;
10
10
  export let BlocksWrapperProps;
11
11
  export let BlocksWrapper;
@@ -25,7 +25,7 @@ function onClick() {
25
25
  type: "builder.clickEmptyBlocks",
26
26
  data: {
27
27
  parentElementId: parent,
28
- dataPath: path,
28
+ dataPath: dataPath(),
29
29
  },
30
30
  }, "*");
31
31
  }
@@ -36,7 +36,7 @@ function onMouseEnter() {
36
36
  type: "builder.hoverEmptyBlocks",
37
37
  data: {
38
38
  parentElementId: parent,
39
- dataPath: path,
39
+ dataPath: dataPath(),
40
40
  },
41
41
  }, "*");
42
42
  }
@@ -46,6 +46,13 @@ $: className = () => {
46
46
  .filter(Boolean)
47
47
  .join(" ");
48
48
  };
49
+ $: dataPath = () => {
50
+ if (!path) {
51
+ return undefined;
52
+ }
53
+ const pathPrefix = "component.options.";
54
+ return path.startsWith(pathPrefix) ? path : `${pathPrefix}${path || ""}`;
55
+ };
49
56
  let blocksWrapperRef;
50
57
  onMount(() => { });
51
58
  </script>
@@ -55,7 +62,7 @@ onMount(() => { });
55
62
  style={stringifyStyles(styleProp)}
56
63
  bind:this={blocksWrapperRef}
57
64
  class={className() + " svelte-element"}
58
- builder-path={path}
65
+ builder-path={dataPath()}
59
66
  builder-parent-id={parent}
60
67
  {...{}}
61
68
  on:click={(event) => {
@@ -8,6 +8,7 @@ import { fetchOneEntry } from "../../../functions/get-content/index";
8
8
  import { isBrowser } from "../../../functions/is-browser";
9
9
  import { isEditing } from "../../../functions/is-editing";
10
10
  import { isPreviewing } from "../../../functions/is-previewing";
11
+ import { logFetch } from "../../../functions/log-fetch";
11
12
  import { createRegisterComponentMessage } from "../../../functions/register-component";
12
13
  import { _track } from "../../../functions/track/index";
13
14
  import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
@@ -127,6 +128,7 @@ function runHttpRequests() {
127
128
  rootState: $builderContextSignal.rootState,
128
129
  rootSetState: $builderContextSignal.rootSetState,
129
130
  })));
131
+ logFetch(evaluatedUrl);
130
132
  fetch(evaluatedUrl)
131
133
  .then((response) => response.json())
132
134
  .then((json) => {
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.28";
1
+ export declare const SDK_VERSION = "2.0.30";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.28";
1
+ export const SDK_VERSION = "2.0.30";
@@ -0,0 +1 @@
1
+ export declare function logFetch(url: string): void;
@@ -0,0 +1,8 @@
1
+ import { logger } from '../helpers/logger';
2
+ export function logFetch(url) {
3
+ if (typeof process !== 'undefined' && process.env?.DEBUG) {
4
+ if (String(process.env.DEBUG) == 'true') {
5
+ logger.log(url);
6
+ }
7
+ }
8
+ }
@@ -5,6 +5,7 @@ import { getSessionId } from '../../helpers/sessionId';
5
5
  import { getVisitorId } from '../../helpers/visitorId';
6
6
  import { isBrowser } from '../is-browser';
7
7
  import { isEditing } from '../is-editing';
8
+ import { logFetch } from '../log-fetch';
8
9
  import { getUserAttributes } from './helpers';
9
10
  const getTrackingEventData = async ({ canTrack }) => {
10
11
  if (!canTrack) {
@@ -54,7 +55,9 @@ export async function _track({ apiHost, ...eventProps }) {
54
55
  return;
55
56
  }
56
57
  const baseUrl = apiHost || 'https://cdn.builder.io';
57
- return fetch(`${baseUrl}/api/v1/track`, {
58
+ const url = `${baseUrl}/api/v1/track`;
59
+ logFetch(url);
60
+ return fetch(url, {
58
61
  method: 'POST',
59
62
  body: JSON.stringify({
60
63
  events: [await createEvent(eventProps)]
@@ -117,13 +117,15 @@ let open = [];
117
117
  <div
118
118
  style={stringifyStyles({
119
119
  ...accordionTitleStyles(),
120
- width: grid ? gridRowWidth : undefined,
121
- ...{
122
- order:
123
- openGridItemOrder() !== null
124
- ? convertOrderNumberToString(index)
125
- : convertOrderNumberToString(index + 1),
126
- },
120
+ ...(grid && {
121
+ width: gridRowWidth,
122
+ ...{
123
+ order:
124
+ openGridItemOrder() !== null
125
+ ? convertOrderNumberToString(index)
126
+ : convertOrderNumberToString(index + 1),
127
+ },
128
+ }),
127
129
  })}
128
130
  class={getAccordionTitleClassName(index)}
129
131
  data-index={index}
@@ -168,7 +168,7 @@ $: flexDir = () => {
168
168
  actionAttributes={{}}
169
169
  attributes={getAttributes(column, index)}
170
170
  ><Blocks
171
- path={`component.options.columns.${index}.blocks`}
171
+ path={`columns.${index}.blocks`}
172
172
  parent={builderBlock.id}
173
173
  styleProp={{
174
174
  flexGrow: "1",
@@ -10,6 +10,7 @@ import { get } from "../../../functions/get";
10
10
  import { isEditing } from "../../../functions/is-editing";
11
11
  import { set } from "../../../functions/set";
12
12
  import { filterAttrs } from "../../helpers";
13
+ import { logFetch } from "../../../functions/log-fetch";
13
14
  import { setAttrs } from "../../helpers";
14
15
  export let builderContext;
15
16
  export let previewState = undefined;
@@ -148,9 +149,11 @@ function onSubmit(event) {
148
149
  }
149
150
  formState = "sending";
150
151
  const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${$builderContext.apiKey}&to=${btoa(sendSubmissionsToEmail || "")}&name=${encodeURIComponent(name || "")}`;
151
- fetch(sendSubmissionsTo === "email"
152
+ const url = sendSubmissionsTo === "email"
152
153
  ? formUrl
153
- : action /* TODO: throw error if no action URL */, {
154
+ : action; /* TODO: throw error if no action URL */
155
+ logFetch(url);
156
+ fetch(url, {
154
157
  body,
155
158
  headers,
156
159
  method: method || "post",
@@ -55,7 +55,7 @@ let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
55
55
  }}
56
56
  ><Blocks
57
57
  parent={builderBlock.id}
58
- path={`component.options.tabs.${index}.label`}
58
+ path={`tabs.${index}.label`}
59
59
  blocks={tab.label}
60
60
  context={builderContext}
61
61
  registeredComponents={builderComponents}
@@ -68,7 +68,7 @@ let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
68
68
  <div>
69
69
  <Blocks
70
70
  parent={builderBlock.id}
71
- path={`component.options.tabs.${activeTab}.content`}
71
+ path={`tabs.${activeTab}.content`}
72
72
  blocks={activeTabContent(activeTab)}
73
73
  context={builderContext}
74
74
  registeredComponents={builderComponents}
@@ -4,8 +4,8 @@
4
4
  import { isEditing } from "../../functions/is-editing";
5
5
  export let blocks;
6
6
  export let classNameProp = undefined;
7
- export let parent;
8
7
  export let path;
8
+ export let parent;
9
9
  export let styleProp;
10
10
  export let BlocksWrapperProps;
11
11
  export let BlocksWrapper;
@@ -25,7 +25,7 @@ function onClick() {
25
25
  type: "builder.clickEmptyBlocks",
26
26
  data: {
27
27
  parentElementId: parent,
28
- dataPath: path,
28
+ dataPath: dataPath(),
29
29
  },
30
30
  }, "*");
31
31
  }
@@ -36,7 +36,7 @@ function onMouseEnter() {
36
36
  type: "builder.hoverEmptyBlocks",
37
37
  data: {
38
38
  parentElementId: parent,
39
- dataPath: path,
39
+ dataPath: dataPath(),
40
40
  },
41
41
  }, "*");
42
42
  }
@@ -46,6 +46,13 @@ $: className = () => {
46
46
  .filter(Boolean)
47
47
  .join(" ");
48
48
  };
49
+ $: dataPath = () => {
50
+ if (!path) {
51
+ return undefined;
52
+ }
53
+ const pathPrefix = "component.options.";
54
+ return path.startsWith(pathPrefix) ? path : `${pathPrefix}${path || ""}`;
55
+ };
49
56
  let blocksWrapperRef;
50
57
  onMount(() => { });
51
58
  </script>
@@ -55,7 +62,7 @@ onMount(() => { });
55
62
  style={stringifyStyles(styleProp)}
56
63
  bind:this={blocksWrapperRef}
57
64
  class={className() + " svelte-element"}
58
- builder-path={path}
65
+ builder-path={dataPath()}
59
66
  builder-parent-id={parent}
60
67
  {...{}}
61
68
  on:click={(event) => {
@@ -8,6 +8,7 @@ import { fetchOneEntry } from "../../../functions/get-content/index";
8
8
  import { isBrowser } from "../../../functions/is-browser";
9
9
  import { isEditing } from "../../../functions/is-editing";
10
10
  import { isPreviewing } from "../../../functions/is-previewing";
11
+ import { logFetch } from "../../../functions/log-fetch";
11
12
  import { createRegisterComponentMessage } from "../../../functions/register-component";
12
13
  import { _track } from "../../../functions/track/index";
13
14
  import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
@@ -127,6 +128,7 @@ function runHttpRequests() {
127
128
  rootState: $builderContextSignal.rootState,
128
129
  rootSetState: $builderContextSignal.rootSetState,
129
130
  })));
131
+ logFetch(evaluatedUrl);
130
132
  fetch(evaluatedUrl)
131
133
  .then((response) => response.json())
132
134
  .then((json) => {
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.28";
1
+ export declare const SDK_VERSION = "2.0.30";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.28";
1
+ export const SDK_VERSION = "2.0.30";
@@ -0,0 +1 @@
1
+ export declare function logFetch(url: string): void;
@@ -0,0 +1,8 @@
1
+ import { logger } from '../helpers/logger';
2
+ export function logFetch(url) {
3
+ if (typeof process !== 'undefined' && process.env?.DEBUG) {
4
+ if (String(process.env.DEBUG) == 'true') {
5
+ logger.log(url);
6
+ }
7
+ }
8
+ }
@@ -5,6 +5,7 @@ import { getSessionId } from '../../helpers/sessionId';
5
5
  import { getVisitorId } from '../../helpers/visitorId';
6
6
  import { isBrowser } from '../is-browser';
7
7
  import { isEditing } from '../is-editing';
8
+ import { logFetch } from '../log-fetch';
8
9
  import { getUserAttributes } from './helpers';
9
10
  const getTrackingEventData = async ({ canTrack }) => {
10
11
  if (!canTrack) {
@@ -54,7 +55,9 @@ export async function _track({ apiHost, ...eventProps }) {
54
55
  return;
55
56
  }
56
57
  const baseUrl = apiHost || 'https://cdn.builder.io';
57
- return fetch(`${baseUrl}/api/v1/track`, {
58
+ const url = `${baseUrl}/api/v1/track`;
59
+ logFetch(url);
60
+ return fetch(url, {
58
61
  method: 'POST',
59
62
  body: JSON.stringify({
60
63
  events: [await createEvent(eventProps)]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "2.0.28",
4
+ "version": "2.0.30",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -154,13 +154,15 @@
154
154
  <div
155
155
  style={stringifyStyles({
156
156
  ...accordionTitleStyles(),
157
- width: grid ? gridRowWidth : undefined,
158
- ...{
159
- order:
160
- openGridItemOrder() !== null
161
- ? convertOrderNumberToString(index)
162
- : convertOrderNumberToString(index + 1),
163
- },
157
+ ...(grid && {
158
+ width: gridRowWidth,
159
+ ...{
160
+ order:
161
+ openGridItemOrder() !== null
162
+ ? convertOrderNumberToString(index)
163
+ : convertOrderNumberToString(index + 1),
164
+ },
165
+ }),
164
166
  })}
165
167
  class={getAccordionTitleClassName(index)}
166
168
  data-index={index}
@@ -192,7 +192,7 @@
192
192
  actionAttributes={{}}
193
193
  attributes={getAttributes(column, index)}
194
194
  ><Blocks
195
- path={`component.options.columns.${index}.blocks`}
195
+ path={`columns.${index}.blocks`}
196
196
  parent={builderBlock.id}
197
197
  styleProp={{
198
198
  flexGrow: "1",
@@ -49,6 +49,7 @@
49
49
  } from "../../../types/builder-props";
50
50
  import type { Dictionary } from "../../../types/typescript";
51
51
  import { filterAttrs } from "../../helpers";
52
+ import { logFetch } from "../../../functions/log-fetch";
52
53
  import { setAttrs } from "../../helpers";
53
54
 
54
55
  export let builderContext: FormProps["builderContext"];
@@ -195,16 +196,17 @@
195
196
  }/api/v1/form-submit?apiKey=${$builderContext.apiKey}&to=${btoa(
196
197
  sendSubmissionsToEmail || ""
197
198
  )}&name=${encodeURIComponent(name || "")}`;
198
- fetch(
199
+ const url =
199
200
  sendSubmissionsTo === "email"
200
201
  ? formUrl
201
- : action! /* TODO: throw error if no action URL */,
202
- {
203
- body,
204
- headers,
205
- method: method || "post",
206
- }
207
- ).then(
202
+ : action!; /* TODO: throw error if no action URL */
203
+
204
+ logFetch(url);
205
+ fetch(url, {
206
+ body,
207
+ headers,
208
+ method: method || "post",
209
+ }).then(
208
210
  async (res) => {
209
211
  let body;
210
212
  const contentType = res.headers.get("content-type");
@@ -61,7 +61,7 @@
61
61
  }}
62
62
  ><Blocks
63
63
  parent={builderBlock.id}
64
- path={`component.options.tabs.${index}.label`}
64
+ path={`tabs.${index}.label`}
65
65
  blocks={tab.label}
66
66
  context={builderContext}
67
67
  registeredComponents={builderComponents}
@@ -74,7 +74,7 @@
74
74
  <div>
75
75
  <Blocks
76
76
  parent={builderBlock.id}
77
- path={`component.options.tabs.${activeTab}.content`}
77
+ path={`tabs.${activeTab}.content`}
78
78
  blocks={activeTabContent(activeTab)}
79
79
  context={builderContext}
80
80
  registeredComponents={builderComponents}
@@ -25,8 +25,8 @@
25
25
 
26
26
  export let blocks: BlocksWrapperProps["blocks"];
27
27
  export let classNameProp: BlocksWrapperProps["classNameProp"] = undefined;
28
- export let parent: BlocksWrapperProps["parent"];
29
28
  export let path: BlocksWrapperProps["path"];
29
+ export let parent: BlocksWrapperProps["parent"];
30
30
  export let styleProp: BlocksWrapperProps["styleProp"];
31
31
  export let BlocksWrapperProps: BlocksWrapperProps["BlocksWrapperProps"];
32
32
  export let BlocksWrapper: BlocksWrapperProps["BlocksWrapper"];
@@ -49,7 +49,7 @@
49
49
  type: "builder.clickEmptyBlocks",
50
50
  data: {
51
51
  parentElementId: parent,
52
- dataPath: path,
52
+ dataPath: dataPath(),
53
53
  },
54
54
  },
55
55
  "*"
@@ -63,7 +63,7 @@
63
63
  type: "builder.hoverEmptyBlocks",
64
64
  data: {
65
65
  parentElementId: parent,
66
- dataPath: path,
66
+ dataPath: dataPath(),
67
67
  },
68
68
  },
69
69
  "*"
@@ -75,6 +75,13 @@
75
75
  .filter(Boolean)
76
76
  .join(" ");
77
77
  };
78
+ $: dataPath = () => {
79
+ if (!path) {
80
+ return undefined;
81
+ }
82
+ const pathPrefix = "component.options.";
83
+ return path.startsWith(pathPrefix) ? path : `${pathPrefix}${path || ""}`;
84
+ };
78
85
 
79
86
  let blocksWrapperRef;
80
87
 
@@ -86,7 +93,7 @@
86
93
  style={stringifyStyles(styleProp)}
87
94
  bind:this={blocksWrapperRef}
88
95
  class={className() + " svelte-element"}
89
- builder-path={path}
96
+ builder-path={dataPath()}
90
97
  builder-parent-id={parent}
91
98
  {...{}}
92
99
  on:click={(event) => {
@@ -25,6 +25,7 @@
25
25
  import { isBrowser } from "../../../functions/is-browser";
26
26
  import { isEditing } from "../../../functions/is-editing";
27
27
  import { isPreviewing } from "../../../functions/is-previewing";
28
+ import { logFetch } from "../../../functions/log-fetch";
28
29
  import { createRegisterComponentMessage } from "../../../functions/register-component";
29
30
  import { _track } from "../../../functions/track/index";
30
31
  import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
@@ -163,6 +164,7 @@
163
164
  })
164
165
  )
165
166
  );
167
+ logFetch(evaluatedUrl);
166
168
  fetch(evaluatedUrl)
167
169
  .then((response) => response.json())
168
170
  .then((json) => {
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.28"
1
+ export const SDK_VERSION = "2.0.30"
@@ -0,0 +1,8 @@
1
+ import { logger } from '../helpers/logger';
2
+ export function logFetch(url: string) {
3
+ if (typeof process !== 'undefined' && process.env?.DEBUG) {
4
+ if (String(process.env.DEBUG) == 'true') {
5
+ logger.log(url);
6
+ }
7
+ }
8
+ }
@@ -7,6 +7,7 @@ import type { CanTrack } from '../../types/can-track';
7
7
  import type { Dictionary } from '../../types/typescript';
8
8
  import { isBrowser } from '../is-browser';
9
9
  import { isEditing } from '../is-editing';
10
+ import { logFetch } from '../log-fetch';
10
11
  import { getUserAttributes } from './helpers';
11
12
  interface Event {
12
13
  /**
@@ -119,7 +120,9 @@ export async function _track({
119
120
  return;
120
121
  }
121
122
  const baseUrl = apiHost || 'https://cdn.builder.io';
122
- return fetch(`${baseUrl}/api/v1/track`, {
123
+ const url = `${baseUrl}/api/v1/track`;
124
+ logFetch(url);
125
+ return fetch(url, {
123
126
  method: 'POST',
124
127
  body: JSON.stringify({
125
128
  events: [await createEvent(eventProps)]