@builder.io/sdk-svelte 1.0.33 → 1.0.36
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/lib/browser/blocks/embed/component-info.js +1 -2
- package/lib/browser/blocks/form/select/select.svelte +2 -0
- package/lib/browser/blocks/form/textarea/component-info.d.ts +2 -0
- package/lib/browser/blocks/{textarea → form/textarea}/textarea.svelte +4 -2
- package/lib/browser/blocks/image/component-info.js +1 -1
- package/lib/browser/constants/extra-components.js +5 -0
- package/lib/browser/constants/sdk-name.d.ts +1 -0
- package/lib/browser/constants/sdk-name.js +12 -0
- 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/node-runtime.js +10 -6
- package/lib/browser/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +2 -0
- package/lib/browser/functions/extract-css-var-default-value.d.ts +1 -0
- package/lib/browser/functions/extract-css-var-default-value.js +11 -0
- package/lib/edge/blocks/embed/component-info.js +1 -2
- package/lib/edge/blocks/form/select/select.svelte +2 -0
- package/lib/edge/blocks/form/textarea/component-info.d.ts +2 -0
- package/lib/edge/blocks/{textarea → form/textarea}/textarea.svelte +4 -2
- package/lib/edge/blocks/image/component-info.js +1 -1
- package/lib/edge/constants/extra-components.js +5 -0
- package/lib/edge/constants/sdk-name.d.ts +1 -0
- package/lib/edge/constants/sdk-name.js +12 -0
- 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/node-runtime.js +10 -6
- package/lib/edge/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +2 -0
- package/lib/edge/functions/extract-css-var-default-value.d.ts +1 -0
- package/lib/edge/functions/extract-css-var-default-value.js +11 -0
- package/lib/node/blocks/embed/component-info.js +1 -2
- package/lib/node/blocks/form/select/select.svelte +2 -0
- package/lib/node/blocks/form/textarea/component-info.d.ts +2 -0
- package/lib/node/blocks/{textarea → form/textarea}/textarea.svelte +4 -2
- package/lib/node/blocks/image/component-info.js +1 -1
- package/lib/node/constants/extra-components.js +5 -0
- package/lib/node/constants/sdk-name.d.ts +1 -0
- package/lib/node/constants/sdk-name.js +12 -0
- 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/node-runtime.js +10 -6
- package/lib/node/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +2 -0
- package/lib/node/functions/extract-css-var-default-value.d.ts +1 -0
- package/lib/node/functions/extract-css-var-default-value.js +11 -0
- package/package.json +1 -1
- package/src/blocks/embed/component-info.ts +4 -2
- package/src/blocks/form/select/select.svelte +3 -0
- package/src/blocks/{textarea → form/textarea}/component-info.ts +1 -1
- package/src/blocks/{textarea → form/textarea}/textarea.svelte +5 -2
- package/src/blocks/image/component-info.ts +1 -1
- package/src/constants/extra-components.ts +5 -0
- package/src/constants/sdk-name.ts +12 -0
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/evaluate/node-runtime/node-runtime.ts +11 -6
- package/src/functions/extract-css-var-default-value.ts +12 -0
- package/lib/browser/blocks/textarea/component-info.d.ts +0 -2
- package/lib/edge/blocks/textarea/component-info.d.ts +0 -2
- package/lib/node/blocks/textarea/component-info.d.ts +0 -2
- /package/lib/browser/blocks/{textarea → form/textarea}/component-info.js +0 -0
- /package/lib/browser/blocks/{textarea → form/textarea}/index.d.ts +0 -0
- /package/lib/browser/blocks/{textarea → form/textarea}/index.js +0 -0
- /package/lib/edge/blocks/{textarea → form/textarea}/component-info.js +0 -0
- /package/lib/edge/blocks/{textarea → form/textarea}/index.d.ts +0 -0
- /package/lib/edge/blocks/{textarea → form/textarea}/index.js +0 -0
- /package/lib/node/blocks/{textarea → form/textarea}/component-info.js +0 -0
- /package/lib/node/blocks/{textarea → form/textarea}/index.d.ts +0 -0
- /package/lib/node/blocks/{textarea → form/textarea}/index.js +0 -0
- /package/src/blocks/{textarea → form/textarea}/index.ts +0 -0
|
@@ -11,8 +11,7 @@ export const componentInfo = {
|
|
|
11
11
|
const url = options.get('url');
|
|
12
12
|
if (url) {
|
|
13
13
|
options.set('content', 'Loading...');
|
|
14
|
-
|
|
15
|
-
const apiKey = 'ae0e60e78201a3f2b0de4b';
|
|
14
|
+
const apiKey = _iframelyApiKey;
|
|
16
15
|
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then(res => res.json()).then(data => {
|
|
17
16
|
if (options.get('url') === url) {
|
|
18
17
|
if (data.html) {
|
|
@@ -10,6 +10,7 @@ export let attributes = undefined;
|
|
|
10
10
|
export let value = undefined;
|
|
11
11
|
export let defaultValue = undefined;
|
|
12
12
|
export let name = undefined;
|
|
13
|
+
export let required = undefined;
|
|
13
14
|
export let options = undefined;
|
|
14
15
|
</script>
|
|
15
16
|
|
|
@@ -19,6 +20,7 @@ export let options = undefined;
|
|
|
19
20
|
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
20
21
|
{defaultValue}
|
|
21
22
|
{name}
|
|
23
|
+
{required}
|
|
22
24
|
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
23
25
|
>
|
|
24
26
|
{#each options as option, index (`${option.name}-${index}`)}
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
|
-
<script>import { filterAttrs } from "
|
|
7
|
-
import { setAttrs } from "
|
|
6
|
+
<script>import { filterAttrs } from "../../helpers";
|
|
7
|
+
import { setAttrs } from "../../helpers";
|
|
8
8
|
export let attributes = undefined;
|
|
9
9
|
export let placeholder = undefined;
|
|
10
10
|
export let name = undefined;
|
|
11
11
|
export let value = undefined;
|
|
12
12
|
export let defaultValue = undefined;
|
|
13
|
+
export let required = undefined;
|
|
13
14
|
</script>
|
|
14
15
|
|
|
15
16
|
<textarea
|
|
@@ -18,5 +19,6 @@ export let defaultValue = undefined;
|
|
|
18
19
|
{name}
|
|
19
20
|
{value}
|
|
20
21
|
{defaultValue}
|
|
22
|
+
{required}
|
|
21
23
|
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
22
24
|
/>
|
|
@@ -13,7 +13,7 @@ export const componentInfo = {
|
|
|
13
13
|
name: 'image',
|
|
14
14
|
type: 'file',
|
|
15
15
|
bubble: true,
|
|
16
|
-
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg'],
|
|
16
|
+
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg', 'webp'],
|
|
17
17
|
required: true,
|
|
18
18
|
defaultValue: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a',
|
|
19
19
|
onChange: (options) => {
|
|
@@ -15,6 +15,8 @@ import { componentInfo as formSelectComponentInfo } from '../blocks/form/select/
|
|
|
15
15
|
import { default as FormSelect } from '../blocks/form/select/index';
|
|
16
16
|
import { componentInfo as formSubmitButtonComponentInfo } from '../blocks/form/submit-button/component-info';
|
|
17
17
|
import { default as FormSubmitButton } from '../blocks/form/submit-button/index';
|
|
18
|
+
import { componentInfo as textAreaComponentInfo } from '../blocks/form/textarea/component-info';
|
|
19
|
+
import { default as Textarea } from '../blocks/form/textarea/index';
|
|
18
20
|
import { componentInfo as imgComponentInfo } from '../blocks/img/component-info';
|
|
19
21
|
import { default as Img } from '../blocks/img/index';
|
|
20
22
|
import { componentInfo as videoComponentInfo } from '../blocks/video/component-info';
|
|
@@ -38,6 +40,9 @@ export const getExtraComponents = () => [{
|
|
|
38
40
|
}, {
|
|
39
41
|
component: FormSelect,
|
|
40
42
|
...formSelectComponentInfo
|
|
43
|
+
}, {
|
|
44
|
+
component: Textarea,
|
|
45
|
+
...textAreaComponentInfo
|
|
41
46
|
}]), {
|
|
42
47
|
component: Img,
|
|
43
48
|
...imgComponentInfo
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_NAME: "@builder.io/sdk-vue" | "@builder.io/sdk-svelte" | "@builder.io/sdk-qwik" | "@builder.io/sdk-react" | "@builder.io/sdk-solid" | "@builder.io/sdk-angular" | "@builder.io/sdk-react-nextjs" | "@builder.io/sdk-react-native";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TARGET } from './target';
|
|
2
|
+
const SDK_NAME_FOR_TARGET = (() => {
|
|
3
|
+
switch (TARGET) {
|
|
4
|
+
case 'rsc':
|
|
5
|
+
return 'react-nextjs';
|
|
6
|
+
case 'reactNative':
|
|
7
|
+
return 'react-native';
|
|
8
|
+
default:
|
|
9
|
+
return TARGET;
|
|
10
|
+
}
|
|
11
|
+
})();
|
|
12
|
+
export const SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.36";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.36";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SDK_NAME } from '../../../constants/sdk-name';
|
|
1
2
|
import { MSG_PREFIX, logger } from '../../../helpers/logger';
|
|
2
3
|
import { fastClone } from '../../fast-clone';
|
|
3
4
|
import { set } from '../../set';
|
|
@@ -65,6 +66,8 @@ export const setIvm = (ivm, options = {}) => {
|
|
|
65
66
|
IVM_INSTANCE = ivm;
|
|
66
67
|
setIsolateContext(options);
|
|
67
68
|
};
|
|
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';
|
|
68
71
|
const getIvm = () => {
|
|
69
72
|
try {
|
|
70
73
|
if (IVM_INSTANCE)
|
|
@@ -76,14 +79,15 @@ const getIvm = () => {
|
|
|
76
79
|
catch (error) {
|
|
77
80
|
logger.error('isolated-vm import error.', error);
|
|
78
81
|
}
|
|
79
|
-
|
|
82
|
+
const ERROR_MESSAGE = `${MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
80
83
|
|
|
81
|
-
In
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
85
|
+
|
|
86
|
+
${SHOULD_MENTION_INITIALIZE_SCRIPT ? '- import and call `initializeNodeRuntime()` from "${SDK_NAME}/node/init".' : ''}
|
|
87
|
+
- add the following import: \`await import('isolated-vm')\`.
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
90
|
+
throw new Error(ERROR_MESSAGE);
|
|
87
91
|
};
|
|
88
92
|
function setIsolateContext(options = {
|
|
89
93
|
memoryLimit: 128
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractCssVarDefaultValue(value: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function extractCssVarDefaultValue(value) {
|
|
2
|
+
// Regular expression to find var() expressions
|
|
3
|
+
const varRegex = /var\(--[^,]+?,\s*([^)]+)\)/;
|
|
4
|
+
// Function to replace var() with its fallback
|
|
5
|
+
let newValue = value;
|
|
6
|
+
let match;
|
|
7
|
+
while (match = newValue.match(varRegex)) {
|
|
8
|
+
newValue = newValue.replace(match[0], match[1].trim());
|
|
9
|
+
}
|
|
10
|
+
return newValue;
|
|
11
|
+
}
|
|
@@ -11,8 +11,7 @@ export const componentInfo = {
|
|
|
11
11
|
const url = options.get('url');
|
|
12
12
|
if (url) {
|
|
13
13
|
options.set('content', 'Loading...');
|
|
14
|
-
|
|
15
|
-
const apiKey = 'ae0e60e78201a3f2b0de4b';
|
|
14
|
+
const apiKey = _iframelyApiKey;
|
|
16
15
|
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then(res => res.json()).then(data => {
|
|
17
16
|
if (options.get('url') === url) {
|
|
18
17
|
if (data.html) {
|
|
@@ -10,6 +10,7 @@ export let attributes = undefined;
|
|
|
10
10
|
export let value = undefined;
|
|
11
11
|
export let defaultValue = undefined;
|
|
12
12
|
export let name = undefined;
|
|
13
|
+
export let required = undefined;
|
|
13
14
|
export let options = undefined;
|
|
14
15
|
</script>
|
|
15
16
|
|
|
@@ -19,6 +20,7 @@ export let options = undefined;
|
|
|
19
20
|
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
20
21
|
{defaultValue}
|
|
21
22
|
{name}
|
|
23
|
+
{required}
|
|
22
24
|
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
23
25
|
>
|
|
24
26
|
{#each options as option, index (`${option.name}-${index}`)}
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
|
-
<script>import { filterAttrs } from "
|
|
7
|
-
import { setAttrs } from "
|
|
6
|
+
<script>import { filterAttrs } from "../../helpers";
|
|
7
|
+
import { setAttrs } from "../../helpers";
|
|
8
8
|
export let attributes = undefined;
|
|
9
9
|
export let placeholder = undefined;
|
|
10
10
|
export let name = undefined;
|
|
11
11
|
export let value = undefined;
|
|
12
12
|
export let defaultValue = undefined;
|
|
13
|
+
export let required = undefined;
|
|
13
14
|
</script>
|
|
14
15
|
|
|
15
16
|
<textarea
|
|
@@ -18,5 +19,6 @@ export let defaultValue = undefined;
|
|
|
18
19
|
{name}
|
|
19
20
|
{value}
|
|
20
21
|
{defaultValue}
|
|
22
|
+
{required}
|
|
21
23
|
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
22
24
|
/>
|
|
@@ -13,7 +13,7 @@ export const componentInfo = {
|
|
|
13
13
|
name: 'image',
|
|
14
14
|
type: 'file',
|
|
15
15
|
bubble: true,
|
|
16
|
-
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg'],
|
|
16
|
+
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg', 'webp'],
|
|
17
17
|
required: true,
|
|
18
18
|
defaultValue: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a',
|
|
19
19
|
onChange: (options) => {
|
|
@@ -15,6 +15,8 @@ import { componentInfo as formSelectComponentInfo } from '../blocks/form/select/
|
|
|
15
15
|
import { default as FormSelect } from '../blocks/form/select/index';
|
|
16
16
|
import { componentInfo as formSubmitButtonComponentInfo } from '../blocks/form/submit-button/component-info';
|
|
17
17
|
import { default as FormSubmitButton } from '../blocks/form/submit-button/index';
|
|
18
|
+
import { componentInfo as textAreaComponentInfo } from '../blocks/form/textarea/component-info';
|
|
19
|
+
import { default as Textarea } from '../blocks/form/textarea/index';
|
|
18
20
|
import { componentInfo as imgComponentInfo } from '../blocks/img/component-info';
|
|
19
21
|
import { default as Img } from '../blocks/img/index';
|
|
20
22
|
import { componentInfo as videoComponentInfo } from '../blocks/video/component-info';
|
|
@@ -38,6 +40,9 @@ export const getExtraComponents = () => [{
|
|
|
38
40
|
}, {
|
|
39
41
|
component: FormSelect,
|
|
40
42
|
...formSelectComponentInfo
|
|
43
|
+
}, {
|
|
44
|
+
component: Textarea,
|
|
45
|
+
...textAreaComponentInfo
|
|
41
46
|
}]), {
|
|
42
47
|
component: Img,
|
|
43
48
|
...imgComponentInfo
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_NAME: "@builder.io/sdk-vue" | "@builder.io/sdk-svelte" | "@builder.io/sdk-qwik" | "@builder.io/sdk-react" | "@builder.io/sdk-solid" | "@builder.io/sdk-angular" | "@builder.io/sdk-react-nextjs" | "@builder.io/sdk-react-native";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TARGET } from './target';
|
|
2
|
+
const SDK_NAME_FOR_TARGET = (() => {
|
|
3
|
+
switch (TARGET) {
|
|
4
|
+
case 'rsc':
|
|
5
|
+
return 'react-nextjs';
|
|
6
|
+
case 'reactNative':
|
|
7
|
+
return 'react-native';
|
|
8
|
+
default:
|
|
9
|
+
return TARGET;
|
|
10
|
+
}
|
|
11
|
+
})();
|
|
12
|
+
export const SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.36";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.36";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SDK_NAME } from '../../../constants/sdk-name';
|
|
1
2
|
import { MSG_PREFIX, logger } from '../../../helpers/logger';
|
|
2
3
|
import { fastClone } from '../../fast-clone';
|
|
3
4
|
import { set } from '../../set';
|
|
@@ -65,6 +66,8 @@ export const setIvm = (ivm, options = {}) => {
|
|
|
65
66
|
IVM_INSTANCE = ivm;
|
|
66
67
|
setIsolateContext(options);
|
|
67
68
|
};
|
|
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';
|
|
68
71
|
const getIvm = () => {
|
|
69
72
|
try {
|
|
70
73
|
if (IVM_INSTANCE)
|
|
@@ -76,14 +79,15 @@ const getIvm = () => {
|
|
|
76
79
|
catch (error) {
|
|
77
80
|
logger.error('isolated-vm import error.', error);
|
|
78
81
|
}
|
|
79
|
-
|
|
82
|
+
const ERROR_MESSAGE = `${MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
80
83
|
|
|
81
|
-
In
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
85
|
+
|
|
86
|
+
${SHOULD_MENTION_INITIALIZE_SCRIPT ? '- import and call `initializeNodeRuntime()` from "${SDK_NAME}/node/init".' : ''}
|
|
87
|
+
- add the following import: \`await import('isolated-vm')\`.
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
90
|
+
throw new Error(ERROR_MESSAGE);
|
|
87
91
|
};
|
|
88
92
|
function setIsolateContext(options = {
|
|
89
93
|
memoryLimit: 128
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractCssVarDefaultValue(value: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function extractCssVarDefaultValue(value) {
|
|
2
|
+
// Regular expression to find var() expressions
|
|
3
|
+
const varRegex = /var\(--[^,]+?,\s*([^)]+)\)/;
|
|
4
|
+
// Function to replace var() with its fallback
|
|
5
|
+
let newValue = value;
|
|
6
|
+
let match;
|
|
7
|
+
while (match = newValue.match(varRegex)) {
|
|
8
|
+
newValue = newValue.replace(match[0], match[1].trim());
|
|
9
|
+
}
|
|
10
|
+
return newValue;
|
|
11
|
+
}
|
|
@@ -11,8 +11,7 @@ export const componentInfo = {
|
|
|
11
11
|
const url = options.get('url');
|
|
12
12
|
if (url) {
|
|
13
13
|
options.set('content', 'Loading...');
|
|
14
|
-
|
|
15
|
-
const apiKey = 'ae0e60e78201a3f2b0de4b';
|
|
14
|
+
const apiKey = _iframelyApiKey;
|
|
16
15
|
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then(res => res.json()).then(data => {
|
|
17
16
|
if (options.get('url') === url) {
|
|
18
17
|
if (data.html) {
|
|
@@ -10,6 +10,7 @@ export let attributes = undefined;
|
|
|
10
10
|
export let value = undefined;
|
|
11
11
|
export let defaultValue = undefined;
|
|
12
12
|
export let name = undefined;
|
|
13
|
+
export let required = undefined;
|
|
13
14
|
export let options = undefined;
|
|
14
15
|
</script>
|
|
15
16
|
|
|
@@ -19,6 +20,7 @@ export let options = undefined;
|
|
|
19
20
|
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
20
21
|
{defaultValue}
|
|
21
22
|
{name}
|
|
23
|
+
{required}
|
|
22
24
|
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
23
25
|
>
|
|
24
26
|
{#each options as option, index (`${option.name}-${index}`)}
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
|
-
<script>import { filterAttrs } from "
|
|
7
|
-
import { setAttrs } from "
|
|
6
|
+
<script>import { filterAttrs } from "../../helpers";
|
|
7
|
+
import { setAttrs } from "../../helpers";
|
|
8
8
|
export let attributes = undefined;
|
|
9
9
|
export let placeholder = undefined;
|
|
10
10
|
export let name = undefined;
|
|
11
11
|
export let value = undefined;
|
|
12
12
|
export let defaultValue = undefined;
|
|
13
|
+
export let required = undefined;
|
|
13
14
|
</script>
|
|
14
15
|
|
|
15
16
|
<textarea
|
|
@@ -18,5 +19,6 @@ export let defaultValue = undefined;
|
|
|
18
19
|
{name}
|
|
19
20
|
{value}
|
|
20
21
|
{defaultValue}
|
|
22
|
+
{required}
|
|
21
23
|
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
22
24
|
/>
|
|
@@ -13,7 +13,7 @@ export const componentInfo = {
|
|
|
13
13
|
name: 'image',
|
|
14
14
|
type: 'file',
|
|
15
15
|
bubble: true,
|
|
16
|
-
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg'],
|
|
16
|
+
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg', 'webp'],
|
|
17
17
|
required: true,
|
|
18
18
|
defaultValue: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a',
|
|
19
19
|
onChange: (options) => {
|
|
@@ -15,6 +15,8 @@ import { componentInfo as formSelectComponentInfo } from '../blocks/form/select/
|
|
|
15
15
|
import { default as FormSelect } from '../blocks/form/select/index';
|
|
16
16
|
import { componentInfo as formSubmitButtonComponentInfo } from '../blocks/form/submit-button/component-info';
|
|
17
17
|
import { default as FormSubmitButton } from '../blocks/form/submit-button/index';
|
|
18
|
+
import { componentInfo as textAreaComponentInfo } from '../blocks/form/textarea/component-info';
|
|
19
|
+
import { default as Textarea } from '../blocks/form/textarea/index';
|
|
18
20
|
import { componentInfo as imgComponentInfo } from '../blocks/img/component-info';
|
|
19
21
|
import { default as Img } from '../blocks/img/index';
|
|
20
22
|
import { componentInfo as videoComponentInfo } from '../blocks/video/component-info';
|
|
@@ -38,6 +40,9 @@ export const getExtraComponents = () => [{
|
|
|
38
40
|
}, {
|
|
39
41
|
component: FormSelect,
|
|
40
42
|
...formSelectComponentInfo
|
|
43
|
+
}, {
|
|
44
|
+
component: Textarea,
|
|
45
|
+
...textAreaComponentInfo
|
|
41
46
|
}]), {
|
|
42
47
|
component: Img,
|
|
43
48
|
...imgComponentInfo
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_NAME: "@builder.io/sdk-vue" | "@builder.io/sdk-svelte" | "@builder.io/sdk-qwik" | "@builder.io/sdk-react" | "@builder.io/sdk-solid" | "@builder.io/sdk-angular" | "@builder.io/sdk-react-nextjs" | "@builder.io/sdk-react-native";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TARGET } from './target';
|
|
2
|
+
const SDK_NAME_FOR_TARGET = (() => {
|
|
3
|
+
switch (TARGET) {
|
|
4
|
+
case 'rsc':
|
|
5
|
+
return 'react-nextjs';
|
|
6
|
+
case 'reactNative':
|
|
7
|
+
return 'react-native';
|
|
8
|
+
default:
|
|
9
|
+
return TARGET;
|
|
10
|
+
}
|
|
11
|
+
})();
|
|
12
|
+
export const SDK_NAME = `@builder.io/sdk-${SDK_NAME_FOR_TARGET}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.36";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.36";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SDK_NAME } from '../../../constants/sdk-name';
|
|
1
2
|
import { MSG_PREFIX, logger } from '../../../helpers/logger';
|
|
2
3
|
import { fastClone } from '../../fast-clone';
|
|
3
4
|
import { set } from '../../set';
|
|
@@ -65,6 +66,8 @@ export const setIvm = (ivm, options = {}) => {
|
|
|
65
66
|
IVM_INSTANCE = ivm;
|
|
66
67
|
setIsolateContext(options);
|
|
67
68
|
};
|
|
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';
|
|
68
71
|
const getIvm = () => {
|
|
69
72
|
try {
|
|
70
73
|
if (IVM_INSTANCE)
|
|
@@ -76,14 +79,15 @@ const getIvm = () => {
|
|
|
76
79
|
catch (error) {
|
|
77
80
|
logger.error('isolated-vm import error.', error);
|
|
78
81
|
}
|
|
79
|
-
|
|
82
|
+
const ERROR_MESSAGE = `${MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
80
83
|
|
|
81
|
-
In
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
85
|
+
|
|
86
|
+
${SHOULD_MENTION_INITIALIZE_SCRIPT ? '- import and call `initializeNodeRuntime()` from "${SDK_NAME}/node/init".' : ''}
|
|
87
|
+
- add the following import: \`await import('isolated-vm')\`.
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
90
|
+
throw new Error(ERROR_MESSAGE);
|
|
87
91
|
};
|
|
88
92
|
function setIsolateContext(options = {
|
|
89
93
|
memoryLimit: 128
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractCssVarDefaultValue(value: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function extractCssVarDefaultValue(value) {
|
|
2
|
+
// Regular expression to find var() expressions
|
|
3
|
+
const varRegex = /var\(--[^,]+?,\s*([^)]+)\)/;
|
|
4
|
+
// Function to replace var() with its fallback
|
|
5
|
+
let newValue = value;
|
|
6
|
+
let match;
|
|
7
|
+
while (match = newValue.match(varRegex)) {
|
|
8
|
+
newValue = newValue.replace(match[0], match[1].trim());
|
|
9
|
+
}
|
|
10
|
+
return newValue;
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { ComponentInfo } from '../../types/components';
|
|
2
|
+
|
|
3
|
+
// Provided by the web app as a local variable in onChange functions
|
|
4
|
+
declare const _iframelyApiKey: string;
|
|
2
5
|
export const componentInfo: ComponentInfo = {
|
|
3
6
|
name: 'Embed',
|
|
4
7
|
static: true,
|
|
@@ -12,8 +15,7 @@ export const componentInfo: ComponentInfo = {
|
|
|
12
15
|
const url = options.get('url');
|
|
13
16
|
if (url) {
|
|
14
17
|
options.set('content', 'Loading...');
|
|
15
|
-
|
|
16
|
-
const apiKey = 'ae0e60e78201a3f2b0de4b';
|
|
18
|
+
const apiKey = _iframelyApiKey;
|
|
17
19
|
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then(res => res.json()).then(data => {
|
|
18
20
|
if (options.get('url') === url) {
|
|
19
21
|
if (data.html) {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
name?: string;
|
|
13
13
|
value?: string;
|
|
14
14
|
defaultValue?: string;
|
|
15
|
+
required?: boolean;
|
|
15
16
|
}
|
|
16
17
|
</script>
|
|
17
18
|
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
export let value: FormSelectProps["value"] = undefined;
|
|
25
26
|
export let defaultValue: FormSelectProps["defaultValue"] = undefined;
|
|
26
27
|
export let name: FormSelectProps["name"] = undefined;
|
|
28
|
+
export let required: FormSelectProps["required"] = undefined;
|
|
27
29
|
export let options: FormSelectProps["options"] = undefined;
|
|
28
30
|
</script>
|
|
29
31
|
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
key={isEditing() && defaultValue ? defaultValue : "default-key"}
|
|
34
36
|
{defaultValue}
|
|
35
37
|
{name}
|
|
38
|
+
{required}
|
|
36
39
|
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
37
40
|
>
|
|
38
41
|
{#each options as option, index (`${option.name}-${index}`)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentInfo } from '
|
|
1
|
+
import type { ComponentInfo } from '../../../types/components';
|
|
2
2
|
export const componentInfo: ComponentInfo = {
|
|
3
3
|
name: 'Form:TextArea',
|
|
4
4
|
image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3',
|
|
@@ -9,18 +9,20 @@
|
|
|
9
9
|
value?: string;
|
|
10
10
|
defaultValue?: string;
|
|
11
11
|
placeholder?: string;
|
|
12
|
+
required?: boolean;
|
|
12
13
|
}
|
|
13
14
|
</script>
|
|
14
15
|
|
|
15
16
|
<script lang="ts">
|
|
16
|
-
import { filterAttrs } from "
|
|
17
|
-
import { setAttrs } from "
|
|
17
|
+
import { filterAttrs } from "../../helpers";
|
|
18
|
+
import { setAttrs } from "../../helpers";
|
|
18
19
|
|
|
19
20
|
export let attributes: TextareaProps["attributes"] = undefined;
|
|
20
21
|
export let placeholder: TextareaProps["placeholder"] = undefined;
|
|
21
22
|
export let name: TextareaProps["name"] = undefined;
|
|
22
23
|
export let value: TextareaProps["value"] = undefined;
|
|
23
24
|
export let defaultValue: TextareaProps["defaultValue"] = undefined;
|
|
25
|
+
export let required: TextareaProps["required"] = undefined;
|
|
24
26
|
</script>
|
|
25
27
|
|
|
26
28
|
<textarea
|
|
@@ -29,5 +31,6 @@
|
|
|
29
31
|
{name}
|
|
30
32
|
{value}
|
|
31
33
|
{defaultValue}
|
|
34
|
+
{required}
|
|
32
35
|
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
33
36
|
/>
|
|
@@ -14,7 +14,7 @@ export const componentInfo: ComponentInfo = {
|
|
|
14
14
|
name: 'image',
|
|
15
15
|
type: 'file',
|
|
16
16
|
bubble: true,
|
|
17
|
-
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg'],
|
|
17
|
+
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg', 'webp'],
|
|
18
18
|
required: true,
|
|
19
19
|
defaultValue: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a',
|
|
20
20
|
onChange: (options: Map<string, any>): void | Promise<void> => {
|
|
@@ -16,6 +16,8 @@ import { componentInfo as formSelectComponentInfo } from '../blocks/form/select/
|
|
|
16
16
|
import { default as FormSelect } from '../blocks/form/select/index';
|
|
17
17
|
import { componentInfo as formSubmitButtonComponentInfo } from '../blocks/form/submit-button/component-info';
|
|
18
18
|
import { default as FormSubmitButton } from '../blocks/form/submit-button/index';
|
|
19
|
+
import { componentInfo as textAreaComponentInfo } from '../blocks/form/textarea/component-info';
|
|
20
|
+
import { default as Textarea } from '../blocks/form/textarea/index';
|
|
19
21
|
import { componentInfo as imgComponentInfo } from '../blocks/img/component-info';
|
|
20
22
|
import { default as Img } from '../blocks/img/index';
|
|
21
23
|
import { componentInfo as videoComponentInfo } from '../blocks/video/component-info';
|
|
@@ -40,6 +42,9 @@ export const getExtraComponents: () => RegisteredComponent[] = () => [{
|
|
|
40
42
|
}, {
|
|
41
43
|
component: FormSelect,
|
|
42
44
|
...formSelectComponentInfo
|
|
45
|
+
}, {
|
|
46
|
+
component: Textarea,
|
|
47
|
+
...textAreaComponentInfo
|
|
43
48
|
}]), {
|
|
44
49
|
component: Img,
|
|
45
50
|
...imgComponentInfo
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TARGET } from './target';
|
|
2
|
+
const SDK_NAME_FOR_TARGET = (() => {
|
|
3
|
+
switch (TARGET) {
|
|
4
|
+
case 'rsc':
|
|
5
|
+
return 'react-nextjs';
|
|
6
|
+
case 'reactNative':
|
|
7
|
+
return 'react-native';
|
|
8
|
+
default:
|
|
9
|
+
return TARGET;
|
|
10
|
+
}
|
|
11
|
+
})();
|
|
12
|
+
export const SDK_NAME = (`@builder.io/sdk-${SDK_NAME_FOR_TARGET}` as const)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.36"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Context, IsolateOptions } from 'isolated-vm';
|
|
2
|
+
import { SDK_NAME } from '../../../constants/sdk-name';
|
|
2
3
|
import { MSG_PREFIX, logger } from '../../../helpers/logger';
|
|
3
4
|
import { fastClone } from '../../fast-clone';
|
|
4
5
|
import { set } from '../../set';
|
|
@@ -77,6 +78,9 @@ export const setIvm = (ivm: IsolatedVMImport, options: IsolateOptions = {}) => {
|
|
|
77
78
|
IVM_INSTANCE = ivm;
|
|
78
79
|
setIsolateContext(options);
|
|
79
80
|
};
|
|
81
|
+
|
|
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';
|
|
80
84
|
const getIvm = (): IsolatedVMImport => {
|
|
81
85
|
try {
|
|
82
86
|
if (IVM_INSTANCE) return IVM_INSTANCE;
|
|
@@ -85,14 +89,15 @@ const getIvm = (): IsolatedVMImport => {
|
|
|
85
89
|
} catch (error) {
|
|
86
90
|
logger.error('isolated-vm import error.', error);
|
|
87
91
|
}
|
|
88
|
-
|
|
92
|
+
const ERROR_MESSAGE = `${MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
89
93
|
|
|
90
|
-
In
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
95
|
+
|
|
96
|
+
${SHOULD_MENTION_INITIALIZE_SCRIPT ? '- import and call `initializeNodeRuntime()` from "${SDK_NAME}/node/init".' : ''}
|
|
97
|
+
- add the following import: \`await import('isolated-vm')\`.
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
100
|
+
throw new Error(ERROR_MESSAGE);
|
|
96
101
|
};
|
|
97
102
|
function setIsolateContext(options: IsolateOptions = {
|
|
98
103
|
memoryLimit: 128
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function extractCssVarDefaultValue(value: string): string {
|
|
2
|
+
// Regular expression to find var() expressions
|
|
3
|
+
const varRegex = /var\(--[^,]+?,\s*([^)]+)\)/;
|
|
4
|
+
|
|
5
|
+
// Function to replace var() with its fallback
|
|
6
|
+
let newValue = value;
|
|
7
|
+
let match: string[] | null;
|
|
8
|
+
while (match = newValue.match(varRegex)) {
|
|
9
|
+
newValue = newValue.replace(match[0], match[1].trim());
|
|
10
|
+
}
|
|
11
|
+
return newValue;
|
|
12
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|