@builder.io/sdk-svelte 2.0.3 → 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 (35) hide show
  1. package/lib/browser/blocks/image/image.svelte +3 -1
  2. package/lib/browser/blocks/image/image.types.d.ts +2 -0
  3. package/lib/browser/blocks/symbol/symbol.types.d.ts +1 -0
  4. package/lib/browser/blocks/text/component-info.js +2 -1
  5. package/lib/browser/blocks/text/text.svelte +16 -2
  6. package/lib/browser/blocks/text/text.svelte.d.ts +1 -0
  7. package/lib/browser/components/block/animator.js +4 -0
  8. package/lib/browser/constants/sdk-version.d.ts +1 -1
  9. package/lib/browser/constants/sdk-version.js +1 -1
  10. package/lib/edge/blocks/image/image.svelte +3 -1
  11. package/lib/edge/blocks/image/image.types.d.ts +2 -0
  12. package/lib/edge/blocks/symbol/symbol.types.d.ts +1 -0
  13. package/lib/edge/blocks/text/component-info.js +2 -1
  14. package/lib/edge/blocks/text/text.svelte +16 -2
  15. package/lib/edge/blocks/text/text.svelte.d.ts +1 -0
  16. package/lib/edge/components/block/animator.js +4 -0
  17. package/lib/edge/constants/sdk-version.d.ts +1 -1
  18. package/lib/edge/constants/sdk-version.js +1 -1
  19. package/lib/node/blocks/image/image.svelte +3 -1
  20. package/lib/node/blocks/image/image.types.d.ts +2 -0
  21. package/lib/node/blocks/symbol/symbol.types.d.ts +1 -0
  22. package/lib/node/blocks/text/component-info.js +2 -1
  23. package/lib/node/blocks/text/text.svelte +16 -2
  24. package/lib/node/blocks/text/text.svelte.d.ts +1 -0
  25. package/lib/node/components/block/animator.js +4 -0
  26. package/lib/node/constants/sdk-version.d.ts +1 -1
  27. package/lib/node/constants/sdk-version.js +1 -1
  28. package/package.json +1 -1
  29. package/src/blocks/image/image.svelte +4 -0
  30. package/src/blocks/image/image.types.ts +2 -0
  31. package/src/blocks/symbol/symbol.types.ts +1 -0
  32. package/src/blocks/text/component-info.ts +2 -1
  33. package/src/blocks/text/text.svelte +25 -1
  34. package/src/components/block/animator.ts +4 -0
  35. package/src/constants/sdk-version.ts +1 -1
@@ -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.3";
1
+ export declare const SDK_VERSION = "2.0.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.3";
1
+ export const SDK_VERSION = "2.0.5";
@@ -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.3";
1
+ export declare const SDK_VERSION = "2.0.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.3";
1
+ export const SDK_VERSION = "2.0.5";
@@ -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.3";
1
+ export declare const SDK_VERSION = "2.0.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.3";
1
+ export const SDK_VERSION = "2.0.5";
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.3",
4
+ "version": "2.0.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -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.3"
1
+ export const SDK_VERSION = "2.0.5"