@builder.io/sdk-qwik 0.12.4 → 0.12.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/lib/browser/index.qwik.cjs +23 -3
- package/lib/browser/index.qwik.mjs +24 -4
- package/lib/edge/index.qwik.cjs +56 -36
- package/lib/edge/index.qwik.mjs +57 -37
- package/lib/node/index.qwik.cjs +58 -38
- package/lib/node/index.qwik.mjs +58 -38
- package/package.json +1 -1
- package/types/src/constants/sdk-version.d.ts +1 -1
- package/types/src/functions/evaluate/should-force-browser-runtime-in-node.d.ts +1 -0
|
@@ -204,7 +204,28 @@ function flattenState(rootState, localState, rootSetState) {
|
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
const
|
|
207
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
208
|
+
function isNodeRuntime() {
|
|
209
|
+
var _a;
|
|
210
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
211
|
+
}
|
|
212
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
213
|
+
var _a;
|
|
214
|
+
if (!isNodeRuntime())
|
|
215
|
+
return false;
|
|
216
|
+
const isArm64 = process.arch === "arm64";
|
|
217
|
+
const isNode20 = process.version.startsWith("v20");
|
|
218
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
219
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
220
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
221
|
+
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.
|
|
222
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
223
|
+
`);
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
};
|
|
228
|
+
const chooseBrowserOrServerEval = (args) => build.isBrowser || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInBrowser(args);
|
|
208
229
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
209
230
|
if (code === "") {
|
|
210
231
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -375,7 +396,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
375
396
|
return newSizes;
|
|
376
397
|
};
|
|
377
398
|
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
399
|
const convertStyleMapToCSSArray = (style) => {
|
|
380
400
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
381
401
|
if (typeof value === "string")
|
|
@@ -3323,7 +3343,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3323
3343
|
}
|
|
3324
3344
|
};
|
|
3325
3345
|
};
|
|
3326
|
-
const SDK_VERSION = "0.12.
|
|
3346
|
+
const SDK_VERSION = "0.12.5";
|
|
3327
3347
|
const registry = {};
|
|
3328
3348
|
function register(type, info) {
|
|
3329
3349
|
let typeList = registry[type];
|
|
@@ -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",
|
|
@@ -202,7 +202,28 @@ function flattenState(rootState, localState, rootSetState) {
|
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
206
|
+
function isNodeRuntime() {
|
|
207
|
+
var _a;
|
|
208
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
209
|
+
}
|
|
210
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
211
|
+
var _a;
|
|
212
|
+
if (!isNodeRuntime())
|
|
213
|
+
return false;
|
|
214
|
+
const isArm64 = process.arch === "arm64";
|
|
215
|
+
const isNode20 = process.version.startsWith("v20");
|
|
216
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
217
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
218
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
219
|
+
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.
|
|
220
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
221
|
+
`);
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
return false;
|
|
225
|
+
};
|
|
226
|
+
const chooseBrowserOrServerEval = (args) => isBrowser$1 || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInBrowser(args);
|
|
206
227
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
207
228
|
if (code === "") {
|
|
208
229
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -373,7 +394,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
373
394
|
return newSizes;
|
|
374
395
|
};
|
|
375
396
|
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
397
|
const convertStyleMapToCSSArray = (style) => {
|
|
378
398
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
379
399
|
if (typeof value === "string")
|
|
@@ -3321,7 +3341,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3321
3341
|
}
|
|
3322
3342
|
};
|
|
3323
3343
|
};
|
|
3324
|
-
const SDK_VERSION = "0.12.
|
|
3344
|
+
const SDK_VERSION = "0.12.5";
|
|
3325
3345
|
const registry = {};
|
|
3326
3346
|
function register(type, info) {
|
|
3327
3347
|
let typeList = registry[type];
|
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,40 @@ 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(rootState, localState, rootSetState)
|
|
186
|
+
});
|
|
187
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
188
|
+
};
|
|
189
|
+
function flattenState(rootState, localState, rootSetState) {
|
|
190
|
+
if (rootState === localState)
|
|
191
|
+
throw new Error("rootState === localState");
|
|
192
|
+
return new Proxy(rootState, {
|
|
193
|
+
get: (_, prop) => {
|
|
194
|
+
if (localState && prop in localState)
|
|
195
|
+
return localState[prop];
|
|
196
|
+
return rootState[prop];
|
|
197
|
+
},
|
|
198
|
+
set: (_, prop, value) => {
|
|
199
|
+
if (localState && prop in localState)
|
|
200
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
201
|
+
rootState[prop] = value;
|
|
202
|
+
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const set = (obj, _path, value) => {
|
|
208
|
+
if (Object(obj) !== obj)
|
|
209
|
+
return obj;
|
|
210
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
211
|
+
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;
|
|
212
|
+
return obj;
|
|
213
|
+
};
|
|
187
214
|
var p;
|
|
188
215
|
var ca = function(a) {
|
|
189
216
|
function b(f) {
|
|
@@ -3415,34 +3442,28 @@ theFunction();
|
|
|
3415
3442
|
return;
|
|
3416
3443
|
}
|
|
3417
3444
|
};
|
|
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
|
-
});
|
|
3445
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
3446
|
+
function isNodeRuntime() {
|
|
3447
|
+
var _a;
|
|
3448
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
3444
3449
|
}
|
|
3445
|
-
const
|
|
3450
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
3451
|
+
var _a;
|
|
3452
|
+
if (!isNodeRuntime())
|
|
3453
|
+
return false;
|
|
3454
|
+
const isArm64 = process.arch === "arm64";
|
|
3455
|
+
const isNode20 = process.version.startsWith("v20");
|
|
3456
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
3457
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
3458
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
3459
|
+
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.
|
|
3460
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
3461
|
+
`);
|
|
3462
|
+
return true;
|
|
3463
|
+
}
|
|
3464
|
+
return false;
|
|
3465
|
+
};
|
|
3466
|
+
const chooseBrowserOrServerEval = (args) => build.isBrowser || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
|
|
3446
3467
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
3447
3468
|
if (code === "") {
|
|
3448
3469
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -3606,7 +3627,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
3606
3627
|
return newSizes;
|
|
3607
3628
|
};
|
|
3608
3629
|
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
3630
|
const convertStyleMapToCSSArray = (style) => {
|
|
3611
3631
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
3612
3632
|
if (typeof value === "string")
|
|
@@ -6554,7 +6574,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
6554
6574
|
}
|
|
6555
6575
|
};
|
|
6556
6576
|
};
|
|
6557
|
-
const SDK_VERSION = "0.12.
|
|
6577
|
+
const SDK_VERSION = "0.12.5";
|
|
6558
6578
|
const registry = {};
|
|
6559
6579
|
function register(type, info) {
|
|
6560
6580
|
let typeList = registry[type];
|
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,40 @@ 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(rootState, localState, rootSetState)
|
|
184
|
+
});
|
|
185
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
186
|
+
};
|
|
187
|
+
function flattenState(rootState, localState, rootSetState) {
|
|
188
|
+
if (rootState === localState)
|
|
189
|
+
throw new Error("rootState === localState");
|
|
190
|
+
return new Proxy(rootState, {
|
|
191
|
+
get: (_, prop) => {
|
|
192
|
+
if (localState && prop in localState)
|
|
193
|
+
return localState[prop];
|
|
194
|
+
return rootState[prop];
|
|
195
|
+
},
|
|
196
|
+
set: (_, prop, value) => {
|
|
197
|
+
if (localState && prop in localState)
|
|
198
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
199
|
+
rootState[prop] = value;
|
|
200
|
+
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const set = (obj, _path, value) => {
|
|
206
|
+
if (Object(obj) !== obj)
|
|
207
|
+
return obj;
|
|
208
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
209
|
+
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;
|
|
210
|
+
return obj;
|
|
211
|
+
};
|
|
185
212
|
var p;
|
|
186
213
|
var ca = function(a) {
|
|
187
214
|
function b(f) {
|
|
@@ -3413,34 +3440,28 @@ theFunction();
|
|
|
3413
3440
|
return;
|
|
3414
3441
|
}
|
|
3415
3442
|
};
|
|
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
|
-
});
|
|
3443
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
3444
|
+
function isNodeRuntime() {
|
|
3445
|
+
var _a;
|
|
3446
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
3442
3447
|
}
|
|
3443
|
-
const
|
|
3448
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
3449
|
+
var _a;
|
|
3450
|
+
if (!isNodeRuntime())
|
|
3451
|
+
return false;
|
|
3452
|
+
const isArm64 = process.arch === "arm64";
|
|
3453
|
+
const isNode20 = process.version.startsWith("v20");
|
|
3454
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
3455
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
3456
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
3457
|
+
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.
|
|
3458
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
3459
|
+
`);
|
|
3460
|
+
return true;
|
|
3461
|
+
}
|
|
3462
|
+
return false;
|
|
3463
|
+
};
|
|
3464
|
+
const chooseBrowserOrServerEval = (args) => isBrowser$1 || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
|
|
3444
3465
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
3445
3466
|
if (code === "") {
|
|
3446
3467
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -3604,7 +3625,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
3604
3625
|
return newSizes;
|
|
3605
3626
|
};
|
|
3606
3627
|
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
3628
|
const convertStyleMapToCSSArray = (style) => {
|
|
3609
3629
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
3610
3630
|
if (typeof value === "string")
|
|
@@ -6552,7 +6572,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
6552
6572
|
}
|
|
6553
6573
|
};
|
|
6554
6574
|
};
|
|
6555
|
-
const SDK_VERSION = "0.12.
|
|
6575
|
+
const SDK_VERSION = "0.12.5";
|
|
6556
6576
|
const registry = {};
|
|
6557
6577
|
function register(type, info) {
|
|
6558
6578
|
let typeList = registry[type];
|
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,41 @@ 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(rootState, localState, rootSetState)
|
|
188
|
+
});
|
|
189
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
190
|
+
};
|
|
191
|
+
function flattenState(rootState, localState, rootSetState) {
|
|
192
|
+
if (rootState === localState)
|
|
193
|
+
throw new Error("rootState === localState");
|
|
194
|
+
return new Proxy(rootState, {
|
|
195
|
+
get: (_, prop) => {
|
|
196
|
+
if (localState && prop in localState)
|
|
197
|
+
return localState[prop];
|
|
198
|
+
return rootState[prop];
|
|
199
|
+
},
|
|
200
|
+
set: (_, prop, value) => {
|
|
201
|
+
if (localState && prop in localState)
|
|
202
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
203
|
+
rootState[prop] = value;
|
|
204
|
+
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
210
|
+
const set = (obj, _path, value) => {
|
|
211
|
+
if (Object(obj) !== obj)
|
|
212
|
+
return obj;
|
|
213
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
214
|
+
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;
|
|
215
|
+
return obj;
|
|
216
|
+
};
|
|
190
217
|
const ivm = nodeEvaluate.safeDynamicRequire("isolated-vm");
|
|
191
218
|
const getSyncValName = (key) => `bldr_${key}_sync`;
|
|
192
219
|
const BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE";
|
|
@@ -286,34 +313,28 @@ const runInNode = ({ code, builder, context, event, localState, rootSetState, ro
|
|
|
286
313
|
return resultStr;
|
|
287
314
|
}
|
|
288
315
|
};
|
|
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
|
-
});
|
|
316
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
317
|
+
function isNodeRuntime() {
|
|
318
|
+
var _a;
|
|
319
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
315
320
|
}
|
|
316
|
-
const
|
|
321
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
322
|
+
var _a;
|
|
323
|
+
if (!isNodeRuntime())
|
|
324
|
+
return false;
|
|
325
|
+
const isArm64 = process.arch === "arm64";
|
|
326
|
+
const isNode20 = process.version.startsWith("v20");
|
|
327
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
328
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
329
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
330
|
+
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.
|
|
331
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
332
|
+
`);
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
return false;
|
|
336
|
+
};
|
|
337
|
+
const chooseBrowserOrServerEval = (args) => build.isBrowser || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInNode(args);
|
|
317
338
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
318
339
|
if (code === "") {
|
|
319
340
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -476,7 +497,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
476
497
|
return newSizes;
|
|
477
498
|
};
|
|
478
499
|
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
500
|
const convertStyleMapToCSSArray = (style) => {
|
|
481
501
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
482
502
|
if (typeof value === "string")
|
|
@@ -3424,7 +3444,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3424
3444
|
}
|
|
3425
3445
|
};
|
|
3426
3446
|
};
|
|
3427
|
-
const SDK_VERSION = "0.12.
|
|
3447
|
+
const SDK_VERSION = "0.12.5";
|
|
3428
3448
|
const registry = {};
|
|
3429
3449
|
function register(type, info) {
|
|
3430
3450
|
let typeList = registry[type];
|
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,41 @@ 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(rootState, localState, rootSetState)
|
|
186
|
+
});
|
|
187
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
188
|
+
};
|
|
189
|
+
function flattenState(rootState, localState, rootSetState) {
|
|
190
|
+
if (rootState === localState)
|
|
191
|
+
throw new Error("rootState === localState");
|
|
192
|
+
return new Proxy(rootState, {
|
|
193
|
+
get: (_, prop) => {
|
|
194
|
+
if (localState && prop in localState)
|
|
195
|
+
return localState[prop];
|
|
196
|
+
return rootState[prop];
|
|
197
|
+
},
|
|
198
|
+
set: (_, prop, value) => {
|
|
199
|
+
if (localState && prop in localState)
|
|
200
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
201
|
+
rootState[prop] = value;
|
|
202
|
+
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
208
|
+
const set = (obj, _path, value) => {
|
|
209
|
+
if (Object(obj) !== obj)
|
|
210
|
+
return obj;
|
|
211
|
+
const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
|
|
212
|
+
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;
|
|
213
|
+
return obj;
|
|
214
|
+
};
|
|
188
215
|
const ivm = safeDynamicRequire("isolated-vm");
|
|
189
216
|
const getSyncValName = (key) => `bldr_${key}_sync`;
|
|
190
217
|
const BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE";
|
|
@@ -284,34 +311,28 @@ const runInNode = ({ code, builder, context, event, localState, rootSetState, ro
|
|
|
284
311
|
return resultStr;
|
|
285
312
|
}
|
|
286
313
|
};
|
|
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
|
-
});
|
|
314
|
+
const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
|
|
315
|
+
function isNodeRuntime() {
|
|
316
|
+
var _a;
|
|
317
|
+
return typeof process !== "undefined" && checkIsDefined((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
313
318
|
}
|
|
314
|
-
const
|
|
319
|
+
const shouldForceBrowserRuntimeInNode = () => {
|
|
320
|
+
var _a;
|
|
321
|
+
if (!isNodeRuntime())
|
|
322
|
+
return false;
|
|
323
|
+
const isArm64 = process.arch === "arm64";
|
|
324
|
+
const isNode20 = process.version.startsWith("v20");
|
|
325
|
+
const hasNoNodeSnapshotNodeOption = (_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--no-node-snapshot");
|
|
326
|
+
if (isArm64 && isNode20 && !hasNoNodeSnapshotNodeOption) {
|
|
327
|
+
logger.log(`Skipping usage of \`isolated-vm\` to avoid crashes in Node v20 on an arm64 machine.
|
|
328
|
+
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.
|
|
329
|
+
See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.
|
|
330
|
+
`);
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
return false;
|
|
334
|
+
};
|
|
335
|
+
const chooseBrowserOrServerEval = (args) => isBrowser$1 || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInNode(args);
|
|
315
336
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
316
337
|
if (code === "") {
|
|
317
338
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -474,7 +495,6 @@ const getSizesForBreakpoints = ({ small, medium }) => {
|
|
|
474
495
|
return newSizes;
|
|
475
496
|
};
|
|
476
497
|
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
498
|
const convertStyleMapToCSSArray = (style) => {
|
|
479
499
|
const cssProps = Object.entries(style).map(([key, value]) => {
|
|
480
500
|
if (typeof value === "string")
|
|
@@ -3422,7 +3442,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3422
3442
|
}
|
|
3423
3443
|
};
|
|
3424
3444
|
};
|
|
3425
|
-
const SDK_VERSION = "0.12.
|
|
3445
|
+
const SDK_VERSION = "0.12.5";
|
|
3426
3446
|
const registry = {};
|
|
3427
3447
|
function register(type, info) {
|
|
3428
3448
|
let typeList = registry[type];
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.12.
|
|
1
|
+
export declare const SDK_VERSION = "0.12.5";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const shouldForceBrowserRuntimeInNode: () => boolean;
|