@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.
- package/README.md +2 -2
- package/lib/browser/blocks/button/button.svelte +16 -15
- package/lib/browser/blocks/columns/columns.svelte +32 -24
- package/lib/browser/blocks/columns/columns.svelte.d.ts +1 -1
- package/lib/browser/blocks/columns/columns.types.d.ts +1 -1
- package/lib/browser/blocks/columns/helpers.d.ts +1 -0
- package/lib/browser/blocks/columns/helpers.js +3 -0
- package/lib/browser/blocks/image/image.svelte +1 -1
- package/lib/browser/blocks/symbol/symbol.helpers.js +1 -1
- package/lib/browser/blocks/symbol/symbol.svelte +9 -2
- package/lib/browser/blocks/tabs/component-info.d.ts +2 -0
- package/lib/browser/blocks/tabs/component-info.js +138 -0
- package/lib/browser/blocks/tabs/index.d.ts +1 -0
- package/lib/browser/blocks/tabs/index.js +1 -0
- package/lib/browser/blocks/tabs/tabs.svelte +76 -0
- package/lib/browser/blocks/tabs/tabs.svelte.d.ts +25 -0
- package/lib/browser/blocks/tabs/tabs.types.d.ts +13 -0
- package/lib/browser/blocks/tabs/tabs.types.js +1 -0
- package/lib/browser/blocks/text/text.types.d.ts +2 -1
- package/lib/browser/components/block/block.helpers.d.ts +4 -2
- package/lib/browser/components/block/block.helpers.js +6 -0
- package/lib/browser/components/block/block.svelte +4 -8
- package/lib/browser/components/block/components/interactive-element.svelte +20 -19
- package/lib/browser/components/content/components/enable-editor.svelte +13 -8
- package/lib/browser/components/content/components/enable-editor.svelte.d.ts +1 -1
- package/lib/browser/components/content/components/styles.helpers.d.ts +1 -0
- package/lib/browser/components/content/components/styles.helpers.js +3 -0
- package/lib/browser/components/content/content.svelte +1 -0
- package/lib/browser/components/dynamic-div.svelte +5 -0
- package/lib/browser/constants/builder-registered-components.js +7 -1
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/evaluate/node-runtime/init.d.ts +17 -1
- package/lib/browser/functions/evaluate/node-runtime/init.js +2 -2
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.d.ts +4 -1
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.js +29 -18
- package/lib/browser/functions/get-class-prop-name.js +1 -0
- package/lib/browser/functions/get-style.js +1 -0
- package/lib/browser/types/targets.d.ts +1 -1
- package/lib/edge/blocks/button/button.svelte +16 -15
- package/lib/edge/blocks/columns/columns.svelte +32 -24
- package/lib/edge/blocks/columns/columns.svelte.d.ts +1 -1
- package/lib/edge/blocks/columns/columns.types.d.ts +1 -1
- package/lib/edge/blocks/columns/helpers.d.ts +1 -0
- package/lib/edge/blocks/columns/helpers.js +3 -0
- package/lib/edge/blocks/image/image.svelte +1 -1
- package/lib/edge/blocks/symbol/symbol.helpers.js +1 -1
- package/lib/edge/blocks/symbol/symbol.svelte +9 -2
- package/lib/edge/blocks/tabs/component-info.d.ts +2 -0
- package/lib/edge/blocks/tabs/component-info.js +138 -0
- package/lib/edge/blocks/tabs/index.d.ts +1 -0
- package/lib/edge/blocks/tabs/index.js +1 -0
- package/lib/edge/blocks/tabs/tabs.svelte +76 -0
- package/lib/edge/blocks/tabs/tabs.svelte.d.ts +25 -0
- package/lib/edge/blocks/tabs/tabs.types.d.ts +13 -0
- package/lib/edge/blocks/tabs/tabs.types.js +1 -0
- package/lib/edge/blocks/text/text.types.d.ts +2 -1
- package/lib/edge/components/block/block.helpers.d.ts +4 -2
- package/lib/edge/components/block/block.helpers.js +6 -0
- package/lib/edge/components/block/block.svelte +4 -8
- package/lib/edge/components/block/components/interactive-element.svelte +20 -19
- package/lib/edge/components/content/components/enable-editor.svelte +13 -8
- package/lib/edge/components/content/components/enable-editor.svelte.d.ts +1 -1
- package/lib/edge/components/content/components/styles.helpers.d.ts +1 -0
- package/lib/edge/components/content/components/styles.helpers.js +3 -0
- package/lib/edge/components/content/content.svelte +1 -0
- package/lib/edge/components/dynamic-div.svelte +5 -0
- package/lib/edge/constants/builder-registered-components.js +7 -1
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/evaluate/node-runtime/init.d.ts +17 -1
- package/lib/edge/functions/evaluate/node-runtime/init.js +2 -2
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.d.ts +4 -1
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.js +29 -18
- package/lib/edge/functions/get-class-prop-name.js +1 -0
- package/lib/edge/functions/get-style.js +1 -0
- package/lib/edge/types/targets.d.ts +1 -1
- package/lib/node/blocks/button/button.svelte +16 -15
- package/lib/node/blocks/columns/columns.svelte +32 -24
- package/lib/node/blocks/columns/columns.svelte.d.ts +1 -1
- package/lib/node/blocks/columns/columns.types.d.ts +1 -1
- package/lib/node/blocks/columns/helpers.d.ts +1 -0
- package/lib/node/blocks/columns/helpers.js +3 -0
- package/lib/node/blocks/image/image.svelte +1 -1
- package/lib/node/blocks/symbol/symbol.helpers.js +1 -1
- package/lib/node/blocks/symbol/symbol.svelte +9 -2
- package/lib/node/blocks/tabs/component-info.d.ts +2 -0
- package/lib/node/blocks/tabs/component-info.js +138 -0
- package/lib/node/blocks/tabs/index.d.ts +1 -0
- package/lib/node/blocks/tabs/index.js +1 -0
- package/lib/node/blocks/tabs/tabs.svelte +76 -0
- package/lib/node/blocks/tabs/tabs.svelte.d.ts +25 -0
- package/lib/node/blocks/tabs/tabs.types.d.ts +13 -0
- package/lib/node/blocks/tabs/tabs.types.js +1 -0
- package/lib/node/blocks/text/text.types.d.ts +2 -1
- package/lib/node/components/block/block.helpers.d.ts +4 -2
- package/lib/node/components/block/block.helpers.js +6 -0
- package/lib/node/components/block/block.svelte +4 -8
- package/lib/node/components/block/components/interactive-element.svelte +20 -19
- package/lib/node/components/content/components/enable-editor.svelte +13 -8
- package/lib/node/components/content/components/enable-editor.svelte.d.ts +1 -1
- package/lib/node/components/content/components/styles.helpers.d.ts +1 -0
- package/lib/node/components/content/components/styles.helpers.js +3 -0
- package/lib/node/components/content/content.svelte +1 -0
- package/lib/node/components/dynamic-div.svelte +5 -0
- package/lib/node/constants/builder-registered-components.js +7 -1
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/evaluate/node-runtime/init.d.ts +17 -1
- package/lib/node/functions/evaluate/node-runtime/init.js +2 -2
- package/lib/node/functions/evaluate/node-runtime/node-runtime.d.ts +4 -1
- package/lib/node/functions/evaluate/node-runtime/node-runtime.js +29 -18
- package/lib/node/functions/get-class-prop-name.js +1 -0
- package/lib/node/functions/get-style.js +1 -0
- package/lib/node/types/targets.d.ts +1 -1
- package/package.json +1 -1
- package/src/blocks/button/button.svelte +19 -15
- package/src/blocks/columns/columns.svelte +34 -26
- package/src/blocks/columns/columns.types.ts +1 -1
- package/src/blocks/columns/helpers.ts +3 -0
- package/src/blocks/image/image.svelte +1 -1
- package/src/blocks/symbol/symbol.helpers.ts +1 -1
- package/src/blocks/symbol/symbol.svelte +9 -2
- package/src/blocks/tabs/component-info.ts +139 -0
- package/src/blocks/tabs/index.ts +1 -0
- package/src/blocks/tabs/tabs.svelte +83 -0
- package/src/blocks/tabs/tabs.types.ts +13 -0
- package/src/blocks/text/text.types.ts +2 -1
- package/src/components/block/block.helpers.ts +7 -1
- package/src/components/block/block.svelte +5 -7
- package/src/components/block/components/interactive-element.svelte +21 -19
- package/src/components/content/components/enable-editor.svelte +13 -8
- package/src/components/content/components/styles.helpers.ts +3 -0
- package/src/components/content/content.svelte +1 -0
- package/src/components/dynamic-div.svelte +19 -0
- package/src/constants/builder-registered-components.ts +7 -1
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/evaluate/node-runtime/init.ts +7 -2
- package/src/functions/evaluate/node-runtime/node-runtime.ts +34 -21
- package/src/functions/get-class-prop-name.ts +1 -0
- package/src/functions/get-style.ts +1 -0
- 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,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
|
-
}) =>
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
{...
|
|
330
|
-
? {}
|
|
331
|
-
: {
|
|
332
|
-
hidden: true,
|
|
333
|
-
"aria-hidden": true,
|
|
334
|
-
}}
|
|
339
|
+
{...showContentProps()}
|
|
335
340
|
{...contentWrapperProps}
|
|
336
|
-
class={
|
|
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;
|
|
@@ -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;
|
|
@@ -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
|
-
}, ...
|
|
49
|
+
}, ...(TARGET === 'rsc' ? [] : [{
|
|
50
|
+
component: Tabs,
|
|
51
|
+
...tabsComponentInfo
|
|
52
|
+
}]), ...getExtraComponents()];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.25";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
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: (
|
|
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:
|
|
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
|
-
|
|
48
|
+
const output = theFunction()
|
|
49
49
|
|
|
50
50
|
if (typeof output === 'object' && output !== null) {
|
|
51
|
-
|
|
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
|
-
|
|
88
|
+
function setIsolateContext(options = {
|
|
89
|
+
memoryLimit: 128
|
|
90
|
+
}) {
|
|
87
91
|
const ivm = getIvm();
|
|
88
|
-
const isolate = new ivm.Isolate(
|
|
89
|
-
|
|
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
|
-
|
|
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.
|
|
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);
|
|
@@ -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
|