@ai-matrx/kit 0.13.1 → 0.13.2
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/CHANGELOG.md +10 -0
- package/README.md +2 -0
- package/dist/content-transfer.cjs +38 -5
- package/dist/content-transfer.cjs.map +1 -1
- package/dist/content-transfer.js +38 -5
- package/dist/content-transfer.js.map +1 -1
- package/dist/index.cjs +38 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2941,7 +2941,7 @@ var stop = (s) => {
|
|
|
2941
2941
|
};
|
|
2942
2942
|
var enc = (x) => x.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
2943
2943
|
var dec = (x) => x.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
2944
|
-
function clone(v, path = "", seen = /* @__PURE__ */ new WeakSet()) {
|
|
2944
|
+
function clone(v, path = "", seen = /* @__PURE__ */ new WeakSet(), policy = {}) {
|
|
2945
2945
|
if (v === null || typeof v === "string" || typeof v === "boolean") return v;
|
|
2946
2946
|
if (typeof v === "number") {
|
|
2947
2947
|
if (!Number.isFinite(v))
|
|
@@ -2980,15 +2980,48 @@ function clone(v, path = "", seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
2980
2980
|
`${path}/${index}`
|
|
2981
2981
|
);
|
|
2982
2982
|
}
|
|
2983
|
-
const out = Array.isArray(v) ? v.map((x, i) => clone(x, `${path}/${i}`, seen)) : Object.fromEntries(
|
|
2984
|
-
Object.entries(v).map(([k, x]) => [
|
|
2983
|
+
const out = Array.isArray(v) ? v.map((x, i) => clone(x, `${path}/${i}`, seen, policy)) : Object.fromEntries(
|
|
2984
|
+
Object.entries(v).filter(([, x]) => !policy.omitUndefinedObjectProperties || x !== void 0).map(([k, x]) => [
|
|
2985
2985
|
k,
|
|
2986
|
-
clone(x, `${path}/${enc(k)}`, seen)
|
|
2986
|
+
clone(x, `${path}/${enc(k)}`, seen, policy)
|
|
2987
2987
|
])
|
|
2988
2988
|
);
|
|
2989
2989
|
seen.delete(v);
|
|
2990
2990
|
return out;
|
|
2991
2991
|
}
|
|
2992
|
+
var maxSurfacePointerSegmentLength = 64;
|
|
2993
|
+
var maxSurfacePointerLength = 192;
|
|
2994
|
+
var truncateSurfacePointer = (value, maxLength) => {
|
|
2995
|
+
const characters = Array.from(value);
|
|
2996
|
+
return characters.length > maxLength ? `${characters.slice(0, maxLength - 1).join("")}\u2026` : value;
|
|
2997
|
+
};
|
|
2998
|
+
function displaySurfacePointer(path) {
|
|
2999
|
+
if (!path) return "/";
|
|
3000
|
+
const safe = path.split("/").slice(1).map((segment) => {
|
|
3001
|
+
const controlSafe = segment.replace(
|
|
3002
|
+
/[\u0000-\u001F\u007F-\u009F]/g,
|
|
3003
|
+
(character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`
|
|
3004
|
+
);
|
|
3005
|
+
return truncateSurfacePointer(controlSafe, maxSurfacePointerSegmentLength);
|
|
3006
|
+
}).join("/");
|
|
3007
|
+
const pointer = `/${safe}`;
|
|
3008
|
+
return truncateSurfacePointer(pointer, maxSurfacePointerLength);
|
|
3009
|
+
}
|
|
3010
|
+
function cloneSurfaceValue(value, path) {
|
|
3011
|
+
try {
|
|
3012
|
+
return clone(value, path, /* @__PURE__ */ new WeakSet(), {
|
|
3013
|
+
omitUndefinedObjectProperties: true
|
|
3014
|
+
});
|
|
3015
|
+
} catch (error) {
|
|
3016
|
+
if (error instanceof ContentTransferError)
|
|
3017
|
+
throw new ContentTransferError(
|
|
3018
|
+
error.code,
|
|
3019
|
+
`Surface capture rejected value at ${displaySurfacePointer(error.path)}: ${error.message}`,
|
|
3020
|
+
error.path
|
|
3021
|
+
);
|
|
3022
|
+
throw error;
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
2992
3025
|
function normalizeTransferJson(value) {
|
|
2993
3026
|
return clone(value);
|
|
2994
3027
|
}
|
|
@@ -3902,7 +3935,7 @@ function createSurfaceTransferHandle(options) {
|
|
|
3902
3935
|
for (const declaration of declarations) {
|
|
3903
3936
|
if (Object.hasOwn(scope, declaration.name) && scope[declaration.name] !== void 0) {
|
|
3904
3937
|
Object.defineProperty(value, declaration.name, {
|
|
3905
|
-
value:
|
|
3938
|
+
value: cloneSurfaceValue(
|
|
3906
3939
|
scope[declaration.name],
|
|
3907
3940
|
`/${enc(declaration.name)}`
|
|
3908
3941
|
),
|