UNPKG

@huddle01/web-core

Version:

The Huddle01 Javascript SDK offers a comprehensive suite of methods and event listeners that allow for seamless real-time audio and video communication with minimal coding required.

1,621 lines (1,605 loc) 94.3 kB
'use strict'; // ../../node_modules/@bufbuild/protobuf/dist/esm/private/assert.js function assert(condition, msg) { if (!condition) { throw new Error(msg); } } var FLOAT32_MAX = 34028234663852886e22; var FLOAT32_MIN = -34028234663852886e22; var UINT32_MAX = 4294967295; var INT32_MAX = 2147483647; var INT32_MIN = -2147483648; function assertInt32(arg) { if (typeof arg !== "number") throw new Error("invalid int 32: " + typeof arg); if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN) throw new Error("invalid int 32: " + arg); } function assertUInt32(arg) { if (typeof arg !== "number") throw new Error("invalid uint 32: " + typeof arg); if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0) throw new Error("invalid uint 32: " + arg); } function assertFloat32(arg) { if (typeof arg !== "number") throw new Error("invalid float 32: " + typeof arg); if (!Number.isFinite(arg)) return; if (arg > FLOAT32_MAX || arg < FLOAT32_MIN) throw new Error("invalid float 32: " + arg); } // ../../node_modules/@bufbuild/protobuf/dist/esm/private/enum.js var enumTypeSymbol = Symbol("@bufbuild/protobuf/enum-type"); function getEnumType(enumObject) { const t = enumObject[enumTypeSymbol]; assert(t, "missing enum type on enum object"); return t; } function setEnumType(enumObject, typeName, values, opt) { enumObject[enumTypeSymbol] = makeEnumType(typeName, values.map((v) => ({ no: v.no, name: v.name, localName: enumObject[v.no] }))); } function makeEnumType(typeName, values, _opt) { const names = /* @__PURE__ */ Object.create(null); const numbers = /* @__PURE__ */ Object.create(null); const normalValues = []; for (const value of values) { const n = normalizeEnumValue(value); normalValues.push(n); names[value.name] = n; numbers[value.no] = n; } return { typeName, values: normalValues, // We do not surface options at this time // options: opt?.options ?? Object.create(null), findName(name) { return names[name]; }, findNumber(no) { return numbers[no]; } }; } function makeEnum(typeName, values, opt) { const enumObject = {}; for (const value of values) { const n = normalizeEnumValue(value); enumObject[n.localName] = n.no; enumObject[n.no] = n.localName; } setEnumType(enumObject, typeName, values); return enumObject; } function normalizeEnumValue(value) { if ("localName" in value) { return value; } return Object.assign(Object.assign({}, value), { localName: value.name }); } // ../../node_modules/@bufbuild/protobuf/dist/esm/message.js var Message = class { /** * Compare with a message of the same type. * Note that this function disregards extensions and unknown fields. */ equals(other) { return this.getType().runtime.util.equals(this.getType(), this, other); } /** * Create a deep copy. */ clone() { return this.getType().runtime.util.clone(this); } /** * Parse from binary data, merging fields. * * Repeated fields are appended. Map entries are added, overwriting * existing keys. * * If a message field is already present, it will be merged with the * new data. */ fromBinary(bytes, options) { const type = this.getType(), format = type.runtime.bin, opt = format.makeReadOptions(options); format.readMessage(this, opt.readerFactory(bytes), bytes.byteLength, opt); return this; } /** * Parse a message from a JSON value. */ fromJson(jsonValue, options) { const type = this.getType(), format = type.runtime.json, opt = format.makeReadOptions(options); format.readMessage(type, jsonValue, opt, this); return this; } /** * Parse a message from a JSON string. */ fromJsonString(jsonString, options) { let json; try { json = JSON.parse(jsonString); } catch (e) { throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${e instanceof Error ? e.message : String(e)}`); } return this.fromJson(json, options); } /** * Serialize the message to binary data. */ toBinary(options) { const type = this.getType(), bin = type.runtime.bin, opt = bin.makeWriteOptions(options), writer = opt.writerFactory(); bin.writeMessage(this, writer, opt); return writer.finish(); } /** * Serialize the message to a JSON value, a JavaScript value that can be * passed to JSON.stringify(). */ toJson(options) { const type = this.getType(), json = type.runtime.json, opt = json.makeWriteOptions(options); return json.writeMessage(this, opt); } /** * Serialize the message to a JSON string. */ toJsonString(options) { var _a; const value = this.toJson(options); return JSON.stringify(value, null, (_a = options === null || options === void 0 ? void 0 : options.prettySpaces) !== null && _a !== void 0 ? _a : 0); } /** * Override for serialization behavior. This will be invoked when calling * JSON.stringify on this message (i.e. JSON.stringify(msg)). * * Note that this will not serialize google.protobuf.Any with a packed * message because the protobuf JSON format specifies that it needs to be * unpacked, and this is only possible with a type registry to look up the * message type. As a result, attempting to serialize a message with this * type will throw an Error. * * This method is protected because you should not need to invoke it * directly -- instead use JSON.stringify or toJsonString for * stringified JSON. Alternatively, if actual JSON is desired, you should * use toJson. */ toJSON() { return this.toJson({ emitDefaultValues: true }); } /** * Retrieve the MessageType of this message - a singleton that represents * the protobuf message declaration and provides metadata for reflection- * based operations. */ getType() { return Object.getPrototypeOf(this).constructor; } }; // ../../node_modules/@bufbuild/protobuf/dist/esm/private/message-type.js function makeMessageType(runtime, typeName, fields, opt) { var _a; const localName = (_a = opt === null || opt === void 0 ? void 0 : opt.localName) !== null && _a !== void 0 ? _a : typeName.substring(typeName.lastIndexOf(".") + 1); const type = { [localName]: function(data) { runtime.util.initFields(this); runtime.util.initPartial(data, this); } }[localName]; Object.setPrototypeOf(type.prototype, new Message()); Object.assign(type, { runtime, typeName, fields: runtime.util.newFieldList(fields), fromBinary(bytes, options) { return new type().fromBinary(bytes, options); }, fromJson(jsonValue, options) { return new type().fromJson(jsonValue, options); }, fromJsonString(jsonString, options) { return new type().fromJsonString(jsonString, options); }, equals(a, b) { return runtime.util.equals(type, a, b); } }); return type; } // ../../node_modules/@bufbuild/protobuf/dist/esm/google/varint.js function varint64read() { let lowBits = 0; let highBits = 0; for (let shift = 0; shift < 28; shift += 7) { let b = this.buf[this.pos++]; lowBits |= (b & 127) << shift; if ((b & 128) == 0) { this.assertBounds(); return [lowBits, highBits]; } } let middleByte = this.buf[this.pos++]; lowBits |= (middleByte & 15) << 28; highBits = (middleByte & 112) >> 4; if ((middleByte & 128) == 0) { this.assertBounds(); return [lowBits, highBits]; } for (let shift = 3; shift <= 31; shift += 7) { let b = this.buf[this.pos++]; highBits |= (b & 127) << shift; if ((b & 128) == 0) { this.assertBounds(); return [lowBits, highBits]; } } throw new Error("invalid varint"); } function varint64write(lo, hi, bytes) { for (let i = 0; i < 28; i = i + 7) { const shift = lo >>> i; const hasNext = !(shift >>> 7 == 0 && hi == 0); const byte = (hasNext ? shift | 128 : shift) & 255; bytes.push(byte); if (!hasNext) { return; } } const splitBits = lo >>> 28 & 15 | (hi & 7) << 4; const hasMoreBits = !(hi >> 3 == 0); bytes.push((hasMoreBits ? splitBits | 128 : splitBits) & 255); if (!hasMoreBits) { return; } for (let i = 3; i < 31; i = i + 7) { const shift = hi >>> i; const hasNext = !(shift >>> 7 == 0); const byte = (hasNext ? shift | 128 : shift) & 255; bytes.push(byte); if (!hasNext) { return; } } bytes.push(hi >>> 31 & 1); } var TWO_PWR_32_DBL = 4294967296; function int64FromString(dec) { const minus = dec[0] === "-"; if (minus) { dec = dec.slice(1); } const base = 1e6; let lowBits = 0; let highBits = 0; function add1e6digit(begin, end) { const digit1e6 = Number(dec.slice(begin, end)); highBits *= base; lowBits = lowBits * base + digit1e6; if (lowBits >= TWO_PWR_32_DBL) { highBits = highBits + (lowBits / TWO_PWR_32_DBL | 0); lowBits = lowBits % TWO_PWR_32_DBL; } } add1e6digit(-24, -18); add1e6digit(-18, -12); add1e6digit(-12, -6); add1e6digit(-6); return minus ? negate(lowBits, highBits) : newBits(lowBits, highBits); } function int64ToString(lo, hi) { let bits = newBits(lo, hi); const negative = bits.hi & 2147483648; if (negative) { bits = negate(bits.lo, bits.hi); } const result = uInt64ToString(bits.lo, bits.hi); return negative ? "-" + result : result; } function uInt64ToString(lo, hi) { ({ lo, hi } = toUnsigned(lo, hi)); if (hi <= 2097151) { return String(TWO_PWR_32_DBL * hi + lo); } const low = lo & 16777215; const mid = (lo >>> 24 | hi << 8) & 16777215; const high = hi >> 16 & 65535; let digitA = low + mid * 6777216 + high * 6710656; let digitB = mid + high * 8147497; let digitC = high * 2; const base = 1e7; if (digitA >= base) { digitB += Math.floor(digitA / base); digitA %= base; } if (digitB >= base) { digitC += Math.floor(digitB / base); digitB %= base; } return digitC.toString() + decimalFrom1e7WithLeadingZeros(digitB) + decimalFrom1e7WithLeadingZeros(digitA); } function toUnsigned(lo, hi) { return { lo: lo >>> 0, hi: hi >>> 0 }; } function newBits(lo, hi) { return { lo: lo | 0, hi: hi | 0 }; } function negate(lowBits, highBits) { highBits = ~highBits; if (lowBits) { lowBits = ~lowBits + 1; } else { highBits += 1; } return newBits(lowBits, highBits); } var decimalFrom1e7WithLeadingZeros = (digit1e7) => { const partial = String(digit1e7); return "0000000".slice(partial.length) + partial; }; function varint32write(value, bytes) { if (value >= 0) { while (value > 127) { bytes.push(value & 127 | 128); value = value >>> 7; } bytes.push(value); } else { for (let i = 0; i < 9; i++) { bytes.push(value & 127 | 128); value = value >> 7; } bytes.push(1); } } function varint32read() { let b = this.buf[this.pos++]; let result = b & 127; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 127) << 7; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 127) << 14; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 127) << 21; if ((b & 128) == 0) { this.assertBounds(); return result; } b = this.buf[this.pos++]; result |= (b & 15) << 28; for (let readBytes = 5; (b & 128) !== 0 && readBytes < 10; readBytes++) b = this.buf[this.pos++]; if ((b & 128) != 0) throw new Error("invalid varint"); this.assertBounds(); return result >>> 0; } // ../../node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js function makeInt64Support() { const dv = new DataView(new ArrayBuffer(8)); const ok = typeof BigInt === "function" && typeof dv.getBigInt64 === "function" && typeof dv.getBigUint64 === "function" && typeof dv.setBigInt64 === "function" && typeof dv.setBigUint64 === "function" && (typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1"); if (ok) { const MIN = BigInt("-9223372036854775808"), MAX = BigInt("9223372036854775807"), UMIN = BigInt("0"), UMAX = BigInt("18446744073709551615"); return { zero: BigInt(0), supported: true, parse(value) { const bi = typeof value == "bigint" ? value : BigInt(value); if (bi > MAX || bi < MIN) { throw new Error(`int64 invalid: ${value}`); } return bi; }, uParse(value) { const bi = typeof value == "bigint" ? value : BigInt(value); if (bi > UMAX || bi < UMIN) { throw new Error(`uint64 invalid: ${value}`); } return bi; }, enc(value) { dv.setBigInt64(0, this.parse(value), true); return { lo: dv.getInt32(0, true), hi: dv.getInt32(4, true) }; }, uEnc(value) { dv.setBigInt64(0, this.uParse(value), true); return { lo: dv.getInt32(0, true), hi: dv.getInt32(4, true) }; }, dec(lo, hi) { dv.setInt32(0, lo, true); dv.setInt32(4, hi, true); return dv.getBigInt64(0, true); }, uDec(lo, hi) { dv.setInt32(0, lo, true); dv.setInt32(4, hi, true); return dv.getBigUint64(0, true); } }; } const assertInt64String = (value) => assert(/^-?[0-9]+$/.test(value), `int64 invalid: ${value}`); const assertUInt64String = (value) => assert(/^[0-9]+$/.test(value), `uint64 invalid: ${value}`); return { zero: "0", supported: false, parse(value) { if (typeof value != "string") { value = value.toString(); } assertInt64String(value); return value; }, uParse(value) { if (typeof value != "string") { value = value.toString(); } assertUInt64String(value); return value; }, enc(value) { if (typeof value != "string") { value = value.toString(); } assertInt64String(value); return int64FromString(value); }, uEnc(value) { if (typeof value != "string") { value = value.toString(); } assertUInt64String(value); return int64FromString(value); }, dec(lo, hi) { return int64ToString(lo, hi); }, uDec(lo, hi) { return uInt64ToString(lo, hi); } }; } var protoInt64 = makeInt64Support(); // ../../node_modules/@bufbuild/protobuf/dist/esm/scalar.js var ScalarType; (function(ScalarType2) { ScalarType2[ScalarType2["DOUBLE"] = 1] = "DOUBLE"; ScalarType2[ScalarType2["FLOAT"] = 2] = "FLOAT"; ScalarType2[ScalarType2["INT64"] = 3] = "INT64"; ScalarType2[ScalarType2["UINT64"] = 4] = "UINT64"; ScalarType2[ScalarType2["INT32"] = 5] = "INT32"; ScalarType2[ScalarType2["FIXED64"] = 6] = "FIXED64"; ScalarType2[ScalarType2["FIXED32"] = 7] = "FIXED32"; ScalarType2[ScalarType2["BOOL"] = 8] = "BOOL"; ScalarType2[ScalarType2["STRING"] = 9] = "STRING"; ScalarType2[ScalarType2["BYTES"] = 12] = "BYTES"; ScalarType2[ScalarType2["UINT32"] = 13] = "UINT32"; ScalarType2[ScalarType2["SFIXED32"] = 15] = "SFIXED32"; ScalarType2[ScalarType2["SFIXED64"] = 16] = "SFIXED64"; ScalarType2[ScalarType2["SINT32"] = 17] = "SINT32"; ScalarType2[ScalarType2["SINT64"] = 18] = "SINT64"; })(ScalarType || (ScalarType = {})); var LongType; (function(LongType2) { LongType2[LongType2["BIGINT"] = 0] = "BIGINT"; LongType2[LongType2["STRING"] = 1] = "STRING"; })(LongType || (LongType = {})); // ../../node_modules/@bufbuild/protobuf/dist/esm/private/scalars.js function scalarEquals(type, a, b) { if (a === b) { return true; } if (type == ScalarType.BYTES) { if (!(a instanceof Uint8Array) || !(b instanceof Uint8Array)) { return false; } if (a.length !== b.length) { return false; } for (let i = 0; i < a.length; i++) { if (a[i] !== b[i]) { return false; } } return true; } switch (type) { case ScalarType.UINT64: case ScalarType.FIXED64: case ScalarType.INT64: case ScalarType.SFIXED64: case ScalarType.SINT64: return a == b; } return false; } function scalarZeroValue(type, longType) { switch (type) { case ScalarType.BOOL: return false; case ScalarType.UINT64: case ScalarType.FIXED64: case ScalarType.INT64: case ScalarType.SFIXED64: case ScalarType.SINT64: return longType == 0 ? protoInt64.zero : "0"; case ScalarType.DOUBLE: case ScalarType.FLOAT: return 0; case ScalarType.BYTES: return new Uint8Array(0); case ScalarType.STRING: return ""; default: return 0; } } function isScalarZeroValue(type, value) { switch (type) { case ScalarType.BOOL: return value === false; case ScalarType.STRING: return value === ""; case ScalarType.BYTES: return value instanceof Uint8Array && !value.byteLength; default: return value == 0; } } // ../../node_modules/@bufbuild/protobuf/dist/esm/binary-encoding.js var WireType; (function(WireType2) { WireType2[WireType2["Varint"] = 0] = "Varint"; WireType2[WireType2["Bit64"] = 1] = "Bit64"; WireType2[WireType2["LengthDelimited"] = 2] = "LengthDelimited"; WireType2[WireType2["StartGroup"] = 3] = "StartGroup"; WireType2[WireType2["EndGroup"] = 4] = "EndGroup"; WireType2[WireType2["Bit32"] = 5] = "Bit32"; })(WireType || (WireType = {})); var BinaryWriter = class { constructor(textEncoder) { this.stack = []; this.textEncoder = textEncoder !== null && textEncoder !== void 0 ? textEncoder : new TextEncoder(); this.chunks = []; this.buf = []; } /** * Return all bytes written and reset this writer. */ finish() { this.chunks.push(new Uint8Array(this.buf)); let len = 0; for (let i = 0; i < this.chunks.length; i++) len += this.chunks[i].length; let bytes = new Uint8Array(len); let offset = 0; for (let i = 0; i < this.chunks.length; i++) { bytes.set(this.chunks[i], offset); offset += this.chunks[i].length; } this.chunks = []; return bytes; } /** * Start a new fork for length-delimited data like a message * or a packed repeated field. * * Must be joined later with `join()`. */ fork() { this.stack.push({ chunks: this.chunks, buf: this.buf }); this.chunks = []; this.buf = []; return this; } /** * Join the last fork. Write its length and bytes, then * return to the previous state. */ join() { let chunk = this.finish(); let prev = this.stack.pop(); if (!prev) throw new Error("invalid state, fork stack empty"); this.chunks = prev.chunks; this.buf = prev.buf; this.uint32(chunk.byteLength); return this.raw(chunk); } /** * Writes a tag (field number and wire type). * * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`. * * Generated code should compute the tag ahead of time and call `uint32()`. */ tag(fieldNo, type) { return this.uint32((fieldNo << 3 | type) >>> 0); } /** * Write a chunk of raw bytes. */ raw(chunk) { if (this.buf.length) { this.chunks.push(new Uint8Array(this.buf)); this.buf = []; } this.chunks.push(chunk); return this; } /** * Write a `uint32` value, an unsigned 32 bit varint. */ uint32(value) { assertUInt32(value); while (value > 127) { this.buf.push(value & 127 | 128); value = value >>> 7; } this.buf.push(value); return this; } /** * Write a `int32` value, a signed 32 bit varint. */ int32(value) { assertInt32(value); varint32write(value, this.buf); return this; } /** * Write a `bool` value, a variant. */ bool(value) { this.buf.push(value ? 1 : 0); return this; } /** * Write a `bytes` value, length-delimited arbitrary data. */ bytes(value) { this.uint32(value.byteLength); return this.raw(value); } /** * Write a `string` value, length-delimited data converted to UTF-8 text. */ string(value) { let chunk = this.textEncoder.encode(value); this.uint32(chunk.byteLength); return this.raw(chunk); } /** * Write a `float` value, 32-bit floating point number. */ float(value) { assertFloat32(value); let chunk = new Uint8Array(4); new DataView(chunk.buffer).setFloat32(0, value, true); return this.raw(chunk); } /** * Write a `double` value, a 64-bit floating point number. */ double(value) { let chunk = new Uint8Array(8); new DataView(chunk.buffer).setFloat64(0, value, true); return this.raw(chunk); } /** * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer. */ fixed32(value) { assertUInt32(value); let chunk = new Uint8Array(4); new DataView(chunk.buffer).setUint32(0, value, true); return this.raw(chunk); } /** * Write a `sfixed32` value, a signed, fixed-length 32-bit integer. */ sfixed32(value) { assertInt32(value); let chunk = new Uint8Array(4); new DataView(chunk.buffer).setInt32(0, value, true); return this.raw(chunk); } /** * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint. */ sint32(value) { assertInt32(value); value = (value << 1 ^ value >> 31) >>> 0; varint32write(value, this.buf); return this; } /** * Write a `fixed64` value, a signed, fixed-length 64-bit integer. */ sfixed64(value) { let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = protoInt64.enc(value); view.setInt32(0, tc.lo, true); view.setInt32(4, tc.hi, true); return this.raw(chunk); } /** * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer. */ fixed64(value) { let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = protoInt64.uEnc(value); view.setInt32(0, tc.lo, true); view.setInt32(4, tc.hi, true); return this.raw(chunk); } /** * Write a `int64` value, a signed 64-bit varint. */ int64(value) { let tc = protoInt64.enc(value); varint64write(tc.lo, tc.hi, this.buf); return this; } /** * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint. */ sint64(value) { let tc = protoInt64.enc(value), sign = tc.hi >> 31, lo = tc.lo << 1 ^ sign, hi = (tc.hi << 1 | tc.lo >>> 31) ^ sign; varint64write(lo, hi, this.buf); return this; } /** * Write a `uint64` value, an unsigned 64-bit varint. */ uint64(value) { let tc = protoInt64.uEnc(value); varint64write(tc.lo, tc.hi, this.buf); return this; } }; var BinaryReader = class { constructor(buf, textDecoder) { this.varint64 = varint64read; this.uint32 = varint32read; this.buf = buf; this.len = buf.length; this.pos = 0; this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength); this.textDecoder = textDecoder !== null && textDecoder !== void 0 ? textDecoder : new TextDecoder(); } /** * Reads a tag - field number and wire type. */ tag() { let tag = this.uint32(), fieldNo = tag >>> 3, wireType = tag & 7; if (fieldNo <= 0 || wireType < 0 || wireType > 5) throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType); return [fieldNo, wireType]; } /** * Skip one element and return the skipped data. * * When skipping StartGroup, provide the tags field number to check for * matching field number in the EndGroup tag. */ skip(wireType, fieldNo) { let start = this.pos; switch (wireType) { case WireType.Varint: while (this.buf[this.pos++] & 128) { } break; // eslint-disable-next-line // @ts-ignore TS7029: Fallthrough case in switch case WireType.Bit64: this.pos += 4; // eslint-disable-next-line // @ts-ignore TS7029: Fallthrough case in switch case WireType.Bit32: this.pos += 4; break; case WireType.LengthDelimited: let len = this.uint32(); this.pos += len; break; case WireType.StartGroup: for (; ; ) { const [fn, wt] = this.tag(); if (wt === WireType.EndGroup) { if (fieldNo !== void 0 && fn !== fieldNo) { throw new Error("invalid end group tag"); } break; } this.skip(wt, fn); } break; default: throw new Error("cant skip wire type " + wireType); } this.assertBounds(); return this.buf.subarray(start, this.pos); } /** * Throws error if position in byte array is out of range. */ assertBounds() { if (this.pos > this.len) throw new RangeError("premature EOF"); } /** * Read a `int32` field, a signed 32 bit varint. */ int32() { return this.uint32() | 0; } /** * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint. */ sint32() { let zze = this.uint32(); return zze >>> 1 ^ -(zze & 1); } /** * Read a `int64` field, a signed 64-bit varint. */ int64() { return protoInt64.dec(...this.varint64()); } /** * Read a `uint64` field, an unsigned 64-bit varint. */ uint64() { return protoInt64.uDec(...this.varint64()); } /** * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint. */ sint64() { let [lo, hi] = this.varint64(); let s = -(lo & 1); lo = (lo >>> 1 | (hi & 1) << 31) ^ s; hi = hi >>> 1 ^ s; return protoInt64.dec(lo, hi); } /** * Read a `bool` field, a variant. */ bool() { let [lo, hi] = this.varint64(); return lo !== 0 || hi !== 0; } /** * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer. */ fixed32() { return this.view.getUint32((this.pos += 4) - 4, true); } /** * Read a `sfixed32` field, a signed, fixed-length 32-bit integer. */ sfixed32() { return this.view.getInt32((this.pos += 4) - 4, true); } /** * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer. */ fixed64() { return protoInt64.uDec(this.sfixed32(), this.sfixed32()); } /** * Read a `fixed64` field, a signed, fixed-length 64-bit integer. */ sfixed64() { return protoInt64.dec(this.sfixed32(), this.sfixed32()); } /** * Read a `float` field, 32-bit floating point number. */ float() { return this.view.getFloat32((this.pos += 4) - 4, true); } /** * Read a `double` field, a 64-bit floating point number. */ double() { return this.view.getFloat64((this.pos += 8) - 8, true); } /** * Read a `bytes` field, length-delimited arbitrary data. */ bytes() { let len = this.uint32(), start = this.pos; this.pos += len; this.assertBounds(); return this.buf.subarray(start, start + len); } /** * Read a `string` field, length-delimited data converted to UTF-8 text. */ string() { return this.textDecoder.decode(this.bytes()); } }; // ../../node_modules/@bufbuild/protobuf/dist/esm/private/extensions.js function makeExtension(runtime, typeName, extendee, field) { let fi; return { typeName, extendee, get field() { if (!fi) { const i = typeof field == "function" ? field() : field; i.name = typeName.split(".").pop(); i.jsonName = `[${typeName}]`; fi = runtime.util.newFieldList([i]).list()[0]; } return fi; }, runtime }; } function createExtensionContainer(extension) { const localName = extension.field.localName; const container = /* @__PURE__ */ Object.create(null); container[localName] = initExtensionField(extension); return [container, () => container[localName]]; } function initExtensionField(ext) { const field = ext.field; if (field.repeated) { return []; } if (field.default !== void 0) { return field.default; } switch (field.kind) { case "enum": return field.T.values[0].no; case "scalar": return scalarZeroValue(field.T, field.L); case "message": const T = field.T, value = new T(); return T.fieldWrapper ? T.fieldWrapper.unwrapField(value) : value; case "map": throw "map fields are not allowed to be extensions"; } } function filterUnknownFields(unknownFields, field) { if (!field.repeated && (field.kind == "enum" || field.kind == "scalar")) { for (let i = unknownFields.length - 1; i >= 0; --i) { if (unknownFields[i].no == field.no) { return [unknownFields[i]]; } } return []; } return unknownFields.filter((uf) => uf.no === field.no); } // ../../node_modules/@bufbuild/protobuf/dist/esm/proto-base64.js var encTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""); var decTable = []; for (let i = 0; i < encTable.length; i++) decTable[encTable[i].charCodeAt(0)] = i; decTable["-".charCodeAt(0)] = encTable.indexOf("+"); decTable["_".charCodeAt(0)] = encTable.indexOf("/"); var protoBase64 = { /** * Decodes a base64 string to a byte array. * * - ignores white-space, including line breaks and tabs * - allows inner padding (can decode concatenated base64 strings) * - does not require padding * - understands base64url encoding: * "-" instead of "+", * "_" instead of "/", * no padding */ dec(base64Str) { let es = base64Str.length * 3 / 4; if (base64Str[base64Str.length - 2] == "=") es -= 2; else if (base64Str[base64Str.length - 1] == "=") es -= 1; let bytes = new Uint8Array(es), bytePos = 0, groupPos = 0, b, p = 0; for (let i = 0; i < base64Str.length; i++) { b = decTable[base64Str.charCodeAt(i)]; if (b === void 0) { switch (base64Str[i]) { // @ts-ignore TS7029: Fallthrough case in switch case "=": groupPos = 0; // reset state when padding found // @ts-ignore TS7029: Fallthrough case in switch case "\n": case "\r": case " ": case " ": continue; // skip white-space, and padding default: throw Error("invalid base64 string."); } } switch (groupPos) { case 0: p = b; groupPos = 1; break; case 1: bytes[bytePos++] = p << 2 | (b & 48) >> 4; p = b; groupPos = 2; break; case 2: bytes[bytePos++] = (p & 15) << 4 | (b & 60) >> 2; p = b; groupPos = 3; break; case 3: bytes[bytePos++] = (p & 3) << 6 | b; groupPos = 0; break; } } if (groupPos == 1) throw Error("invalid base64 string."); return bytes.subarray(0, bytePos); }, /** * Encode a byte array to a base64 string. */ enc(bytes) { let base64 = "", groupPos = 0, b, p = 0; for (let i = 0; i < bytes.length; i++) { b = bytes[i]; switch (groupPos) { case 0: base64 += encTable[b >> 2]; p = (b & 3) << 4; groupPos = 1; break; case 1: base64 += encTable[p | b >> 4]; p = (b & 15) << 2; groupPos = 2; break; case 2: base64 += encTable[p | b >> 6]; base64 += encTable[b & 63]; groupPos = 0; break; } } if (groupPos) { base64 += encTable[p]; base64 += "="; if (groupPos == 1) base64 += "="; } return base64; } }; // ../../node_modules/@bufbuild/protobuf/dist/esm/extension-accessor.js function getExtension(message, extension, options) { assertExtendee(extension, message); const opt = extension.runtime.bin.makeReadOptions(options); const ufs = filterUnknownFields(message.getType().runtime.bin.listUnknownFields(message), extension.field); const [container, get] = createExtensionContainer(extension); for (const uf of ufs) { extension.runtime.bin.readField(container, opt.readerFactory(uf.data), extension.field, uf.wireType, opt); } return get(); } function setExtension(message, extension, value, options) { assertExtendee(extension, message); const readOpt = extension.runtime.bin.makeReadOptions(options); const writeOpt = extension.runtime.bin.makeWriteOptions(options); if (hasExtension(message, extension)) { const ufs = message.getType().runtime.bin.listUnknownFields(message).filter((uf) => uf.no != extension.field.no); message.getType().runtime.bin.discardUnknownFields(message); for (const uf of ufs) { message.getType().runtime.bin.onUnknownField(message, uf.no, uf.wireType, uf.data); } } const writer = writeOpt.writerFactory(); let f = extension.field; if (!f.opt && !f.repeated && (f.kind == "enum" || f.kind == "scalar")) { f = Object.assign(Object.assign({}, extension.field), { opt: true }); } extension.runtime.bin.writeField(f, value, writer, writeOpt); const reader = readOpt.readerFactory(writer.finish()); while (reader.pos < reader.len) { const [no, wireType] = reader.tag(); const data = reader.skip(wireType, no); message.getType().runtime.bin.onUnknownField(message, no, wireType, data); } } function hasExtension(message, extension) { const messageType = message.getType(); return extension.extendee.typeName === messageType.typeName && !!messageType.runtime.bin.listUnknownFields(message).find((uf) => uf.no == extension.field.no); } function assertExtendee(extension, message) { assert(extension.extendee.typeName == message.getType().typeName, `extension ${extension.typeName} can only be applied to message ${extension.extendee.typeName}`); } // ../../node_modules/@bufbuild/protobuf/dist/esm/private/reflect.js function isFieldSet(field, target) { const localName = field.localName; if (field.repeated) { return target[localName].length > 0; } if (field.oneof) { return target[field.oneof.localName].case === localName; } switch (field.kind) { case "enum": case "scalar": if (field.opt || field.req) { return target[localName] !== void 0; } if (field.kind == "enum") { return target[localName] !== field.T.values[0].no; } return !isScalarZeroValue(field.T, target[localName]); case "message": return target[localName] !== void 0; case "map": return Object.keys(target[localName]).length > 0; } } function clearField(field, target) { const localName = field.localName; const implicitPresence = !field.opt && !field.req; if (field.repeated) { target[localName] = []; } else if (field.oneof) { target[field.oneof.localName] = { case: void 0 }; } else { switch (field.kind) { case "map": target[localName] = {}; break; case "enum": target[localName] = implicitPresence ? field.T.values[0].no : void 0; break; case "scalar": target[localName] = implicitPresence ? scalarZeroValue(field.T, field.L) : void 0; break; case "message": target[localName] = void 0; break; } } } // ../../node_modules/@bufbuild/protobuf/dist/esm/is-message.js function isMessage(arg, type) { if (arg === null || typeof arg != "object") { return false; } if (!Object.getOwnPropertyNames(Message.prototype).every((m) => m in arg && typeof arg[m] == "function")) { return false; } const actualType = arg.getType(); if (actualType === null || typeof actualType != "function" || !("typeName" in actualType) || typeof actualType.typeName != "string") { return false; } return type === void 0 ? true : actualType.typeName == type.typeName; } // ../../node_modules/@bufbuild/protobuf/dist/esm/private/field-wrapper.js function wrapField(type, value) { if (isMessage(value) || !type.fieldWrapper) { return value; } return type.fieldWrapper.wrapField(value); } ({ "google.protobuf.DoubleValue": ScalarType.DOUBLE, "google.protobuf.FloatValue": ScalarType.FLOAT, "google.protobuf.Int64Value": ScalarType.INT64, "google.protobuf.UInt64Value": ScalarType.UINT64, "google.protobuf.Int32Value": ScalarType.INT32, "google.protobuf.UInt32Value": ScalarType.UINT32, "google.protobuf.BoolValue": ScalarType.BOOL, "google.protobuf.StringValue": ScalarType.STRING, "google.protobuf.BytesValue": ScalarType.BYTES }); // ../../node_modules/@bufbuild/protobuf/dist/esm/private/json-format.js var jsonReadDefaults = { ignoreUnknownFields: false }; var jsonWriteDefaults = { emitDefaultValues: false, enumAsInteger: false, useProtoFieldName: false, prettySpaces: 0 }; function makeReadOptions(options) { return options ? Object.assign(Object.assign({}, jsonReadDefaults), options) : jsonReadDefaults; } function makeWriteOptions(options) { return options ? Object.assign(Object.assign({}, jsonWriteDefaults), options) : jsonWriteDefaults; } var tokenNull = Symbol(); var tokenIgnoredUnknownEnum = Symbol(); function makeJsonFormat() { return { makeReadOptions, makeWriteOptions, readMessage(type, json, options, message) { if (json == null || Array.isArray(json) || typeof json != "object") { throw new Error(`cannot decode message ${type.typeName} from JSON: ${debugJsonValue(json)}`); } message = message !== null && message !== void 0 ? message : new type(); const oneofSeen = /* @__PURE__ */ new Map(); const registry = options.typeRegistry; for (const [jsonKey, jsonValue] of Object.entries(json)) { const field = type.fields.findJsonName(jsonKey); if (field) { if (field.oneof) { if (jsonValue === null && field.kind == "scalar") { continue; } const seen = oneofSeen.get(field.oneof); if (seen !== void 0) { throw new Error(`cannot decode message ${type.typeName} from JSON: multiple keys for oneof "${field.oneof.name}" present: "${seen}", "${jsonKey}"`); } oneofSeen.set(field.oneof, jsonKey); } readField(message, jsonValue, field, options, type); } else { let found = false; if ((registry === null || registry === void 0 ? void 0 : registry.findExtension) && jsonKey.startsWith("[") && jsonKey.endsWith("]")) { const ext = registry.findExtension(jsonKey.substring(1, jsonKey.length - 1)); if (ext && ext.extendee.typeName == type.typeName) { found = true; const [container, get] = createExtensionContainer(ext); readField(container, jsonValue, ext.field, options, ext); setExtension(message, ext, get(), options); } } if (!found && !options.ignoreUnknownFields) { throw new Error(`cannot decode message ${type.typeName} from JSON: key "${jsonKey}" is unknown`); } } } return message; }, writeMessage(message, options) { const type = message.getType(); const json = {}; let field; try { for (field of type.fields.byNumber()) { if (!isFieldSet(field, message)) { if (field.req) { throw `required field not set`; } if (!options.emitDefaultValues) { continue; } if (!canEmitFieldDefaultValue(field)) { continue; } } const value = field.oneof ? message[field.oneof.localName].value : message[field.localName]; const jsonValue = writeField(field, value, options); if (jsonValue !== void 0) { json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue; } } const registry = options.typeRegistry; if (registry === null || registry === void 0 ? void 0 : registry.findExtensionFor) { for (const uf of type.runtime.bin.listUnknownFields(message)) { const ext = registry.findExtensionFor(type.typeName, uf.no); if (ext && hasExtension(message, ext)) { const value = getExtension(message, ext, options); const jsonValue = writeField(ext.field, value, options); if (jsonValue !== void 0) { json[ext.field.jsonName] = jsonValue; } } } } } catch (e) { const m = field ? `cannot encode field ${type.typeName}.${field.name} to JSON` : `cannot encode message ${type.typeName} to JSON`; const r = e instanceof Error ? e.message : String(e); throw new Error(m + (r.length > 0 ? `: ${r}` : "")); } return json; }, readScalar(type, json, longType) { return readScalar(type, json, longType !== null && longType !== void 0 ? longType : LongType.BIGINT, true); }, writeScalar(type, value, emitDefaultValues) { if (value === void 0) { return void 0; } if (emitDefaultValues || isScalarZeroValue(type, value)) { return writeScalar(type, value); } return void 0; }, debug: debugJsonValue }; } function debugJsonValue(json) { if (json === null) { return "null"; } switch (typeof json) { case "object": return Array.isArray(json) ? "array" : "object"; case "string": return json.length > 100 ? "string" : `"${json.split('"').join('\\"')}"`; default: return String(json); } } function readField(target, jsonValue, field, options, parentType) { let localName = field.localName; if (field.repeated) { assert(field.kind != "map"); if (jsonValue === null) { return; } if (!Array.isArray(jsonValue)) { throw new Error(`cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`); } const targetArray = target[localName]; for (const jsonItem of jsonValue) { if (jsonItem === null) { throw new Error(`cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonItem)}`); } switch (field.kind) { case "message": targetArray.push(field.T.fromJson(jsonItem, options)); break; case "enum": const enumValue = readEnum(field.T, jsonItem, options.ignoreUnknownFields, true); if (enumValue !== tokenIgnoredUnknownEnum) { targetArray.push(enumValue); } break; case "scalar": try { targetArray.push(readScalar(field.T, jsonItem, field.L, true)); } catch (e) { let m = `cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonItem)}`; if (e instanceof Error && e.message.length > 0) { m += `: ${e.message}`; } throw new Error(m); } break; } } } else if (field.kind == "map") { if (jsonValue === null) { return; } if (typeof jsonValue != "object" || Array.isArray(jsonValue)) { throw new Error(`cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`); } const targetMap = target[localName]; for (const [jsonMapKey, jsonMapValue] of Object.entries(jsonValue)) { if (jsonMapValue === null) { throw new Error(`cannot decode field ${parentType.typeName}.${field.name} from JSON: map value null`); } let key; try { key = readMapKey(field.K, jsonMapKey); } catch (e) { let m = `cannot decode map key for field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`; if (e instanceof Error && e.message.length > 0) { m += `: ${e.message}`; } throw new Error(m); } switch (field.V.kind) { case "message": targetMap[key] = field.V.T.fromJson(jsonMapValue, options); break; case "enum": const enumValue = readEnum(field.V.T, jsonMapValue, options.ignoreUnknownFields, true); if (enumValue !== tokenIgnoredUnknownEnum) { targetMap[key] = enumValue; } break; case "scalar": try { targetMap[key] = readScalar(field.V.T, jsonMapValue, LongType.BIGINT, true); } catch (e) { let m = `cannot decode map value for field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`; if (e instanceof Error && e.message.length > 0) { m += `: ${e.message}`; } throw new Error(m); } break; } } } else { if (field.oneof) { target = target[field.oneof.localName] = { case: localName }; localName = "value"; } switch (field.kind) { case "message": const messageType = field.T; if (jsonValue === null && messageType.typeName != "google.protobuf.Value") { return; } let currentValue = target[localName]; if (isMessage(currentValue)) { currentValue.fromJson(jsonValue, options); } else { target[localName] = currentValue = messageType.fromJson(jsonValue, options); if (messageType.fieldWrapper && !field.oneof) { target[localName] = messageType.fieldWrapper.unwrapField(currentValue); } } break; case "enum": const enumValue = readEnum(field.T, jsonValue, options.ignoreUnknownFields, false); switch (enumValue) { case tokenNull: clearField(field, target); break; case tokenIgnoredUnknownEnum: break; default: target[localName] = enumValue; break; } break; case "scalar": try { const scalarValue = readScalar(field.T, jsonValue, field.L, false); switch (scalarValue) { case tokenNull: clearField(field, target); break; default: target[localName] = scalarValue; break; } } catch (e) { let m = `cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`; if (e instanceof Error && e.message.length > 0) { m += `: ${e.message}`; } throw new Error(m); } break; } } } function readMapKey(type, json) { if (type === ScalarType.BOOL) { switch (json) { case "true": json = true; break; case "false": json = false; break; } } return readScalar(type, json, LongType.BIGINT, true).toString(); } function readScalar(type, json, longType, nullAsZeroValue) { if (json === null) { if (nullAsZeroValue) { return scalarZeroValue(type, longType); } return tokenNull; } switch (type) { // float, double: JSON value will be a number or one of the special string values "NaN", "Infinity", and "-Infinity". // Either numbers or strings are accepted. Exponent notation is also accepted. case ScalarType.DOUBLE: case ScalarType.FLOAT: if (json === "NaN") return Number.NaN; if (json === "Infinity") return Number.POSITIVE_INFINITY; if (json === "-Infinity") return Number.NEGATIVE_INFINITY; if (json === "") { break; } if (typeof json == "string" && json.trim().length !== json.length) { break; } if (typeof json != "string" && typeof json != "number") { break; } const float = Number(json); if (Number.isNaN(float)) { break; } if (!Number.isFinite(float)) { break; } if (type == ScalarType.FLOAT) assertFloat32(float); return float; // int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted. case ScalarType.INT32: case ScalarType.FIXED32: case ScalarType.SFIXED32: case ScalarType.SINT32: case ScalarType.UINT32: let int32; if (typeof json == "number") int32 = json; else if (typeof json == "string" && json.length > 0) { if (json.trim().length === json.length) int32 = Number(json); } if (int32 === void 0) break; if (type == ScalarType.UINT32 || type == ScalarType.FIXED32) assertUInt32(int32); else assertInt32(int32); return int32; // int64, fixed64, uint64: JSON value will be a decimal string. Either numbers or strings are accepted. case ScalarType.INT64: case ScalarType.SFIXED64: case ScalarType.SINT64: if (typeof json != "number" && typeof json != "string") break; const long = protoInt64.parse(json); return longType ? long.toString() : long; case ScalarType.FIXED64: case ScalarType.UINT64: if (typeof json != "number" && typeof json != "string") break; const uLong = protoInt64.uParse(json); return longType ? uLong.toString() : uLong; // bool: case ScalarType.BOOL: if (typeof json !== "boolean") break; return json; // string: case ScalarType.STRING: if (typeof json !== "string") { break; } try { encodeURIComponent(json); } catch (e) { throw new Error("invalid UTF8"); } return json; // bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings. // Either standard or URL-safe base64 encoding with/without paddings are accepted. case ScalarType.BYTES: if (json === "") return new Uint