1 line
10 KiB
JSON
1 line
10 KiB
JSON
{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.writeProtobufMessage = exports.MessageWriter = void 0;\nconst util_js_1 = require(\"./util.js\");\nclass MessageWriter {\n #buf;\n #array;\n #view;\n #pos;\n constructor() {\n this.#buf = new ArrayBuffer(256);\n this.#array = new Uint8Array(this.#buf);\n this.#view = new DataView(this.#buf);\n this.#pos = 0;\n }\n #ensure(extra) {\n if (this.#pos + extra <= this.#buf.byteLength) {\n return;\n }\n let newCap = this.#buf.byteLength;\n while (newCap < this.#pos + extra) {\n newCap *= 2;\n }\n const newBuf = new ArrayBuffer(newCap);\n const newArray = new Uint8Array(newBuf);\n const newView = new DataView(newBuf);\n newArray.set(new Uint8Array(this.#buf, 0, this.#pos));\n this.#buf = newBuf;\n this.#array = newArray;\n this.#view = newView;\n }\n #varint(value) {\n this.#ensure(5);\n value = 0 | value;\n do {\n let byte = value & 0x7f;\n value >>>= 7;\n byte |= value ? 0x80 : 0;\n this.#array[this.#pos++] = byte;\n } while (value);\n }\n #varintBig(value) {\n this.#ensure(10);\n value = value & 0xffffffffffffffffn;\n do {\n let byte = Number(value & 0x7fn);\n value >>= 7n;\n byte |= value ? 0x80 : 0;\n this.#array[this.#pos++] = byte;\n } while (value);\n }\n #tag(tag, wireType) {\n this.#varint(tag << 3 | wireType);\n }\n bytes(tag, value) {\n this.#tag(tag, util_js_1.LENGTH_DELIMITED);\n this.#varint(value.byteLength);\n this.#ensure(value.byteLength);\n this.#array.set(value, this.#pos);\n this.#pos += value.byteLength;\n }\n string(tag, value) {\n this.bytes(tag, new TextEncoder().encode(value));\n }\n message(tag, value, fun) {\n const writer = new MessageWriter();\n fun(writer, value);\n this.bytes(tag, writer.data());\n }\n int32(tag, value) {\n this.#tag(tag, util_js_1.VARINT);\n this.#varint(value);\n }\n uint32(tag, value) {\n this.int32(tag, value);\n }\n bool(tag, value) {\n this.int32(tag, value ? 1 : 0);\n }\n sint64(tag, value) {\n this.#tag(tag, util_js_1.VARINT);\n this.#varintBig(value << 1n ^ value >> 63n);\n }\n double(tag, value) {\n this.#tag(tag, util_js_1.FIXED_64);\n this.#ensure(8);\n this.#view.setFloat64(this.#pos, value, true);\n this.#pos += 8;\n }\n data() {\n return new Uint8Array(this.#buf, 0, this.#pos);\n }\n}\nexports.MessageWriter = MessageWriter;\nfunction writeProtobufMessage(value, fun) {\n const w = new MessageWriter();\n fun(w, value);\n return w.data();\n}\nexports.writeProtobufMessage = writeProtobufMessage;","map":{"version":3,"names":["Object","defineProperty","exports","value","writeProtobufMessage","MessageWriter","util_js_1","require","buf","array","view","pos","constructor","ArrayBuffer","Uint8Array","DataView","ensure","#ensure","extra","byteLength","newCap","newBuf","newArray","newView","set","varint","#varint","byte","varintBig","#varintBig","Number","tag","#tag","wireType","bytes","LENGTH_DELIMITED","string","TextEncoder","encode","message","fun","writer","data","int32","VARINT","uint32","bool","sint64","double","FIXED_64","setFloat64","w"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-cjs/encoding/protobuf/encode.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.writeProtobufMessage = exports.MessageWriter = void 0;\nconst util_js_1 = require(\"./util.js\");\nclass MessageWriter {\n #buf;\n #array;\n #view;\n #pos;\n constructor() {\n this.#buf = new ArrayBuffer(256);\n this.#array = new Uint8Array(this.#buf);\n this.#view = new DataView(this.#buf);\n this.#pos = 0;\n }\n #ensure(extra) {\n if (this.#pos + extra <= this.#buf.byteLength) {\n return;\n }\n let newCap = this.#buf.byteLength;\n while (newCap < this.#pos + extra) {\n newCap *= 2;\n }\n const newBuf = new ArrayBuffer(newCap);\n const newArray = new Uint8Array(newBuf);\n const newView = new DataView(newBuf);\n newArray.set(new Uint8Array(this.#buf, 0, this.#pos));\n this.#buf = newBuf;\n this.#array = newArray;\n this.#view = newView;\n }\n #varint(value) {\n this.#ensure(5);\n value = 0 | value;\n do {\n let byte = value & 0x7f;\n value >>>= 7;\n byte |= (value ? 0x80 : 0);\n this.#array[this.#pos++] = byte;\n } while (value);\n }\n #varintBig(value) {\n this.#ensure(10);\n value = value & 0xffffffffffffffffn;\n do {\n let byte = Number(value & 0x7fn);\n value >>= 7n;\n byte |= (value ? 0x80 : 0);\n this.#array[this.#pos++] = byte;\n } while (value);\n }\n #tag(tag, wireType) {\n this.#varint((tag << 3) | wireType);\n }\n bytes(tag, value) {\n this.#tag(tag, util_js_1.LENGTH_DELIMITED);\n this.#varint(value.byteLength);\n this.#ensure(value.byteLength);\n this.#array.set(value, this.#pos);\n this.#pos += value.byteLength;\n }\n string(tag, value) {\n this.bytes(tag, new TextEncoder().encode(value));\n }\n message(tag, value, fun) {\n const writer = new MessageWriter();\n fun(writer, value);\n this.bytes(tag, writer.data());\n }\n int32(tag, value) {\n this.#tag(tag, util_js_1.VARINT);\n this.#varint(value);\n }\n uint32(tag, value) {\n this.int32(tag, value);\n }\n bool(tag, value) {\n this.int32(tag, value ? 1 : 0);\n }\n sint64(tag, value) {\n this.#tag(tag, util_js_1.VARINT);\n this.#varintBig((value << 1n) ^ (value >> 63n));\n }\n double(tag, value) {\n this.#tag(tag, util_js_1.FIXED_64);\n this.#ensure(8);\n this.#view.setFloat64(this.#pos, value, true);\n this.#pos += 8;\n }\n data() {\n return new Uint8Array(this.#buf, 0, this.#pos);\n }\n}\nexports.MessageWriter = MessageWriter;\nfunction writeProtobufMessage(value, fun) {\n const w = new MessageWriter();\n fun(w, value);\n return w.data();\n}\nexports.writeProtobufMessage = writeProtobufMessage;\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,oBAAoB,GAAGF,OAAO,CAACG,aAAa,GAAG,KAAK,CAAC;AAC7D,MAAMC,SAAS,GAAGC,OAAO,CAAC,WAAW,CAAC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