@builder.io/sdk-react-nextjs 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.
@@ -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 @@
1
+ export { runInNonNode } from './non-node-runtime.js';
@@ -0,0 +1,2 @@
1
+ // TEMPORARY FIX UNTIL we fix dynamic imports
2
+ export { runInNonNode } from './non-node-runtime.js';
@@ -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();
@@ -3,5 +3,7 @@ import { init } from './init';
3
3
  export function getPreviewContent(searchParams) {
4
4
  init();
5
5
  const id = getIdFromSearchParams(searchParams);
6
- return typeof id === 'string' ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(id) : undefined;
6
+ return typeof id === 'string'
7
+ ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(id)
8
+ : undefined;
7
9
  }
@@ -9,7 +9,7 @@ export function init() {
9
9
  globalThis._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
10
10
  max: 500,
11
11
  // how long to live in ms
12
- ttl: 1000 * 60 * 5
12
+ ttl: 1000 * 60 * 5,
13
13
  });
14
14
  }
15
15
  }
@@ -1,5 +1,5 @@
1
1
  import type { BuilderContent } from '../../types/builder-content';
2
- export declare function postPreviewContent({ key, value }: {
2
+ export declare function postPreviewContent({ key, value, }: {
3
3
  key: string;
4
4
  value: BuilderContent;
5
5
  }): Promise<{
@@ -1,9 +1,7 @@
1
1
  'use server';
2
2
  import { init } from './init';
3
- export async function postPreviewContent({ key, value }) {
3
+ export async function postPreviewContent({ key, value, }) {
4
4
  init();
5
5
  globalThis._BUILDER_PREVIEW_LRU_CACHE.set(key, value);
6
- return {
7
- [key]: value
8
- };
6
+ return { [key]: value };
9
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-nextjs",
3
3
  "description": "Builder.io SDK for React",
4
- "version": "0.5.3",
4
+ "version": "0.5.5",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
@@ -15,7 +15,8 @@
15
15
  },
16
16
  "peerDependencies": {
17
17
  "next": "^13.4.4",
18
- "react": "^18.2.0"
18
+ "react": "^18.2.0",
19
+ "react-dom": "^18.2.0"
19
20
  },
20
21
  "devDependencies": {
21
22
  "next": "^13.4.4",
@@ -26,8 +27,7 @@
26
27
  "typescript": "^5.1.6"
27
28
  },
28
29
  "dependencies": {
29
- "lru-cache": "^10.0.0",
30
- "react-dom": "^18.2.0"
30
+ "lru-cache": "^10.0.0"
31
31
  },
32
32
  "nx": {
33
33
  "implicitDependencies": [
File without changes