@builder.io/sdk-svelte 1.0.23 → 1.0.25

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 (142) hide show
  1. package/README.md +2 -2
  2. package/lib/browser/blocks/button/button.svelte +16 -15
  3. package/lib/browser/blocks/columns/columns.svelte +32 -24
  4. package/lib/browser/blocks/columns/columns.svelte.d.ts +1 -1
  5. package/lib/browser/blocks/columns/columns.types.d.ts +1 -1
  6. package/lib/browser/blocks/columns/helpers.d.ts +1 -0
  7. package/lib/browser/blocks/columns/helpers.js +3 -0
  8. package/lib/browser/blocks/image/image.svelte +1 -1
  9. package/lib/browser/blocks/symbol/symbol.helpers.js +1 -1
  10. package/lib/browser/blocks/symbol/symbol.svelte +9 -2
  11. package/lib/browser/blocks/tabs/component-info.d.ts +2 -0
  12. package/lib/browser/blocks/tabs/component-info.js +138 -0
  13. package/lib/browser/blocks/tabs/index.d.ts +1 -0
  14. package/lib/browser/blocks/tabs/index.js +1 -0
  15. package/lib/browser/blocks/tabs/tabs.svelte +76 -0
  16. package/lib/browser/blocks/tabs/tabs.svelte.d.ts +25 -0
  17. package/lib/browser/blocks/tabs/tabs.types.d.ts +13 -0
  18. package/lib/browser/blocks/tabs/tabs.types.js +1 -0
  19. package/lib/browser/blocks/text/text.types.d.ts +2 -1
  20. package/lib/browser/components/block/block.helpers.d.ts +4 -2
  21. package/lib/browser/components/block/block.helpers.js +6 -0
  22. package/lib/browser/components/block/block.svelte +4 -8
  23. package/lib/browser/components/block/components/interactive-element.svelte +20 -19
  24. package/lib/browser/components/content/components/enable-editor.svelte +13 -8
  25. package/lib/browser/components/content/components/enable-editor.svelte.d.ts +1 -1
  26. package/lib/browser/components/content/components/styles.helpers.d.ts +1 -0
  27. package/lib/browser/components/content/components/styles.helpers.js +3 -0
  28. package/lib/browser/components/content/content.svelte +1 -0
  29. package/lib/browser/components/dynamic-div.svelte +5 -0
  30. package/lib/browser/constants/builder-registered-components.js +7 -1
  31. package/lib/browser/constants/sdk-version.d.ts +1 -1
  32. package/lib/browser/constants/sdk-version.js +1 -1
  33. package/lib/browser/functions/evaluate/node-runtime/init.d.ts +17 -1
  34. package/lib/browser/functions/evaluate/node-runtime/init.js +2 -2
  35. package/lib/browser/functions/evaluate/node-runtime/node-runtime.d.ts +4 -1
  36. package/lib/browser/functions/evaluate/node-runtime/node-runtime.js +29 -18
  37. package/lib/browser/functions/get-class-prop-name.js +1 -0
  38. package/lib/browser/functions/get-style.js +1 -0
  39. package/lib/browser/types/targets.d.ts +1 -1
  40. package/lib/edge/blocks/button/button.svelte +16 -15
  41. package/lib/edge/blocks/columns/columns.svelte +32 -24
  42. package/lib/edge/blocks/columns/columns.svelte.d.ts +1 -1
  43. package/lib/edge/blocks/columns/columns.types.d.ts +1 -1
  44. package/lib/edge/blocks/columns/helpers.d.ts +1 -0
  45. package/lib/edge/blocks/columns/helpers.js +3 -0
  46. package/lib/edge/blocks/image/image.svelte +1 -1
  47. package/lib/edge/blocks/symbol/symbol.helpers.js +1 -1
  48. package/lib/edge/blocks/symbol/symbol.svelte +9 -2
  49. package/lib/edge/blocks/tabs/component-info.d.ts +2 -0
  50. package/lib/edge/blocks/tabs/component-info.js +138 -0
  51. package/lib/edge/blocks/tabs/index.d.ts +1 -0
  52. package/lib/edge/blocks/tabs/index.js +1 -0
  53. package/lib/edge/blocks/tabs/tabs.svelte +76 -0
  54. package/lib/edge/blocks/tabs/tabs.svelte.d.ts +25 -0
  55. package/lib/edge/blocks/tabs/tabs.types.d.ts +13 -0
  56. package/lib/edge/blocks/tabs/tabs.types.js +1 -0
  57. package/lib/edge/blocks/text/text.types.d.ts +2 -1
  58. package/lib/edge/components/block/block.helpers.d.ts +4 -2
  59. package/lib/edge/components/block/block.helpers.js +6 -0
  60. package/lib/edge/components/block/block.svelte +4 -8
  61. package/lib/edge/components/block/components/interactive-element.svelte +20 -19
  62. package/lib/edge/components/content/components/enable-editor.svelte +13 -8
  63. package/lib/edge/components/content/components/enable-editor.svelte.d.ts +1 -1
  64. package/lib/edge/components/content/components/styles.helpers.d.ts +1 -0
  65. package/lib/edge/components/content/components/styles.helpers.js +3 -0
  66. package/lib/edge/components/content/content.svelte +1 -0
  67. package/lib/edge/components/dynamic-div.svelte +5 -0
  68. package/lib/edge/constants/builder-registered-components.js +7 -1
  69. package/lib/edge/constants/sdk-version.d.ts +1 -1
  70. package/lib/edge/constants/sdk-version.js +1 -1
  71. package/lib/edge/functions/evaluate/node-runtime/init.d.ts +17 -1
  72. package/lib/edge/functions/evaluate/node-runtime/init.js +2 -2
  73. package/lib/edge/functions/evaluate/node-runtime/node-runtime.d.ts +4 -1
  74. package/lib/edge/functions/evaluate/node-runtime/node-runtime.js +29 -18
  75. package/lib/edge/functions/get-class-prop-name.js +1 -0
  76. package/lib/edge/functions/get-style.js +1 -0
  77. package/lib/edge/types/targets.d.ts +1 -1
  78. package/lib/node/blocks/button/button.svelte +16 -15
  79. package/lib/node/blocks/columns/columns.svelte +32 -24
  80. package/lib/node/blocks/columns/columns.svelte.d.ts +1 -1
  81. package/lib/node/blocks/columns/columns.types.d.ts +1 -1
  82. package/lib/node/blocks/columns/helpers.d.ts +1 -0
  83. package/lib/node/blocks/columns/helpers.js +3 -0
  84. package/lib/node/blocks/image/image.svelte +1 -1
  85. package/lib/node/blocks/symbol/symbol.helpers.js +1 -1
  86. package/lib/node/blocks/symbol/symbol.svelte +9 -2
  87. package/lib/node/blocks/tabs/component-info.d.ts +2 -0
  88. package/lib/node/blocks/tabs/component-info.js +138 -0
  89. package/lib/node/blocks/tabs/index.d.ts +1 -0
  90. package/lib/node/blocks/tabs/index.js +1 -0
  91. package/lib/node/blocks/tabs/tabs.svelte +76 -0
  92. package/lib/node/blocks/tabs/tabs.svelte.d.ts +25 -0
  93. package/lib/node/blocks/tabs/tabs.types.d.ts +13 -0
  94. package/lib/node/blocks/tabs/tabs.types.js +1 -0
  95. package/lib/node/blocks/text/text.types.d.ts +2 -1
  96. package/lib/node/components/block/block.helpers.d.ts +4 -2
  97. package/lib/node/components/block/block.helpers.js +6 -0
  98. package/lib/node/components/block/block.svelte +4 -8
  99. package/lib/node/components/block/components/interactive-element.svelte +20 -19
  100. package/lib/node/components/content/components/enable-editor.svelte +13 -8
  101. package/lib/node/components/content/components/enable-editor.svelte.d.ts +1 -1
  102. package/lib/node/components/content/components/styles.helpers.d.ts +1 -0
  103. package/lib/node/components/content/components/styles.helpers.js +3 -0
  104. package/lib/node/components/content/content.svelte +1 -0
  105. package/lib/node/components/dynamic-div.svelte +5 -0
  106. package/lib/node/constants/builder-registered-components.js +7 -1
  107. package/lib/node/constants/sdk-version.d.ts +1 -1
  108. package/lib/node/constants/sdk-version.js +1 -1
  109. package/lib/node/functions/evaluate/node-runtime/init.d.ts +17 -1
  110. package/lib/node/functions/evaluate/node-runtime/init.js +2 -2
  111. package/lib/node/functions/evaluate/node-runtime/node-runtime.d.ts +4 -1
  112. package/lib/node/functions/evaluate/node-runtime/node-runtime.js +29 -18
  113. package/lib/node/functions/get-class-prop-name.js +1 -0
  114. package/lib/node/functions/get-style.js +1 -0
  115. package/lib/node/types/targets.d.ts +1 -1
  116. package/package.json +1 -1
  117. package/src/blocks/button/button.svelte +19 -15
  118. package/src/blocks/columns/columns.svelte +34 -26
  119. package/src/blocks/columns/columns.types.ts +1 -1
  120. package/src/blocks/columns/helpers.ts +3 -0
  121. package/src/blocks/image/image.svelte +1 -1
  122. package/src/blocks/symbol/symbol.helpers.ts +1 -1
  123. package/src/blocks/symbol/symbol.svelte +9 -2
  124. package/src/blocks/tabs/component-info.ts +139 -0
  125. package/src/blocks/tabs/index.ts +1 -0
  126. package/src/blocks/tabs/tabs.svelte +83 -0
  127. package/src/blocks/tabs/tabs.types.ts +13 -0
  128. package/src/blocks/text/text.types.ts +2 -1
  129. package/src/components/block/block.helpers.ts +7 -1
  130. package/src/components/block/block.svelte +5 -7
  131. package/src/components/block/components/interactive-element.svelte +21 -19
  132. package/src/components/content/components/enable-editor.svelte +13 -8
  133. package/src/components/content/components/styles.helpers.ts +3 -0
  134. package/src/components/content/content.svelte +1 -0
  135. package/src/components/dynamic-div.svelte +19 -0
  136. package/src/constants/builder-registered-components.ts +7 -1
  137. package/src/constants/sdk-version.ts +1 -1
  138. package/src/functions/evaluate/node-runtime/init.ts +7 -2
  139. package/src/functions/evaluate/node-runtime/node-runtime.ts +34 -21
  140. package/src/functions/get-class-prop-name.ts +1 -0
  141. package/src/functions/get-style.ts +1 -0
  142. package/src/types/targets.ts +1 -1
@@ -0,0 +1 @@
1
+ export { default } from './tabs.svelte';
@@ -0,0 +1,76 @@
1
+ <script>import Blocks from "../../components/blocks/blocks.svelte";
2
+ export let defaultActiveTab = undefined;
3
+ export let tabs;
4
+ export let activeTabStyle = undefined;
5
+ export let tabHeaderLayout = undefined;
6
+ export let collapsible = undefined;
7
+ export let builderBlock;
8
+ export let builderContext;
9
+ export let builderComponents;
10
+ export let builderLinkComponent = undefined;
11
+ function stringifyStyles(stylesObj) {
12
+ let styles = "";
13
+ for (let key in stylesObj) {
14
+ const dashedKey = key.replace(/[A-Z]/g, function (match) {
15
+ return "-" + match.toLowerCase();
16
+ });
17
+ styles += dashedKey + ":" + stylesObj[key] + ";";
18
+ }
19
+ return styles;
20
+ }
21
+ function activeTabContent(active) {
22
+ return tabs && tabs[active].content;
23
+ }
24
+ function getActiveTabStyle(index) {
25
+ return activeTab === index ? activeTabStyle : {};
26
+ }
27
+ let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
28
+ </script>
29
+
30
+ <div>
31
+ <div
32
+ style={stringifyStyles({
33
+ display: "flex",
34
+ flexDirection: "row",
35
+ justifyContent: tabHeaderLayout || "flex-start",
36
+ overflow: "auto",
37
+ })}
38
+ class="builder-tabs-wrap"
39
+ >
40
+ {#each tabs as tab, index (index)}
41
+ <span
42
+ style={stringifyStyles(getActiveTabStyle(index))}
43
+ class={`builder-tab-wrap ${
44
+ activeTab === index ? "builder-tab-active" : ""
45
+ }`}
46
+ on:click={(event) => {
47
+ if (index === activeTab && collapsible) {
48
+ activeTab = -1;
49
+ } else {
50
+ activeTab = index;
51
+ }
52
+ }}
53
+ ><Blocks
54
+ parent={builderBlock.id}
55
+ path={`component.options.tabs.${index}.label`}
56
+ blocks={tab.label}
57
+ context={builderContext}
58
+ registeredComponents={builderComponents}
59
+ linkComponent={builderLinkComponent}
60
+ /></span
61
+ >
62
+ {/each}
63
+ </div>
64
+ {#if activeTabContent(activeTab)}
65
+ <div>
66
+ <Blocks
67
+ parent={builderBlock.id}
68
+ path={`component.options.tabs.${activeTab}.content`}
69
+ blocks={activeTabContent(activeTab)}
70
+ context={builderContext}
71
+ registeredComponents={builderComponents}
72
+ linkComponent={builderLinkComponent}
73
+ />
74
+ </div>
75
+ {/if}
76
+ </div>
@@ -0,0 +1,25 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { TabsProps } from "./tabs.types";
3
+ declare const __propDef: {
4
+ props: {
5
+ defaultActiveTab?: TabsProps["defaultActiveTab"];
6
+ tabs: TabsProps["tabs"];
7
+ activeTabStyle?: TabsProps["activeTabStyle"];
8
+ tabHeaderLayout?: TabsProps["tabHeaderLayout"];
9
+ collapsible?: TabsProps["collapsible"];
10
+ builderBlock: TabsProps["builderBlock"];
11
+ builderContext: TabsProps["builderContext"];
12
+ builderComponents: TabsProps["builderComponents"];
13
+ builderLinkComponent?: TabsProps["builderLinkComponent"];
14
+ };
15
+ events: {
16
+ [evt: string]: CustomEvent<any>;
17
+ };
18
+ slots: {};
19
+ };
20
+ type TabsProps_ = typeof __propDef.props;
21
+ export { TabsProps_ as TabsProps };
22
+ export type TabsEvents = typeof __propDef.events;
23
+ export type TabsSlots = typeof __propDef.slots;
24
+ export default class Tabs extends SvelteComponent<TabsProps, TabsEvents, TabsSlots> {
25
+ }
@@ -0,0 +1,13 @@
1
+ import type { BuilderBlock } from '../../types/builder-block';
2
+ import type { BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp } from '../../types/builder-props';
3
+ export interface TabsProps extends BuilderComponentsProp, BuilderLinkComponentProp, BuilderDataProps {
4
+ tabs: {
5
+ label: BuilderBlock[];
6
+ content: BuilderBlock[];
7
+ }[];
8
+ builderBlock: BuilderBlock;
9
+ defaultActiveTab?: number;
10
+ collapsible?: boolean;
11
+ tabHeaderLayout?: 'center' | 'flex-start' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly';
12
+ activeTabStyle?: any;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { BuilderDataProps } from '../../types/builder-props';
1
2
  export type TextProps = {
2
3
  text?: string;
3
- };
4
+ } & BuilderDataProps;
@@ -1,11 +1,11 @@
1
- import type { BuilderContextInterface, RegisteredComponents } from '../../context/types';
1
+ import type { BuilderContextInterface, RegisteredComponent, RegisteredComponents } from '../../context/types';
2
2
  import type { BuilderBlock } from '../../types/builder-block';
3
3
  import type { RepeatData } from './types';
4
4
  export declare const getComponent: ({ block, context, registeredComponents }: {
5
5
  block: BuilderBlock;
6
6
  context: BuilderContextInterface;
7
7
  registeredComponents: RegisteredComponents;
8
- }) => import("../../context/types").RegisteredComponent | null | undefined;
8
+ }) => RegisteredComponent | null | undefined;
9
9
  export declare const getRepeatItemData: ({ block, context }: {
10
10
  block: BuilderBlock;
11
11
  context: BuilderContextInterface;
@@ -14,3 +14,5 @@ export declare const getInheritedStyles: ({ block, context }: {
14
14
  block: BuilderBlock;
15
15
  context: BuilderContextInterface;
16
16
  }) => Partial<CSSStyleDeclaration>;
17
+ export declare const shouldPassLinkComponent: (block: RegisteredComponent | null | undefined) => boolean | null | undefined;
18
+ export declare const shouldPassRegisteredComponents: (block: RegisteredComponent | null | undefined) => boolean | null | undefined;
@@ -73,3 +73,9 @@ export const getInheritedStyles = ({ block, context }) => {
73
73
  }
74
74
  return extractTextStyles(style);
75
75
  };
76
+ export const shouldPassLinkComponent = (block) => {
77
+ return block && (block.isRSC || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs'].includes(block.name));
78
+ };
79
+ export const shouldPassRegisteredComponents = (block) => {
80
+ return block && (block.isRSC || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs'].includes(block.name));
81
+ };
@@ -4,11 +4,12 @@
4
4
  import { getBlockComponentOptions } from "../../functions/get-block-component-options";
5
5
  import { getProcessedBlock } from "../../functions/get-processed-block";
6
6
  import { bindAnimations } from "./animator";
7
- import { getComponent, getRepeatItemData, } from "./block.helpers";
7
+ import { getComponent, getRepeatItemData, shouldPassLinkComponent, shouldPassRegisteredComponents, } from "./block.helpers";
8
8
  import BlockStyles from "./components/block-styles.svelte";
9
9
  import BlockWrapper from "./components/block-wrapper.svelte";
10
10
  import ComponentRef from "./components/component-ref/component-ref.svelte";
11
11
  import RepeatedBlock from "./components/repeated-block.svelte";
12
+ import "../dynamic-div.svelte";
12
13
  export let block;
13
14
  export let context;
14
15
  export let registeredComponents;
@@ -76,17 +77,12 @@ $: componentRefProps = () => {
76
77
  componentOptions: {
77
78
  ...getBlockComponentOptions(processedBlock()),
78
79
  builderContext: context,
79
- ...(blockComponent?.()?.name === "Core:Button" ||
80
- blockComponent?.()?.name === "Symbol" ||
81
- blockComponent?.()?.name === "Columns" ||
82
- blockComponent?.()?.name === "Form:Form"
80
+ ...(shouldPassLinkComponent(blockComponent())
83
81
  ? {
84
82
  builderLinkComponent: linkComponent,
85
83
  }
86
84
  : {}),
87
- ...(blockComponent?.()?.name === "Symbol" ||
88
- blockComponent?.()?.name === "Columns" ||
89
- blockComponent?.()?.name === "Form:Form"
85
+ ...(shouldPassRegisteredComponents(blockComponent())
90
86
  ? {
91
87
  builderComponents: registeredComponents,
92
88
  }
@@ -2,29 +2,30 @@
2
2
 
3
3
  <script>import { getBlockActions } from "../../../functions/get-block-actions";
4
4
  import { getBlockProperties } from "../../../functions/get-block-properties";
5
- export let wrapperProps;
6
5
  export let includeBlockProps;
7
6
  export let block;
8
7
  export let context;
8
+ export let wrapperProps;
9
9
  export let Wrapper;
10
+ $: attributes = () => {
11
+ return includeBlockProps
12
+ ? {
13
+ ...getBlockProperties({
14
+ block: block,
15
+ context: $context,
16
+ }),
17
+ ...getBlockActions({
18
+ block: block,
19
+ rootState: $context.rootState,
20
+ rootSetState: $context.rootSetState,
21
+ localState: $context.localState,
22
+ context: $context.context,
23
+ }),
24
+ }
25
+ : {};
26
+ };
10
27
  </script>
11
28
 
12
- <svelte:component
13
- this={Wrapper}
14
- {...wrapperProps}
15
- attributes={includeBlockProps
16
- ? {
17
- ...getBlockProperties({
18
- block: block,
19
- context: $context,
20
- }),
21
- ...getBlockActions({
22
- block: block,
23
- rootState: $context.rootState,
24
- rootSetState: $context.rootSetState,
25
- localState: $context.localState,
26
- context: $context.context,
27
- }),
28
- }
29
- : {}}><slot /></svelte:component
29
+ <svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
30
+ ><slot /></svelte:component
30
31
  >
@@ -18,6 +18,8 @@ import "../../../helpers/preview-lru-cache/set";
18
18
  import { createEditorListener } from "../../../helpers/subscribe-to-editor";
19
19
  import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing";
20
20
  import { triggerAnimation } from "../../block/animator";
21
+ import { getWrapperClassName } from "./styles.helpers";
22
+ import "../../dynamic-div.svelte";
21
23
  export let builderContextSignal;
22
24
  export let canTrack = undefined;
23
25
  export let apiKey;
@@ -27,9 +29,9 @@ export let trustedHosts = undefined;
27
29
  export let model = undefined;
28
30
  export let content = undefined;
29
31
  export let data = undefined;
32
+ export let showContent;
30
33
  export let contentWrapper = undefined;
31
34
  export let context = undefined;
32
- export let showContent;
33
35
  export let contentWrapperProps = undefined;
34
36
  function mergeNewRootState(newData) {
35
37
  const combinedState = {
@@ -224,6 +226,14 @@ function elementRef_onInitpreviewingbldr(event) {
224
226
  });
225
227
  }
226
228
  }
229
+ $: showContentProps = () => {
230
+ return showContent
231
+ ? {}
232
+ : {
233
+ hidden: true,
234
+ "aria-hidden": true,
235
+ };
236
+ };
227
237
  let elementRef;
228
238
  let ContentWrapper = contentWrapper || "div";
229
239
  let httpReqsData = {};
@@ -326,14 +336,9 @@ onDestroy(() => {
326
336
  builder-content-id={$builderContextSignal.content?.id}
327
337
  builder-model={model}
328
338
  {...{}}
329
- {...showContent
330
- ? {}
331
- : {
332
- hidden: true,
333
- "aria-hidden": true,
334
- }}
339
+ {...showContentProps()}
335
340
  {...contentWrapperProps}
336
- class={`variant-${content?.testVariationId || content?.id}`}
341
+ class={getWrapperClassName(content?.testVariationId || content?.id)}
337
342
  on:initeditingbldr={(event) => {
338
343
  elementRef_onIniteditingbldr(event);
339
344
  }}
@@ -18,9 +18,9 @@ declare const __propDef: {
18
18
  model?: BuilderEditorProps["model"];
19
19
  content?: BuilderEditorProps["content"];
20
20
  data?: BuilderEditorProps["data"];
21
+ showContent: BuilderEditorProps["showContent"];
21
22
  contentWrapper?: BuilderEditorProps["contentWrapper"];
22
23
  context?: BuilderEditorProps["context"];
23
- showContent: BuilderEditorProps["showContent"];
24
24
  contentWrapperProps?: BuilderEditorProps["contentWrapperProps"];
25
25
  };
26
26
  events: {
@@ -14,3 +14,4 @@ export declare const getCss: ({ cssCode, contentId }: {
14
14
  contentId?: string | undefined;
15
15
  }) => string;
16
16
  export declare const getDefaultStyles: (isNested: boolean | undefined) => "" | "\n.builder-button {\n all: unset;\n}\n\n.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {\n margin: 0;\n}\n.builder-text > p, .builder-text > .builder-paragraph {\n color: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n font-weight: inherit;\n font-size: inherit;\n text-align: inherit;\n font-family: inherit;\n}\n";
17
+ export declare const getWrapperClassName: (variationId?: string) => string;
@@ -77,3 +77,6 @@ const DEFAULT_STYLES = `
77
77
  export const getDefaultStyles = (isNested) => {
78
78
  return !isNested ? DEFAULT_STYLES : '';
79
79
  };
80
+ export const getWrapperClassName = (variationId) => {
81
+ return `variant-${variationId}`;
82
+ };
@@ -11,6 +11,7 @@ import EnableEditor from "./components/enable-editor.svelte";
11
11
  import ContentStyles from "./components/styles.svelte";
12
12
  import { getContentInitialValue, getRootStateInitialValue, } from "./content.helpers";
13
13
  import "./wrap-component-ref";
14
+ import "../dynamic-div.svelte";
14
15
  export let content = undefined;
15
16
  export let customComponents = undefined;
16
17
  export let data = undefined;
@@ -0,0 +1,5 @@
1
+ <script context="module"></script>
2
+
3
+ <script></script>
4
+
5
+ <div><slot /></div>
@@ -12,9 +12,12 @@ import { componentInfo as slotComponentInfo } from '../blocks/slot/component-inf
12
12
  import { default as Slot } from '../blocks/slot/index';
13
13
  import { componentInfo as symbolComponentInfo } from '../blocks/symbol/component-info';
14
14
  import { default as Symbol } from '../blocks/symbol/index';
15
+ import { componentInfo as tabsComponentInfo } from '../blocks/tabs/component-info';
16
+ import { default as Tabs } from '../blocks/tabs/index';
15
17
  import { componentInfo as textComponentInfo } from '../blocks/text/component-info';
16
18
  import { default as Text } from '../blocks/text/index';
17
19
  import { getExtraComponents } from './extra-components';
20
+ import { TARGET } from './target';
18
21
  /**
19
22
  * Returns a list of all registered components.
20
23
  * NOTE: This needs to be a function to work around ESM circular dependencies.
@@ -43,4 +46,7 @@ export const getDefaultRegisteredComponents = () => [{
43
46
  }, {
44
47
  component: Text,
45
48
  ...textComponentInfo
46
- }, ...getExtraComponents()];
49
+ }, ...(TARGET === 'rsc' ? [] : [{
50
+ component: Tabs,
51
+ ...tabsComponentInfo
52
+ }]), ...getExtraComponents()];
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.0.23";
1
+ export declare const SDK_VERSION = "1.0.25";
@@ -1 +1 @@
1
- export const SDK_VERSION = "1.0.23";
1
+ export const SDK_VERSION = "1.0.25";
@@ -1,3 +1,17 @@
1
+ /**
2
+ * This file:
3
+ * - imports `isolated-vm`, which can only be made from a file that never runs
4
+ * on the client (e.g. Next's `_document.tsx`)
5
+ * - stores the ivm instance in a global variable using `setIvm`
6
+ *
7
+ * This is needed for when bundlers/meta-frameworks are not able to reliably
8
+ * import the `isolated-vm` package using our `safeDynamicRequire` trick.
9
+ *
10
+ * The `isolated-vm` import must exist in this separate file, or it will end up
11
+ * in the SDK's main entry point, causing errors for users.
12
+ */
13
+ import ivm from 'isolated-vm';
14
+ import type { IsolateOptions } from 'isolated-vm';
1
15
  /**
2
16
  * This function initializes the SDK on a Node server. It handles importing the
3
17
  * `isolated-vm` package which is needed for dynamic bindings.
@@ -7,4 +21,6 @@
7
21
  * - The NextJS Pages router's `_document.tsx`
8
22
  * - Your Remix route's `loader`
9
23
  */
10
- export declare const initializeNodeRuntime: () => void;
24
+ export declare const initializeNodeRuntime: ({ ivmIsolateOptions }: {
25
+ ivmIsolateOptions?: ivm.IsolateOptions | undefined;
26
+ }) => void;
@@ -21,6 +21,6 @@ import { setIvm } from './node-runtime';
21
21
  * - The NextJS Pages router's `_document.tsx`
22
22
  * - Your Remix route's `loader`
23
23
  */
24
- export const initializeNodeRuntime = () => {
25
- setIvm(ivm);
24
+ export const initializeNodeRuntime = ({ ivmIsolateOptions }) => {
25
+ setIvm(ivm, ivmIsolateOptions);
26
26
  };
@@ -1,8 +1,11 @@
1
+ import type { IsolateOptions } from 'isolated-vm';
1
2
  import type { ExecutorArgs } from '../helpers';
3
+ type IsolatedVMImport = typeof import('isolated-vm');
2
4
  /**
3
5
  * Set the `isolated-vm` instance to be used by the node runtime.
4
6
  * This is useful for environments that are not able to rely on our
5
7
  * `safeDynamicRequire` trick to import the `isolated-vm` package.
6
8
  */
7
- export declare const setIvm: (ivm: typeof import('isolated-vm')) => void;
9
+ export declare const setIvm: (ivm: IsolatedVMImport, options?: IsolateOptions) => void;
8
10
  export declare const runInNode: ({ code, builder, context, event, localState, rootSetState, rootState }: ExecutorArgs) => any;
11
+ export {};
@@ -45,23 +45,25 @@ function theFunction() {
45
45
  ${code}
46
46
  }
47
47
 
48
- let output = theFunction()
48
+ const output = theFunction()
49
49
 
50
50
  if (typeof output === 'object' && output !== null) {
51
- output = JSON.stringify(output.copySync ? output.copySync() : output);
51
+ return JSON.stringify(output.copySync ? output.copySync() : output);
52
+ } else {
53
+ return output;
52
54
  }
53
-
54
- output;
55
55
  `;
56
56
  };
57
57
  let IVM_INSTANCE = null;
58
+ let IVM_CONTEXT = null;
58
59
  /**
59
60
  * Set the `isolated-vm` instance to be used by the node runtime.
60
61
  * This is useful for environments that are not able to rely on our
61
62
  * `safeDynamicRequire` trick to import the `isolated-vm` package.
62
63
  */
63
- export const setIvm = (ivm) => {
64
+ export const setIvm = (ivm, options = {}) => {
64
65
  IVM_INSTANCE = ivm;
66
+ setIsolateContext(options);
65
67
  };
66
68
  const getIvm = () => {
67
69
  try {
@@ -83,12 +85,29 @@ const getIvm = () => {
83
85
  Please see the documentation for more information: https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments
84
86
  `);
85
87
  };
86
- const getIsolateContext = () => {
88
+ function setIsolateContext(options = {
89
+ memoryLimit: 128
90
+ }) {
87
91
  const ivm = getIvm();
88
- const isolate = new ivm.Isolate({
89
- memoryLimit: 128
92
+ const isolate = new ivm.Isolate(options);
93
+ const context = isolate.createContextSync();
94
+ const jail = context.global;
95
+ // This makes the global object available in the context as `global`. We use `derefInto()` here
96
+ // because otherwise `global` would actually be a Reference{} object in the new isolate.
97
+ jail.setSync('global', jail.derefInto());
98
+ // We will create a basic `log` function for the new isolate to use.
99
+ jail.setSync('log', function (...logArgs) {
100
+ console.log(...logArgs);
90
101
  });
91
- return isolate.createContextSync();
102
+ jail.setSync(INJECTED_IVM_GLOBAL, ivm);
103
+ IVM_CONTEXT = context;
104
+ return context;
105
+ }
106
+ const getIsolateContext = () => {
107
+ if (IVM_CONTEXT)
108
+ return IVM_CONTEXT;
109
+ const context = setIsolateContext();
110
+ return context;
92
111
  };
93
112
  export const runInNode = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
94
113
  const ivm = getIvm();
@@ -104,13 +123,6 @@ export const runInNode = ({ code, builder, context, event, localState, rootSetSt
104
123
  });
105
124
  const isolateContext = getIsolateContext();
106
125
  const jail = isolateContext.global;
107
- // This makes the global object available in the context as `global`. We use `derefInto()` here
108
- // because otherwise `global` would actually be a Reference{} object in the new isolate.
109
- jail.setSync('global', jail.derefInto());
110
- // We will create a basic `log` function for the new isolate to use.
111
- jail.setSync('log', function (...logArgs) {
112
- console.log(...logArgs);
113
- });
114
126
  /**
115
127
  * Propagate state changes back to the reactive root state.
116
128
  */
@@ -130,12 +142,11 @@ export const runInNode = ({ code, builder, context, event, localState, rootSetSt
130
142
  } : arg) : null;
131
143
  jail.setSync(getSyncValName(key), val);
132
144
  });
133
- jail.setSync(INJECTED_IVM_GLOBAL, ivm);
134
145
  const evalStr = processCode({
135
146
  code,
136
147
  args
137
148
  });
138
- const resultStr = isolateContext.evalSync(evalStr);
149
+ const resultStr = isolateContext.evalClosureSync(evalStr);
139
150
  try {
140
151
  // returning objects throw errors in isolated vm, so we stringify it and parse it back
141
152
  const res = JSON.parse(resultStr);
@@ -9,6 +9,7 @@ export const getClassPropName = () => {
9
9
  case 'vue':
10
10
  case 'solid':
11
11
  case 'qwik':
12
+ case 'angular':
12
13
  return 'class';
13
14
  }
14
15
  };
@@ -18,6 +18,7 @@ export function mapStyleObjToStrIfNeeded(style) {
18
18
  case 'svelte':
19
19
  case 'vue':
20
20
  case 'solid':
21
+ case 'angular':
21
22
  return convertStyleMapToCSSArray(style).join(' ');
22
23
  case 'qwik':
23
24
  case 'reactNative':
@@ -1 +1 @@
1
- export type Target = 'vue' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
1
+ export type Target = 'vue' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc' | 'angular';
@@ -6,24 +6,25 @@ export let link = undefined;
6
6
  export let openLinkInNewTab = undefined;
7
7
  export let builderLinkComponent = undefined;
8
8
  export let text = undefined;
9
+ function attrs() {
10
+ return {
11
+ ...filterAttrs(attributes, "on:", false),
12
+ [getClassPropName()]: `${link ? "" : "builder-button"} ${attributes[getClassPropName()] || ""}`,
13
+ ...(link
14
+ ? {
15
+ href: link,
16
+ target: openLinkInNewTab ? "_blank" : undefined,
17
+ role: "link",
18
+ }
19
+ : {
20
+ role: "button",
21
+ }),
22
+ };
23
+ }
9
24
  </script>
10
25
 
11
26
  <DynamicRenderer
12
- attributes={{
13
- ...filterAttrs(attributes, "on:", false),
14
- [getClassPropName()]: `${link ? "" : "builder-button"} ${
15
- attributes[getClassPropName()] || ""
16
- }`,
17
- ...(link
18
- ? {
19
- href: link,
20
- target: openLinkInNewTab ? "_blank" : undefined,
21
- role: "link",
22
- }
23
- : {
24
- role: "button",
25
- }),
26
- }}
27
+ attributes={attrs()}
27
28
  TagName={link ? builderLinkComponent || "a" : "button"}
28
29
  actionAttributes={filterAttrs(attributes, "on:", true)}
29
30
  >{text}</DynamicRenderer