Flatbuffers Merge commit '8cd6f0538a362ceefbcfcbf6c7b8b3f341d1fb41' into master
Upgrade flatbuffers to the latest.
Change-Id: I901787ac6fc5d7ce2c4019cc0d275de68086b4d8
diff --git a/third_party/flatbuffers/js/flexbuffers/bit-width-util.js b/third_party/flatbuffers/js/flexbuffers/bit-width-util.js
new file mode 100644
index 0000000..16f9d26
--- /dev/null
+++ b/third_party/flatbuffers/js/flexbuffers/bit-width-util.js
@@ -0,0 +1,46 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.paddingSize = exports.fromByteWidth = exports.uwidth = exports.fwidth = exports.iwidth = exports.toByteWidth = void 0;
+var bit_width_1 = require("./bit-width");
+function toByteWidth(bitWidth) {
+ return 1 << bitWidth;
+}
+exports.toByteWidth = toByteWidth;
+function iwidth(value) {
+ if (value >= -128 && value <= 127)
+ return bit_width_1.BitWidth.WIDTH8;
+ if (value >= -32768 && value <= 32767)
+ return bit_width_1.BitWidth.WIDTH16;
+ if (value >= -2147483648 && value <= 2147483647)
+ return bit_width_1.BitWidth.WIDTH32;
+ return bit_width_1.BitWidth.WIDTH64;
+}
+exports.iwidth = iwidth;
+function fwidth(value) {
+ return value === Math.fround(value) ? bit_width_1.BitWidth.WIDTH32 : bit_width_1.BitWidth.WIDTH64;
+}
+exports.fwidth = fwidth;
+function uwidth(value) {
+ if (value <= 255)
+ return bit_width_1.BitWidth.WIDTH8;
+ if (value <= 65535)
+ return bit_width_1.BitWidth.WIDTH16;
+ if (value <= 4294967295)
+ return bit_width_1.BitWidth.WIDTH32;
+ return bit_width_1.BitWidth.WIDTH64;
+}
+exports.uwidth = uwidth;
+function fromByteWidth(value) {
+ if (value === 1)
+ return bit_width_1.BitWidth.WIDTH8;
+ if (value === 2)
+ return bit_width_1.BitWidth.WIDTH16;
+ if (value === 4)
+ return bit_width_1.BitWidth.WIDTH32;
+ return bit_width_1.BitWidth.WIDTH64;
+}
+exports.fromByteWidth = fromByteWidth;
+function paddingSize(bufSize, scalarSize) {
+ return (~bufSize + 1) & (scalarSize - 1);
+}
+exports.paddingSize = paddingSize;
diff --git a/third_party/flatbuffers/js/flexbuffers/bit-width.js b/third_party/flatbuffers/js/flexbuffers/bit-width.js
new file mode 100644
index 0000000..d0c5c05
--- /dev/null
+++ b/third_party/flatbuffers/js/flexbuffers/bit-width.js
@@ -0,0 +1,10 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.BitWidth = void 0;
+var BitWidth;
+(function (BitWidth) {
+ BitWidth[BitWidth["WIDTH8"] = 0] = "WIDTH8";
+ BitWidth[BitWidth["WIDTH16"] = 1] = "WIDTH16";
+ BitWidth[BitWidth["WIDTH32"] = 2] = "WIDTH32";
+ BitWidth[BitWidth["WIDTH64"] = 3] = "WIDTH64";
+})(BitWidth = exports.BitWidth || (exports.BitWidth = {}));
diff --git a/third_party/flatbuffers/js/flexbuffers/builder.js b/third_party/flatbuffers/js/flexbuffers/builder.js
new file mode 100644
index 0000000..3243417
--- /dev/null
+++ b/third_party/flatbuffers/js/flexbuffers/builder.js
@@ -0,0 +1,541 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Builder = void 0;
+var bit_width_1 = require("./bit-width");
+var bit_width_util_1 = require("./bit-width-util");
+var flexbuffers_util_1 = require("./flexbuffers-util");
+var value_type_1 = require("./value-type");
+var value_type_util_1 = require("./value-type-util");
+var stack_value_1 = require("./stack-value");
+var Builder = /** @class */ (function () {
+ function Builder(size, dedupStrings, dedupKeys, dedupKeyVectors) {
+ if (size === void 0) { size = 2048; }
+ if (dedupStrings === void 0) { dedupStrings = true; }
+ if (dedupKeys === void 0) { dedupKeys = true; }
+ if (dedupKeyVectors === void 0) { dedupKeyVectors = true; }
+ this.dedupStrings = dedupStrings;
+ this.dedupKeys = dedupKeys;
+ this.dedupKeyVectors = dedupKeyVectors;
+ this.stack = [];
+ this.stackPointers = [];
+ this.offset = 0;
+ this.finished = false;
+ this.stringLookup = {};
+ this.keyLookup = {};
+ this.keyVectorLookup = {};
+ this.indirectIntLookup = {};
+ this.indirectUIntLookup = {};
+ this.indirectFloatLookup = {};
+ this.buffer = new ArrayBuffer(size > 0 ? size : 2048);
+ this.view = new DataView(this.buffer);
+ }
+ Builder.prototype.align = function (width) {
+ var byteWidth = bit_width_util_1.toByteWidth(width);
+ this.offset += bit_width_util_1.paddingSize(this.offset, byteWidth);
+ return byteWidth;
+ };
+ Builder.prototype.computeOffset = function (newValueSize) {
+ var targetOffset = this.offset + newValueSize;
+ var size = this.buffer.byteLength;
+ var prevSize = size;
+ while (size < targetOffset) {
+ size <<= 1;
+ }
+ if (prevSize < size) {
+ var prevBuffer = this.buffer;
+ this.buffer = new ArrayBuffer(size);
+ this.view = new DataView(this.buffer);
+ new Uint8Array(this.buffer).set(new Uint8Array(prevBuffer), 0);
+ }
+ return targetOffset;
+ };
+ Builder.prototype.pushInt = function (value, width) {
+ if (width === bit_width_1.BitWidth.WIDTH8) {
+ this.view.setInt8(this.offset, value);
+ }
+ else if (width === bit_width_1.BitWidth.WIDTH16) {
+ this.view.setInt16(this.offset, value, true);
+ }
+ else if (width === bit_width_1.BitWidth.WIDTH32) {
+ this.view.setInt32(this.offset, value, true);
+ }
+ else if (width === bit_width_1.BitWidth.WIDTH64) {
+ this.view.setBigInt64(this.offset, BigInt(value), true);
+ }
+ else {
+ throw "Unexpected width: " + width + " for value: " + value;
+ }
+ };
+ Builder.prototype.pushUInt = function (value, width) {
+ if (width === bit_width_1.BitWidth.WIDTH8) {
+ this.view.setUint8(this.offset, value);
+ }
+ else if (width === bit_width_1.BitWidth.WIDTH16) {
+ this.view.setUint16(this.offset, value, true);
+ }
+ else if (width === bit_width_1.BitWidth.WIDTH32) {
+ this.view.setUint32(this.offset, value, true);
+ }
+ else if (width === bit_width_1.BitWidth.WIDTH64) {
+ this.view.setBigUint64(this.offset, BigInt(value), true);
+ }
+ else {
+ throw "Unexpected width: " + width + " for value: " + value;
+ }
+ };
+ Builder.prototype.writeInt = function (value, byteWidth) {
+ var newOffset = this.computeOffset(byteWidth);
+ this.pushInt(value, bit_width_util_1.fromByteWidth(byteWidth));
+ this.offset = newOffset;
+ };
+ Builder.prototype.writeUInt = function (value, byteWidth) {
+ var newOffset = this.computeOffset(byteWidth);
+ this.pushUInt(value, bit_width_util_1.fromByteWidth(byteWidth));
+ this.offset = newOffset;
+ };
+ Builder.prototype.writeBlob = function (arrayBuffer) {
+ var length = arrayBuffer.byteLength;
+ var bitWidth = bit_width_util_1.uwidth(length);
+ var byteWidth = this.align(bitWidth);
+ this.writeUInt(length, byteWidth);
+ var blobOffset = this.offset;
+ var newOffset = this.computeOffset(length);
+ new Uint8Array(this.buffer).set(new Uint8Array(arrayBuffer), blobOffset);
+ this.stack.push(this.offsetStackValue(blobOffset, value_type_1.ValueType.BLOB, bitWidth));
+ this.offset = newOffset;
+ };
+ Builder.prototype.writeString = function (str) {
+ if (this.dedupStrings && Object.prototype.hasOwnProperty.call(this.stringLookup, str)) {
+ this.stack.push(this.stringLookup[str]);
+ return;
+ }
+ var utf8 = flexbuffers_util_1.toUTF8Array(str);
+ var length = utf8.length;
+ var bitWidth = bit_width_util_1.uwidth(length);
+ var byteWidth = this.align(bitWidth);
+ this.writeUInt(length, byteWidth);
+ var stringOffset = this.offset;
+ var newOffset = this.computeOffset(length + 1);
+ new Uint8Array(this.buffer).set(utf8, stringOffset);
+ var stackValue = this.offsetStackValue(stringOffset, value_type_1.ValueType.STRING, bitWidth);
+ this.stack.push(stackValue);
+ if (this.dedupStrings) {
+ this.stringLookup[str] = stackValue;
+ }
+ this.offset = newOffset;
+ };
+ Builder.prototype.writeKey = function (str) {
+ if (this.dedupKeys && Object.prototype.hasOwnProperty.call(this.keyLookup, str)) {
+ this.stack.push(this.keyLookup[str]);
+ return;
+ }
+ var utf8 = flexbuffers_util_1.toUTF8Array(str);
+ var length = utf8.length;
+ var newOffset = this.computeOffset(length + 1);
+ new Uint8Array(this.buffer).set(utf8, this.offset);
+ var stackValue = this.offsetStackValue(this.offset, value_type_1.ValueType.KEY, bit_width_1.BitWidth.WIDTH8);
+ this.stack.push(stackValue);
+ if (this.dedupKeys) {
+ this.keyLookup[str] = stackValue;
+ }
+ this.offset = newOffset;
+ };
+ Builder.prototype.writeStackValue = function (value, byteWidth) {
+ var newOffset = this.computeOffset(byteWidth);
+ if (value.isOffset()) {
+ var relativeOffset = this.offset - value.offset;
+ if (byteWidth === 8 || BigInt(relativeOffset) < (BigInt(1) << BigInt(byteWidth * 8))) {
+ this.writeUInt(relativeOffset, byteWidth);
+ }
+ else {
+ throw "Unexpected size " + byteWidth + ". This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new";
+ }
+ }
+ else {
+ value.writeToBuffer(byteWidth);
+ }
+ this.offset = newOffset;
+ };
+ Builder.prototype.integrityCheckOnValueAddition = function () {
+ if (this.finished) {
+ throw "Adding values after finish is prohibited";
+ }
+ if (this.stackPointers.length !== 0 && this.stackPointers[this.stackPointers.length - 1].isVector === false) {
+ if (this.stack[this.stack.length - 1].type !== value_type_1.ValueType.KEY) {
+ throw "Adding value to a map before adding a key is prohibited";
+ }
+ }
+ };
+ Builder.prototype.integrityCheckOnKeyAddition = function () {
+ if (this.finished) {
+ throw "Adding values after finish is prohibited";
+ }
+ if (this.stackPointers.length === 0 || this.stackPointers[this.stackPointers.length - 1].isVector) {
+ throw "Adding key before starting a map is prohibited";
+ }
+ };
+ Builder.prototype.startVector = function () {
+ this.stackPointers.push({ stackPosition: this.stack.length, isVector: true });
+ };
+ Builder.prototype.startMap = function (presorted) {
+ if (presorted === void 0) { presorted = false; }
+ this.stackPointers.push({ stackPosition: this.stack.length, isVector: false, presorted: presorted });
+ };
+ Builder.prototype.endVector = function (stackPointer) {
+ var vecLength = this.stack.length - stackPointer.stackPosition;
+ var vec = this.createVector(stackPointer.stackPosition, vecLength, 1);
+ this.stack.splice(stackPointer.stackPosition, vecLength);
+ this.stack.push(vec);
+ };
+ Builder.prototype.endMap = function (stackPointer) {
+ if (!stackPointer.presorted) {
+ this.sort(stackPointer);
+ }
+ var keyVectorHash = "";
+ for (var i = stackPointer.stackPosition; i < this.stack.length; i += 2) {
+ keyVectorHash += "," + this.stack[i].offset;
+ }
+ var vecLength = (this.stack.length - stackPointer.stackPosition) >> 1;
+ if (this.dedupKeyVectors && !Object.prototype.hasOwnProperty.call(this.keyVectorLookup, keyVectorHash)) {
+ this.keyVectorLookup[keyVectorHash] = this.createVector(stackPointer.stackPosition, vecLength, 2);
+ }
+ var keysStackValue = this.dedupKeyVectors ? this.keyVectorLookup[keyVectorHash] : this.createVector(stackPointer.stackPosition, vecLength, 2);
+ var valuesStackValue = this.createVector(stackPointer.stackPosition + 1, vecLength, 2, keysStackValue);
+ this.stack.splice(stackPointer.stackPosition, vecLength << 1);
+ this.stack.push(valuesStackValue);
+ };
+ Builder.prototype.sort = function (stackPointer) {
+ var view = this.view;
+ var stack = this.stack;
+ function shouldFlip(v1, v2) {
+ if (v1.type !== value_type_1.ValueType.KEY || v2.type !== value_type_1.ValueType.KEY) {
+ throw "Stack values are not keys " + v1 + " | " + v2 + ". Check if you combined [addKey] with add... method calls properly.";
+ }
+ var c1, c2;
+ var index = 0;
+ do {
+ c1 = view.getUint8(v1.offset + index);
+ c2 = view.getUint8(v2.offset + index);
+ if (c2 < c1)
+ return true;
+ if (c1 < c2)
+ return false;
+ index += 1;
+ } while (c1 !== 0 && c2 !== 0);
+ return false;
+ }
+ function swap(stack, flipIndex, i) {
+ if (flipIndex === i)
+ return;
+ var k = stack[flipIndex];
+ var v = stack[flipIndex + 1];
+ stack[flipIndex] = stack[i];
+ stack[flipIndex + 1] = stack[i + 1];
+ stack[i] = k;
+ stack[i + 1] = v;
+ }
+ function selectionSort() {
+ for (var i = stackPointer.stackPosition; i < stack.length; i += 2) {
+ var flipIndex = i;
+ for (var j = i + 2; j < stack.length; j += 2) {
+ if (shouldFlip(stack[flipIndex], stack[j])) {
+ flipIndex = j;
+ }
+ }
+ if (flipIndex !== i) {
+ swap(stack, flipIndex, i);
+ }
+ }
+ }
+ function smaller(v1, v2) {
+ if (v1.type !== value_type_1.ValueType.KEY || v2.type !== value_type_1.ValueType.KEY) {
+ throw "Stack values are not keys " + v1 + " | " + v2 + ". Check if you combined [addKey] with add... method calls properly.";
+ }
+ if (v1.offset === v2.offset) {
+ return false;
+ }
+ var c1, c2;
+ var index = 0;
+ do {
+ c1 = view.getUint8(v1.offset + index);
+ c2 = view.getUint8(v2.offset + index);
+ if (c1 < c2)
+ return true;
+ if (c2 < c1)
+ return false;
+ index += 1;
+ } while (c1 !== 0 && c2 !== 0);
+ return false;
+ }
+ function quickSort(left, right) {
+ if (left < right) {
+ var mid = left + (((right - left) >> 2)) * 2;
+ var pivot = stack[mid];
+ var left_new = left;
+ var right_new = right;
+ do {
+ while (smaller(stack[left_new], pivot)) {
+ left_new += 2;
+ }
+ while (smaller(pivot, stack[right_new])) {
+ right_new -= 2;
+ }
+ if (left_new <= right_new) {
+ swap(stack, left_new, right_new);
+ left_new += 2;
+ right_new -= 2;
+ }
+ } while (left_new <= right_new);
+ quickSort(left, right_new);
+ quickSort(left_new, right);
+ }
+ }
+ var sorted = true;
+ for (var i = stackPointer.stackPosition; i < this.stack.length - 2; i += 2) {
+ if (shouldFlip(this.stack[i], this.stack[i + 2])) {
+ sorted = false;
+ break;
+ }
+ }
+ if (!sorted) {
+ if (this.stack.length - stackPointer.stackPosition > 40) {
+ quickSort(stackPointer.stackPosition, this.stack.length - 2);
+ }
+ else {
+ selectionSort();
+ }
+ }
+ };
+ Builder.prototype.end = function () {
+ if (this.stackPointers.length < 1)
+ return;
+ var pointer = this.stackPointers.pop();
+ if (pointer.isVector) {
+ this.endVector(pointer);
+ }
+ else {
+ this.endMap(pointer);
+ }
+ };
+ Builder.prototype.createVector = function (start, vecLength, step, keys) {
+ if (keys === void 0) { keys = null; }
+ var bitWidth = bit_width_util_1.uwidth(vecLength);
+ var prefixElements = 1;
+ if (keys !== null) {
+ var elementWidth = keys.elementWidth(this.offset, 0);
+ if (elementWidth > bitWidth) {
+ bitWidth = elementWidth;
+ }
+ prefixElements += 2;
+ }
+ var vectorType = value_type_1.ValueType.KEY;
+ var typed = keys === null;
+ for (var i = start; i < this.stack.length; i += step) {
+ var elementWidth = this.stack[i].elementWidth(this.offset, i + prefixElements);
+ if (elementWidth > bitWidth) {
+ bitWidth = elementWidth;
+ }
+ if (i === start) {
+ vectorType = this.stack[i].type;
+ typed = typed && value_type_util_1.isTypedVectorElement(vectorType);
+ }
+ else {
+ if (vectorType !== this.stack[i].type) {
+ typed = false;
+ }
+ }
+ }
+ var byteWidth = this.align(bitWidth);
+ var fix = typed && value_type_util_1.isNumber(vectorType) && vecLength >= 2 && vecLength <= 4;
+ if (keys !== null) {
+ this.writeStackValue(keys, byteWidth);
+ this.writeUInt(1 << keys.width, byteWidth);
+ }
+ if (!fix) {
+ this.writeUInt(vecLength, byteWidth);
+ }
+ var vecOffset = this.offset;
+ for (var i = start; i < this.stack.length; i += step) {
+ this.writeStackValue(this.stack[i], byteWidth);
+ }
+ if (!typed) {
+ for (var i = start; i < this.stack.length; i += step) {
+ this.writeUInt(this.stack[i].storedPackedType(), 1);
+ }
+ }
+ if (keys !== null) {
+ return this.offsetStackValue(vecOffset, value_type_1.ValueType.MAP, bitWidth);
+ }
+ if (typed) {
+ var vType = value_type_util_1.toTypedVector(vectorType, fix ? vecLength : 0);
+ return this.offsetStackValue(vecOffset, vType, bitWidth);
+ }
+ return this.offsetStackValue(vecOffset, value_type_1.ValueType.VECTOR, bitWidth);
+ };
+ Builder.prototype.nullStackValue = function () {
+ return new stack_value_1.StackValue(this, value_type_1.ValueType.NULL, bit_width_1.BitWidth.WIDTH8);
+ };
+ Builder.prototype.boolStackValue = function (value) {
+ return new stack_value_1.StackValue(this, value_type_1.ValueType.BOOL, bit_width_1.BitWidth.WIDTH8, value);
+ };
+ Builder.prototype.intStackValue = function (value) {
+ return new stack_value_1.StackValue(this, value_type_1.ValueType.INT, bit_width_util_1.iwidth(value), value);
+ };
+ Builder.prototype.uintStackValue = function (value) {
+ return new stack_value_1.StackValue(this, value_type_1.ValueType.UINT, bit_width_util_1.uwidth(value), value);
+ };
+ Builder.prototype.floatStackValue = function (value) {
+ return new stack_value_1.StackValue(this, value_type_1.ValueType.FLOAT, bit_width_util_1.fwidth(value), value);
+ };
+ Builder.prototype.offsetStackValue = function (offset, valueType, bitWidth) {
+ return new stack_value_1.StackValue(this, valueType, bitWidth, null, offset);
+ };
+ Builder.prototype.finishBuffer = function () {
+ if (this.stack.length !== 1) {
+ throw "Stack has to be exactly 1, but it is " + this.stack.length + ". You have to end all started vectors and maps before calling [finish]";
+ }
+ var value = this.stack[0];
+ var byteWidth = this.align(value.elementWidth(this.offset, 0));
+ this.writeStackValue(value, byteWidth);
+ this.writeUInt(value.storedPackedType(), 1);
+ this.writeUInt(byteWidth, 1);
+ this.finished = true;
+ };
+ Builder.prototype.add = function (value) {
+ this.integrityCheckOnValueAddition();
+ if (typeof value === 'undefined') {
+ throw "You need to provide a value";
+ }
+ if (value === null) {
+ this.stack.push(this.nullStackValue());
+ }
+ else if (typeof value === "boolean") {
+ this.stack.push(this.boolStackValue(value));
+ }
+ else if (typeof value === "bigint") {
+ this.stack.push(this.intStackValue(value));
+ }
+ else if (typeof value == 'number') {
+ if (Number.isInteger(value)) {
+ this.stack.push(this.intStackValue(value));
+ }
+ else {
+ this.stack.push(this.floatStackValue(value));
+ }
+ }
+ else if (ArrayBuffer.isView(value)) {
+ this.writeBlob(value.buffer);
+ }
+ else if (typeof value === 'string' || value instanceof String) {
+ this.writeString(value);
+ }
+ else if (Array.isArray(value)) {
+ this.startVector();
+ for (var i = 0; i < value.length; i++) {
+ this.add(value[i]);
+ }
+ this.end();
+ }
+ else if (typeof value === 'object') {
+ var properties = Object.getOwnPropertyNames(value).sort();
+ this.startMap(true);
+ for (var i = 0; i < properties.length; i++) {
+ var key = properties[i];
+ this.addKey(key);
+ this.add(value[key]);
+ }
+ this.end();
+ }
+ else {
+ throw "Unexpected value input " + value;
+ }
+ };
+ Builder.prototype.finish = function () {
+ if (!this.finished) {
+ this.finishBuffer();
+ }
+ var result = this.buffer.slice(0, this.offset);
+ return new Uint8Array(result);
+ };
+ Builder.prototype.isFinished = function () {
+ return this.finished;
+ };
+ Builder.prototype.addKey = function (key) {
+ this.integrityCheckOnKeyAddition();
+ this.writeKey(key);
+ };
+ Builder.prototype.addInt = function (value, indirect, deduplicate) {
+ if (indirect === void 0) { indirect = false; }
+ if (deduplicate === void 0) { deduplicate = false; }
+ this.integrityCheckOnValueAddition();
+ if (!indirect) {
+ this.stack.push(this.intStackValue(value));
+ return;
+ }
+ if (deduplicate && Object.prototype.hasOwnProperty.call(this.indirectIntLookup, value)) {
+ this.stack.push(this.indirectIntLookup[value]);
+ return;
+ }
+ var stackValue = this.intStackValue(value);
+ var byteWidth = this.align(stackValue.width);
+ var newOffset = this.computeOffset(byteWidth);
+ var valueOffset = this.offset;
+ stackValue.writeToBuffer(byteWidth);
+ var stackOffset = this.offsetStackValue(valueOffset, value_type_1.ValueType.INDIRECT_INT, stackValue.width);
+ this.stack.push(stackOffset);
+ this.offset = newOffset;
+ if (deduplicate) {
+ this.indirectIntLookup[value] = stackOffset;
+ }
+ };
+ Builder.prototype.addUInt = function (value, indirect, deduplicate) {
+ if (indirect === void 0) { indirect = false; }
+ if (deduplicate === void 0) { deduplicate = false; }
+ this.integrityCheckOnValueAddition();
+ if (!indirect) {
+ this.stack.push(this.uintStackValue(value));
+ return;
+ }
+ if (deduplicate && Object.prototype.hasOwnProperty.call(this.indirectUIntLookup, value)) {
+ this.stack.push(this.indirectUIntLookup[value]);
+ return;
+ }
+ var stackValue = this.uintStackValue(value);
+ var byteWidth = this.align(stackValue.width);
+ var newOffset = this.computeOffset(byteWidth);
+ var valueOffset = this.offset;
+ stackValue.writeToBuffer(byteWidth);
+ var stackOffset = this.offsetStackValue(valueOffset, value_type_1.ValueType.INDIRECT_UINT, stackValue.width);
+ this.stack.push(stackOffset);
+ this.offset = newOffset;
+ if (deduplicate) {
+ this.indirectUIntLookup[value] = stackOffset;
+ }
+ };
+ Builder.prototype.addFloat = function (value, indirect, deduplicate) {
+ if (indirect === void 0) { indirect = false; }
+ if (deduplicate === void 0) { deduplicate = false; }
+ this.integrityCheckOnValueAddition();
+ if (!indirect) {
+ this.stack.push(this.floatStackValue(value));
+ return;
+ }
+ if (deduplicate && Object.prototype.hasOwnProperty.call(this.indirectFloatLookup, value)) {
+ this.stack.push(this.indirectFloatLookup[value]);
+ return;
+ }
+ var stackValue = this.floatStackValue(value);
+ var byteWidth = this.align(stackValue.width);
+ var newOffset = this.computeOffset(byteWidth);
+ var valueOffset = this.offset;
+ stackValue.writeToBuffer(byteWidth);
+ var stackOffset = this.offsetStackValue(valueOffset, value_type_1.ValueType.INDIRECT_FLOAT, stackValue.width);
+ this.stack.push(stackOffset);
+ this.offset = newOffset;
+ if (deduplicate) {
+ this.indirectFloatLookup[value] = stackOffset;
+ }
+ };
+ return Builder;
+}());
+exports.Builder = Builder;
diff --git a/third_party/flatbuffers/js/flexbuffers/flexbuffers-util.js b/third_party/flatbuffers/js/flexbuffers/flexbuffers-util.js
new file mode 100644
index 0000000..0d4e166
--- /dev/null
+++ b/third_party/flatbuffers/js/flexbuffers/flexbuffers-util.js
@@ -0,0 +1,13 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.toUTF8Array = exports.fromUTF8Array = void 0;
+function fromUTF8Array(data) {
+ var decoder = new TextDecoder();
+ return decoder.decode(data);
+}
+exports.fromUTF8Array = fromUTF8Array;
+function toUTF8Array(str) {
+ var encoder = new TextEncoder();
+ return encoder.encode(str);
+}
+exports.toUTF8Array = toUTF8Array;
diff --git a/third_party/flatbuffers/js/flexbuffers/reference-util.js b/third_party/flatbuffers/js/flexbuffers/reference-util.js
new file mode 100644
index 0000000..fc035b9
--- /dev/null
+++ b/third_party/flatbuffers/js/flexbuffers/reference-util.js
@@ -0,0 +1,129 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.keyForIndex = exports.valueForIndexWithKey = exports.diffKeys = exports.keyIndex = exports.indirect = exports.readFloat = exports.readUInt = exports.readInt = exports.validateOffset = void 0;
+var bit_width_1 = require("./bit-width");
+var bit_width_util_1 = require("./bit-width-util");
+var flexbuffers_util_1 = require("./flexbuffers-util");
+var reference_1 = require("./reference");
+var long_1 = require("../long");
+function validateOffset(dataView, offset, width) {
+ if (dataView.byteLength <= offset + width || (offset & (bit_width_util_1.toByteWidth(width) - 1)) !== 0) {
+ throw "Bad offset: " + offset + ", width: " + width;
+ }
+}
+exports.validateOffset = validateOffset;
+function readInt(dataView, offset, width) {
+ if (width < 2) {
+ if (width < 1) {
+ return dataView.getInt8(offset);
+ }
+ else {
+ return dataView.getInt16(offset, true);
+ }
+ }
+ else {
+ if (width < 3) {
+ return dataView.getInt32(offset, true);
+ }
+ else {
+ if (dataView.setBigInt64 === undefined) {
+ return new long_1.Long(dataView.getUint32(offset, true), dataView.getUint32(offset + 4, true));
+ }
+ return dataView.getBigInt64(offset, true);
+ }
+ }
+}
+exports.readInt = readInt;
+function readUInt(dataView, offset, width) {
+ if (width < 2) {
+ if (width < 1) {
+ return dataView.getUint8(offset);
+ }
+ else {
+ return dataView.getUint16(offset, true);
+ }
+ }
+ else {
+ if (width < 3) {
+ return dataView.getUint32(offset, true);
+ }
+ else {
+ if (dataView.getBigUint64 === undefined) {
+ return new long_1.Long(dataView.getUint32(offset, true), dataView.getUint32(offset + 4, true));
+ }
+ return dataView.getBigUint64(offset, true);
+ }
+ }
+}
+exports.readUInt = readUInt;
+function readFloat(dataView, offset, width) {
+ if (width < bit_width_1.BitWidth.WIDTH32) {
+ throw "Bad width: " + width;
+ }
+ if (width === bit_width_1.BitWidth.WIDTH32) {
+ return dataView.getFloat32(offset, true);
+ }
+ return dataView.getFloat64(offset, true);
+}
+exports.readFloat = readFloat;
+function indirect(dataView, offset, width) {
+ var step = readUInt(dataView, offset, width);
+ return offset - step;
+}
+exports.indirect = indirect;
+function keyIndex(key, dataView, offset, parentWidth, byteWidth, length) {
+ var input = flexbuffers_util_1.toUTF8Array(key);
+ var keysVectorOffset = indirect(dataView, offset, parentWidth) - byteWidth * 3;
+ var bitWidth = bit_width_util_1.fromByteWidth(byteWidth);
+ var indirectOffset = keysVectorOffset - readUInt(dataView, keysVectorOffset, bitWidth);
+ var _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth);
+ var low = 0;
+ var high = length - 1;
+ while (low <= high) {
+ var mid = (high + low) >> 1;
+ var dif = diffKeys(input, mid, dataView, indirectOffset, _byteWidth);
+ if (dif === 0)
+ return mid;
+ if (dif < 0) {
+ high = mid - 1;
+ }
+ else {
+ low = mid + 1;
+ }
+ }
+ return null;
+}
+exports.keyIndex = keyIndex;
+function diffKeys(input, index, dataView, offset, width) {
+ var keyOffset = offset + index * width;
+ var keyIndirectOffset = keyOffset - readUInt(dataView, keyOffset, bit_width_util_1.fromByteWidth(width));
+ for (var i = 0; i < input.length; i++) {
+ var dif = input[i] - dataView.getUint8(keyIndirectOffset + i);
+ if (dif !== 0) {
+ return dif;
+ }
+ }
+ return dataView.getUint8(keyIndirectOffset + input.length) === 0 ? 0 : -1;
+}
+exports.diffKeys = diffKeys;
+function valueForIndexWithKey(index, key, dataView, offset, parentWidth, byteWidth, length, path) {
+ var _indirect = indirect(dataView, offset, parentWidth);
+ var elementOffset = _indirect + index * byteWidth;
+ var packedType = dataView.getUint8(_indirect + length * byteWidth + index);
+ return new reference_1.Reference(dataView, elementOffset, bit_width_util_1.fromByteWidth(byteWidth), packedType, path + "/" + key);
+}
+exports.valueForIndexWithKey = valueForIndexWithKey;
+function keyForIndex(index, dataView, offset, parentWidth, byteWidth) {
+ var keysVectorOffset = indirect(dataView, offset, parentWidth) - byteWidth * 3;
+ var bitWidth = bit_width_util_1.fromByteWidth(byteWidth);
+ var indirectOffset = keysVectorOffset - readUInt(dataView, keysVectorOffset, bitWidth);
+ var _byteWidth = readUInt(dataView, keysVectorOffset + byteWidth, bitWidth);
+ var keyOffset = indirectOffset + index * _byteWidth;
+ var keyIndirectOffset = keyOffset - readUInt(dataView, keyOffset, bit_width_util_1.fromByteWidth(_byteWidth));
+ var length = 0;
+ while (dataView.getUint8(keyIndirectOffset + length) !== 0) {
+ length++;
+ }
+ return flexbuffers_util_1.fromUTF8Array(new Uint8Array(dataView.buffer, keyIndirectOffset, length));
+}
+exports.keyForIndex = keyForIndex;
diff --git a/third_party/flatbuffers/js/flexbuffers/reference.js b/third_party/flatbuffers/js/flexbuffers/reference.js
new file mode 100644
index 0000000..748d2b7
--- /dev/null
+++ b/third_party/flatbuffers/js/flexbuffers/reference.js
@@ -0,0 +1,184 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Reference = exports.toReference = void 0;
+var bit_width_util_1 = require("./bit-width-util");
+var value_type_1 = require("./value-type");
+var value_type_util_1 = require("./value-type-util");
+var reference_util_1 = require("./reference-util");
+var flexbuffers_util_1 = require("./flexbuffers-util");
+var bit_width_1 = require("./bit-width");
+function toReference(buffer) {
+ var len = buffer.byteLength;
+ if (len < 3) {
+ throw "Buffer needs to be bigger than 3";
+ }
+ var dataView = new DataView(buffer);
+ var byteWidth = dataView.getUint8(len - 1);
+ var packedType = dataView.getUint8(len - 2);
+ var parentWidth = bit_width_util_1.fromByteWidth(byteWidth);
+ var offset = len - byteWidth - 2;
+ return new Reference(dataView, offset, parentWidth, packedType, "/");
+}
+exports.toReference = toReference;
+var Reference = /** @class */ (function () {
+ function Reference(dataView, offset, parentWidth, packedType, path) {
+ this.dataView = dataView;
+ this.offset = offset;
+ this.parentWidth = parentWidth;
+ this.packedType = packedType;
+ this.path = path;
+ this._length = -1;
+ this.byteWidth = 1 << (packedType & 3);
+ this.valueType = packedType >> 2;
+ }
+ Reference.prototype.isNull = function () { return this.valueType === value_type_1.ValueType.NULL; };
+ Reference.prototype.isNumber = function () { return value_type_util_1.isNumber(this.valueType) || value_type_util_1.isIndirectNumber(this.valueType); };
+ Reference.prototype.isFloat = function () { return value_type_1.ValueType.FLOAT === this.valueType || value_type_1.ValueType.INDIRECT_FLOAT === this.valueType; };
+ Reference.prototype.isInt = function () { return this.isNumber() && !this.isFloat(); };
+ Reference.prototype.isString = function () { return value_type_1.ValueType.STRING === this.valueType || value_type_1.ValueType.KEY === this.valueType; };
+ Reference.prototype.isBool = function () { return value_type_1.ValueType.BOOL === this.valueType; };
+ Reference.prototype.isBlob = function () { return value_type_1.ValueType.BLOB === this.valueType; };
+ Reference.prototype.isVector = function () { return value_type_util_1.isAVector(this.valueType); };
+ Reference.prototype.isMap = function () { return value_type_1.ValueType.MAP === this.valueType; };
+ Reference.prototype.boolValue = function () {
+ if (this.isBool()) {
+ return reference_util_1.readInt(this.dataView, this.offset, this.parentWidth) > 0;
+ }
+ return null;
+ };
+ Reference.prototype.intValue = function () {
+ if (this.valueType === value_type_1.ValueType.INT) {
+ return reference_util_1.readInt(this.dataView, this.offset, this.parentWidth);
+ }
+ if (this.valueType === value_type_1.ValueType.UINT) {
+ return reference_util_1.readUInt(this.dataView, this.offset, this.parentWidth);
+ }
+ if (this.valueType === value_type_1.ValueType.INDIRECT_INT) {
+ return reference_util_1.readInt(this.dataView, reference_util_1.indirect(this.dataView, this.offset, this.parentWidth), bit_width_util_1.fromByteWidth(this.byteWidth));
+ }
+ if (this.valueType === value_type_1.ValueType.INDIRECT_UINT) {
+ return reference_util_1.readUInt(this.dataView, reference_util_1.indirect(this.dataView, this.offset, this.parentWidth), bit_width_util_1.fromByteWidth(this.byteWidth));
+ }
+ return null;
+ };
+ Reference.prototype.floatValue = function () {
+ if (this.valueType === value_type_1.ValueType.FLOAT) {
+ return reference_util_1.readFloat(this.dataView, this.offset, this.parentWidth);
+ }
+ if (this.valueType === value_type_1.ValueType.INDIRECT_FLOAT) {
+ return reference_util_1.readFloat(this.dataView, reference_util_1.indirect(this.dataView, this.offset, this.parentWidth), bit_width_util_1.fromByteWidth(this.byteWidth));
+ }
+ return null;
+ };
+ Reference.prototype.numericValue = function () { return this.floatValue() || this.intValue(); };
+ Reference.prototype.stringValue = function () {
+ if (this.valueType === value_type_1.ValueType.STRING || this.valueType === value_type_1.ValueType.KEY) {
+ var begin = reference_util_1.indirect(this.dataView, this.offset, this.parentWidth);
+ return flexbuffers_util_1.fromUTF8Array(new Uint8Array(this.dataView.buffer, begin, this.length()));
+ }
+ return null;
+ };
+ Reference.prototype.blobValue = function () {
+ if (this.isBlob()) {
+ var begin = reference_util_1.indirect(this.dataView, this.offset, this.parentWidth);
+ return new Uint8Array(this.dataView.buffer, begin, this.length());
+ }
+ return null;
+ };
+ Reference.prototype.get = function (key) {
+ var length = this.length();
+ if (Number.isInteger(key) && value_type_util_1.isAVector(this.valueType)) {
+ if (key >= length || key < 0) {
+ throw "Key: [" + key + "] is not applicable on " + this.path + " of " + this.valueType + " length: " + length;
+ }
+ var _indirect = reference_util_1.indirect(this.dataView, this.offset, this.parentWidth);
+ var elementOffset = _indirect + key * this.byteWidth;
+ var _packedType = this.dataView.getUint8(_indirect + length * this.byteWidth + key);
+ if (value_type_util_1.isTypedVector(this.valueType)) {
+ var _valueType = value_type_util_1.typedVectorElementType(this.valueType);
+ _packedType = value_type_util_1.packedType(_valueType, bit_width_1.BitWidth.WIDTH8);
+ }
+ else if (value_type_util_1.isFixedTypedVector(this.valueType)) {
+ var _valueType = value_type_util_1.fixedTypedVectorElementType(this.valueType);
+ _packedType = value_type_util_1.packedType(_valueType, bit_width_1.BitWidth.WIDTH8);
+ }
+ return new Reference(this.dataView, elementOffset, bit_width_util_1.fromByteWidth(this.byteWidth), _packedType, this.path + "[" + key + "]");
+ }
+ if (typeof key === 'string') {
+ var index = reference_util_1.keyIndex(key, this.dataView, this.offset, this.parentWidth, this.byteWidth, length);
+ if (index !== null) {
+ return reference_util_1.valueForIndexWithKey(index, key, this.dataView, this.offset, this.parentWidth, this.byteWidth, length, this.path);
+ }
+ }
+ throw "Key [" + key + "] is not applicable on " + this.path + " of " + this.valueType;
+ };
+ Reference.prototype.length = function () {
+ var size;
+ if (this._length > -1) {
+ return this._length;
+ }
+ if (value_type_util_1.isFixedTypedVector(this.valueType)) {
+ this._length = value_type_util_1.fixedTypedVectorElementSize(this.valueType);
+ }
+ else if (this.valueType === value_type_1.ValueType.BLOB
+ || this.valueType === value_type_1.ValueType.MAP
+ || value_type_util_1.isAVector(this.valueType)) {
+ this._length = reference_util_1.readUInt(this.dataView, reference_util_1.indirect(this.dataView, this.offset, this.parentWidth) - this.byteWidth, bit_width_util_1.fromByteWidth(this.byteWidth));
+ }
+ else if (this.valueType === value_type_1.ValueType.NULL) {
+ this._length = 0;
+ }
+ else if (this.valueType === value_type_1.ValueType.STRING) {
+ var _indirect = reference_util_1.indirect(this.dataView, this.offset, this.parentWidth);
+ var sizeByteWidth = this.byteWidth;
+ size = reference_util_1.readUInt(this.dataView, _indirect - sizeByteWidth, bit_width_util_1.fromByteWidth(this.byteWidth));
+ while (this.dataView.getInt8(_indirect + size) !== 0) {
+ sizeByteWidth <<= 1;
+ size = reference_util_1.readUInt(this.dataView, _indirect - sizeByteWidth, bit_width_util_1.fromByteWidth(this.byteWidth));
+ }
+ this._length = size;
+ }
+ else if (this.valueType === value_type_1.ValueType.KEY) {
+ var _indirect = reference_util_1.indirect(this.dataView, this.offset, this.parentWidth);
+ size = 1;
+ while (this.dataView.getInt8(_indirect + size) !== 0) {
+ size++;
+ }
+ this._length = size;
+ }
+ else {
+ this._length = 1;
+ }
+ return this._length;
+ };
+ Reference.prototype.toObject = function () {
+ var length = this.length();
+ if (this.isVector()) {
+ var result = [];
+ for (var i = 0; i < length; i++) {
+ result.push(this.get(i).toObject());
+ }
+ return result;
+ }
+ if (this.isMap()) {
+ var result = {};
+ for (var i = 0; i < length; i++) {
+ var key = reference_util_1.keyForIndex(i, this.dataView, this.offset, this.parentWidth, this.byteWidth);
+ result[key] = reference_util_1.valueForIndexWithKey(i, key, this.dataView, this.offset, this.parentWidth, this.byteWidth, length, this.path).toObject();
+ }
+ return result;
+ }
+ if (this.isNull()) {
+ return null;
+ }
+ if (this.isBool()) {
+ return this.boolValue();
+ }
+ if (this.isNumber()) {
+ return this.numericValue();
+ }
+ return this.blobValue() || this.stringValue();
+ };
+ return Reference;
+}());
+exports.Reference = Reference;
diff --git a/third_party/flatbuffers/js/flexbuffers/stack-value.js b/third_party/flatbuffers/js/flexbuffers/stack-value.js
new file mode 100644
index 0000000..98ca482
--- /dev/null
+++ b/third_party/flatbuffers/js/flexbuffers/stack-value.js
@@ -0,0 +1,74 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.StackValue = void 0;
+var bit_width_1 = require("./bit-width");
+var bit_width_util_1 = require("./bit-width-util");
+var value_type_1 = require("./value-type");
+var value_type_util_1 = require("./value-type-util");
+var StackValue = /** @class */ (function () {
+ function StackValue(builder, type, width, value, offset) {
+ if (value === void 0) { value = null; }
+ if (offset === void 0) { offset = 0; }
+ this.builder = builder;
+ this.type = type;
+ this.width = width;
+ this.value = value;
+ this.offset = offset;
+ }
+ StackValue.prototype.elementWidth = function (size, index) {
+ if (value_type_util_1.isInline(this.type))
+ return this.width;
+ for (var i = 0; i < 4; i++) {
+ var width = 1 << i;
+ var offsetLoc = size + bit_width_util_1.paddingSize(size, width) + index * width;
+ var offset = offsetLoc - this.offset;
+ var bitWidth = bit_width_util_1.uwidth(offset);
+ if (1 << bitWidth === width) {
+ return bitWidth;
+ }
+ }
+ throw "Element is unknown. Size: " + size + " at index: " + index + ". This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new";
+ };
+ StackValue.prototype.writeToBuffer = function (byteWidth) {
+ var newOffset = this.builder.computeOffset(byteWidth);
+ if (this.type === value_type_1.ValueType.FLOAT) {
+ if (this.width === bit_width_1.BitWidth.WIDTH32) {
+ this.builder.view.setFloat32(this.builder.offset, this.value, true);
+ }
+ else {
+ this.builder.view.setFloat64(this.builder.offset, this.value, true);
+ }
+ }
+ else if (this.type === value_type_1.ValueType.INT) {
+ var bitWidth = bit_width_util_1.fromByteWidth(byteWidth);
+ this.builder.pushInt(this.value, bitWidth);
+ }
+ else if (this.type === value_type_1.ValueType.UINT) {
+ var bitWidth = bit_width_util_1.fromByteWidth(byteWidth);
+ this.builder.pushUInt(this.value, bitWidth);
+ }
+ else if (this.type === value_type_1.ValueType.NULL) {
+ this.builder.pushInt(0, this.width);
+ }
+ else if (this.type === value_type_1.ValueType.BOOL) {
+ this.builder.pushInt(this.value ? 1 : 0, this.width);
+ }
+ else {
+ throw "Unexpected type: " + this.type + ". This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new";
+ }
+ this.offset = newOffset;
+ };
+ StackValue.prototype.storedWidth = function (width) {
+ if (width === void 0) { width = bit_width_1.BitWidth.WIDTH8; }
+ return value_type_util_1.isInline(this.type) ? Math.max(width, this.width) : this.width;
+ };
+ StackValue.prototype.storedPackedType = function (width) {
+ if (width === void 0) { width = bit_width_1.BitWidth.WIDTH8; }
+ return value_type_util_1.packedType(this.type, this.storedWidth(width));
+ };
+ StackValue.prototype.isOffset = function () {
+ return !value_type_util_1.isInline(this.type);
+ };
+ return StackValue;
+}());
+exports.StackValue = StackValue;
diff --git a/third_party/flatbuffers/js/flexbuffers/value-type-util.js b/third_party/flatbuffers/js/flexbuffers/value-type-util.js
new file mode 100644
index 0000000..996a6e9
--- /dev/null
+++ b/third_party/flatbuffers/js/flexbuffers/value-type-util.js
@@ -0,0 +1,71 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.packedType = exports.fixedTypedVectorElementSize = exports.fixedTypedVectorElementType = exports.typedVectorElementType = exports.toTypedVector = exports.isAVector = exports.isFixedTypedVector = exports.isTypedVector = exports.isTypedVectorElement = exports.isIndirectNumber = exports.isNumber = exports.isInline = void 0;
+var value_type_1 = require("./value-type");
+function isInline(value) {
+ return value === value_type_1.ValueType.BOOL
+ || value <= value_type_1.ValueType.FLOAT;
+}
+exports.isInline = isInline;
+function isNumber(value) {
+ return value >= value_type_1.ValueType.INT
+ && value <= value_type_1.ValueType.FLOAT;
+}
+exports.isNumber = isNumber;
+function isIndirectNumber(value) {
+ return value >= value_type_1.ValueType.INDIRECT_INT
+ && value <= value_type_1.ValueType.INDIRECT_FLOAT;
+}
+exports.isIndirectNumber = isIndirectNumber;
+function isTypedVectorElement(value) {
+ return value === value_type_1.ValueType.BOOL
+ || (value >= value_type_1.ValueType.INT
+ && value <= value_type_1.ValueType.STRING);
+}
+exports.isTypedVectorElement = isTypedVectorElement;
+function isTypedVector(value) {
+ return value === value_type_1.ValueType.VECTOR_BOOL
+ || (value >= value_type_1.ValueType.VECTOR_INT
+ && value <= value_type_1.ValueType.VECTOR_STRING_DEPRECATED);
+}
+exports.isTypedVector = isTypedVector;
+function isFixedTypedVector(value) {
+ return value >= value_type_1.ValueType.VECTOR_INT2
+ && value <= value_type_1.ValueType.VECTOR_FLOAT4;
+}
+exports.isFixedTypedVector = isFixedTypedVector;
+function isAVector(value) {
+ return isTypedVector(value)
+ || isFixedTypedVector(value)
+ || value === value_type_1.ValueType.VECTOR;
+}
+exports.isAVector = isAVector;
+function toTypedVector(valueType, length) {
+ if (length === 0)
+ return valueType - value_type_1.ValueType.INT + value_type_1.ValueType.VECTOR_INT;
+ if (length === 2)
+ return valueType - value_type_1.ValueType.INT + value_type_1.ValueType.VECTOR_INT2;
+ if (length === 3)
+ return valueType - value_type_1.ValueType.INT + value_type_1.ValueType.VECTOR_INT3;
+ if (length === 4)
+ return valueType - value_type_1.ValueType.INT + value_type_1.ValueType.VECTOR_INT4;
+ throw "Unexpected length " + length;
+}
+exports.toTypedVector = toTypedVector;
+function typedVectorElementType(valueType) {
+ return valueType - value_type_1.ValueType.VECTOR_INT + value_type_1.ValueType.INT;
+}
+exports.typedVectorElementType = typedVectorElementType;
+function fixedTypedVectorElementType(valueType) {
+ return ((valueType - value_type_1.ValueType.VECTOR_INT2) % 3) + value_type_1.ValueType.INT;
+}
+exports.fixedTypedVectorElementType = fixedTypedVectorElementType;
+function fixedTypedVectorElementSize(valueType) {
+ // The x / y >> 0 trick is to have an int division. Suppose to be faster than Math.floor()
+ return (((valueType - value_type_1.ValueType.VECTOR_INT2) / 3) >> 0) + 2;
+}
+exports.fixedTypedVectorElementSize = fixedTypedVectorElementSize;
+function packedType(valueType, bitWidth) {
+ return bitWidth | (valueType << 2);
+}
+exports.packedType = packedType;
diff --git a/third_party/flatbuffers/js/flexbuffers/value-type.js b/third_party/flatbuffers/js/flexbuffers/value-type.js
new file mode 100644
index 0000000..0ffbf1f
--- /dev/null
+++ b/third_party/flatbuffers/js/flexbuffers/value-type.js
@@ -0,0 +1,34 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.ValueType = void 0;
+var ValueType;
+(function (ValueType) {
+ ValueType[ValueType["NULL"] = 0] = "NULL";
+ ValueType[ValueType["INT"] = 1] = "INT";
+ ValueType[ValueType["UINT"] = 2] = "UINT";
+ ValueType[ValueType["FLOAT"] = 3] = "FLOAT";
+ ValueType[ValueType["KEY"] = 4] = "KEY";
+ ValueType[ValueType["STRING"] = 5] = "STRING";
+ ValueType[ValueType["INDIRECT_INT"] = 6] = "INDIRECT_INT";
+ ValueType[ValueType["INDIRECT_UINT"] = 7] = "INDIRECT_UINT";
+ ValueType[ValueType["INDIRECT_FLOAT"] = 8] = "INDIRECT_FLOAT";
+ ValueType[ValueType["MAP"] = 9] = "MAP";
+ ValueType[ValueType["VECTOR"] = 10] = "VECTOR";
+ ValueType[ValueType["VECTOR_INT"] = 11] = "VECTOR_INT";
+ ValueType[ValueType["VECTOR_UINT"] = 12] = "VECTOR_UINT";
+ ValueType[ValueType["VECTOR_FLOAT"] = 13] = "VECTOR_FLOAT";
+ ValueType[ValueType["VECTOR_KEY"] = 14] = "VECTOR_KEY";
+ ValueType[ValueType["VECTOR_STRING_DEPRECATED"] = 15] = "VECTOR_STRING_DEPRECATED";
+ ValueType[ValueType["VECTOR_INT2"] = 16] = "VECTOR_INT2";
+ ValueType[ValueType["VECTOR_UINT2"] = 17] = "VECTOR_UINT2";
+ ValueType[ValueType["VECTOR_FLOAT2"] = 18] = "VECTOR_FLOAT2";
+ ValueType[ValueType["VECTOR_INT3"] = 19] = "VECTOR_INT3";
+ ValueType[ValueType["VECTOR_UINT3"] = 20] = "VECTOR_UINT3";
+ ValueType[ValueType["VECTOR_FLOAT3"] = 21] = "VECTOR_FLOAT3";
+ ValueType[ValueType["VECTOR_INT4"] = 22] = "VECTOR_INT4";
+ ValueType[ValueType["VECTOR_UINT4"] = 23] = "VECTOR_UINT4";
+ ValueType[ValueType["VECTOR_FLOAT4"] = 24] = "VECTOR_FLOAT4";
+ ValueType[ValueType["BLOB"] = 25] = "BLOB";
+ ValueType[ValueType["BOOL"] = 26] = "BOOL";
+ ValueType[ValueType["VECTOR_BOOL"] = 36] = "VECTOR_BOOL";
+})(ValueType = exports.ValueType || (exports.ValueType = {}));