@builder.io/sdk-svelte 2.0.8 → 2.0.9

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.
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
3
3
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components";
4
4
  import { TARGET } from "../../constants/target";
5
5
  import ComponentsContext from "../../context/components.context";
6
- import { serializeComponentInfo } from "../../functions/register-component";
6
+ import { serializeIncludingFunctions } from "../../functions/register-component";
7
7
  import Blocks from "../blocks/blocks.svelte";
8
8
  import { getUpdateVariantVisibilityScript } from "../content-variants/helpers";
9
9
  import "../dynamic-div.svelte";
@@ -54,7 +54,7 @@ let registeredComponents = [
54
54
  ...acc,
55
55
  [info.name]: {
56
56
  component: component,
57
- ...serializeComponentInfo(info),
57
+ ...serializeIncludingFunctions(info),
58
58
  },
59
59
  }), {});
60
60
  let builderContextSignal = writable({
@@ -84,7 +84,7 @@ let builderContextSignal = writable({
84
84
  }) || []),
85
85
  ].reduce((acc, { component: _, ...info }) => ({
86
86
  ...acc,
87
- [info.name]: serializeComponentInfo(info),
87
+ [info.name]: serializeIncludingFunctions(info),
88
88
  }), {}),
89
89
  inheritedStyles: {},
90
90
  BlocksWrapper: blocksWrapper || "div",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.8";
1
+ export declare const SDK_VERSION = "2.0.9";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.8";
1
+ export const SDK_VERSION = "2.0.9";
@@ -3,4 +3,4 @@ export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
3
3
  type: string;
4
4
  data: any;
5
5
  };
6
- export declare function serializeComponentInfo(info: ComponentInfo): any;
6
+ export declare function serializeIncludingFunctions(info: ComponentInfo): any;
@@ -1,6 +1,6 @@
1
1
  export const createRegisterComponentMessage = (info) => ({
2
2
  type: 'builder.registerComponent',
3
- data: serializeComponentInfo(info)
3
+ data: serializeIncludingFunctions(info)
4
4
  });
5
5
  // eslint-disable-next-line @typescript-eslint/ban-types
6
6
  const serializeFn = (fnValue) => {
@@ -12,7 +12,7 @@ const serializeFn = (fnValue) => {
12
12
  const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
13
13
  return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
14
14
  };
15
- export function serializeComponentInfo(info) {
15
+ export function serializeIncludingFunctions(info) {
16
16
  return JSON.parse(JSON.stringify(info, (key, value) => {
17
17
  if (typeof value === 'function') {
18
18
  return serializeFn(value);
@@ -1,6 +1,10 @@
1
1
  import { isBrowser } from './is-browser';
2
+ import { serializeIncludingFunctions } from './register-component';
2
3
  const registry = {};
3
4
  export function register(type, info) {
5
+ if (type === 'plugin') {
6
+ info = serializeIncludingFunctions(info);
7
+ }
4
8
  let typeList = registry[type];
5
9
  if (!typeList) {
6
10
  typeList = registry[type] = [];
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
3
3
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components";
4
4
  import { TARGET } from "../../constants/target";
5
5
  import ComponentsContext from "../../context/components.context";
6
- import { serializeComponentInfo } from "../../functions/register-component";
6
+ import { serializeIncludingFunctions } from "../../functions/register-component";
7
7
  import Blocks from "../blocks/blocks.svelte";
8
8
  import { getUpdateVariantVisibilityScript } from "../content-variants/helpers";
9
9
  import "../dynamic-div.svelte";
@@ -54,7 +54,7 @@ let registeredComponents = [
54
54
  ...acc,
55
55
  [info.name]: {
56
56
  component: component,
57
- ...serializeComponentInfo(info),
57
+ ...serializeIncludingFunctions(info),
58
58
  },
59
59
  }), {});
60
60
  let builderContextSignal = writable({
@@ -84,7 +84,7 @@ let builderContextSignal = writable({
84
84
  }) || []),
85
85
  ].reduce((acc, { component: _, ...info }) => ({
86
86
  ...acc,
87
- [info.name]: serializeComponentInfo(info),
87
+ [info.name]: serializeIncludingFunctions(info),
88
88
  }), {}),
89
89
  inheritedStyles: {},
90
90
  BlocksWrapper: blocksWrapper || "div",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.8";
1
+ export declare const SDK_VERSION = "2.0.9";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.8";
1
+ export const SDK_VERSION = "2.0.9";
@@ -3,4 +3,4 @@ export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
3
3
  type: string;
4
4
  data: any;
5
5
  };
6
- export declare function serializeComponentInfo(info: ComponentInfo): any;
6
+ export declare function serializeIncludingFunctions(info: ComponentInfo): any;
@@ -1,6 +1,6 @@
1
1
  export const createRegisterComponentMessage = (info) => ({
2
2
  type: 'builder.registerComponent',
3
- data: serializeComponentInfo(info)
3
+ data: serializeIncludingFunctions(info)
4
4
  });
5
5
  // eslint-disable-next-line @typescript-eslint/ban-types
6
6
  const serializeFn = (fnValue) => {
@@ -12,7 +12,7 @@ const serializeFn = (fnValue) => {
12
12
  const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
13
13
  return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
14
14
  };
15
- export function serializeComponentInfo(info) {
15
+ export function serializeIncludingFunctions(info) {
16
16
  return JSON.parse(JSON.stringify(info, (key, value) => {
17
17
  if (typeof value === 'function') {
18
18
  return serializeFn(value);
@@ -1,6 +1,10 @@
1
1
  import { isBrowser } from './is-browser';
2
+ import { serializeIncludingFunctions } from './register-component';
2
3
  const registry = {};
3
4
  export function register(type, info) {
5
+ if (type === 'plugin') {
6
+ info = serializeIncludingFunctions(info);
7
+ }
4
8
  let typeList = registry[type];
5
9
  if (!typeList) {
6
10
  typeList = registry[type] = [];
@@ -3,7 +3,7 @@ import { writable } from "svelte/store";
3
3
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components";
4
4
  import { TARGET } from "../../constants/target";
5
5
  import ComponentsContext from "../../context/components.context";
6
- import { serializeComponentInfo } from "../../functions/register-component";
6
+ import { serializeIncludingFunctions } from "../../functions/register-component";
7
7
  import Blocks from "../blocks/blocks.svelte";
8
8
  import { getUpdateVariantVisibilityScript } from "../content-variants/helpers";
9
9
  import "../dynamic-div.svelte";
@@ -54,7 +54,7 @@ let registeredComponents = [
54
54
  ...acc,
55
55
  [info.name]: {
56
56
  component: component,
57
- ...serializeComponentInfo(info),
57
+ ...serializeIncludingFunctions(info),
58
58
  },
59
59
  }), {});
60
60
  let builderContextSignal = writable({
@@ -84,7 +84,7 @@ let builderContextSignal = writable({
84
84
  }) || []),
85
85
  ].reduce((acc, { component: _, ...info }) => ({
86
86
  ...acc,
87
- [info.name]: serializeComponentInfo(info),
87
+ [info.name]: serializeIncludingFunctions(info),
88
88
  }), {}),
89
89
  inheritedStyles: {},
90
90
  BlocksWrapper: blocksWrapper || "div",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.8";
1
+ export declare const SDK_VERSION = "2.0.9";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.8";
1
+ export const SDK_VERSION = "2.0.9";
@@ -3,4 +3,4 @@ export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
3
3
  type: string;
4
4
  data: any;
5
5
  };
6
- export declare function serializeComponentInfo(info: ComponentInfo): any;
6
+ export declare function serializeIncludingFunctions(info: ComponentInfo): any;
@@ -1,6 +1,6 @@
1
1
  export const createRegisterComponentMessage = (info) => ({
2
2
  type: 'builder.registerComponent',
3
- data: serializeComponentInfo(info)
3
+ data: serializeIncludingFunctions(info)
4
4
  });
5
5
  // eslint-disable-next-line @typescript-eslint/ban-types
6
6
  const serializeFn = (fnValue) => {
@@ -12,7 +12,7 @@ const serializeFn = (fnValue) => {
12
12
  const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
13
13
  return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
14
14
  };
15
- export function serializeComponentInfo(info) {
15
+ export function serializeIncludingFunctions(info) {
16
16
  return JSON.parse(JSON.stringify(info, (key, value) => {
17
17
  if (typeof value === 'function') {
18
18
  return serializeFn(value);
@@ -1,6 +1,10 @@
1
1
  import { isBrowser } from './is-browser';
2
+ import { serializeIncludingFunctions } from './register-component';
2
3
  const registry = {};
3
4
  export function register(type, info) {
5
+ if (type === 'plugin') {
6
+ info = serializeIncludingFunctions(info);
7
+ }
4
8
  let typeList = registry[type];
5
9
  if (!typeList) {
6
10
  typeList = registry[type] = [];
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.8",
4
+ "version": "2.0.9",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -10,7 +10,7 @@
10
10
  BuilderRenderState,
11
11
  RegisteredComponents,
12
12
  } from "../../context/types";
13
- import { serializeComponentInfo } from "../../functions/register-component";
13
+ import { serializeIncludingFunctions } from "../../functions/register-component";
14
14
  import type { ComponentInfo } from "../../types/components";
15
15
  import type { Dictionary } from "../../types/typescript";
16
16
  import Blocks from "../blocks/blocks.svelte";
@@ -70,7 +70,7 @@
70
70
  ...acc,
71
71
  [info.name]: {
72
72
  component: component,
73
- ...serializeComponentInfo(info),
73
+ ...serializeIncludingFunctions(info),
74
74
  },
75
75
  }),
76
76
  {}
@@ -101,7 +101,7 @@
101
101
  ].reduce<Dictionary<ComponentInfo>>(
102
102
  (acc, { component: _, ...info }) => ({
103
103
  ...acc,
104
- [info.name]: serializeComponentInfo(info),
104
+ [info.name]: serializeIncludingFunctions(info),
105
105
  }),
106
106
  {}
107
107
  ),
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.8"
1
+ export const SDK_VERSION = "2.0.9"
@@ -1,7 +1,7 @@
1
1
  import type { ComponentInfo } from '../types/components';
2
2
  export const createRegisterComponentMessage = (info: ComponentInfo) => ({
3
3
  type: 'builder.registerComponent',
4
- data: serializeComponentInfo(info)
4
+ data: serializeIncludingFunctions(info)
5
5
  });
6
6
 
7
7
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -15,7 +15,7 @@ const serializeFn = (fnValue: Function) => {
15
15
  const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
16
16
  return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
17
17
  };
18
- export function serializeComponentInfo(info: ComponentInfo) {
18
+ export function serializeIncludingFunctions(info: ComponentInfo) {
19
19
  return JSON.parse(JSON.stringify(info, (key, value) => {
20
20
  if (typeof value === 'function') {
21
21
  return serializeFn(value);
@@ -1,6 +1,7 @@
1
1
  import type { BuilderBlock } from '../types/builder-block';
2
2
  import type { DeepPartial } from '../types/deep-partial';
3
3
  import { isBrowser } from './is-browser';
4
+ import { serializeIncludingFunctions } from './register-component';
4
5
  export interface InsertMenuItem {
5
6
  name: string;
6
7
  icon?: string;
@@ -19,6 +20,9 @@ const registry: {
19
20
  export function register(type: 'insertMenu', info: InsertMenuConfig): void;
20
21
  export function register(type: string, info: any): void;
21
22
  export function register(type: string, info: any) {
23
+ if (type === 'plugin') {
24
+ info = serializeIncludingFunctions(info);
25
+ }
22
26
  let typeList = registry[type];
23
27
  if (!typeList) {
24
28
  typeList = registry[type] = [];