@builder.io/sdk-svelte 0.5.2 → 0.5.3
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 +4 -0
- package/package/--package.json +18 -4
- package/package/README.md +4 -0
- package/package/blocks/image/image.svelte.d.ts +1 -0
- package/package/blocks/text/text.svelte +2 -1
- package/package/components/content-variants/content-variants.svelte +12 -6
- package/package/constants/sdk-version.d.ts +1 -1
- package/package/constants/sdk-version.js +1 -1
- package/package/functions/evaluate/evaluate.js +19 -1
- package/package/functions/evaluate/interpreter.js +1 -1
- package/package/functions/evaluate/types.d.ts +1 -0
- package/package.json +18 -4
- package/src/blocks/text/text.svelte +2 -1
- package/src/components/content-variants/content-variants.svelte +12 -6
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/evaluate/evaluate.ts +20 -1
- package/src/functions/evaluate/interpreter.ts +1 -1
- package/src/functions/evaluate/types.ts +2 -1
package/README.md
CHANGED
|
@@ -21,3 +21,7 @@ Take a look at [our example repo](/examples/svelte/sveltekit) for how to use thi
|
|
|
21
21
|
## Fetch
|
|
22
22
|
|
|
23
23
|
This Package uses fetch. See [these docs](https://github.com/BuilderIO/this-package-uses-fetch/blob/main/README.md) for more information.
|
|
24
|
+
|
|
25
|
+
## Non-Node.js Runtimes (Edge, Serverless)
|
|
26
|
+
|
|
27
|
+
If planning to deploy your app to a non-Node.js runtime (like Edge or Serverless functions), make sure to read the [Non-Node.js Runtimes](../../README.md#non-nodejs-runtimes-edge-serverless) section of the main README.
|
package/package/--package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-svelte",
|
|
3
3
|
"description": "Builder.io SDK for Svelte",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"package",
|
|
@@ -175,11 +175,25 @@
|
|
|
175
175
|
"@sveltejs/adapter-auto": "1.0.0-next.71",
|
|
176
176
|
"@sveltejs/kit": "^1.16.2",
|
|
177
177
|
"@sveltejs/package": "1.0.0-next.1",
|
|
178
|
+
"nx": "^16.6.0",
|
|
179
|
+
"nx-cloud": "^16.2.0",
|
|
178
180
|
"svelte": "^3.59.1",
|
|
179
|
-
"svelte-check": "^3.
|
|
180
|
-
"svelte-preprocess": "^
|
|
181
|
+
"svelte-check": "^3.4.6",
|
|
182
|
+
"svelte-preprocess": "^5.0.4",
|
|
181
183
|
"tslib": "^2.3.1",
|
|
182
184
|
"typescript": "^5.1.6",
|
|
183
|
-
"vite": "^
|
|
185
|
+
"vite": "^4.4.8"
|
|
186
|
+
},
|
|
187
|
+
"nx": {
|
|
188
|
+
"implicitDependencies": [
|
|
189
|
+
"@builder.io/sdks"
|
|
190
|
+
],
|
|
191
|
+
"targets": {
|
|
192
|
+
"build": {
|
|
193
|
+
"outputs": [
|
|
194
|
+
"{projectRoot}/package"
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
}
|
|
184
198
|
}
|
|
185
199
|
}
|
package/package/README.md
CHANGED
|
@@ -21,3 +21,7 @@ Take a look at [our example repo](/examples/svelte/sveltekit) for how to use thi
|
|
|
21
21
|
## Fetch
|
|
22
22
|
|
|
23
23
|
This Package uses fetch. See [these docs](https://github.com/BuilderIO/this-package-uses-fetch/blob/main/README.md) for more information.
|
|
24
|
+
|
|
25
|
+
## Non-Node.js Runtimes (Edge, Serverless)
|
|
26
|
+
|
|
27
|
+
If planning to deploy your app to a non-Node.js runtime (like Edge or Serverless functions), make sure to read the [Non-Node.js Runtimes](../../README.md#non-nodejs-runtimes-edge-serverless) section of the main README.
|
|
@@ -31,6 +31,17 @@ $: hideVariantsStyleString = () => {
|
|
|
31
31
|
.map((value) => `.variant-${value.testVariationId} { display: none; } `)
|
|
32
32
|
.join("");
|
|
33
33
|
};
|
|
34
|
+
$: defaultContent = () => {
|
|
35
|
+
return shouldRenderVariants
|
|
36
|
+
? {
|
|
37
|
+
...content,
|
|
38
|
+
testVariationId: content?.id,
|
|
39
|
+
}
|
|
40
|
+
: handleABTestingSync({
|
|
41
|
+
item: content,
|
|
42
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
43
|
+
});
|
|
44
|
+
};
|
|
34
45
|
let shouldRenderVariants = checkShouldRunVariants({
|
|
35
46
|
canTrack: getDefaultCanTrack(canTrack),
|
|
36
47
|
content: content,
|
|
@@ -76,12 +87,7 @@ onMount(() => {
|
|
|
76
87
|
|
|
77
88
|
<ContentComponent
|
|
78
89
|
{...{}}
|
|
79
|
-
content={
|
|
80
|
-
? content
|
|
81
|
-
: handleABTestingSync({
|
|
82
|
-
item: content,
|
|
83
|
-
canTrack: getDefaultCanTrack(canTrack),
|
|
84
|
-
})}
|
|
90
|
+
content={defaultContent()}
|
|
85
91
|
classNameProp={`variant-${content?.id}`}
|
|
86
92
|
showContent={true}
|
|
87
93
|
{model}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "UNKNOWN_VERSION";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION =
|
|
1
|
+
export const SDK_VERSION = 'UNKNOWN_VERSION';
|
|
@@ -2,7 +2,25 @@ import { logger } from '../../helpers/logger.js';
|
|
|
2
2
|
import { isBrowser } from '../is-browser.js';
|
|
3
3
|
import { isEditing } from '../is-editing.js';
|
|
4
4
|
import { isNonNodeServer } from '../is-non-node-server.js';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* We need to lazy-load this module so it doesn't leak into the browser, as it is massive and not needed there.
|
|
7
|
+
* https://css-tricks.com/dynamic-conditional-imports/
|
|
8
|
+
*/
|
|
9
|
+
let runInNonNode;
|
|
10
|
+
if (isNonNodeServer()) {
|
|
11
|
+
import('./non-node-runtime.js').then(m => {
|
|
12
|
+
runInNonNode = m.runInNonNode;
|
|
13
|
+
}).catch(err => {
|
|
14
|
+
const ERROR_MESSAGE = `Error importing JS interpreter for non-Node.js runtimes. Make sure \`js-interpreter\` is installed.
|
|
15
|
+
Read more here: https://github.com/BuilderIO/builder/tree/main/packages/sdks/README.md#non-nodejs-runtimes-edge-serverless
|
|
16
|
+
`;
|
|
17
|
+
logger.error(ERROR_MESSAGE, err);
|
|
18
|
+
runInNonNode = (..._args) => {
|
|
19
|
+
logger.error(ERROR_MESSAGE);
|
|
20
|
+
return undefined;
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
6
24
|
export function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
7
25
|
if (code === '') {
|
|
8
26
|
logger.warn('Skipping evaluation of empty code block.');
|
|
@@ -3847,7 +3847,7 @@ Interpreter.prototype['getStateStack'] = Interpreter.prototype.getStateStack;
|
|
|
3847
3847
|
Interpreter.prototype['setStateStack'] = Interpreter.prototype.setStateStack;
|
|
3848
3848
|
Interpreter['VALUE_IN_DESCRIPTOR'] = Interpreter.VALUE_IN_DESCRIPTOR;
|
|
3849
3849
|
// BUILDER.IO: added acorn.parse import here
|
|
3850
|
-
import { parse } from 'acorn';
|
|
3850
|
+
import { parse } from './acorn';
|
|
3851
3851
|
Interpreter.nativeGlobal.acornParse = parse;
|
|
3852
3852
|
// BUILDER.IO: exported Interpreter
|
|
3853
3853
|
export default Interpreter;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-svelte",
|
|
3
3
|
"description": "Builder.io SDK for Svelte",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"package",
|
|
@@ -37,11 +37,25 @@
|
|
|
37
37
|
"@sveltejs/adapter-auto": "1.0.0-next.71",
|
|
38
38
|
"@sveltejs/kit": "^1.16.2",
|
|
39
39
|
"@sveltejs/package": "1.0.0-next.1",
|
|
40
|
+
"nx": "^16.6.0",
|
|
41
|
+
"nx-cloud": "^16.2.0",
|
|
40
42
|
"svelte": "^3.59.1",
|
|
41
|
-
"svelte-check": "^3.
|
|
42
|
-
"svelte-preprocess": "^
|
|
43
|
+
"svelte-check": "^3.4.6",
|
|
44
|
+
"svelte-preprocess": "^5.0.4",
|
|
43
45
|
"tslib": "^2.3.1",
|
|
44
46
|
"typescript": "^5.1.6",
|
|
45
|
-
"vite": "^
|
|
47
|
+
"vite": "^4.4.8"
|
|
48
|
+
},
|
|
49
|
+
"nx": {
|
|
50
|
+
"implicitDependencies": [
|
|
51
|
+
"@builder.io/sdks"
|
|
52
|
+
],
|
|
53
|
+
"targets": {
|
|
54
|
+
"build": {
|
|
55
|
+
"outputs": [
|
|
56
|
+
"{projectRoot}/package"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
46
60
|
}
|
|
47
61
|
}
|
|
@@ -51,6 +51,17 @@
|
|
|
51
51
|
.map((value) => `.variant-${value.testVariationId} { display: none; } `)
|
|
52
52
|
.join("");
|
|
53
53
|
};
|
|
54
|
+
$: defaultContent = () => {
|
|
55
|
+
return shouldRenderVariants
|
|
56
|
+
? {
|
|
57
|
+
...content,
|
|
58
|
+
testVariationId: content?.id,
|
|
59
|
+
}
|
|
60
|
+
: handleABTestingSync({
|
|
61
|
+
item: content,
|
|
62
|
+
canTrack: getDefaultCanTrack(canTrack),
|
|
63
|
+
});
|
|
64
|
+
};
|
|
54
65
|
|
|
55
66
|
let shouldRenderVariants = checkShouldRunVariants({
|
|
56
67
|
canTrack: getDefaultCanTrack(canTrack),
|
|
@@ -98,12 +109,7 @@
|
|
|
98
109
|
|
|
99
110
|
<ContentComponent
|
|
100
111
|
{...{}}
|
|
101
|
-
content={
|
|
102
|
-
? content
|
|
103
|
-
: handleABTestingSync({
|
|
104
|
-
item: content,
|
|
105
|
-
canTrack: getDefaultCanTrack(canTrack),
|
|
106
|
-
})}
|
|
112
|
+
content={defaultContent()}
|
|
107
113
|
classNameProp={`variant-${content?.id}`}
|
|
108
114
|
showContent={true}
|
|
109
115
|
{model}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION =
|
|
1
|
+
export const SDK_VERSION = 'UNKNOWN_VERSION'
|
|
@@ -3,8 +3,27 @@ import { logger } from '../../helpers/logger.js';
|
|
|
3
3
|
import { isBrowser } from '../is-browser.js';
|
|
4
4
|
import { isEditing } from '../is-editing.js';
|
|
5
5
|
import { isNonNodeServer } from '../is-non-node-server.js';
|
|
6
|
-
import { runInNonNode } from './non-node-runtime.js';
|
|
7
6
|
import type { ExecutorArgs } from './types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* We need to lazy-load this module so it doesn't leak into the browser, as it is massive and not needed there.
|
|
10
|
+
* https://css-tricks.com/dynamic-conditional-imports/
|
|
11
|
+
*/
|
|
12
|
+
let runInNonNode: typeof import('./non-node-runtime.js').runInNonNode;
|
|
13
|
+
if (isNonNodeServer()) {
|
|
14
|
+
import('./non-node-runtime.js').then(m => {
|
|
15
|
+
runInNonNode = m.runInNonNode;
|
|
16
|
+
}).catch(err => {
|
|
17
|
+
const ERROR_MESSAGE = `Error importing JS interpreter for non-Node.js runtimes. Make sure \`js-interpreter\` is installed.
|
|
18
|
+
Read more here: https://github.com/BuilderIO/builder/tree/main/packages/sdks/README.md#non-nodejs-runtimes-edge-serverless
|
|
19
|
+
`;
|
|
20
|
+
logger.error(ERROR_MESSAGE, err);
|
|
21
|
+
runInNonNode = (..._args) => {
|
|
22
|
+
logger.error(ERROR_MESSAGE);
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
|
8
27
|
export function evaluate({
|
|
9
28
|
code,
|
|
10
29
|
context,
|
|
@@ -3880,7 +3880,7 @@ Interpreter.prototype['setStateStack'] = Interpreter.prototype.setStateStack;
|
|
|
3880
3880
|
Interpreter['VALUE_IN_DESCRIPTOR'] = Interpreter.VALUE_IN_DESCRIPTOR;
|
|
3881
3881
|
|
|
3882
3882
|
// BUILDER.IO: added acorn.parse import here
|
|
3883
|
-
import { parse } from 'acorn';
|
|
3883
|
+
import { parse } from './acorn';
|
|
3884
3884
|
Interpreter.nativeGlobal.acornParse = parse;
|
|
3885
3885
|
|
|
3886
3886
|
// BUILDER.IO: exported Interpreter
|