@builder.io/sdk-qwik 0.12.4 → 0.12.6
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/index.qwik.cjs +44 -13
- package/lib/browser/index.qwik.mjs +45 -14
- package/lib/edge/index.qwik.cjs +68 -37
- package/lib/edge/index.qwik.mjs +69 -38
- package/lib/node/index.qwik.cjs +70 -39
- package/lib/node/index.qwik.mjs +70 -39
- package/package.json +1 -1
- package/types/src/constants/sdk-version.d.ts +1 -1
- package/types/src/functions/evaluate/browser-runtime/browser.d.ts +5 -1
- package/types/src/functions/evaluate/should-force-browser-runtime-in-node.d.ts +1 -0
|
@@ -182,29 +182,62 @@ const runInBrowser = ({ code, builder, context, event, localState, rootSetState,
|
|
|
182
182
|
builder,
|
|
183
183
|
context,
|
|
184
184
|
event,
|
|
185
|
-
state: flattenState(
|
|
185
|
+
state: flattenState({
|
|
186
|
+
rootState,
|
|
187
|
+
localState,
|
|
188
|
+
rootSetState
|
|
189
|
+
})
|
|
186
190
|
});
|
|
187
191
|
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
188
192
|
};
|
|
189
|
-
function flattenState(rootState, localState, rootSetState) {
|
|
190
|
-
if (rootState === localState)
|
|
191
|
-
throw new Error("rootState === localState");
|
|
193
|
+
function flattenState({ rootState, localState, rootSetState }) {
|
|
192
194
|
return new Proxy(rootState, {
|
|
193
|
-
get: (
|
|
195
|
+
get: (target, prop) => {
|
|
194
196
|
if (localState && prop in localState)
|
|
195
197
|
return localState[prop];
|
|
196
|
-
|
|
198
|
+
const val = target[prop];
|
|
199
|
+
if (typeof val === "object")
|
|
200
|
+
return flattenState({
|
|
201
|
+
rootState: val,
|
|
202
|
+
localState: void 0,
|
|
203
|
+
rootSetState: rootSetState ? (subState) => {
|
|
204
|
+
target[prop] = subState;
|
|
205
|
+
rootSetState(target);
|
|
206
|
+
} : void 0
|
|
207
|
+
});
|
|
208
|
+
return val;
|
|
197
209
|
},
|
|
198
|
-
set: (
|
|
210
|
+
set: (target, prop, value) => {
|
|
199
211
|
if (localState && prop in localState)
|
|
200
212
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
201
|
-
|
|
202
|
-
rootSetState == null ? void 0 : rootSetState(
|
|
213
|
+
target[prop] = value;
|
|
214
|
+
rootSetState == null ? void 0 : rootSetState(target);
|
|
203
215
|
return true;
|
|
204
216
|
}
|
|
205
217
|
});
|
|
206
218
|
}
|
|
207
|
-
const
|
|
219
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
220
|
+
function isNodeRuntime() {
|
|
221
|
+
var _a;
|
|
222
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
223
|
+
}
|
|
224
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
225
|
+
var _a;
|
|
226
|
+
if (!isNodeRuntime())
|
|
227
|
+
return false;
|
|
228
|
+
const isArm64 = process.arch === "arm64";
|
|
229
|
+
const isNode20 = process.version.startsWith("v20");
|
|
230
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
231
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
232
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
233
|
+
If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
|
|
234
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
235
|
+
`);
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
return false;
|
|
239
|
+
};
|
|
240
|
+
const chooseBrowserOrServerEval = (args) => build.isBrowser || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInBrowser(args);
|
|
208
241
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
209
242
|
if (code === "") {
|
|
210
243
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -375,7 +408,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
375
408
|
return newSizes;
|
|
376
409
|
};
|
|
377
410
|
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
378
|
-
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
379
411
|
const convertStyleMapToCSSArray = (style) => {
|
|
380
412
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
381
413
|
if (typeof value === "string")
|
|
@@ -3323,7 +3355,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3323
3355
|
}
|
|
3324
3356
|
};
|
|
3325
3357
|
};
|
|
3326
|
-
const SDK_VERSION = "0.12.
|
|
3358
|
+
const SDK_VERSION = "0.12.6";
|
|
3327
3359
|
const registry = {};
|
|
3328
3360
|
function register(type, info) {
|
|
3329
3361
|
let typeList = registry[type];
|
|
@@ -3718,7 +3750,6 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
|
|
|
3718
3750
|
var _a2, _b2;
|
|
3719
3751
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
3720
3752
|
});
|
|
3721
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
3722
3753
|
evaluateJsCode(props2);
|
|
3723
3754
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
3724
3755
|
elementRef,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { componentQrl, inlinedQrl, _jsxBranch, _jsxC, Slot as Slot$1, _fnSignal, _IMMUTABLE, createContextId, _jsxQ, useComputedQrl, useLexicalScope, useStore, useContextProvider, _wrapProp, useStylesScopedQrl, useContext, Fragment as Fragment$1, _jsxS, useSignal, useOn, useTaskQrl, createElement } from "@builder.io/qwik";
|
|
2
2
|
import { Fragment } from "@builder.io/qwik/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { isBrowser as isBrowser$1 } from "@builder.io/qwik/build";
|
|
4
4
|
const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set([
|
|
5
5
|
"area",
|
|
6
6
|
"base",
|
|
@@ -180,29 +180,62 @@ const runInBrowser = ({ code, builder, context, event, localState, rootSetState,
|
|
|
180
180
|
builder,
|
|
181
181
|
context,
|
|
182
182
|
event,
|
|
183
|
-
state: flattenState(
|
|
183
|
+
state: flattenState({
|
|
184
|
+
rootState,
|
|
185
|
+
localState,
|
|
186
|
+
rootSetState
|
|
187
|
+
})
|
|
184
188
|
});
|
|
185
189
|
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
186
190
|
};
|
|
187
|
-
function flattenState(rootState, localState, rootSetState) {
|
|
188
|
-
if (rootState === localState)
|
|
189
|
-
throw new Error("rootState === localState");
|
|
191
|
+
function flattenState({ rootState, localState, rootSetState }) {
|
|
190
192
|
return new Proxy(rootState, {
|
|
191
|
-
get: (
|
|
193
|
+
get: (target, prop) => {
|
|
192
194
|
if (localState && prop in localState)
|
|
193
195
|
return localState[prop];
|
|
194
|
-
|
|
196
|
+
const val = target[prop];
|
|
197
|
+
if (typeof val === "object")
|
|
198
|
+
return flattenState({
|
|
199
|
+
rootState: val,
|
|
200
|
+
localState: void 0,
|
|
201
|
+
rootSetState: rootSetState ? (subState) => {
|
|
202
|
+
target[prop] = subState;
|
|
203
|
+
rootSetState(target);
|
|
204
|
+
} : void 0
|
|
205
|
+
});
|
|
206
|
+
return val;
|
|
195
207
|
},
|
|
196
|
-
set: (
|
|
208
|
+
set: (target, prop, value) => {
|
|
197
209
|
if (localState && prop in localState)
|
|
198
210
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
199
|
-
|
|
200
|
-
rootSetState == null ? void 0 : rootSetState(
|
|
211
|
+
target[prop] = value;
|
|
212
|
+
rootSetState == null ? void 0 : rootSetState(target);
|
|
201
213
|
return true;
|
|
202
214
|
}
|
|
203
215
|
});
|
|
204
216
|
}
|
|
205
|
-
const
|
|
217
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
218
|
+
function isNodeRuntime() {
|
|
219
|
+
var _a;
|
|
220
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
221
|
+
}
|
|
222
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
223
|
+
var _a;
|
|
224
|
+
if (!isNodeRuntime())
|
|
225
|
+
return false;
|
|
226
|
+
const isArm64 = process.arch === "arm64";
|
|
227
|
+
const isNode20 = process.version.startsWith("v20");
|
|
228
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
229
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
230
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
231
|
+
If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
|
|
232
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
233
|
+
`);
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
return false;
|
|
237
|
+
};
|
|
238
|
+
const chooseBrowserOrServerEval = (args) => isBrowser$1 || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInBrowser(args);
|
|
206
239
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
207
240
|
if (code === "") {
|
|
208
241
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -373,7 +406,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
373
406
|
return newSizes;
|
|
374
407
|
};
|
|
375
408
|
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
376
|
-
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
377
409
|
const convertStyleMapToCSSArray = (style) => {
|
|
378
410
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
379
411
|
if (typeof value === "string")
|
|
@@ -3321,7 +3353,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3321
3353
|
}
|
|
3322
3354
|
};
|
|
3323
3355
|
};
|
|
3324
|
-
const SDK_VERSION = "0.12.
|
|
3356
|
+
const SDK_VERSION = "0.12.6";
|
|
3325
3357
|
const registry = {};
|
|
3326
3358
|
function register(type, info) {
|
|
3327
3359
|
let typeList = registry[type];
|
|
@@ -3716,7 +3748,6 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
3716
3748
|
var _a2, _b2;
|
|
3717
3749
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
3718
3750
|
});
|
|
3719
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
3720
3751
|
evaluateJsCode(props2);
|
|
3721
3752
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
3722
3753
|
elementRef,
|
package/lib/edge/index.qwik.cjs
CHANGED
|
@@ -102,13 +102,6 @@ const logger = {
|
|
|
102
102
|
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
103
103
|
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
104
104
|
};
|
|
105
|
-
const set = (obj, _path, value) => {
|
|
106
|
-
if (Object(obj) !== obj)
|
|
107
|
-
return obj;
|
|
108
|
-
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
109
|
-
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
110
|
-
return obj;
|
|
111
|
-
};
|
|
112
105
|
function isBrowser() {
|
|
113
106
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
114
107
|
}
|
|
@@ -184,6 +177,52 @@ const parseCode = (code, { isExpression = true }) => {
|
|
|
184
177
|
const useCode = useReturn ? `return (${code});` : code;
|
|
185
178
|
return useCode;
|
|
186
179
|
};
|
|
180
|
+
const runInBrowser = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
|
|
181
|
+
const functionArgs = getFunctionArguments({
|
|
182
|
+
builder,
|
|
183
|
+
context,
|
|
184
|
+
event,
|
|
185
|
+
state: flattenState({
|
|
186
|
+
rootState,
|
|
187
|
+
localState,
|
|
188
|
+
rootSetState
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
192
|
+
};
|
|
193
|
+
function flattenState({ rootState, localState, rootSetState }) {
|
|
194
|
+
return new Proxy(rootState, {
|
|
195
|
+
get: (target, prop) => {
|
|
196
|
+
if (localState && prop in localState)
|
|
197
|
+
return localState[prop];
|
|
198
|
+
const val = target[prop];
|
|
199
|
+
if (typeof val === "object")
|
|
200
|
+
return flattenState({
|
|
201
|
+
rootState: val,
|
|
202
|
+
localState: void 0,
|
|
203
|
+
rootSetState: rootSetState ? (subState) => {
|
|
204
|
+
target[prop] = subState;
|
|
205
|
+
rootSetState(target);
|
|
206
|
+
} : void 0
|
|
207
|
+
});
|
|
208
|
+
return val;
|
|
209
|
+
},
|
|
210
|
+
set: (target, prop, value) => {
|
|
211
|
+
if (localState && prop in localState)
|
|
212
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
213
|
+
target[prop] = value;
|
|
214
|
+
rootSetState == null ? void 0 : rootSetState(target);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const set = (obj, _path, value) => {
|
|
220
|
+
if (Object(obj) !== obj)
|
|
221
|
+
return obj;
|
|
222
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
223
|
+
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
224
|
+
return obj;
|
|
225
|
+
};
|
|
187
226
|
var p;
|
|
188
227
|
var ca = function(a) {
|
|
189
228
|
function b(f) {
|
|
@@ -3415,34 +3454,28 @@ theFunction();
|
|
|
3415
3454
|
return;
|
|
3416
3455
|
}
|
|
3417
3456
|
};
|
|
3418
|
-
const
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
event,
|
|
3423
|
-
state: flattenState(rootState, localState, rootSetState)
|
|
3424
|
-
});
|
|
3425
|
-
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
3426
|
-
};
|
|
3427
|
-
function flattenState(rootState, localState, rootSetState) {
|
|
3428
|
-
if (rootState === localState)
|
|
3429
|
-
throw new Error("rootState === localState");
|
|
3430
|
-
return new Proxy(rootState, {
|
|
3431
|
-
get: (_, prop) => {
|
|
3432
|
-
if (localState && prop in localState)
|
|
3433
|
-
return localState[prop];
|
|
3434
|
-
return rootState[prop];
|
|
3435
|
-
},
|
|
3436
|
-
set: (_, prop, value) => {
|
|
3437
|
-
if (localState && prop in localState)
|
|
3438
|
-
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
3439
|
-
rootState[prop] = value;
|
|
3440
|
-
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
3441
|
-
return true;
|
|
3442
|
-
}
|
|
3443
|
-
});
|
|
3457
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
3458
|
+
function isNodeRuntime() {
|
|
3459
|
+
var _a;
|
|
3460
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
3444
3461
|
}
|
|
3445
|
-
const
|
|
3462
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
3463
|
+
var _a;
|
|
3464
|
+
if (!isNodeRuntime())
|
|
3465
|
+
return false;
|
|
3466
|
+
const isArm64 = process.arch === "arm64";
|
|
3467
|
+
const isNode20 = process.version.startsWith("v20");
|
|
3468
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
3469
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
3470
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
3471
|
+
If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
|
|
3472
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
3473
|
+
`);
|
|
3474
|
+
return true;
|
|
3475
|
+
}
|
|
3476
|
+
return false;
|
|
3477
|
+
};
|
|
3478
|
+
const chooseBrowserOrServerEval = (args) => build.isBrowser || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
|
|
3446
3479
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
3447
3480
|
if (code === "") {
|
|
3448
3481
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -3606,7 +3639,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
3606
3639
|
return newSizes;
|
|
3607
3640
|
};
|
|
3608
3641
|
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
3609
|
-
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
3610
3642
|
const convertStyleMapToCSSArray = (style) => {
|
|
3611
3643
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
3612
3644
|
if (typeof value === "string")
|
|
@@ -6554,7 +6586,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
6554
6586
|
}
|
|
6555
6587
|
};
|
|
6556
6588
|
};
|
|
6557
|
-
const SDK_VERSION = "0.12.
|
|
6589
|
+
const SDK_VERSION = "0.12.6";
|
|
6558
6590
|
const registry = {};
|
|
6559
6591
|
function register(type, info) {
|
|
6560
6592
|
let typeList = registry[type];
|
|
@@ -6949,7 +6981,6 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
|
|
|
6949
6981
|
var _a2, _b2;
|
|
6950
6982
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
6951
6983
|
});
|
|
6952
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
6953
6984
|
evaluateJsCode(props2);
|
|
6954
6985
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
6955
6986
|
elementRef,
|
package/lib/edge/index.qwik.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { componentQrl, inlinedQrl, _jsxBranch, _jsxC, Slot as Slot$1, _fnSignal, _IMMUTABLE, createContextId, _jsxQ, useComputedQrl, useLexicalScope, useStore, useContextProvider, _wrapProp, useStylesScopedQrl, useContext, Fragment as Fragment$1, _jsxS, useSignal, useOn, useTaskQrl, createElement } from "@builder.io/qwik";
|
|
2
2
|
import { Fragment } from "@builder.io/qwik/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { isBrowser as isBrowser$1 } from "@builder.io/qwik/build";
|
|
4
4
|
const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set([
|
|
5
5
|
"area",
|
|
6
6
|
"base",
|
|
@@ -100,13 +100,6 @@ const logger = {
|
|
|
100
100
|
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
101
101
|
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
102
102
|
};
|
|
103
|
-
const set = (obj, _path, value) => {
|
|
104
|
-
if (Object(obj) !== obj)
|
|
105
|
-
return obj;
|
|
106
|
-
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
107
|
-
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
108
|
-
return obj;
|
|
109
|
-
};
|
|
110
103
|
function isBrowser() {
|
|
111
104
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
112
105
|
}
|
|
@@ -182,6 +175,52 @@ const parseCode = (code, { isExpression = true }) => {
|
|
|
182
175
|
const useCode = useReturn ? `return (${code});` : code;
|
|
183
176
|
return useCode;
|
|
184
177
|
};
|
|
178
|
+
const runInBrowser = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
|
|
179
|
+
const functionArgs = getFunctionArguments({
|
|
180
|
+
builder,
|
|
181
|
+
context,
|
|
182
|
+
event,
|
|
183
|
+
state: flattenState({
|
|
184
|
+
rootState,
|
|
185
|
+
localState,
|
|
186
|
+
rootSetState
|
|
187
|
+
})
|
|
188
|
+
});
|
|
189
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
190
|
+
};
|
|
191
|
+
function flattenState({ rootState, localState, rootSetState }) {
|
|
192
|
+
return new Proxy(rootState, {
|
|
193
|
+
get: (target, prop) => {
|
|
194
|
+
if (localState && prop in localState)
|
|
195
|
+
return localState[prop];
|
|
196
|
+
const val = target[prop];
|
|
197
|
+
if (typeof val === "object")
|
|
198
|
+
return flattenState({
|
|
199
|
+
rootState: val,
|
|
200
|
+
localState: void 0,
|
|
201
|
+
rootSetState: rootSetState ? (subState) => {
|
|
202
|
+
target[prop] = subState;
|
|
203
|
+
rootSetState(target);
|
|
204
|
+
} : void 0
|
|
205
|
+
});
|
|
206
|
+
return val;
|
|
207
|
+
},
|
|
208
|
+
set: (target, prop, value) => {
|
|
209
|
+
if (localState && prop in localState)
|
|
210
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
211
|
+
target[prop] = value;
|
|
212
|
+
rootSetState == null ? void 0 : rootSetState(target);
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
const set = (obj, _path, value) => {
|
|
218
|
+
if (Object(obj) !== obj)
|
|
219
|
+
return obj;
|
|
220
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
221
|
+
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
222
|
+
return obj;
|
|
223
|
+
};
|
|
185
224
|
var p;
|
|
186
225
|
var ca = function(a) {
|
|
187
226
|
function b(f) {
|
|
@@ -3413,34 +3452,28 @@ theFunction();
|
|
|
3413
3452
|
return;
|
|
3414
3453
|
}
|
|
3415
3454
|
};
|
|
3416
|
-
const
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
event,
|
|
3421
|
-
state: flattenState(rootState, localState, rootSetState)
|
|
3422
|
-
});
|
|
3423
|
-
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
3424
|
-
};
|
|
3425
|
-
function flattenState(rootState, localState, rootSetState) {
|
|
3426
|
-
if (rootState === localState)
|
|
3427
|
-
throw new Error("rootState === localState");
|
|
3428
|
-
return new Proxy(rootState, {
|
|
3429
|
-
get: (_, prop) => {
|
|
3430
|
-
if (localState && prop in localState)
|
|
3431
|
-
return localState[prop];
|
|
3432
|
-
return rootState[prop];
|
|
3433
|
-
},
|
|
3434
|
-
set: (_, prop, value) => {
|
|
3435
|
-
if (localState && prop in localState)
|
|
3436
|
-
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
3437
|
-
rootState[prop] = value;
|
|
3438
|
-
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
3439
|
-
return true;
|
|
3440
|
-
}
|
|
3441
|
-
});
|
|
3455
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
3456
|
+
function isNodeRuntime() {
|
|
3457
|
+
var _a;
|
|
3458
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
3442
3459
|
}
|
|
3443
|
-
const
|
|
3460
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
3461
|
+
var _a;
|
|
3462
|
+
if (!isNodeRuntime())
|
|
3463
|
+
return false;
|
|
3464
|
+
const isArm64 = process.arch === "arm64";
|
|
3465
|
+
const isNode20 = process.version.startsWith("v20");
|
|
3466
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
3467
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
3468
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
3469
|
+
If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
|
|
3470
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
3471
|
+
`);
|
|
3472
|
+
return true;
|
|
3473
|
+
}
|
|
3474
|
+
return false;
|
|
3475
|
+
};
|
|
3476
|
+
const chooseBrowserOrServerEval = (args) => isBrowser$1 || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
|
|
3444
3477
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
3445
3478
|
if (code === "") {
|
|
3446
3479
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -3604,7 +3637,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
3604
3637
|
return newSizes;
|
|
3605
3638
|
};
|
|
3606
3639
|
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
3607
|
-
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
3608
3640
|
const convertStyleMapToCSSArray = (style) => {
|
|
3609
3641
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
3610
3642
|
if (typeof value === "string")
|
|
@@ -6552,7 +6584,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
6552
6584
|
}
|
|
6553
6585
|
};
|
|
6554
6586
|
};
|
|
6555
|
-
const SDK_VERSION = "0.12.
|
|
6587
|
+
const SDK_VERSION = "0.12.6";
|
|
6556
6588
|
const registry = {};
|
|
6557
6589
|
function register(type, info) {
|
|
6558
6590
|
let typeList = registry[type];
|
|
@@ -6947,7 +6979,6 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
6947
6979
|
var _a2, _b2;
|
|
6948
6980
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
6949
6981
|
});
|
|
6950
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
6951
6982
|
evaluateJsCode(props2);
|
|
6952
6983
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
6953
6984
|
elementRef,
|
package/lib/node/index.qwik.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const qwik = require("@builder.io/qwik");
|
|
4
4
|
const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
|
|
5
|
-
const nodeEvaluate = require("./node-evaluate-4014c795.cjs");
|
|
6
5
|
const build = require("@builder.io/qwik/build");
|
|
6
|
+
const nodeEvaluate = require("./node-evaluate-4014c795.cjs");
|
|
7
7
|
require("node:module");
|
|
8
8
|
const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set([
|
|
9
9
|
"area",
|
|
@@ -104,14 +104,6 @@ const logger = {
|
|
|
104
104
|
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
105
105
|
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
106
106
|
};
|
|
107
|
-
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
108
|
-
const set = (obj, _path, value) => {
|
|
109
|
-
if (Object(obj) !== obj)
|
|
110
|
-
return obj;
|
|
111
|
-
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
112
|
-
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
113
|
-
return obj;
|
|
114
|
-
};
|
|
115
107
|
function isBrowser() {
|
|
116
108
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
117
109
|
}
|
|
@@ -187,6 +179,53 @@ const parseCode = (code, { isExpression = true }) => {
|
|
|
187
179
|
const useCode = useReturn ? `return (${code});` : code;
|
|
188
180
|
return useCode;
|
|
189
181
|
};
|
|
182
|
+
const runInBrowser = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
|
|
183
|
+
const functionArgs = getFunctionArguments({
|
|
184
|
+
builder,
|
|
185
|
+
context,
|
|
186
|
+
event,
|
|
187
|
+
state: flattenState({
|
|
188
|
+
rootState,
|
|
189
|
+
localState,
|
|
190
|
+
rootSetState
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
194
|
+
};
|
|
195
|
+
function flattenState({ rootState, localState, rootSetState }) {
|
|
196
|
+
return new Proxy(rootState, {
|
|
197
|
+
get: (target, prop) => {
|
|
198
|
+
if (localState && prop in localState)
|
|
199
|
+
return localState[prop];
|
|
200
|
+
const val = target[prop];
|
|
201
|
+
if (typeof val === "object")
|
|
202
|
+
return flattenState({
|
|
203
|
+
rootState: val,
|
|
204
|
+
localState: void 0,
|
|
205
|
+
rootSetState: rootSetState ? (subState) => {
|
|
206
|
+
target[prop] = subState;
|
|
207
|
+
rootSetState(target);
|
|
208
|
+
} : void 0
|
|
209
|
+
});
|
|
210
|
+
return val;
|
|
211
|
+
},
|
|
212
|
+
set: (target, prop, value) => {
|
|
213
|
+
if (localState && prop in localState)
|
|
214
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
215
|
+
target[prop] = value;
|
|
216
|
+
rootSetState == null ? void 0 : rootSetState(target);
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
222
|
+
const set = (obj, _path, value) => {
|
|
223
|
+
if (Object(obj) !== obj)
|
|
224
|
+
return obj;
|
|
225
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
226
|
+
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
227
|
+
return obj;
|
|
228
|
+
};
|
|
190
229
|
const ivm = nodeEvaluate.safeDynamicRequire("isolated-vm");
|
|
191
230
|
const getSyncValName = (key) => `bldr_${key}_sync`;
|
|
192
231
|
const BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE";
|
|
@@ -286,34 +325,28 @@ const runInNode = ({ code, builder, context, event, localState, rootSetState, ro
|
|
|
286
325
|
return resultStr;
|
|
287
326
|
}
|
|
288
327
|
};
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
event,
|
|
294
|
-
state: flattenState(rootState, localState, rootSetState)
|
|
295
|
-
});
|
|
296
|
-
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
297
|
-
};
|
|
298
|
-
function flattenState(rootState, localState, rootSetState) {
|
|
299
|
-
if (rootState === localState)
|
|
300
|
-
throw new Error("rootState === localState");
|
|
301
|
-
return new Proxy(rootState, {
|
|
302
|
-
get: (_, prop) => {
|
|
303
|
-
if (localState && prop in localState)
|
|
304
|
-
return localState[prop];
|
|
305
|
-
return rootState[prop];
|
|
306
|
-
},
|
|
307
|
-
set: (_, prop, value) => {
|
|
308
|
-
if (localState && prop in localState)
|
|
309
|
-
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
310
|
-
rootState[prop] = value;
|
|
311
|
-
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
312
|
-
return true;
|
|
313
|
-
}
|
|
314
|
-
});
|
|
328
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
329
|
+
function isNodeRuntime() {
|
|
330
|
+
var _a;
|
|
331
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
315
332
|
}
|
|
316
|
-
const
|
|
333
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
334
|
+
var _a;
|
|
335
|
+
if (!isNodeRuntime())
|
|
336
|
+
return false;
|
|
337
|
+
const isArm64 = process.arch === "arm64";
|
|
338
|
+
const isNode20 = process.version.startsWith("v20");
|
|
339
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
340
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
341
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
342
|
+
If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
|
|
343
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
344
|
+
`);
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
return false;
|
|
348
|
+
};
|
|
349
|
+
const chooseBrowserOrServerEval = (args) => build.isBrowser || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInNode(args);
|
|
317
350
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
318
351
|
if (code === "") {
|
|
319
352
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -476,7 +509,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
476
509
|
return newSizes;
|
|
477
510
|
};
|
|
478
511
|
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
479
|
-
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
480
512
|
const convertStyleMapToCSSArray = (style) => {
|
|
481
513
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
482
514
|
if (typeof value === "string")
|
|
@@ -3424,7 +3456,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3424
3456
|
}
|
|
3425
3457
|
};
|
|
3426
3458
|
};
|
|
3427
|
-
const SDK_VERSION = "0.12.
|
|
3459
|
+
const SDK_VERSION = "0.12.6";
|
|
3428
3460
|
const registry = {};
|
|
3429
3461
|
function register(type, info) {
|
|
3430
3462
|
let typeList = registry[type];
|
|
@@ -3819,7 +3851,6 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
|
|
|
3819
3851
|
var _a2, _b2;
|
|
3820
3852
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
3821
3853
|
});
|
|
3822
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
3823
3854
|
evaluateJsCode(props2);
|
|
3824
3855
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
3825
3856
|
elementRef,
|
package/lib/node/index.qwik.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { componentQrl, inlinedQrl, _jsxBranch, _jsxC, Slot as Slot$1, _fnSignal, _IMMUTABLE, createContextId, _jsxQ, useComputedQrl, useLexicalScope, useStore, useContextProvider, _wrapProp, useStylesScopedQrl, useContext, Fragment as Fragment$1, _jsxS, useSignal, useOn, useTaskQrl, createElement } from "@builder.io/qwik";
|
|
2
2
|
import { Fragment } from "@builder.io/qwik/jsx-runtime";
|
|
3
|
+
import { isBrowser as isBrowser$1 } from "@builder.io/qwik/build";
|
|
3
4
|
import { s as safeDynamicRequire } from "./node-evaluate-db446d2b.js";
|
|
4
|
-
import { isServer } from "@builder.io/qwik/build";
|
|
5
5
|
import "node:module";
|
|
6
6
|
const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set([
|
|
7
7
|
"area",
|
|
@@ -102,14 +102,6 @@ const logger = {
|
|
|
102
102
|
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
103
103
|
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
104
104
|
};
|
|
105
|
-
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
106
|
-
const set = (obj, _path, value) => {
|
|
107
|
-
if (Object(obj) !== obj)
|
|
108
|
-
return obj;
|
|
109
|
-
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
110
|
-
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
111
|
-
return obj;
|
|
112
|
-
};
|
|
113
105
|
function isBrowser() {
|
|
114
106
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
115
107
|
}
|
|
@@ -185,6 +177,53 @@ const parseCode = (code, { isExpression = true }) => {
|
|
|
185
177
|
const useCode = useReturn ? `return (${code});` : code;
|
|
186
178
|
return useCode;
|
|
187
179
|
};
|
|
180
|
+
const runInBrowser = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
|
|
181
|
+
const functionArgs = getFunctionArguments({
|
|
182
|
+
builder,
|
|
183
|
+
context,
|
|
184
|
+
event,
|
|
185
|
+
state: flattenState({
|
|
186
|
+
rootState,
|
|
187
|
+
localState,
|
|
188
|
+
rootSetState
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
192
|
+
};
|
|
193
|
+
function flattenState({ rootState, localState, rootSetState }) {
|
|
194
|
+
return new Proxy(rootState, {
|
|
195
|
+
get: (target, prop) => {
|
|
196
|
+
if (localState && prop in localState)
|
|
197
|
+
return localState[prop];
|
|
198
|
+
const val = target[prop];
|
|
199
|
+
if (typeof val === "object")
|
|
200
|
+
return flattenState({
|
|
201
|
+
rootState: val,
|
|
202
|
+
localState: void 0,
|
|
203
|
+
rootSetState: rootSetState ? (subState) => {
|
|
204
|
+
target[prop] = subState;
|
|
205
|
+
rootSetState(target);
|
|
206
|
+
} : void 0
|
|
207
|
+
});
|
|
208
|
+
return val;
|
|
209
|
+
},
|
|
210
|
+
set: (target, prop, value) => {
|
|
211
|
+
if (localState && prop in localState)
|
|
212
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
213
|
+
target[prop] = value;
|
|
214
|
+
rootSetState == null ? void 0 : rootSetState(target);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
220
|
+
const set = (obj, _path, value) => {
|
|
221
|
+
if (Object(obj) !== obj)
|
|
222
|
+
return obj;
|
|
223
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
224
|
+
path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
225
|
+
return obj;
|
|
226
|
+
};
|
|
188
227
|
const ivm = safeDynamicRequire("isolated-vm");
|
|
189
228
|
const getSyncValName = (key) => `bldr_${key}_sync`;
|
|
190
229
|
const BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE";
|
|
@@ -284,34 +323,28 @@ const runInNode = ({ code, builder, context, event, localState, rootSetState, ro
|
|
|
284
323
|
return resultStr;
|
|
285
324
|
}
|
|
286
325
|
};
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
event,
|
|
292
|
-
state: flattenState(rootState, localState, rootSetState)
|
|
293
|
-
});
|
|
294
|
-
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
295
|
-
};
|
|
296
|
-
function flattenState(rootState, localState, rootSetState) {
|
|
297
|
-
if (rootState === localState)
|
|
298
|
-
throw new Error("rootState === localState");
|
|
299
|
-
return new Proxy(rootState, {
|
|
300
|
-
get: (_, prop) => {
|
|
301
|
-
if (localState && prop in localState)
|
|
302
|
-
return localState[prop];
|
|
303
|
-
return rootState[prop];
|
|
304
|
-
},
|
|
305
|
-
set: (_, prop, value) => {
|
|
306
|
-
if (localState && prop in localState)
|
|
307
|
-
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
308
|
-
rootState[prop] = value;
|
|
309
|
-
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
});
|
|
326
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
327
|
+
function isNodeRuntime() {
|
|
328
|
+
var _a;
|
|
329
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
313
330
|
}
|
|
314
|
-
const
|
|
331
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
332
|
+
var _a;
|
|
333
|
+
if (!isNodeRuntime())
|
|
334
|
+
return false;
|
|
335
|
+
const isArm64 = process.arch === "arm64";
|
|
336
|
+
const isNode20 = process.version.startsWith("v20");
|
|
337
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
338
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
339
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
340
|
+
If you would like to use the \`isolated-vm\` package on this machine, please provide the \`NODE_OPTIONS=--no-node-snapshot\` config to your Node process.
|
|
341
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
342
|
+
`);
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
return false;
|
|
346
|
+
};
|
|
347
|
+
const chooseBrowserOrServerEval = (args) => isBrowser$1 || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInNode(args);
|
|
315
348
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
316
349
|
if (code === "") {
|
|
317
350
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -474,7 +507,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
474
507
|
return newSizes;
|
|
475
508
|
};
|
|
476
509
|
const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
477
|
-
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
478
510
|
const convertStyleMapToCSSArray = (style) => {
|
|
479
511
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
480
512
|
if (typeof value === "string")
|
|
@@ -3422,7 +3454,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3422
3454
|
}
|
|
3423
3455
|
};
|
|
3424
3456
|
};
|
|
3425
|
-
const SDK_VERSION = "0.12.
|
|
3457
|
+
const SDK_VERSION = "0.12.6";
|
|
3426
3458
|
const registry = {};
|
|
3427
3459
|
function register(type, info) {
|
|
3428
3460
|
let typeList = registry[type];
|
|
@@ -3817,7 +3849,6 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
3817
3849
|
var _a2, _b2;
|
|
3818
3850
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
3819
3851
|
});
|
|
3820
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
3821
3852
|
evaluateJsCode(props2);
|
|
3822
3853
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
3823
3854
|
elementRef,
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.12.
|
|
1
|
+
export declare const SDK_VERSION = "0.12.6";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { BuilderRenderState } from '../../../context/types.js';
|
|
2
2
|
import type { ExecutorArgs } from '../helpers.js';
|
|
3
3
|
export declare const runInBrowser: ({ code, builder, context, event, localState, rootSetState, rootState }: ExecutorArgs) => any;
|
|
4
|
-
export declare function flattenState(rootState
|
|
4
|
+
export declare function flattenState({ rootState, localState, rootSetState }: {
|
|
5
|
+
rootState: Record<string | symbol, any>;
|
|
6
|
+
localState: Record<string | symbol, any> | undefined;
|
|
7
|
+
rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
|
|
8
|
+
}): BuilderRenderState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const shouldForceBrowserRuntimeInNode: () => boolean;
|