// Code generated by protoc-gen-grpc-ts. DO NOT EDIT. // Generated from: lock/types.proto import { NeoFsV2Refs } from '../refs/types_pb'; type ChecksumType = NeoFsV2Refs.ChecksumType; class BinaryWriter { private buffer: Uint8Array = new Uint8Array(1024); private position: number = 0; private ensureCapacity(needed: number): void { if (this.position + needed > this.buffer.length) { const minSize = this.position + needed const newBuffer = new Uint8Array(Math.max(this.buffer.length * 2, minSize)) newBuffer.set(this.buffer); this.buffer = newBuffer; } } private writeVarint(value: number): void { while (value > 127) { this.ensureCapacity(1); this.buffer[this.position++] = (value & 127) | 128; value >>>= 7; } this.ensureCapacity(1); this.buffer[this.position++] = value & 127; } private writeVarintBigInt(value: bigint): void { while (value > 127n) { this.ensureCapacity(1); this.buffer[this.position++] = Number(value & 127n) | 128; value >>= 7n; } this.ensureCapacity(1); this.buffer[this.position++] = Number(value & 127n); } writeDouble(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 1); // wire type 1 this.ensureCapacity(8); const view = new DataView(this.buffer.buffer, this.buffer.byteOffset + this.position, 8); view.setFloat64(0, value, true); // little endian this.position += 8; } writeFloat(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 5); // wire type 5 this.ensureCapacity(4); const view = new DataView(this.buffer.buffer, this.buffer.byteOffset + this.position, 4); view.setFloat32(0, value, true); // little endian this.position += 4; } writeInt32(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarint(value); } writeInt64(fieldNumber: number, value: bigint): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarintBigInt(value); } writeUint32(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarint(value); } writeUint64(fieldNumber: number, value: bigint): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarintBigInt(value); } writeBool(fieldNumber: number, value: boolean): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarint(value ? 1 : 0); } writeString(fieldNumber: number, value: string): void { this.writeVarint((fieldNumber << 3) | 2); // wire type 2 const bytes = this.encodeString(value); this.writeVarint(bytes.length); this.ensureCapacity(bytes.length); this.buffer.set(bytes, this.position); this.position += bytes.length; } writeBytes(fieldNumber: number, value: Uint8Array): void { this.writeVarint((fieldNumber << 3) | 2); // wire type 2 this.writeVarint(value.length); this.ensureCapacity(value.length); this.buffer.set(value, this.position); this.position += value.length; } writeMessage(fieldNumber: number, value: any): void { this.writeVarint((fieldNumber << 3) | 2); // wire type 2 const bytes = value.serializeBinary(); this.writeVarint(bytes.length); this.ensureCapacity(bytes.length); this.buffer.set(bytes, this.position); this.position += bytes.length; } writeEnum(fieldNumber: number, value: number): void { this.writeVarint((fieldNumber << 3) | 0); // wire type 0 this.writeVarint(value); } private encodeString(str: string): Uint8Array { // Manual UTF-8 encoding (React Native compatible) const bytes: number[] = []; for (let i = 0; i < str.length; i++) { let codePoint = str.charCodeAt(i); if (codePoint >= 0xD800 && codePoint <= 0xDBFF && i + 1 < str.length) { const next = str.charCodeAt(i + 1); if (next >= 0xDC00 && next <= 0xDFFF) { codePoint = 0x10000 + ((codePoint - 0xD800) << 10) + (next - 0xDC00); i++; } } if (codePoint < 0x80) { bytes.push(codePoint); } else if (codePoint < 0x800) { bytes.push(0xC0 | (codePoint >> 6), 0x80 | (codePoint & 0x3F)); } else if (codePoint < 0x10000) { bytes.push(0xE0 | (codePoint >> 12), 0x80 | ((codePoint >> 6) & 0x3F), 0x80 | (codePoint & 0x3F)); } else { bytes.push(0xF0 | (codePoint >> 18), 0x80 | ((codePoint >> 12) & 0x3F), 0x80 | ((codePoint >> 6) & 0x3F), 0x80 | (codePoint & 0x3F)); } } return new Uint8Array(bytes); } getResultBuffer(): Uint8Array { return this.buffer.slice(0, this.position); } } class BinaryReader { buffer: Uint8Array; position: number = 0; constructor(data: Uint8Array) { this.buffer = data; } readVarint(): number { let result = 0; let shift = 0; while (this.position < this.buffer.length) { const byte = this.buffer[this.position++]; result |= (byte & 127) << shift; if ((byte & 128) === 0) break; shift += 7; } return result; } readVarintBigInt(): bigint { let result = 0n; let shift = 0n; while (this.position < this.buffer.length) { const byte = BigInt(this.buffer[this.position++]); result |= (byte & 127n) << shift; if ((byte & 128n) === 0n) break; shift += 7n; } return result; } readDouble(): number { const view = new DataView(this.buffer.buffer, this.buffer.byteOffset + this.position, 8); this.position += 8; return view.getFloat64(0, true); // little endian } readFloat(): number { const view = new DataView(this.buffer.buffer, this.buffer.byteOffset + this.position, 4); this.position += 4; return view.getFloat32(0, true); // little endian } readInt32(): number { return this.readVarint(); } readInt64(): bigint { return this.readVarintBigInt(); } readUint32(): number { return this.readVarint(); } readUint64(): bigint { return this.readVarintBigInt(); } readBool(): boolean { return this.readVarint() !== 0; } readString(): string { const length = this.readVarint(); const bytes = this.buffer.slice(this.position, this.position + length); this.position += length; return this.decodeString(bytes); } private decodeString(bytes: Uint8Array): string { // Manual UTF-8 decoding (React Native compatible) let result = ''; let i = 0; while (i < bytes.length) { const byte1 = bytes[i++]; if (byte1 < 0x80) { result += String.fromCharCode(byte1); } else if ((byte1 & 0xE0) === 0xC0) { const byte2 = bytes[i++] & 0x3F; result += String.fromCharCode(((byte1 & 0x1F) << 6) | byte2); } else if ((byte1 & 0xF0) === 0xE0) { const byte2 = bytes[i++] & 0x3F; const byte3 = bytes[i++] & 0x3F; result += String.fromCharCode(((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3); } else if ((byte1 & 0xF8) === 0xF0) { const byte2 = bytes[i++] & 0x3F; const byte3 = bytes[i++] & 0x3F; const byte4 = bytes[i++] & 0x3F; const codePoint = ((byte1 & 0x07) << 18) | (byte2 << 12) | (byte3 << 6) | byte4; result += String.fromCharCode(0xD800 + ((codePoint - 0x10000) >> 10), 0xDC00 + ((codePoint - 0x10000) & 0x3FF)); } } return result; } readBytes(): Uint8Array { const length = this.readVarint(); const bytes = this.buffer.slice(this.position, this.position + length); this.position += length; return bytes; } readMessage(deserialize: (data: Uint8Array) => T): T { const length = this.readVarint(); const bytes = this.buffer.slice(this.position, this.position + length); this.position += length; return deserialize(bytes); } readEnum(): number { return this.readVarint(); } readInt32Fixed(): number { const bytes = this.buffer.slice(this.position, this.position + 4); this.position += 4; const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); return view.getInt32(0, true); // little-endian } readInt64Fixed(): bigint { const bytes = this.buffer.slice(this.position, this.position + 8); this.position += 8; const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); return view.getBigInt64(0, true); // little-endian } readUint32Fixed(): number { const bytes = this.buffer.slice(this.position, this.position + 4); this.position += 4; const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); return view.getUint32(0, true); // little-endian } readUint64Fixed(): bigint { const bytes = this.buffer.slice(this.position, this.position + 8); this.position += 8; const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); return view.getBigUint64(0, true); // little-endian } skipField(wireType: number): void { switch (wireType) { case 0: // Varint this.readVarint(); break; case 1: // 64-bit this.position += 8; break; case 2: // Length-delimited const length = this.readVarint(); this.position += length; break; case 3: // Start group (deprecated, just skip) // Groups are deprecated in proto3, skip without reading break; case 4: // End group (deprecated, just skip) // Groups are deprecated in proto3, skip without reading break; case 5: // 32-bit this.position += 4; break; default: throw new Error(`Unknown wire type: ${wireType}`); } } } export namespace NeoFsV2Lock { export interface Lock { Members: NeoFsV2Refs.ObjectID[]; } export class LockImpl implements Lock { Members!: NeoFsV2Refs.ObjectID[]; constructor(data?: Partial) { this.Members = data?.Members ?? []; } serializeBinary(): Uint8Array { const writer = new BinaryWriter(); for (const item of this.Members) { writer.writeMessage(1, item); } return writer.getResultBuffer(); } static deserializeBinary(data: Uint8Array): LockImpl { const reader = new BinaryReader(data); const message = new LockImpl(); // Parse protobuf wire format while (reader.position < reader.buffer.length) { const tag = reader.readVarint(); const fieldNumber = tag >>> 3; const wireType = tag & 7; switch (fieldNumber) { case 1: // Members if (wireType === 2) { // Length-delimited message.Members.push(reader.readMessage(NeoFsV2Refs.ObjectIDImpl.deserializeBinary)); } else { reader.skipField(wireType); } break; default: // Skip unknown fields reader.skipField(wireType); break; } } return message; } toObject(): LockData { return { Members: this.Members }; } } // Export class alias without Impl suffix for Node.js compatibility export class Lock extends LockImpl {} // Type for interface data only (excludes class methods from merged type) export type LockData = Omit; } // namespace NeoFsV2Lock