@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
@@ -4,26 +4,7 @@ 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
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
- }
7
+ import { runInNonNode } from './non-node-runtime/index.js';
27
8
  export function evaluate({
28
9
  code,
29
10
  context,
@@ -0,0 +1,23 @@
1
+ import { logger } from '../../../helpers/logger.js';
2
+ import { isNonNodeServer } from '../../is-non-node-server.js';
3
+
4
+ /**
5
+ * We need to lazy-load this module so it doesn't leak into the browser, as it is massive and not needed there.
6
+ * https://css-tricks.com/dynamic-conditional-imports/
7
+ */
8
+ let runInNonNode: typeof import('./non-node-runtime.js').runInNonNode;
9
+ if (isNonNodeServer()) {
10
+ import('./non-node-runtime.js').then(m => {
11
+ runInNonNode = m.runInNonNode;
12
+ }).catch(err => {
13
+ const ERROR_MESSAGE = `Error importing JS interpreter for non-Node.js runtimes. Make sure \`js-interpreter\` is installed.
14
+ Read more here: https://github.com/BuilderIO/builder/tree/main/packages/sdks/README.md#non-nodejs-runtimes-edge-serverless
15
+ `;
16
+ logger.error(ERROR_MESSAGE, err);
17
+ runInNonNode = (..._args) => {
18
+ logger.error(ERROR_MESSAGE);
19
+ return undefined;
20
+ };
21
+ });
22
+ }
23
+ export { runInNonNode }
@@ -1,7 +1,7 @@
1
- import { logger } from '../../helpers/logger';
2
- import { set } from '../set';
3
- import Interpreter from './interpreter.js';
4
- import type { ExecutorArgs } from './types';
1
+ import { logger } from '../../../helpers/logger';
2
+ import { set } from '../../set';
3
+ import Interpreter from '../acorn-interpreter.js';
4
+ import type { ExecutorArgs } from '../types';
5
5
  const processCode = (code: string) => {
6
6
  return code.split('\n').map(line => {
7
7
  const trimmed = line.trim();
@@ -1,8 +1,4 @@
1
- import { getIdFromSearchParams } from './helpers';
2
- import { init } from './init';
3
- import type { GlobalWCache } from './types';
4
- export function getPreviewContent(searchParams: URLSearchParams) {
5
- init();
6
- const id = getIdFromSearchParams(searchParams);
7
- return typeof id === 'string' ? (globalThis as GlobalWCache)._BUILDER_PREVIEW_LRU_CACHE.get(id) : undefined;
1
+ import type { BuilderContent } from '../../types/builder-content';
2
+ export function getPreviewContent(_searchParams: URLSearchParams): BuilderContent | undefined {
3
+ return undefined;
8
4
  }
@@ -1,9 +0,0 @@
1
- import { logger } from '../logger';
2
- export const getIdFromSearchParams = (searchParams: URLSearchParams) => {
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
- }
@@ -4,14 +4,4 @@
4
4
  * Note: This logic is only used by the NextJS SDK.
5
5
  */
6
6
 
7
- import { LRUCache } from 'lru-cache';
8
- import type { GlobalWCache } from './types';
9
- export function init() {
10
- if (!(globalThis as GlobalWCache)._BUILDER_PREVIEW_LRU_CACHE) {
11
- (globalThis as GlobalWCache)._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
12
- max: 500,
13
- // how long to live in ms
14
- ttl: 1000 * 60 * 5
15
- });
16
- }
17
- }
7
+ export function init() {}
@@ -1,8 +1,4 @@
1
- 'use server';
2
-
3
1
  import type { BuilderContent } from '../../types/builder-content';
4
- import { init } from './init';
5
- import type { GlobalWCache } from './types';
6
2
  export async function postPreviewContent({
7
3
  key,
8
4
  value
@@ -10,8 +6,6 @@ export async function postPreviewContent({
10
6
  key: string;
11
7
  value: BuilderContent;
12
8
  }) {
13
- init();
14
- (globalThis as GlobalWCache)._BUILDER_PREVIEW_LRU_CACHE.set(key, value);
15
9
  return {
16
10
  [key]: value
17
11
  };
@@ -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
-
7
- import type { LRUCache } from 'lru-cache';
8
- import type { BuilderContent } from '../../types/builder-content';
9
- type BuilderLRUCache = LRUCache<string, BuilderContent>;
10
- export type GlobalWCache = typeof globalThis & {
11
- _BUILDER_PREVIEW_LRU_CACHE: BuilderLRUCache;
12
- }
File without changes