mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 01:29:58 +00:00
Install scripts, build app with rollup & configurable mirror app id
This commit is contained in:
7
app/src/fx_cast_bridge.json
Executable file
7
app/src/fx_cast_bridge.json
Executable file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "fx_cast_bridge"
|
||||
, "description": ""
|
||||
, "path": ""
|
||||
, "type": "stdio"
|
||||
, "allowed_extensions": [ "fx_cast@matt.tf" ]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,107 +1,107 @@
|
||||
"use strict";
|
||||
|
||||
const { Transform } = require("stream");
|
||||
|
||||
|
||||
/**
|
||||
* Takes a handler function that implements the transform
|
||||
* and calls the transform callback.
|
||||
*/
|
||||
const response = (handler) => new Transform({
|
||||
readableObjectMode: true
|
||||
, writableObjectMode: true
|
||||
|
||||
, transform (chunk, encoding, callback) {
|
||||
|
||||
Promise.resolve(handler(chunk, callback))
|
||||
.then(response => {
|
||||
if (response) {
|
||||
callback(null, response);
|
||||
} else {
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Takes input, decodes the message string, parses as JSON
|
||||
* and outputs the parsed result.
|
||||
*/
|
||||
const decode = new Transform({
|
||||
readableObjectMode: true
|
||||
|
||||
, transform (chunk, encoding, callback) {
|
||||
// Setup persistent data
|
||||
if (!this.hasOwnProperty("buf")
|
||||
&& !this.hasOwnProperty("message_length")) {
|
||||
|
||||
this.buf = new Buffer(0);
|
||||
this.message_length = null;
|
||||
}
|
||||
|
||||
// Append next chunk to buffer
|
||||
this.buf = Buffer.concat([ this.buf, chunk ]);
|
||||
|
||||
while (true) {
|
||||
if (this.message_length === null) {
|
||||
if (this.buf.length >= 4) {
|
||||
|
||||
// Read message length
|
||||
this.message_length = this.buf.readUInt32LE(0);
|
||||
|
||||
// Offset buffer
|
||||
this.buf = this.buf.slice(4);
|
||||
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (this.buf.length >= this.message_length) {
|
||||
const message = JSON.parse(this.buf.slice(
|
||||
0, this.message_length));
|
||||
|
||||
this.push(message);
|
||||
|
||||
// Cleanup persistent data
|
||||
this.buf = this.buf.slice(this.message_length);
|
||||
this.message_length = null;
|
||||
|
||||
// Parse next message
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// No complete messages left
|
||||
callback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Takes input, encodes the message length and content and
|
||||
* outputs the encoded result.
|
||||
*/
|
||||
const encode = new Transform({
|
||||
writableObjectMode: true
|
||||
|
||||
, transform (chunk, encoding, callback) {
|
||||
const message_length = new Buffer(4);
|
||||
const message = new Buffer(JSON.stringify(chunk));
|
||||
|
||||
// Write message length
|
||||
message_length.writeUInt32LE(message.length, 0);
|
||||
|
||||
// Output joined message length and content
|
||||
callback(null, Buffer.concat([message_length, message]));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
module.exports = {
|
||||
response
|
||||
, decode
|
||||
, encode
|
||||
};
|
||||
"use strict";
|
||||
|
||||
const { Transform } = require("stream");
|
||||
|
||||
|
||||
/**
|
||||
* Takes a handler function that implements the transform
|
||||
* and calls the transform callback.
|
||||
*/
|
||||
const response = (handler) => new Transform({
|
||||
readableObjectMode: true
|
||||
, writableObjectMode: true
|
||||
|
||||
, transform (chunk, encoding, callback) {
|
||||
|
||||
Promise.resolve(handler(chunk, callback))
|
||||
.then(response => {
|
||||
if (response) {
|
||||
callback(null, response);
|
||||
} else {
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Takes input, decodes the message string, parses as JSON
|
||||
* and outputs the parsed result.
|
||||
*/
|
||||
const decode = new Transform({
|
||||
readableObjectMode: true
|
||||
|
||||
, transform (chunk, encoding, callback) {
|
||||
// Setup persistent data
|
||||
if (!this.hasOwnProperty("buf")
|
||||
&& !this.hasOwnProperty("message_length")) {
|
||||
|
||||
this.buf = new Buffer(0);
|
||||
this.message_length = null;
|
||||
}
|
||||
|
||||
// Append next chunk to buffer
|
||||
this.buf = Buffer.concat([ this.buf, chunk ]);
|
||||
|
||||
while (true) {
|
||||
if (this.message_length === null) {
|
||||
if (this.buf.length >= 4) {
|
||||
|
||||
// Read message length
|
||||
this.message_length = this.buf.readUInt32LE(0);
|
||||
|
||||
// Offset buffer
|
||||
this.buf = this.buf.slice(4);
|
||||
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (this.buf.length >= this.message_length) {
|
||||
const message = JSON.parse(this.buf.slice(
|
||||
0, this.message_length));
|
||||
|
||||
this.push(message);
|
||||
|
||||
// Cleanup persistent data
|
||||
this.buf = this.buf.slice(this.message_length);
|
||||
this.message_length = null;
|
||||
|
||||
// Parse next message
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// No complete messages left
|
||||
callback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Takes input, encodes the message length and content and
|
||||
* outputs the encoded result.
|
||||
*/
|
||||
const encode = new Transform({
|
||||
writableObjectMode: true
|
||||
|
||||
, transform (chunk, encoding, callback) {
|
||||
const message_length = new Buffer(4);
|
||||
const message = new Buffer(JSON.stringify(chunk));
|
||||
|
||||
// Write message length
|
||||
message_length.writeUInt32LE(message.length, 0);
|
||||
|
||||
// Output joined message length and content
|
||||
callback(null, Buffer.concat([message_length, message]));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export {
|
||||
response
|
||||
, decode
|
||||
, encode
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
AVAHI_COMPAT_NOWARN=1 node main.js
|
||||
|
||||
#!/usr/bin/env bash
|
||||
BASEDIR=$(dirname $0)
|
||||
PATH=/usr/local/bin:$PATH
|
||||
AVAHI_COMPAT_NOWARN=1 node $BASEDIR/app.js
|
||||
|
||||
Reference in New Issue
Block a user