@builder.io/sdk-qwik 0.23.0 → 0.24.0
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/lib/browser/constants/sdk-version.qwik.cjs +1 -1
- package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
- package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
- package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
- package/lib/node/constants/sdk-version.qwik.cjs +1 -1
- package/lib/node/constants/sdk-version.qwik.mjs +1 -1
- package/lib/node/functions/evaluate/node-runtime/node-runtime.qwik.cjs +56 -58
- package/lib/node/functions/evaluate/node-runtime/node-runtime.qwik.mjs +56 -58
- package/package.json +1 -1
- package/types/src/constants/sdk-version.d.ts +1 -1
- package/types/src/types/input.d.ts +1 -1
|
@@ -55,12 +55,15 @@ if (typeof output === 'object' && output !== null) {
|
|
|
55
55
|
`;
|
|
56
56
|
};
|
|
57
57
|
let IVM_INSTANCE = null;
|
|
58
|
-
let
|
|
59
|
-
|
|
58
|
+
let IVM_OPTIONS = {
|
|
59
|
+
memoryLimit: 128
|
|
60
|
+
};
|
|
61
|
+
const setIvm = (ivm, options) => {
|
|
60
62
|
if (IVM_INSTANCE)
|
|
61
63
|
return;
|
|
62
64
|
IVM_INSTANCE = ivm;
|
|
63
|
-
|
|
65
|
+
if (options)
|
|
66
|
+
IVM_OPTIONS = options;
|
|
64
67
|
};
|
|
65
68
|
const SHOULD_MENTION_INITIALIZE_SCRIPT = sdkName.SDK_NAME === "@builder.io/sdk-react-nextjs" || sdkName.SDK_NAME === "@builder.io/sdk-react" || sdkName.SDK_NAME === "@builder.io/sdk-qwik" || sdkName.SDK_NAME === "@builder.io/sdk-vue";
|
|
66
69
|
const getIvm = () => {
|
|
@@ -83,64 +86,59 @@ const getIvm = () => {
|
|
|
83
86
|
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
84
87
|
throw new Error(ERROR_MESSAGE);
|
|
85
88
|
};
|
|
86
|
-
function setIsolateContext(options = {
|
|
87
|
-
memoryLimit: 128
|
|
88
|
-
}) {
|
|
89
|
-
if (IVM_CONTEXT)
|
|
90
|
-
return IVM_CONTEXT;
|
|
91
|
-
const ivm = getIvm();
|
|
92
|
-
const isolate = new ivm.Isolate(options);
|
|
93
|
-
const context = isolate.createContextSync();
|
|
94
|
-
const jail = context.global;
|
|
95
|
-
jail.setSync("global", jail.derefInto());
|
|
96
|
-
jail.setSync("log", function(...logArgs) {
|
|
97
|
-
console.log(...logArgs);
|
|
98
|
-
});
|
|
99
|
-
jail.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
100
|
-
IVM_CONTEXT = context;
|
|
101
|
-
return context;
|
|
102
|
-
}
|
|
103
|
-
const getIsolateContext = () => {
|
|
104
|
-
return setIsolateContext();
|
|
105
|
-
};
|
|
106
89
|
const runInNode = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
|
|
107
90
|
const ivm = getIvm();
|
|
108
|
-
|
|
109
|
-
...rootState,
|
|
110
|
-
...localState
|
|
111
|
-
});
|
|
112
|
-
const args = helpers.getFunctionArguments({
|
|
113
|
-
builder,
|
|
114
|
-
context,
|
|
115
|
-
event,
|
|
116
|
-
state
|
|
117
|
-
});
|
|
118
|
-
const isolateContext = getIsolateContext();
|
|
119
|
-
const jail = isolateContext.global;
|
|
120
|
-
jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
|
|
121
|
-
set.set(rootState, key, value);
|
|
122
|
-
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
123
|
-
});
|
|
124
|
-
args.forEach(([key, arg]) => {
|
|
125
|
-
const val = typeof arg === "object" ? new ivm.Reference(
|
|
126
|
-
// workaround: methods with default values for arguments is not being cloned over
|
|
127
|
-
key === "builder" ? {
|
|
128
|
-
...arg,
|
|
129
|
-
getUserAttributes: () => arg.getUserAttributes()
|
|
130
|
-
} : arg
|
|
131
|
-
) : null;
|
|
132
|
-
jail.setSync(getSyncValName(key), val);
|
|
133
|
-
});
|
|
134
|
-
const evalStr = processCode({
|
|
135
|
-
code,
|
|
136
|
-
args
|
|
137
|
-
});
|
|
138
|
-
const resultStr = isolateContext.evalClosureSync(evalStr);
|
|
91
|
+
let isolate;
|
|
139
92
|
try {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
93
|
+
isolate = new ivm.Isolate(IVM_OPTIONS);
|
|
94
|
+
const isolateContext = isolate.createContextSync();
|
|
95
|
+
const jail = isolateContext.global;
|
|
96
|
+
jail.setSync("global", jail.derefInto());
|
|
97
|
+
jail.setSync("log", function(...logArgs) {
|
|
98
|
+
console.log(...logArgs);
|
|
99
|
+
});
|
|
100
|
+
jail.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
101
|
+
const state = fastClone.fastClone({
|
|
102
|
+
...rootState,
|
|
103
|
+
...localState
|
|
104
|
+
});
|
|
105
|
+
const args = helpers.getFunctionArguments({
|
|
106
|
+
builder,
|
|
107
|
+
context,
|
|
108
|
+
event,
|
|
109
|
+
state
|
|
110
|
+
});
|
|
111
|
+
jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
|
|
112
|
+
set.set(rootState, key, value);
|
|
113
|
+
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
114
|
+
});
|
|
115
|
+
args.forEach(([key, arg]) => {
|
|
116
|
+
const val = typeof arg === "object" ? new ivm.Reference(
|
|
117
|
+
// workaround: methods with default values for arguments is not being cloned over
|
|
118
|
+
key === "builder" ? {
|
|
119
|
+
...arg,
|
|
120
|
+
getUserAttributes: () => arg.getUserAttributes()
|
|
121
|
+
} : arg
|
|
122
|
+
) : null;
|
|
123
|
+
jail.setSync(getSyncValName(key), val);
|
|
124
|
+
});
|
|
125
|
+
const evalStr = processCode({
|
|
126
|
+
code,
|
|
127
|
+
args
|
|
128
|
+
});
|
|
129
|
+
const resultStr = isolateContext.evalClosureSync(evalStr);
|
|
130
|
+
try {
|
|
131
|
+
const res = JSON.parse(resultStr);
|
|
132
|
+
return res;
|
|
133
|
+
} catch (_error) {
|
|
134
|
+
return resultStr;
|
|
135
|
+
}
|
|
136
|
+
} finally {
|
|
137
|
+
if (isolate)
|
|
138
|
+
try {
|
|
139
|
+
isolate.dispose();
|
|
140
|
+
} catch (e) {
|
|
141
|
+
}
|
|
144
142
|
}
|
|
145
143
|
};
|
|
146
144
|
exports.runInNode = runInNode;
|
|
@@ -53,12 +53,15 @@ if (typeof output === 'object' && output !== null) {
|
|
|
53
53
|
`;
|
|
54
54
|
};
|
|
55
55
|
let IVM_INSTANCE = null;
|
|
56
|
-
let
|
|
57
|
-
|
|
56
|
+
let IVM_OPTIONS = {
|
|
57
|
+
memoryLimit: 128
|
|
58
|
+
};
|
|
59
|
+
const setIvm = (ivm, options) => {
|
|
58
60
|
if (IVM_INSTANCE)
|
|
59
61
|
return;
|
|
60
62
|
IVM_INSTANCE = ivm;
|
|
61
|
-
|
|
63
|
+
if (options)
|
|
64
|
+
IVM_OPTIONS = options;
|
|
62
65
|
};
|
|
63
66
|
const SHOULD_MENTION_INITIALIZE_SCRIPT = SDK_NAME === "@builder.io/sdk-react-nextjs" || SDK_NAME === "@builder.io/sdk-react" || SDK_NAME === "@builder.io/sdk-qwik" || SDK_NAME === "@builder.io/sdk-vue";
|
|
64
67
|
const getIvm = () => {
|
|
@@ -81,64 +84,59 @@ const getIvm = () => {
|
|
|
81
84
|
For more information, visit https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments`;
|
|
82
85
|
throw new Error(ERROR_MESSAGE);
|
|
83
86
|
};
|
|
84
|
-
function setIsolateContext(options = {
|
|
85
|
-
memoryLimit: 128
|
|
86
|
-
}) {
|
|
87
|
-
if (IVM_CONTEXT)
|
|
88
|
-
return IVM_CONTEXT;
|
|
89
|
-
const ivm = getIvm();
|
|
90
|
-
const isolate = new ivm.Isolate(options);
|
|
91
|
-
const context = isolate.createContextSync();
|
|
92
|
-
const jail = context.global;
|
|
93
|
-
jail.setSync("global", jail.derefInto());
|
|
94
|
-
jail.setSync("log", function(...logArgs) {
|
|
95
|
-
console.log(...logArgs);
|
|
96
|
-
});
|
|
97
|
-
jail.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
98
|
-
IVM_CONTEXT = context;
|
|
99
|
-
return context;
|
|
100
|
-
}
|
|
101
|
-
const getIsolateContext = () => {
|
|
102
|
-
return setIsolateContext();
|
|
103
|
-
};
|
|
104
87
|
const runInNode = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
|
|
105
88
|
const ivm = getIvm();
|
|
106
|
-
|
|
107
|
-
...rootState,
|
|
108
|
-
...localState
|
|
109
|
-
});
|
|
110
|
-
const args = getFunctionArguments({
|
|
111
|
-
builder,
|
|
112
|
-
context,
|
|
113
|
-
event,
|
|
114
|
-
state
|
|
115
|
-
});
|
|
116
|
-
const isolateContext = getIsolateContext();
|
|
117
|
-
const jail = isolateContext.global;
|
|
118
|
-
jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
|
|
119
|
-
set(rootState, key, value);
|
|
120
|
-
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
121
|
-
});
|
|
122
|
-
args.forEach(([key, arg]) => {
|
|
123
|
-
const val = typeof arg === "object" ? new ivm.Reference(
|
|
124
|
-
// workaround: methods with default values for arguments is not being cloned over
|
|
125
|
-
key === "builder" ? {
|
|
126
|
-
...arg,
|
|
127
|
-
getUserAttributes: () => arg.getUserAttributes()
|
|
128
|
-
} : arg
|
|
129
|
-
) : null;
|
|
130
|
-
jail.setSync(getSyncValName(key), val);
|
|
131
|
-
});
|
|
132
|
-
const evalStr = processCode({
|
|
133
|
-
code,
|
|
134
|
-
args
|
|
135
|
-
});
|
|
136
|
-
const resultStr = isolateContext.evalClosureSync(evalStr);
|
|
89
|
+
let isolate;
|
|
137
90
|
try {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
91
|
+
isolate = new ivm.Isolate(IVM_OPTIONS);
|
|
92
|
+
const isolateContext = isolate.createContextSync();
|
|
93
|
+
const jail = isolateContext.global;
|
|
94
|
+
jail.setSync("global", jail.derefInto());
|
|
95
|
+
jail.setSync("log", function(...logArgs) {
|
|
96
|
+
console.log(...logArgs);
|
|
97
|
+
});
|
|
98
|
+
jail.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
99
|
+
const state = fastClone({
|
|
100
|
+
...rootState,
|
|
101
|
+
...localState
|
|
102
|
+
});
|
|
103
|
+
const args = getFunctionArguments({
|
|
104
|
+
builder,
|
|
105
|
+
context,
|
|
106
|
+
event,
|
|
107
|
+
state
|
|
108
|
+
});
|
|
109
|
+
jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
|
|
110
|
+
set(rootState, key, value);
|
|
111
|
+
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
112
|
+
});
|
|
113
|
+
args.forEach(([key, arg]) => {
|
|
114
|
+
const val = typeof arg === "object" ? new ivm.Reference(
|
|
115
|
+
// workaround: methods with default values for arguments is not being cloned over
|
|
116
|
+
key === "builder" ? {
|
|
117
|
+
...arg,
|
|
118
|
+
getUserAttributes: () => arg.getUserAttributes()
|
|
119
|
+
} : arg
|
|
120
|
+
) : null;
|
|
121
|
+
jail.setSync(getSyncValName(key), val);
|
|
122
|
+
});
|
|
123
|
+
const evalStr = processCode({
|
|
124
|
+
code,
|
|
125
|
+
args
|
|
126
|
+
});
|
|
127
|
+
const resultStr = isolateContext.evalClosureSync(evalStr);
|
|
128
|
+
try {
|
|
129
|
+
const res = JSON.parse(resultStr);
|
|
130
|
+
return res;
|
|
131
|
+
} catch (_error) {
|
|
132
|
+
return resultStr;
|
|
133
|
+
}
|
|
134
|
+
} finally {
|
|
135
|
+
if (isolate)
|
|
136
|
+
try {
|
|
137
|
+
isolate.dispose();
|
|
138
|
+
} catch (e) {
|
|
139
|
+
}
|
|
142
140
|
}
|
|
143
141
|
};
|
|
144
142
|
export {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.24.0";
|
|
@@ -3,7 +3,7 @@ export interface Input {
|
|
|
3
3
|
name: string;
|
|
4
4
|
/** A friendlier name to show in the UI if the component prop name is not ideal for end users */
|
|
5
5
|
friendlyName?: string;
|
|
6
|
-
/**
|
|
6
|
+
/** A description to show in the UI to give guidance on how to use this input */
|
|
7
7
|
description?: string;
|
|
8
8
|
/** A default value to use */
|
|
9
9
|
defaultValue?: any;
|