site-panzai/node_modules/seroval/dist/write-C0KqlAXN.d.ts

86 lines
4.5 KiB
TypeScript
Raw Permalink Normal View History

2026-11-13 13:57:04 +01:00
import { A as PluginAccessOptions, B as SyncParserContextOptions, R as StreamParserContextOptions, at as AsyncParserContextOptions, et as CrossContextOptions, ot as BaseParserContextOptions, st as SerovalNode } from "./shared-DTMVoS-y.js";
import { n as SerovalJSON } from "./read-Bn_ffmiS.js";
//#region src/core/cross/write.d.ts
interface CrossAssignmentOptions {
/**
* Only assign `$R[n]` for values that the output reads more than once,
* such as shared references and cycles. The output is shorter, but later
* scripts cannot read the other values from `$R`. Only use it when no
* later output that shares the same references refers back to this one.
*/
assignSharedRefsOnly?: boolean;
}
interface CrossSerializeOptions extends SyncParserContextOptions, CrossContextOptions, CrossAssignmentOptions {}
declare function crossSerialize<T>(source: T, options?: CrossSerializeOptions): string;
interface CrossSerializeAsyncOptions extends AsyncParserContextOptions, CrossContextOptions, CrossAssignmentOptions {}
declare function crossSerializeAsync<T>(source: T, options?: CrossSerializeAsyncOptions): Promise<string>;
type ToCrossJSONOptions = SyncParserContextOptions;
declare function toCrossJSON<T>(source: T, options?: ToCrossJSONOptions): SerovalNode;
type ToCrossJSONAsyncOptions = AsyncParserContextOptions;
declare function toCrossJSONAsync<T>(source: T, options?: ToCrossJSONAsyncOptions): Promise<SerovalNode>;
interface CrossSerializeStreamOptions extends Omit<StreamParserContextOptions, 'onParse'>, CrossContextOptions {
/**
* Receives each serialized record. Returning a promise defers the next
* record, and the acceptance of the live stream event behind this one,
* until the promise settles.
*/
onSerialize: (data: string, initial: boolean) => void | PromiseLike<void>;
}
declare function crossSerializeStream<T>(source: T, options: CrossSerializeStreamOptions): (reason?: unknown) => void;
type ToCrossJSONStreamOptions = StreamParserContextOptions;
declare function toCrossJSONStream<T>(source: T, options: ToCrossJSONStreamOptions): (reason?: unknown) => void;
//#endregion
//#region src/core/keys.d.ts
declare function getCrossReferenceHeader(id?: string): string;
//#endregion
//#region src/core/Serializer.d.ts
interface SerializerOptions extends PluginAccessOptions {
globalIdentifier: string;
scopeId?: string;
disabledFeatures?: number;
compactArrayBufferViews?: boolean;
depthLimit?: number;
onData: (result: string) => void;
onError: (error: unknown) => void;
onDone?: () => void;
}
declare class Serializer {
private alive;
private flushed;
private done;
private pending;
private cleanups;
private readonly refs;
private plugins?;
private options;
constructor(options: SerializerOptions);
keys: Set<string>;
write(key: string, value: unknown): void;
private finishWrite;
ids: number;
private getNextID;
push(value: unknown): string;
flush(): void;
close(): void;
private finish;
}
//#endregion
//#region src/core/tree/write.d.ts
/**
* Options for `serialize`. The same as the parser options, without `refs`:
* the output is self-contained, so there is nothing to share between calls.
*/
type SerializeOptions = Omit<BaseParserContextOptions, 'refs'>;
/** Options for `serializeAsync`. */
type SerializeAsyncOptions = Omit<BaseParserContextOptions, 'refs'>;
/** Options for `toJSON`. */
type ToJSONOptions = SerializeOptions;
/** Options for `toJSONAsync`. */
type ToJSONAsyncOptions = SerializeAsyncOptions;
declare function serialize<T>(source: T, options?: SerializeOptions): string;
declare function serializeAsync<T>(source: T, options?: SerializeAsyncOptions): Promise<string>;
declare function toJSON<T>(source: T, options?: ToJSONOptions): SerovalJSON;
declare function toJSONAsync<T>(source: T, options?: ToJSONAsyncOptions): Promise<SerovalJSON>;
declare function compileJSON(source: SerovalJSON, options?: PluginAccessOptions): string;
//#endregion
export { toCrossJSONAsync as C, toCrossJSON as S, ToCrossJSONOptions as _, compileJSON as a, crossSerializeAsync as b, toJSON as c, getCrossReferenceHeader as d, CrossAssignmentOptions as f, ToCrossJSONAsyncOptions as g, CrossSerializeStreamOptions as h, ToJSONOptions as i, toJSONAsync as l, CrossSerializeOptions as m, SerializeOptions as n, serialize as o, CrossSerializeAsyncOptions as p, ToJSONAsyncOptions as r, serializeAsync as s, SerializeAsyncOptions as t, Serializer as u, ToCrossJSONStreamOptions as v, toCrossJSONStream as w, crossSerializeStream as x, crossSerialize as y };