@builder.io/sdk-svelte 2.0.16 → 2.0.18

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 (34) hide show
  1. package/lib/browser/components/awaiter.svelte +19 -0
  2. package/lib/browser/components/awaiter.svelte.d.ts +21 -0
  3. package/lib/browser/components/block/components/interactive-element.svelte +14 -4
  4. package/lib/browser/constants/sdk-version.d.ts +1 -1
  5. package/lib/browser/constants/sdk-version.js +1 -1
  6. package/lib/browser/context/component-reference-types.d.ts +15 -0
  7. package/lib/browser/context/component-reference-types.js +1 -0
  8. package/lib/browser/context/types.d.ts +2 -1
  9. package/lib/browser/functions/evaluate/node-runtime/node-runtime.js +1 -1
  10. package/lib/edge/components/awaiter.svelte +19 -0
  11. package/lib/edge/components/awaiter.svelte.d.ts +21 -0
  12. package/lib/edge/components/block/components/interactive-element.svelte +14 -4
  13. package/lib/edge/constants/sdk-version.d.ts +1 -1
  14. package/lib/edge/constants/sdk-version.js +1 -1
  15. package/lib/edge/context/component-reference-types.d.ts +15 -0
  16. package/lib/edge/context/component-reference-types.js +1 -0
  17. package/lib/edge/context/types.d.ts +2 -1
  18. package/lib/edge/functions/evaluate/node-runtime/node-runtime.js +1 -1
  19. package/lib/node/components/awaiter.svelte +19 -0
  20. package/lib/node/components/awaiter.svelte.d.ts +21 -0
  21. package/lib/node/components/block/components/interactive-element.svelte +14 -4
  22. package/lib/node/constants/sdk-version.d.ts +1 -1
  23. package/lib/node/constants/sdk-version.js +1 -1
  24. package/lib/node/context/component-reference-types.d.ts +15 -0
  25. package/lib/node/context/component-reference-types.js +1 -0
  26. package/lib/node/context/types.d.ts +2 -1
  27. package/lib/node/functions/evaluate/node-runtime/node-runtime.js +1 -1
  28. package/package.json +1 -1
  29. package/src/components/awaiter.svelte +20 -0
  30. package/src/components/block/components/interactive-element.svelte +14 -4
  31. package/src/constants/sdk-version.ts +1 -1
  32. package/src/context/component-reference-types.ts +16 -0
  33. package/src/context/types.ts +2 -1
  34. package/src/functions/evaluate/node-runtime/node-runtime.ts +1 -1
@@ -0,0 +1,19 @@
1
+ <script>export let load;
2
+ export let fallback;
3
+ export let props;
4
+ export let attributes;
5
+ </script>
6
+
7
+ {#await load()}
8
+ {#if fallback}
9
+ <svelte:component this={fallback} />
10
+ {/if}
11
+ {:then { default: Component }}
12
+ <svelte:component
13
+ this={Component}
14
+ {...props}
15
+ attributes={attributes}
16
+ >
17
+ <slot />
18
+ </svelte:component>
19
+ {/await}
@@ -0,0 +1,21 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ load: () => Promise<any>;
5
+ fallback: any;
6
+ props: any;
7
+ attributes: any;
8
+ };
9
+ events: {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {
13
+ default: {};
14
+ };
15
+ };
16
+ export type AwaiterProps = typeof __propDef.props;
17
+ export type AwaiterEvents = typeof __propDef.events;
18
+ export type AwaiterSlots = typeof __propDef.slots;
19
+ export default class Awaiter extends SvelteComponent<AwaiterProps, AwaiterEvents, AwaiterSlots> {
20
+ }
21
+ export {};
@@ -2,11 +2,12 @@
2
2
 
3
3
  <script>import { getBlockActions } from "../../../functions/get-block-actions";
4
4
  import { getBlockProperties } from "../../../functions/get-block-properties";
5
+ import Awaiter from "../../awaiter.svelte";
5
6
  export let includeBlockProps;
6
7
  export let block;
7
8
  export let context;
8
- export let wrapperProps;
9
9
  export let Wrapper;
10
+ export let wrapperProps;
10
11
  $: attributes = () => {
11
12
  return includeBlockProps
12
13
  ? {
@@ -26,6 +27,15 @@ $: attributes = () => {
26
27
  };
27
28
  </script>
28
29
 
29
- <svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
30
- ><slot /></svelte:component
31
- >
30
+ {#if Wrapper.load}
31
+ <Awaiter
32
+ load={Wrapper.load}
33
+ fallback={Wrapper.fallback}
34
+ props={wrapperProps}
35
+ attributes={attributes()}><slot /></Awaiter
36
+ >
37
+ {:else}
38
+ <svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
39
+ ><slot /></svelte:component
40
+ >
41
+ {/if}
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.16";
1
+ export declare const SDK_VERSION = "2.0.18";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.16";
1
+ export const SDK_VERSION = "2.0.18";
@@ -0,0 +1,15 @@
1
+ import type { SvelteComponent } from 'svelte';
2
+ export type ComponentReference = {
3
+ /**
4
+ * A dynamic import function pointing to the component.
5
+ * Example: `() => import('../components/my-component.svelte')`
6
+ * @returns A Promise that resolves to the loaded component.
7
+ */
8
+ load: () => Promise<{
9
+ default: typeof SvelteComponent<any>;
10
+ }>;
11
+ /**
12
+ * An optional fallback component to render while the dynamic component is loading.
13
+ */
14
+ fallback?: typeof SvelteComponent<any>;
15
+ } | typeof SvelteComponent<any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -3,9 +3,10 @@ import type { ApiVersion } from '../types/api-version';
3
3
  import type { BuilderContent } from '../types/builder-content';
4
4
  import type { ComponentInfo } from '../types/components';
5
5
  import type { Dictionary, Nullable } from '../types/typescript';
6
+ import type { ComponentReference } from './component-reference-types';
6
7
  import type { ExtraContextTypes } from './extra-context-types';
7
8
  export type RegisteredComponent = ComponentInfo & {
8
- component: any;
9
+ component: ComponentReference;
9
10
  };
10
11
  export type RegisteredComponents = Dictionary<RegisteredComponent>;
11
12
  export type BuilderRenderState = Record<string, unknown>;
@@ -67,7 +67,7 @@ export const setIvm = (ivm, options = {}) => {
67
67
  setIsolateContext(options);
68
68
  };
69
69
  // only mention the script for SDKs that have it.
70
- const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === '@builder.io/sdk-react-nextjs' || SDK_NAME === '@builder.io/sdk-react' || SDK_NAME === '@builder.io/sdk-qwik';
70
+ const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === '@builder.io/sdk-react-nextjs' || SDK_NAME === '@builder.io/sdk-react' || SDK_NAME === '@builder.io/sdk-qwik' || SDK_NAME === '@builder.io/sdk-vue';
71
71
  const getIvm = () => {
72
72
  try {
73
73
  if (IVM_INSTANCE)
@@ -0,0 +1,19 @@
1
+ <script>export let load;
2
+ export let fallback;
3
+ export let props;
4
+ export let attributes;
5
+ </script>
6
+
7
+ {#await load()}
8
+ {#if fallback}
9
+ <svelte:component this={fallback} />
10
+ {/if}
11
+ {:then { default: Component }}
12
+ <svelte:component
13
+ this={Component}
14
+ {...props}
15
+ attributes={attributes}
16
+ >
17
+ <slot />
18
+ </svelte:component>
19
+ {/await}
@@ -0,0 +1,21 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ load: () => Promise<any>;
5
+ fallback: any;
6
+ props: any;
7
+ attributes: any;
8
+ };
9
+ events: {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {
13
+ default: {};
14
+ };
15
+ };
16
+ export type AwaiterProps = typeof __propDef.props;
17
+ export type AwaiterEvents = typeof __propDef.events;
18
+ export type AwaiterSlots = typeof __propDef.slots;
19
+ export default class Awaiter extends SvelteComponent<AwaiterProps, AwaiterEvents, AwaiterSlots> {
20
+ }
21
+ export {};
@@ -2,11 +2,12 @@
2
2
 
3
3
  <script>import { getBlockActions } from "../../../functions/get-block-actions";
4
4
  import { getBlockProperties } from "../../../functions/get-block-properties";
5
+ import Awaiter from "../../awaiter.svelte";
5
6
  export let includeBlockProps;
6
7
  export let block;
7
8
  export let context;
8
- export let wrapperProps;
9
9
  export let Wrapper;
10
+ export let wrapperProps;
10
11
  $: attributes = () => {
11
12
  return includeBlockProps
12
13
  ? {
@@ -26,6 +27,15 @@ $: attributes = () => {
26
27
  };
27
28
  </script>
28
29
 
29
- <svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
30
- ><slot /></svelte:component
31
- >
30
+ {#if Wrapper.load}
31
+ <Awaiter
32
+ load={Wrapper.load}
33
+ fallback={Wrapper.fallback}
34
+ props={wrapperProps}
35
+ attributes={attributes()}><slot /></Awaiter
36
+ >
37
+ {:else}
38
+ <svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
39
+ ><slot /></svelte:component
40
+ >
41
+ {/if}
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.16";
1
+ export declare const SDK_VERSION = "2.0.18";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.16";
1
+ export const SDK_VERSION = "2.0.18";
@@ -0,0 +1,15 @@
1
+ import type { SvelteComponent } from 'svelte';
2
+ export type ComponentReference = {
3
+ /**
4
+ * A dynamic import function pointing to the component.
5
+ * Example: `() => import('../components/my-component.svelte')`
6
+ * @returns A Promise that resolves to the loaded component.
7
+ */
8
+ load: () => Promise<{
9
+ default: typeof SvelteComponent<any>;
10
+ }>;
11
+ /**
12
+ * An optional fallback component to render while the dynamic component is loading.
13
+ */
14
+ fallback?: typeof SvelteComponent<any>;
15
+ } | typeof SvelteComponent<any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -3,9 +3,10 @@ import type { ApiVersion } from '../types/api-version';
3
3
  import type { BuilderContent } from '../types/builder-content';
4
4
  import type { ComponentInfo } from '../types/components';
5
5
  import type { Dictionary, Nullable } from '../types/typescript';
6
+ import type { ComponentReference } from './component-reference-types';
6
7
  import type { ExtraContextTypes } from './extra-context-types';
7
8
  export type RegisteredComponent = ComponentInfo & {
8
- component: any;
9
+ component: ComponentReference;
9
10
  };
10
11
  export type RegisteredComponents = Dictionary<RegisteredComponent>;
11
12
  export type BuilderRenderState = Record<string, unknown>;
@@ -67,7 +67,7 @@ export const setIvm = (ivm, options = {}) => {
67
67
  setIsolateContext(options);
68
68
  };
69
69
  // only mention the script for SDKs that have it.
70
- const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === '@builder.io/sdk-react-nextjs' || SDK_NAME === '@builder.io/sdk-react' || SDK_NAME === '@builder.io/sdk-qwik';
70
+ const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === '@builder.io/sdk-react-nextjs' || SDK_NAME === '@builder.io/sdk-react' || SDK_NAME === '@builder.io/sdk-qwik' || SDK_NAME === '@builder.io/sdk-vue';
71
71
  const getIvm = () => {
72
72
  try {
73
73
  if (IVM_INSTANCE)
@@ -0,0 +1,19 @@
1
+ <script>export let load;
2
+ export let fallback;
3
+ export let props;
4
+ export let attributes;
5
+ </script>
6
+
7
+ {#await load()}
8
+ {#if fallback}
9
+ <svelte:component this={fallback} />
10
+ {/if}
11
+ {:then { default: Component }}
12
+ <svelte:component
13
+ this={Component}
14
+ {...props}
15
+ attributes={attributes}
16
+ >
17
+ <slot />
18
+ </svelte:component>
19
+ {/await}
@@ -0,0 +1,21 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ load: () => Promise<any>;
5
+ fallback: any;
6
+ props: any;
7
+ attributes: any;
8
+ };
9
+ events: {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {
13
+ default: {};
14
+ };
15
+ };
16
+ export type AwaiterProps = typeof __propDef.props;
17
+ export type AwaiterEvents = typeof __propDef.events;
18
+ export type AwaiterSlots = typeof __propDef.slots;
19
+ export default class Awaiter extends SvelteComponent<AwaiterProps, AwaiterEvents, AwaiterSlots> {
20
+ }
21
+ export {};
@@ -2,11 +2,12 @@
2
2
 
3
3
  <script>import { getBlockActions } from "../../../functions/get-block-actions";
4
4
  import { getBlockProperties } from "../../../functions/get-block-properties";
5
+ import Awaiter from "../../awaiter.svelte";
5
6
  export let includeBlockProps;
6
7
  export let block;
7
8
  export let context;
8
- export let wrapperProps;
9
9
  export let Wrapper;
10
+ export let wrapperProps;
10
11
  $: attributes = () => {
11
12
  return includeBlockProps
12
13
  ? {
@@ -26,6 +27,15 @@ $: attributes = () => {
26
27
  };
27
28
  </script>
28
29
 
29
- <svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
30
- ><slot /></svelte:component
31
- >
30
+ {#if Wrapper.load}
31
+ <Awaiter
32
+ load={Wrapper.load}
33
+ fallback={Wrapper.fallback}
34
+ props={wrapperProps}
35
+ attributes={attributes()}><slot /></Awaiter
36
+ >
37
+ {:else}
38
+ <svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
39
+ ><slot /></svelte:component
40
+ >
41
+ {/if}
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.16";
1
+ export declare const SDK_VERSION = "2.0.18";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.16";
1
+ export const SDK_VERSION = "2.0.18";
@@ -0,0 +1,15 @@
1
+ import type { SvelteComponent } from 'svelte';
2
+ export type ComponentReference = {
3
+ /**
4
+ * A dynamic import function pointing to the component.
5
+ * Example: `() => import('../components/my-component.svelte')`
6
+ * @returns A Promise that resolves to the loaded component.
7
+ */
8
+ load: () => Promise<{
9
+ default: typeof SvelteComponent<any>;
10
+ }>;
11
+ /**
12
+ * An optional fallback component to render while the dynamic component is loading.
13
+ */
14
+ fallback?: typeof SvelteComponent<any>;
15
+ } | typeof SvelteComponent<any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -3,9 +3,10 @@ import type { ApiVersion } from '../types/api-version';
3
3
  import type { BuilderContent } from '../types/builder-content';
4
4
  import type { ComponentInfo } from '../types/components';
5
5
  import type { Dictionary, Nullable } from '../types/typescript';
6
+ import type { ComponentReference } from './component-reference-types';
6
7
  import type { ExtraContextTypes } from './extra-context-types';
7
8
  export type RegisteredComponent = ComponentInfo & {
8
- component: any;
9
+ component: ComponentReference;
9
10
  };
10
11
  export type RegisteredComponents = Dictionary<RegisteredComponent>;
11
12
  export type BuilderRenderState = Record<string, unknown>;
@@ -67,7 +67,7 @@ export const setIvm = (ivm, options = {}) => {
67
67
  setIsolateContext(options);
68
68
  };
69
69
  // only mention the script for SDKs that have it.
70
- const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === '@builder.io/sdk-react-nextjs' || SDK_NAME === '@builder.io/sdk-react' || SDK_NAME === '@builder.io/sdk-qwik';
70
+ const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === '@builder.io/sdk-react-nextjs' || SDK_NAME === '@builder.io/sdk-react' || SDK_NAME === '@builder.io/sdk-qwik' || SDK_NAME === '@builder.io/sdk-vue';
71
71
  const getIvm = () => {
72
72
  try {
73
73
  if (IVM_INSTANCE)
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.16",
4
+ "version": "2.0.18",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ export let load: () => Promise<any>;
3
+ export let fallback: any;
4
+ export let props: any;
5
+ export let attributes: any;
6
+ </script>
7
+
8
+ {#await load()}
9
+ {#if fallback}
10
+ <svelte:component this={fallback} />
11
+ {/if}
12
+ {:then { default: Component }}
13
+ <svelte:component
14
+ this={Component}
15
+ {...props}
16
+ attributes={attributes}
17
+ >
18
+ <slot />
19
+ </svelte:component>
20
+ {/await}
@@ -15,13 +15,14 @@
15
15
  import { getBlockProperties } from "../../../functions/get-block-properties";
16
16
  import type { BuilderBlock } from "../../../types/builder-block";
17
17
  import type { Dictionary } from "../../../types/typescript";
18
+ import Awaiter from "../../awaiter.svelte";
18
19
  import type { Writable } from "svelte/store";
19
20
 
20
21
  export let includeBlockProps: InteractiveElementProps["includeBlockProps"];
21
22
  export let block: InteractiveElementProps["block"];
22
23
  export let context: InteractiveElementProps["context"];
23
- export let wrapperProps: InteractiveElementProps["wrapperProps"];
24
24
  export let Wrapper: InteractiveElementProps["Wrapper"];
25
+ export let wrapperProps: InteractiveElementProps["wrapperProps"];
25
26
 
26
27
  $: attributes = () => {
27
28
  return includeBlockProps
@@ -42,6 +43,15 @@
42
43
  };
43
44
  </script>
44
45
 
45
- <svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
46
- ><slot /></svelte:component
47
- >
46
+ {#if Wrapper.load}
47
+ <Awaiter
48
+ load={Wrapper.load}
49
+ fallback={Wrapper.fallback}
50
+ props={wrapperProps}
51
+ attributes={attributes()}><slot /></Awaiter
52
+ >
53
+ {:else}
54
+ <svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
55
+ ><slot /></svelte:component
56
+ >
57
+ {/if}
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.16"
1
+ export const SDK_VERSION = "2.0.18"
@@ -0,0 +1,16 @@
1
+ import type { SvelteComponent } from 'svelte';
2
+
3
+ export type ComponentReference =
4
+ | {
5
+ /**
6
+ * A dynamic import function pointing to the component.
7
+ * Example: `() => import('../components/my-component.svelte')`
8
+ * @returns A Promise that resolves to the loaded component.
9
+ */
10
+ load: () => Promise<{ default: typeof SvelteComponent<any> }>;
11
+ /**
12
+ * An optional fallback component to render while the dynamic component is loading.
13
+ */
14
+ fallback?: typeof SvelteComponent<any>;
15
+ }
16
+ | typeof SvelteComponent<any>;
@@ -3,9 +3,10 @@ import type { ApiVersion } from '../types/api-version';
3
3
  import type { BuilderContent } from '../types/builder-content';
4
4
  import type { ComponentInfo } from '../types/components';
5
5
  import type { Dictionary, Nullable } from '../types/typescript';
6
+ import type { ComponentReference } from './component-reference-types';
6
7
  import type { ExtraContextTypes } from './extra-context-types';
7
8
  export type RegisteredComponent = ComponentInfo & {
8
- component: any;
9
+ component: ComponentReference;
9
10
  };
10
11
  export type RegisteredComponents = Dictionary<RegisteredComponent>;
11
12
  export type BuilderRenderState = Record<string, unknown>;
@@ -80,7 +80,7 @@ export const setIvm = (ivm: IsolatedVMImport, options: IsolateOptions = {}) => {
80
80
  };
81
81
 
82
82
  // only mention the script for SDKs that have it.
83
- const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === '@builder.io/sdk-react-nextjs' || SDK_NAME === '@builder.io/sdk-react' || SDK_NAME === '@builder.io/sdk-qwik';
83
+ const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === '@builder.io/sdk-react-nextjs' || SDK_NAME === '@builder.io/sdk-react' || SDK_NAME === '@builder.io/sdk-qwik' || SDK_NAME === '@builder.io/sdk-vue';
84
84
  const getIvm = (): IsolatedVMImport => {
85
85
  try {
86
86
  if (IVM_INSTANCE) return IVM_INSTANCE;