decord/source/1292_binaryWriteOptions.js
2026-07-20 16:05:17 +00:00

297 lines
8.2 KiB
JavaScript

// Module ID: 1292
// Function ID: 15110
// Name: binaryWriteOptions
// Dependencies: []
// Exports: binaryWriteOptions
// Module 1292 (binaryWriteOptions)
let closure_2 = require(dependencyMap[0]);
let closure_3 = require(dependencyMap[1]);
let closure_4 = {
writeUnknownFields: true,
writerFactory() {
return new tmp2();
}
};
const tmp2 = () => {
class BinaryWriter {
constructor(arg0) {
textEncoder = arg0;
self = this;
tmp2 = closure_2(this, BinaryWriter);
this.stack = [];
if (null == arg0) {
tmp3 = globalThis;
_TextEncoder = TextEncoder;
prototype = TextEncoder.prototype;
tmp4 = new.target;
tmp5 = new.target;
textEncoder = new TextEncoder();
}
self.textEncoder = textEncoder;
self.chunks = [];
self.buf = [];
return;
}
}
const require = BinaryWriter;
let obj = {
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 {
num = num + self.chunks[num2].length;
num2 = num2 + 1;
num3 = num;
length = self.chunks.length;
} while (num2 < length);
}
const uint8Array1 = new Uint8Array(num3);
let num4 = 0;
let num5 = 0;
if (0 < self.chunks.length) {
do {
let result = uint8Array1.set(self.chunks[num5], num4);
num4 = num4 + self.chunks[num5].length;
num5 = num5 + 1;
length2 = self.chunks.length;
} while (num5 < length2);
}
self.chunks = [];
return uint8Array1;
}
};
const items = [obj, , , , , , , , , , , , , , , , , , , ];
obj = {
key: "fork",
value: function fork() {
const stack = this.stack;
stack.push({ chunks: this.chunks, buf: this.buf });
this.chunks = [];
this.buf = [];
return this;
}
};
items[1] = obj;
obj = {
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;
const error = new Error("invalid state, fork stack empty");
throw error;
}
}
};
items[2] = obj;
items[3] = {
key: "tag",
value: function tag(arg0, arg1) {
return this.uint32((arg0 << 3 | arg1) >>> 0);
}
};
items[4] = {
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;
}
};
items[5] = {
key: "uint32",
value: function uint32(byteLength) {
const self = this;
BinaryWriter(closure_1[2]).assertUInt32(byteLength);
let tmp2 = byteLength;
let tmp3 = byteLength;
if (byteLength > 127) {
do {
let buf = self.buf;
let arr = buf.push(127 & tmp2 | 128);
tmp2 = tmp2 >>> 7;
tmp3 = tmp2;
} while (tmp2 > 127);
}
const buf1 = self.buf;
buf1.push(tmp3);
return self;
}
};
items[6] = {
key: "int32",
value: function int32(NumberResult) {
BinaryWriter(closure_1[2]).assertInt32(NumberResult);
const obj = BinaryWriter(closure_1[2]);
BinaryWriter(closure_1[3]).varint32write(NumberResult, this.buf);
return this;
}
};
items[7] = {
key: "bool",
value: function bool(arg0) {
const buf = this.buf;
let num = 0;
if (arg0) {
num = 1;
}
buf.push(num);
return this;
}
};
items[8] = {
key: "bytes",
value: function bytes(byteLength) {
this.uint32(byteLength.byteLength);
return this.raw(byteLength);
}
};
items[9] = {
key: "string",
value: function string(arg0) {
const textEncoder = this.textEncoder;
const encodeResult = textEncoder.encode(arg0);
this.uint32(encodeResult.byteLength);
return this.raw(encodeResult);
}
};
items[10] = {
key: "float",
value: function float(NumberResult) {
BinaryWriter(closure_1[2]).assertFloat32(NumberResult);
const uint8Array = new Uint8Array(4);
const dataView = new DataView(uint8Array.buffer);
dataView.setFloat32(0, NumberResult, true);
return this.raw(uint8Array);
}
};
items[11] = {
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);
}
};
items[12] = {
key: "fixed32",
value: function fixed32(NumberResult) {
BinaryWriter(closure_1[2]).assertUInt32(NumberResult);
const uint8Array = new Uint8Array(4);
const dataView = new DataView(uint8Array.buffer);
dataView.setUint32(0, NumberResult, true);
return this.raw(uint8Array);
}
};
items[13] = {
key: "sfixed32",
value: function sfixed32(NumberResult) {
BinaryWriter(closure_1[2]).assertInt32(NumberResult);
const uint8Array = new Uint8Array(4);
const dataView = new DataView(uint8Array.buffer);
dataView.setInt32(0, NumberResult, true);
return this.raw(uint8Array);
}
};
items[14] = {
key: "sint32",
value: function sint32(NumberResult) {
BinaryWriter(closure_1[2]).assertInt32(NumberResult);
const obj = BinaryWriter(closure_1[2]);
const tmp2 = NumberResult << 1;
const tmp3 = NumberResult >> 31;
BinaryWriter(closure_1[3]).varint32write((tmp2 ^ tmp3) >>> 0, this.buf);
return this;
}
};
items[15] = {
key: "sfixed64",
value: function sfixed64(arg0) {
const uint8Array = new Uint8Array(8);
const dataView = new DataView(uint8Array.buffer);
const PbLong = BinaryWriter(closure_1[4]).PbLong;
const fromResult = PbLong.from(arg0);
dataView.setInt32(0, fromResult.lo, true);
dataView.setInt32(4, fromResult.hi, true);
return this.raw(uint8Array);
}
};
items[16] = {
key: "fixed64",
value: function fixed64(arg0) {
const uint8Array = new Uint8Array(8);
const dataView = new DataView(uint8Array.buffer);
const PbULong = BinaryWriter(closure_1[4]).PbULong;
const fromResult = PbULong.from(arg0);
dataView.setInt32(0, fromResult.lo, true);
dataView.setInt32(4, fromResult.hi, true);
return this.raw(uint8Array);
}
};
items[17] = {
key: "int64",
value: function int64(arg0) {
const PbLong = BinaryWriter(closure_1[4]).PbLong;
const fromResult = PbLong.from(arg0);
BinaryWriter(closure_1[3]).varint64write(fromResult.lo, fromResult.hi, this.buf);
return this;
}
};
items[18] = {
key: "sint64",
value: function sint64(arg0) {
const PbLong = BinaryWriter(closure_1[4]).PbLong;
const fromResult = PbLong.from(arg0);
BinaryWriter(closure_1[3]).varint64write(fromResult.lo << 1 ^ fromResult.hi >> 31, (fromResult.hi << 1 | fromResult.lo >>> 31) ^ fromResult.hi >> 31, this.buf);
return this;
}
};
items[19] = {
key: "uint64",
value: function uint64(arg0) {
const PbULong = BinaryWriter(closure_1[4]).PbULong;
const fromResult = PbULong.from(arg0);
BinaryWriter(closure_1[3]).varint64write(fromResult.lo, fromResult.hi, this.buf);
return this;
}
};
return callback(BinaryWriter, items);
}();
export const binaryWriteOptions = function binaryWriteOptions(arg0) {
if (arg0) {
const _Object = Object;
const _Object2 = Object;
let merged = Object.assign(Object.assign({}, closure_4), arg0);
} else {
merged = closure_4;
}
return merged;
};
export const BinaryWriter = tmp2;