@firebase/firestore
Version:
The Cloud Firestore component of the Firebase JS SDK.
67 lines (66 loc) • 2.61 kB
TypeScript
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { BundleMetadata } from '../protos/firestore_bundle_proto';
import { JsonProtoSerializer } from '../remote/serializer';
import { BundleReaderSync, SizedBundleElement } from './bundle_reader';
/**
* A class that can parse a bundle from the string serialization of a bundle.
*
* Bundle element length prefixes are specified as UTF-8 byte counts, so the
* bundle string is UTF-8 encoded and parsed as bytes rather than as UTF-16
* code units (which would differ for any non-ASCII character).
*/
export declare class BundleReaderSyncImpl implements BundleReaderSync {
readonly serializer: JsonProtoSerializer;
private metadata;
private elements;
private cursor;
private readonly bundleData;
private readonly textDecoder;
constructor(bundleData: string, serializer: JsonProtoSerializer);
getMetadata(): BundleMetadata;
getElements(): SizedBundleElement[];
/**
* Parses the next element of the bundle.
*
* @returns a SizedBundleElement representation of the next element in the bundle, or null if
* no more elements exist.
*/
private nextElement;
/**
* Reads from a specified position from the UTF-8 encoded bundleData, for a
* specified number of bytes.
*
* @param length - how many bytes to read.
* @returns a string parsed from the bundle.
*/
private readJsonString;
/**
* Reads from the current cursor until the first '{', and advances the cursor
* to it.
*
* @returns The parsed length of the next element, in bytes.
* @throws An {@link Error} if the cursor has reached the end of the
* bundle data, since lengths prefix bundle objects, or if the length prefix
* is not a non-negative integer.
*/
private readLength;
}
/**
* Creates an instance of BundleReader without exposing the BundleReaderSyncImpl class type.
*/
export declare function newBundleReaderSync(bundleData: string, serializer: JsonProtoSerializer): BundleReaderSync;