@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.
- package/dist/functions/evaluate/acorn-interpreter.js +3111 -0
- package/dist/functions/evaluate/evaluate.js +1 -19
- package/dist/functions/evaluate/non-node-runtime/index.d.ts +1 -0
- package/dist/functions/evaluate/non-node-runtime/index.js +2 -0
- package/dist/functions/evaluate/{non-node-runtime.d.ts → non-node-runtime/non-node-runtime.d.ts} +1 -1
- package/dist/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js} +3 -3
- package/dist/helpers/preview-lru-cache/get.js +3 -1
- package/dist/helpers/preview-lru-cache/init.js +1 -1
- package/dist/helpers/preview-lru-cache/set.d.ts +1 -1
- package/dist/helpers/preview-lru-cache/set.js +2 -4
- package/package.json +4 -4
- package/dist/functions/evaluate/acorn.d.ts +0 -0
- package/dist/functions/evaluate/acorn.js +0 -2432
- package/dist/functions/evaluate/interpreter.js +0 -3853
- /package/dist/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 @@
|
|
|
1
|
+
export { runInNonNode } from './non-node-runtime.js';
|
package/dist/functions/evaluate/{non-node-runtime.d.ts → non-node-runtime/non-node-runtime.d.ts}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ExecutorArgs } from '
|
|
1
|
+
import type { ExecutorArgs } from '../types';
|
|
2
2
|
export declare const runInNonNode: ({ builder, context, event, rootState, localState, rootSetState, useCode }: ExecutorArgs) => any;
|
package/dist/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { logger } from '
|
|
2
|
-
import { set } from '
|
|
3
|
-
import Interpreter from '
|
|
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'
|
|
6
|
+
return typeof id === 'string'
|
|
7
|
+
? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(id)
|
|
8
|
+
: undefined;
|
|
7
9
|
}
|
|
@@ -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.
|
|
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
|