/** * @module node-opcua-address-space * * A precompiled nodeset image: the records of a document as JSON Lines, gzip-compressed. Line 1 * is the header, then one line per node, and a trailer with the node count and the digest of the * source, so that a reader knows it saw the whole file. Writing an image is consuming records; * reading one is producing them: the loader replays an image exactly as it applies the XML. */ import { type EncodeHeaderOptions, type NodesetImageHeader, type NodesetImageTrailer } from "./nodeset_image_codec.js"; import { type NodesetRecord, type NodesetRecordConsumer } from "./nodeset_record.js"; import type { NodesetChunkStream } from "./nodeset_source.js"; export { NodesetImageError, type NodesetImageHeader, type NodesetImageTrailer } from "./nodeset_image_codec.js"; /** the two bytes every gzip stream starts with: how an image is told from XML */ export declare function isNodesetImage(firstBytes: Uint8Array): boolean; /** forget the inflated lines of `image`; the next reader inflates again */ export declare function releaseInflatedImageLines(image: Uint8Array): void; /** whether the inflated lines of `image` are being kept, for the tests */ export declare function hasInflatedImageLines(image: Uint8Array): boolean; /** gzip bytes to text, the way the platform does it best; see {@link setImageInflater} */ export type ImageInflater = (image: Uint8Array) => Promise; /** * how an image given whole is inflated: DecompressionStream everywhere by default; the Node.js * entry point installs zlib, three times as fast on a 200 KB image and off the main thread. * Returns the inflater that was installed before. */ export declare function setImageInflater(inflater: ImageInflater): ImageInflater; export declare function inflatedImageLines(image: Uint8Array): Promise; export interface NodesetImageWriterOptions extends EncodeHeaderOptions { } /** * a record consumer that builds the image; attach it next to the address-space applier and the * image is written in the same pass as the parse, whatever the source */ export declare class NodesetImageWriter implements NodesetRecordConsumer { private readonly options; private readonly nodeLines; private lines; private header; constructor(options?: NodesetImageWriterOptions); apply(record: NodesetRecord): void; /** * the node lines, each reference marked when the target's record in this document does not * declare the inverse (see NodesetReferenceRecord.inverseDeclared): decided here, over the * whole document, whatever the producer knew */ private encodedLines; /** * the uncompressed lines, header first, trailer last; the header is encoded here because the * length of the source is only known once every chunk went through */ text(sourceDigest: string, sourceLength?: number): string; /** the node lines alone, what an exported namespace's digest covers (the header carries a timestamp) */ bodyText(): string; /** the image: the lines, gzip-compressed */ finish(sourceDigest: string, sourceLength?: number): Promise; } export interface ReadNodesetImageOptions { /** the digest the trailer must carry; a mismatch is an image of another source */ expectedDigest?: string; } /** * the records of an image, as its lines inflate; the header is checked first, the trailer last * (node count, and the digest when one is expected); a corrupt, truncated or foreign image throws * a {@link NodesetImageError} */ export declare function imageNodesetRecords(image: Uint8Array | NodesetChunkStream, options?: ReadNodesetImageOptions): AsyncGenerator; /** * the records of an image given whole, as a synchronous iterator: what the loader consumes * without a turn of the microtask queue per record. The lines come from {@link inflatedImageLines}. */ export declare function imageLinesToRecords(lines: string[], options?: ReadNodesetImageOptions): Generator; /** * what disqualifies an image from being replayed by this loader, or null: the one verdict the * store path, the sibling path and the catalog check share. `expectedDigest` is the SHA-256 of * the source the image must have been built from, when the caller knows it */ export declare function nodesetImageProblem(info: { header: NodesetImageHeader; trailer: NodesetImageTrailer | null; lines: number; }, expectedDigest?: string): string | null; /** the shape {@link readNodesetImageInfo} returns */ export interface NodesetImageInfo { header: NodesetImageHeader; trailer: NodesetImageTrailer | null; /** the node lines: every non-empty line but the header and the trailer */ lines: number; } /** * the header and the trailer of an image; the body lines are inflated but not parsed. An image * given whole is read from its two ends, whatever its size: the header is its first line, the * trailer its last non-empty one, and the node lines are counted, not read */ export declare function readNodesetImageInfo(image: Uint8Array | NodesetChunkStream): Promise;