move sparkplug protocol to js file as file is not included when packaging

maybe there is a better way to resolve this..
This commit is contained in:
Björn Dalfors
2024-04-02 13:01:23 +02:00
parent a63b12b266
commit 1b7c9c52f6
2 changed files with 203 additions and 3 deletions

View File

@@ -1,10 +1,9 @@
import { readFileSync } from 'fs'
import * as protobuf from 'protobufjs'
import protocol from './sparkplugb.proto'
import { Base64Message } from './Base64Message'
import { Decoder } from './Decoder'
const buffer = readFileSync(require.resolve('../../../../res/sparkplug_b.proto'))
const root = protobuf.parse(buffer.toString()).root
const root = protobuf.parse(protocol).root
export let SparkplugPayload = root.lookupType('com.cirruslink.sparkplug.protobuf.Payload')
export const SparkplugDecoder = {
@@ -18,5 +17,6 @@ export const SparkplugDecoder = {
} catch {
// ignore
}
return undefined
},
}