UNPKG

@coremarine/nmea-parser

Version:
319 lines (313 loc) 19.9 kB
import * as _schemasjs_validator from '@schemasjs/validator'; import * as v from 'valibot'; declare const StringSchema: _schemasjs_validator.Schema<string>; declare const StringArraySchema: _schemasjs_validator.Schema<string[]>; declare const BooleanSchema: _schemasjs_validator.Schema<boolean>; declare const NumberSchema: _schemasjs_validator.Schema<number>; declare const IntegerSchema: _schemasjs_validator.Schema<number>; declare const Int8Schema: _schemasjs_validator.Schema<number>; declare const Int16Schema: _schemasjs_validator.Schema<number>; declare const Int32Schema: _schemasjs_validator.Schema<number>; declare const Int64Schema: _schemasjs_validator.Schema<bigint>; declare const UnsignedIntegerSchema: _schemasjs_validator.Schema<number>; declare const Uint8Schema: _schemasjs_validator.Schema<number>; declare const Uint16Schema: _schemasjs_validator.Schema<number>; declare const Uint32Schema: _schemasjs_validator.Schema<number>; declare const Uint64Schema: _schemasjs_validator.Schema<bigint>; declare const Float32Schema: _schemasjs_validator.Schema<number>; declare const Float64Schema: _schemasjs_validator.Schema<number>; declare const ProtocolFieldTypeSchema: _schemasjs_validator.Schema<"string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64">; declare const ProtocolFieldSchema: _schemasjs_validator.Schema<{ type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64"; name: string; units?: string | undefined; description?: string | undefined; }>; declare const ProtocolSentencePayloadSchema: _schemasjs_validator.Schema<{ type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64"; name: string; units?: string | undefined; description?: string | undefined; }[]>; declare const ProtocolSentenceSchema: _schemasjs_validator.Schema<{ id: string; payload: { type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64"; name: string; units?: string | undefined; description?: string | undefined; }[]; description?: string | undefined; }>; declare const VersionSchema: _schemasjs_validator.Schema<`${number}.${number}.${number}`>; declare const ProtocolSchema: _schemasjs_validator.Schema<{ standard: boolean; sentences: { id: string; payload: { type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64"; name: string; units?: string | undefined; description?: string | undefined; }[]; description?: string | undefined; }[]; protocol: string; version?: string | undefined; }>; declare const ValibotProtocolsFileContentSchema: v.ObjectSchema<{ readonly protocols: v.ArraySchema<v.ObjectSchema<{ readonly protocol: v.StringSchema<undefined>; readonly version: v.OptionalSchema<v.StringSchema<undefined>, never>; readonly standard: v.OptionalSchema<v.BooleanSchema<undefined>, false>; readonly sentences: v.ArraySchema<v.ObjectSchema<{ readonly id: v.StringSchema<undefined>; readonly payload: v.ArraySchema<v.ObjectSchema<{ readonly name: v.StringSchema<undefined>; readonly type: v.PicklistSchema<readonly ["uint8", "uint16", "uint32", "uint64", "int8", "int16", "int32", "int64", "float32", "float64", "string", "boolean"], "invalid type">; readonly units: v.OptionalSchema<v.StringSchema<undefined>, never>; readonly description: v.OptionalSchema<v.StringSchema<undefined>, never>; }, undefined>, "invalid payload">; readonly description: v.OptionalSchema<v.StringSchema<undefined>, never>; }, undefined>, undefined>; }, undefined>, undefined>; }, undefined>; declare const ProtocolsFileContentSchema: _schemasjs_validator.Schema<{ protocols: { standard: boolean; sentences: { id: string; payload: { type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64"; name: string; units?: string | undefined; description?: string | undefined; }[]; description?: string | undefined; }[]; protocol: string; version?: string | undefined; }[]; }>; declare const ProtocolsInputSchema: _schemasjs_validator.Schema<{ protocols?: { standard: boolean; sentences: { id: string; payload: { type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64"; name: string; units?: string | undefined; description?: string | undefined; }[]; description?: string | undefined; }[]; protocol: string; version?: string | undefined; }[] | undefined; file?: string | undefined; content?: string | undefined; }>; declare const StoredSentenceSchema: _schemasjs_validator.Schema<{ id: string; payload: { type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64"; name: string; units?: string | undefined; description?: string | undefined; }[]; protocol: { name: string; standard: boolean; version?: string | undefined; }; description?: string | undefined; }>; declare const MapStoredSentencesSchema: _schemasjs_validator.Schema<v.InferMapOutput<v.StringSchema<undefined>, v.ObjectSchema<{ readonly id: v.StringSchema<undefined>; readonly protocol: v.ObjectSchema<{ readonly name: v.StringSchema<undefined>; readonly standard: v.OptionalSchema<v.BooleanSchema<undefined>, false>; readonly version: v.OptionalSchema<v.StringSchema<undefined>, never>; }, undefined>; readonly payload: v.ArraySchema<v.ObjectSchema<{ readonly name: v.StringSchema<undefined>; readonly type: v.PicklistSchema<readonly ["uint8", "uint16", "uint32", "uint64", "int8", "int16", "int32", "int64", "float32", "float64", "string", "boolean"], "invalid type">; readonly units: v.OptionalSchema<v.StringSchema<undefined>, never>; readonly description: v.OptionalSchema<v.StringSchema<undefined>, never>; }, undefined>, undefined>; readonly description: v.OptionalSchema<v.StringSchema<undefined>, never>; }, undefined>>>; declare const JSONSchemaInputSchema: _schemasjs_validator.Schema<{ path?: string | undefined; filename?: string | undefined; }>; declare const ChecksumSchema: _schemasjs_validator.Schema<{ sample: string; value: number; }>; declare const ValueSchema: _schemasjs_validator.Schema<string | number | bigint | boolean | null>; declare const TalkerSchema: _schemasjs_validator.Schema<{ description: string; value: string; }>; declare const NMEALikeSchema: _schemasjs_validator.Schema<`$${string}*${string}\r\n`>; declare const NMEAParsedFieldchema: _schemasjs_validator.Schema<{ type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64" | "unknown"; units: string; name: string; sample: string; value: string | number | bigint | boolean | null; description?: string | undefined; metadata?: any; }>; declare const NMEAParsedPayloadSchema: _schemasjs_validator.Schema<{ type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64" | "unknown"; units: string; name: string; sample: string; value: string | number | bigint | boolean | null; description?: string | undefined; metadata?: any; }[]>; declare const NMEASentenceSchema: _schemasjs_validator.Schema<{ id: string; payload: { type: "string" | "boolean" | "uint8" | "uint16" | "uint32" | "uint64" | "int8" | "int16" | "int32" | "int64" | "float32" | "float64" | "unknown"; units: string; name: string; sample: string; value: string | number | bigint | boolean | null; description?: string | undefined; metadata?: any; }[]; protocol: { name: string; standard: boolean; version?: string | undefined; }; sample: `$${string}*${string}\r\n`; received: number; checksum: { sample: string; value: number; }; description?: string | undefined; metadata?: any; talker?: { description: string; value: string; } | undefined; }>; type Integer = ReturnType<typeof IntegerSchema.parse>; type Int8 = ReturnType<typeof Int8Schema.parse>; type Int16 = ReturnType<typeof Int16Schema.parse>; type Int32 = ReturnType<typeof Int32Schema.parse>; type Int64 = ReturnType<typeof Int64Schema.parse>; type UnsignedInteger = ReturnType<typeof UnsignedIntegerSchema.parse>; type Uint8 = ReturnType<typeof Uint8Schema.parse>; type Uint16 = ReturnType<typeof Uint16Schema.parse>; type Uint32 = ReturnType<typeof Uint32Schema.parse>; type Uint64 = ReturnType<typeof Uint64Schema.parse>; type Float32 = ReturnType<typeof Float64Schema.parse>; type Float64 = ReturnType<typeof Float32Schema.parse>; type ProtocolFieldType = ReturnType<typeof ProtocolFieldTypeSchema.parse>; type ProtocolField = ReturnType<typeof ProtocolFieldSchema.parse>; type ProtocolSentence = ReturnType<typeof ProtocolSentenceSchema.parse>; type Version = ReturnType<typeof VersionSchema.parse>; type Protocol = ReturnType<typeof ProtocolSchema.parse>; type ProtocolsFileContent = ReturnType<typeof ProtocolsFileContentSchema.parse>; type ProtocolsInput = ReturnType<typeof ProtocolsInputSchema.parse>; type StoredSentence = ReturnType<typeof StoredSentenceSchema.parse>; type StoredPayload = ReturnType<typeof ProtocolSentencePayloadSchema.parse>; type MapStoredSentences = ReturnType<typeof MapStoredSentencesSchema.parse>; type JSONSchemaInput = ReturnType<typeof JSONSchemaInputSchema.parse>; type Checksum = ReturnType<typeof ChecksumSchema.parse>; type Value = ReturnType<typeof ValueSchema.parse>; type Talker = ReturnType<typeof TalkerSchema.parse>; type Field = ReturnType<typeof NMEAParsedFieldchema.parse>; type Payload = ReturnType<typeof NMEAParsedPayloadSchema.parse>; type NMEASentence = ReturnType<typeof NMEASentenceSchema.parse>; type Sentence = StoredSentence & { talker?: Talker; }; type ProtocolOutput = Record<string, StoredSentence[]>; type NMEALike = ReturnType<typeof NMEALikeSchema.parse>; interface NMEAParser { parseData: (data: string) => NMEASentence[]; addProtocols: (protocols: ProtocolsInput) => void; getSentences: () => StoredSentence[]; getSentencesByProtocol: () => ProtocolOutput; getSentence: (id: string) => Sentence | null; getFakeSentenceByID: (id: string) => NMEALike | null; } declare class Parser implements NMEAParser { protected _memory: boolean; get memory(): typeof this._memory; set memory(mem: boolean); protected _buffer: string; protected _bufferLength: number; get bufferLimit(): typeof this._bufferLength; set bufferLimit(limit: number); protected _sentences: MapStoredSentences; constructor(memory?: boolean, limit?: number); private readInternalProtocols; private readProtocols; addProtocols(input: ProtocolsInput): void; parseData(text: string): NMEASentence[]; private getFrames; private getFrame; getSentences(): StoredSentence[]; getSentencesByProtocol(): ProtocolOutput; getSentence(id: string): Sentence | null; getFakeSentenceByID(id: string): NMEALike | null; } declare const FIELD_TYPES: readonly ["uint8", "uint16", "uint32", "uint64", "int8", "int16", "int32", "int64", "float32", "float64", "string", "boolean"]; declare const START_FLAG = "$"; declare const SEPARATOR = ","; declare const DELIMITER = "*"; declare const END_FLAG = "\r\n"; declare const START_FLAG_LENGTH: number; declare const SEPARATOR_LENGTH: number; declare const DELIMITER_LENGTH: number; declare const CHECKSUM_LENGTH = 2; declare const END_FLAG_LENGTH: number; declare const MINIMAL_LENGTH: number; declare const NMEA_ID_LENGTH = 3; declare const NMEA_TALKER_LENGTH = 2; declare const NMEA_SENTENCE_LENGTH: number; declare const TALKERS: readonly [readonly ["AB", "Independent AIS Base Station"], readonly ["AD", "Dependent AIS Base Station"], readonly ["AG", "Autopilot - General"], readonly ["AI", "Mobile AIS Station"], readonly ["AN", "AIS Aid to Navigation"], readonly ["AP", "Autopilot - Magnetic"], readonly ["AR", "AIS Receiving Station"], readonly ["AT", "AIS Transmitting Station"], readonly ["AX", "AIS Simplex Repeater"], readonly ["BD", "BeiDou (China)"], readonly ["BI", "Bilge System"], readonly ["BN", "Bridge navigational watch alarm system"], readonly ["CA", "Central Alarm"], readonly ["CC", "Computer - Programmed Calculator (obsolete)"], readonly ["CD", "Communications - Digital Selective Calling (DSC)"], readonly ["CM", "Computer - Memory Data (obsolete)"], readonly ["CR", "Data Receiver"], readonly ["CS", "Communications - Satellite"], readonly ["CT", "Communications - Radio-Telephone (MF/HF)"], readonly ["CV", "Communications - Radio-Telephone (VHF)"], readonly ["CX", "Communications - Scanning Receiver"], readonly ["DE", "DECCA Navigation (obsolete)"], readonly ["DF", "Direction Finder"], readonly ["DM", "Velocity Sensor, Speed Log, Water, Magnetic"], readonly ["DP", "Dynamiv Position"], readonly ["DU", "Duplex repeater station"], readonly ["EC", "Electronic Chart Display & Information System (ECDIS)"], readonly ["EP", "Emergency Position Indicating Beacon (EPIRB)"], readonly ["ER", "Engine Room Monitoring Systems"], readonly ["FD", "Fire Door"], readonly ["FS", "Fire Sprinkler"], readonly ["GA", "Galileo Positioning System"], readonly ["GB", "BeiDou (China)"], readonly ["GI", "NavIC, IRNSS (India)"], readonly ["GL", "GLONASS, according to IEIC 61162-1"], readonly ["GN", "Combination of multiple satellite systems (NMEA 1083)"], readonly ["GP", "Global Positioning System receiver"], readonly ["GQ", "QZSS regional GPS augmentation system (Japan)"], readonly ["HC", "Heading - Magnetic Compass"], readonly ["HD", "Hull Door"], readonly ["HE", "Heading - North Seeking Gyro"], readonly ["HF", "Heading - Fluxgate"], readonly ["HN", "Heading - Non North Seeking Gyro"], readonly ["HS", "Hull Stress"], readonly ["II", "Integrated Instrumentation"], readonly ["IN", "Integrated Navigation"], readonly ["JA", "Alarm and Monitoring"], readonly ["JB", "Water Monitoring"], readonly ["JC", "Power Management"], readonly ["JD", "Propulsion Control"], readonly ["JE", "Engine Control"], readonly ["JF", "Propulsion Boiler"], readonly ["JG", "Aux Boiler"], readonly ["JH", "Engine Governor"], readonly ["LA", "Loran A (obsolete)"], readonly ["LC", "Loran C (obsolete)"], readonly ["MP", "Microwave Positioning System (obsolete)"], readonly ["MX", "Multiplexer"], readonly ["NL", "Navigation light controller"], readonly ["OM", "OMEGA Navigation System (obsolete)"], readonly ["OS", "Distress Alarm System (obsolete)"], readonly ["QZ", "QZSS regional GPS augmentation system (Japan)"], readonly ["RA", "RADAR and/or ARPA"], readonly ["RB", "Record Book"], readonly ["RC", "Propulsion Machinery"], readonly ["RI", "Rudder Angle Indicator"], readonly ["SA", "Physical Shore AUS Station"], readonly ["SD", "Depth Sounder"], readonly ["SG", "Steering Gear"], readonly ["SN", "Electronic Positioning System, other/general"], readonly ["SS", "Scanning Sounder"], readonly ["ST", "Skytraq debug output"], readonly ["TC", "Track Control"], readonly ["TI", "Turn Rate Indicator"], readonly ["TR", "TRANSIT Navigation System"], readonly ["UP", "Microprocessor controller"], readonly ["VA", "VHF Data Exchange System (VDES), ASM"], readonly ["VD", "Velocity Sensor, Doppler, other/general"], readonly ["VM", "Velocity Sensor, Speed Log, Water, Magnetic"], readonly ["VR", "Voyage Data recorder"], readonly ["VS", "VHF Data Exchange System (VDES), Satellite"], readonly ["VT", "VHF Data Exchange System (VDES), Terrestrial"], readonly ["VW", "Velocity Sensor, Speed Log, Water, Mechanical"], readonly ["WD", "Watertight Door"], readonly ["WI", "Weather Instruments"], readonly ["WL", "Water Level"], readonly ["YC", "Transducer - Temperature (obsolete)"], readonly ["YD", "Transducer - Displacement, Angular or Linear (obsolete)"], readonly ["YF", "Transducer - Frequency (obsolete)"], readonly ["YL", "Transducer - Level (obsolete)"], readonly ["YP", "Transducer - Pressure (obsolete)"], readonly ["YR", "Transducer - Flow Rate (obsolete)"], readonly ["YT", "Transducer - Tachometer (obsolete)"], readonly ["YV", "Transducer - Volume (obsolete)"], readonly ["YX", "Transducer"], readonly ["ZA", "Timekeeper - Atomic Clock"], readonly ["ZC", "Timekeeper - Chronometer"], readonly ["ZQ", "Timekeeper - Quartz"], readonly ["ZV", "Timekeeper - Radio Update, WWV or WWVH"]]; declare const TALKERS_SPECIAL: { P: string; U: string; }; declare const CODE: { readonly A: number; readonly Z: number; readonly a: number; readonly z: number; readonly 0: number; readonly 9: number; }; declare const UINT8_MAX: number; declare const UINT16_MAX: number; declare const UINT32_MAX: number; declare const INT8_MIN: number; declare const INT8_MAX: number; declare const INT16_MIN: number; declare const INT16_MAX: number; declare const INT32_MIN: number; declare const INT32_MAX: number; declare const MAX_FLOAT = 999999999999999; declare const MIN_FLOAT = -999999999999999; declare const MAX_CHARACTERS = 1024; declare const MAX_NMEA_CHARACTERS = 82; declare const UNKNOWN_NMEA_SENTENCE_SCAFOLDING: { id: string; protocol: { name: string; standard: boolean; }; description: string; }; export { BooleanSchema, CHECKSUM_LENGTH, CODE, type Checksum, ChecksumSchema, DELIMITER, DELIMITER_LENGTH, END_FLAG, END_FLAG_LENGTH, FIELD_TYPES, type Field, type Float32, Float32Schema, type Float64, Float64Schema, INT16_MAX, INT16_MIN, INT32_MAX, INT32_MIN, INT8_MAX, INT8_MIN, type Int16, Int16Schema, type Int32, Int32Schema, type Int64, Int64Schema, type Int8, Int8Schema, type Integer, IntegerSchema, type JSONSchemaInput, JSONSchemaInputSchema, MAX_CHARACTERS, MAX_FLOAT, MAX_NMEA_CHARACTERS, MINIMAL_LENGTH, MIN_FLOAT, type MapStoredSentences, MapStoredSentencesSchema, type NMEALike, NMEALikeSchema, NMEAParsedFieldchema, NMEAParsedPayloadSchema, Parser as NMEAParser, type NMEASentence, NMEASentenceSchema, NMEA_ID_LENGTH, NMEA_SENTENCE_LENGTH, NMEA_TALKER_LENGTH, NumberSchema, type Payload, type Protocol, type ProtocolField, ProtocolFieldSchema, type ProtocolFieldType, ProtocolFieldTypeSchema, type ProtocolOutput, ProtocolSchema, type ProtocolSentence, ProtocolSentencePayloadSchema, ProtocolSentenceSchema, type ProtocolsFileContent, ProtocolsFileContentSchema, type ProtocolsInput, ProtocolsInputSchema, SEPARATOR, SEPARATOR_LENGTH, START_FLAG, START_FLAG_LENGTH, type Sentence, type StoredPayload, type StoredSentence, StoredSentenceSchema, StringArraySchema, StringSchema, TALKERS, TALKERS_SPECIAL, type Talker, TalkerSchema, UINT16_MAX, UINT32_MAX, UINT8_MAX, UNKNOWN_NMEA_SENTENCE_SCAFOLDING, type Uint16, Uint16Schema, type Uint32, Uint32Schema, type Uint64, Uint64Schema, type Uint8, Uint8Schema, type UnsignedInteger, UnsignedIntegerSchema, ValibotProtocolsFileContentSchema, type Value, ValueSchema, type Version, VersionSchema };