@objectstack/runtime 12.5.0 → 12.6.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/dist/index.cjs +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/package.json +21 -21
package/dist/index.cjs
CHANGED
|
@@ -265,8 +265,20 @@ function installApiMethod(vm, parent, method, objectName, ctx, caps, required, o
|
|
|
265
265
|
vm.setProp(parent, method, fn);
|
|
266
266
|
fn.dispose();
|
|
267
267
|
}
|
|
268
|
+
function safeJsonStringify(v) {
|
|
269
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
270
|
+
const json = JSON.stringify(v ?? null, function(_key, value) {
|
|
271
|
+
if (typeof value === "bigint") return value.toString();
|
|
272
|
+
if (typeof value === "object" && value !== null) {
|
|
273
|
+
if (seen.has(value)) return void 0;
|
|
274
|
+
seen.add(value);
|
|
275
|
+
}
|
|
276
|
+
return value;
|
|
277
|
+
});
|
|
278
|
+
return json ?? "null";
|
|
279
|
+
}
|
|
268
280
|
function jsonToHandle(vm, v) {
|
|
269
|
-
const json =
|
|
281
|
+
const json = safeJsonStringify(v);
|
|
270
282
|
const r = vm.evalCode(`(${json})`);
|
|
271
283
|
if (r.error) {
|
|
272
284
|
const msg = vm.dump(r.error);
|
|
@@ -276,7 +288,7 @@ function jsonToHandle(vm, v) {
|
|
|
276
288
|
return r.value;
|
|
277
289
|
}
|
|
278
290
|
function setGlobalJson(vm, name, v) {
|
|
279
|
-
const json =
|
|
291
|
+
const json = safeJsonStringify(v);
|
|
280
292
|
const result = vm.evalCode(`(${json})`);
|
|
281
293
|
if (result.error) {
|
|
282
294
|
result.error.dispose();
|
|
@@ -286,7 +298,7 @@ function setGlobalJson(vm, name, v) {
|
|
|
286
298
|
result.value.dispose();
|
|
287
299
|
}
|
|
288
300
|
function setObjectJson(vm, parent, key, v) {
|
|
289
|
-
const json =
|
|
301
|
+
const json = safeJsonStringify(v);
|
|
290
302
|
const result = vm.evalCode(`(${json})`);
|
|
291
303
|
if (result.error) {
|
|
292
304
|
result.error.dispose();
|