@builder.io/sdk-svelte 0.5.0 → 0.5.2

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "package",
@@ -94,6 +94,7 @@
94
94
  "./constants/sdk-version": "./constants/sdk-version.js",
95
95
  "./constants/target": "./constants/target.js",
96
96
  "./context/builder.context": "./context/builder.context.js",
97
+ "./context/components.context": "./context/components.context.js",
97
98
  "./context/types": "./context/types.js",
98
99
  "./functions/apply-patch-with-mutation": "./functions/apply-patch-with-mutation.js",
99
100
  "./functions/camel-to-kebab-case": "./functions/camel-to-kebab-case.js",
@@ -1,3 +1,11 @@
1
+ ### 0.5.2
2
+
3
+ - No Changes.
4
+
5
+ ### 0.5.1
6
+
7
+ - Fix: make `RenderBlocks` properties `context` and `registeredComponents` optional for external use.
8
+
1
9
  ### 0.5.0
2
10
 
3
11
  - Feature: Added support for rudimentary data-bindings in Non-Node.js (edge, serverless, etc.) server runtimes.
@@ -1,26 +1,36 @@
1
1
  <script context="module"></script>
2
2
 
3
- <script>import BlockStyles from "../block/components/block-styles.svelte";
3
+ <script>import { getContext } from "svelte";
4
+ import BlockStyles from "../block/components/block-styles.svelte";
4
5
  import Block from "../block/block.svelte";
5
6
  import BlocksWrapper from "./blocks-wrapper.svelte";
7
+ import BuilderContext from "../../context/builder.context";
8
+ import ComponentsContext from "../../context/components.context";
6
9
  export let blocks;
7
10
  export let parent;
8
11
  export let path;
9
12
  export let styleProp;
10
13
  export let context;
11
14
  export let registeredComponents;
15
+ let builderContext = getContext(BuilderContext.key);
16
+ let componentsContext = getContext(ComponentsContext.key);
12
17
  </script>
13
18
 
14
19
  <BlocksWrapper {blocks} {parent} {path} {styleProp}>
15
20
  {#if blocks}
16
21
  {#each blocks as block ("render-block-" + block.id)}
17
- <Block {block} {context} {registeredComponents} />
22
+ <Block
23
+ {block}
24
+ context={context || builderContext}
25
+ registeredComponents={registeredComponents ||
26
+ componentsContext.registeredComponents}
27
+ />
18
28
  {/each}
19
29
  {/if}
20
30
 
21
31
  {#if blocks}
22
32
  {#each blocks as block ("block-style-" + block.id)}
23
- <BlockStyles {block} context={$context} />
33
+ <BlockStyles {block} context={$context || $builderContext} />
24
34
  {/each}
25
35
  {/if}
26
36
  </BlocksWrapper>
@@ -1,7 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  export type BlocksProps = Partial<BlocksWrapperProps> & {
3
- context: Writable<BuilderContextInterface>;
4
- registeredComponents: RegisteredComponents;
3
+ context?: Writable<BuilderContextInterface>;
4
+ registeredComponents?: RegisteredComponents;
5
5
  };
6
6
  import type { BlocksWrapperProps } from "./blocks-wrapper.svelte";
7
7
  import type { BuilderContextInterface, RegisteredComponents } from "../../context/types.js";
@@ -1,4 +1,5 @@
1
- <script>import { writable } from "svelte/store";
1
+ <script>import { setContext } from "svelte";
2
+ import { writable } from "svelte/store";
2
3
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
3
4
  import { components, serializeComponentInfo, } from "../../functions/register-component.js";
4
5
  import Blocks from "../blocks/blocks.svelte";
@@ -9,6 +10,7 @@ import { getRenderContentScriptString } from "../content-variants/helpers.js";
9
10
  import EnableEditor from "./components/enable-editor.svelte";
10
11
  import InlinedScript from "../inlined-script.svelte";
11
12
  import "./wrap-component-ref.js";
13
+ import ComponentsContext from "../../context/components.context";
12
14
  export let content;
13
15
  export let customComponents;
14
16
  export let data;
@@ -78,6 +80,9 @@ let builderContextSignal = writable({
78
80
  }), {}),
79
81
  inheritedStyles: {},
80
82
  });
83
+ setContext(ComponentsContext.key, {
84
+ registeredComponents: registeredComponents,
85
+ });
81
86
  </script>
82
87
 
83
88
  <EnableEditor
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.5.0";
1
+ export declare const SDK_VERSION = "0.5.2";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.5.0";
1
+ export const SDK_VERSION = "0.5.2";
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ Components: {
3
+ registeredComponents: {};
4
+ };
5
+ key: symbol;
6
+ };
7
+ export default _default;
@@ -0,0 +1,5 @@
1
+ const key = Symbol();
2
+ export default {
3
+ Components: { registeredComponents: {} },
4
+ key,
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": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "package",
@@ -1,11 +1,13 @@
1
1
  <script context="module" lang="ts">
2
2
  export type BlocksProps = Partial<BlocksWrapperProps> & {
3
- context: Writable<BuilderContextInterface>;
4
- registeredComponents: RegisteredComponents;
3
+ context?: Writable<BuilderContextInterface>;
4
+ registeredComponents?: RegisteredComponents;
5
5
  };
6
6
  </script>
7
7
 
8
8
  <script lang="ts">
9
+ import { getContext } from "svelte";
10
+
9
11
  import BlockStyles from "../block/components/block-styles.svelte";
10
12
  import Block from "../block/block.svelte";
11
13
  import type { BlocksWrapperProps } from "./blocks-wrapper.svelte";
@@ -14,6 +16,8 @@
14
16
  BuilderContextInterface,
15
17
  RegisteredComponents,
16
18
  } from "../../context/types.js";
19
+ import BuilderContext from "../../context/builder.context";
20
+ import ComponentsContext from "../../context/components.context";
17
21
  import type { Writable } from "svelte/store";
18
22
 
19
23
  export let blocks: BlocksProps["blocks"];
@@ -22,18 +26,26 @@
22
26
  export let styleProp: BlocksProps["styleProp"];
23
27
  export let context: BlocksProps["context"];
24
28
  export let registeredComponents: BlocksProps["registeredComponents"];
29
+
30
+ let builderContext = getContext(BuilderContext.key);
31
+ let componentsContext = getContext(ComponentsContext.key);
25
32
  </script>
26
33
 
27
34
  <BlocksWrapper {blocks} {parent} {path} {styleProp}>
28
35
  {#if blocks}
29
36
  {#each blocks as block ("render-block-" + block.id)}
30
- <Block {block} {context} {registeredComponents} />
37
+ <Block
38
+ {block}
39
+ context={context || builderContext}
40
+ registeredComponents={registeredComponents ||
41
+ componentsContext.registeredComponents}
42
+ />
31
43
  {/each}
32
44
  {/if}
33
45
 
34
46
  {#if blocks}
35
47
  {#each blocks as block ("block-style-" + block.id)}
36
- <BlockStyles {block} context={$context} />
48
+ <BlockStyles {block} context={$context || $builderContext} />
37
49
  {/each}
38
50
  {/if}
39
51
  </BlocksWrapper>
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { setContext } from "svelte";
2
3
  import { writable } from "svelte/store";
3
4
 
4
5
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
@@ -25,6 +26,7 @@
25
26
  import { wrapComponentRef } from "./wrap-component-ref.js";
26
27
  import type { ComponentInfo } from "../../types/components.js";
27
28
  import type { Dictionary } from "../../types/typescript.js";
29
+ import ComponentsContext from "../../context/components.context";
28
30
 
29
31
  export let content: ContentProps["content"];
30
32
  export let customComponents: ContentProps["customComponents"];
@@ -103,6 +105,10 @@
103
105
  ),
104
106
  inheritedStyles: {},
105
107
  });
108
+
109
+ setContext(ComponentsContext.key, {
110
+ registeredComponents: registeredComponents,
111
+ });
106
112
  </script>
107
113
 
108
114
  <EnableEditor
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.5.0"
1
+ export const SDK_VERSION = "0.5.2"
@@ -0,0 +1,6 @@
1
+ const key = Symbol();
2
+
3
+ export default {
4
+ Components: { registeredComponents: {} },
5
+ key,
6
+ };