enso/app/gui2/shared/binaryProtocol.ts
somebody1234 9b7e3d0f16
E2E tests (#8239)
- Closes #8179

# Important Notes
- ⚠️ These tests are currently *not run* on any CI workflow.
- There is some unused code for mocking the PM. This has been intentionally kept, as this may be useful in the future.
Note that this may be useful for testing the dashboard, however the dashboard is currently only tested in cloud mode
- that is, without the backend switcher, and with only the remote backend available. As such, currently it uses HTTP API mocks, and no PM mock.
2023-11-27 15:48:37 +00:00

2295 lines
72 KiB
TypeScript

// Automatically generated by the FlatBuffers compiler (flatc version 1.12.0),
// and modified by inlining the `flatbuffers` dependency and switching from manual decoding
// to a `DataView`.
// Helper classes copied from https://github.com/google/flatbuffers,
// which is licensed under the Apache License, Version 2.0:
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2014 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const SIZEOF_SHORT = 2
const SIZEOF_INT = 4
const FILE_IDENTIFIER_LENGTH = 4
const SIZE_PREFIX_LENGTH = 4
const TEXT_ENCODER = new TextEncoder()
const TEXT_DECODER = new TextDecoder()
export const Null = 0 as Offset<never>
declare const offsetType: unique symbol
type OffsetConstraint = Table | number | string | Uint8Array | ArrayBuffer | OffsetConstraint[]
export type Offset<T extends OffsetConstraint> = number & {
[offsetType]: T
}
type AnyOffset = Offset<OffsetConstraint>
export type CreateOffset<T extends OffsetConstraint> =
| ((builder: Builder) => Offset<T>)
| null
| undefined
interface IGeneratedObject<T extends OffsetConstraint> {
pack(builder: Builder): Offset<T>
}
export type Table = {
bb: ByteBuffer
bbPos: number
}
export class Builder {
private bb: ByteBuffer
private space: number
private minAlignment = 1
private vtable: number[] | null = null
private vtableInUse = 0
private isNested = false
private objectStart = 0
private vtables: number[] = []
private vectorNumElems = 0
private _forceDefaults = false
private stringMaps: Map<string | Uint8Array, AnyOffset> | null = null
constructor(initialSize?: number) {
initialSize ??= 1024
this.bb = new ByteBuffer(new ArrayBuffer(initialSize))
this.space = initialSize
}
clear(): void {
this.bb.position = 0
this.space = this.bb.view.byteLength
this.minAlignment = 1
this.vtable = []
this.vtableInUse = 0
this.isNested = false
this.objectStart = 0
this.vtables = []
this.vectorNumElems = 0
this._forceDefaults = false
this.stringMaps = null
}
/**
* In order to save space, fields that are set to their default value
* don't get serialized into the buffer. Forcing defaults provides a
* way to manually disable this optimization.
*
* @param forceDefaults true always serializes default values
*/
forceDefaults(forceDefaults: boolean): void {
this._forceDefaults = forceDefaults
}
toArrayBuffer(): ArrayBuffer {
return this.bb.view.buffer.slice(this.bb.position, this.bb.position + this.offset())
}
prep(size: number, additionalBytes: number): void {
if (size > this.minAlignment) {
this.minAlignment = size
}
const alignSize = (~(this.bb.view.byteLength - this.space + additionalBytes) + 1) & (size - 1)
while (this.space < alignSize + size + additionalBytes) {
const oldBufSize = this.bb.view.byteLength
Builder.growByteBuffer(this.bb)
this.space += this.bb.view.byteLength - oldBufSize
}
this.pad(alignSize)
}
pad(byteSize: number): void {
for (let i = 0; i < byteSize; i++) {
this.bb.view.setInt8(--this.space, 0)
}
}
writeInt8(value: number): void {
this.bb.view.setInt8((this.space -= 1), value)
}
writeInt16(value: number): void {
this.bb.view.setInt16((this.space -= 2), value, true)
}
writeInt32(value: number): void {
this.bb.view.setInt32((this.space -= 4), value, true)
}
writeInt64(value: bigint): void {
this.bb.view.setBigInt64((this.space -= 8), value, true)
}
writeFloat32(value: number): void {
this.bb.view.setFloat32((this.space -= 4), value, true)
}
writeFloat64(value: number): void {
this.bb.view.setFloat64((this.space -= 8), value, true)
}
addInt8(value: number): void {
this.prep(1, 0)
this.writeInt8(value)
}
addInt16(value: number): void {
this.prep(2, 0)
this.writeInt16(value)
}
addInt32(value: number): void {
this.prep(4, 0)
this.writeInt32(value)
}
addInt64(value: bigint): void {
this.prep(8, 0)
this.writeInt64(value)
}
addFloat32(value: number): void {
this.prep(4, 0)
this.writeFloat32(value)
}
addFloat64(value: number): void {
this.prep(8, 0)
this.writeFloat64(value)
}
addFieldInt8(voffset: number, value: number, defaultValue: number | null): void {
if (this._forceDefaults || value != defaultValue) {
this.addInt8(value)
this.slot(voffset)
}
}
addFieldInt16(voffset: number, value: number, defaultValue: number | null): void {
if (this._forceDefaults || value != defaultValue) {
this.addInt16(value)
this.slot(voffset)
}
}
addFieldInt32(voffset: number, value: number, defaultValue: number | null): void {
if (this._forceDefaults || value != defaultValue) {
this.addInt32(value)
this.slot(voffset)
}
}
addFieldInt64(voffset: number, value: bigint, defaultValue: bigint | null): void {
if (this._forceDefaults || value !== defaultValue) {
this.addInt64(value)
this.slot(voffset)
}
}
addFieldFloat32(voffset: number, value: number, defaultValue: number | null): void {
if (this._forceDefaults || value != defaultValue) {
this.addFloat32(value)
this.slot(voffset)
}
}
addFieldFloat64(voffset: number, value: number, defaultValue: number | null): void {
if (this._forceDefaults || value != defaultValue) {
this.addFloat64(value)
this.slot(voffset)
}
}
addFieldOffset<T extends OffsetConstraint>(
voffset: number,
value: Offset<T>,
defaultValue: Offset<T>,
): void {
if (this._forceDefaults || value != defaultValue) {
this.addOffset(value)
this.slot(voffset)
}
}
addFieldStruct<T extends OffsetConstraint>(
voffset: number,
value: Offset<T>,
defaultValue: Offset<T>,
): void {
if (value != defaultValue) {
this.nested(value)
this.slot(voffset)
}
}
nested(obj: AnyOffset): void {
if (obj != this.offset()) {
throw new TypeError('FlatBuffers: struct must be serialized inline.')
}
}
notNested(): void {
if (this.isNested) {
throw new TypeError('FlatBuffers: object serialization must not be nested.')
}
}
slot(voffset: number): void {
if (this.vtable !== null) this.vtable[voffset] = this.offset()
}
offset<T extends OffsetConstraint>(): Offset<T> {
return (this.bb.view.byteLength - this.space) as Offset<T>
}
static growByteBuffer(bb: ByteBuffer): void {
const oldBufSize = bb.view.byteLength
// Ensure we don't grow beyond what fits in an int.
if (oldBufSize & 0xc0000000) {
throw new globalThis.Error('FlatBuffers: cannot grow buffer beyond 2 gigabytes.')
}
const newBufSize = oldBufSize << 1
const newBuffer = new ArrayBuffer(newBufSize)
bb.position = newBufSize - oldBufSize
new Uint8Array(newBuffer).set(new Uint8Array(bb.view.buffer), bb.position)
bb.view = new DataView(newBuffer)
}
addOffset(offset: AnyOffset): void {
this.prep(SIZEOF_INT, 0) // Ensure alignment is already done.
this.writeInt32(this.offset() - offset + SIZEOF_INT)
}
startObject(numfields: number): void {
this.notNested()
if (this.vtable == null) {
this.vtable = []
}
this.vtableInUse = numfields
for (let i = 0; i < numfields; i++) {
this.vtable[i] = 0 // This will push additional elements as needed
}
this.isNested = true
this.objectStart = this.offset()
}
endObject<T extends OffsetConstraint>(): Offset<T> {
if (this.vtable == null || !this.isNested) {
throw new globalThis.Error('FlatBuffers: endObject called without startObject')
}
this.addInt32(0)
const vtableloc = this.offset()
// Trim trailing zeroes.
let i = this.vtableInUse - 1
// eslint-disable-next-line no-empty
for (; i >= 0 && this.vtable[i] === 0; i -= 1) {}
const trimmedSize = i + 1
// Write out the current vtable.
for (; i >= 0; i -= 1) {
// Offset relative to the start of the table.
this.addInt16(this.vtable[i] !== 0 ? vtableloc - this.vtable[i]! : 0)
}
const standardFields = 2 // The fields below:
this.addInt16(vtableloc - this.objectStart)
const len = (trimmedSize + standardFields) * SIZEOF_SHORT
this.addInt16(len)
// Search for an existing vtable that matches the current one.
let existingVtable = 0
const vt1 = this.space
outerLoop: for (i = 0; i < this.vtables.length; i++) {
const vt2 = this.bb.view.byteLength - this.vtables[i]!
if (len == this.bb.view.getInt16(vt2, true)) {
for (let j = SIZEOF_SHORT; j < len; j += SIZEOF_SHORT) {
if (this.bb.view.getInt16(vt1 + j, true) != this.bb.view.getInt16(vt2 + j, true)) {
continue outerLoop
}
}
existingVtable = this.vtables[i]!
break
}
}
if (existingVtable) {
// Found a match:
// Remove the current vtable.
this.space = this.bb.view.byteLength - vtableloc
// Point table to existing vtable.
this.bb.view.setInt32(this.space, existingVtable - vtableloc, true)
} else {
// No match:
// Add the location of the current vtable to the list of vtables.
this.vtables.push(this.offset())
// Point table to current vtable.
this.bb.view.setInt32(this.bb.view.byteLength - vtableloc, this.offset() - vtableloc, true)
}
this.isNested = false
return vtableloc as Offset<T>
}
finish(
rootTable: AnyOffset,
fileIdentifier?: string,
shouldIncludeSizePrefix?: boolean,
): Builder {
const sizePrefix = shouldIncludeSizePrefix ? SIZE_PREFIX_LENGTH : 0
if (fileIdentifier) {
this.prep(this.minAlignment, SIZEOF_INT + FILE_IDENTIFIER_LENGTH + sizePrefix)
if (fileIdentifier.length != FILE_IDENTIFIER_LENGTH) {
throw new TypeError('FlatBuffers: file identifier must be length ' + FILE_IDENTIFIER_LENGTH)
}
for (let i = FILE_IDENTIFIER_LENGTH - 1; i >= 0; i -= 1) {
this.writeInt8(fileIdentifier.charCodeAt(i))
}
}
this.prep(this.minAlignment, SIZEOF_INT + sizePrefix)
this.addOffset(rootTable)
if (sizePrefix) {
this.addInt32(this.bb.view.byteLength - this.space)
}
this.bb.position = this.space
return this
}
finishSizePrefixed(rootTable: AnyOffset, fileIdentifier?: string): Builder {
this.finish(rootTable, fileIdentifier, true)
return this
}
requiredField(table: AnyOffset, field: number): void {
const tableStart = this.bb.view.byteLength - table
const vtableStart = tableStart - this.bb.view.getInt32(tableStart, true)
const ok =
field < this.bb.view.getInt16(vtableStart, true) &&
this.bb.view.getInt16(vtableStart + field, true) != 0
// If this fails, the caller will show what field needs to be set.
if (!ok) {
throw new TypeError('FlatBuffers: field ' + field + ' must be set')
}
}
startVector(elemSize: number, numElems: number, alignment: number): void {
this.notNested()
this.vectorNumElems = numElems
this.prep(SIZEOF_INT, elemSize * numElems)
this.prep(alignment, elemSize * numElems) // Just in case alignment > int.
}
endVector<T extends OffsetConstraint>(): Offset<T> {
this.writeInt32(this.vectorNumElems)
return this.offset()
}
createSharedString<T extends string | Uint8Array>(s: T): Offset<T> {
if (!s) {
return 0 as Offset<T>
}
if (!this.stringMaps) {
this.stringMaps = new Map()
}
const value = this.stringMaps.get(s)
if (value != null) {
return value as Offset<T>
}
const offset = this.createString(s)
this.stringMaps.set(s, offset)
return offset as Offset<T>
}
createString(s: string | Uint8Array | ArrayBuffer | null | undefined): Offset<Uint8Array> {
if (s === null || s === undefined) return Null
let utf8: string | Uint8Array | number[]
if (s instanceof Uint8Array) {
utf8 = s
} else if (s instanceof ArrayBuffer) {
utf8 = new Uint8Array(s)
} else {
utf8 = TEXT_ENCODER.encode(s)
}
this.addInt8(0)
this.startVector(1, utf8.length, 1)
this.bb.position = this.space -= utf8.length
for (let i = 0, offset = this.space, bytes = this.bb.view; i < utf8.length; i++) {
bytes.setUint8(offset++, utf8[i]!)
}
return this.endVector()
}
createObjectOffset<T extends OffsetConstraint>(
obj: T extends string | null ? T : IGeneratedObject<T>,
): Offset<T> {
if (obj === null) return Null
else if (typeof obj === 'string') return this.createString(obj) as Offset<T>
else return obj.pack(this) as Offset<T>
}
createObjectOffsetList<T extends OffsetConstraint>(
list: (T extends string ? string : IGeneratedObject<T>)[],
): Offset<T>[] {
const ret: number[] = []
for (let i = 0; i < list.length; ++i) {
const val = list[i]
if (val != null) {
ret.push(this.createObjectOffset(val as any))
} else {
throw new TypeError('FlatBuffers: Argument for createObjectOffsetList cannot contain null.')
}
}
return ret as Offset<T>[]
}
createStructOffsetList<T extends OffsetConstraint>(
list: (T extends string ? string : IGeneratedObject<T>)[],
startFunc: (builder: Builder, length: number) => void,
): Offset<T> {
startFunc(this, list.length)
this.createObjectOffsetList(list.slice().reverse())
return this.endVector()
}
}
export class ByteBuffer {
position = 0
view: DataView
constructor(buffer: ArrayBufferLike) {
this.view = new DataView(buffer)
}
offset<T extends OffsetConstraint>(bbPos: number, vtableOffset: number): Offset<T> {
const vtable = bbPos - this.view.getInt32(bbPos, true)
return (
vtableOffset < this.view.getInt16(vtable, true)
? this.view.getInt16(vtable + vtableOffset, true)
: 0
) as Offset<T>
}
union(t: Table, offset: number): Table {
t.bbPos = offset + this.view.getInt32(offset, true)
t.bb = this
return t
}
rawMessage(offset: number): ArrayBuffer {
offset += this.view.getInt32(offset, true)
const length = this.view.getInt32(offset, true)
offset += SIZEOF_INT
return this.view.buffer.slice(offset, offset + length)
}
message(offset: number): string {
return TEXT_DECODER.decode(this.rawMessage(offset))
}
indirect<T extends OffsetConstraint>(offset: number | Offset<T>): Offset<T> {
return (offset + this.view.getInt32(offset, true)) as Offset<T>
}
vector<T extends OffsetConstraint>(offset: number | Offset<T>): Offset<T> {
return (offset + this.view.getInt32(offset, true) + SIZEOF_INT) as Offset<T> // data starts after the length
}
vectorLength(offset: number | AnyOffset): Offset<number> {
return this.view.getInt32(offset + this.view.getInt32(offset, true), true) as Offset<number>
}
}
export enum InboundPayload {
NONE = 0,
INIT_SESSION_CMD = 1,
WRITE_FILE_CMD = 2,
READ_FILE_CMD = 3,
WRITE_BYTES_CMD = 4,
READ_BYTES_CMD = 5,
CHECKSUM_BYTES_CMD = 6,
}
export type AnyInboundPayload =
| None
| InitSessionCommand
| WriteFileCommand
| ReadFileCommand
| WriteBytesCommand
| ReadBytesCommand
| ChecksumBytesCommand
export enum OutboundPayload {
NONE = 0,
ERROR = 1,
SUCCESS = 2,
VISUALIZATION_UPDATE = 3,
FILE_CONTENTS_REPLY = 4,
WRITE_BYTES_REPLY = 5,
READ_BYTES_REPLY = 6,
CHECKSUM_BYTES_REPLY = 7,
}
export type AnyOutboundPayload =
| None
| Error
| Success
| VisualizationUpdate
| FileContentsReply
| WriteBytesReply
| ReadBytesReply
| ChecksumBytesReply
export enum ErrorPayload {
NONE = 0,
READ_OOB = 1,
}
export type AnyErrorPayload = None | ReadOutOfBoundsError
export class InboundMessage implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): InboundMessage {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsInboundMessage(bb: ByteBuffer, obj?: InboundMessage): InboundMessage {
return (obj ?? new InboundMessage()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
static getSizePrefixedRootAsInboundMessage(bb: ByteBuffer, obj?: InboundMessage): InboundMessage {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new InboundMessage()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
messageId(obj?: EnsoUUID): EnsoUUID | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? (obj ?? new EnsoUUID()).init(this.bbPos + offset, this.bb!) : null
}
correlationId(obj?: EnsoUUID): EnsoUUID | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? (obj ?? new EnsoUUID()).init(this.bbPos + offset, this.bb!) : null
}
payloadType(): InboundPayload {
const offset = this.bb.offset(this.bbPos, 8)
return offset ? this.bb.view.getUint8(this.bbPos + offset) : InboundPayload.NONE
}
payload<T extends Table>(obj: T): T | null {
const offset = this.bb.offset(this.bbPos, 10)
// @ts-expect-error
return offset ? this.bb.union(obj, this.bbPos + offset) : null
}
static startInboundMessage(builder: Builder) {
builder.startObject(4)
}
static addMessageId(builder: Builder, messageIdOffset: Offset<EnsoUUID>) {
builder.addFieldStruct(0, messageIdOffset, Null)
}
static addCorrelationId(builder: Builder, correlationIdOffset: Offset<EnsoUUID>) {
builder.addFieldStruct(1, correlationIdOffset, Null)
}
static addPayloadType(builder: Builder, payloadType: InboundPayload) {
builder.addFieldInt8(2, payloadType, InboundPayload.NONE)
}
static addPayload(builder: Builder, payloadOffset: Offset<AnyInboundPayload>) {
builder.addFieldOffset(3, payloadOffset, Null)
}
static endInboundMessage(builder: Builder): Offset<InboundMessage> {
const offset = builder.endObject<InboundMessage>()
builder.requiredField(offset, 4) // messageId
builder.requiredField(offset, 10) // payload
return offset
}
static createInboundMessage(
builder: Builder,
createMessageId: CreateOffset<EnsoUUID>,
createCorrelationId: CreateOffset<EnsoUUID>,
payloadType: InboundPayload,
payloadOffset: Offset<AnyInboundPayload>,
): Offset<InboundMessage> {
InboundMessage.startInboundMessage(builder)
InboundMessage.addMessageId(builder, createMessageId?.(builder) ?? Null)
InboundMessage.addCorrelationId(builder, createCorrelationId?.(builder) ?? Null)
InboundMessage.addPayloadType(builder, payloadType)
InboundMessage.addPayload(builder, payloadOffset)
return InboundMessage.endInboundMessage(builder)
}
}
export class OutboundMessage implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): OutboundMessage {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsOutboundMessage(bb: ByteBuffer, obj?: OutboundMessage): OutboundMessage {
return (obj ?? new OutboundMessage()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsOutboundMessage(
bb: ByteBuffer,
obj?: OutboundMessage,
): OutboundMessage {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new OutboundMessage()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
messageId(obj?: EnsoUUID): EnsoUUID | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? (obj ?? new EnsoUUID()).init(this.bbPos + offset, this.bb!) : null
}
correlationId(obj?: EnsoUUID): EnsoUUID | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? (obj ?? new EnsoUUID()).init(this.bbPos + offset, this.bb!) : null
}
payloadType(): OutboundPayload {
const offset = this.bb.offset(this.bbPos, 8)
return offset ? this.bb.view.getUint8(this.bbPos + offset) : OutboundPayload.NONE
}
payload<T extends Table>(obj: T): T | null {
const offset = this.bb.offset(this.bbPos, 10)
// @ts-expect-error
return offset ? this.bb.union(obj, this.bbPos + offset) : null
}
static startOutboundMessage(builder: Builder) {
builder.startObject(4)
}
static addMessageId(builder: Builder, messageIdOffset: Offset<EnsoUUID>) {
builder.addFieldStruct(0, messageIdOffset, Null)
}
static addCorrelationId(builder: Builder, correlationIdOffset: Offset<EnsoUUID>) {
builder.addFieldStruct(1, correlationIdOffset, Null)
}
static addPayloadType(builder: Builder, payloadType: OutboundPayload) {
builder.addFieldInt8(2, payloadType, OutboundPayload.NONE)
}
static addPayload(builder: Builder, payloadOffset: Offset<AnyOutboundPayload>) {
builder.addFieldOffset(3, payloadOffset, Null)
}
static endOutboundMessage(builder: Builder): Offset<OutboundMessage> {
const offset = builder.endObject<OutboundMessage>()
builder.requiredField(offset, 4) // messageId
builder.requiredField(offset, 10) // payload
return offset
}
static createOutboundMessage(
builder: Builder,
createMessageId: CreateOffset<EnsoUUID>,
createCorrelationId: CreateOffset<EnsoUUID>,
payloadType: OutboundPayload,
payloadOffset: Offset<AnyOutboundPayload>,
): Offset<OutboundMessage> {
OutboundMessage.startOutboundMessage(builder)
OutboundMessage.addMessageId(builder, createMessageId?.(builder) ?? Null)
OutboundMessage.addCorrelationId(builder, createCorrelationId?.(builder) ?? Null)
OutboundMessage.addPayloadType(builder, payloadType)
OutboundMessage.addPayload(builder, payloadOffset)
return OutboundMessage.endOutboundMessage(builder)
}
}
export class EnsoUUID implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): EnsoUUID {
this.bbPos = i
this.bb = bb
return this
}
leastSigBits(): bigint {
return this.bb.view.getBigUint64(this.bbPos, true)
}
mostSigBits(): bigint {
return this.bb.view.getBigUint64(this.bbPos + 8, true)
}
static createEnsoUUID(
builder: Builder,
leastSigBits: bigint,
mostSigBits: bigint,
): Offset<EnsoUUID> {
builder.prep(8, 16)
builder.writeInt64(mostSigBits)
builder.writeInt64(leastSigBits)
return builder.offset()
}
}
export class Error implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): Error {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsError(bb: ByteBuffer, obj?: Error): Error {
return (obj ?? new Error()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
static getSizePrefixedRootAsError(bb: ByteBuffer, obj?: Error): Error {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new Error()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
code(): number {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? this.bb.view.getInt32(this.bbPos + offset, true) : 0
}
rawMessage(): ArrayBuffer | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.rawMessage(this.bbPos + offset) : null
}
message(): string | null {
const rawMessage = this.rawMessage()
return rawMessage ? TEXT_DECODER.decode(rawMessage) : null
}
dataType(): ErrorPayload {
const offset = this.bb.offset(this.bbPos, 8)
return offset ? this.bb.view.getUint8(this.bbPos + offset) : ErrorPayload.NONE
}
data<T extends Table>(obj: T): T | null {
const offset = this.bb.offset(this.bbPos, 10)
// @ts-expect-error
return offset ? this.bb.union(obj, this.bbPos + offset) : null
}
static startError(builder: Builder) {
builder.startObject(4)
}
static addCode(builder: Builder, code: number) {
builder.addFieldInt32(0, code, 0)
}
static addMessage(builder: Builder, messageOffset: Offset<string | ArrayBuffer>) {
builder.addFieldOffset(1, messageOffset, Null)
}
static addDataType(builder: Builder, dataType: ErrorPayload) {
builder.addFieldInt8(2, dataType, ErrorPayload.NONE)
}
static addData(builder: Builder, dataOffset: Offset<AnyErrorPayload>) {
builder.addFieldOffset(3, dataOffset, Null)
}
static endError(builder: Builder): Offset<Error> {
const offset = builder.endObject<Error>()
builder.requiredField(offset, 6) // message
return offset
}
static createError(
builder: Builder,
code: number,
messageOffset: Offset<string | ArrayBuffer>,
dataType: ErrorPayload,
dataOffset: Offset<AnyErrorPayload>,
): Offset<Error> {
Error.startError(builder)
Error.addCode(builder, code)
Error.addMessage(builder, messageOffset)
Error.addDataType(builder, dataType)
Error.addData(builder, dataOffset)
return Error.endError(builder)
}
}
export class ReadOutOfBoundsError implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): ReadOutOfBoundsError {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsReadOutOfBoundsError(
bb: ByteBuffer,
obj?: ReadOutOfBoundsError,
): ReadOutOfBoundsError {
return (obj ?? new ReadOutOfBoundsError()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsReadOutOfBoundsError(
bb: ByteBuffer,
obj?: ReadOutOfBoundsError,
): ReadOutOfBoundsError {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new ReadOutOfBoundsError()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
fileLength(): bigint {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? this.bb.view.getBigUint64(this.bbPos + offset, true) : 0n
}
static startReadOutOfBoundsError(builder: Builder) {
builder.startObject(1)
}
static addFileLength(builder: Builder, fileLength: bigint) {
builder.addFieldInt64(0, fileLength, 0n)
}
static endReadOutOfBoundsError(builder: Builder): Offset<ReadOutOfBoundsError> {
const offset = builder.endObject<ReadOutOfBoundsError>()
return offset
}
static createReadOutOfBoundsError(
builder: Builder,
fileLength: bigint,
): Offset<ReadOutOfBoundsError> {
ReadOutOfBoundsError.startReadOutOfBoundsError(builder)
ReadOutOfBoundsError.addFileLength(builder, fileLength)
return ReadOutOfBoundsError.endReadOutOfBoundsError(builder)
}
}
export class None implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): None {
this.bbPos = i
this.bb = bb
return this
}
}
export class Success implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): Success {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsSuccess(bb: ByteBuffer, obj?: Success): Success {
return (obj ?? new Success()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
static getSizePrefixedRootAsSuccess(bb: ByteBuffer, obj?: Success): Success {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new Success()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
static startSuccess(builder: Builder) {
builder.startObject(0)
}
static endSuccess(builder: Builder): Offset<Success> {
const offset = builder.endObject<Success>()
return offset
}
static createSuccess(builder: Builder): Offset<Success> {
Success.startSuccess(builder)
return Success.endSuccess(builder)
}
}
export class InitSessionCommand implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): InitSessionCommand {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsInitSessionCommand(bb: ByteBuffer, obj?: InitSessionCommand): InitSessionCommand {
return (obj ?? new InitSessionCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsInitSessionCommand(
bb: ByteBuffer,
obj?: InitSessionCommand,
): InitSessionCommand {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new InitSessionCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
identifier(obj?: EnsoUUID): EnsoUUID | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? (obj ?? new EnsoUUID()).init(this.bbPos + offset, this.bb!) : null
}
static startInitSessionCommand(builder: Builder) {
builder.startObject(1)
}
static addIdentifier(builder: Builder, identifierOffset: Offset<EnsoUUID>) {
builder.addFieldStruct(0, identifierOffset, Null)
}
static endInitSessionCommand(builder: Builder): Offset<InitSessionCommand> {
const offset = builder.endObject<InitSessionCommand>()
builder.requiredField(offset, 4) // identifier
return offset
}
static createInitSessionCommand(
builder: Builder,
createIdentifier: CreateOffset<EnsoUUID>,
): Offset<InitSessionCommand> {
InitSessionCommand.startInitSessionCommand(builder)
InitSessionCommand.addIdentifier(builder, createIdentifier?.(builder) ?? Null)
return InitSessionCommand.endInitSessionCommand(builder)
}
}
export class VisualizationContext implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): VisualizationContext {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsVisualizationContext(
bb: ByteBuffer,
obj?: VisualizationContext,
): VisualizationContext {
return (obj ?? new VisualizationContext()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsVisualizationContext(
bb: ByteBuffer,
obj?: VisualizationContext,
): VisualizationContext {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new VisualizationContext()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
visualizationId(obj?: EnsoUUID): EnsoUUID | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? (obj ?? new EnsoUUID()).init(this.bbPos + offset, this.bb!) : null
}
contextId(obj?: EnsoUUID): EnsoUUID | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? (obj ?? new EnsoUUID()).init(this.bbPos + offset, this.bb!) : null
}
expressionId(obj?: EnsoUUID): EnsoUUID | null {
const offset = this.bb.offset(this.bbPos, 8)
return offset ? (obj ?? new EnsoUUID()).init(this.bbPos + offset, this.bb!) : null
}
static startVisualizationContext(builder: Builder) {
builder.startObject(3)
}
static addVisualizationId(builder: Builder, visualizationIdOffset: Offset<EnsoUUID>) {
builder.addFieldStruct(0, visualizationIdOffset, Null)
}
static addContextId(builder: Builder, contextIdOffset: Offset<EnsoUUID>) {
builder.addFieldStruct(1, contextIdOffset, Null)
}
static addExpressionId(builder: Builder, expressionIdOffset: Offset<EnsoUUID>) {
builder.addFieldStruct(2, expressionIdOffset, Null)
}
static endVisualizationContext(builder: Builder): Offset<VisualizationContext> {
const offset = builder.endObject<VisualizationContext>()
builder.requiredField(offset, 4) // visualizationId
builder.requiredField(offset, 6) // contextId
builder.requiredField(offset, 8) // expressionId
return offset
}
static createVisualizationContext(
builder: Builder,
createVisualizationId: CreateOffset<EnsoUUID>,
createContextId: CreateOffset<EnsoUUID>,
createExpressionId: CreateOffset<EnsoUUID>,
): Offset<VisualizationContext> {
VisualizationContext.startVisualizationContext(builder)
VisualizationContext.addVisualizationId(builder, createVisualizationId?.(builder) ?? Null)
VisualizationContext.addContextId(builder, createContextId?.(builder) ?? Null)
VisualizationContext.addExpressionId(builder, createExpressionId?.(builder) ?? Null)
return VisualizationContext.endVisualizationContext(builder)
}
}
export class VisualizationUpdate implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): VisualizationUpdate {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsVisualizationUpdate(
bb: ByteBuffer,
obj?: VisualizationUpdate,
): VisualizationUpdate {
return (obj ?? new VisualizationUpdate()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsVisualizationUpdate(
bb: ByteBuffer,
obj?: VisualizationUpdate,
): VisualizationUpdate {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new VisualizationUpdate()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
visualizationContext(obj?: VisualizationContext): VisualizationContext | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset
? (obj ?? new VisualizationContext()).init(this.bb.indirect(this.bbPos + offset), this.bb!)
: null
}
data(index: number): number | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.view.getUint8(this.bb.vector(this.bbPos + offset) + index) : 0
}
dataLength(): number {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.vectorLength(this.bbPos + offset) : 0
}
dataArray(): Uint8Array | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset
? new Uint8Array(
this.bb.view.buffer,
this.bb.view.byteOffset + this.bb.vector(this.bbPos + offset),
this.bb.vectorLength(this.bbPos + offset),
)
: null
}
dataString(): string | null {
const buffer = this.dataArray()
return buffer != null ? TEXT_DECODER.decode(buffer) : null
}
static startVisualizationUpdate(builder: Builder) {
builder.startObject(2)
}
static addVisualizationContext(
builder: Builder,
visualizationContextOffset: Offset<VisualizationContext>,
) {
builder.addFieldOffset(0, visualizationContextOffset, Null)
}
static addData(builder: Builder, dataOffset: Offset<Uint8Array>) {
builder.addFieldOffset(1, dataOffset, Null)
}
static createDataVector(builder: Builder, data: number[] | Uint8Array): Offset<Uint8Array> {
builder.startVector(1, data.length, 1)
// An iterator is more type-safe, but less performant.
for (let i = data.length - 1; i >= 0; i -= 1) {
builder.addInt8(data[i]!)
}
return builder.endVector()
}
static startDataVector(builder: Builder, numElems: number) {
builder.startVector(1, numElems, 1)
}
static endVisualizationUpdate(builder: Builder): Offset<VisualizationUpdate> {
const offset = builder.endObject<VisualizationUpdate>()
builder.requiredField(offset, 4) // visualizationContext
builder.requiredField(offset, 6) // data
return offset
}
static createVisualizationUpdate(
builder: Builder,
visualizationContextOffset: Offset<VisualizationContext>,
dataOffset: Offset<Uint8Array>,
): Offset<VisualizationUpdate> {
VisualizationUpdate.startVisualizationUpdate(builder)
VisualizationUpdate.addVisualizationContext(builder, visualizationContextOffset)
VisualizationUpdate.addData(builder, dataOffset)
return VisualizationUpdate.endVisualizationUpdate(builder)
}
}
export class Path implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): Path {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsPath(bb: ByteBuffer, obj?: Path): Path {
return (obj ?? new Path()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
static getSizePrefixedRootAsPath(bb: ByteBuffer, obj?: Path): Path {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new Path()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
rootId(obj?: EnsoUUID): EnsoUUID | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? (obj ?? new EnsoUUID()).init(this.bbPos + offset, this.bb) : null
}
rawSegments(index: number): ArrayBuffer {
const offset = this.bb.offset(this.bbPos, 6)
return offset
? this.bb.rawMessage(this.bb.vector(this.bbPos + offset) + index * 4)
: new Uint8Array()
}
segments(index: number): string {
return TEXT_DECODER.decode(this.rawSegments(index))
}
segmentsLength(): number {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.vectorLength(this.bbPos + offset) : 0
}
static startPath(builder: Builder) {
builder.startObject(2)
}
static addRootId(builder: Builder, rootIdOffset: Offset<EnsoUUID>) {
builder.addFieldStruct(0, rootIdOffset, Null)
}
static addSegments(builder: Builder, segmentsOffset: Offset<string[] | ArrayBuffer[]>) {
builder.addFieldOffset(1, segmentsOffset, Null)
}
static createSegmentsVector(
builder: Builder,
data: Offset<string>[] | Offset<ArrayBuffer>[],
): Offset<string[] | ArrayBuffer[]> {
builder.startVector(4, data.length, 4)
// An iterator is more type-safe, but less performant.
for (let i = data.length - 1; i >= 0; i -= 1) {
builder.addOffset(data[i]!)
}
return builder.endVector()
}
static startSegmentsVector(builder: Builder, numElems: number) {
builder.startVector(4, numElems, 4)
}
static endPath(builder: Builder): Offset<Path> {
const offset = builder.endObject<Path>()
return offset
}
static createPath(
builder: Builder,
createRootId: CreateOffset<EnsoUUID>,
segmentsOffset: Offset<string[] | ArrayBuffer[]>,
): Offset<Path> {
Path.startPath(builder)
Path.addRootId(builder, createRootId?.(builder) ?? Null)
Path.addSegments(builder, segmentsOffset)
return Path.endPath(builder)
}
}
export class WriteFileCommand implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): WriteFileCommand {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsWriteFileCommand(bb: ByteBuffer, obj?: WriteFileCommand): WriteFileCommand {
return (obj ?? new WriteFileCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsWriteFileCommand(
bb: ByteBuffer,
obj?: WriteFileCommand,
): WriteFileCommand {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new WriteFileCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
path(obj?: Path): Path | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? (obj ?? new Path()).init(this.bb.indirect(this.bbPos + offset), this.bb!) : null
}
contents(index: number): number | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.view.getUint8(this.bb.vector(this.bbPos + offset) + index) : 0
}
contentsLength(): number {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.vectorLength(this.bbPos + offset) : 0
}
contentsArray(): Uint8Array | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset
? new Uint8Array(
this.bb.view.buffer,
this.bb.view.byteOffset + this.bb.vector(this.bbPos + offset),
this.bb.vectorLength(this.bbPos + offset),
)
: null
}
static startWriteFileCommand(builder: Builder) {
builder.startObject(2)
}
static addPath(builder: Builder, pathOffset: Offset<Path>) {
builder.addFieldOffset(0, pathOffset, Null)
}
static addContents(builder: Builder, contentsOffset: Offset<Uint8Array>) {
builder.addFieldOffset(1, contentsOffset, Null)
}
static createContentsVector(builder: Builder, data: number[] | Uint8Array): Offset<Uint8Array> {
builder.startVector(1, data.length, 1)
// An iterator is more type-safe, but less performant.
for (let i = data.length - 1; i >= 0; i -= 1) {
builder.addInt8(data[i]!)
}
return builder.endVector()
}
static startContentsVector(builder: Builder, numElems: number) {
builder.startVector(1, numElems, 1)
}
static endWriteFileCommand(builder: Builder): Offset<WriteFileCommand> {
const offset = builder.endObject<WriteFileCommand>()
return offset
}
static createWriteFileCommand(
builder: Builder,
pathOffset: Offset<Path>,
contentsOffset: Offset<Uint8Array>,
): Offset<WriteFileCommand> {
WriteFileCommand.startWriteFileCommand(builder)
WriteFileCommand.addPath(builder, pathOffset)
WriteFileCommand.addContents(builder, contentsOffset)
return WriteFileCommand.endWriteFileCommand(builder)
}
}
export class ReadFileCommand implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): ReadFileCommand {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsReadFileCommand(bb: ByteBuffer, obj?: ReadFileCommand): ReadFileCommand {
return (obj ?? new ReadFileCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsReadFileCommand(
bb: ByteBuffer,
obj?: ReadFileCommand,
): ReadFileCommand {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new ReadFileCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
path(obj?: Path): Path | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? (obj ?? new Path()).init(this.bb.indirect(this.bbPos + offset), this.bb!) : null
}
static startReadFileCommand(builder: Builder) {
builder.startObject(1)
}
static addPath(builder: Builder, pathOffset: Offset<Path>) {
builder.addFieldOffset(0, pathOffset, Null)
}
static endReadFileCommand(builder: Builder): Offset<ReadFileCommand> {
const offset = builder.endObject<ReadFileCommand>()
return offset
}
static createReadFileCommand(
builder: Builder,
pathOffset: Offset<Path>,
): Offset<ReadFileCommand> {
ReadFileCommand.startReadFileCommand(builder)
ReadFileCommand.addPath(builder, pathOffset)
return ReadFileCommand.endReadFileCommand(builder)
}
}
export class FileContentsReply implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): FileContentsReply {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsFileContentsReply(bb: ByteBuffer, obj?: FileContentsReply): FileContentsReply {
return (obj ?? new FileContentsReply()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsFileContentsReply(
bb: ByteBuffer,
obj?: FileContentsReply,
): FileContentsReply {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new FileContentsReply()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
contents(index: number): number | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? this.bb.view.getUint8(this.bb.vector(this.bbPos + offset) + index) : 0
}
contentsLength(): number {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? this.bb.vectorLength(this.bbPos + offset) : 0
}
contentsArray(): Uint8Array | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset
? new Uint8Array(
this.bb.view.buffer,
this.bb.view.byteOffset + this.bb.vector(this.bbPos + offset),
this.bb.vectorLength(this.bbPos + offset),
)
: null
}
static startFileContentsReply(builder: Builder) {
builder.startObject(1)
}
static addContents(builder: Builder, contentsOffset: Offset<Uint8Array>) {
builder.addFieldOffset(0, contentsOffset, Null)
}
static createContentsVector(builder: Builder, data: number[] | Uint8Array): Offset<Uint8Array> {
builder.startVector(1, data.length, 1)
// An iterator is more type-safe, but less performant.
for (let i = data.length - 1; i >= 0; i -= 1) {
builder.addInt8(data[i]!)
}
return builder.endVector()
}
static startContentsVector(builder: Builder, numElems: number) {
builder.startVector(1, numElems, 1)
}
static endFileContentsReply(builder: Builder): Offset<FileContentsReply> {
const offset = builder.endObject<FileContentsReply>()
return offset
}
static createFileContentsReply(
builder: Builder,
contentsOffset: Offset<Uint8Array>,
): Offset<FileContentsReply> {
FileContentsReply.startFileContentsReply(builder)
FileContentsReply.addContents(builder, contentsOffset)
return FileContentsReply.endFileContentsReply(builder)
}
}
export class WriteBytesCommand implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): WriteBytesCommand {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsWriteBytesCommand(bb: ByteBuffer, obj?: WriteBytesCommand): WriteBytesCommand {
return (obj ?? new WriteBytesCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsWriteBytesCommand(
bb: ByteBuffer,
obj?: WriteBytesCommand,
): WriteBytesCommand {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new WriteBytesCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
path(obj?: Path): Path | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? (obj ?? new Path()).init(this.bb.indirect(this.bbPos + offset), this.bb!) : null
}
byteOffset(): bigint {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.view.getBigUint64(this.bbPos + offset, true) : 0n
}
overwriteExisting(): boolean {
const offset = this.bb.offset(this.bbPos, 8)
return offset ? !!this.bb.view.getInt8(this.bbPos + offset) : false
}
bytes(index: number): number | null {
const offset = this.bb.offset(this.bbPos, 10)
return offset ? this.bb.view.getUint8(this.bb.vector(this.bbPos + offset) + index) : 0
}
bytesLength(): number {
const offset = this.bb.offset(this.bbPos, 10)
return offset ? this.bb.vectorLength(this.bbPos + offset) : 0
}
bytesArray(): Uint8Array | null {
const offset = this.bb.offset(this.bbPos, 10)
return offset
? new Uint8Array(
this.bb.view.buffer,
this.bb.view.byteOffset + this.bb.vector(this.bbPos + offset),
this.bb.vectorLength(this.bbPos + offset),
)
: null
}
static startWriteBytesCommand(builder: Builder) {
builder.startObject(4)
}
static addPath(builder: Builder, pathOffset: Offset<Path>) {
builder.addFieldOffset(0, pathOffset, Null)
}
static addByteOffset(builder: Builder, byteOffset: bigint) {
builder.addFieldInt64(1, byteOffset, 0n)
}
static addOverwriteExisting(builder: Builder, overwriteExisting: boolean) {
builder.addFieldInt8(2, +overwriteExisting, +false)
}
static addBytes(builder: Builder, bytesOffset: Offset<Uint8Array>) {
builder.addFieldOffset(3, bytesOffset, Null)
}
static createBytesVector(builder: Builder, data: number[] | Uint8Array): Offset<Uint8Array> {
builder.startVector(1, data.length, 1)
// An iterator is more type-safe, but less performant.
for (let i = data.length - 1; i >= 0; i -= 1) {
builder.addInt8(data[i]!)
}
return builder.endVector()
}
static startBytesVector(builder: Builder, numElems: number) {
builder.startVector(1, numElems, 1)
}
static endWriteBytesCommand(builder: Builder): Offset<WriteBytesCommand> {
const offset = builder.endObject<WriteBytesCommand>()
builder.requiredField(offset, 4) // path
builder.requiredField(offset, 10) // bytes
return offset
}
static createWriteBytesCommand(
builder: Builder,
pathOffset: Offset<Path>,
byteOffset: bigint,
overwriteExisting: boolean,
bytesOffset: Offset<Uint8Array>,
): Offset<WriteBytesCommand> {
WriteBytesCommand.startWriteBytesCommand(builder)
WriteBytesCommand.addPath(builder, pathOffset)
WriteBytesCommand.addByteOffset(builder, byteOffset)
WriteBytesCommand.addOverwriteExisting(builder, overwriteExisting)
WriteBytesCommand.addBytes(builder, bytesOffset)
return WriteBytesCommand.endWriteBytesCommand(builder)
}
}
export class WriteBytesReply implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): WriteBytesReply {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsWriteBytesReply(bb: ByteBuffer, obj?: WriteBytesReply): WriteBytesReply {
return (obj ?? new WriteBytesReply()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsWriteBytesReply(
bb: ByteBuffer,
obj?: WriteBytesReply,
): WriteBytesReply {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new WriteBytesReply()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
checksum(obj?: EnsoDigest): EnsoDigest | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset
? (obj ?? new EnsoDigest()).init(this.bb.indirect(this.bbPos + offset), this.bb!)
: null
}
static startWriteBytesReply(builder: Builder) {
builder.startObject(1)
}
static addChecksum(builder: Builder, checksumOffset: Offset<EnsoDigest>) {
builder.addFieldOffset(0, checksumOffset, Null)
}
static endWriteBytesReply(builder: Builder): Offset<WriteBytesReply> {
const offset = builder.endObject<WriteBytesReply>()
builder.requiredField(offset, 4) // checksum
return offset
}
static createWriteBytesReply(
builder: Builder,
checksumOffset: Offset<EnsoDigest>,
): Offset<WriteBytesReply> {
WriteBytesReply.startWriteBytesReply(builder)
WriteBytesReply.addChecksum(builder, checksumOffset)
return WriteBytesReply.endWriteBytesReply(builder)
}
}
export class ReadBytesCommand implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): ReadBytesCommand {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsReadBytesCommand(bb: ByteBuffer, obj?: ReadBytesCommand): ReadBytesCommand {
return (obj ?? new ReadBytesCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsReadBytesCommand(
bb: ByteBuffer,
obj?: ReadBytesCommand,
): ReadBytesCommand {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new ReadBytesCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
segment(obj?: FileSegment): FileSegment | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset
? (obj ?? new FileSegment()).init(this.bb.indirect(this.bbPos + offset), this.bb!)
: null
}
static startReadBytesCommand(builder: Builder) {
builder.startObject(1)
}
static addSegment(builder: Builder, segmentOffset: Offset<FileSegment>) {
builder.addFieldOffset(0, segmentOffset, Null)
}
static endReadBytesCommand(builder: Builder): Offset<ReadBytesCommand> {
const offset = builder.endObject<ReadBytesCommand>()
builder.requiredField(offset, 4) // segment
return offset
}
static createReadBytesCommand(
builder: Builder,
segmentOffset: Offset<FileSegment>,
): Offset<ReadBytesCommand> {
ReadBytesCommand.startReadBytesCommand(builder)
ReadBytesCommand.addSegment(builder, segmentOffset)
return ReadBytesCommand.endReadBytesCommand(builder)
}
}
export class ReadBytesReply implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): ReadBytesReply {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsReadBytesReply(bb: ByteBuffer, obj?: ReadBytesReply): ReadBytesReply {
return (obj ?? new ReadBytesReply()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
static getSizePrefixedRootAsReadBytesReply(bb: ByteBuffer, obj?: ReadBytesReply): ReadBytesReply {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new ReadBytesReply()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
checksum(obj?: EnsoDigest): EnsoDigest | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset
? (obj ?? new EnsoDigest()).init(this.bb.indirect(this.bbPos + offset), this.bb!)
: null
}
bytes(index: number): number | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.view.getUint8(this.bb.vector(this.bbPos + offset) + index) : 0
}
bytesLength(): number {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.vectorLength(this.bbPos + offset) : 0
}
bytesArray(): Uint8Array | null {
const offset = this.bb.offset(this.bbPos, 6)
return offset
? new Uint8Array(
this.bb.view.buffer,
this.bb.view.byteOffset + this.bb.vector(this.bbPos + offset),
this.bb.vectorLength(this.bbPos + offset),
)
: null
}
static startReadBytesReply(builder: Builder) {
builder.startObject(2)
}
static addChecksum(builder: Builder, checksumOffset: Offset<EnsoDigest>) {
builder.addFieldOffset(0, checksumOffset, Null)
}
static addBytes(builder: Builder, bytesOffset: Offset<Uint8Array>) {
builder.addFieldOffset(1, bytesOffset, Null)
}
static createBytesVector(builder: Builder, data: number[] | Uint8Array): Offset<Uint8Array> {
builder.startVector(1, data.length, 1)
// An iterator is more type-safe, but less performant.
for (let i = data.length - 1; i >= 0; i -= 1) {
builder.addInt8(data[i]!)
}
return builder.endVector()
}
static startBytesVector(builder: Builder, numElems: number) {
builder.startVector(1, numElems, 1)
}
static endReadBytesReply(builder: Builder): Offset<ReadBytesReply> {
const offset = builder.endObject<ReadBytesReply>()
builder.requiredField(offset, 4) // checksum
builder.requiredField(offset, 6) // bytes
return offset
}
static createReadBytesReply(
builder: Builder,
checksumOffset: Offset<EnsoDigest>,
bytesOffset: Offset<Uint8Array>,
): Offset<ReadBytesReply> {
ReadBytesReply.startReadBytesReply(builder)
ReadBytesReply.addChecksum(builder, checksumOffset)
ReadBytesReply.addBytes(builder, bytesOffset)
return ReadBytesReply.endReadBytesReply(builder)
}
}
export class ChecksumBytesCommand implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): ChecksumBytesCommand {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsChecksumBytesCommand(
bb: ByteBuffer,
obj?: ChecksumBytesCommand,
): ChecksumBytesCommand {
return (obj ?? new ChecksumBytesCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsChecksumBytesCommand(
bb: ByteBuffer,
obj?: ChecksumBytesCommand,
): ChecksumBytesCommand {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new ChecksumBytesCommand()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
segment(obj?: FileSegment): FileSegment | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset
? (obj ?? new FileSegment()).init(this.bb.indirect(this.bbPos + offset), this.bb!)
: null
}
static startChecksumBytesCommand(builder: Builder) {
builder.startObject(1)
}
static addSegment(builder: Builder, segmentOffset: Offset<FileSegment>) {
builder.addFieldOffset(0, segmentOffset, Null)
}
static endChecksumBytesCommand(builder: Builder): Offset<ChecksumBytesCommand> {
const offset = builder.endObject<ChecksumBytesCommand>()
builder.requiredField(offset, 4) // segment
return offset
}
static createChecksumBytesCommand(
builder: Builder,
segmentOffset: Offset<FileSegment>,
): Offset<ChecksumBytesCommand> {
ChecksumBytesCommand.startChecksumBytesCommand(builder)
ChecksumBytesCommand.addSegment(builder, segmentOffset)
return ChecksumBytesCommand.endChecksumBytesCommand(builder)
}
}
export class ChecksumBytesReply implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): ChecksumBytesReply {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsChecksumBytesReply(bb: ByteBuffer, obj?: ChecksumBytesReply): ChecksumBytesReply {
return (obj ?? new ChecksumBytesReply()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
static getSizePrefixedRootAsChecksumBytesReply(
bb: ByteBuffer,
obj?: ChecksumBytesReply,
): ChecksumBytesReply {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new ChecksumBytesReply()).init(
bb.view.getInt32(bb.position, true) + bb.position,
bb,
)
}
checksum(obj?: EnsoDigest): EnsoDigest | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset
? (obj ?? new EnsoDigest()).init(this.bb.indirect(this.bbPos + offset), this.bb!)
: null
}
static startChecksumBytesReply(builder: Builder) {
builder.startObject(1)
}
static addChecksum(builder: Builder, checksumOffset: Offset<EnsoDigest>) {
builder.addFieldOffset(0, checksumOffset, Null)
}
static endChecksumBytesReply(builder: Builder): Offset<ChecksumBytesReply> {
const offset = builder.endObject<ChecksumBytesReply>()
builder.requiredField(offset, 4) // checksum
return offset
}
static createChecksumBytesReply(
builder: Builder,
checksumOffset: Offset<EnsoDigest>,
): Offset<ChecksumBytesReply> {
ChecksumBytesReply.startChecksumBytesReply(builder)
ChecksumBytesReply.addChecksum(builder, checksumOffset)
return ChecksumBytesReply.endChecksumBytesReply(builder)
}
}
export class EnsoDigest implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): EnsoDigest {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsEnsoDigest(bb: ByteBuffer, obj?: EnsoDigest): EnsoDigest {
return (obj ?? new EnsoDigest()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
static getSizePrefixedRootAsEnsoDigest(bb: ByteBuffer, obj?: EnsoDigest): EnsoDigest {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new EnsoDigest()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
bytes(index: number): number | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? this.bb.view.getUint8(this.bb.vector(this.bbPos + offset) + index) : 0
}
bytesLength(): number {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? this.bb.vectorLength(this.bbPos + offset) : 0
}
bytesArray(): Uint8Array | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset
? new Uint8Array(
this.bb.view.buffer,
this.bb.view.byteOffset + this.bb.vector(this.bbPos + offset),
this.bb.vectorLength(this.bbPos + offset),
)
: null
}
static startEnsoDigest(builder: Builder) {
builder.startObject(1)
}
static addBytes(builder: Builder, bytesOffset: Offset<Uint8Array>) {
builder.addFieldOffset(0, bytesOffset, Null)
}
static createBytesVector(builder: Builder, data: number[] | Uint8Array): Offset<Uint8Array> {
builder.startVector(1, data.length, 1)
// An iterator is more type-safe, but less performant.
for (let i = data.length - 1; i >= 0; i -= 1) {
builder.addInt8(data[i]!)
}
return builder.endVector()
}
static startBytesVector(builder: Builder, numElems: number) {
builder.startVector(1, numElems, 1)
}
static endEnsoDigest(builder: Builder): Offset<EnsoDigest> {
const offset = builder.endObject<EnsoDigest>()
builder.requiredField(offset, 4) // bytes
return offset
}
static createEnsoDigest(builder: Builder, bytesOffset: Offset<Uint8Array>): Offset<EnsoDigest> {
EnsoDigest.startEnsoDigest(builder)
EnsoDigest.addBytes(builder, bytesOffset)
return EnsoDigest.endEnsoDigest(builder)
}
}
export class FileSegment implements Table {
bb!: ByteBuffer
bbPos: number = 0
init(i: number, bb: ByteBuffer): FileSegment {
this.bbPos = i
this.bb = bb
return this
}
static getRootAsFileSegment(bb: ByteBuffer, obj?: FileSegment): FileSegment {
return (obj ?? new FileSegment()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
static getSizePrefixedRootAsFileSegment(bb: ByteBuffer, obj?: FileSegment): FileSegment {
bb.position += SIZE_PREFIX_LENGTH
return (obj ?? new FileSegment()).init(bb.view.getInt32(bb.position, true) + bb.position, bb)
}
path(obj?: Path): Path | null {
const offset = this.bb.offset(this.bbPos, 4)
return offset ? (obj ?? new Path()).init(this.bb.indirect(this.bbPos + offset), this.bb!) : null
}
byteOffset(): bigint {
const offset = this.bb.offset(this.bbPos, 6)
return offset ? this.bb.view.getBigUint64(this.bbPos + offset, true) : 0n
}
length(): bigint {
const offset = this.bb.offset(this.bbPos, 8)
return offset ? this.bb.view.getBigUint64(this.bbPos + offset, true) : 0n
}
static startFileSegment(builder: Builder) {
builder.startObject(3)
}
static addPath(builder: Builder, pathOffset: Offset<Path>) {
builder.addFieldOffset(0, pathOffset, Null)
}
static addByteOffset(builder: Builder, byteOffset: bigint) {
builder.addFieldInt64(1, byteOffset, 0n)
}
static addLength(builder: Builder, length: bigint) {
builder.addFieldInt64(2, length, 0n)
}
static endFileSegment(builder: Builder): Offset<FileSegment> {
const offset = builder.endObject<FileSegment>()
builder.requiredField(offset, 4) // path
return offset
}
static createFileSegment(
builder: Builder,
pathOffset: Offset<Path>,
byteOffset: bigint,
length: bigint,
): Offset<FileSegment> {
FileSegment.startFileSegment(builder)
FileSegment.addPath(builder, pathOffset)
FileSegment.addByteOffset(builder, byteOffset)
FileSegment.addLength(builder, length)
return FileSegment.endFileSegment(builder)
}
}