@mochabug/adaptkit
Version:
A cmd to create, emulate and publish Mochabug Adapt plugins
1,756 lines (1,740 loc) • 326 kB
JavaScript
#!/usr/bin/env node
// <define:__PACKAGE_JSON__>
var define_PACKAGE_JSON_default = { name: "@mochabug/adaptkit", version: "1.0.0-rc.35" };
// node_modules/@bufbuild/protobuf/dist/esm/is-message.js
function isMessage(arg, schema) {
const isMessage2 = arg !== null && typeof arg == "object" && "$typeName" in arg && typeof arg.$typeName == "string";
if (!isMessage2) {
return false;
}
if (schema === void 0) {
return true;
}
return schema.typeName === arg.$typeName;
}
// node_modules/@bufbuild/protobuf/dist/esm/descriptors.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 = {}));
// node_modules/@bufbuild/protobuf/dist/esm/wire/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
var protoInt64 = /* @__PURE__ */ makeInt64Support();
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" && (!!globalThis.Deno || typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1");
if (ok) {
const MIN = BigInt("-9223372036854775808");
const MAX = BigInt("9223372036854775807");
const UMIN = BigInt("0");
const 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(`invalid int64: ${value}`);
}
return bi;
},
uParse(value) {
const bi = typeof value == "bigint" ? value : BigInt(value);
if (bi > UMAX || bi < UMIN) {
throw new Error(`invalid uint64: ${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);
}
};
}
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);
}
};
}
function assertInt64String(value) {
if (!/^-?[0-9]+$/.test(value)) {
throw new Error("invalid int64: " + value);
}
}
function assertUInt64String(value) {
if (!/^[0-9]+$/.test(value)) {
throw new Error("invalid uint64: " + value);
}
}
// node_modules/@bufbuild/protobuf/dist/esm/reflect/scalar.js
function scalarZeroValue(type, longAsString) {
switch (type) {
case ScalarType.STRING:
return "";
case ScalarType.BOOL:
return false;
case ScalarType.DOUBLE:
case ScalarType.FLOAT:
return 0;
case ScalarType.INT64:
case ScalarType.UINT64:
case ScalarType.SFIXED64:
case ScalarType.FIXED64:
case ScalarType.SINT64:
return longAsString ? "0" : protoInt64.zero;
case ScalarType.BYTES:
return new Uint8Array(0);
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/reflect/unsafe.js
var IMPLICIT = 2;
var unsafeLocal = Symbol.for("reflect unsafe local");
function unsafeOneofCase(target, oneof) {
const c = target[oneof.localName].case;
if (c === void 0) {
return c;
}
return oneof.fields.find((f) => f.localName === c);
}
function unsafeIsSet(target, field) {
const name = field.localName;
if (field.oneof) {
return target[field.oneof.localName].case === name;
}
if (field.presence != IMPLICIT) {
return target[name] !== void 0 && Object.prototype.hasOwnProperty.call(target, name);
}
switch (field.fieldKind) {
case "list":
return target[name].length > 0;
case "map":
return Object.keys(target[name]).length > 0;
case "scalar":
return !isScalarZeroValue(field.scalar, target[name]);
case "enum":
return target[name] !== field.enum.values[0].number;
}
throw new Error("message field with implicit presence");
}
function unsafeIsSetExplicit(target, localName) {
return Object.prototype.hasOwnProperty.call(target, localName) && target[localName] !== void 0;
}
function unsafeGet(target, field) {
if (field.oneof) {
const oneof = target[field.oneof.localName];
if (oneof.case === field.localName) {
return oneof.value;
}
return void 0;
}
return target[field.localName];
}
function unsafeSet(target, field, value) {
if (field.oneof) {
target[field.oneof.localName] = {
case: field.localName,
value
};
} else {
target[field.localName] = value;
}
}
function unsafeClear(target, field) {
const name = field.localName;
if (field.oneof) {
const oneofLocalName = field.oneof.localName;
if (target[oneofLocalName].case === name) {
target[oneofLocalName] = { case: void 0 };
}
} else if (field.presence != IMPLICIT) {
delete target[name];
} else {
switch (field.fieldKind) {
case "map":
target[name] = {};
break;
case "list":
target[name] = [];
break;
case "enum":
target[name] = field.enum.values[0].number;
break;
case "scalar":
target[name] = scalarZeroValue(field.scalar, field.longAsString);
break;
}
}
}
// node_modules/@bufbuild/protobuf/dist/esm/reflect/guard.js
function isObject(arg) {
return arg !== null && typeof arg == "object" && !Array.isArray(arg);
}
function isReflectList(arg, field) {
var _a, _b, _c, _d;
if (isObject(arg) && unsafeLocal in arg && "add" in arg && "field" in arg && typeof arg.field == "function") {
if (field !== void 0) {
const a = field;
const b = arg.field();
return a.listKind == b.listKind && a.scalar === b.scalar && ((_a = a.message) === null || _a === void 0 ? void 0 : _a.typeName) === ((_b = b.message) === null || _b === void 0 ? void 0 : _b.typeName) && ((_c = a.enum) === null || _c === void 0 ? void 0 : _c.typeName) === ((_d = b.enum) === null || _d === void 0 ? void 0 : _d.typeName);
}
return true;
}
return false;
}
function isReflectMap(arg, field) {
var _a, _b, _c, _d;
if (isObject(arg) && unsafeLocal in arg && "has" in arg && "field" in arg && typeof arg.field == "function") {
if (field !== void 0) {
const a = field, b = arg.field();
return a.mapKey === b.mapKey && a.mapKind == b.mapKind && a.scalar === b.scalar && ((_a = a.message) === null || _a === void 0 ? void 0 : _a.typeName) === ((_b = b.message) === null || _b === void 0 ? void 0 : _b.typeName) && ((_c = a.enum) === null || _c === void 0 ? void 0 : _c.typeName) === ((_d = b.enum) === null || _d === void 0 ? void 0 : _d.typeName);
}
return true;
}
return false;
}
function isReflectMessage(arg, messageDesc2) {
return isObject(arg) && unsafeLocal in arg && "desc" in arg && isObject(arg.desc) && arg.desc.kind === "message" && (messageDesc2 === void 0 || arg.desc.typeName == messageDesc2.typeName);
}
// node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.js
function isWrapper(arg) {
return isWrapperTypeName(arg.$typeName);
}
function isWrapperDesc(messageDesc2) {
const f = messageDesc2.fields[0];
return isWrapperTypeName(messageDesc2.typeName) && f !== void 0 && f.fieldKind == "scalar" && f.name == "value" && f.number == 1;
}
function isWrapperTypeName(name) {
return name.startsWith("google.protobuf.") && [
"DoubleValue",
"FloatValue",
"Int64Value",
"UInt64Value",
"Int32Value",
"UInt32Value",
"BoolValue",
"StringValue",
"BytesValue"
].includes(name.substring(16));
}
// node_modules/@bufbuild/protobuf/dist/esm/create.js
var EDITION_PROTO3 = 999;
var EDITION_PROTO2 = 998;
var IMPLICIT2 = 2;
function create(schema, init2) {
if (isMessage(init2, schema)) {
return init2;
}
const message = createZeroMessage(schema);
if (init2 !== void 0) {
initMessage(schema, message, init2);
}
return message;
}
function initMessage(messageDesc2, message, init2) {
for (const member of messageDesc2.members) {
let value = init2[member.localName];
if (value == null) {
continue;
}
let field;
if (member.kind == "oneof") {
const oneofField = unsafeOneofCase(init2, member);
if (!oneofField) {
continue;
}
field = oneofField;
value = unsafeGet(init2, oneofField);
} else {
field = member;
}
switch (field.fieldKind) {
case "message":
value = toMessage(field, value);
break;
case "scalar":
value = initScalar(field, value);
break;
case "list":
value = initList(field, value);
break;
case "map":
value = initMap(field, value);
break;
}
unsafeSet(message, field, value);
}
return message;
}
function initScalar(field, value) {
if (field.scalar == ScalarType.BYTES) {
return toU8Arr(value);
}
return value;
}
function initMap(field, value) {
if (isObject(value)) {
if (field.scalar == ScalarType.BYTES) {
return convertObjectValues(value, toU8Arr);
}
if (field.mapKind == "message") {
return convertObjectValues(value, (val) => toMessage(field, val));
}
}
return value;
}
function initList(field, value) {
if (Array.isArray(value)) {
if (field.scalar == ScalarType.BYTES) {
return value.map(toU8Arr);
}
if (field.listKind == "message") {
return value.map((item) => toMessage(field, item));
}
}
return value;
}
function toMessage(field, value) {
if (field.fieldKind == "message" && !field.oneof && isWrapperDesc(field.message)) {
return initScalar(field.message.fields[0], value);
}
if (isObject(value)) {
if (field.message.typeName == "google.protobuf.Struct" && field.parent.typeName !== "google.protobuf.Value") {
return value;
}
if (!isMessage(value, field.message)) {
return create(field.message, value);
}
}
return value;
}
function toU8Arr(value) {
return Array.isArray(value) ? new Uint8Array(value) : value;
}
function convertObjectValues(obj, fn) {
const ret = {};
for (const entry of Object.entries(obj)) {
ret[entry[0]] = fn(entry[1]);
}
return ret;
}
var tokenZeroMessageField = Symbol();
var messagePrototypes = /* @__PURE__ */ new WeakMap();
function createZeroMessage(desc) {
let msg;
if (!needsPrototypeChain(desc)) {
msg = {
$typeName: desc.typeName
};
for (const member of desc.members) {
if (member.kind == "oneof" || member.presence == IMPLICIT2) {
msg[member.localName] = createZeroField(member);
}
}
} else {
const cached = messagePrototypes.get(desc);
let prototype;
let members;
if (cached) {
({ prototype, members } = cached);
} else {
prototype = {};
members = /* @__PURE__ */ new Set();
for (const member of desc.members) {
if (member.kind == "oneof") {
continue;
}
if (member.fieldKind != "scalar" && member.fieldKind != "enum") {
continue;
}
if (member.presence == IMPLICIT2) {
continue;
}
members.add(member);
prototype[member.localName] = createZeroField(member);
}
messagePrototypes.set(desc, { prototype, members });
}
msg = Object.create(prototype);
msg.$typeName = desc.typeName;
for (const member of desc.members) {
if (members.has(member)) {
continue;
}
if (member.kind == "field") {
if (member.fieldKind == "message") {
continue;
}
if (member.fieldKind == "scalar" || member.fieldKind == "enum") {
if (member.presence != IMPLICIT2) {
continue;
}
}
}
msg[member.localName] = createZeroField(member);
}
}
return msg;
}
function needsPrototypeChain(desc) {
switch (desc.file.edition) {
case EDITION_PROTO3:
return false;
case EDITION_PROTO2:
return true;
default:
return desc.fields.some((f) => f.presence != IMPLICIT2 && f.fieldKind != "message" && !f.oneof);
}
}
function createZeroField(field) {
if (field.kind == "oneof") {
return { case: void 0 };
}
if (field.fieldKind == "list") {
return [];
}
if (field.fieldKind == "map") {
return {};
}
if (field.fieldKind == "message") {
return tokenZeroMessageField;
}
const defaultValue = field.getDefaultValue();
if (defaultValue !== void 0) {
return field.fieldKind == "scalar" && field.longAsString ? defaultValue.toString() : defaultValue;
}
return field.fieldKind == "scalar" ? scalarZeroValue(field.scalar, field.longAsString) : field.enum.values[0].number;
}
// node_modules/@bufbuild/protobuf/dist/esm/reflect/error.js
var errorNames = [
"FieldValueInvalidError",
"FieldListRangeError",
"ForeignFieldError"
];
var FieldError = class extends Error {
constructor(fieldOrOneof, message, name = "FieldValueInvalidError") {
super(message);
this.name = name;
this.field = () => fieldOrOneof;
}
};
function isFieldError(arg) {
return arg instanceof Error && errorNames.includes(arg.name) && "field" in arg && typeof arg.field == "function";
}
// node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js
var symbol = Symbol.for("@bufbuild/protobuf/text-encoding");
function getTextEncoding() {
if (globalThis[symbol] == void 0) {
const te = new globalThis.TextEncoder();
const td = new globalThis.TextDecoder();
globalThis[symbol] = {
encodeUtf8(text) {
return te.encode(text);
},
decodeUtf8(bytes) {
return td.decode(bytes);
},
checkUtf8(text) {
try {
encodeURIComponent(text);
return true;
} catch (_) {
return false;
}
}
};
}
return globalThis[symbol];
}
// node_modules/@bufbuild/protobuf/dist/esm/wire/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 FLOAT32_MAX = 34028234663852886e22;
var FLOAT32_MIN = -34028234663852886e22;
var UINT32_MAX = 4294967295;
var INT32_MAX = 2147483647;
var INT32_MIN = -2147483648;
var BinaryWriter = class {
constructor(encodeUtf8 = getTextEncoding().encodeUtf8) {
this.encodeUtf8 = encodeUtf8;
this.stack = [];
this.chunks = [];
this.buf = [];
}
/**
* Return all bytes written and reset this writer.
*/
finish() {
if (this.buf.length) {
this.chunks.push(new Uint8Array(this.buf));
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.encodeUtf8(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) {
const 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) {
const tc = protoInt64.uEnc(value);
varint64write(tc.lo, tc.hi, this.buf);
return this;
}
};
var BinaryReader = class {
constructor(buf, decodeUtf8 = getTextEncoding().decodeUtf8) {
this.decodeUtf8 = decodeUtf8;
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);
}
/**
* 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;
// @ts-ignore TS7029: Fallthrough case in switch -- ignore instead of expect-error for compiler settings without noFallthroughCasesInSwitch: true
case WireType.Bit64:
this.pos += 4;
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.decodeUtf8(this.bytes());
}
};
function assertInt32(arg) {
if (typeof arg == "string") {
arg = Number(arg);
} else if (typeof arg != "number") {
throw new Error("invalid int32: " + typeof arg);
}
if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN)
throw new Error("invalid int32: " + arg);
}
function assertUInt32(arg) {
if (typeof arg == "string") {
arg = Number(arg);
} else if (typeof arg != "number") {
throw new Error("invalid uint32: " + typeof arg);
}
if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0)
throw new Error("invalid uint32: " + arg);
}
function assertFloat32(arg) {
if (typeof arg == "string") {
const o = arg;
arg = Number(arg);
if (Number.isNaN(arg) && o !== "NaN") {
throw new Error("invalid float32: " + o);
}
} else if (typeof arg != "number") {
throw new Error("invalid float32: " + typeof arg);
}
if (Number.isFinite(arg) && (arg > FLOAT32_MAX || arg < FLOAT32_MIN))
throw new Error("invalid float32: " + arg);
}
// node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.js
function checkField(field, value) {
const check = field.fieldKind == "list" ? isReflectList(value, field) : field.fieldKind == "map" ? isReflectMap(value, field) : checkSingular(field, value);
if (check === true) {
return void 0;
}
let reason;
switch (field.fieldKind) {
case "list":
reason = `expected ${formatReflectList(field)}, got ${formatVal(value)}`;
break;
case "map":
reason = `expected ${formatReflectMap(field)}, got ${formatVal(value)}`;
break;
default: {
reason = reasonSingular(field, value, check);
}
}
return new FieldError(field, reason);
}
function checkListItem(field, index, value) {
const check = checkSingular(field, value);
if (check !== true) {
return new FieldError(field, `list item #${index + 1}: ${reasonSingular(field, value, check)}`);
}
return void 0;
}
function checkMapEntry(field, key, value) {
const checkKey = checkScalarValue(key, field.mapKey);
if (checkKey !== true) {
return new FieldError(field, `invalid map key: ${reasonSingular({ scalar: field.mapKey }, key, checkKey)}`);
}
const checkVal = checkSingular(field, value);
if (checkVal !== true) {
return new FieldError(field, `map entry ${formatVal(key)}: ${reasonSingular(field, value, checkVal)}`);
}
return void 0;
}
function checkSingular(field, value) {
if (field.scalar !== void 0) {
return checkScalarValue(value, field.scalar);
}
if (field.enum !== void 0) {
if (field.enum.open) {
return Number.isInteger(value);
}
return field.enum.values.some((v) => v.number === value);
}
return isReflectMessage(value, field.message);
}
function checkScalarValue(value, scalar) {
switch (scalar) {
case ScalarType.DOUBLE:
return typeof value == "number";
case ScalarType.FLOAT:
if (typeof value != "number") {
return false;
}
if (Number.isNaN(value) || !Number.isFinite(value)) {
return true;
}
if (value > FLOAT32_MAX || value < FLOAT32_MIN) {
return `${value.toFixed()} out of range`;
}
return true;
case ScalarType.INT32:
case ScalarType.SFIXED32:
case ScalarType.SINT32:
if (typeof value !== "number" || !Number.isInteger(value)) {
return false;
}
if (value > INT32_MAX || value < INT32_MIN) {
return `${value.toFixed()} out of range`;
}
return true;
case ScalarType.FIXED32:
case ScalarType.UINT32:
if (typeof value !== "number" || !Number.isInteger(value)) {
return false;
}
if (value > UINT32_MAX || value < 0) {
return `${value.toFixed()} out of range`;
}
return true;
case ScalarType.BOOL:
return typeof value == "boolean";
case ScalarType.STRING:
if (typeof value != "string") {
return false;
}
return getTextEncoding().checkUtf8(value) || "invalid UTF8";
case ScalarType.BYTES:
return value instanceof Uint8Array;
case ScalarType.INT64:
case ScalarType.SFIXED64:
case ScalarType.SINT64:
if (typeof value == "bigint" || typeof value == "number" || typeof value == "string" && value.length > 0) {
try {
protoInt64.parse(value);
return true;
} catch (_) {
return `${value} out of range`;
}
}
return false;
case ScalarType.FIXED64:
case ScalarType.UINT64:
if (typeof value == "bigint" || typeof value == "number" || typeof value == "string" && value.length > 0) {
try {
protoInt64.uParse(value);
return true;
} catch (_) {
return `${value} out of range`;
}
}
return false;
}
}
function reasonSingular(field, val, details) {
details = typeof details == "string" ? `: ${details}` : `, got ${formatVal(val)}`;
if (field.scalar !== void 0) {
return `expected ${scalarTypeDescription(field.scalar)}` + details;
}
if (field.enum !== void 0) {
return `expected ${field.enum.toString()}` + details;
}
return `expected ${formatReflectMessage(field.message)}` + details;
}
function formatVal(val) {
switch (typeof val) {
case "object":
if (val === null) {
return "null";
}
if (val instanceof Uint8Array) {
return `Uint8Array(${val.length})`;
}
if (Array.isArray(val)) {
return `Array(${val.length})`;
}
if (isReflectList(val)) {
return formatReflectList(val.field());
}
if (isReflectMap(val)) {
return formatReflectMap(val.field());
}
if (isReflectMessage(val)) {
return formatReflectMessage(val.desc);
}
if (isMessage(val)) {
return `message ${val.$typeName}`;
}
return "object";
case "string":
return val.length > 30 ? "string" : `"${val.split('"').join('\\"')}"`;
case "boolean":
return String(val);
case "number":
return String(val);
case "bigint":
return String(val) + "n";
default:
return typeof val;
}
}
function formatReflectMessage(desc) {
return `ReflectMessage (${desc.typeName})`;
}
function formatReflectList(field) {
switch (field.listKind) {
case "message":
return `ReflectList (${field.message.toString()})`;
case "enum":
return `ReflectList (${field.enum.toString()})`;
case "scalar":
return `ReflectList (${ScalarType[field.scalar]})`;
}
}
function formatReflectMap(field) {
switch (field.mapKind) {
case "message":
return `ReflectMap (${ScalarType[field.mapKey]}, ${field.message.toString()})`;
case "enum":
return `ReflectMap (${ScalarType[field.mapKey]}, ${field.enum.toString()})`;
case "scalar":
return `ReflectMap (${ScalarType[field.mapKey]}, ${ScalarType[field.scalar]})`;
}
}
function scalarTypeDescription(scalar) {
switch (scalar) {
case ScalarType.STRING:
return "string";
case ScalarType.BOOL:
return "boolean";
case ScalarType.INT64:
case ScalarType.SINT64:
case ScalarType.SFIXED64:
return "bigint (int64)";
case ScalarType.UINT64:
case ScalarType.FIXED64:
return "bigint (uint64)";
case ScalarType.BYTES:
return "Uint8Array";
case ScalarType.DOUBLE:
return "number (float64)";
case ScalarType.FLOAT:
return "number (float32)";
case ScalarType.FIXED32:
case ScalarType.UINT32:
return "number (uint32)";
case ScalarType.INT32:
case ScalarType.SFIXED32:
case ScalarType.SINT32:
return "number (int32)";
}
}
// node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js
function reflect(messageDesc2, message, check = true) {
return new ReflectMessageImpl(messageDesc2, message, check);
}
var ReflectMessageImpl = class {
get sortedFields() {
var _a;
return (_a = this._sortedFields) !== null && _a !== void 0 ? _a : (
// biome-ignore lint/suspicious/noAssignInExpressions: no
this._sortedFields = this.desc.fields.concat().sort((a, b) => a.number - b.number)
);
}
constructor(messageDesc2, message, check = true) {
this.lists = /* @__PURE__ */ new Map();
this.maps = /* @__PURE__ */ new Map();
this.check = check;
this.desc = messageDesc2;
this.message = this[unsafeLocal] = message !== null && message !== void 0 ? message : create(messageDesc2);
this.fields = messageDesc2.fields;
this.oneofs = messageDesc2.oneofs;
this.members = messageDesc2.members;
}
findNumber(number) {
if (!this._fieldsByNumber) {
this._fieldsByNumber = new Map(this.desc.fields.map((f) => [f.number, f]));
}
return this._fieldsByNumber.get(number);
}
oneofCase(oneof) {
assertOwn(this.message, oneof);
return unsafeOneofCase(this.message, oneof);
}
isSet(field) {
assertOwn(this.message, field);
return unsafeIsSet(this.message, field);
}
clear(field) {
assertOwn(this.message, field);
unsafeClear(this.message, field);
}
get(field) {
assertOwn(this.message, field);
const value = unsafeGet(this.message, field);
switch (field.fieldKind) {
case "list":
let list = this.lists.get(field);
if (!list || list[unsafeLocal] !== value) {
this.lists.set(
field,
// biome-ignore lint/suspicious/noAssignInExpressions: no
list = new ReflectListImpl(field, value, this.check)
);
}
return list;
case "map":
let map = this.maps.get(field);
if (!map || map[unsafeLocal] !== value) {
this.maps.set(
field,
// biome-ignore lint/suspicious/noAssignInExpressions: no
map = new ReflectMapImpl(field, value, this.check)
);
}
return map;
case "message":
return messageToReflect(field, value, this.check);
case "scalar":
return value === void 0 ? scalarZeroValue(field.scalar, false) : longToReflect(field, value);
case "enum":
return value !== null && value !== void 0 ? value : field.enum.values[0].number;
}
}
set(field, value) {
assertOwn(this.message, field);
if (this.check) {
const err = checkField(field, value);
if (err) {
throw err;
}
}
let local;
if (field.fieldKind == "message") {
local = messageToLocal(field, value);
} else if (isReflectMap(value) || isReflectList(value)) {
local = value[unsafeLocal];
} else {
local = longToLocal(field, value);
}
unsafeSet(this.message, field, local);
}
getUnknown() {
return this.message.$unknown;
}
setUnknown(value) {
this.message.$unknown = value;
}
};
function assertOwn(owner, member) {
if (member.parent.typeName !== owner.$typeName) {
throw new FieldError(member, `cannot use ${member.toString()} with message ${owner.$typeName}`, "ForeignFieldError");
}
}
var ReflectListImpl = class {
field() {
return this._field;
}
get size() {
return this._arr.length;
}
constructor(field, unsafeInput, check) {
this._field = field;
this._arr = this[unsafeLocal] = unsafeInput;
this.check = check;
}
get(index) {
const item = this._arr[index];
return item === void 0 ? void 0 : listItemToReflect(this._field, item, this.check);
}
set(index, item) {
if (index < 0 || index >= this._arr.length) {
throw new FieldError(this._field, `list item #${index + 1}: out of range`);
}
if (this.check) {
const err = checkListItem(this._field, index, item);
if (err) {
throw err;
}
}
this._arr[index] = listItemToLocal(this._field, item);
}
add(item) {
if (this.check) {
const err = checkListItem(this._field, this._arr.length, item);
if (err) {
throw err;
}
}
this._arr.push(listItemToLocal(this._field, item));
return void 0;
}
clear() {
this._arr.splice(0, this._arr.length);
}
[Symbol.iterator]() {
return this.values();
}
keys() {
return this._arr.keys();
}
*values() {
for (const item of this._arr) {
yield listItemToReflect(this._field, item, this.check);
}
}
*entries() {
for (let i = 0; i < this._arr.length; i++) {
yield [i, listItemToReflect(this._field, this._arr[i], this.check)];
}
}
};
var ReflectMapImpl = class {
constructor(field, unsafeInput, check = true) {
this.obj = this[unsafeLocal] = unsafeInput !== null && unsafeInput !== void 0 ? unsafeInput : {};
this.check = check;
this._field = field;
}
field() {
return this._field;
}
set(key, value) {
if (this.check) {
const err = checkMapEntry(this._field, key, value);
if (err) {
throw err;
}
}
this.obj[mapKeyToLocal(key)] = mapValueToLocal(this._field, value);
return this;
}
delete(key) {
const k = mapKeyToLocal(key);
const has = Object.prototype.hasOwnProperty.call(this.obj, k);
if (has) {
delete this.obj[k];
}
return has;
}
clear() {
for (const key of Object.keys(this.obj)) {
delete this.obj[key];
}
}
get(key) {
let val = this.obj[mapKeyToLocal(key)];
if (val !== void 0) {
val = mapValueToReflect(this._field, val, this.check);
}
return val;
}
has(key) {
return Object.prototype.hasOwnProperty.call(this.obj, mapKeyToLocal(key));
}
*keys() {
for (const objKey of Object.keys(this.obj)) {
yield mapKeyToReflect(objKey, this._field.mapKey);
}
}
*entries() {
for (const objEntry of Object.entries(this.obj)) {
yield [
mapKeyToReflect(objEntry[0], this._field.mapKey),
mapValueToReflect(this._field, objEntry[1], this.check)
];
}
}
[Symbol.iterator]() {
return this.entries();
}
get size() {
return Object.keys(this.obj).length;
}
*values() {
for (const val of Object.values(this.obj)) {
yield mapValueToReflect(this._field, val, this.check);
}
}
forEach(callbackfn, thisArg) {
for (const mapEntry of this.entries()) {
callbackfn.call(thisArg, mapEntry[1], mapEntry[0], this);
}
}
};
function messageToLocal(field, value) {
if (!isReflectMessage(value)) {
return value;
}
if (isWrapper(value.message) && !field.oneof && field.fieldKind == "message") {
return value.message.value;
}
if (value.desc.typeName == "google.protobuf.Struct" && field.parent.typeName != "google.protobuf.Value") {
return wktStructToLocal(value.message);
}
return value.message;
}
function messageToReflect(field, value, check) {
if (value !== void 0) {
if (isWrapperDesc(field.message) && !field.oneof && field.fieldKind == "message") {
value = {
$typeName: field.message.typeName,
value: longToReflect(field.message.fields[0], value)
};
} else if (field.message.typeName == "google.protobuf.Struct" && field.parent.typeName != "google.protobuf.Value" && isObject(value)) {
value = wktStructToReflect(value);
}
}
return new ReflectMessageImpl(field.message, value, check);
}
function listItemToLocal(field, value) {
if (field.listKind == "message") {
return messageToLocal(field, value);
}
return longToLocal(field, value);
}
function listItemToReflect(field, value, check) {
if (field.listKind == "message") {
return messageToReflect(field, value, check);
}
return longToReflect(field, value);
}
function mapValueToLocal(field, value) {
if (field.mapKind == "message") {
return messageToLocal(field, value);
}
return longToLocal(field, value);
}
function mapValueToReflect(field, value, check) {
if (field.mapKind == "message") {
return messageToReflect(field, value, check);
}
return value;
}
function mapKeyToLocal(key) {
return typeof key == "string" || typeof key == "number" ? key : String(key);
}
function mapKeyToReflect(key, type) {
switch (type) {
case ScalarType.STRING:
return key;
case ScalarType.INT32:
case ScalarType.FIXED32:
case ScalarType.UINT32:
case ScalarType.SFIXED32:
case ScalarType.SINT32: {
const n = Number.parseInt(key);
if (Number.isFinite(n)) {
return n;
}
break;
}
case ScalarType.BOOL:
switch (key) {
case "true":
return true;
case "false":
return false;
}
break;
case ScalarType.UINT64:
case ScalarType.FIXED64:
try {
return protoInt64.uParse(key);
} catch (_a) {
}
break;
default:
try {
return protoInt64.parse(key);
} catch (_b) {
}
break;
}
return key;
}
function longToReflect(field, value) {
switch (field.scalar) {
case ScalarType.INT64:
case ScalarType.SFIXED64:
case ScalarType.SINT64:
if ("longAsString" in field && field.longAsString && typeof value == "string") {
value = protoInt64.parse(value);
}
break;
case ScalarType.FIXED64:
case ScalarType.UINT64:
if ("longAsString" in field && field.longAsString && typeof value == "string") {
value = protoInt64.uParse(value);
}
break;
}
return value;
}
function longToLocal(field, value) {
switch (field.scalar) {
case ScalarType.INT64:
case ScalarType.SFIXED64:
case ScalarType.SINT64:
if ("longAsString" in field && field.longAsString) {
value = String(value);
} else if (typeof value == "string" || typeof value == "number") {
value = protoInt64.parse(value);
}
break;
case ScalarType.FIXED64:
case ScalarType.UINT64:
if ("longAsString" in field && field.longAsString) {
value = String(value);
} else if (typeof value == "string" || typeof value == "number") {
value = protoInt64.uParse(value);
}
break;
}
return value;
}
function wktStructToReflect(json) {
const struct = {
$typeName: "google.protobuf.Struct",
fields: {}
};
if (isObject(json)) {
for (const [k, v] of Object.entries(json)) {
struct.fields[k] = wktValueToReflect(v);
}
}
return struct;
}
function wktStructToLocal(val) {
const json = {};
for (const [k, v] of Object.entries(val.fields)) {
json[k] = wktValueToLocal(v);
}
return json;
}
function wktValueToLocal(val) {
switch (val.kind.case) {
case "structValue":
return wktStructToLocal(val.kind.value);
case "listValue":
return val.kind.value.values.map(wktValueToLocal);
case "nullValue":
case void 0:
return null;
default:
return val.kind.value;
}
}
function wktValueToReflect(json) {
const value = {
$typeName: "google.protobuf.Value",
kind: { case: void 0 }
};
switch (typeof json) {
case "number":
value.kind = { case: "numberValue", value: json };
break;
case "string":
value.kind = { case: "stringValue", value: json };
break;