@builder.io/sdk-svelte 0.5.3 → 0.5.5

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 (32) hide show
  1. package/package/--package.json +4 -4
  2. package/package/CHANGELOG.md +9 -0
  3. package/package/functions/evaluate/acorn-interpreter.js +3111 -0
  4. package/package/functions/evaluate/evaluate.js +1 -19
  5. package/package/functions/evaluate/non-node-runtime/index.d.ts +6 -0
  6. package/package/functions/evaluate/non-node-runtime/index.js +22 -0
  7. package/package/functions/evaluate/{non-node-runtime.d.ts → non-node-runtime/non-node-runtime.d.ts} +1 -1
  8. package/package/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js} +3 -3
  9. package/package/helpers/preview-lru-cache/get.d.ts +2 -1
  10. package/package/helpers/preview-lru-cache/get.js +2 -6
  11. package/package/helpers/preview-lru-cache/helpers.d.ts +0 -1
  12. package/package/helpers/preview-lru-cache/helpers.js +1 -9
  13. package/package/helpers/preview-lru-cache/init.js +1 -10
  14. package/package/helpers/preview-lru-cache/set.js +0 -4
  15. package/package/helpers/preview-lru-cache/types.d.ts +0 -12
  16. package/package/helpers/preview-lru-cache/types.js +1 -6
  17. package/package.json +1 -1
  18. package/src/functions/evaluate/acorn-interpreter.ts +2891 -0
  19. package/src/functions/evaluate/evaluate.ts +1 -20
  20. package/src/functions/evaluate/non-node-runtime/index.ts +23 -0
  21. package/src/functions/evaluate/{non-node-runtime.ts → non-node-runtime/non-node-runtime.ts} +4 -4
  22. package/src/helpers/preview-lru-cache/get.ts +3 -7
  23. package/src/helpers/preview-lru-cache/helpers.ts +0 -9
  24. package/src/helpers/preview-lru-cache/init.ts +1 -11
  25. package/src/helpers/preview-lru-cache/set.ts +0 -6
  26. package/src/helpers/preview-lru-cache/types.ts +0 -12
  27. package/package/functions/evaluate/acorn.d.ts +0 -0
  28. package/package/functions/evaluate/acorn.js +0 -2433
  29. package/package/functions/evaluate/interpreter.js +0 -3853
  30. package/src/functions/evaluate/acorn.ts +0 -2501
  31. package/src/functions/evaluate/interpreter.ts +0 -3887
  32. /package/package/functions/evaluate/{interpreter.d.ts → acorn-interpreter.d.ts} +0 -0
@@ -2,25 +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
- /**
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
- }
5
+ import { runInNonNode } from './non-node-runtime/index.js';
24
6
  export function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
25
7
  if (code === '') {
26
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();
@@ -1 +1,2 @@
1
- export declare function getPreviewContent(searchParams: URLSearchParams): import("../../types/builder-content").BuilderContent | undefined;
1
+ import type { BuilderContent } from '../../types/builder-content';
2
+ export declare function getPreviewContent(_searchParams: URLSearchParams): BuilderContent | undefined;
@@ -1,7 +1,3 @@
1
- import { getIdFromSearchParams } from './helpers';
2
- import { init } from './init';
3
- export function getPreviewContent(searchParams) {
4
- init();
5
- const id = getIdFromSearchParams(searchParams);
6
- return typeof id === 'string' ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(id) : undefined;
1
+ export function getPreviewContent(_searchParams) {
2
+ return undefined;
7
3
  }
@@ -1 +0,0 @@
1
- export declare const getIdFromSearchParams: (searchParams: URLSearchParams) => string | null;
@@ -1,9 +1 @@
1
- import { logger } from '../logger';
2
- export const getIdFromSearchParams = (searchParams) => {
3
- const previewedModel = searchParams.get('preview');
4
- const previewedId = searchParams.get('overrides.' + previewedModel);
5
- if (!previewedId) {
6
- logger.warn('No previewed ID found in search params.');
7
- }
8
- return previewedId;
9
- };
1
+ "use strict";
@@ -3,13 +3,4 @@
3
3
  *
4
4
  * Note: This logic is only used by the NextJS SDK.
5
5
  */
6
- import { LRUCache } from 'lru-cache';
7
- export function init() {
8
- if (!globalThis._BUILDER_PREVIEW_LRU_CACHE) {
9
- globalThis._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
10
- max: 500,
11
- // how long to live in ms
12
- ttl: 1000 * 60 * 5
13
- });
14
- }
15
- }
6
+ export function init() { }
@@ -1,8 +1,4 @@
1
- 'use server';
2
- import { init } from './init';
3
1
  export async function postPreviewContent({ key, value }) {
4
- init();
5
- globalThis._BUILDER_PREVIEW_LRU_CACHE.set(key, value);
6
2
  return {
7
3
  [key]: value
8
4
  };
@@ -1,12 +0,0 @@
1
- /**
2
- * This is an LRU cache to hold preview content on the server-side.
3
- *
4
- * Note: This logic is only used by the NextJS SDK.
5
- */
6
- import type { LRUCache } from 'lru-cache';
7
- import type { BuilderContent } from '../../types/builder-content';
8
- type BuilderLRUCache = LRUCache<string, BuilderContent>;
9
- export type GlobalWCache = typeof globalThis & {
10
- _BUILDER_PREVIEW_LRU_CACHE: BuilderLRUCache;
11
- };
12
- export {};
@@ -1,6 +1 @@
1
- /**
2
- * This is an LRU cache to hold preview content on the server-side.
3
- *
4
- * Note: This logic is only used by the NextJS SDK.
5
- */
6
- export {};
1
+ "use strict";
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.3",
4
+ "version": "0.5.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "package",