2026-07-29 08:29:29 +00:00
|
|
|
// Module ID: 1315
|
|
|
|
|
// Function ID: 1316
|
2026-07-20 16:05:17 +00:00
|
|
|
// Name: binaryWriteOptions
|
2026-07-29 08:29:29 +00:00
|
|
|
// Dependencies: [41, 42, 1316, 1313, 1314]
|
2026-07-20 16:05:17 +00:00
|
|
|
// Exports: binaryWriteOptions
|
|
|
|
|
|
2026-07-29 08:29:29 +00:00
|
|
|
// Module 1315 (binaryWriteOptions)
|
2026-08-24 06:08:38 +00:00
|
|
|
import closure_2 from "_classCallCheck" /* 41 */;
|
|
|
|
|
import _createClass from "_createClass" /* 42 */;
|
2026-07-23 10:11:24 +00:00
|
|
|
|
2026-07-29 08:29:29 +00:00
|
|
|
const BinaryWriter = require;
|
|
|
|
|
let closure_3 = {
|
2026-07-20 16:05:17 +00:00
|
|
|
writeUnknownFields: true,
|
|
|
|
|
writerFactory() {
|
2026-07-29 08:29:29 +00:00
|
|
|
return new closure_4();
|
2026-07-20 16:05:17 +00:00
|
|
|
}
|
|
|
|
|
};
|
2026-07-29 08:29:29 +00:00
|
|
|
class BinaryWriter {
|
|
|
|
|
constructor(arg0) {
|
|
|
|
|
self = this;
|
|
|
|
|
textEncoder = global;
|
2026-08-24 06:08:38 +00:00
|
|
|
tmp2 = closure_2(this, BinaryWriter);
|
2026-07-29 08:29:29 +00:00
|
|
|
this.stack = [];
|
|
|
|
|
if (null == global) {
|
|
|
|
|
tmp3 = globalThis;
|
|
|
|
|
_TextEncoder = TextEncoder;
|
|
|
|
|
tmp4 = new.target;
|
|
|
|
|
tmp5 = new.target;
|
|
|
|
|
textEncoder = new TextEncoder();
|
2026-07-20 16:05:17 +00:00
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
self.textEncoder = textEncoder;
|
|
|
|
|
self.chunks = [];
|
|
|
|
|
self.buf = [];
|
|
|
|
|
return;
|
2026-07-20 16:05:17 +00:00
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
}
|
|
|
|
|
const items = [
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "finish",
|
|
|
|
|
value: function finish() {
|
|
|
|
|
let length;
|
|
|
|
|
let length2;
|
|
|
|
|
const self = this;
|
|
|
|
|
const chunks = this.chunks;
|
|
|
|
|
const uint8Array = new Uint8Array(this.buf);
|
|
|
|
|
chunks.push(uint8Array);
|
|
|
|
|
let num = 0;
|
|
|
|
|
let num2 = 0;
|
|
|
|
|
let num3 = 0;
|
|
|
|
|
if (0 < this.chunks.length) {
|
|
|
|
|
do {
|
2026-07-29 08:29:29 +00:00
|
|
|
num2 = num2 + self.chunks[num].length;
|
|
|
|
|
num = num + 1;
|
|
|
|
|
num3 = num2;
|
2026-07-20 16:05:17 +00:00
|
|
|
length = self.chunks.length;
|
2026-07-29 08:29:29 +00:00
|
|
|
} while (num < length);
|
2026-07-20 16:05:17 +00:00
|
|
|
}
|
|
|
|
|
const uint8Array1 = new Uint8Array(num3);
|
|
|
|
|
let num4 = 0;
|
|
|
|
|
let num5 = 0;
|
|
|
|
|
if (0 < self.chunks.length) {
|
|
|
|
|
do {
|
2026-07-29 08:29:29 +00:00
|
|
|
let result = uint8Array1.set(self.chunks[num4], num5);
|
|
|
|
|
num5 = num5 + self.chunks[num4].length;
|
|
|
|
|
num4 = num4 + 1;
|
2026-07-20 16:05:17 +00:00
|
|
|
length2 = self.chunks.length;
|
2026-07-29 08:29:29 +00:00
|
|
|
} while (num4 < length2);
|
2026-07-20 16:05:17 +00:00
|
|
|
}
|
|
|
|
|
self.chunks = [];
|
|
|
|
|
return uint8Array1;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "fork",
|
|
|
|
|
value: function fork() {
|
|
|
|
|
const stack = this.stack;
|
|
|
|
|
stack.push({ chunks: this.chunks, buf: this.buf });
|
|
|
|
|
this.chunks = [];
|
|
|
|
|
this.buf = [];
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "join",
|
|
|
|
|
value: function join() {
|
|
|
|
|
const self = this;
|
|
|
|
|
const finishResult = this.finish();
|
|
|
|
|
const stack = this.stack;
|
|
|
|
|
const arr = stack.pop();
|
|
|
|
|
if (arr) {
|
|
|
|
|
({ chunks: self.chunks, buf: self.buf } = arr);
|
|
|
|
|
self.uint32(finishResult.byteLength);
|
|
|
|
|
return self.raw(finishResult);
|
|
|
|
|
} else {
|
|
|
|
|
const _Error = Error;
|
2026-08-24 06:08:38 +00:00
|
|
|
error = new Error("invalid state, fork stack empty");
|
2026-07-20 16:05:17 +00:00
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "tag",
|
|
|
|
|
value: function tag(arg0, arg1) {
|
|
|
|
|
return this.uint32((arg0 << 3 | arg1) >>> 0);
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "raw",
|
|
|
|
|
value: function raw(arg0) {
|
|
|
|
|
const self = this;
|
|
|
|
|
if (this.buf.length) {
|
|
|
|
|
const chunks = self.chunks;
|
|
|
|
|
const _Uint8Array = Uint8Array;
|
|
|
|
|
const uint8Array = new Uint8Array(self.buf);
|
|
|
|
|
chunks.push(uint8Array);
|
|
|
|
|
self.buf = [];
|
|
|
|
|
}
|
|
|
|
|
const chunks1 = self.chunks;
|
|
|
|
|
chunks1.push(arg0);
|
|
|
|
|
return self;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "uint32",
|
2026-07-23 10:11:24 +00:00
|
|
|
value: function uint32(NumberResult) {
|
2026-07-20 16:05:17 +00:00
|
|
|
const self = this;
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1316).assertUInt32(NumberResult);
|
2026-07-23 10:11:24 +00:00
|
|
|
let tmp2 = NumberResult;
|
|
|
|
|
let tmp3 = NumberResult;
|
|
|
|
|
if (NumberResult > 127) {
|
2026-07-20 16:05:17 +00:00
|
|
|
do {
|
|
|
|
|
let buf = self.buf;
|
|
|
|
|
let arr = buf.push(127 & tmp2 | 128);
|
|
|
|
|
tmp2 = tmp2 >>> 7;
|
|
|
|
|
tmp3 = tmp2;
|
2026-07-29 08:29:29 +00:00
|
|
|
} while (127 < tmp2);
|
2026-07-20 16:05:17 +00:00
|
|
|
}
|
|
|
|
|
const buf1 = self.buf;
|
|
|
|
|
buf1.push(tmp3);
|
|
|
|
|
return self;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "int32",
|
|
|
|
|
value: function int32(NumberResult) {
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1316).assertInt32(NumberResult);
|
|
|
|
|
const obj = BinaryWriter(1316);
|
|
|
|
|
BinaryWriter(1313).varint32write(NumberResult, this.buf);
|
2026-07-20 16:05:17 +00:00
|
|
|
return this;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "bool",
|
|
|
|
|
value: function bool(arg0) {
|
|
|
|
|
const buf = this.buf;
|
|
|
|
|
let num = 0;
|
|
|
|
|
if (arg0) {
|
|
|
|
|
num = 1;
|
|
|
|
|
}
|
|
|
|
|
buf.push(num);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "bytes",
|
|
|
|
|
value: function bytes(byteLength) {
|
|
|
|
|
this.uint32(byteLength.byteLength);
|
|
|
|
|
return this.raw(byteLength);
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "string",
|
|
|
|
|
value: function string(arg0) {
|
|
|
|
|
const textEncoder = this.textEncoder;
|
|
|
|
|
const encodeResult = textEncoder.encode(arg0);
|
|
|
|
|
this.uint32(encodeResult.byteLength);
|
|
|
|
|
return this.raw(encodeResult);
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "float",
|
|
|
|
|
value: function float(NumberResult) {
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1316).assertFloat32(NumberResult);
|
2026-07-20 16:05:17 +00:00
|
|
|
const uint8Array = new Uint8Array(4);
|
|
|
|
|
const dataView = new DataView(uint8Array.buffer);
|
|
|
|
|
dataView.setFloat32(0, NumberResult, true);
|
|
|
|
|
return this.raw(uint8Array);
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "double",
|
|
|
|
|
value: function double(arg0) {
|
|
|
|
|
const uint8Array = new Uint8Array(8);
|
|
|
|
|
const dataView = new DataView(uint8Array.buffer);
|
|
|
|
|
dataView.setFloat64(0, arg0, true);
|
|
|
|
|
return this.raw(uint8Array);
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "fixed32",
|
|
|
|
|
value: function fixed32(NumberResult) {
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1316).assertUInt32(NumberResult);
|
2026-07-20 16:05:17 +00:00
|
|
|
const uint8Array = new Uint8Array(4);
|
|
|
|
|
const dataView = new DataView(uint8Array.buffer);
|
|
|
|
|
dataView.setUint32(0, NumberResult, true);
|
|
|
|
|
return this.raw(uint8Array);
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "sfixed32",
|
|
|
|
|
value: function sfixed32(NumberResult) {
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1316).assertInt32(NumberResult);
|
2026-07-20 16:05:17 +00:00
|
|
|
const uint8Array = new Uint8Array(4);
|
|
|
|
|
const dataView = new DataView(uint8Array.buffer);
|
|
|
|
|
dataView.setInt32(0, NumberResult, true);
|
|
|
|
|
return this.raw(uint8Array);
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "sint32",
|
|
|
|
|
value: function sint32(NumberResult) {
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1316).assertInt32(NumberResult);
|
|
|
|
|
const obj = BinaryWriter(1316);
|
2026-07-20 16:05:17 +00:00
|
|
|
const tmp2 = NumberResult << 1;
|
|
|
|
|
const tmp3 = NumberResult >> 31;
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1313).varint32write((tmp2 ^ tmp3) >>> 0, this.buf);
|
2026-07-20 16:05:17 +00:00
|
|
|
return this;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "sfixed64",
|
|
|
|
|
value: function sfixed64(arg0) {
|
|
|
|
|
const uint8Array = new Uint8Array(8);
|
|
|
|
|
const dataView = new DataView(uint8Array.buffer);
|
2026-07-29 08:29:29 +00:00
|
|
|
const PbLong = BinaryWriter(1314).PbLong;
|
2026-07-20 16:05:17 +00:00
|
|
|
const fromResult = PbLong.from(arg0);
|
|
|
|
|
dataView.setInt32(0, fromResult.lo, true);
|
|
|
|
|
dataView.setInt32(4, fromResult.hi, true);
|
|
|
|
|
return this.raw(uint8Array);
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "fixed64",
|
|
|
|
|
value: function fixed64(arg0) {
|
|
|
|
|
const uint8Array = new Uint8Array(8);
|
|
|
|
|
const dataView = new DataView(uint8Array.buffer);
|
2026-07-29 08:29:29 +00:00
|
|
|
const PbULong = BinaryWriter(1314).PbULong;
|
2026-07-20 16:05:17 +00:00
|
|
|
const fromResult = PbULong.from(arg0);
|
|
|
|
|
dataView.setInt32(0, fromResult.lo, true);
|
|
|
|
|
dataView.setInt32(4, fromResult.hi, true);
|
|
|
|
|
return this.raw(uint8Array);
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "int64",
|
|
|
|
|
value: function int64(arg0) {
|
2026-07-29 08:29:29 +00:00
|
|
|
const PbLong = BinaryWriter(1314).PbLong;
|
2026-07-20 16:05:17 +00:00
|
|
|
const fromResult = PbLong.from(arg0);
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1313).varint64write(fromResult.lo, fromResult.hi, this.buf);
|
2026-07-20 16:05:17 +00:00
|
|
|
return this;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "sint64",
|
|
|
|
|
value: function sint64(arg0) {
|
2026-07-29 08:29:29 +00:00
|
|
|
const PbLong = BinaryWriter(1314).PbLong;
|
2026-07-20 16:05:17 +00:00
|
|
|
const fromResult = PbLong.from(arg0);
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1313).varint64write(fromResult.lo << 1 ^ fromResult.hi >> 31, (fromResult.hi << 1 | fromResult.lo >>> 31) ^ fromResult.hi >> 31, this.buf);
|
2026-07-20 16:05:17 +00:00
|
|
|
return this;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
},
|
|
|
|
|
{
|
2026-07-20 16:05:17 +00:00
|
|
|
key: "uint64",
|
|
|
|
|
value: function uint64(arg0) {
|
2026-07-29 08:29:29 +00:00
|
|
|
const PbULong = BinaryWriter(1314).PbULong;
|
2026-07-20 16:05:17 +00:00
|
|
|
const fromResult = PbULong.from(arg0);
|
2026-07-29 08:29:29 +00:00
|
|
|
BinaryWriter(1313).varint64write(fromResult.lo, fromResult.hi, this.buf);
|
2026-07-20 16:05:17 +00:00
|
|
|
return this;
|
|
|
|
|
}
|
2026-07-29 08:29:29 +00:00
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
const _moduleResult = _createClass(BinaryWriter, items);
|
|
|
|
|
let c4 = _moduleResult;
|
2026-07-20 16:05:17 +00:00
|
|
|
|
|
|
|
|
export const binaryWriteOptions = function binaryWriteOptions(arg0) {
|
|
|
|
|
if (arg0) {
|
|
|
|
|
const _Object = Object;
|
|
|
|
|
const _Object2 = Object;
|
2026-07-29 08:29:29 +00:00
|
|
|
let merged = Object.assign(Object.assign({}, closure_3), arg0);
|
2026-07-20 16:05:17 +00:00
|
|
|
} else {
|
2026-07-29 08:29:29 +00:00
|
|
|
merged = closure_3;
|
2026-07-20 16:05:17 +00:00
|
|
|
}
|
|
|
|
|
return merged;
|
|
|
|
|
};
|
2026-07-29 08:29:29 +00:00
|
|
|
export const BinaryWriter = _moduleResult;
|