Prepare electron releases

This commit is contained in:
Thomas Nordquist
2019-01-01 23:48:35 +01:00
parent b2badfd43f
commit 5697b2daea
19 changed files with 10823 additions and 880 deletions

3748
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,15 @@
{
"name": "mqtt-explorer",
"name": "mqtt-explorer-backend",
"version": "1.0.0",
"description": "",
"main": "src/index.ts",
"main": "build/index.js",
"scripts": {
"test": "mocha",
"build": "tsc",
"test-inspect": "mocha --inspect-brk",
"coverage": "nyc mocha",
"debug": "ts-node --inspect ./src/index.ts"
"debug": "ts-node --inspect ./src/index.ts",
"postinstall": "npm run build"
},
"author": "",
"license": "ISC",
@@ -34,23 +36,23 @@
"instrument": true
},
"dependencies": {
"@types/sha1": "^1.1.1",
"@types/socket.io": "^2.1.2",
"mqtt": "^2.18.8",
"sha1": "^1.1.1",
"socket.io": "^2.2.0",
"tslint": "^5.12.0",
"typescript": "^3.2.2"
"socket.io": "^2.2.0"
},
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.18",
"@types/sha1": "^1.1.1",
"@types/socket.io": "^2.1.2",
"chai": "^4.2.0",
"mocha": "^5.2.0",
"nyc": "^13.1.0",
"source-map-support": "^0.5.9",
"ts-node": "^7.0.1",
"tslint-strict-null-checks": "^1.0.1"
"tslint": "^5.12.0",
"tslint-strict-null-checks": "^1.0.1",
"typescript": "^3.2.2"
}
}

View File

@@ -1,10 +1,10 @@
import { DataSourceState } from './'
import { DataSourceStateMachine } from './'
type MessageCallback = (topic: string, payload: Buffer) => void
// A DataSource should automatically reconnect if connection was broken
interface DataSource<DataSourceOptions> {
connect(options: DataSourceOptions): DataSourceState
connect(options: DataSourceOptions): DataSourceStateMachine
disconnect(): void
onMessage(messageCallback: MessageCallback): void
topicSeparator: string

View File

@@ -1,11 +1,13 @@
interface InternalState {
import { EventEmitter } from 'events'
export interface DataSourceState {
connecting: boolean
connected: boolean
error?: Error
}
export class DataSourceState {
private state: InternalState = {
export class DataSourceStateMachine extends EventEmitter {
private state: DataSourceState = {
error: undefined,
connected: false,
connecting: false

View File

@@ -1,5 +1,5 @@
import { Client, connect as mqttConnect } from 'mqtt'
import { DataSource, DataSourceState } from './'
import { DataSource, DataSourceStateMachine } from './'
export interface MqttOptions {
url: string
@@ -15,8 +15,8 @@ export class MqttSource implements DataSource<MqttOptions> {
this.messageCallback = messageCallback
}
public connect(options: MqttOptions): DataSourceState {
const state = new DataSourceState()
public connect(options: MqttOptions): DataSourceStateMachine {
const state = new DataSourceStateMachine()
const client = mqttConnect(options.url, {
resubscribe: false

View File

@@ -1,10 +1,11 @@
import { DataSource } from './DataSource'
import { DataSourceState } from './DataSourceState'
import { DataSourceState, DataSourceStateMachine } from './DataSourceState'
import { MqttOptions, MqttSource } from './MqttSource'
export {
DataSource,
DataSourceState,
DataSourceStateMachine,
MqttOptions,
MqttSource,
}

View File

@@ -1,61 +0,0 @@
import { Tree, TreeNode } from './Model'
export class DotExport {
public static renderNodeInformation(node: TreeNode): string {
return `\t${node.sourceEdge.hash()} [label=${this.renderLabel(node.value)}]`
}
public static toDot(tree: Tree): string {
let i = 1
let leaveEdges = Object.values(tree.edges)
.map(e => e.node)
.map(node => node.leafes())
.reduce((a, b) => a.concat(b), [])
.map(leave => leave.branch())
const allEdges: Array<string> = []
const nodeInformation: {[s: string]: string} = {}
leaveEdges.map(edges => edges.reduce( (prev, current) => {
let currentHash = current.sourceEdge.hash()
nodeInformation[currentHash] = this.renderNodeInformation(current)
if (current && prev) {
allEdges.push(`\t${prev.sourceEdge.hash()} -> ${currentHash} [label=${this.renderLabel(current.sourceEdge.name)}]`)
}
return current
}))
return `strict digraph ethane {
${
[this.renderNodeInformation(tree)]
.concat(Object.values(nodeInformation))
.concat(allEdges)
.join('\n')
}
}`;
}
private static renderLabel(value: any): string {
let str;
if(!isNaN(value)) {
str = value
} else {
str = JSON.stringify(value)
if(str && str.length > 0) {
str = str.slice(1, -1)
}
}
if (!str) {
return '""'
}
if(str.length > 20) {
str = str.slice(0, 20)+'…'
}
if (str[0] !== '"') {
str = `"${str}"`
}
return str
}
}

View File

@@ -3,15 +3,13 @@ import { MqttSource, DataSource } from './DataSource'
import * as socketIO from 'socket.io'
const server = require('http').createServer();
let tree = new Tree()
const http = require('http')
let options = {url: 'mqtt://nodered'}
let dataSource = new MqttSource()
let count = 200
const a: Array<any> = []
const server = http.createServer()
const io = socketIO(server)
io.on('connection', client => {
console.log('connection')