@builder.io/sdk-svelte 2.0.2 → 2.0.5

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 (46) hide show
  1. package/lib/browser/blocks/columns/columns.svelte +3 -2
  2. package/lib/browser/blocks/image/image.svelte +3 -1
  3. package/lib/browser/blocks/image/image.types.d.ts +2 -0
  4. package/lib/browser/blocks/symbol/symbol.types.d.ts +1 -0
  5. package/lib/browser/blocks/text/component-info.js +2 -1
  6. package/lib/browser/blocks/text/text.svelte +16 -2
  7. package/lib/browser/blocks/text/text.svelte.d.ts +1 -0
  8. package/lib/browser/components/block/animator.js +4 -0
  9. package/lib/browser/constants/sdk-version.d.ts +1 -1
  10. package/lib/browser/constants/sdk-version.js +1 -1
  11. package/lib/browser/functions/register-component.d.ts +2 -2
  12. package/lib/browser/functions/register-component.js +8 -9
  13. package/lib/edge/blocks/columns/columns.svelte +3 -2
  14. package/lib/edge/blocks/image/image.svelte +3 -1
  15. package/lib/edge/blocks/image/image.types.d.ts +2 -0
  16. package/lib/edge/blocks/symbol/symbol.types.d.ts +1 -0
  17. package/lib/edge/blocks/text/component-info.js +2 -1
  18. package/lib/edge/blocks/text/text.svelte +16 -2
  19. package/lib/edge/blocks/text/text.svelte.d.ts +1 -0
  20. package/lib/edge/components/block/animator.js +4 -0
  21. package/lib/edge/constants/sdk-version.d.ts +1 -1
  22. package/lib/edge/constants/sdk-version.js +1 -1
  23. package/lib/edge/functions/register-component.d.ts +2 -2
  24. package/lib/edge/functions/register-component.js +8 -9
  25. package/lib/node/blocks/columns/columns.svelte +3 -2
  26. package/lib/node/blocks/image/image.svelte +3 -1
  27. package/lib/node/blocks/image/image.types.d.ts +2 -0
  28. package/lib/node/blocks/symbol/symbol.types.d.ts +1 -0
  29. package/lib/node/blocks/text/component-info.js +2 -1
  30. package/lib/node/blocks/text/text.svelte +16 -2
  31. package/lib/node/blocks/text/text.svelte.d.ts +1 -0
  32. package/lib/node/components/block/animator.js +4 -0
  33. package/lib/node/constants/sdk-version.d.ts +1 -1
  34. package/lib/node/constants/sdk-version.js +1 -1
  35. package/lib/node/functions/register-component.d.ts +2 -2
  36. package/lib/node/functions/register-component.js +8 -9
  37. package/package.json +1 -1
  38. package/src/blocks/columns/columns.svelte +3 -2
  39. package/src/blocks/image/image.svelte +4 -0
  40. package/src/blocks/image/image.types.ts +2 -0
  41. package/src/blocks/symbol/symbol.types.ts +1 -0
  42. package/src/blocks/text/component-info.ts +2 -1
  43. package/src/blocks/text/text.svelte +25 -1
  44. package/src/components/block/animator.ts +4 -0
  45. package/src/constants/sdk-version.ts +1 -1
  46. package/src/functions/register-component.ts +8 -13
@@ -93,6 +93,7 @@ function getWidthForBreakpointSize(size) {
93
93
  return breakpointSizes[size].max;
94
94
  }
95
95
  function columnsStyles() {
96
+ const childColumnDiv = `.${builderBlock.id}-breakpoints > .builder-column`;
96
97
  return `
97
98
  @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
98
99
  .${builderBlock.id}-breakpoints {
@@ -100,7 +101,7 @@ function columnsStyles() {
100
101
  align-items: stretch;
101
102
  }
102
103
 
103
- .${builderBlock.id}-breakpoints > .builder-column {
104
+ ${childColumnDiv} {
104
105
  width: var(--column-width-tablet) !important;
105
106
  margin-left: var(--column-margin-left-tablet) !important;
106
107
  }
@@ -112,7 +113,7 @@ function columnsStyles() {
112
113
  align-items: stretch;
113
114
  }
114
115
 
115
- .${builderBlock.id}-breakpoints > .builder-column {
116
+ ${childColumnDiv} {
116
117
  width: var(--column-width-mobile) !important;
117
118
  margin-left: var(--column-margin-left-mobile) !important;
118
119
  }
@@ -1,4 +1,5 @@
1
- <script>import { getSrcSet } from "./image.helpers";
1
+ <script>import { onMount } from "svelte";
2
+ import { getSrcSet } from "./image.helpers";
2
3
  export let image;
3
4
  export let src = undefined;
4
5
  export let srcset = undefined;
@@ -64,6 +65,7 @@ $: aspectRatioCss = () => {
64
65
  const out = aspectRatio ? aspectRatioStyles : undefined;
65
66
  return out;
66
67
  };
68
+ onMount(() => { });
67
69
  </script>
68
70
 
69
71
  <picture>
@@ -1,5 +1,6 @@
1
1
  import type { BuilderBlock } from '../../types/builder-block';
2
2
  export interface ImageProps {
3
+ attributes?: string;
3
4
  highPriority?: boolean;
4
5
  className?: string;
5
6
  image: string;
@@ -12,6 +13,7 @@ export interface ImageProps {
12
13
  backgroundPosition?: string;
13
14
  srcset?: string;
14
15
  aspectRatio?: number;
16
+ lockAspectRatio?: boolean;
15
17
  children?: any;
16
18
  fitContent?: boolean;
17
19
  builderBlock?: BuilderBlock;
@@ -14,5 +14,6 @@ export interface SymbolProps extends BuilderComponentsProp, BuilderDataProps, Bu
14
14
  dynamic?: boolean;
15
15
  attributes?: any;
16
16
  inheritState?: boolean;
17
+ renderToLiquid?: boolean;
17
18
  }
18
19
  export {};
@@ -1,7 +1,8 @@
1
1
  import { TARGET } from '../../constants/target';
2
2
  export const componentInfo = {
3
3
  shouldReceiveBuilderProps: {
4
- builderBlock: TARGET === 'reactNative' ? true : false
4
+ builderBlock: TARGET === 'reactNative' ? true : false,
5
+ builderContext: true
5
6
  },
6
7
  name: 'Text',
7
8
  static: true,
@@ -1,4 +1,6 @@
1
- <script>export let text = undefined;
1
+ <script>import { evaluate } from "../../functions/evaluate/index";
2
+ export let builderContext;
3
+ export let text = undefined;
2
4
  function stringifyStyles(stylesObj) {
3
5
  let styles = "";
4
6
  for (let key in stylesObj) {
@@ -9,6 +11,18 @@ function stringifyStyles(stylesObj) {
9
11
  }
10
12
  return styles;
11
13
  }
14
+ $: processedText = () => {
15
+ const context = $builderContext;
16
+ const { context: contextContext, localState, rootState, rootSetState, } = context;
17
+ return String(text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
18
+ code: group,
19
+ context: contextContext,
20
+ localState,
21
+ rootState,
22
+ rootSetState,
23
+ enableCache: false,
24
+ }));
25
+ };
12
26
  </script>
13
27
 
14
28
  <div
@@ -17,5 +31,5 @@ function stringifyStyles(stylesObj) {
17
31
  })}
18
32
  class="builder-text"
19
33
  >
20
- {@html text?.toString() || ""}
34
+ {@html processedText()}
21
35
  </div>
@@ -2,6 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  import type { TextProps } from "./text.types";
3
3
  declare const __propDef: {
4
4
  props: {
5
+ builderContext: TextProps["builderContext"];
5
6
  text?: TextProps["text"];
6
7
  };
7
8
  events: {
@@ -1,3 +1,4 @@
1
+ import { TARGET } from '../../constants/target';
1
2
  import { camelToKebabCase } from '../../functions/camel-to-kebab-case';
2
3
  // eslint-disable-next-line @typescript-eslint/ban-types
3
4
  function throttle(func, wait, options = {}) {
@@ -56,6 +57,9 @@ function assign(target, ..._args) {
56
57
  return to;
57
58
  }
58
59
  export function bindAnimations(animations) {
60
+ if (TARGET === 'reactNative') {
61
+ return;
62
+ }
59
63
  for (const animation of animations) {
60
64
  switch (animation.trigger) {
61
65
  case 'pageLoad':
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.2";
1
+ export declare const SDK_VERSION = "2.0.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.2";
1
+ export const SDK_VERSION = "2.0.5";
@@ -1,6 +1,6 @@
1
1
  import type { ComponentInfo } from '../types/components';
2
2
  export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
3
3
  type: string;
4
- data: ComponentInfo;
4
+ data: any;
5
5
  };
6
- export declare const serializeComponentInfo: ({ inputs, ...info }: ComponentInfo) => ComponentInfo;
6
+ export declare function serializeComponentInfo(info: ComponentInfo): any;
@@ -1,4 +1,3 @@
1
- import { fastClone } from './fast-clone';
2
1
  export const createRegisterComponentMessage = (info) => ({
3
2
  type: 'builder.registerComponent',
4
3
  data: serializeComponentInfo(info)
@@ -13,11 +12,11 @@ const serializeFn = (fnValue) => {
13
12
  const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
14
13
  return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
15
14
  };
16
- const serializeValue = (value) => typeof value === 'function' ? serializeFn(value) : fastClone(value);
17
- export const serializeComponentInfo = ({ inputs, ...info }) => ({
18
- ...fastClone(info),
19
- inputs: inputs?.map(input => Object.entries(input).reduce((acc, [key, value]) => ({
20
- ...acc,
21
- [key]: serializeValue(value)
22
- }), {}))
23
- });
15
+ export function serializeComponentInfo(info) {
16
+ return JSON.parse(JSON.stringify(info, (key, value) => {
17
+ if (typeof value === 'function') {
18
+ return serializeFn(value);
19
+ }
20
+ return value;
21
+ }));
22
+ }
@@ -93,6 +93,7 @@ function getWidthForBreakpointSize(size) {
93
93
  return breakpointSizes[size].max;
94
94
  }
95
95
  function columnsStyles() {
96
+ const childColumnDiv = `.${builderBlock.id}-breakpoints > .builder-column`;
96
97
  return `
97
98
  @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
98
99
  .${builderBlock.id}-breakpoints {
@@ -100,7 +101,7 @@ function columnsStyles() {
100
101
  align-items: stretch;
101
102
  }
102
103
 
103
- .${builderBlock.id}-breakpoints > .builder-column {
104
+ ${childColumnDiv} {
104
105
  width: var(--column-width-tablet) !important;
105
106
  margin-left: var(--column-margin-left-tablet) !important;
106
107
  }
@@ -112,7 +113,7 @@ function columnsStyles() {
112
113
  align-items: stretch;
113
114
  }
114
115
 
115
- .${builderBlock.id}-breakpoints > .builder-column {
116
+ ${childColumnDiv} {
116
117
  width: var(--column-width-mobile) !important;
117
118
  margin-left: var(--column-margin-left-mobile) !important;
118
119
  }
@@ -1,4 +1,5 @@
1
- <script>import { getSrcSet } from "./image.helpers";
1
+ <script>import { onMount } from "svelte";
2
+ import { getSrcSet } from "./image.helpers";
2
3
  export let image;
3
4
  export let src = undefined;
4
5
  export let srcset = undefined;
@@ -64,6 +65,7 @@ $: aspectRatioCss = () => {
64
65
  const out = aspectRatio ? aspectRatioStyles : undefined;
65
66
  return out;
66
67
  };
68
+ onMount(() => { });
67
69
  </script>
68
70
 
69
71
  <picture>
@@ -1,5 +1,6 @@
1
1
  import type { BuilderBlock } from '../../types/builder-block';
2
2
  export interface ImageProps {
3
+ attributes?: string;
3
4
  highPriority?: boolean;
4
5
  className?: string;
5
6
  image: string;
@@ -12,6 +13,7 @@ export interface ImageProps {
12
13
  backgroundPosition?: string;
13
14
  srcset?: string;
14
15
  aspectRatio?: number;
16
+ lockAspectRatio?: boolean;
15
17
  children?: any;
16
18
  fitContent?: boolean;
17
19
  builderBlock?: BuilderBlock;
@@ -14,5 +14,6 @@ export interface SymbolProps extends BuilderComponentsProp, BuilderDataProps, Bu
14
14
  dynamic?: boolean;
15
15
  attributes?: any;
16
16
  inheritState?: boolean;
17
+ renderToLiquid?: boolean;
17
18
  }
18
19
  export {};
@@ -1,7 +1,8 @@
1
1
  import { TARGET } from '../../constants/target';
2
2
  export const componentInfo = {
3
3
  shouldReceiveBuilderProps: {
4
- builderBlock: TARGET === 'reactNative' ? true : false
4
+ builderBlock: TARGET === 'reactNative' ? true : false,
5
+ builderContext: true
5
6
  },
6
7
  name: 'Text',
7
8
  static: true,
@@ -1,4 +1,6 @@
1
- <script>export let text = undefined;
1
+ <script>import { evaluate } from "../../functions/evaluate/index";
2
+ export let builderContext;
3
+ export let text = undefined;
2
4
  function stringifyStyles(stylesObj) {
3
5
  let styles = "";
4
6
  for (let key in stylesObj) {
@@ -9,6 +11,18 @@ function stringifyStyles(stylesObj) {
9
11
  }
10
12
  return styles;
11
13
  }
14
+ $: processedText = () => {
15
+ const context = $builderContext;
16
+ const { context: contextContext, localState, rootState, rootSetState, } = context;
17
+ return String(text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
18
+ code: group,
19
+ context: contextContext,
20
+ localState,
21
+ rootState,
22
+ rootSetState,
23
+ enableCache: false,
24
+ }));
25
+ };
12
26
  </script>
13
27
 
14
28
  <div
@@ -17,5 +31,5 @@ function stringifyStyles(stylesObj) {
17
31
  })}
18
32
  class="builder-text"
19
33
  >
20
- {@html text?.toString() || ""}
34
+ {@html processedText()}
21
35
  </div>
@@ -2,6 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  import type { TextProps } from "./text.types";
3
3
  declare const __propDef: {
4
4
  props: {
5
+ builderContext: TextProps["builderContext"];
5
6
  text?: TextProps["text"];
6
7
  };
7
8
  events: {
@@ -1,3 +1,4 @@
1
+ import { TARGET } from '../../constants/target';
1
2
  import { camelToKebabCase } from '../../functions/camel-to-kebab-case';
2
3
  // eslint-disable-next-line @typescript-eslint/ban-types
3
4
  function throttle(func, wait, options = {}) {
@@ -56,6 +57,9 @@ function assign(target, ..._args) {
56
57
  return to;
57
58
  }
58
59
  export function bindAnimations(animations) {
60
+ if (TARGET === 'reactNative') {
61
+ return;
62
+ }
59
63
  for (const animation of animations) {
60
64
  switch (animation.trigger) {
61
65
  case 'pageLoad':
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.2";
1
+ export declare const SDK_VERSION = "2.0.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.2";
1
+ export const SDK_VERSION = "2.0.5";
@@ -1,6 +1,6 @@
1
1
  import type { ComponentInfo } from '../types/components';
2
2
  export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
3
3
  type: string;
4
- data: ComponentInfo;
4
+ data: any;
5
5
  };
6
- export declare const serializeComponentInfo: ({ inputs, ...info }: ComponentInfo) => ComponentInfo;
6
+ export declare function serializeComponentInfo(info: ComponentInfo): any;
@@ -1,4 +1,3 @@
1
- import { fastClone } from './fast-clone';
2
1
  export const createRegisterComponentMessage = (info) => ({
3
2
  type: 'builder.registerComponent',
4
3
  data: serializeComponentInfo(info)
@@ -13,11 +12,11 @@ const serializeFn = (fnValue) => {
13
12
  const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
14
13
  return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
15
14
  };
16
- const serializeValue = (value) => typeof value === 'function' ? serializeFn(value) : fastClone(value);
17
- export const serializeComponentInfo = ({ inputs, ...info }) => ({
18
- ...fastClone(info),
19
- inputs: inputs?.map(input => Object.entries(input).reduce((acc, [key, value]) => ({
20
- ...acc,
21
- [key]: serializeValue(value)
22
- }), {}))
23
- });
15
+ export function serializeComponentInfo(info) {
16
+ return JSON.parse(JSON.stringify(info, (key, value) => {
17
+ if (typeof value === 'function') {
18
+ return serializeFn(value);
19
+ }
20
+ return value;
21
+ }));
22
+ }
@@ -93,6 +93,7 @@ function getWidthForBreakpointSize(size) {
93
93
  return breakpointSizes[size].max;
94
94
  }
95
95
  function columnsStyles() {
96
+ const childColumnDiv = `.${builderBlock.id}-breakpoints > .builder-column`;
96
97
  return `
97
98
  @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
98
99
  .${builderBlock.id}-breakpoints {
@@ -100,7 +101,7 @@ function columnsStyles() {
100
101
  align-items: stretch;
101
102
  }
102
103
 
103
- .${builderBlock.id}-breakpoints > .builder-column {
104
+ ${childColumnDiv} {
104
105
  width: var(--column-width-tablet) !important;
105
106
  margin-left: var(--column-margin-left-tablet) !important;
106
107
  }
@@ -112,7 +113,7 @@ function columnsStyles() {
112
113
  align-items: stretch;
113
114
  }
114
115
 
115
- .${builderBlock.id}-breakpoints > .builder-column {
116
+ ${childColumnDiv} {
116
117
  width: var(--column-width-mobile) !important;
117
118
  margin-left: var(--column-margin-left-mobile) !important;
118
119
  }
@@ -1,4 +1,5 @@
1
- <script>import { getSrcSet } from "./image.helpers";
1
+ <script>import { onMount } from "svelte";
2
+ import { getSrcSet } from "./image.helpers";
2
3
  export let image;
3
4
  export let src = undefined;
4
5
  export let srcset = undefined;
@@ -64,6 +65,7 @@ $: aspectRatioCss = () => {
64
65
  const out = aspectRatio ? aspectRatioStyles : undefined;
65
66
  return out;
66
67
  };
68
+ onMount(() => { });
67
69
  </script>
68
70
 
69
71
  <picture>
@@ -1,5 +1,6 @@
1
1
  import type { BuilderBlock } from '../../types/builder-block';
2
2
  export interface ImageProps {
3
+ attributes?: string;
3
4
  highPriority?: boolean;
4
5
  className?: string;
5
6
  image: string;
@@ -12,6 +13,7 @@ export interface ImageProps {
12
13
  backgroundPosition?: string;
13
14
  srcset?: string;
14
15
  aspectRatio?: number;
16
+ lockAspectRatio?: boolean;
15
17
  children?: any;
16
18
  fitContent?: boolean;
17
19
  builderBlock?: BuilderBlock;
@@ -14,5 +14,6 @@ export interface SymbolProps extends BuilderComponentsProp, BuilderDataProps, Bu
14
14
  dynamic?: boolean;
15
15
  attributes?: any;
16
16
  inheritState?: boolean;
17
+ renderToLiquid?: boolean;
17
18
  }
18
19
  export {};
@@ -1,7 +1,8 @@
1
1
  import { TARGET } from '../../constants/target';
2
2
  export const componentInfo = {
3
3
  shouldReceiveBuilderProps: {
4
- builderBlock: TARGET === 'reactNative' ? true : false
4
+ builderBlock: TARGET === 'reactNative' ? true : false,
5
+ builderContext: true
5
6
  },
6
7
  name: 'Text',
7
8
  static: true,
@@ -1,4 +1,6 @@
1
- <script>export let text = undefined;
1
+ <script>import { evaluate } from "../../functions/evaluate/index";
2
+ export let builderContext;
3
+ export let text = undefined;
2
4
  function stringifyStyles(stylesObj) {
3
5
  let styles = "";
4
6
  for (let key in stylesObj) {
@@ -9,6 +11,18 @@ function stringifyStyles(stylesObj) {
9
11
  }
10
12
  return styles;
11
13
  }
14
+ $: processedText = () => {
15
+ const context = $builderContext;
16
+ const { context: contextContext, localState, rootState, rootSetState, } = context;
17
+ return String(text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
18
+ code: group,
19
+ context: contextContext,
20
+ localState,
21
+ rootState,
22
+ rootSetState,
23
+ enableCache: false,
24
+ }));
25
+ };
12
26
  </script>
13
27
 
14
28
  <div
@@ -17,5 +31,5 @@ function stringifyStyles(stylesObj) {
17
31
  })}
18
32
  class="builder-text"
19
33
  >
20
- {@html text?.toString() || ""}
34
+ {@html processedText()}
21
35
  </div>
@@ -2,6 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  import type { TextProps } from "./text.types";
3
3
  declare const __propDef: {
4
4
  props: {
5
+ builderContext: TextProps["builderContext"];
5
6
  text?: TextProps["text"];
6
7
  };
7
8
  events: {
@@ -1,3 +1,4 @@
1
+ import { TARGET } from '../../constants/target';
1
2
  import { camelToKebabCase } from '../../functions/camel-to-kebab-case';
2
3
  // eslint-disable-next-line @typescript-eslint/ban-types
3
4
  function throttle(func, wait, options = {}) {
@@ -56,6 +57,9 @@ function assign(target, ..._args) {
56
57
  return to;
57
58
  }
58
59
  export function bindAnimations(animations) {
60
+ if (TARGET === 'reactNative') {
61
+ return;
62
+ }
59
63
  for (const animation of animations) {
60
64
  switch (animation.trigger) {
61
65
  case 'pageLoad':
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.2";
1
+ export declare const SDK_VERSION = "2.0.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.2";
1
+ export const SDK_VERSION = "2.0.5";
@@ -1,6 +1,6 @@
1
1
  import type { ComponentInfo } from '../types/components';
2
2
  export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
3
3
  type: string;
4
- data: ComponentInfo;
4
+ data: any;
5
5
  };
6
- export declare const serializeComponentInfo: ({ inputs, ...info }: ComponentInfo) => ComponentInfo;
6
+ export declare function serializeComponentInfo(info: ComponentInfo): any;
@@ -1,4 +1,3 @@
1
- import { fastClone } from './fast-clone';
2
1
  export const createRegisterComponentMessage = (info) => ({
3
2
  type: 'builder.registerComponent',
4
3
  data: serializeComponentInfo(info)
@@ -13,11 +12,11 @@ const serializeFn = (fnValue) => {
13
12
  const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
14
13
  return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
15
14
  };
16
- const serializeValue = (value) => typeof value === 'function' ? serializeFn(value) : fastClone(value);
17
- export const serializeComponentInfo = ({ inputs, ...info }) => ({
18
- ...fastClone(info),
19
- inputs: inputs?.map(input => Object.entries(input).reduce((acc, [key, value]) => ({
20
- ...acc,
21
- [key]: serializeValue(value)
22
- }), {}))
23
- });
15
+ export function serializeComponentInfo(info) {
16
+ return JSON.parse(JSON.stringify(info, (key, value) => {
17
+ if (typeof value === 'function') {
18
+ return serializeFn(value);
19
+ }
20
+ return value;
21
+ }));
22
+ }
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.2",
4
+ "version": "2.0.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -117,6 +117,7 @@
117
117
  return breakpointSizes[size].max;
118
118
  }
119
119
  function columnsStyles() {
120
+ const childColumnDiv = `.${builderBlock.id}-breakpoints > .builder-column`;
120
121
  return `
121
122
  @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
122
123
  .${builderBlock.id}-breakpoints {
@@ -124,7 +125,7 @@
124
125
  align-items: stretch;
125
126
  }
126
127
 
127
- .${builderBlock.id}-breakpoints > .builder-column {
128
+ ${childColumnDiv} {
128
129
  width: var(--column-width-tablet) !important;
129
130
  margin-left: var(--column-margin-left-tablet) !important;
130
131
  }
@@ -136,7 +137,7 @@
136
137
  align-items: stretch;
137
138
  }
138
139
 
139
- .${builderBlock.id}-breakpoints > .builder-column {
140
+ ${childColumnDiv} {
140
141
  width: var(--column-width-mobile) !important;
141
142
  margin-left: var(--column-margin-left-mobile) !important;
142
143
  }
@@ -1,4 +1,6 @@
1
1
  <script lang="ts">
2
+ import { onMount } from "svelte";
3
+
2
4
  import { getSrcSet } from "./image.helpers";
3
5
  import type { ImageProps } from "./image.types";
4
6
 
@@ -69,6 +71,8 @@
69
71
  const out = aspectRatio ? aspectRatioStyles : undefined;
70
72
  return out;
71
73
  };
74
+
75
+ onMount(() => {});
72
76
  </script>
73
77
 
74
78
  <picture>
@@ -1,5 +1,6 @@
1
1
  import type { BuilderBlock } from '../../types/builder-block';
2
2
  export interface ImageProps {
3
+ attributes?: string;
3
4
  highPriority?: boolean;
4
5
  className?: string;
5
6
  image: string;
@@ -12,6 +13,7 @@ export interface ImageProps {
12
13
  backgroundPosition?: string;
13
14
  srcset?: string;
14
15
  aspectRatio?: number;
16
+ lockAspectRatio?: boolean;
15
17
  children?: any;
16
18
  fitContent?: boolean;
17
19
  builderBlock?: BuilderBlock;
@@ -14,4 +14,5 @@ export interface SymbolProps extends BuilderComponentsProp, BuilderDataProps, Bu
14
14
  dynamic?: boolean;
15
15
  attributes?: any;
16
16
  inheritState?: boolean;
17
+ renderToLiquid?: boolean;
17
18
  }
@@ -2,7 +2,8 @@ import { TARGET } from '../../constants/target';
2
2
  import type { ComponentInfo } from '../../types/components';
3
3
  export const componentInfo: ComponentInfo = {
4
4
  shouldReceiveBuilderProps: {
5
- builderBlock: TARGET === 'reactNative' ? true : false
5
+ builderBlock: TARGET === 'reactNative' ? true : false,
6
+ builderContext: true
6
7
  },
7
8
  name: 'Text',
8
9
  static: true,
@@ -1,6 +1,8 @@
1
1
  <script lang="ts">
2
+ import { evaluate } from "../../functions/evaluate/index";
2
3
  import type { TextProps } from "./text.types";
3
4
 
5
+ export let builderContext: TextProps["builderContext"];
4
6
  export let text: TextProps["text"] = undefined;
5
7
  function stringifyStyles(stylesObj) {
6
8
  let styles = "";
@@ -12,6 +14,28 @@
12
14
  }
13
15
  return styles;
14
16
  }
17
+
18
+ $: processedText = () => {
19
+ const context = $builderContext;
20
+ const {
21
+ context: contextContext,
22
+ localState,
23
+ rootState,
24
+ rootSetState,
25
+ } = context;
26
+ return String(text?.toString() || "").replace(
27
+ /{{([^}]+)}}/g,
28
+ (match, group) =>
29
+ evaluate({
30
+ code: group,
31
+ context: contextContext,
32
+ localState,
33
+ rootState,
34
+ rootSetState,
35
+ enableCache: false,
36
+ }) as string
37
+ );
38
+ };
15
39
  </script>
16
40
 
17
41
  <div
@@ -20,5 +44,5 @@
20
44
  })}
21
45
  class="builder-text"
22
46
  >
23
- {@html text?.toString() || ""}
47
+ {@html processedText()}
24
48
  </div>
@@ -1,3 +1,4 @@
1
+ import { TARGET } from '../../constants/target';
1
2
  import { camelToKebabCase } from '../../functions/camel-to-kebab-case';
2
3
  import type { BuilderAnimation } from '../../types/builder-block';
3
4
 
@@ -54,6 +55,9 @@ function assign(target: object, ..._args: any[]) {
54
55
  return to;
55
56
  }
56
57
  export function bindAnimations(animations: BuilderAnimation[]) {
58
+ if (TARGET === 'reactNative') {
59
+ return;
60
+ }
57
61
  for (const animation of animations) {
58
62
  switch (animation.trigger) {
59
63
  case 'pageLoad':
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.2"
1
+ export const SDK_VERSION = "2.0.5"
@@ -1,6 +1,4 @@
1
1
  import type { ComponentInfo } from '../types/components';
2
- import type { Input } from '../types/input';
3
- import { fastClone } from './fast-clone';
4
2
  export const createRegisterComponentMessage = (info: ComponentInfo) => ({
5
3
  type: 'builder.registerComponent',
6
4
  data: serializeComponentInfo(info)
@@ -17,14 +15,11 @@ const serializeFn = (fnValue: Function) => {
17
15
  const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
18
16
  return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
19
17
  };
20
- const serializeValue = (value: object): any => typeof value === 'function' ? serializeFn(value) : fastClone(value);
21
- export const serializeComponentInfo = ({
22
- inputs,
23
- ...info
24
- }: ComponentInfo): ComponentInfo => ({
25
- ...fastClone(info),
26
- inputs: inputs?.map(input => Object.entries(input).reduce((acc, [key, value]) => ({
27
- ...acc,
28
- [key]: serializeValue(value)
29
- }), ({} as Input)))
30
- })
18
+ export function serializeComponentInfo(info: ComponentInfo) {
19
+ return JSON.parse(JSON.stringify(info, (key, value) => {
20
+ if (typeof value === 'function') {
21
+ return serializeFn(value);
22
+ }
23
+ return value;
24
+ }));
25
+ }