21 Commits

Author SHA1 Message Date
Joel Wetzell
36b085ef5c Merge pull request #130 from jwetzell/dependabot/go_modules/modernc.org/sqlite-1.48.1
Bump modernc.org/sqlite from 1.48.0 to 1.48.1
2026-04-12 20:17:36 -05:00
dependabot[bot]
65f2259cf4 Bump modernc.org/sqlite from 1.48.0 to 1.48.1
Bumps [modernc.org/sqlite](https://gitlab.com/cznic/sqlite) from 1.48.0 to 1.48.1.
- [Changelog](https://gitlab.com/cznic/sqlite/blob/master/CHANGELOG.md)
- [Commits](https://gitlab.com/cznic/sqlite/compare/v1.48.0...v1.48.1)

---
updated-dependencies:
- dependency-name: modernc.org/sqlite
  dependency-version: 1.48.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-13 01:13:28 +00:00
Joel Wetzell
2b62c593e2 Merge pull request #131 from jwetzell/dependabot/go_modules/modernc.org/quickjs-0.17.2
Bump modernc.org/quickjs from 0.17.1 to 0.17.2
2026-04-12 20:12:16 -05:00
dependabot[bot]
dbcbecbf11 Bump modernc.org/quickjs from 0.17.1 to 0.17.2
Bumps [modernc.org/quickjs](https://gitlab.com/cznic/quickjs) from 0.17.1 to 0.17.2.
- [Commits](https://gitlab.com/cznic/quickjs/compare/v0.17.1...v0.17.2)

---
updated-dependencies:
- dependency-name: modernc.org/quickjs
  dependency-version: 0.17.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-13 01:10:21 +00:00
Joel Wetzell
9f9f941d13 Merge pull request #127 from jwetzell/dependabot/github_actions/docker/login-action-4.1.0
Bump docker/login-action from 4.0.0 to 4.1.0
2026-04-12 20:09:59 -05:00
Joel Wetzell
7bb0b49459 Merge pull request #132 from jwetzell/dependabot/go_modules/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp-1.43.0
Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp from 1.42.0 to 1.43.0
2026-04-12 20:08:58 -05:00
Joel Wetzell
91a89379c7 update go version 2026-04-08 07:32:29 -05:00
dependabot[bot]
ebba7cd8fc Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
Bumps [go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp](https://github.com/open-telemetry/opentelemetry-go) from 1.42.0 to 1.43.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.42.0...v1.43.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
  dependency-version: 1.43.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-07 17:25:41 +00:00
dependabot[bot]
5eab29b3b8 Bump docker/login-action from 4.0.0 to 4.1.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](b45d80f862...4907a6ddec)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 4.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-07 17:24:56 +00:00
Joel Wetzell
b5df389cb2 Merge pull request #123 from jwetzell/dependabot/go_modules/modernc.org/sqlite-1.48.0
Bump modernc.org/sqlite from 1.47.0 to 1.48.0
2026-04-03 19:49:45 -05:00
Joel Wetzell
c1692b291e Merge pull request #124 from jwetzell/dependabot/go_modules/github.com/nats-io/nats.go-1.50.0
Bump github.com/nats-io/nats.go from 1.49.0 to 1.50.0
2026-04-03 19:49:22 -05:00
Joel Wetzell
06d5dcf3e1 Merge pull request #125 from jwetzell/dependabot/go_modules/github.com/urfave/cli/v3-3.8.0
Bump github.com/urfave/cli/v3 from 3.7.0 to 3.8.0
2026-04-03 19:49:12 -05:00
Joel Wetzell
2222d09078 Merge pull request #126 from jwetzell/dependabot/go_modules/github.com/emiago/sipgo-1.3.0
Bump github.com/emiago/sipgo from 1.2.1 to 1.3.0
2026-04-03 19:48:53 -05:00
dependabot[bot]
b2598ffede Bump github.com/emiago/sipgo from 1.2.1 to 1.3.0
Bumps [github.com/emiago/sipgo](https://github.com/emiago/sipgo) from 1.2.1 to 1.3.0.
- [Release notes](https://github.com/emiago/sipgo/releases)
- [Commits](https://github.com/emiago/sipgo/compare/v1.2.1...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/emiago/sipgo
  dependency-version: 1.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-31 17:26:39 +00:00
dependabot[bot]
bab0c72d97 Bump github.com/urfave/cli/v3 from 3.7.0 to 3.8.0
Bumps [github.com/urfave/cli/v3](https://github.com/urfave/cli) from 3.7.0 to 3.8.0.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v3.7.0...v3.8.0)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v3
  dependency-version: 3.8.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-31 17:26:34 +00:00
dependabot[bot]
62d86bc79d Bump github.com/nats-io/nats.go from 1.49.0 to 1.50.0
Bumps [github.com/nats-io/nats.go](https://github.com/nats-io/nats.go) from 1.49.0 to 1.50.0.
- [Release notes](https://github.com/nats-io/nats.go/releases)
- [Commits](https://github.com/nats-io/nats.go/compare/v1.49.0...v1.50.0)

---
updated-dependencies:
- dependency-name: github.com/nats-io/nats.go
  dependency-version: 1.50.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-31 17:26:25 +00:00
dependabot[bot]
5fe6a35b5b Bump modernc.org/sqlite from 1.47.0 to 1.48.0
Bumps [modernc.org/sqlite](https://gitlab.com/cznic/sqlite) from 1.47.0 to 1.48.0.
- [Changelog](https://gitlab.com/cznic/sqlite/blob/master/CHANGELOG.md)
- [Commits](https://gitlab.com/cznic/sqlite/compare/v1.47.0...v1.48.0)

---
updated-dependencies:
- dependency-name: modernc.org/sqlite
  dependency-version: 1.48.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-31 17:26:14 +00:00
Joel Wetzell
f57f9d8ce5 fix additionProperties in JSONSchema and add IDs to everything 2026-03-30 20:58:39 -05:00
Joel Wetzell
979addeff8 set default for whole api section of config 2026-03-30 20:17:36 -05:00
Joel Wetzell
af92dbcce3 Merge pull request #122 from jwetzell/chore/separate-midi-message-create
convert midi.message.create into separate processors
2026-03-28 15:44:58 -05:00
Joel Wetzell
87947527d6 conver midi.message.create into separate processors 2026-03-28 15:43:13 -05:00
78 changed files with 1276 additions and 1300 deletions

View File

@@ -43,7 +43,7 @@ jobs:
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to Docker Hub
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

View File

@@ -1,4 +1,4 @@
ARG GO_VERSION=1.26.0
ARG GO_VERSION=1.26.2
FROM golang:${GO_VERSION}-alpine AS build
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /build

View File

@@ -1,5 +0,0 @@
package main
import "syscall/js"
var document = js.Global().Get("document")

View File

@@ -1,71 +0,0 @@
<html>
<head>
<meta charset="utf-8" />
<script src="wasm_exec.js"></script>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
height: 100vh;
margin: 0;
padding: 0;
}
#output-container {
flex-grow: 1;
}
#log-container {
background-color: #1e1e1e;
width: 100%;
height: 200px;
overflow-y: auto;
overflow-x: scroll;
box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}
#logs {
margin: 0;
padding-left: 2px;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 13px;
line-height: 1.4;
color: #a8cc8c;
}
</style>
<script>
const container = document.getElementById("log-container");
function isScrolledToBottom() {
const scrollThreshold = 1;
return (
container.scrollHeight - container.clientHeight <=
container.scrollTop + scrollThreshold
);
}
function scrollToBottomManual() {
const container = document.getElementById("log-container");
// Set scrollTop to the maximum value possible (scrollHeight - clientHeight)
container.scrollTop = container.scrollHeight - container.clientHeight;
}
</script>
</head>
<body>
<div id="output-container">
<div id="output"></div>
</div>
<div id="log-container">
<pre id="logs"></pre>
</div>
<script>
const go = new Go();
WebAssembly.instantiateStreaming(
fetch("main.wasm"),
go.importObject,
).then((result) => {
go.run(result.instance);
});
</script>
</body>
</html>

View File

@@ -1,42 +0,0 @@
package main
import "syscall/js"
type LogWriter struct {
Element js.Value
Container js.Value
}
func (pw *LogWriter) ScrollToBottom() {
scrollHeight := pw.Container.Get("scrollHeight").Int()
clientHeight := pw.Container.Get("clientHeight").Int()
pw.Container.Set("scrollTop", scrollHeight-clientHeight)
}
func (pw *LogWriter) IsScrolledToBottom() bool {
scrollHeight := pw.Container.Get("scrollHeight").Int()
clientHeight := pw.Container.Get("clientHeight").Int()
scrollTop := pw.Container.Get("scrollTop").Int()
return scrollHeight-clientHeight <= scrollTop+25
}
func (pw *LogWriter) Write(p []byte) (n int, err error) {
if !pw.Element.IsUndefined() {
currentText := pw.Element.Get("textContent").String()
newText := currentText + string(p)
pw.Element.Set("textContent", newText)
if pw.IsScrolledToBottom() {
pw.ScrollToBottom()
}
}
return len(p), nil
}
func NewLogWriter(id string) *LogWriter {
element := document.Call("getElementById", id)
container := element.Get("parentElement")
return &LogWriter{
Element: element,
Container: container,
}
}

View File

@@ -1,71 +0,0 @@
package main
import (
"context"
"fmt"
"log/slog"
"github.com/jwetzell/showbridge-go"
"github.com/jwetzell/showbridge-go/internal/config"
)
func main() {
slog.SetLogLoggerLevel(slog.LevelDebug)
slog.SetDefault(slog.New(slog.NewTextHandler(NewLogWriter("logs"), &slog.HandlerOptions{
Level: slog.LevelDebug,
})))
router, moduleConfigErrors, routeConfigErrors := showbridge.NewRouter(config.Config{
Api: config.ApiConfig{
Enabled: false,
Port: 0,
},
Modules: []config.ModuleConfig{
{
Id: "midi",
Type: "midi.input",
Params: map[string]any{
"port": "Launchpad S",
},
},
},
Routes: []config.RouteConfig{
{
Input: "midi",
Processors: []config.ProcessorConfig{
{
Type: "debug.log",
},
{
Type: "web.set",
Params: map[string]any{
"id": "output",
"property": "textContent",
"value": "{{.Payload}}",
},
},
},
},
},
})
if len(moduleConfigErrors) > 0 {
for _, err := range moduleConfigErrors {
println("Module config error:", err.Error)
}
}
if len(routeConfigErrors) > 0 {
for _, err := range routeConfigErrors {
println("Route config error:", err.Error)
}
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go func() {
router.Start(ctx)
fmt.Println("router stopped")
}()
<-ctx.Done()
}

38
go.mod
View File

@@ -1,11 +1,11 @@
module github.com/jwetzell/showbridge-go
go 1.26.0
go 1.26.2
require (
github.com/eclipse/paho.mqtt.golang v1.5.1
github.com/emiago/diago v0.28.0
github.com/emiago/sipgo v1.2.1
github.com/emiago/sipgo v1.3.0
github.com/expr-lang/expr v1.17.8
github.com/extism/go-sdk v1.7.1
github.com/google/jsonschema-go v0.4.2
@@ -15,17 +15,17 @@ require (
github.com/jwetzell/osc-go v0.2.0
github.com/jwetzell/psn-go v0.3.0
github.com/nats-io/nats-server/v2 v2.12.6
github.com/nats-io/nats.go v1.49.0
github.com/nats-io/nats.go v1.50.0
github.com/redis/go-redis/v9 v9.18.0
github.com/urfave/cli/v3 v3.7.0
github.com/urfave/cli/v3 v3.8.0
gitlab.com/gomidi/midi/v2 v2.3.23
go.bug.st/serial v1.6.4
go.opentelemetry.io/otel v1.42.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.42.0
go.opentelemetry.io/otel/sdk v1.42.0
go.opentelemetry.io/otel/trace v1.42.0
modernc.org/quickjs v0.17.1
modernc.org/sqlite v1.47.0
go.opentelemetry.io/otel v1.43.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0
go.opentelemetry.io/otel/sdk v1.43.0
go.opentelemetry.io/otel/trace v1.43.0
modernc.org/quickjs v0.17.2
modernc.org/sqlite v1.48.2
sigs.k8s.io/yaml v1.6.0
)
@@ -50,7 +50,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca // indirect
github.com/icholy/digest v1.1.0 // indirect
github.com/klauspost/compress v1.18.4 // indirect
github.com/klauspost/compress v1.18.5 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/minio/highwayhash v1.0.4-0.20251030100505-070ab1a87a76 // indirect
github.com/nats-io/jwt/v2 v2.8.1 // indirect
@@ -69,24 +69,24 @@ require (
github.com/tetratelabs/wazero v1.9.0 // indirect
github.com/zaf/g711 v1.4.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0 // indirect
go.opentelemetry.io/otel/metric v1.42.0 // indirect
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
golang.org/x/crypto v0.49.0 // indirect
golang.org/x/net v0.51.0 // indirect
golang.org/x/net v0.52.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/text v0.35.0 // indirect
golang.org/x/time v0.15.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 // indirect
google.golang.org/grpc v1.79.2 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
google.golang.org/grpc v1.80.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/hraban/opus.v2 v2.0.0-20230925203106-0188a62cb302 // indirect
modernc.org/libc v1.70.0 // indirect
modernc.org/libquickjs v0.12.3 // indirect
modernc.org/libquickjs v0.12.4 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
)

80
go.sum
View File

@@ -24,8 +24,8 @@ github.com/emiago/diago v0.28.0 h1:VCiimhFYLoBTsxH6WrufLSt6tKWG8Fv7LfCkZHqct2E=
github.com/emiago/diago v0.28.0/go.mod h1:eQT6j9co9PMQ/25aUiM2jpvwxxWFXLWi2w5R3lZNmKg=
github.com/emiago/dtls/v3 v3.0.0-20260122183559-8b8d23e359c0 h1:o4LxpUnZ1zxiQ+Qjc9kLwXcjz31NGAHmnZ7xoJto3VM=
github.com/emiago/dtls/v3 v3.0.0-20260122183559-8b8d23e359c0/go.mod h1:ydcZ977eS1I6uOWodzMuw30BwvNAzT9su/xcNYSJqjA=
github.com/emiago/sipgo v1.2.1 h1:5JTwogbe3yQFA3sjBVueN2Q4WTU350tGeBwPYT8HMv0=
github.com/emiago/sipgo v1.2.1/go.mod h1:DuwAxBZhKMqIzQFPGZb1MVAGU6Wuxj64oTOhd5dx/FY=
github.com/emiago/sipgo v1.3.0 h1:efxQln1wJqcIU9+N+4eTKNtTZ7YsRsg8yc+0XYqyuQU=
github.com/emiago/sipgo v1.3.0/go.mod h1:DuwAxBZhKMqIzQFPGZb1MVAGU6Wuxj64oTOhd5dx/FY=
github.com/expr-lang/expr v1.17.8 h1:W1loDTT+0PQf5YteHSTpju2qfUfNoBt4yw9+wOEU9VM=
github.com/expr-lang/expr v1.17.8/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
github.com/extism/go-sdk v1.7.1 h1:lWJos6uY+tRFdlIHR+SJjwFDApY7OypS/2nMhiVQ9Sw=
@@ -75,8 +75,8 @@ github.com/jwetzell/osc-go v0.2.0 h1:4as+BYCeZhEddFczGveP5yZZxvY728Uavz+ZSLZfOII
github.com/jwetzell/osc-go v0.2.0/go.mod h1:D3ZIXYB12bt4S35lKFUqgCFbF1Y+9Ld0sOhHA9mGZZM=
github.com/jwetzell/psn-go v0.3.0 h1:WVpCEmExYE8a+I5hQak5jNJJp2x35VdGX/VuMUKPmhY=
github.com/jwetzell/psn-go v0.3.0/go.mod h1:bcEAeti4sQM375buujb3mIfmUstD4Aby18gq3ENb6+o=
github.com/klauspost/compress v1.18.4 h1:RPhnKRAQ4Fh8zU2FY/6ZFDwTVTxgJ/EMydqSTzE9a2c=
github.com/klauspost/compress v1.18.4/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE=
github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@@ -91,8 +91,8 @@ github.com/nats-io/jwt/v2 v2.8.1 h1:V0xpGuD/N8Mi+fQNDynXohVvp7ZztevW5io8CUWlPmU=
github.com/nats-io/jwt/v2 v2.8.1/go.mod h1:nWnOEEiVMiKHQpnAy4eXlizVEtSfzacZ1Q43LIRavZg=
github.com/nats-io/nats-server/v2 v2.12.6 h1:Egbx9Vl7Ch8wTtpXPGqbehkZ+IncKqShUxvrt1+Enc8=
github.com/nats-io/nats-server/v2 v2.12.6/go.mod h1:4HPlrvtmSO3yd7KcElDNMx9kv5EBJBnJJzQPptXlheo=
github.com/nats-io/nats.go v1.49.0 h1:yh/WvY59gXqYpgl33ZI+XoVPKyut/IcEaqtsiuTJpoE=
github.com/nats-io/nats.go v1.49.0/go.mod h1:fDCn3mN5cY8HooHwE2ukiLb4p4G4ImmzvXyJt+tGwdw=
github.com/nats-io/nats.go v1.50.0 h1:5zAeQrTvyrKrWLJ0fu02W3br8ym57qf7csDzgLOpcds=
github.com/nats-io/nats.go v1.50.0/go.mod h1:26HypzazeOkyO3/mqd1zZd53STJN0EjCYF9Uy2ZOBno=
github.com/nats-io/nkeys v0.4.15 h1:JACV5jRVO9V856KOapQ7x+EY8Jo3qw1vJt/9Jpwzkk4=
github.com/nats-io/nkeys v0.4.15/go.mod h1:CpMchTXC9fxA5zrMo4KpySxNjiDVvr8ANOSZdiNfUrs=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
@@ -127,8 +127,8 @@ github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 h1:ZF+QBjOI+tILZ
github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834/go.mod h1:m9ymHTgNSEjuxvw8E7WWe4Pl4hZQHXONY8wE6dMLaRk=
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
github.com/urfave/cli/v3 v3.7.0 h1:AGSnbUyjtLiM+WJUb4dzXKldl/gL+F8OwmRDtVr6g2U=
github.com/urfave/cli/v3 v3.7.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
github.com/urfave/cli/v3 v3.8.0 h1:XqKPrm0q4P0q5JpoclYoCAv0/MIvH/jZ2umzuf8pNTI=
github.com/urfave/cli/v3 v3.8.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
github.com/zaf/g711 v1.4.0 h1:XZYkjjiAg9QTBnHqEg37m2I9q3IIDv5JRYXs2N8ma7c=
github.com/zaf/g711 v1.4.0/go.mod h1:eCDXt3dSp/kYYAoooba7ukD/Q75jvAaS4WOMr0l1Roo=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
@@ -139,22 +139,22 @@ go.bug.st/serial v1.6.4 h1:7FmqNPgVp3pu2Jz5PoPtbZ9jJO5gnEnZIvnI1lzve8A=
go.bug.st/serial v1.6.4/go.mod h1:nofMJxTeNVny/m6+KaafC6vJGj3miwQZ6vW4BZUGJPI=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel v1.42.0 h1:lSQGzTgVR3+sgJDAU/7/ZMjN9Z+vUip7leaqBKy4sho=
go.opentelemetry.io/otel v1.42.0/go.mod h1:lJNsdRMxCUIWuMlVJWzecSMuNjE7dOYyWlqOXWkdqCc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0 h1:THuZiwpQZuHPul65w4WcwEnkX2QIuMT+UFoOrygtoJw=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0/go.mod h1:J2pvYM5NGHofZ2/Ru6zw/TNWnEQp5crgyDeSrYpXkAw=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.42.0 h1:uLXP+3mghfMf7XmV4PkGfFhFKuNWoCvvx5wP/wOXo0o=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.42.0/go.mod h1:v0Tj04armyT59mnURNUJf7RCKcKzq+lgJs6QSjHjaTc=
go.opentelemetry.io/otel/metric v1.42.0 h1:2jXG+3oZLNXEPfNmnpxKDeZsFI5o4J+nz6xUlaFdF/4=
go.opentelemetry.io/otel/metric v1.42.0/go.mod h1:RlUN/7vTU7Ao/diDkEpQpnz3/92J9ko05BIwxYa2SSI=
go.opentelemetry.io/otel/sdk v1.42.0 h1:LyC8+jqk6UJwdrI/8VydAq/hvkFKNHZVIWuslJXYsDo=
go.opentelemetry.io/otel/sdk v1.42.0/go.mod h1:rGHCAxd9DAph0joO4W6OPwxjNTYWghRWmkHuGbayMts=
go.opentelemetry.io/otel/sdk/metric v1.42.0 h1:D/1QR46Clz6ajyZ3G8SgNlTJKBdGp84q9RKCAZ3YGuA=
go.opentelemetry.io/otel/sdk/metric v1.42.0/go.mod h1:Ua6AAlDKdZ7tdvaQKfSmnFTdHx37+J4ba8MwVCYM5hc=
go.opentelemetry.io/otel/trace v1.42.0 h1:OUCgIPt+mzOnaUTpOQcBiM/PLQ/Op7oq6g4LenLmOYY=
go.opentelemetry.io/otel/trace v1.42.0/go.mod h1:f3K9S+IFqnumBkKhRJMeaZeNk9epyhnCmQh/EysQCdc=
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 h1:88Y4s2C8oTui1LGM6bTWkw0ICGcOLCAI5l6zsD1j20k=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0/go.mod h1:Vl1/iaggsuRlrHf/hfPJPvVag77kKyvrLeD10kpMl+A=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0 h1:3iZJKlCZufyRzPzlQhUIWVmfltrXuGyfjREgGP3UUjc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.43.0/go.mod h1:/G+nUPfhq2e+qiXMGxMwumDrP5jtzU+mWN7/sjT2rak=
go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=
go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg=
go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw=
go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
@@ -167,8 +167,8 @@ golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -181,14 +181,14 @@ golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 h1:JLQynH/LBHfCTSbDWl+py8C+Rg/k1OVH3xfcaiANuF0=
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57/go.mod h1:kSJwQxqmFXeo79zOmbrALdflXQeAYcUbgS7PbpMknCY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 h1:mWPCjDEyshlQYzBpMNHaEof6UX1PmHcaUODUywQ0uac=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=
google.golang.org/grpc v1.79.2 h1:fRMD94s2tITpyJGtBBn7MkMseNpOZU8ZxgC3MMBaXRU=
google.golang.org/grpc v1.79.2/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 h1:VPWxll4HlMw1Vs/qXtN7BvhZqsS9cdAittCNvVENElA=
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:7QBABkRtR8z+TEnmXTqIqwJLlzrZKVfAUm7tY3yGv0M=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 h1:m8qni9SQFH0tJc1X0vmnpw/0t+AImlSvp30sEupozUg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM=
google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -214,20 +214,20 @@ modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
modernc.org/libc v1.70.0 h1:U58NawXqXbgpZ/dcdS9kMshu08aiA6b7gusEusqzNkw=
modernc.org/libc v1.70.0/go.mod h1:OVmxFGP1CI/Z4L3E0Q3Mf1PDE0BucwMkcXjjLntvHJo=
modernc.org/libquickjs v0.12.3 h1:2IU9B6njBmce2PuYttJDkXeoLRV9WnvgP+eU5HAC8YI=
modernc.org/libquickjs v0.12.3/go.mod h1:iCsgVxnHTX3i0YPxxHBmJk0GLA5sVUHXWI/090UXgeE=
modernc.org/libquickjs v0.12.4 h1:WQ2XP6pAscvtHKPEVuHTf8NiAl5nMomKgIL6790r7AQ=
modernc.org/libquickjs v0.12.4/go.mod h1:MqdjijqGUwLw+r86+YbFLLj7vKZhVHEKRs8XOsnM/n8=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/quickjs v0.17.1 h1:CbYnbTf7ksZk9YZ1rRM2Ab1Zfi+X6s50kXiOhpd2NIg=
modernc.org/quickjs v0.17.1/go.mod h1:hATT7DIJc33I5Q/Fjffhm0tpUHNSqdKHma/ossibTA0=
modernc.org/quickjs v0.17.2 h1:LrhCQ763clXttVFFYdfnwAATM4JFv/vPKee/tLsFFIE=
modernc.org/quickjs v0.17.2/go.mod h1:h8zcP/sP8AZkDvtMXwIoUV/g5pWTPqivz0PLU070URQ=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.47.0 h1:R1XyaNpoW4Et9yly+I2EeX7pBza/w+pmYee/0HJDyKk=
modernc.org/sqlite v1.47.0/go.mod h1:hWjRO6Tj/5Ik8ieqxQybiEOUXy0NJFNp2tpvVpKlvig=
modernc.org/sqlite v1.48.2 h1:5CnW4uP8joZtA0LedVqLbZV5GD7F/0x91AXeSyjoh5c=
modernc.org/sqlite v1.48.2/go.mod h1:hWjRO6Tj/5Ik8ieqxQybiEOUXy0NJFNp2tpvVpKlvig=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -37,7 +35,8 @@ func init() {
MinLength: jsonschema.Ptr(1),
},
},
Required: []string{"dsn"},
Required: []string{"dsn"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -1,7 +0,0 @@
//go:build cgo
package module
import (
_ "gitlab.com/gomidi/midi/v2/drivers/rtmididrv"
)

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -71,7 +69,7 @@ func init() {
},
},
Required: []string{"port"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -1,4 +1,4 @@
//go:build cgo || js
//go:build cgo
package module
@@ -12,6 +12,7 @@ import (
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"gitlab.com/gomidi/midi/v2"
_ "gitlab.com/gomidi/midi/v2/drivers/rtmididrv"
)
type MIDIInput struct {
@@ -37,7 +38,7 @@ func init() {
},
},
Required: []string{"port"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -1,4 +1,4 @@
//go:build cgo || js
//go:build cgo
package module
@@ -12,6 +12,7 @@ import (
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"gitlab.com/gomidi/midi/v2"
_ "gitlab.com/gomidi/midi/v2/drivers/rtmididrv"
)
type MIDIOutput struct {
@@ -37,7 +38,7 @@ func init() {
},
},
Required: []string{"port"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -47,7 +45,7 @@ func init() {
},
},
Required: []string{"broker", "topic", "clientId"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -42,7 +40,7 @@ func init() {
},
},
Required: []string{"url", "subject"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -48,9 +46,8 @@ func init() {
Default: json.RawMessage(`4222`),
},
},
Required: []string{},
AdditionalProperties: nil,
Required: []string{},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(moduleConfig config.ModuleConfig) (common.Module, error) {
params := moduleConfig.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -29,7 +27,6 @@ func init() {
Type: "psn.client",
Title: "PosiStageNet Client",
New: func(config config.ModuleConfig) (common.Module, error) {
return &PSNClient{config: config, decoder: psn.NewDecoder(), logger: CreateLogger(config)}, nil
},
})

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -42,7 +40,7 @@ func init() {
},
},
Required: []string{"host", "port"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -45,7 +45,7 @@ func init() {
},
},
Required: []string{"port", "baudRate"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -79,7 +77,7 @@ func init() {
},
},
Required: []string{},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(moduleConfig config.ModuleConfig) (common.Module, error) {
params := moduleConfig.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -85,7 +83,7 @@ func init() {
},
},
Required: []string{"separator"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(moduleConfig config.ModuleConfig) (common.Module, error) {
params := moduleConfig.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -51,7 +49,7 @@ func init() {
},
},
Required: []string{"host", "port", "framing"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -59,7 +57,7 @@ func init() {
},
},
Required: []string{"port", "framing"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(moduleConfig config.ModuleConfig) (common.Module, error) {
params := moduleConfig.Params

View File

@@ -36,7 +36,7 @@ func init() {
},
},
Required: []string{"duration"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -36,7 +36,7 @@ func init() {
},
},
Required: []string{"duration"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params
@@ -64,7 +64,7 @@ func (t *TimeTimer) Start(ctx context.Context) error {
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
if !ok {
return errors.New("time.timer unable to get router from context")
return errors.New("net.tcp.client unable to get router from context")
}
t.router = router
moduleContext, cancel := context.WithCancel(ctx)

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -44,7 +42,7 @@ func init() {
},
},
Required: []string{"host", "port"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -44,7 +42,7 @@ func init() {
},
},
Required: []string{"ip", "port"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(moduleConfig config.ModuleConfig) (common.Module, error) {
params := moduleConfig.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package module
import (
@@ -53,7 +51,7 @@ func init() {
},
},
Required: []string{"port"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(moduleConfig config.ModuleConfig) (common.Module, error) {
params := moduleConfig.Params

View File

@@ -1,91 +0,0 @@
//go:build js
package module
import (
"context"
"errors"
"fmt"
"log/slog"
"syscall/js"
"time"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
)
type WebOnClick struct {
config config.ModuleConfig
ctx context.Context
router common.RouteIO
logger *slog.Logger
ElementId string
}
func init() {
RegisterModule(ModuleRegistration{
Type: "web.onclick",
Title: "On Click",
ParamsSchema: &jsonschema.Schema{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"id": {
Title: "Element ID",
Type: "string",
Description: "ID of the HTML element to attach the click listener to",
},
},
Required: []string{"duration"},
AdditionalProperties: nil,
},
New: func(config config.ModuleConfig) (common.Module, error) {
params := config.Params
idString, err := params.GetString("id")
if err != nil {
return nil, fmt.Errorf("web.onclick id error: %w", err)
}
return &WebOnClick{ElementId: idString, config: config, logger: CreateLogger(config)}, nil
},
})
}
func (woc *WebOnClick) Id() string {
return woc.config.Id
}
func (woc *WebOnClick) Type() string {
return woc.config.Type
}
func (woc *WebOnClick) Start(ctx context.Context) error {
woc.logger.Debug("running")
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
if !ok {
return errors.New("net.tcp.client unable to get router from context")
}
woc.router = router
woc.ctx = ctx
element := js.Global().Get("document").Call("getElementById", woc.ElementId)
if element.IsNull() || element.IsUndefined() {
return fmt.Errorf("web.onclick unable to find element with id: %s", woc.ElementId)
}
element.Set("onclick", js.FuncOf(func(js.Value, []js.Value) interface{} {
if woc.router != nil {
woc.router.HandleInput(woc.ctx, woc.Id(), time.Now())
}
return nil
}))
<-ctx.Done()
return nil
}
func (woc *WebOnClick) Stop() {
}

View File

@@ -1,7 +0,0 @@
//go:build js
package module
import (
_ "gitlab.com/gomidi/midi/v2/drivers/webmididrv"
)

View File

@@ -1,5 +1,3 @@
//go:build !js
package processor
import (

View File

@@ -1,5 +1,3 @@
//go:build !js
package processor
import (

View File

@@ -59,7 +59,7 @@ func init() {
},
},
Required: []string{"expression"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -51,7 +51,7 @@ func init() {
},
},
Required: []string{"pattern"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -53,7 +53,7 @@ func init() {
Default: json.RawMessage("64"),
},
},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(moduleConfig config.ProcessorConfig) (Processor, error) {
params := moduleConfig.Params

View File

@@ -61,7 +61,7 @@ func init() {
},
},
Required: []string{"min", "max"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(processorConfig config.ProcessorConfig) (Processor, error) {
params := processorConfig.Params

View File

@@ -259,7 +259,7 @@ func init() {
"zoom",
"focus",
},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {

View File

@@ -21,11 +21,6 @@ type HTTPRequestDo struct {
URL *template.Template
}
type HTTPResponse struct {
Status int
Body []byte
}
func (hrd *HTTPRequestDo) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
@@ -92,7 +87,7 @@ func init() {
},
},
Required: []string{"method", "url"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package processor
import (
@@ -19,6 +17,11 @@ type HTTPResponseCreate struct {
config config.ProcessorConfig
}
type HTTPResponse struct {
Status int
Body []byte
}
func (hrc *HTTPResponseCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
@@ -57,7 +60,7 @@ func init() {
},
},
Required: []string{"status", "body"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -60,7 +60,7 @@ func init() {
Default: json.RawMessage("64"),
},
},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(moduleConfig config.ProcessorConfig) (Processor, error) {
params := moduleConfig.Params

View File

@@ -44,7 +44,7 @@ func init() {
},
},
Required: []string{"min", "max"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -60,7 +60,7 @@ func init() {
},
},
Required: []string{"inMin", "inMax", "outMin", "outMax"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -67,7 +67,7 @@ func init() {
},
},
Required: []string{"module", "key"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {

View File

@@ -82,7 +82,7 @@ func init() {
},
},
Required: []string{"module", "key", "value"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {

View File

@@ -0,0 +1,134 @@
//go:build cgo
package processor
import (
"bytes"
"context"
"fmt"
"strconv"
"text/template"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"gitlab.com/gomidi/midi/v2"
)
type MIDIControlChangeCreate struct {
config config.ProcessorConfig
Channel *template.Template
Control *template.Template
Value *template.Template
}
func (mccc *MIDIControlChangeCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
var channelBuffer bytes.Buffer
err := mccc.Channel.Execute(&channelBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
channelValue, err := strconv.ParseUint(channelBuffer.String(), 10, 8)
var controlBuffer bytes.Buffer
err = mccc.Control.Execute(&controlBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
controlValue, err := strconv.ParseUint(controlBuffer.String(), 10, 8)
var valueBuffer bytes.Buffer
err = mccc.Value.Execute(&valueBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
valueValue, err := strconv.ParseUint(valueBuffer.String(), 10, 8)
payloadMessage := midi.ControlChange(uint8(channelValue), uint8(controlValue), uint8(valueValue))
wrappedPayload.Payload = payloadMessage
return wrappedPayload, nil
}
func (mccc *MIDIControlChangeCreate) Type() string {
return mccc.config.Type
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "midi.control_change.create",
Title: "Create MIDI Control Change Message",
ParamsSchema: &jsonschema.Schema{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"channel": {
Title: "Channel",
Type: "string",
},
"control": {
Title: "Control",
Type: "string",
},
"value": {
Title: "Value",
Type: "string",
},
},
Required: []string{"channel", "control", "value"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params
channelString, err := params.GetString("channel")
if err != nil {
return nil, fmt.Errorf("midi.control_change.create channel error: %w", err)
}
channelTemplate, err := template.New("channel").Parse(channelString)
if err != nil {
return nil, err
}
controlString, err := params.GetString("control")
if err != nil {
return nil, fmt.Errorf("midi.control_change.create control error: %w", err)
}
controlTemplate, err := template.New("control").Parse(controlString)
if err != nil {
return nil, err
}
valueString, err := params.GetString("value")
if err != nil {
return nil, fmt.Errorf("midi.control_change.create value error: %w", err)
}
valueTemplate, err := template.New("value").Parse(valueString)
if err != nil {
return nil, err
}
return &MIDIControlChangeCreate{
config: config,
Channel: channelTemplate,
Control: controlTemplate,
Value: valueTemplate,
}, nil
},
})
}

View File

@@ -1,439 +0,0 @@
//go:build cgo || js
package processor
import (
"bytes"
"context"
"fmt"
"strconv"
"text/template"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"gitlab.com/gomidi/midi/v2"
)
// TODO(jwetzell): support using numbers in config file treated as hardcoded values
type MIDIMessageCreate struct {
config config.ProcessorConfig
ProcessFunc func(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error)
}
func (mmc *MIDIMessageCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
return mmc.ProcessFunc(ctx, wrappedPayload)
}
func (mmc *MIDIMessageCreate) Type() string {
return mmc.config.Type
}
func newMidiNoteOnCreate(config config.ProcessorConfig) (Processor, error) {
params := config.Params
channelString, err := params.GetString("channel")
if err != nil {
return nil, fmt.Errorf("midi.message.create channel error: %w", err)
}
channelTemplate, err := template.New("channel").Parse(channelString)
if err != nil {
return nil, err
}
noteString, err := params.GetString("note")
if err != nil {
return nil, fmt.Errorf("midi.message.create note error: %w", err)
}
noteTemplate, err := template.New("note").Parse(noteString)
if err != nil {
return nil, err
}
velocityString, err := params.GetString("velocity")
if err != nil {
return nil, fmt.Errorf("midi.message.create velocity error: %w", err)
}
velocityTemplate, err := template.New("velocity").Parse(velocityString)
if err != nil {
return nil, err
}
return &MIDIMessageCreate{config: config, ProcessFunc: func(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
var channelBuffer bytes.Buffer
err := channelTemplate.Execute(&channelBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
channelValue, err := strconv.ParseUint(channelBuffer.String(), 10, 8)
var noteBuffer bytes.Buffer
err = noteTemplate.Execute(&noteBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
noteValue, err := strconv.ParseUint(noteBuffer.String(), 10, 8)
var velocityBuffer bytes.Buffer
err = velocityTemplate.Execute(&velocityBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
velocityValue, err := strconv.ParseUint(velocityBuffer.String(), 10, 8)
payloadMessage := midi.NoteOn(uint8(channelValue), uint8(noteValue), uint8(velocityValue))
wrappedPayload.Payload = payloadMessage
return wrappedPayload, nil
}}, nil
}
func newMidiNoteOffCreate(config config.ProcessorConfig) (Processor, error) {
params := config.Params
channelString, err := params.GetString("channel")
if err != nil {
return nil, fmt.Errorf("midi.message.create channel error: %w", err)
}
channelTemplate, err := template.New("channel").Parse(channelString)
if err != nil {
return nil, err
}
noteString, err := params.GetString("note")
if err != nil {
return nil, fmt.Errorf("midi.message.create note error: %w", err)
}
noteTemplate, err := template.New("note").Parse(noteString)
if err != nil {
return nil, err
}
velocityString, err := params.GetString("velocity")
if err != nil {
return nil, fmt.Errorf("midi.message.create velocity error: %w", err)
}
velocityTemplate, err := template.New("velocity").Parse(velocityString)
if err != nil {
return nil, err
}
return &MIDIMessageCreate{config: config, ProcessFunc: func(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
var channelBuffer bytes.Buffer
err := channelTemplate.Execute(&channelBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
channelValue, err := strconv.ParseUint(channelBuffer.String(), 10, 8)
var noteBuffer bytes.Buffer
err = noteTemplate.Execute(&noteBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
noteValue, err := strconv.ParseUint(noteBuffer.String(), 10, 8)
var velocityBuffer bytes.Buffer
err = velocityTemplate.Execute(&velocityBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
velocityValue, err := strconv.ParseUint(velocityBuffer.String(), 10, 8)
payloadMessage := midi.NoteOffVelocity(uint8(channelValue), uint8(noteValue), uint8(velocityValue))
wrappedPayload.Payload = payloadMessage
return wrappedPayload, nil
}}, nil
}
func newMidiControlChangeCreate(config config.ProcessorConfig) (Processor, error) {
params := config.Params
channelString, err := params.GetString("channel")
if err != nil {
return nil, fmt.Errorf("midi.message.create channel error: %w", err)
}
channelTemplate, err := template.New("channel").Parse(channelString)
if err != nil {
return nil, err
}
controlString, err := params.GetString("control")
if err != nil {
return nil, fmt.Errorf("midi.message.create control error: %w", err)
}
controlTemplate, err := template.New("control").Parse(controlString)
if err != nil {
return nil, err
}
valueString, err := params.GetString("value")
if err != nil {
return nil, fmt.Errorf("midi.message.create value error: %w", err)
}
valueTemplate, err := template.New("value").Parse(valueString)
if err != nil {
return nil, err
}
return &MIDIMessageCreate{config: config, ProcessFunc: func(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
var channelBuffer bytes.Buffer
err := channelTemplate.Execute(&channelBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
channelValue, err := strconv.ParseUint(channelBuffer.String(), 10, 8)
var controlBuffer bytes.Buffer
err = controlTemplate.Execute(&controlBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
controlValue, err := strconv.ParseUint(controlBuffer.String(), 10, 8)
var valueBuffer bytes.Buffer
err = valueTemplate.Execute(&valueBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
valueValue, err := strconv.ParseUint(valueBuffer.String(), 10, 8)
payloadMessage := midi.ControlChange(uint8(channelValue), uint8(controlValue), uint8(valueValue))
wrappedPayload.Payload = payloadMessage
return wrappedPayload, nil
}}, nil
}
func newMidiProgramChangeCreate(config config.ProcessorConfig) (Processor, error) {
params := config.Params
channelString, err := params.GetString("channel")
if err != nil {
return nil, fmt.Errorf("midi.message.create channel error: %w", err)
}
channelTemplate, err := template.New("channel").Parse(channelString)
if err != nil {
return nil, err
}
programString, err := params.GetString("program")
if err != nil {
return nil, fmt.Errorf("midi.message.create program error: %w", err)
}
programTemplate, err := template.New("program").Parse(programString)
if err != nil {
return nil, err
}
return &MIDIMessageCreate{config: config, ProcessFunc: func(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
var channelBuffer bytes.Buffer
err := channelTemplate.Execute(&channelBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
channelValue, err := strconv.ParseUint(channelBuffer.String(), 10, 8)
var programBuffer bytes.Buffer
err = programTemplate.Execute(&programBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
programValue, err := strconv.ParseUint(programBuffer.String(), 10, 8)
payloadMessage := midi.ProgramChange(uint8(channelValue), uint8(programValue))
wrappedPayload.Payload = payloadMessage
return wrappedPayload, nil
}}, nil
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "midi.message.create",
Title: "Create MIDI Message",
ParamsSchema: &jsonschema.Schema{
Type: "object",
OneOf: []*jsonschema.Schema{
{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"type": {
Title: "MIDI Message Type",
Type: "string",
Enum: []any{"NoteOn", "noteon", "note_on"},
},
"channel": {
Title: "Channel",
Type: "string",
},
"note": {
Title: "Note",
Type: "string",
},
"velocity": {
Title: "Velocity",
Type: "string",
},
},
Required: []string{"type", "channel", "note", "velocity"},
AdditionalProperties: nil,
},
{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"type": {
Title: "MIDI Message Type",
Type: "string",
Enum: []any{"NoteOff", "noteoff", "note_off"},
},
"channel": {
Title: "Channel",
Type: "string",
},
"note": {
Title: "Note",
Type: "string",
},
"velocity": {
Title: "Velocity",
Type: "string",
},
},
Required: []string{"type", "channel", "note", "velocity"},
AdditionalProperties: nil,
},
{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"type": {
Title: "MIDI Message Type",
Type: "string",
Enum: []any{"ControlChange", "controlchange", "control_change"},
},
"channel": {
Title: "Channel",
Type: "string",
},
"control": {
Title: "Control",
Type: "string",
},
"value": {
Title: "Value",
Type: "string",
},
},
Required: []string{"type", "channel", "control", "value"},
AdditionalProperties: nil,
},
{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"type": {
Title: "MIDI Message Type",
Type: "string",
Enum: []any{"ProgramChange", "programchange", "program_change"},
},
"channel": {
Title: "Channel",
Type: "string",
},
"program": {
Title: "Program",
Type: "string",
},
},
Required: []string{"type", "channel", "program"},
AdditionalProperties: nil,
},
},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params
msgTypeString, err := params.GetString("type")
if err != nil {
return nil, fmt.Errorf("midi.message.create type error: %w", err)
}
switch msgTypeString {
case "NoteOn", "noteon", "note_on":
return newMidiNoteOnCreate(config)
case "NoteOff", "noteoff", "note_off":
return newMidiNoteOffCreate(config)
case "ControlChange", "controlchange", "control_change":
return newMidiControlChangeCreate(config)
case "ProgramChange", "programchange", "program_change":
return newMidiProgramChangeCreate(config)
default:
return nil, fmt.Errorf("midi.message.create does not support type %s", msgTypeString)
}
},
})
}

View File

@@ -1,4 +1,4 @@
//go:build cgo || js
//go:build cgo
package processor

View File

@@ -1,4 +1,4 @@
//go:build cgo || js
//go:build cgo
package processor

View File

@@ -1,4 +1,4 @@
//go:build cgo || js
//go:build cgo
package processor

View File

@@ -0,0 +1,132 @@
//go:build cgo
package processor
import (
"bytes"
"context"
"fmt"
"strconv"
"text/template"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"gitlab.com/gomidi/midi/v2"
)
type MIDINoteOffCreate struct {
config config.ProcessorConfig
Channel *template.Template
Note *template.Template
Velocity *template.Template
}
func (mnoc *MIDINoteOffCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
var channelBuffer bytes.Buffer
err := mnoc.Channel.Execute(&channelBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
channelValue, err := strconv.ParseUint(channelBuffer.String(), 10, 8)
var noteBuffer bytes.Buffer
err = mnoc.Note.Execute(&noteBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
noteValue, err := strconv.ParseUint(noteBuffer.String(), 10, 8)
var velocityBuffer bytes.Buffer
err = mnoc.Velocity.Execute(&velocityBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
velocityValue, err := strconv.ParseUint(velocityBuffer.String(), 10, 8)
payloadMessage := midi.NoteOffVelocity(uint8(channelValue), uint8(noteValue), uint8(velocityValue))
wrappedPayload.Payload = payloadMessage
return wrappedPayload, nil
}
func (mnoc *MIDINoteOffCreate) Type() string {
return mnoc.config.Type
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "midi.note_off.create",
Title: "Create MIDI Note Off Message",
ParamsSchema: &jsonschema.Schema{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"channel": {
Title: "Channel",
Type: "string",
},
"note": {
Title: "Note",
Type: "string",
},
"velocity": {
Title: "Velocity",
Type: "string",
},
},
Required: []string{"channel", "note", "velocity"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params
channelString, err := params.GetString("channel")
if err != nil {
return nil, fmt.Errorf("midi.note_off.create channel error: %w", err)
}
channelTemplate, err := template.New("channel").Parse(channelString)
if err != nil {
return nil, err
}
noteString, err := params.GetString("note")
if err != nil {
return nil, fmt.Errorf("midi.note_off.create note error: %w", err)
}
noteTemplate, err := template.New("note").Parse(noteString)
if err != nil {
return nil, err
}
velocityString, err := params.GetString("velocity")
if err != nil {
return nil, fmt.Errorf("midi.note_off.create velocity error: %w", err)
}
velocityTemplate, err := template.New("velocity").Parse(velocityString)
if err != nil {
return nil, err
}
return &MIDINoteOffCreate{
config: config,
Channel: channelTemplate,
Note: noteTemplate,
Velocity: velocityTemplate,
}, nil
},
})
}

View File

@@ -0,0 +1,132 @@
//go:build cgo
package processor
import (
"bytes"
"context"
"fmt"
"strconv"
"text/template"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"gitlab.com/gomidi/midi/v2"
)
type MIDINoteOnCreate struct {
config config.ProcessorConfig
Channel *template.Template
Note *template.Template
Velocity *template.Template
}
func (mnoc *MIDINoteOnCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
var channelBuffer bytes.Buffer
err := mnoc.Channel.Execute(&channelBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
channelValue, err := strconv.ParseUint(channelBuffer.String(), 10, 8)
var noteBuffer bytes.Buffer
err = mnoc.Note.Execute(&noteBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
noteValue, err := strconv.ParseUint(noteBuffer.String(), 10, 8)
var velocityBuffer bytes.Buffer
err = mnoc.Velocity.Execute(&velocityBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
velocityValue, err := strconv.ParseUint(velocityBuffer.String(), 10, 8)
payloadMessage := midi.NoteOn(uint8(channelValue), uint8(noteValue), uint8(velocityValue))
wrappedPayload.Payload = payloadMessage
return wrappedPayload, nil
}
func (mnoc *MIDINoteOnCreate) Type() string {
return mnoc.config.Type
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "midi.note_on.create",
Title: "Create MIDI Note On Message",
ParamsSchema: &jsonschema.Schema{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"channel": {
Title: "Channel",
Type: "string",
},
"note": {
Title: "Note",
Type: "string",
},
"velocity": {
Title: "Velocity",
Type: "string",
},
},
Required: []string{"channel", "note", "velocity"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params
channelString, err := params.GetString("channel")
if err != nil {
return nil, fmt.Errorf("midi.note_on.create channel error: %w", err)
}
channelTemplate, err := template.New("channel").Parse(channelString)
if err != nil {
return nil, err
}
noteString, err := params.GetString("note")
if err != nil {
return nil, fmt.Errorf("midi.note_on.create note error: %w", err)
}
noteTemplate, err := template.New("note").Parse(noteString)
if err != nil {
return nil, err
}
velocityString, err := params.GetString("velocity")
if err != nil {
return nil, fmt.Errorf("midi.note_on.create velocity error: %w", err)
}
velocityTemplate, err := template.New("velocity").Parse(velocityString)
if err != nil {
return nil, err
}
return &MIDINoteOnCreate{
config: config,
Channel: channelTemplate,
Note: noteTemplate,
Velocity: velocityTemplate,
}, nil
},
})
}

View File

@@ -0,0 +1,106 @@
//go:build cgo
package processor
import (
"bytes"
"context"
"fmt"
"strconv"
"text/template"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"gitlab.com/gomidi/midi/v2"
)
type MIDIProgramChangeCreate struct {
config config.ProcessorConfig
Channel *template.Template
Program *template.Template
}
func (mpcc *MIDIProgramChangeCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
templateData := wrappedPayload
var channelBuffer bytes.Buffer
err := mpcc.Channel.Execute(&channelBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
channelValue, err := strconv.ParseUint(channelBuffer.String(), 10, 8)
var programBuffer bytes.Buffer
err = mpcc.Program.Execute(&programBuffer, templateData)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
programValue, err := strconv.ParseUint(programBuffer.String(), 10, 8)
payloadMessage := midi.ProgramChange(uint8(channelValue), uint8(programValue))
wrappedPayload.Payload = payloadMessage
return wrappedPayload, nil
}
func (mpcc *MIDIProgramChangeCreate) Type() string {
return mpcc.config.Type
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "midi.program_change.create",
Title: "Create MIDI Prgoram Change Message",
ParamsSchema: &jsonschema.Schema{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"channel": {
Title: "Channel",
Type: "string",
},
"program": {
Title: "Program",
Type: "string",
},
},
Required: []string{"type", "channel", "program"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params
channelString, err := params.GetString("channel")
if err != nil {
return nil, fmt.Errorf("midi.program_change.create channel error: %w", err)
}
channelTemplate, err := template.New("channel").Parse(channelString)
if err != nil {
return nil, err
}
programString, err := params.GetString("program")
if err != nil {
return nil, fmt.Errorf("midi.program_change.create program error: %w", err)
}
programTemplate, err := template.New("program").Parse(programString)
if err != nil {
return nil, err
}
return &MIDIProgramChangeCreate{
config: config,
Channel: channelTemplate,
Program: programTemplate,
}, nil
},
})
}

View File

@@ -1,5 +1,3 @@
//go:build !js
package processor
import (
@@ -106,7 +104,7 @@ func init() {
},
},
Required: []string{"topic", "qos", "retained", "payload"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(processorConfig config.ProcessorConfig) (Processor, error) {
params := processorConfig.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package processor
import (
@@ -77,7 +75,7 @@ func init() {
},
},
Required: []string{"subject", "payload"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -109,7 +109,7 @@ func init() {
},
},
Required: []string{"address"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(processorConfig config.ProcessorConfig) (Processor, error) {
params := processorConfig.Params

View File

@@ -57,7 +57,7 @@ func init() {
},
},
Required: []string{"source"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {

View File

@@ -53,7 +53,7 @@ func init() {
},
},
Required: []string{"module"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {

View File

@@ -48,7 +48,7 @@ func init() {
},
},
Required: []string{"expression"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package processor
import (
@@ -107,7 +105,7 @@ func init() {
},
},
Required: []string{"program"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package processor
import (
@@ -75,7 +73,7 @@ func init() {
},
},
Required: []string{"path"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(processorConfig config.ProcessorConfig) (Processor, error) {
params := processorConfig.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package processor
import (
@@ -72,7 +70,7 @@ func init() {
},
},
Required: []string{"preWait", "postWait", "audioFile"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -1,5 +1,3 @@
//go:build !js
package processor
import (
@@ -80,7 +78,7 @@ func init() {
},
},
Required: []string{"preWait", "postWait", "digits"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -49,7 +49,7 @@ func init() {
},
},
Required: []string{"template"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -47,7 +47,7 @@ func init() {
},
},
Required: []string{"separator"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -55,7 +55,8 @@ func init() {
Type: "string",
},
},
Required: []string{"name"},
Required: []string{"name"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -74,7 +74,8 @@ func init() {
Type: "string",
},
},
Required: []string{"name"},
Required: []string{"name"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -0,0 +1,161 @@
package processor_test
import (
"reflect"
"testing"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
"gitlab.com/gomidi/midi/v2"
)
func TestMIDIControlChangeCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.control_change.create"]
if !ok {
t.Fatalf("midi.control_change.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.control_change.create",
Params: map[string]any{
"channel": "1",
"control": "60",
"value": "100",
},
})
if err != nil {
t.Fatalf("failed to create midi.control_change.create processor: %s", err)
}
if processorInstance.Type() != "midi.control_change.create" {
t.Fatalf("midi.control_change.create processor has wrong type: %s", processorInstance.Type())
}
}
func TestGoodMIDIControlChangeCreate(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
expected any
}{
{
name: "control_change message",
params: map[string]any{
"type": "control_change",
"channel": "1",
"control": "64",
"value": "127",
},
payload: "test",
expected: midi.ControlChange(1, 64, 127),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.control_change.create"]
if !ok {
t.Fatalf("midi.control_change.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.control_change.create",
Params: test.params,
})
if err != nil {
t.Fatalf("midi.control_change.create failed to create processor: %s", err)
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err != nil {
t.Fatalf("midi.control_change.create processing failed: %s", err)
}
gotMessage, ok := got.Payload.(midi.Message)
if !ok {
t.Fatalf("midi.control_change.create returned a %T payload: %+v", got, got)
}
if !reflect.DeepEqual(gotMessage, test.expected) {
t.Fatalf("midi.control_change.create got %v, expected %v", gotMessage, test.expected)
}
})
}
}
func TestBadMIDIControlChangeCreate(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
errorString string
}{
{
name: "control_change no channel",
params: map[string]any{
"type": "control_change",
"control": "64",
"value": "127",
},
payload: "test",
errorString: "midi.control_change.create channel error: not found",
},
{
name: "control_change no control",
params: map[string]any{
"type": "control_change",
"channel": "1",
"value": "127",
},
payload: "test",
errorString: "midi.control_change.create control error: not found",
},
{
name: "control_change no value",
params: map[string]any{
"type": "control_change",
"channel": "1",
"control": "64",
},
payload: "test",
errorString: "midi.control_change.create value error: not found",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.control_change.create"]
if !ok {
t.Fatalf("midi.control_change.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.control_change.create",
Params: test.params,
})
if err != nil {
if test.errorString != err.Error() {
t.Fatalf("midi.control_change.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
return
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err == nil {
t.Fatalf("midi.control_change.create expected to fail but succeeded, got: %v", got)
}
if err.Error() != test.errorString {
t.Fatalf("midi.control_change.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
})
}
}

View File

@@ -1,294 +0,0 @@
package processor_test
import (
"reflect"
"testing"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
"gitlab.com/gomidi/midi/v2"
)
func TestMIDIMessageCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.create"]
if !ok {
t.Fatalf("midi.message.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.message.create",
Params: map[string]any{
"type": "note_on",
"channel": "1",
"note": "60",
"velocity": "100",
},
})
if err != nil {
t.Fatalf("failed to create midi.message.create processor: %s", err)
}
if processorInstance.Type() != "midi.message.create" {
t.Fatalf("midi.message.create processor has wrong type: %s", processorInstance.Type())
}
}
func TestGoodMIDIMessageCreate(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
expected any
}{
{
name: "note_on message",
params: map[string]any{
"type": "note_on",
"channel": "1",
"note": "60",
"velocity": "100",
},
payload: "test",
expected: midi.NoteOn(1, 60, 100),
},
{
name: "note_off message",
params: map[string]any{
"type": "note_off",
"channel": "1",
"note": "60",
"velocity": "100",
},
payload: "test",
expected: midi.NoteOffVelocity(1, 60, 100),
},
{
name: "control_change message",
params: map[string]any{
"type": "control_change",
"channel": "1",
"control": "64",
"value": "127",
},
payload: "test",
expected: midi.ControlChange(1, 64, 127),
},
{
name: "program_change message",
params: map[string]any{
"type": "program_change",
"channel": "1",
"program": "10",
},
payload: "test",
expected: midi.ProgramChange(1, 10),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.create"]
if !ok {
t.Fatalf("midi.message.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.message.create",
Params: test.params,
})
if err != nil {
t.Fatalf("midi.message.create failed to create processor: %s", err)
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err != nil {
t.Fatalf("midi.message.create processing failed: %s", err)
}
gotMessage, ok := got.Payload.(midi.Message)
if !ok {
t.Fatalf("midi.message.create returned a %T payload: %+v", got, got)
}
if !reflect.DeepEqual(gotMessage, test.expected) {
t.Fatalf("midi.message.create got %v, expected %v", gotMessage, test.expected)
}
})
}
}
func TestBadMIDIMessageCreate(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
errorString string
}{
{
name: "no type parameter",
params: map[string]any{},
payload: "test",
errorString: "midi.message.create type error: not found",
},
{
name: "non-string type parameter",
params: map[string]any{
"type": 1,
},
payload: "test",
errorString: "midi.message.create type error: not a string",
},
{
name: "unknown type parameter",
params: map[string]any{
"type": "asdf",
},
payload: "test",
errorString: "midi.message.create does not support type asdf",
},
{
name: "note_on message no channel",
params: map[string]any{
"type": "note_on",
"note": "60",
"velocity": "100",
},
payload: "test",
errorString: "midi.message.create channel error: not found",
},
{
name: "note_on message no note",
params: map[string]any{
"type": "note_on",
"channel": "1",
"velocity": "100",
},
payload: "test",
errorString: "midi.message.create note error: not found",
},
{
name: "note_on message no velocity",
params: map[string]any{
"type": "note_on",
"channel": "1",
"note": "60",
},
payload: "test",
errorString: "midi.message.create velocity error: not found",
},
{
name: "note_off message no channel",
params: map[string]any{
"type": "note_off",
"note": "60",
"velocity": "100",
},
payload: "test",
errorString: "midi.message.create channel error: not found",
},
{
name: "note_off message no note",
params: map[string]any{
"type": "note_off",
"channel": "1",
"velocity": "100",
},
payload: "test",
errorString: "midi.message.create note error: not found",
},
{
name: "note_off message no velocity",
params: map[string]any{
"type": "note_off",
"channel": "1",
"note": "60",
},
payload: "test",
errorString: "midi.message.create velocity error: not found",
},
{
name: "control_change no channel",
params: map[string]any{
"type": "control_change",
"control": "64",
"value": "127",
},
payload: "test",
errorString: "midi.message.create channel error: not found",
},
{
name: "control_change no control",
params: map[string]any{
"type": "control_change",
"channel": "1",
"value": "127",
},
payload: "test",
errorString: "midi.message.create control error: not found",
},
{
name: "control_change no value",
params: map[string]any{
"type": "control_change",
"channel": "1",
"control": "64",
},
payload: "test",
errorString: "midi.message.create value error: not found",
},
{
name: "program_change no channel",
params: map[string]any{
"type": "program_change",
"program": "64",
},
payload: "test",
errorString: "midi.message.create channel error: not found",
},
{
name: "program_change no program",
params: map[string]any{
"type": "program_change",
"channel": "1",
},
payload: "test",
errorString: "midi.message.create program error: not found",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.create"]
if !ok {
t.Fatalf("midi.message.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.message.create",
Params: test.params,
})
if err != nil {
if test.errorString != err.Error() {
t.Fatalf("midi.message.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
return
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err == nil {
t.Fatalf("midi.message.create expected to fail but succeeded, got: %v", got)
}
if err.Error() != test.errorString {
t.Fatalf("midi.message.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
})
}
}

View File

@@ -0,0 +1,160 @@
package processor_test
import (
"reflect"
"testing"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
"gitlab.com/gomidi/midi/v2"
)
func TestMIDINoteOffCreteaFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_off.create"]
if !ok {
t.Fatalf("midi.note_off.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.note_off.create",
Params: map[string]any{
"channel": "1",
"note": "60",
"velocity": "100",
},
})
if err != nil {
t.Fatalf("failed to create midi.note_off.create processor: %s", err)
}
if processorInstance.Type() != "midi.note_off.create" {
t.Fatalf("midi.note_off.create processor has wrong type: %s", processorInstance.Type())
}
}
func TestGoodMIDINoteOffCretea(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
expected any
}{
{
name: "note_off message",
params: map[string]any{
"channel": "1",
"note": "60",
"velocity": "100",
},
payload: "test",
expected: midi.NoteOffVelocity(1, 60, 100),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_off.create"]
if !ok {
t.Fatalf("midi.note_off.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.note_off.create",
Params: test.params,
})
if err != nil {
t.Fatalf("midi.note_off.create failed to create processor: %s", err)
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err != nil {
t.Fatalf("midi.note_off.create processing failed: %s", err)
}
gotMessage, ok := got.Payload.(midi.Message)
if !ok {
t.Fatalf("midi.note_off.create returned a %T payload: %+v", got, got)
}
if !reflect.DeepEqual(gotMessage, test.expected) {
t.Fatalf("midi.note_off.create got %v, expected %v", gotMessage, test.expected)
}
})
}
}
func TestBadMIDINoteOffCretea(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
errorString string
}{
{
name: "note_off message no channel",
params: map[string]any{
"type": "note_off",
"note": "60",
"velocity": "100",
},
payload: "test",
errorString: "midi.note_off.create channel error: not found",
},
{
name: "note_off message no note",
params: map[string]any{
"type": "note_off",
"channel": "1",
"velocity": "100",
},
payload: "test",
errorString: "midi.note_off.create note error: not found",
},
{
name: "note_off message no velocity",
params: map[string]any{
"type": "note_off",
"channel": "1",
"note": "60",
},
payload: "test",
errorString: "midi.note_off.create velocity error: not found",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_off.create"]
if !ok {
t.Fatalf("midi.note_off.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.note_off.create",
Params: test.params,
})
if err != nil {
if test.errorString != err.Error() {
t.Fatalf("midi.note_off.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
return
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err == nil {
t.Fatalf("midi.note_off.create expected to fail but succeeded, got: %v", got)
}
if err.Error() != test.errorString {
t.Fatalf("midi.note_off.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
})
}
}

View File

@@ -0,0 +1,157 @@
package processor_test
import (
"reflect"
"testing"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
"gitlab.com/gomidi/midi/v2"
)
func TestMIDINoteOnCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_on.create"]
if !ok {
t.Fatalf("midi.note_on.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.note_on.create",
Params: map[string]any{
"channel": "1",
"note": "60",
"velocity": "100",
},
})
if err != nil {
t.Fatalf("failed to create midi.note_on.create processor: %s", err)
}
if processorInstance.Type() != "midi.note_on.create" {
t.Fatalf("midi.note_on.create processor has wrong type: %s", processorInstance.Type())
}
}
func TestGoodMIDINoteOnCreate(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
expected any
}{
{
name: "note_on message",
params: map[string]any{
"channel": "1",
"note": "60",
"velocity": "100",
},
payload: "test",
expected: midi.NoteOn(1, 60, 100),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_on.create"]
if !ok {
t.Fatalf("midi.note_on.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.note_on.create",
Params: test.params,
})
if err != nil {
t.Fatalf("midi.note_on.create failed to create processor: %s", err)
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err != nil {
t.Fatalf("midi.note_on.create processing failed: %s", err)
}
gotMessage, ok := got.Payload.(midi.Message)
if !ok {
t.Fatalf("midi.note_on.create returned a %T payload: %+v", got, got)
}
if !reflect.DeepEqual(gotMessage, test.expected) {
t.Fatalf("midi.note_on.create got %v, expected %v", gotMessage, test.expected)
}
})
}
}
func TestBadMIDINoteOnCreate(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
errorString string
}{
{
name: "note_on message no channel",
params: map[string]any{
"note": "60",
"velocity": "100",
},
payload: "test",
errorString: "midi.note_on.create channel error: not found",
},
{
name: "note_on message no note",
params: map[string]any{
"channel": "1",
"velocity": "100",
},
payload: "test",
errorString: "midi.note_on.create note error: not found",
},
{
name: "note_on message no velocity",
params: map[string]any{
"channel": "1",
"note": "60",
},
payload: "test",
errorString: "midi.note_on.create velocity error: not found",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.note_on.create"]
if !ok {
t.Fatalf("midi.note_on.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.note_on.create",
Params: test.params,
})
if err != nil {
if test.errorString != err.Error() {
t.Fatalf("midi.note_on.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
return
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err == nil {
t.Fatalf("midi.note_on.create expected to fail but succeeded, got: %v", got)
}
if err.Error() != test.errorString {
t.Fatalf("midi.note_on.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
})
}
}

View File

@@ -0,0 +1,147 @@
package processor_test
import (
"reflect"
"testing"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
"gitlab.com/gomidi/midi/v2"
)
func TestMIDIProgramChangeCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.program_change.create"]
if !ok {
t.Fatalf("midi.program_change.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.program_change.create",
Params: map[string]any{
"channel": "1",
"program": "60",
},
})
if err != nil {
t.Fatalf("failed to create midi.program_change.create processor: %s", err)
}
if processorInstance.Type() != "midi.program_change.create" {
t.Fatalf("midi.program_change.create processor has wrong type: %s", processorInstance.Type())
}
}
func TestGoodMIDIProgramChangeCreate(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
expected any
}{
{
name: "program_change message",
params: map[string]any{
"type": "program_change",
"channel": "1",
"program": "10",
},
payload: "test",
expected: midi.ProgramChange(1, 10),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.program_change.create"]
if !ok {
t.Fatalf("midi.program_change.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.program_change.create",
Params: test.params,
})
if err != nil {
t.Fatalf("midi.program_change.create failed to create processor: %s", err)
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err != nil {
t.Fatalf("midi.program_change.create processing failed: %s", err)
}
gotMessage, ok := got.Payload.(midi.Message)
if !ok {
t.Fatalf("midi.program_change.create returned a %T payload: %+v", got, got)
}
if !reflect.DeepEqual(gotMessage, test.expected) {
t.Fatalf("midi.program_change.create got %v, expected %v", gotMessage, test.expected)
}
})
}
}
func TestBadMIDIProgramChangeCreate(t *testing.T) {
tests := []struct {
name string
params map[string]any
payload any
errorString string
}{
{
name: "program_change no channel",
params: map[string]any{
"type": "program_change",
"program": "64",
},
payload: "test",
errorString: "midi.program_change.create channel error: not found",
},
{
name: "program_change no program",
params: map[string]any{
"type": "program_change",
"channel": "1",
},
payload: "test",
errorString: "midi.program_change.create program error: not found",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.program_change.create"]
if !ok {
t.Fatalf("midi.program_change.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.program_change.create",
Params: test.params,
})
if err != nil {
if test.errorString != err.Error() {
t.Fatalf("midi.program_change.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
return
}
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
if err == nil {
t.Fatalf("midi.program_change.create expected to fail but succeeded, got: %v", got)
}
if err.Error() != test.errorString {
t.Fatalf("midi.program_change.create got error '%s', expected '%s'", err.Error(), test.errorString)
}
})
}
}

View File

@@ -37,7 +37,8 @@ func init() {
Description: "Duration to sleep in milliseconds",
},
},
Required: []string{"duration"},
Required: []string{"duration"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params

View File

@@ -1,102 +0,0 @@
//go:build js
package processor
import (
"bytes"
"context"
"fmt"
"html/template"
"log/slog"
"syscall/js"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/common"
"github.com/jwetzell/showbridge-go/internal/config"
)
type WebSet struct {
config config.ProcessorConfig
ModuleId string
ElementId string
Property string
Value *template.Template
logger *slog.Logger
}
func (kvs *WebSet) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
element := js.Global().Get("document").Call("getElementById", kvs.ElementId)
if element.IsNull() || element.IsUndefined() {
wrappedPayload.End = true
return wrappedPayload, fmt.Errorf("web.set unable to find element with id: %s", kvs.ElementId)
}
var valueBuffer bytes.Buffer
err := kvs.Value.Execute(&valueBuffer, wrappedPayload)
if err != nil {
wrappedPayload.End = true
return wrappedPayload, err
}
element.Set(kvs.Property, valueBuffer.String())
return wrappedPayload, nil
}
func (kvs *WebSet) Type() string {
return kvs.config.Type
}
func init() {
RegisterProcessor(ProcessorRegistration{
Type: "web.set",
Title: "Set Web Element Property",
ParamsSchema: &jsonschema.Schema{
Type: "object",
Properties: map[string]*jsonschema.Schema{
"id": {
Title: "Element ID",
Type: "string",
},
"property": {
Title: "Property",
Type: "string",
},
"value": {
Title: "Value",
Type: "string",
},
},
Required: []string{"id", "property", "value"},
AdditionalProperties: nil,
},
New: func(config config.ProcessorConfig) (Processor, error) {
params := config.Params
idString, err := params.GetString("id")
if err != nil {
return nil, fmt.Errorf("web.set id error: %w", err)
}
propertyString, err := params.GetString("property")
if err != nil {
return nil, fmt.Errorf("web.set property error: %w", err)
}
valueString, err := params.GetString("value")
if err != nil {
return nil, fmt.Errorf("web.set value error: %w", err)
}
valueTemplate, err := template.New("template").Parse(valueString)
if err != nil {
return nil, err
}
return &WebSet{config: config, ElementId: idString, Property: propertyString, Value: valueTemplate, logger: slog.Default().With("component", "processor", "type", config.Type)}, nil
},
})
}

View File

@@ -7,6 +7,7 @@ import (
)
var ApiConfigSchema = jsonschema.Schema{
ID: "https://showbridge.io/api.schema.json",
Type: "object",
Properties: map[string]*jsonschema.Schema{
"enabled": {
@@ -22,5 +23,7 @@ var ApiConfigSchema = jsonschema.Schema{
Default: json.RawMessage(`8080`),
},
},
Required: []string{"port"},
Required: []string{"port"},
Default: json.RawMessage(`{"enabled": false, "port": 8080}`),
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
}

View File

@@ -19,6 +19,7 @@ var ConfigSchema = jsonschema.Schema{
Ref: "https://showbridge.io/routes.schema.json",
},
},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
}
func ApplyDefaults(cfg *map[string]any) error {

View File

@@ -1,6 +1,8 @@
package schema
import (
"encoding/json"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/module"
)
@@ -13,11 +15,13 @@ func GetModulesSchema() *jsonschema.Schema {
Title: "Modules",
Description: "module configurations",
Type: "array",
Default: json.RawMessage(`[]`),
}
moduleDefinitionSchemas := []*jsonschema.Schema{}
for _, mod := range module.ModuleRegistry {
moduleSchema := &jsonschema.Schema{
ID: mod.Type,
Type: "object",
Properties: map[string]*jsonschema.Schema{
"id": {
@@ -29,7 +33,7 @@ func GetModulesSchema() *jsonschema.Schema {
},
},
Required: []string{"id", "type"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
}
if mod.Title != "" {
moduleSchema.Title = mod.Title

View File

@@ -1,6 +1,8 @@
package schema
import (
"encoding/json"
"github.com/google/jsonschema-go/jsonschema"
"github.com/jwetzell/showbridge-go/internal/processor"
)
@@ -13,11 +15,13 @@ func GetProcessorsSchema() *jsonschema.Schema {
Title: "Processors",
Description: "processor configurations",
Type: "array",
Default: json.RawMessage(`[]`),
}
processorDefinitionSchemas := []*jsonschema.Schema{}
for _, proc := range processor.ProcessorRegistry {
processorSchema := &jsonschema.Schema{
ID: proc.Type,
Type: "object",
Properties: map[string]*jsonschema.Schema{
"type": {
@@ -25,7 +29,7 @@ func GetProcessorsSchema() *jsonschema.Schema {
},
},
Required: []string{"type"},
AdditionalProperties: nil,
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
}
if proc.Title != "" {
processorSchema.Title = proc.Title

View File

@@ -1,6 +1,10 @@
package schema
import "github.com/google/jsonschema-go/jsonschema"
import (
"encoding/json"
"github.com/google/jsonschema-go/jsonschema"
)
var RoutesConfigSchema = jsonschema.Schema{
Schema: "https://json-schema.org/draft/2020-12/schema",
@@ -19,6 +23,8 @@ var RoutesConfigSchema = jsonschema.Schema{
Ref: "https://showbridge.io/processors.schema.json",
},
},
Required: []string{"input"},
Required: []string{"input"},
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
},
Default: json.RawMessage(`[]`),
}