fix(build,json): replace lodash.clonedeep with structuredClone and migrate package metadata to smartconfig

This commit is contained in:
2026-04-30 06:59:14 +00:00
parent 6ac04e2069
commit ba38d4377b
9 changed files with 2245 additions and 2986 deletions
+20 -8
View File
@@ -14,22 +14,34 @@ interface IEncodedBuffer {
type TParseReviver = (this: any, key: string, value: any) => any;
type TParseReplacer = (this: any, key: string, value: any) => any;
interface INodeBufferLike extends Uint8Array {
toString(): string;
toString(encoding: 'base64'): string;
}
interface INodeBufferConstructor {
from(data: Uint8Array): INodeBufferLike;
from(data: string, encoding: 'base64'): INodeBufferLike;
}
const getNodeBuffer = (): INodeBufferConstructor | undefined => {
return (globalThis as typeof globalThis & { Buffer?: INodeBufferConstructor }).Buffer;
};
// Utility functions to handle base64 encoding/decoding in a cross-platform way
function base64Encode(data: Uint8Array): string {
// Prefer Node's Buffer when available
if (typeof Buffer !== 'undefined') {
// @ts-ignore Buffer might not exist in browser builds
return Buffer.from(data).toString('base64');
const NodeBuffer = getNodeBuffer();
if (NodeBuffer) {
return NodeBuffer.from(data).toString('base64');
}
// Fallback for browsers
return btoa(String.fromCharCode(...data));
}
function base64Decode(str: string): Uint8Array {
// Prefer Node's Buffer when available
if (typeof Buffer !== 'undefined') {
// @ts-ignore Buffer might not exist in browser builds
const buf = Buffer.from(str, 'base64');
const NodeBuffer = getNodeBuffer();
if (NodeBuffer) {
const buf = NodeBuffer.from(str, 'base64');
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
}
// Fallback for browsers