@builder.io/sdk-svelte 0.5.2 → 0.5.4

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 (31) hide show
  1. package/README.md +4 -0
  2. package/package/--package.json +21 -7
  3. package/package/CHANGELOG.md +5 -0
  4. package/package/README.md +4 -0
  5. package/package/blocks/image/image.svelte.d.ts +1 -0
  6. package/package/blocks/text/text.svelte +2 -1
  7. package/package/components/content-variants/content-variants.svelte +12 -6
  8. package/package/constants/sdk-version.d.ts +1 -1
  9. package/package/constants/sdk-version.js +1 -1
  10. package/package/functions/evaluate/acorn-interpreter.js +3111 -0
  11. package/package/functions/evaluate/evaluate.js +1 -1
  12. package/package/functions/evaluate/non-node-runtime/index.d.ts +6 -0
  13. package/package/functions/evaluate/non-node-runtime/index.js +22 -0
  14. package/package/functions/evaluate/{non-node-runtime.d.ts → non-node-runtime/non-node-runtime.d.ts} +1 -1
  15. package/package/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js} +3 -3
  16. package/package/functions/evaluate/types.d.ts +1 -0
  17. package/package.json +18 -4
  18. package/src/blocks/text/text.svelte +2 -1
  19. package/src/components/content-variants/content-variants.svelte +12 -6
  20. package/src/constants/sdk-version.ts +1 -1
  21. package/src/functions/evaluate/acorn-interpreter.ts +2891 -0
  22. package/src/functions/evaluate/evaluate.ts +1 -1
  23. package/src/functions/evaluate/non-node-runtime/index.ts +23 -0
  24. package/src/functions/evaluate/{non-node-runtime.ts → non-node-runtime/non-node-runtime.ts} +4 -4
  25. package/src/functions/evaluate/types.ts +2 -1
  26. package/package/functions/evaluate/acorn.d.ts +0 -0
  27. package/package/functions/evaluate/acorn.js +0 -2433
  28. package/package/functions/evaluate/interpreter.js +0 -3853
  29. package/src/functions/evaluate/acorn.ts +0 -2501
  30. package/src/functions/evaluate/interpreter.ts +0 -3887
  31. /package/package/functions/evaluate/{interpreter.d.ts → acorn-interpreter.d.ts} +0 -0
@@ -2,7 +2,7 @@ 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
- import { runInNonNode } from './non-node-runtime.js';
5
+ import { runInNonNode } from './non-node-runtime/index.js';
6
6
  export function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
7
7
  if (code === '') {
8
8
  logger.warn('Skipping evaluation of empty code block.');
@@ -0,0 +1,6 @@
1
+ /**
2
+ * We need to lazy-load this module so it doesn't leak into the browser, as it is massive and not needed there.
3
+ * https://css-tricks.com/dynamic-conditional-imports/
4
+ */
5
+ declare let runInNonNode: typeof import('./non-node-runtime.js').runInNonNode;
6
+ export { runInNonNode };
@@ -0,0 +1,22 @@
1
+ import { logger } from '../../../helpers/logger.js';
2
+ import { isNonNodeServer } from '../../is-non-node-server.js';
3
+ /**
4
+ * We need to lazy-load this module so it doesn't leak into the browser, as it is massive and not needed there.
5
+ * https://css-tricks.com/dynamic-conditional-imports/
6
+ */
7
+ let runInNonNode;
8
+ if (isNonNodeServer()) {
9
+ import('./non-node-runtime.js').then(m => {
10
+ runInNonNode = m.runInNonNode;
11
+ }).catch(err => {
12
+ const ERROR_MESSAGE = `Error importing JS interpreter for non-Node.js runtimes. Make sure \`js-interpreter\` is installed.
13
+ Read more here: https://github.com/BuilderIO/builder/tree/main/packages/sdks/README.md#non-nodejs-runtimes-edge-serverless
14
+ `;
15
+ logger.error(ERROR_MESSAGE, err);
16
+ runInNonNode = (..._args) => {
17
+ logger.error(ERROR_MESSAGE);
18
+ return undefined;
19
+ };
20
+ });
21
+ }
22
+ export { runInNonNode };
@@ -1,2 +1,2 @@
1
- import type { ExecutorArgs } from './types';
1
+ import type { ExecutorArgs } from '../types';
2
2
  export declare const runInNonNode: ({ builder, context, event, rootState, localState, rootSetState, useCode }: ExecutorArgs) => any;
@@ -1,6 +1,6 @@
1
- import { logger } from '../../helpers/logger';
2
- import { set } from '../set';
3
- import Interpreter from './interpreter.js';
1
+ import { logger } from '../../../helpers/logger';
2
+ import { set } from '../../set';
3
+ import Interpreter from '../acorn-interpreter.js';
4
4
  const processCode = (code) => {
5
5
  return code.split('\n').map(line => {
6
6
  const trimmed = line.trim();
@@ -8,3 +8,4 @@ export type ExecutorArgs = Pick<BuilderContextInterface, 'localState' | 'context
8
8
  };
9
9
  event: Event | undefined;
10
10
  };
11
+ export type Executor = (args: ExecutorArgs) => any;
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.2",
4
+ "version": "0.5.4",
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.3.2",
42
- "svelte-preprocess": "^4.10.6",
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": "^3.0.4"
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
  }
@@ -22,5 +22,6 @@
22
22
  use:mitosis_styling={{
23
23
  outline: "none",
24
24
  }}
25
- class="builder-text">{@html text?.toString() || ""}</span
25
+ class="builder-text"
26
+ {...{}}>{@html text?.toString() || ""}</span
26
27
  >
@@ -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={shouldRenderVariants
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 = "0.5.2"
1
+ export const SDK_VERSION = 'UNKNOWN_VERSION'