From 4f87623977c989d8d96585112024e2dd3a5eaa08 Mon Sep 17 00:00:00 2001 From: gabrielburnworth Date: Thu, 2 Nov 2023 13:02:28 -0700 Subject: [PATCH] v15.8.3 --- dist/farmbot.js | 2 +- dist/farmbot_single_file.js | 2 +- dist/farmbot_single_file.js.map | 2 +- dist/interfaces.d.ts | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/farmbot.ts | 2 +- src/interfaces.ts | 1 + 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dist/farmbot.js b/dist/farmbot.js index 93c67cc..66d9329 100644 --- a/dist/farmbot.js +++ b/dist/farmbot.js @@ -454,7 +454,7 @@ var Farmbot = /** @class */ (function () { enumerable: false, configurable: true }); - Farmbot.VERSION = "15.8.2"; + Farmbot.VERSION = "15.8.3"; return Farmbot; }()); exports.Farmbot = Farmbot; diff --git a/dist/farmbot_single_file.js b/dist/farmbot_single_file.js index f2adc7c..5cd5afe 100644 --- a/dist/farmbot_single_file.js +++ b/dist/farmbot_single_file.js @@ -47,7 +47,7 @@ if(![4,5,6,11].includes(e.pin_number))throw Error("Servos only work on pins 4 an */this.send=function(e){return new Promise(function(n,t){r.publish(e),r.on(e.args.label,function(e){switch(e.kind){case"rpc_ok":return n(e);case"rpc_error":return t(Error("Problem sending RPC command: "+(e.body||[]).map(function(e){return e.args.message}).join(", ")));default:throw console.dir(e),Error("Got a bad CeleryScript node.")}},!0)})},/** Main entry point for all MQTT packets. */this._onmessage=function(e,n){var t=(0,c.bufferToString)(n),o=e.split(d.Misc.MQTT_DELIM),i=r.emit;try{var s=JSON.parse(t);if(o[0]==d.MqttChanName.publicBroadcast)return i(d.MqttChanName.publicBroadcast,s);switch(o[2]){case d.MqttChanName.logs:return i(d.FbjsEventName.logs,s);case d.MqttChanName.status:return i(d.FbjsEventName.status,s);case d.MqttChanName.sync:return i(d.FbjsEventName.sync,s);case d.MqttChanName.pong:return i(o[3],s);default:var a=(0,p.hasLabel)(s)?s.args.label:d.FbjsEventName.malformed;return i(a,s)}}catch(e){console.dir({text:"Could not parse inbound message from MQTT.",error:e}),i(d.FbjsEventName.malformed,t)}},this.ping=function(e,n){return void 0===e&&(e=1e4),void 0===n&&(n=(0,l.timestamp)()),r.setConfig("LAST_PING_OUT",n),r.doPing(n,e)},// STEP 0: Subscribe to `bot/device_23/pong/#` // STEP 0: Send `bot/device_23/ping/3123123` // STEP 0: Receive `bot/device_23/pong/3123123` -this.doPing=function(e,n){return Promise.race([new Promise(function(e,t){return setTimeout(function(){return t(-0)},n)}),new Promise(function(n,t){r.on(""+e,function(){var t=(0,l.timestamp)();r.setConfig("LAST_PING_IN",t),n(t-e)},!0);var o=r.channel.ping(e);r.client&&r.client.publish(o,JSON.stringify(e))})])},/** Bootstrap the device onto the MQTT broker. */this.connect=function(){var t=r.config,o=t.mqttUsername,i=t.token,s=t.mqttServer,c=d.Misc.RECONNECT_THROTTLE_MS,u=(0,e.connect)(s,{clean:!0,clientId:"FBJS-".concat(n.VERSION,"-").concat((0,a.uuid)()),password:i,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:c,username:o});r.client=u,r.resources=new f.ResourceAdapter(r,r.config.mqttUsername),u.on("message",r._onmessage),u.on("offline",function(){return r.emit(d.FbjsEventName.offline,{})}),u.on("connect",function(){return r.emit(d.FbjsEventName.online,{})});var p=[r.channel.logs,r.channel.status,r.channel.sync,r.channel.toClient,r.channel.pong];return u.subscribe(p),new Promise(function(e,n){if(r.client)r.client.once("connect",function(){return e(r)});else throw Error("Please connect first.")})},this._events={},this.config=(0,u.generateConfig)(t),this.resources=new f.ResourceAdapter(this,this.config.mqttUsername)}return Object.defineProperty(n.prototype,"channel",{/** Dictionary of all relevant MQTT channels the bot uses. */get:function(){var e=this.config.mqttUsername;return{/** From the browser, usually. */toDevice:"bot/".concat(e,"/").concat(d.MqttChanName.fromClients),/** From farmbot */toClient:"bot/".concat(e,"/").concat(d.MqttChanName.fromDevice),status:"bot/".concat(e,"/").concat(d.MqttChanName.status),logs:"bot/".concat(e,"/").concat(d.MqttChanName.logs),sync:"bot/".concat(e,"/").concat(d.MqttChanName.sync,"/#"),/** Read only */pong:"bot/".concat(e,"/pong/#"),/** Write only: bot/${deviceName}/ping/${timestamp} */ping:function(n){return"bot/".concat(e,"/ping/").concat(n)}}},enumerable:!1,configurable:!0}),n.VERSION="15.8.2",n}()}),a("jOzD0",function(e,r){t(e.exports,"stringToBuffer",()=>d),t(e.exports,"bufferToString",()=>l);var o=s("8i5S2"),i=s("byyGl"),a=s("3SNLU"),c=s("4svrT"),u=s("01gfL"),f=s("iwcyJ");function d(e){var n=e.split("").map(function(e){return e.charCodeAt(0)});return new Uint8Array(n)}var p="undefined"!=typeof util&&util.TextDecoder?new util.TextDecoder:"undefined"!=typeof window&&window.TextDecoder?new window.TextDecoder:{decode:function(e){var n=[];return e.forEach(function(e){return n.push(String.fromCharCode(e))}),n.join("")}},l=function(e){return p.decode(e)};n(e.exports,o),n(e.exports,i),n(e.exports,a),n(e.exports,c),n(e.exports,u),n(e.exports,f)}),a("8i5S2",function(e,n){t(e.exports,"coordinate",()=>r);function r(e,n,t){return{kind:"coordinate",args:{x:e,y:n,z:t}}}}),a("byyGl",function(e,n){t(e.exports,"isCeleryScript",()=>o),t(e.exports,"hasLabel",()=>i);var r=function(e){return!!(e&&"object"==typeof e)};function o(e){var n;return r(e)&&"string"==typeof e.kind&&r(n=e)&&!!n.args}function i(e){return!!o(e)&&"string"==typeof e.args.label}}),a("3SNLU",function(e,n){t(e.exports,"isNode",()=>r);function r(){return"undefined"==typeof window}}),a("4svrT",function(e,n){t(e.exports,"pick",()=>r);function r(e,n,t){return e[n]}}),a("01gfL",function(e,n){t(e.exports,"Priority",()=>o),t(e.exports,"rpcRequest",()=>a);var r,o,i=s("iwcyJ");(r=o||(o={}))[r.HIGHEST=9e3]="HIGHEST",r[r.NORMAL=600]="NORMAL",r[r.LOWEST=300]="LOWEST";var a=function(e,n){return void 0===n&&(n=o.NORMAL),{kind:"rpc_request",args:{label:(0,i.uuid)(),priority:n},body:e}}}),a("iwcyJ",function(e,n){t(e.exports,"uuid",()=>r);function r(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=16*Math.random()|0;return("x"===e?n:3&n|8).toString(16)})}}),a("f5H0j",function(e,n){t(e.exports,"CONFIG_DEFAULTS",()=>i),t(e.exports,"generateConfig",()=>c),s("jOzD0");var o=s("3SNLU"),i={speed:100},a=function(e){try{return JSON.parse(atob(e.split(".")[1]))}catch(e){throw console.warn(e),Error("Unable to parse token. Is it properly formatted?")}},c=function(e){if((0,o.isNode)()&&!r.atob)throw Error("NOTE TO NODEJS USERS:\n\nThis library requires an 'atob()' function.\nPlease fix this first.\nSOLUTION: https://github.com/FarmBot/farmbot-js/issues/33");var n=a(e.token);return{speed:e.speed||i.speed,token:e.token,secure:!1!==e.secure,mqttServer:(0,o.isNode)()?"mqtt://".concat(n.mqtt,":1883"):n.mqtt_ws,mqttUsername:n.bot||"MISSING_MQTT_USERNAME",LAST_PING_OUT:0,LAST_PING_IN:0}}}),a("dPMce",function(e,n){t(e.exports,"ResourceAdapter",()=>a),s("gwFY1");var r=s("iwcyJ"),o=s("kGTNw"),i=s("d1UZh"),a=function(e,n){var t=this;this.parent=e,this.username=n,this.destroy=function(e){var n=t.parent.client;return n?t.doDestroy(n,e.kind,e.id):(0,i.rejectRpc)()},this.save=function(e){var n=t.parent.client;return n?t.doSave(n,e):(0,i.rejectRpc)()},this.destroyAll=function(e){return Promise.all(e.map(function(e){return t.destroy(e)}))},this.doDestroy=function(e,n,i){return new Promise(function(s,a){var c=(0,r.uuid)();t.parent.on(c,(0,o.resolveOrReject)(s,a)),e.publish((0,o.outboundChanFor)(t.username,"destroy",n,c,i),"")})},this.doSave=function(e,n){return new Promise(function(i,s){var a=(0,r.uuid)();t.parent.on(a,(0,o.resolveOrReject)(i,s));var c=(0,o.outboundChanFor)(t.username,"save",n.kind,a,n.body.id);e.publish(c,JSON.stringify(n.body))})}}}),a("kGTNw",function(e,n){t(e.exports,"outboundChanFor",()=>r),t(e.exports,"internalError",()=>o),t(e.exports,"resolveOrReject",()=>i);var r=function(e,n,t,r,o){return void 0===o&&(o=0),["bot",e,"resources_v0",n,t,r,o].join("/")},o={kind:"rpc_error",args:{label:"BROWSER_LEVEL_FAILURE"},body:[{kind:"explanation",args:{message:"Tried to perform batch operation before connect."}}]},i=function(e,n){return function(t){return("rpc_ok"==t.kind?e:n)(t)}}}),a("d1UZh",function(e,n){t(e.exports,"rejectRpc",()=>o);var r=s("kGTNw"),o=function(){return Promise.reject(r.internalError)}}),a("7tZ6d",function(e,n){var r,o,i,s,a,c;t(e.exports,"MqttChanName",()=>r),t(e.exports,"FbjsEventName",()=>o),t(e.exports,"Misc",()=>i),(s=r||(r={})).fromApi="from_api",s.fromClients="from_clients",s.fromDevice="from_device",s.logs="logs",s.status="status",s.sync="sync",/** THIS ONE IS SPECIAL. */s.publicBroadcast="public_broadcast",s.pong="pong",/** State tree update. */(a=o||(o={})).status="status",/** When a log is received */a.logs="logs",/** When an unexpected message is received */a.malformed="malformed",/** Unreliable. */a.offline="offline",/** Fired on connect. */a.online="online",/** Fires when the API sends an MQTT message to users. */a.publicBroadcast="public_broadcast",/** Fires after any message is sent from current client. */a.sent="sent",/** Used by resource auto-sync. */a.sync="sync",/** When a key is removed from the device state tree. */a.remove="remove",/** Channel delimiter for MQTT channels. */(c=i||(i={})).MQTT_DELIM="/",/** A null value when dealing with empty `pair` nodes in CeleryScript. */c.NULL="null",/** Reconnect interval for MQTT.js */c[c.RECONNECT_THROTTLE_MS=1e3]="RECONNECT_THROTTLE_MS"}),a("aWv1W",function(e,n){t(e.exports,"timestamp",()=>r);/** Returns a timestamp in ms. */function r(){return Math.round(new Date().getTime()/100)}// type RejectFn = (reason?: any) => void; +this.doPing=function(e,n){return Promise.race([new Promise(function(e,t){return setTimeout(function(){return t(-0)},n)}),new Promise(function(n,t){r.on(""+e,function(){var t=(0,l.timestamp)();r.setConfig("LAST_PING_IN",t),n(t-e)},!0);var o=r.channel.ping(e);r.client&&r.client.publish(o,JSON.stringify(e))})])},/** Bootstrap the device onto the MQTT broker. */this.connect=function(){var t=r.config,o=t.mqttUsername,i=t.token,s=t.mqttServer,c=d.Misc.RECONNECT_THROTTLE_MS,u=(0,e.connect)(s,{clean:!0,clientId:"FBJS-".concat(n.VERSION,"-").concat((0,a.uuid)()),password:i,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:c,username:o});r.client=u,r.resources=new f.ResourceAdapter(r,r.config.mqttUsername),u.on("message",r._onmessage),u.on("offline",function(){return r.emit(d.FbjsEventName.offline,{})}),u.on("connect",function(){return r.emit(d.FbjsEventName.online,{})});var p=[r.channel.logs,r.channel.status,r.channel.sync,r.channel.toClient,r.channel.pong];return u.subscribe(p),new Promise(function(e,n){if(r.client)r.client.once("connect",function(){return e(r)});else throw Error("Please connect first.")})},this._events={},this.config=(0,u.generateConfig)(t),this.resources=new f.ResourceAdapter(this,this.config.mqttUsername)}return Object.defineProperty(n.prototype,"channel",{/** Dictionary of all relevant MQTT channels the bot uses. */get:function(){var e=this.config.mqttUsername;return{/** From the browser, usually. */toDevice:"bot/".concat(e,"/").concat(d.MqttChanName.fromClients),/** From farmbot */toClient:"bot/".concat(e,"/").concat(d.MqttChanName.fromDevice),status:"bot/".concat(e,"/").concat(d.MqttChanName.status),logs:"bot/".concat(e,"/").concat(d.MqttChanName.logs),sync:"bot/".concat(e,"/").concat(d.MqttChanName.sync,"/#"),/** Read only */pong:"bot/".concat(e,"/pong/#"),/** Write only: bot/${deviceName}/ping/${timestamp} */ping:function(n){return"bot/".concat(e,"/ping/").concat(n)}}},enumerable:!1,configurable:!0}),n.VERSION="15.8.3",n}()}),a("jOzD0",function(e,r){t(e.exports,"stringToBuffer",()=>d),t(e.exports,"bufferToString",()=>l);var o=s("8i5S2"),i=s("byyGl"),a=s("3SNLU"),c=s("4svrT"),u=s("01gfL"),f=s("iwcyJ");function d(e){var n=e.split("").map(function(e){return e.charCodeAt(0)});return new Uint8Array(n)}var p="undefined"!=typeof util&&util.TextDecoder?new util.TextDecoder:"undefined"!=typeof window&&window.TextDecoder?new window.TextDecoder:{decode:function(e){var n=[];return e.forEach(function(e){return n.push(String.fromCharCode(e))}),n.join("")}},l=function(e){return p.decode(e)};n(e.exports,o),n(e.exports,i),n(e.exports,a),n(e.exports,c),n(e.exports,u),n(e.exports,f)}),a("8i5S2",function(e,n){t(e.exports,"coordinate",()=>r);function r(e,n,t){return{kind:"coordinate",args:{x:e,y:n,z:t}}}}),a("byyGl",function(e,n){t(e.exports,"isCeleryScript",()=>o),t(e.exports,"hasLabel",()=>i);var r=function(e){return!!(e&&"object"==typeof e)};function o(e){var n;return r(e)&&"string"==typeof e.kind&&r(n=e)&&!!n.args}function i(e){return!!o(e)&&"string"==typeof e.args.label}}),a("3SNLU",function(e,n){t(e.exports,"isNode",()=>r);function r(){return"undefined"==typeof window}}),a("4svrT",function(e,n){t(e.exports,"pick",()=>r);function r(e,n,t){return e[n]}}),a("01gfL",function(e,n){t(e.exports,"Priority",()=>o),t(e.exports,"rpcRequest",()=>a);var r,o,i=s("iwcyJ");(r=o||(o={}))[r.HIGHEST=9e3]="HIGHEST",r[r.NORMAL=600]="NORMAL",r[r.LOWEST=300]="LOWEST";var a=function(e,n){return void 0===n&&(n=o.NORMAL),{kind:"rpc_request",args:{label:(0,i.uuid)(),priority:n},body:e}}}),a("iwcyJ",function(e,n){t(e.exports,"uuid",()=>r);function r(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=16*Math.random()|0;return("x"===e?n:3&n|8).toString(16)})}}),a("f5H0j",function(e,n){t(e.exports,"CONFIG_DEFAULTS",()=>i),t(e.exports,"generateConfig",()=>c),s("jOzD0");var o=s("3SNLU"),i={speed:100},a=function(e){try{return JSON.parse(atob(e.split(".")[1]))}catch(e){throw console.warn(e),Error("Unable to parse token. Is it properly formatted?")}},c=function(e){if((0,o.isNode)()&&!r.atob)throw Error("NOTE TO NODEJS USERS:\n\nThis library requires an 'atob()' function.\nPlease fix this first.\nSOLUTION: https://github.com/FarmBot/farmbot-js/issues/33");var n=a(e.token);return{speed:e.speed||i.speed,token:e.token,secure:!1!==e.secure,mqttServer:(0,o.isNode)()?"mqtt://".concat(n.mqtt,":1883"):n.mqtt_ws,mqttUsername:n.bot||"MISSING_MQTT_USERNAME",LAST_PING_OUT:0,LAST_PING_IN:0}}}),a("dPMce",function(e,n){t(e.exports,"ResourceAdapter",()=>a),s("gwFY1");var r=s("iwcyJ"),o=s("kGTNw"),i=s("d1UZh"),a=function(e,n){var t=this;this.parent=e,this.username=n,this.destroy=function(e){var n=t.parent.client;return n?t.doDestroy(n,e.kind,e.id):(0,i.rejectRpc)()},this.save=function(e){var n=t.parent.client;return n?t.doSave(n,e):(0,i.rejectRpc)()},this.destroyAll=function(e){return Promise.all(e.map(function(e){return t.destroy(e)}))},this.doDestroy=function(e,n,i){return new Promise(function(s,a){var c=(0,r.uuid)();t.parent.on(c,(0,o.resolveOrReject)(s,a)),e.publish((0,o.outboundChanFor)(t.username,"destroy",n,c,i),"")})},this.doSave=function(e,n){return new Promise(function(i,s){var a=(0,r.uuid)();t.parent.on(a,(0,o.resolveOrReject)(i,s));var c=(0,o.outboundChanFor)(t.username,"save",n.kind,a,n.body.id);e.publish(c,JSON.stringify(n.body))})}}}),a("kGTNw",function(e,n){t(e.exports,"outboundChanFor",()=>r),t(e.exports,"internalError",()=>o),t(e.exports,"resolveOrReject",()=>i);var r=function(e,n,t,r,o){return void 0===o&&(o=0),["bot",e,"resources_v0",n,t,r,o].join("/")},o={kind:"rpc_error",args:{label:"BROWSER_LEVEL_FAILURE"},body:[{kind:"explanation",args:{message:"Tried to perform batch operation before connect."}}]},i=function(e,n){return function(t){return("rpc_ok"==t.kind?e:n)(t)}}}),a("d1UZh",function(e,n){t(e.exports,"rejectRpc",()=>o);var r=s("kGTNw"),o=function(){return Promise.reject(r.internalError)}}),a("7tZ6d",function(e,n){var r,o,i,s,a,c;t(e.exports,"MqttChanName",()=>r),t(e.exports,"FbjsEventName",()=>o),t(e.exports,"Misc",()=>i),(s=r||(r={})).fromApi="from_api",s.fromClients="from_clients",s.fromDevice="from_device",s.logs="logs",s.status="status",s.sync="sync",/** THIS ONE IS SPECIAL. */s.publicBroadcast="public_broadcast",s.pong="pong",/** State tree update. */(a=o||(o={})).status="status",/** When a log is received */a.logs="logs",/** When an unexpected message is received */a.malformed="malformed",/** Unreliable. */a.offline="offline",/** Fired on connect. */a.online="online",/** Fires when the API sends an MQTT message to users. */a.publicBroadcast="public_broadcast",/** Fires after any message is sent from current client. */a.sent="sent",/** Used by resource auto-sync. */a.sync="sync",/** When a key is removed from the device state tree. */a.remove="remove",/** Channel delimiter for MQTT channels. */(c=i||(i={})).MQTT_DELIM="/",/** A null value when dealing with empty `pair` nodes in CeleryScript. */c.NULL="null",/** Reconnect interval for MQTT.js */c[c.RECONNECT_THROTTLE_MS=1e3]="RECONNECT_THROTTLE_MS"}),a("aWv1W",function(e,n){t(e.exports,"timestamp",()=>r);/** Returns a timestamp in ms. */function r(){return Math.round(new Date().getTime()/100)}// type RejectFn = (reason?: any) => void; // type ResolveFn = (value?: T | PromiseLike) => void; // interface Executor { // (x: (resolve: ResolveFn, reject: RejectFn) => void): Promise; diff --git a/dist/farmbot_single_file.js.map b/dist/farmbot_single_file.js.map index 2256f6b..35d27c4 100644 --- a/dist/farmbot_single_file.js.map +++ b/dist/farmbot_single_file.js.map @@ -1 +1 @@ -{"mappings":"A,I,E,Q,Q,S,E,C,C,C,E,O,O,I,C,G,O,C,S,C,E,Y,G,A,e,G,E,c,C,I,O,c,C,E,E,C,W,C,E,I,W,O,C,C,E,A,C,E,G,C,C,S,E,C,C,C,C,C,C,C,E,O,c,C,E,E,C,I,E,I,E,W,C,E,a,C,C,E,C,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C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/coordinate.ts","src/util/is_celery_script.ts","src/util/is_node.ts","src/util/pick.ts","src/util/rpc_request.ts","src/util/uuid.ts","src/config.ts","src/resources/resource_adapter.ts","src/resources/support.ts","src/resources/reject_rpc.ts","src/constants.ts","src/util/time.ts","src/interfaces.ts","src/resources/tagged_resource.ts","src/farmbot_single_file.js"],"sourcesContent":["var $b8E1b$mqtt = require(\"mqtt\");\n\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n }\n });\n });\n\n return dest;\n}\n\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequire1c57\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequire1c57\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nparcelRegister(\"gwFY1\", function(module, exports) {\n\nvar $h19jY = parcelRequire(\"h19jY\");\n\nvar $fTGM0 = parcelRequire(\"fTGM0\");\n\nvar $3tZ8P = parcelRequire(\"3tZ8P\");\n\nvar $jOzD0 = parcelRequire(\"jOzD0\");\n\nvar $bFr0L = parcelRequire(\"bFr0L\");\n$parcel$exportWildcard(module.exports, $h19jY);\n$parcel$exportWildcard(module.exports, $fTGM0);\n$parcel$exportWildcard(module.exports, $3tZ8P);\n$parcel$exportWildcard(module.exports, $jOzD0);\n$parcel$exportWildcard(module.exports, $bFr0L);\n\n});\nparcelRegister(\"h19jY\", function(module, exports) {\n\n$parcel$export(module.exports, \"LATEST_VERSION\", () => $c639c2a4041df2b3$export$5bd6772f122cb888);\n$parcel$export(module.exports, \"DIGITAL\", () => $c639c2a4041df2b3$export$642ebf9ec2e6a14a);\n$parcel$export(module.exports, \"ANALOG\", () => $c639c2a4041df2b3$export$59b5878345794ac6);\n// THIS INTERFACE WAS AUTO GENERATED ON 2023-07-27\n// DO NOT EDIT THIS FILE.\n// IT WILL BE OVERWRITTEN ON EVERY CELERYSCRIPT UPGRADE.\nvar $c639c2a4041df2b3$export$5bd6772f122cb888 = 20180209;\nvar $c639c2a4041df2b3$export$642ebf9ec2e6a14a = 0;\nvar $c639c2a4041df2b3$export$59b5878345794ac6 = 1;\n\n});\n\nparcelRegister(\"fTGM0\", function(module, exports) {\n\n$parcel$export(module.exports, \"Farmbot\", () => $b92d2bf8eb506f9b$export$3ab9a2df6016a88a);\n\nparcelRequire(\"jOzD0\");\nvar $01gfL = parcelRequire(\"01gfL\");\nvar $8i5S2 = parcelRequire(\"8i5S2\");\nvar $iwcyJ = parcelRequire(\"iwcyJ\");\nparcelRequire(\"gwFY1\");\nvar $jOzD0 = parcelRequire(\"jOzD0\");\n\nvar $f5H0j = parcelRequire(\"f5H0j\");\n\nvar $dPMce = parcelRequire(\"dPMce\");\n\nvar $7tZ6d = parcelRequire(\"7tZ6d\");\n\nvar $byyGl = parcelRequire(\"byyGl\");\n\nvar $aWv1W = parcelRequire(\"aWv1W\");\n\nvar $01gfL = parcelRequire(\"01gfL\");\nvar $b92d2bf8eb506f9b$export$3ab9a2df6016a88a = /** @class */ function() {\n function Farmbot(input) {\n var _this = this;\n /** Get a Farmbot Constructor Parameter. */ this.getConfig = function(key) {\n return _this.config[key];\n };\n /** Set a Farmbot Constructor Parameter. */ this.setConfig = function(key, value) {\n _this.config[key] = value;\n };\n /**\n * Installs a \"Farmware\" (plugin) onto the bot's SD card.\n * URL must point to a valid Farmware manifest JSON document.\n */ this.installFarmware = function(url) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"install_farmware\",\n args: {\n url: url\n }\n }\n ]));\n };\n /**\n * Checks for updates on a particular Farmware plugin when given the name of\n * a Farmware. `updateFarmware(\"take-photo\")`\n */ this.updateFarmware = function(pkg) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"update_farmware\",\n args: {\n package: pkg\n }\n }\n ]));\n };\n /** Uninstall a Farmware plugin. */ this.removeFarmware = function(pkg) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"remove_farmware\",\n args: {\n package: pkg\n }\n }\n ]));\n };\n /**\n * Installs \"Farmware\" (plugins) authored by FarmBot, Inc.\n * onto the bot's SD card.\n */ this.installFirstPartyFarmware = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"install_first_party_farmware\",\n args: {}\n }\n ]));\n };\n /**\n * Deactivate FarmBot OS completely (shutdown).\n * Useful before unplugging the power.\n */ this.powerOff = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"power_off\",\n args: {}\n }\n ]));\n };\n /** Restart FarmBot OS. */ this.reboot = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"reboot\",\n args: {\n package: \"farmbot_os\"\n }\n }\n ]));\n };\n /** Reinitialize the FarmBot microcontroller firmware. */ this.rebootFirmware = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"reboot\",\n args: {\n package: \"arduino_firmware\"\n }\n }\n ]));\n };\n /** Check for new versions of FarmBot OS.\n * Downloads and installs if available. */ this.checkUpdates = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"check_updates\",\n args: {\n package: \"farmbot_os\"\n }\n }\n ]));\n };\n /** THIS WILL RESET THE SD CARD, deleting all non-factory data!\n * Be careful!! */ this.resetOS = function() {\n return _this.publish((0, $01gfL.rpcRequest)([\n {\n kind: \"factory_reset\",\n args: {\n package: \"farmbot_os\"\n }\n }\n ]));\n };\n /** WARNING: will reset all firmware (hardware) settings! */ this.resetMCU = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"factory_reset\",\n args: {\n package: \"arduino_firmware\"\n }\n }\n ]));\n };\n this.flashFirmware = function(/** one of: \"arduino\"|\"express_k10\"|\"farmduino_k14\"|\"farmduino\" */ firmware_name) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"flash_firmware\",\n args: {\n package: firmware_name\n }\n }\n ]));\n };\n /**\n * Lock the bot from moving (E-STOP). Turns off peripherals and motors. This\n * also will pause running regimens and cause any running sequences to exit.\n */ this.emergencyLock = function() {\n var body = [\n {\n kind: \"emergency_lock\",\n args: {}\n }\n ];\n var rpc = (0, $01gfL.rpcRequest)(body, (0, $01gfL.Priority).HIGHEST);\n return _this.send(rpc);\n };\n /** Unlock the bot when the user says it is safe. */ this.emergencyUnlock = function() {\n var body = [\n {\n kind: \"emergency_unlock\",\n args: {}\n }\n ];\n var rpc = (0, $01gfL.rpcRequest)(body, (0, $01gfL.Priority).HIGHEST);\n return _this.send(rpc);\n };\n /** Execute a sequence by its ID on the FarmBot API. */ this.execSequence = function(sequence_id, body) {\n if (body === void 0) body = [];\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"execute\",\n args: {\n sequence_id: sequence_id\n },\n body: body\n }\n ]));\n };\n /** Run an installed Farmware plugin on the SD Card. */ this.execScript = function(/** Name of the Farmware. */ label, /** Optional ENV vars to pass the Farmware. */ envVars) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"execute_script\",\n args: {\n label: label\n },\n body: envVars\n }\n ]));\n };\n /** Bring a particular axis (or all of them) to position 0 in Z Y X order. */ this.home = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"home\",\n args: args\n }\n ]));\n };\n /** Use end stops or encoders to figure out where 0,0,0 is in Z Y X axis\n * order. WON'T WORK WITHOUT ENCODERS OR END STOPS! A blockage or stall\n * during this command will set that position as zero. Use carefully. */ this.findHome = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"find_home\",\n args: args\n }\n ]));\n };\n /** Move FarmBot to an absolute point. */ this.moveAbsolute = function(args) {\n var x = args.x, y = args.y, z = args.z;\n var speed = args.speed || (0, $f5H0j.CONFIG_DEFAULTS).speed;\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"move_absolute\",\n args: {\n location: (0, $8i5S2.coordinate)(x, y, z),\n offset: (0, $8i5S2.coordinate)(0, 0, 0),\n speed: speed\n }\n }\n ]));\n };\n /** Move FarmBot to position relative to its current position. */ this.moveRelative = function(args) {\n var x = args.x, y = args.y, z = args.z;\n var speed = args.speed || (0, $f5H0j.CONFIG_DEFAULTS).speed;\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"move_relative\",\n args: {\n x: x,\n y: y,\n z: z,\n speed: speed\n }\n }\n ]));\n };\n /** Set a GPIO pin to a particular value. */ this.writePin = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"write_pin\",\n args: args\n }\n ]));\n };\n /** Read the value of a GPIO pin. Will create a SensorReading if it's\n * a sensor. */ this.readPin = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"read_pin\",\n args: args\n }\n ]));\n };\n /** Reverse the value of a digital pin. */ this.togglePin = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"toggle_pin\",\n args: args\n }\n ]));\n };\n /** Read the status of the bot. Should not be needed unless you are first\n * logging in to the device, since the device pushes new states out on\n * every update. */ this.readStatus = function(args) {\n if (args === void 0) args = {};\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"read_status\",\n args: args\n }\n ]));\n };\n /** Snap a photo and send to the API for post processing. */ this.takePhoto = function(args) {\n if (args === void 0) args = {};\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"take_photo\",\n args: args\n }\n ]));\n };\n /** Download/apply all of the latest FarmBot API JSON resources (plants,\n * account info, etc.) to the device. */ this.sync = function(args) {\n if (args === void 0) args = {};\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"sync\",\n args: args\n }\n ]));\n };\n /**\n * Set the current position of the given axis to 0.\n * Example: Sending `bot.setZero(\"x\")` at x: 255 will translate position\n * 255 to 0, causing that position to be x: 0.\n */ this.setZero = function(axis) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"zero\",\n args: {\n axis: axis\n }\n }\n ]));\n };\n /**\n * Set user ENV vars (usually used by 3rd-party Farmware plugins).\n * Set value to `undefined` to unset.\n */ this.setUserEnv = function(configs) {\n var body = Object.keys(configs).map(function(label) {\n return {\n kind: \"pair\",\n args: {\n label: label,\n value: configs[label] || (0, $7tZ6d.Misc).NULL\n }\n };\n });\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"set_user_env\",\n args: {},\n body: body\n }\n ]));\n };\n this.sendMessage = function(message_type, message, channels) {\n if (channels === void 0) channels = [];\n _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"send_message\",\n args: {\n message_type: message_type,\n message: message\n },\n body: channels.map(function(channel_name) {\n return {\n kind: \"channel\",\n args: {\n channel_name: channel_name\n }\n };\n })\n }\n ]));\n };\n /** Control servos on pins 4 and 5. */ this.setServoAngle = function(args) {\n var result = _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"set_servo_angle\",\n args: args\n }\n ]));\n // Celery script can't validate `pin_number` and `pin_value` the way we need\n // for `set_servo_angle`. We will send the RPC command off, but also\n // crash the client to aid debugging.\n if (![\n 4,\n 5,\n 6,\n 11\n ].includes(args.pin_number)) throw new Error(\"Servos only work on pins 4 and 5\");\n if (args.pin_value > 180 || args.pin_value < 0) throw new Error(\"Pin value outside of 0...180 range\");\n return result;\n };\n /**\n * Find the axis extents using encoder, motor, or end-stop feedback.\n * Will set a new home position and a new axis length for the given axis.\n */ this.calibrate = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"calibrate\",\n args: args\n }\n ]));\n };\n this.lua = function(lua) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"lua\",\n args: {\n lua: lua\n }\n }\n ]));\n };\n /**\n * Retrieves all of the event handlers for a particular event.\n * Returns an empty array if the event did not exist.\n */ this.event = function(name) {\n _this._events[name] = _this._events[name] || [];\n return _this._events[name];\n };\n this.on = function(event, value, once) {\n if (once === void 0) once = false;\n _this.event(event).push({\n value: value,\n once: once,\n event: event\n });\n };\n this.emit = function(event, data) {\n var nextArray = [];\n _this.event(event).concat(_this.event(\"*\")).forEach(function(handler) {\n try {\n handler.value(data, event);\n if (!handler.once && handler.event === event) nextArray.push(handler);\n } catch (e) {\n var msg = \"Exception thrown while handling '\".concat(event, \"' event.\");\n console.warn(msg);\n console.dir(e);\n }\n });\n if (nextArray.length === 0) delete _this._events[event];\n else _this._events[event] = nextArray;\n };\n /** Low-level means of sending MQTT packets. Does not check format. Does not\n * acknowledge confirmation. Probably not the one you want. */ this.publish = function(msg, important) {\n if (important === void 0) important = true;\n if (_this.client) {\n _this.emit((0, $7tZ6d.FbjsEventName).sent, msg);\n /** SEE: https://github.com/mqttjs/MQTT.js#client */ _this.client.publish(_this.channel.toDevice, JSON.stringify(msg));\n } else {\n if (important) throw new Error(\"Not connected to server\");\n }\n };\n /** Low-level means of sending MQTT RPC commands to the bot. Acknowledges\n * receipt of message, but does not check formatting. Consider using higher\n * level methods like .moveRelative(), .calibrate(), etc....\n */ this.send = function(input) {\n return new Promise(function(resolve, reject) {\n _this.publish(input);\n function handler(response) {\n switch(response.kind){\n case \"rpc_ok\":\n return resolve(response);\n case \"rpc_error\":\n var reason = (response.body || []).map(function(x) {\n return x.args.message;\n }).join(\", \");\n return reject(new Error(\"Problem sending RPC command: \" + reason));\n default:\n console.dir(response);\n throw new Error(\"Got a bad CeleryScript node.\");\n }\n }\n _this.on(input.args.label, handler, true);\n });\n };\n /** Main entry point for all MQTT packets. */ this._onmessage = function(chan, buffer) {\n var original = (0, $jOzD0.bufferToString)(buffer);\n var segments = chan.split((0, $7tZ6d.Misc).MQTT_DELIM);\n var emit = _this.emit;\n try {\n var msg = JSON.parse(original);\n if (segments[0] == (0, $7tZ6d.MqttChanName).publicBroadcast) return emit((0, $7tZ6d.MqttChanName).publicBroadcast, msg);\n switch(segments[2]){\n case (0, $7tZ6d.MqttChanName).logs:\n return emit((0, $7tZ6d.FbjsEventName).logs, msg);\n case (0, $7tZ6d.MqttChanName).status:\n return emit((0, $7tZ6d.FbjsEventName).status, msg);\n case (0, $7tZ6d.MqttChanName).sync:\n return emit((0, $7tZ6d.FbjsEventName).sync, msg);\n case (0, $7tZ6d.MqttChanName).pong:\n return emit(segments[3], msg);\n default:\n var ev = (0, $byyGl.hasLabel)(msg) ? msg.args.label : (0, $7tZ6d.FbjsEventName).malformed;\n return emit(ev, msg);\n }\n } catch (error) {\n console.dir({\n text: \"Could not parse inbound message from MQTT.\",\n error: error\n });\n emit((0, $7tZ6d.FbjsEventName).malformed, original);\n }\n };\n this.ping = function(timeout, now) {\n if (timeout === void 0) timeout = 10000;\n if (now === void 0) now = (0, $aWv1W.timestamp)();\n _this.setConfig(\"LAST_PING_OUT\", now);\n return _this.doPing(now, timeout);\n };\n // STEP 0: Subscribe to `bot/device_23/pong/#`\n // STEP 0: Send `bot/device_23/ping/3123123`\n // STEP 0: Receive `bot/device_23/pong/3123123`\n this.doPing = function(startedAt, timeout) {\n var timeoutPromise = new Promise(function(_, rej) {\n return setTimeout(function() {\n return rej(-0);\n }, timeout);\n });\n var pingPromise = new Promise(function(res, _) {\n var ok = function() {\n var t = (0, $aWv1W.timestamp)();\n _this.setConfig(\"LAST_PING_IN\", t);\n res(t - startedAt);\n };\n _this.on(\"\" + startedAt, ok, true);\n var chan = _this.channel.ping(startedAt);\n if (_this.client) _this.client.publish(chan, JSON.stringify(startedAt));\n });\n return Promise.race([\n timeoutPromise,\n pingPromise\n ]);\n };\n /** Bootstrap the device onto the MQTT broker. */ this.connect = function() {\n var _a = _this.config, mqttUsername = _a.mqttUsername, token = _a.token, mqttServer = _a.mqttServer;\n var reconnectPeriod = (0, $7tZ6d.Misc).RECONNECT_THROTTLE_MS;\n var client = (0, $b8E1b$mqtt.connect)(mqttServer, {\n clean: true,\n clientId: \"FBJS-\".concat(Farmbot.VERSION, \"-\").concat((0, $iwcyJ.uuid)()),\n password: token,\n protocolId: \"MQTT\",\n protocolVersion: 4,\n reconnectPeriod: reconnectPeriod,\n username: mqttUsername\n });\n _this.client = client;\n _this.resources = new (0, $dPMce.ResourceAdapter)(_this, _this.config.mqttUsername);\n client.on(\"message\", _this._onmessage);\n client.on(\"offline\", function() {\n return _this.emit((0, $7tZ6d.FbjsEventName).offline, {});\n });\n client.on(\"connect\", function() {\n return _this.emit((0, $7tZ6d.FbjsEventName).online, {});\n });\n var channels = [\n _this.channel.logs,\n _this.channel.status,\n _this.channel.sync,\n _this.channel.toClient,\n _this.channel.pong\n ];\n client.subscribe(channels);\n return new Promise(function(resolve, _reject) {\n if (_this.client) _this.client.once(\"connect\", function() {\n return resolve(_this);\n });\n else throw new Error(\"Please connect first.\");\n });\n };\n this._events = {};\n this.config = (0, $f5H0j.generateConfig)(input);\n this.resources = new (0, $dPMce.ResourceAdapter)(this, this.config.mqttUsername);\n }\n Object.defineProperty(Farmbot.prototype, \"channel\", {\n /** Dictionary of all relevant MQTT channels the bot uses. */ get: function() {\n var deviceName = this.config.mqttUsername;\n return {\n /** From the browser, usually. */ toDevice: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).fromClients),\n /** From farmbot */ toClient: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).fromDevice),\n status: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).status),\n logs: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).logs),\n sync: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).sync, \"/#\"),\n /** Read only */ pong: \"bot/\".concat(deviceName, \"/pong/#\"),\n /** Write only: bot/${deviceName}/ping/${timestamp} */ ping: function(tStamp) {\n return \"bot/\".concat(deviceName, \"/ping/\").concat(tStamp);\n }\n };\n },\n enumerable: false,\n configurable: true\n });\n Farmbot.VERSION = \"15.8.2\";\n return Farmbot;\n}();\n\n});\nparcelRegister(\"jOzD0\", function(module, exports) {\n\n$parcel$export(module.exports, \"stringToBuffer\", () => $e6ce52d33b3b9851$export$1e95461c937e230d);\n$parcel$export(module.exports, \"bufferToString\", () => $e6ce52d33b3b9851$export$4f75cc6593308bd6);\n\nvar $8i5S2 = parcelRequire(\"8i5S2\");\n\nvar $byyGl = parcelRequire(\"byyGl\");\n\nvar $3SNLU = parcelRequire(\"3SNLU\");\n\nvar $4svrT = parcelRequire(\"4svrT\");\n\nvar $01gfL = parcelRequire(\"01gfL\");\n\nvar $iwcyJ = parcelRequire(\"iwcyJ\");\nfunction $e6ce52d33b3b9851$export$1e95461c937e230d(str) {\n var regular_array = str.split(\"\").map(function(x) {\n return x.charCodeAt(0);\n });\n var data16 = new Uint8Array(regular_array);\n return data16;\n}\nfunction $e6ce52d33b3b9851$var$newDecoder() {\n if (typeof util !== \"undefined\" && util.TextDecoder) return new util.TextDecoder();\n if (typeof window !== \"undefined\" && window.TextDecoder) return new window.TextDecoder();\n return {\n decode: function(buffer) {\n var chars = [];\n buffer.forEach(function(x) {\n return chars.push(String.fromCharCode(x));\n });\n return chars.join(\"\");\n }\n };\n}\nvar $e6ce52d33b3b9851$var$td = $e6ce52d33b3b9851$var$newDecoder();\nvar $e6ce52d33b3b9851$export$4f75cc6593308bd6 = function(b) {\n return $e6ce52d33b3b9851$var$td.decode(b);\n};\n$parcel$exportWildcard(module.exports, $8i5S2);\n$parcel$exportWildcard(module.exports, $byyGl);\n$parcel$exportWildcard(module.exports, $3SNLU);\n$parcel$exportWildcard(module.exports, $4svrT);\n$parcel$exportWildcard(module.exports, $01gfL);\n$parcel$exportWildcard(module.exports, $iwcyJ);\n\n});\nparcelRegister(\"8i5S2\", function(module, exports) {\n\n$parcel$export(module.exports, \"coordinate\", () => $60948eee8fcc500d$export$bf56ff1a05c69b9a);\nfunction $60948eee8fcc500d$export$bf56ff1a05c69b9a(x, y, z) {\n return {\n kind: \"coordinate\",\n args: {\n x: x,\n y: y,\n z: z\n }\n };\n}\n\n});\n\nparcelRegister(\"byyGl\", function(module, exports) {\n\n$parcel$export(module.exports, \"isCeleryScript\", () => $869dc5c8a17d7708$export$7b28645421dfad14);\n$parcel$export(module.exports, \"hasLabel\", () => $869dc5c8a17d7708$export$939ea909fc0c90e4);\nvar $869dc5c8a17d7708$var$isObj = function(o) {\n return !!(o && typeof o === \"object\");\n};\nvar $869dc5c8a17d7708$var$hasKind = function(o) {\n return typeof o.kind === \"string\";\n};\nvar $869dc5c8a17d7708$var$hasArgs = function(o) {\n return $869dc5c8a17d7708$var$isObj(o) && !!o.args;\n};\nfunction $869dc5c8a17d7708$export$7b28645421dfad14(x) {\n return $869dc5c8a17d7708$var$isObj(x) && $869dc5c8a17d7708$var$hasKind(x) && $869dc5c8a17d7708$var$hasArgs(x);\n}\nfunction $869dc5c8a17d7708$export$939ea909fc0c90e4(x) {\n if ($869dc5c8a17d7708$export$7b28645421dfad14(x)) return typeof x.args.label === \"string\";\n else return false;\n}\n\n});\n\nparcelRegister(\"3SNLU\", function(module, exports) {\n\n$parcel$export(module.exports, \"isNode\", () => $2d3d05e3f1851e01$export$8ee0fc9ee280b4ee);\nfunction $2d3d05e3f1851e01$export$8ee0fc9ee280b4ee() {\n return typeof window === \"undefined\";\n}\n\n});\n\nparcelRegister(\"4svrT\", function(module, exports) {\n\n$parcel$export(module.exports, \"pick\", () => $33f22c0e5ae5fa1f$export$357523c63a2253b9);\nfunction $33f22c0e5ae5fa1f$export$357523c63a2253b9(target, value, fallback) {\n var result = target[value];\n return result;\n}\n\n});\n\nparcelRegister(\"01gfL\", function(module, exports) {\n\n$parcel$export(module.exports, \"Priority\", () => $003cb3b035fb32f9$export$300334f671c43555);\n$parcel$export(module.exports, \"rpcRequest\", () => $003cb3b035fb32f9$export$d6d466271de85642);\n\nvar $iwcyJ = parcelRequire(\"iwcyJ\");\nvar $003cb3b035fb32f9$export$300334f671c43555;\n(function(Priority) {\n Priority[Priority[\"HIGHEST\"] = 9000] = \"HIGHEST\";\n Priority[Priority[\"NORMAL\"] = 600] = \"NORMAL\";\n Priority[Priority[\"LOWEST\"] = 300] = \"LOWEST\";\n})($003cb3b035fb32f9$export$300334f671c43555 || ($003cb3b035fb32f9$export$300334f671c43555 = {}));\nvar $003cb3b035fb32f9$export$d6d466271de85642 = function(body, priority) {\n if (priority === void 0) priority = $003cb3b035fb32f9$export$300334f671c43555.NORMAL;\n return {\n kind: \"rpc_request\",\n args: {\n label: (0, $iwcyJ.uuid)(),\n priority: priority\n },\n body: body\n };\n};\n\n});\nparcelRegister(\"iwcyJ\", function(module, exports) {\n\n$parcel$export(module.exports, \"uuid\", () => $d7b4f5289284df15$export$31b40729666a4ae0);\nfunction $d7b4f5289284df15$export$31b40729666a4ae0() {\n var template = \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\";\n var replaceChar = function(c) {\n var r = Math.random() * 16 | 0;\n var v = c === \"x\" ? r : r & 0x3 | 0x8;\n return v.toString(16);\n };\n return template.replace(/[xy]/g, replaceChar);\n}\n\n});\n\n\n\nparcelRegister(\"f5H0j\", function(module, exports) {\n\n$parcel$export(module.exports, \"CONFIG_DEFAULTS\", () => $afc8ae5bc0bbdf6a$export$429fe2716bb77ce4);\n$parcel$export(module.exports, \"generateConfig\", () => $afc8ae5bc0bbdf6a$export$2eafab8a593352a4);\nparcelRequire(\"jOzD0\");\nvar $3SNLU = parcelRequire(\"3SNLU\");\nvar $afc8ae5bc0bbdf6a$var$ERR_TOKEN_PARSE = \"Unable to parse token. Is it properly formatted?\";\nvar $afc8ae5bc0bbdf6a$export$429fe2716bb77ce4 = {\n speed: 100\n};\nvar $afc8ae5bc0bbdf6a$var$ERR_MISSING_MQTT_USERNAME = \"MISSING_MQTT_USERNAME\";\nvar $afc8ae5bc0bbdf6a$export$ddc74f6374f2ef10 = \"NOTE TO NODEJS USERS:\\n\\nThis library requires an 'atob()' function.\\nPlease fix this first.\\nSOLUTION: https://github.com/FarmBot/farmbot-js/issues/33\";\nvar $afc8ae5bc0bbdf6a$var$parseToken = function(input) {\n try {\n return JSON.parse(atob(input.split(\".\")[1]));\n } catch (e) {\n console.warn(e);\n throw new Error($afc8ae5bc0bbdf6a$var$ERR_TOKEN_PARSE);\n }\n};\nvar $afc8ae5bc0bbdf6a$export$2eafab8a593352a4 = function(input) {\n if ((0, $3SNLU.isNode)() && !$parcel$global.atob) throw new Error($afc8ae5bc0bbdf6a$export$ddc74f6374f2ef10);\n var t = $afc8ae5bc0bbdf6a$var$parseToken(input.token);\n return {\n speed: input.speed || $afc8ae5bc0bbdf6a$export$429fe2716bb77ce4.speed,\n token: input.token,\n secure: input.secure === false ? false : true,\n mqttServer: (0, $3SNLU.isNode)() ? \"mqtt://\".concat(t.mqtt, \":1883\") : t.mqtt_ws,\n mqttUsername: t.bot || $afc8ae5bc0bbdf6a$var$ERR_MISSING_MQTT_USERNAME,\n LAST_PING_OUT: 0,\n LAST_PING_IN: 0\n };\n};\n\n});\n\nparcelRegister(\"dPMce\", function(module, exports) {\n\n$parcel$export(module.exports, \"ResourceAdapter\", () => $a1256c8ef829f998$export$61d38aff960bd05b);\nparcelRequire(\"gwFY1\");\nvar $iwcyJ = parcelRequire(\"iwcyJ\");\n\nvar $kGTNw = parcelRequire(\"kGTNw\");\n\nvar $d1UZh = parcelRequire(\"d1UZh\");\nvar $a1256c8ef829f998$export$61d38aff960bd05b = /** @class */ function() {\n function ResourceAdapter(parent, username) {\n var _this = this;\n this.parent = parent;\n this.username = username;\n this.destroy = function(r) {\n var client = _this.parent.client;\n return client ? _this.doDestroy(client, r.kind, r.id) : (0, $d1UZh.rejectRpc)();\n };\n this.save = function(resource) {\n var client = _this.parent.client;\n return client ? _this.doSave(client, resource) : (0, $d1UZh.rejectRpc)();\n };\n this.destroyAll = function(req) {\n return Promise.all(req.map(function(r) {\n return _this.destroy(r);\n }));\n };\n this.doDestroy = function(client, kind, id) {\n return new Promise(function(res, rej) {\n var requestId = (0, $iwcyJ.uuid)();\n _this.parent.on(requestId, (0, $kGTNw.resolveOrReject)(res, rej));\n client.publish((0, $kGTNw.outboundChanFor)(_this.username, \"destroy\", kind, requestId, id), \"\");\n });\n };\n this.doSave = function(client, r) {\n return new Promise(function(res, rej) {\n var uid = (0, $iwcyJ.uuid)();\n _this.parent.on(uid, (0, $kGTNw.resolveOrReject)(res, rej));\n var chan = (0, $kGTNw.outboundChanFor)(_this.username, \"save\", r.kind, uid, r.body.id);\n client.publish(chan, JSON.stringify(r.body));\n });\n };\n }\n return ResourceAdapter;\n}();\n\n});\nparcelRegister(\"kGTNw\", function(module, exports) {\n\n$parcel$export(module.exports, \"outboundChanFor\", () => $f103032c79b02b9d$export$282f68fea638d11);\n$parcel$export(module.exports, \"internalError\", () => $f103032c79b02b9d$export$bcbf15ce904d591a);\n$parcel$export(module.exports, \"resolveOrReject\", () => $f103032c79b02b9d$export$cbefd47f9f016f08);\nvar $f103032c79b02b9d$export$282f68fea638d11 = function(username, op, kind, uuid, id) {\n if (id === void 0) id = 0;\n var segments = [\n \"bot\",\n username,\n \"resources_v0\",\n op,\n kind,\n uuid,\n id\n ];\n return segments.join(\"/\");\n};\nvar $f103032c79b02b9d$export$bcbf15ce904d591a = {\n kind: \"rpc_error\",\n args: {\n label: \"BROWSER_LEVEL_FAILURE\"\n },\n body: [\n {\n kind: \"explanation\",\n args: {\n message: \"Tried to perform batch operation before connect.\"\n }\n }\n ]\n};\nvar $f103032c79b02b9d$export$cbefd47f9f016f08 = function(res, rej) {\n return function(m) {\n return (m.kind == \"rpc_ok\" ? res : rej)(m);\n };\n};\n\n});\n\nparcelRegister(\"d1UZh\", function(module, exports) {\n\n$parcel$export(module.exports, \"rejectRpc\", () => $97c792dbbae05474$export$d53e1703f9959ce0);\n\nvar $kGTNw = parcelRequire(\"kGTNw\");\nvar $97c792dbbae05474$export$d53e1703f9959ce0 = function() {\n return Promise.reject((0, $kGTNw.internalError));\n};\n\n});\n\n\nparcelRegister(\"7tZ6d\", function(module, exports) {\n\n$parcel$export(module.exports, \"MqttChanName\", () => $572aa2e43a4df30f$export$51316fc5e371191b);\n$parcel$export(module.exports, \"FbjsEventName\", () => $572aa2e43a4df30f$export$9758e930bdf73341);\n$parcel$export(module.exports, \"Misc\", () => $572aa2e43a4df30f$export$4b3033a0406d3b);\nvar $572aa2e43a4df30f$export$51316fc5e371191b;\n(function(MqttChanName) {\n MqttChanName[\"fromApi\"] = \"from_api\";\n MqttChanName[\"fromClients\"] = \"from_clients\";\n MqttChanName[\"fromDevice\"] = \"from_device\";\n MqttChanName[\"logs\"] = \"logs\";\n MqttChanName[\"status\"] = \"status\";\n MqttChanName[\"sync\"] = \"sync\";\n /** THIS ONE IS SPECIAL. */ MqttChanName[\"publicBroadcast\"] = \"public_broadcast\";\n MqttChanName[\"pong\"] = \"pong\";\n})($572aa2e43a4df30f$export$51316fc5e371191b || ($572aa2e43a4df30f$export$51316fc5e371191b = {}));\nvar $572aa2e43a4df30f$export$9758e930bdf73341;\n(function(FbjsEventName) {\n /** State tree update. */ FbjsEventName[\"status\"] = \"status\";\n /** When a log is received */ FbjsEventName[\"logs\"] = \"logs\";\n /** When an unexpected message is received */ FbjsEventName[\"malformed\"] = \"malformed\";\n /** Unreliable. */ FbjsEventName[\"offline\"] = \"offline\";\n /** Fired on connect. */ FbjsEventName[\"online\"] = \"online\";\n /** Fires when the API sends an MQTT message to users. */ FbjsEventName[\"publicBroadcast\"] = \"public_broadcast\";\n /** Fires after any message is sent from current client. */ FbjsEventName[\"sent\"] = \"sent\";\n /** Used by resource auto-sync. */ FbjsEventName[\"sync\"] = \"sync\";\n /** When a key is removed from the device state tree. */ FbjsEventName[\"remove\"] = \"remove\";\n})($572aa2e43a4df30f$export$9758e930bdf73341 || ($572aa2e43a4df30f$export$9758e930bdf73341 = {}));\nvar $572aa2e43a4df30f$export$4b3033a0406d3b;\n(function(Misc) {\n /** Channel delimiter for MQTT channels. */ Misc[\"MQTT_DELIM\"] = \"/\";\n /** A null value when dealing with empty `pair` nodes in CeleryScript. */ Misc[\"NULL\"] = \"null\";\n /** Reconnect interval for MQTT.js */ Misc[Misc[\"RECONNECT_THROTTLE_MS\"] = 1000] = \"RECONNECT_THROTTLE_MS\";\n})($572aa2e43a4df30f$export$4b3033a0406d3b || ($572aa2e43a4df30f$export$4b3033a0406d3b = {}));\n\n});\n\nparcelRegister(\"aWv1W\", function(module, exports) {\n\n$parcel$export(module.exports, \"timestamp\", () => $7f77641fb0661547$export$fc00ee57782020aa);\n/** Returns a timestamp in ms. */ function $7f77641fb0661547$export$fc00ee57782020aa() {\n return Math.round(new Date().getTime() / 100);\n} // type RejectFn = (reason?: any) => void;\n // type ResolveFn = (value?: T | PromiseLike) => void;\n // interface Executor {\n // (x: (resolve: ResolveFn, reject: RejectFn) => void): Promise;\n // }\n // export function timeoutPromise(time: number, executor: Executor): Promise {\n // return new Promise(executor);\n // }\n\n});\n\n\nparcelRegister(\"3tZ8P\", function(module, exports) {\n\n$parcel$export(module.exports, \"Encoder\", () => $289381f16f78a587$export$a50aceb0e02a00aa);\nvar $289381f16f78a587$export$a50aceb0e02a00aa;\n(function(Encoder) {\n Encoder[Encoder[\"unknown\"] = -1] = \"unknown\";\n Encoder[Encoder[\"quadrature\"] = 0] = \"quadrature\";\n Encoder[Encoder[\"differential\"] = 1] = \"differential\";\n})($289381f16f78a587$export$a50aceb0e02a00aa || ($289381f16f78a587$export$a50aceb0e02a00aa = {}));\n\n});\n\nparcelRegister(\"bFr0L\", function(module, exports) {\n\n$parcel$export(module.exports, \"SpecialStatus\", () => $02312b41c59a57c7$export$d3ccc720d6d43811);\n/** Denotes special status of resource */ var $02312b41c59a57c7$export$d3ccc720d6d43811;\n(function(SpecialStatus) {\n /** The local copy is different than the one on the remote end. */ SpecialStatus[\"DIRTY\"] = \"DIRTY\";\n /** The local copy is being saved on the remote end right now? */ SpecialStatus[\"SAVING\"] = \"SAVING\";\n /** API and FE are in sync. Using \"\" for now because its falsey like old\n * `undefined` value */ SpecialStatus[\"SAVED\"] = \"\";\n})($02312b41c59a57c7$export$d3ccc720d6d43811 || ($02312b41c59a57c7$export$d3ccc720d6d43811 = {}));\n\n});\n\n\n// This is a stub for developers who do not have a module loader or are\n// prototyping one-off scripts in a browser.\n\nwindow.fbjs = (parcelRequire(\"gwFY1\"));\n\n\n//# sourceMappingURL=farmbot_single_file.js.map\n","export * from \"./corpus\";\nexport * from \"./farmbot\";\nexport * from \"./interfaces\";\nexport * from \"./util\";\nexport * from \"./resources/tagged_resource\";\n","\n// THIS INTERFACE WAS AUTO GENERATED ON 2023-07-27\n// DO NOT EDIT THIS FILE.\n// IT WILL BE OVERWRITTEN ON EVERY CELERYSCRIPT UPGRADE.\n\nexport const LATEST_VERSION = 20180209;\nexport const DIGITAL = 0;\nexport const ANALOG = 1;\nexport type CSBoolean = boolean;\nexport type CSFloat = number;\nexport type CSInteger = number;\nexport type CSString = string;\nexport type ALLOWED_ASSERTION_TYPES = \"abort\" |\n \"abort_recover\" |\n \"continue\" |\n \"recover\";\nexport type ALLOWED_AXIS = \"all\" |\n \"x\" |\n \"y\" |\n \"z\";\nexport type ALLOWED_CHANNEL_NAMES = \"email\" |\n \"espeak\" |\n \"ticker\" |\n \"toast\";\nexport type ALLOWED_MESSAGE_TYPES = \"assertion\" |\n \"busy\" |\n \"debug\" |\n \"error\" |\n \"fun\" |\n \"info\" |\n \"success\" |\n \"warn\";\nexport type ALLOWED_OPS = \"<\" |\n \">\" |\n \"is\" |\n \"is_undefined\" |\n \"not\";\nexport type ALLOWED_PACKAGES = \"arduino_firmware\" |\n \"farmbot_os\";\nexport type ALLOWED_PIN_IO_MODES = \"input\" |\n \"input_pullup\" |\n \"output\";\nexport type ALLOWED_PIN_MODES = 0 |\n 1;\nexport type ALLOWED_SPECIAL_VALUE = \"current_location\" |\n \"safe_height\" |\n \"soil_height\";\nexport type AllowedPinTypes = \"BoxLed3\" |\n \"BoxLed4\" |\n \"Peripheral\" |\n \"Sensor\";\nexport type Color = \"blue\" |\n \"gray\" |\n \"green\" |\n \"orange\" |\n \"pink\" |\n \"purple\" |\n \"red\" |\n \"yellow\";\nexport type DataChangeType = \"add\" |\n \"remove\" |\n \"update\";\nexport type LegalArgString = \"_else\" |\n \"_then\" |\n \"assertion_type\" |\n \"axis\" |\n \"axis_operand\" |\n \"channel_name\" |\n \"data_value\" |\n \"default_value\" |\n \"depth\" |\n \"label\" |\n \"lhs\" |\n \"locals\" |\n \"location\" |\n \"lua\" |\n \"message\" |\n \"message_type\" |\n \"milliseconds\" |\n \"number\" |\n \"offset\" |\n \"op\" |\n \"package\" |\n \"pin_id\" |\n \"pin_io_mode\" |\n \"pin_mode\" |\n \"pin_number\" |\n \"pin_type\" |\n \"pin_value\" |\n \"point_group_id\" |\n \"pointer_id\" |\n \"pointer_type\" |\n \"priority\" |\n \"radius\" |\n \"resource\" |\n \"resource_id\" |\n \"resource_type\" |\n \"rhs\" |\n \"sequence_id\" |\n \"speed\" |\n \"speed_setting\" |\n \"string\" |\n \"tool_id\" |\n \"url\" |\n \"value\" |\n \"variance\" |\n \"version\" |\n \"x\" |\n \"y\" |\n \"z\";\nexport type LegalKindString = \"Assertion\" |\n \"AxisAddition\" |\n \"AxisOverwrite\" |\n \"Calibrate\" |\n \"ChangeOwnership\" |\n \"Channel\" |\n \"CheckUpdates\" |\n \"Coordinate\" |\n \"EmergencyLock\" |\n \"EmergencyUnlock\" |\n \"Execute\" |\n \"ExecuteScript\" |\n \"Explanation\" |\n \"FactoryReset\" |\n \"FindHome\" |\n \"FlashFirmware\" |\n \"Home\" |\n \"Identifier\" |\n \"If\" |\n \"InstallFarmware\" |\n \"InstallFirstPartyFarmware\" |\n \"InternalEntryPoint\" |\n \"InternalFarmEvent\" |\n \"InternalRegimen\" |\n \"LocationPlaceholder\" |\n \"Lua\" |\n \"Move\" |\n \"MoveAbsolute\" |\n \"MoveRelative\" |\n \"NamedPin\" |\n \"Nothing\" |\n \"NumberPlaceholder\" |\n \"Numeric\" |\n \"Pair\" |\n \"ParameterApplication\" |\n \"ParameterDeclaration\" |\n \"Point\" |\n \"PointGroup\" |\n \"PowerOff\" |\n \"Random\" |\n \"ReadPin\" |\n \"ReadStatus\" |\n \"Reboot\" |\n \"RemoveFarmware\" |\n \"Resource\" |\n \"ResourcePlaceholder\" |\n \"ResourceUpdate\" |\n \"RpcError\" |\n \"RpcOk\" |\n \"RpcRequest\" |\n \"SafeZ\" |\n \"ScopeDeclaration\" |\n \"SendMessage\" |\n \"Sequence\" |\n \"SetPinIoMode\" |\n \"SetServoAngle\" |\n \"SetUserEnv\" |\n \"SpecialValue\" |\n \"SpeedOverwrite\" |\n \"Sync\" |\n \"TakePhoto\" |\n \"Text\" |\n \"TextPlaceholder\" |\n \"TogglePin\" |\n \"Tool\" |\n \"UpdateFarmware\" |\n \"UpdateResource\" |\n \"VariableDeclaration\" |\n \"Wait\" |\n \"WritePin\" |\n \"Zero\";\nexport type LegalSequenceKind = \"_if\" |\n \"assertion\" |\n \"calibrate\" |\n \"change_ownership\" |\n \"check_updates\" |\n \"emergency_lock\" |\n \"emergency_unlock\" |\n \"execute\" |\n \"execute_script\" |\n \"factory_reset\" |\n \"find_home\" |\n \"flash_firmware\" |\n \"home\" |\n \"install_farmware\" |\n \"install_first_party_farmware\" |\n \"lua\" |\n \"move\" |\n \"move_absolute\" |\n \"move_relative\" |\n \"power_off\" |\n \"read_pin\" |\n \"read_status\" |\n \"reboot\" |\n \"remove_farmware\" |\n \"send_message\" |\n \"set_pin_io_mode\" |\n \"set_servo_angle\" |\n \"set_user_env\" |\n \"sync\" |\n \"take_photo\" |\n \"toggle_pin\" |\n \"update_farmware\" |\n \"update_resource\" |\n \"wait\" |\n \"write_pin\" |\n \"zero\";\nexport type PlantStage = \"active\" |\n \"harvested\" |\n \"pending\" |\n \"planned\" |\n \"planted\" |\n \"removed\" |\n \"sprouted\";\nexport type PointType = \"GenericPointer\" |\n \"Plant\" |\n \"ToolSlot\" |\n \"Weed\";\nexport type lhs = \"pin0\" |\n \"pin1\" |\n \"pin10\" |\n \"pin11\" |\n \"pin12\" |\n \"pin13\" |\n \"pin14\" |\n \"pin15\" |\n \"pin16\" |\n \"pin17\" |\n \"pin18\" |\n \"pin19\" |\n \"pin2\" |\n \"pin20\" |\n \"pin21\" |\n \"pin22\" |\n \"pin23\" |\n \"pin24\" |\n \"pin25\" |\n \"pin26\" |\n \"pin27\" |\n \"pin28\" |\n \"pin29\" |\n \"pin3\" |\n \"pin30\" |\n \"pin31\" |\n \"pin32\" |\n \"pin33\" |\n \"pin34\" |\n \"pin35\" |\n \"pin36\" |\n \"pin37\" |\n \"pin38\" |\n \"pin39\" |\n \"pin4\" |\n \"pin40\" |\n \"pin41\" |\n \"pin42\" |\n \"pin43\" |\n \"pin44\" |\n \"pin45\" |\n \"pin46\" |\n \"pin47\" |\n \"pin48\" |\n \"pin49\" |\n \"pin5\" |\n \"pin50\" |\n \"pin51\" |\n \"pin52\" |\n \"pin53\" |\n \"pin54\" |\n \"pin55\" |\n \"pin56\" |\n \"pin57\" |\n \"pin58\" |\n \"pin59\" |\n \"pin6\" |\n \"pin60\" |\n \"pin61\" |\n \"pin62\" |\n \"pin63\" |\n \"pin64\" |\n \"pin65\" |\n \"pin66\" |\n \"pin67\" |\n \"pin68\" |\n \"pin69\" |\n \"pin7\" |\n \"pin8\" |\n \"pin9\" |\n \"x\" |\n \"y\" |\n \"z\";\nexport type resource_type = \"Device\" |\n \"GenericPointer\" |\n \"Peripheral\" |\n \"Plant\" |\n \"Point\" |\n \"Sensor\" |\n \"Sequence\" |\n \"ToolSlot\" |\n \"Weed\";\nexport type AssertionBodyItem = never;\n/** assertion\n\n Tag properties: *. */\nexport interface Assertion {\n comment?: string | undefined;\n kind: \"assertion\";\n args: {\n _then: Execute |\n Nothing;\n assertion_type: ALLOWED_ASSERTION_TYPES;\n lua: CSString;\n }\n body?: AssertionBodyItem[] | undefined;\n}\n\nexport type IfBodyItem = (Pair);\n/** _if\n\n Tag properties: *. */\nexport interface If {\n comment?: string | undefined;\n kind: \"_if\";\n args: {\n _else: Execute |\n Nothing;\n _then: Execute |\n Nothing;\n lhs: CSString |\n NamedPin;\n op: ALLOWED_OPS;\n rhs: CSInteger;\n }\n body?: IfBodyItem[] | undefined;\n}\n\nexport type CalibrateBodyItem = never;\n/** calibrate\n\n Tag properties: firmware_user, function. */\nexport interface Calibrate {\n comment?: string | undefined;\n kind: \"calibrate\";\n args: {\n axis: ALLOWED_AXIS;\n }\n body?: CalibrateBodyItem[] | undefined;\n}\n\nexport type ChangeOwnershipBodyItem = (Pair);\n/** change_ownership\nNot a commonly used node. May be removed without notice.\n Tag properties: api_writer, cuts_power, disk_user, function, network_user. */\nexport interface ChangeOwnership {\n comment?: string | undefined;\n kind: \"change_ownership\";\n args: {\n }\n body?: ChangeOwnershipBodyItem[] | undefined;\n}\n\nexport type ChannelBodyItem = never;\n/** channel\nSpecifies a communication path for log messages.\n Tag properties: data. */\nexport interface Channel {\n comment?: string | undefined;\n kind: \"channel\";\n args: {\n channel_name: ALLOWED_CHANNEL_NAMES;\n }\n body?: ChannelBodyItem[] | undefined;\n}\n\nexport type CheckUpdatesBodyItem = never;\n/** check_updates\n\n Tag properties: cuts_power, disk_user, function, network_user. */\nexport interface CheckUpdates {\n comment?: string | undefined;\n kind: \"check_updates\";\n args: {\n package: CSString;\n }\n body?: CheckUpdatesBodyItem[] | undefined;\n}\n\nexport type CoordinateBodyItem = never;\n/** coordinate\n\n Tag properties: data, location_like. */\nexport interface Coordinate {\n comment?: string | undefined;\n kind: \"coordinate\";\n args: {\n x: CSInteger |\n CSFloat;\n y: CSInteger |\n CSFloat;\n z: CSInteger |\n CSFloat;\n }\n body?: CoordinateBodyItem[] | undefined;\n}\n\nexport type EmergencyLockBodyItem = never;\n/** emergency_lock\n\n Tag properties: control_flow, firmware_user, function. */\nexport interface EmergencyLock {\n comment?: string | undefined;\n kind: \"emergency_lock\";\n args: {\n }\n body?: EmergencyLockBodyItem[] | undefined;\n}\n\nexport type EmergencyUnlockBodyItem = never;\n/** emergency_unlock\n\n Tag properties: firmware_user, function. */\nexport interface EmergencyUnlock {\n comment?: string | undefined;\n kind: \"emergency_unlock\";\n args: {\n }\n body?: EmergencyUnlockBodyItem[] | undefined;\n}\n\nexport type ExecuteScriptBodyItem = (Pair);\n/** execute_script\n\n Tag properties: *. */\nexport interface ExecuteScript {\n comment?: string | undefined;\n kind: \"execute_script\";\n args: {\n label: CSString;\n }\n body?: ExecuteScriptBodyItem[] | undefined;\n}\n\nexport type ExecuteBodyItem = (ParameterApplication);\n/** execute\n\n Tag properties: *. */\nexport interface Execute {\n comment?: string | undefined;\n kind: \"execute\";\n args: {\n sequence_id: CSInteger;\n }\n body?: ExecuteBodyItem[] | undefined;\n}\n\nexport type ExplanationBodyItem = never;\n/** explanation\n\n Tag properties: data. */\nexport interface Explanation {\n comment?: string | undefined;\n kind: \"explanation\";\n args: {\n message: CSString;\n }\n body?: ExplanationBodyItem[] | undefined;\n}\n\nexport type FactoryResetBodyItem = never;\n/** factory_reset\n\n Tag properties: cuts_power, function. */\nexport interface FactoryReset {\n comment?: string | undefined;\n kind: \"factory_reset\";\n args: {\n package: CSString;\n }\n body?: FactoryResetBodyItem[] | undefined;\n}\n\nexport type FindHomeBodyItem = never;\n/** find_home\n\n Tag properties: firmware_user, function. */\nexport interface FindHome {\n comment?: string | undefined;\n kind: \"find_home\";\n args: {\n axis: ALLOWED_AXIS;\n speed: CSInteger;\n }\n body?: FindHomeBodyItem[] | undefined;\n}\n\nexport type FlashFirmwareBodyItem = never;\n/** flash_firmware\n\n Tag properties: api_writer, disk_user, firmware_user, function, network_user. */\nexport interface FlashFirmware {\n comment?: string | undefined;\n kind: \"flash_firmware\";\n args: {\n package: CSString;\n }\n body?: FlashFirmwareBodyItem[] | undefined;\n}\n\nexport type HomeBodyItem = never;\n/** home\n\n Tag properties: firmware_user, function. */\nexport interface Home {\n comment?: string | undefined;\n kind: \"home\";\n args: {\n axis: ALLOWED_AXIS;\n speed: CSInteger;\n }\n body?: HomeBodyItem[] | undefined;\n}\n\nexport type IdentifierBodyItem = never;\n/** identifier\n\n Tag properties: data. */\nexport interface Identifier {\n comment?: string | undefined;\n kind: \"identifier\";\n args: {\n label: CSString;\n }\n body?: IdentifierBodyItem[] | undefined;\n}\n\nexport type InstallFarmwareBodyItem = never;\n/** install_farmware\n\n Tag properties: api_writer, disk_user, function, network_user. */\nexport interface InstallFarmware {\n comment?: string | undefined;\n kind: \"install_farmware\";\n args: {\n url: CSString;\n }\n body?: InstallFarmwareBodyItem[] | undefined;\n}\n\nexport type InstallFirstPartyFarmwareBodyItem = never;\n/** install_first_party_farmware\n\n Tag properties: function, network_user. */\nexport interface InstallFirstPartyFarmware {\n comment?: string | undefined;\n kind: \"install_first_party_farmware\";\n args: {\n }\n body?: InstallFirstPartyFarmwareBodyItem[] | undefined;\n}\n\nexport type InternalFarmEventBodyItem = (ParameterApplication);\n/** internal_farm_event\n\n Tag properties: . */\nexport interface InternalFarmEvent {\n comment?: string | undefined;\n kind: \"internal_farm_event\";\n args: {\n }\n body?: InternalFarmEventBodyItem[] | undefined;\n}\n\nexport type InternalRegimenBodyItem = (ParameterApplication |\n ParameterDeclaration |\n VariableDeclaration);\n/** internal_regimen\n\n Tag properties: . */\nexport interface InternalRegimen {\n comment?: string | undefined;\n kind: \"internal_regimen\";\n args: {\n }\n body?: InternalRegimenBodyItem[] | undefined;\n}\n\nexport type MoveRelativeBodyItem = never;\n/** move_relative\n\n Tag properties: firmware_user, function. */\nexport interface MoveRelative {\n comment?: string | undefined;\n kind: \"move_relative\";\n args: {\n speed: CSInteger;\n x: CSInteger |\n CSFloat;\n y: CSInteger |\n CSFloat;\n z: CSInteger |\n CSFloat;\n }\n body?: MoveRelativeBodyItem[] | undefined;\n}\n\nexport type NothingBodyItem = never;\n/** nothing\n\n Tag properties: data, function. */\nexport interface Nothing {\n comment?: string | undefined;\n kind: \"nothing\";\n args: {\n }\n body?: NothingBodyItem[] | undefined;\n}\n\nexport type PairBodyItem = never;\n/** pair\n\n Tag properties: data. */\nexport interface Pair {\n comment?: string | undefined;\n kind: \"pair\";\n args: {\n label: CSString;\n value: CSString |\n CSInteger |\n CSBoolean;\n }\n body?: PairBodyItem[] | undefined;\n}\n\nexport type ParameterApplicationBodyItem = never;\n/** parameter_application\n\n Tag properties: control_flow, function, scope_writer. */\nexport interface ParameterApplication {\n comment?: string | undefined;\n kind: \"parameter_application\";\n args: {\n data_value: Coordinate |\n Identifier |\n LocationPlaceholder |\n NumberPlaceholder |\n Numeric |\n Point |\n Resource |\n ResourcePlaceholder |\n Text |\n TextPlaceholder |\n Tool |\n PointGroup;\n label: CSString;\n }\n body?: ParameterApplicationBodyItem[] | undefined;\n}\n\nexport type ParameterDeclarationBodyItem = never;\n/** parameter_declaration\n\n Tag properties: scope_writer. */\nexport interface ParameterDeclaration {\n comment?: string | undefined;\n kind: \"parameter_declaration\";\n args: {\n default_value: Coordinate |\n Identifier |\n LocationPlaceholder |\n NumberPlaceholder |\n Numeric |\n Point |\n Resource |\n ResourcePlaceholder |\n Text |\n TextPlaceholder |\n Tool;\n label: CSString;\n }\n body?: ParameterDeclarationBodyItem[] | undefined;\n}\n\nexport type PointBodyItem = never;\n/** point\n\n Tag properties: data, location_like. */\nexport interface Point {\n comment?: string | undefined;\n kind: \"point\";\n args: {\n pointer_id: CSInteger;\n pointer_type: PointType;\n }\n body?: PointBodyItem[] | undefined;\n}\n\nexport type PowerOffBodyItem = never;\n/** power_off\n\n Tag properties: cuts_power, function. */\nexport interface PowerOff {\n comment?: string | undefined;\n kind: \"power_off\";\n args: {\n }\n body?: PowerOffBodyItem[] | undefined;\n}\n\nexport type ReadStatusBodyItem = never;\n/** read_status\n\n Tag properties: function. */\nexport interface ReadStatus {\n comment?: string | undefined;\n kind: \"read_status\";\n args: {\n }\n body?: ReadStatusBodyItem[] | undefined;\n}\n\nexport type RebootBodyItem = never;\n/** reboot\n\n Tag properties: cuts_power, firmware_user, function. */\nexport interface Reboot {\n comment?: string | undefined;\n kind: \"reboot\";\n args: {\n package: CSString;\n }\n body?: RebootBodyItem[] | undefined;\n}\n\nexport type RemoveFarmwareBodyItem = never;\n/** remove_farmware\n\n Tag properties: function. */\nexport interface RemoveFarmware {\n comment?: string | undefined;\n kind: \"remove_farmware\";\n args: {\n package: CSString;\n }\n body?: RemoveFarmwareBodyItem[] | undefined;\n}\n\nexport type RpcErrorBodyItem = (Explanation);\n/** rpc_error\n\n Tag properties: data. */\nexport interface RpcError {\n comment?: string | undefined;\n kind: \"rpc_error\";\n args: {\n label: CSString;\n }\n body?: RpcErrorBodyItem[] | undefined;\n}\n\nexport type RpcOkBodyItem = never;\n/** rpc_ok\n\n Tag properties: data. */\nexport interface RpcOk {\n comment?: string | undefined;\n kind: \"rpc_ok\";\n args: {\n label: CSString;\n }\n body?: RpcOkBodyItem[] | undefined;\n}\n\nexport type RpcRequestBodyItem = (If |\n Assertion |\n Calibrate |\n ChangeOwnership |\n CheckUpdates |\n EmergencyLock |\n EmergencyUnlock |\n Execute |\n ExecuteScript |\n FactoryReset |\n FindHome |\n FlashFirmware |\n Home |\n InstallFarmware |\n InstallFirstPartyFarmware |\n Lua |\n Move |\n MoveAbsolute |\n MoveRelative |\n PowerOff |\n ReadPin |\n ReadStatus |\n Reboot |\n RemoveFarmware |\n SendMessage |\n SetPinIoMode |\n SetServoAngle |\n SetUserEnv |\n Sync |\n TakePhoto |\n TogglePin |\n UpdateFarmware |\n UpdateResource |\n Wait |\n WritePin |\n Zero);\n/** rpc_request\n\n Tag properties: *. */\nexport interface RpcRequest {\n comment?: string | undefined;\n kind: \"rpc_request\";\n args: {\n label: CSString;\n priority: CSInteger;\n }\n body?: RpcRequestBodyItem[] | undefined;\n}\n\nexport type ScopeDeclarationBodyItem = (ParameterDeclaration |\n VariableDeclaration);\n/** scope_declaration\n\n Tag properties: scope_writer. */\nexport interface ScopeDeclaration {\n comment?: string | undefined;\n kind: \"scope_declaration\";\n args: {\n }\n body?: ScopeDeclarationBodyItem[] | undefined;\n}\n\nexport type SendMessageBodyItem = (Channel);\n/** send_message\n\n Tag properties: function. */\nexport interface SendMessage {\n comment?: string | undefined;\n kind: \"send_message\";\n args: {\n message: CSString;\n message_type: ALLOWED_MESSAGE_TYPES;\n }\n body?: SendMessageBodyItem[] | undefined;\n}\n\nexport type SequenceBodyItem = (If |\n Assertion |\n Calibrate |\n ChangeOwnership |\n CheckUpdates |\n EmergencyLock |\n EmergencyUnlock |\n Execute |\n ExecuteScript |\n FactoryReset |\n FindHome |\n FlashFirmware |\n Home |\n InstallFarmware |\n InstallFirstPartyFarmware |\n Lua |\n Move |\n MoveAbsolute |\n MoveRelative |\n PowerOff |\n ReadPin |\n ReadStatus |\n Reboot |\n RemoveFarmware |\n SendMessage |\n SetPinIoMode |\n SetServoAngle |\n SetUserEnv |\n Sync |\n TakePhoto |\n TogglePin |\n UpdateFarmware |\n UpdateResource |\n Wait |\n WritePin |\n Zero);\n/** sequence\n\n Tag properties: *. */\nexport interface Sequence {\n comment?: string | undefined;\n kind: \"sequence\";\n args: {\n locals: ScopeDeclaration;\n version: CSInteger;\n }\n body?: SequenceBodyItem[] | undefined;\n}\n\nexport type SetServoAngleBodyItem = never;\n/** set_servo_angle\n\n Tag properties: firmware_user, function. */\nexport interface SetServoAngle {\n comment?: string | undefined;\n kind: \"set_servo_angle\";\n args: {\n pin_number: CSInteger |\n NamedPin;\n pin_value: CSInteger;\n }\n body?: SetServoAngleBodyItem[] | undefined;\n}\n\nexport type SetPinIoModeBodyItem = never;\n/** set_pin_io_mode\n\n Tag properties: firmware_user, function. */\nexport interface SetPinIoMode {\n comment?: string | undefined;\n kind: \"set_pin_io_mode\";\n args: {\n pin_io_mode: ALLOWED_PIN_IO_MODES;\n pin_number: CSInteger |\n NamedPin;\n }\n body?: SetPinIoModeBodyItem[] | undefined;\n}\n\nexport type SetUserEnvBodyItem = (Pair);\n/** set_user_env\n\n Tag properties: disk_user, function. */\nexport interface SetUserEnv {\n comment?: string | undefined;\n kind: \"set_user_env\";\n args: {\n }\n body?: SetUserEnvBodyItem[] | undefined;\n}\n\nexport type SyncBodyItem = never;\n/** sync\n\n Tag properties: disk_user, function, network_user. */\nexport interface Sync {\n comment?: string | undefined;\n kind: \"sync\";\n args: {\n }\n body?: SyncBodyItem[] | undefined;\n}\n\nexport type TakePhotoBodyItem = never;\n/** take_photo\n\n Tag properties: disk_user, function. */\nexport interface TakePhoto {\n comment?: string | undefined;\n kind: \"take_photo\";\n args: {\n }\n body?: TakePhotoBodyItem[] | undefined;\n}\n\nexport type TextBodyItem = never;\n/** text\n\n Tag properties: . */\nexport interface Text {\n comment?: string | undefined;\n kind: \"text\";\n args: {\n string: CSString;\n }\n body?: TextBodyItem[] | undefined;\n}\n\nexport type TogglePinBodyItem = never;\n/** toggle_pin\n\n Tag properties: firmware_user, function. */\nexport interface TogglePin {\n comment?: string | undefined;\n kind: \"toggle_pin\";\n args: {\n pin_number: CSInteger |\n NamedPin;\n }\n body?: TogglePinBodyItem[] | undefined;\n}\n\nexport type ToolBodyItem = never;\n/** tool\n\n Tag properties: api_validated, data, location_like. */\nexport interface Tool {\n comment?: string | undefined;\n kind: \"tool\";\n args: {\n tool_id: CSInteger;\n }\n body?: ToolBodyItem[] | undefined;\n}\n\nexport type UpdateFarmwareBodyItem = never;\n/** update_farmware\n\n Tag properties: api_validated, function, network_user. */\nexport interface UpdateFarmware {\n comment?: string | undefined;\n kind: \"update_farmware\";\n args: {\n package: CSString;\n }\n body?: UpdateFarmwareBodyItem[] | undefined;\n}\n\nexport type VariableDeclarationBodyItem = never;\n/** variable_declaration\n\n Tag properties: function, scope_writer. */\nexport interface VariableDeclaration {\n comment?: string | undefined;\n kind: \"variable_declaration\";\n args: {\n data_value: Coordinate |\n Identifier |\n LocationPlaceholder |\n NumberPlaceholder |\n Numeric |\n Point |\n Resource |\n ResourcePlaceholder |\n Text |\n TextPlaceholder |\n Tool |\n PointGroup;\n label: CSString;\n }\n body?: VariableDeclarationBodyItem[] | undefined;\n}\n\nexport type WaitBodyItem = never;\n/** wait\n\n Tag properties: function. */\nexport interface Wait {\n comment?: string | undefined;\n kind: \"wait\";\n args: {\n milliseconds: CSInteger;\n }\n body?: WaitBodyItem[] | undefined;\n}\n\nexport type ZeroBodyItem = never;\n/** zero\n\n Tag properties: firmware_user, function. */\nexport interface Zero {\n comment?: string | undefined;\n kind: \"zero\";\n args: {\n axis: ALLOWED_AXIS;\n }\n body?: ZeroBodyItem[] | undefined;\n}\n\nexport type NamedPinBodyItem = never;\n/** named_pin\n\n Tag properties: api_validated, data, firmware_user, function, rpi_user. */\nexport interface NamedPin {\n comment?: string | undefined;\n kind: \"named_pin\";\n args: {\n pin_id: CSInteger;\n pin_type: AllowedPinTypes;\n }\n body?: NamedPinBodyItem[] | undefined;\n}\n\nexport type MoveAbsoluteBodyItem = never;\n/** move_absolute\n\n Tag properties: firmware_user, function. */\nexport interface MoveAbsolute {\n comment?: string | undefined;\n kind: \"move_absolute\";\n args: {\n location: Tool |\n Coordinate |\n Point |\n Identifier;\n offset: Coordinate;\n speed: CSInteger;\n }\n body?: MoveAbsoluteBodyItem[] | undefined;\n}\n\nexport type WritePinBodyItem = never;\n/** write_pin\n\n Tag properties: firmware_user, function, rpi_user. */\nexport interface WritePin {\n comment?: string | undefined;\n kind: \"write_pin\";\n args: {\n pin_mode: ALLOWED_PIN_MODES;\n pin_number: CSInteger |\n NamedPin;\n pin_value: CSInteger;\n }\n body?: WritePinBodyItem[] | undefined;\n}\n\nexport type ReadPinBodyItem = never;\n/** read_pin\n\n Tag properties: firmware_user, function, rpi_user. */\nexport interface ReadPin {\n comment?: string | undefined;\n kind: \"read_pin\";\n args: {\n label: CSString;\n pin_mode: ALLOWED_PIN_MODES;\n pin_number: CSInteger |\n NamedPin;\n }\n body?: ReadPinBodyItem[] | undefined;\n}\n\nexport type ResourceUpdateBodyItem = never;\n/** resource_update\n\n Tag properties: api_writer, function, network_user. */\nexport interface ResourceUpdate {\n comment?: string | undefined;\n kind: \"resource_update\";\n args: {\n label: CSString;\n resource_id: CSInteger;\n resource_type: resource_type;\n value: CSString |\n CSInteger |\n CSBoolean;\n }\n body?: ResourceUpdateBodyItem[] | undefined;\n}\n\nexport type ResourceBodyItem = never;\n/** resource\n\n Tag properties: network_user. */\nexport interface Resource {\n comment?: string | undefined;\n kind: \"resource\";\n args: {\n resource_id: CSInteger;\n resource_type: resource_type;\n }\n body?: ResourceBodyItem[] | undefined;\n}\n\nexport type ResourcePlaceholderBodyItem = never;\n/** resource_placeholder\n\n Tag properties: . */\nexport interface ResourcePlaceholder {\n comment?: string | undefined;\n kind: \"resource_placeholder\";\n args: {\n resource_type: resource_type;\n }\n body?: ResourcePlaceholderBodyItem[] | undefined;\n}\n\nexport type NumberPlaceholderBodyItem = never;\n/** number_placeholder\n\n Tag properties: . */\nexport interface NumberPlaceholder {\n comment?: string | undefined;\n kind: \"number_placeholder\";\n args: {\n }\n body?: NumberPlaceholderBodyItem[] | undefined;\n}\n\nexport type TextPlaceholderBodyItem = never;\n/** text_placeholder\n\n Tag properties: . */\nexport interface TextPlaceholder {\n comment?: string | undefined;\n kind: \"text_placeholder\";\n args: {\n }\n body?: TextPlaceholderBodyItem[] | undefined;\n}\n\nexport type LocationPlaceholderBodyItem = never;\n/** location_placeholder\n\n Tag properties: . */\nexport interface LocationPlaceholder {\n comment?: string | undefined;\n kind: \"location_placeholder\";\n args: {\n }\n body?: LocationPlaceholderBodyItem[] | undefined;\n}\n\nexport type UpdateResourceBodyItem = (Pair);\n/** update_resource\n\n Tag properties: api_writer, function, network_user. */\nexport interface UpdateResource {\n comment?: string | undefined;\n kind: \"update_resource\";\n args: {\n resource: Identifier |\n Resource |\n Point;\n }\n body?: UpdateResourceBodyItem[] | undefined;\n}\n\nexport type PointGroupBodyItem = never;\n/** point_group\n\n Tag properties: data, list_like. */\nexport interface PointGroup {\n comment?: string | undefined;\n kind: \"point_group\";\n args: {\n point_group_id: CSInteger;\n }\n body?: PointGroupBodyItem[] | undefined;\n}\n\nexport type NumericBodyItem = never;\n/** numeric\n\n Tag properties: data. */\nexport interface Numeric {\n comment?: string | undefined;\n kind: \"numeric\";\n args: {\n number: CSInteger;\n }\n body?: NumericBodyItem[] | undefined;\n}\n\nexport type LuaBodyItem = (Pair);\n/** lua\n\n Tag properties: *. */\nexport interface Lua {\n comment?: string | undefined;\n kind: \"lua\";\n args: {\n lua: CSString;\n }\n body?: LuaBodyItem[] | undefined;\n}\n\nexport type SpecialValueBodyItem = never;\n/** special_value\n\n Tag properties: data. */\nexport interface SpecialValue {\n comment?: string | undefined;\n kind: \"special_value\";\n args: {\n label: CSString;\n }\n body?: SpecialValueBodyItem[] | undefined;\n}\n\nexport type AxisOverwriteBodyItem = never;\n/** axis_overwrite\n\n Tag properties: data. */\nexport interface AxisOverwrite {\n comment?: string | undefined;\n kind: \"axis_overwrite\";\n args: {\n axis: ALLOWED_AXIS;\n axis_operand: Coordinate |\n Identifier |\n Lua |\n Numeric |\n Point |\n Random |\n SpecialValue |\n Tool;\n }\n body?: AxisOverwriteBodyItem[] | undefined;\n}\n\nexport type AxisAdditionBodyItem = never;\n/** axis_addition\n\n Tag properties: data. */\nexport interface AxisAddition {\n comment?: string | undefined;\n kind: \"axis_addition\";\n args: {\n axis: ALLOWED_AXIS;\n axis_operand: Coordinate |\n Identifier |\n Lua |\n Numeric |\n Point |\n Random |\n SpecialValue |\n Tool;\n }\n body?: AxisAdditionBodyItem[] | undefined;\n}\n\nexport type SpeedOverwriteBodyItem = never;\n/** speed_overwrite\n\n Tag properties: data. */\nexport interface SpeedOverwrite {\n comment?: string | undefined;\n kind: \"speed_overwrite\";\n args: {\n axis: ALLOWED_AXIS;\n speed_setting: Lua |\n Numeric;\n }\n body?: SpeedOverwriteBodyItem[] | undefined;\n}\n\nexport type SafeZBodyItem = never;\n/** safe_z\n\n Tag properties: data. */\nexport interface SafeZ {\n comment?: string | undefined;\n kind: \"safe_z\";\n args: {\n }\n body?: SafeZBodyItem[] | undefined;\n}\n\nexport type RandomBodyItem = never;\n/** random\n\n Tag properties: data. */\nexport interface Random {\n comment?: string | undefined;\n kind: \"random\";\n args: {\n variance: CSInteger;\n }\n body?: RandomBodyItem[] | undefined;\n}\n\nexport type MoveBodyItem = (AxisAddition |\n AxisOverwrite |\n SafeZ |\n SpeedOverwrite);\n/** move\n\n Tag properties: firmware_user, function. */\nexport interface Move {\n comment?: string | undefined;\n kind: \"move\";\n args: {\n }\n body?: MoveBodyItem[] | undefined;\n}\nexport type CeleryNode = Assertion |\n AxisAddition |\n AxisOverwrite |\n Calibrate |\n ChangeOwnership |\n Channel |\n CheckUpdates |\n Coordinate |\n EmergencyLock |\n EmergencyUnlock |\n Execute |\n ExecuteScript |\n Explanation |\n FactoryReset |\n FindHome |\n FlashFirmware |\n Home |\n Identifier |\n If |\n InstallFarmware |\n InstallFirstPartyFarmware |\n InternalFarmEvent |\n InternalRegimen |\n LocationPlaceholder |\n Lua |\n Move |\n MoveAbsolute |\n MoveRelative |\n NamedPin |\n Nothing |\n NumberPlaceholder |\n Numeric |\n Pair |\n ParameterApplication |\n ParameterDeclaration |\n Point |\n PointGroup |\n PowerOff |\n Random |\n ReadPin |\n ReadStatus |\n Reboot |\n RemoveFarmware |\n Resource |\n ResourcePlaceholder |\n ResourceUpdate |\n RpcError |\n RpcOk |\n RpcRequest |\n SafeZ |\n ScopeDeclaration |\n SendMessage |\n Sequence |\n SetPinIoMode |\n SetServoAngle |\n SetUserEnv |\n SpecialValue |\n SpeedOverwrite |\n Sync |\n TakePhoto |\n Text |\n TextPlaceholder |\n TogglePin |\n Tool |\n UpdateFarmware |\n UpdateResource |\n VariableDeclaration |\n Wait |\n WritePin |\n Zero;\n","import * as Corpus from \"./corpus\";\nimport {\n connect,\n MqttClient\n} from \"mqtt\";\nimport {\n rpcRequest,\n coordinate,\n uuid as genUuid\n} from \"./util\";\nimport { Dictionary, Vector3 } from \"./interfaces\";\nimport { ReadPin, WritePin, bufferToString } from \".\";\nimport {\n FarmBotInternalConfig as Conf,\n FarmbotConstructorParams,\n generateConfig,\n CONFIG_DEFAULTS\n} from \"./config\";\nimport { ResourceAdapter } from \"./resources/resource_adapter\";\nimport { MqttChanName, FbjsEventName, Misc } from \"./constants\";\nimport { hasLabel } from \"./util/is_celery_script\";\nimport { timestamp } from \"./util/time\";\nimport { Priority } from \"./util/rpc_request\";\n\ntype RpcResponse = Promise;\n\n/*\n * Clarification for several terms used:\n * * Farmware: Plug-ins for FarmBot OS. Sometimes referred to as `scripts`.\n * * Microcontroller: Directly controls and interfaces with motors,\n * peripherals, sensors, etc. May be on an Arduino or Farmduino board.\n * Mostly referred to as `arduino`, but also `mcu`.\n */\n\n/** Meta data that wraps an event callback */\ninterface CallbackWrapper {\n once: boolean;\n event: string;\n value: Function;\n}\n\nexport class Farmbot {\n /** Storage area for all event handlers */\n private _events: Dictionary;\n private config: Conf;\n public client?: MqttClient;\n public resources: ResourceAdapter;\n static VERSION = \"15.8.2\";\n\n constructor(input: FarmbotConstructorParams) {\n this._events = {};\n this.config = generateConfig(input);\n this.resources = new ResourceAdapter(this, this.config.mqttUsername);\n }\n\n /** Get a Farmbot Constructor Parameter. */\n getConfig = (key: U): Conf[U] => this.config[key];\n\n /** Set a Farmbot Constructor Parameter. */\n setConfig = (key: U, value: Conf[U]) => {\n this.config[key] = value;\n }\n\n /**\n * Installs a \"Farmware\" (plugin) onto the bot's SD card.\n * URL must point to a valid Farmware manifest JSON document.\n */\n installFarmware = (url: string) => {\n return this.send(rpcRequest([{ kind: \"install_farmware\", args: { url } }]));\n }\n\n /**\n * Checks for updates on a particular Farmware plugin when given the name of\n * a Farmware. `updateFarmware(\"take-photo\")`\n */\n updateFarmware = (pkg: string) => {\n return this.send(rpcRequest([{\n kind: \"update_farmware\",\n args: { package: pkg }\n }]));\n }\n\n /** Uninstall a Farmware plugin. */\n removeFarmware = (pkg: string) => {\n return this.send(rpcRequest([{\n kind: \"remove_farmware\",\n args: {\n package: pkg\n }\n }]));\n }\n\n /**\n * Installs \"Farmware\" (plugins) authored by FarmBot, Inc.\n * onto the bot's SD card.\n */\n installFirstPartyFarmware = () => {\n return this.send(rpcRequest([{\n kind: \"install_first_party_farmware\",\n args: {}\n }]));\n }\n\n /**\n * Deactivate FarmBot OS completely (shutdown).\n * Useful before unplugging the power.\n */\n powerOff = () => {\n return this.send(rpcRequest([{ kind: \"power_off\", args: {} }]));\n }\n\n /** Restart FarmBot OS. */\n reboot = () => {\n return this.send(rpcRequest([\n { kind: \"reboot\", args: { package: \"farmbot_os\" } }\n ]));\n }\n\n /** Reinitialize the FarmBot microcontroller firmware. */\n rebootFirmware = () => {\n return this.send(rpcRequest([\n { kind: \"reboot\", args: { package: \"arduino_firmware\" } }\n ]));\n }\n\n /** Check for new versions of FarmBot OS.\n * Downloads and installs if available. */\n checkUpdates = () => {\n return this.send(rpcRequest([\n { kind: \"check_updates\", args: { package: \"farmbot_os\" } }\n ]));\n }\n\n /** THIS WILL RESET THE SD CARD, deleting all non-factory data!\n * Be careful!! */\n resetOS = (): void => {\n return this.publish(rpcRequest([\n { kind: \"factory_reset\", args: { package: \"farmbot_os\" } }\n ]));\n }\n\n /** WARNING: will reset all firmware (hardware) settings! */\n resetMCU = () => {\n return this.send(rpcRequest([\n { kind: \"factory_reset\", args: { package: \"arduino_firmware\" } }\n ]));\n }\n\n flashFirmware = (\n /** one of: \"arduino\"|\"express_k10\"|\"farmduino_k14\"|\"farmduino\" */\n firmware_name: string) => {\n return this.send(rpcRequest([{\n kind: \"flash_firmware\",\n args: {\n package: firmware_name\n }\n }]));\n }\n\n /**\n * Lock the bot from moving (E-STOP). Turns off peripherals and motors. This\n * also will pause running regimens and cause any running sequences to exit.\n */\n emergencyLock = () => {\n const body: Corpus.RpcRequestBodyItem[] =\n [{ kind: \"emergency_lock\", args: {} }];\n const rpc = rpcRequest(body, Priority.HIGHEST);\n\n return this.send(rpc);\n }\n\n /** Unlock the bot when the user says it is safe. */\n emergencyUnlock = () => {\n const body: Corpus.RpcRequestBodyItem[] =\n [{ kind: \"emergency_unlock\", args: {} }];\n const rpc = rpcRequest(body, Priority.HIGHEST);\n\n return this.send(rpc);\n }\n /** Execute a sequence by its ID on the FarmBot API. */\n execSequence =\n (sequence_id: number, body: Corpus.ParameterApplication[] = []) => {\n return this.send(rpcRequest([\n { kind: \"execute\", args: { sequence_id }, body }\n ]));\n }\n\n /** Run an installed Farmware plugin on the SD Card. */\n execScript = (\n /** Name of the Farmware. */\n label: string,\n /** Optional ENV vars to pass the Farmware. */\n envVars?: Corpus.Pair[] | undefined) => {\n return this.send(rpcRequest([\n { kind: \"execute_script\", args: { label }, body: envVars }\n ]));\n }\n\n /** Bring a particular axis (or all of them) to position 0 in Z Y X order. */\n home = (args: { speed: number, axis: Corpus.ALLOWED_AXIS }) => {\n return this.send(rpcRequest([{ kind: \"home\", args }]));\n }\n\n /** Use end stops or encoders to figure out where 0,0,0 is in Z Y X axis\n * order. WON'T WORK WITHOUT ENCODERS OR END STOPS! A blockage or stall\n * during this command will set that position as zero. Use carefully. */\n findHome = (args: { speed: number, axis: Corpus.ALLOWED_AXIS }) => {\n return this.send(rpcRequest([{ kind: \"find_home\", args }]));\n }\n\n /** Move FarmBot to an absolute point. */\n moveAbsolute = (args: Vector3 & { speed?: number }) => {\n const { x, y, z } = args;\n const speed = args.speed || CONFIG_DEFAULTS.speed;\n return this.send(rpcRequest([\n {\n kind: \"move_absolute\",\n args: {\n location: coordinate(x, y, z),\n offset: coordinate(0, 0, 0),\n speed\n }\n }\n ]));\n }\n\n /** Move FarmBot to position relative to its current position. */\n moveRelative = (args: Vector3 & { speed?: number }) => {\n const { x, y, z } = args;\n const speed = args.speed || CONFIG_DEFAULTS.speed;\n return this.send(rpcRequest([\n { kind: \"move_relative\", args: { x, y, z, speed } }\n ]));\n }\n\n /** Set a GPIO pin to a particular value. */\n writePin = (args: WritePin[\"args\"]) => {\n return this.send(rpcRequest([{ kind: \"write_pin\", args }]));\n }\n\n /** Read the value of a GPIO pin. Will create a SensorReading if it's\n * a sensor. */\n readPin = (args: ReadPin[\"args\"]) => {\n return this.send(rpcRequest([{ kind: \"read_pin\", args }]));\n }\n\n /** Reverse the value of a digital pin. */\n togglePin = (args: { pin_number: number; }) => {\n return this.send(rpcRequest([{ kind: \"toggle_pin\", args }]));\n }\n\n /** Read the status of the bot. Should not be needed unless you are first\n * logging in to the device, since the device pushes new states out on\n * every update. */\n readStatus = (args = {}) => {\n return this.send(rpcRequest([{ kind: \"read_status\", args }]));\n }\n\n /** Snap a photo and send to the API for post processing. */\n takePhoto =\n (args = {}) => this.send(rpcRequest([{ kind: \"take_photo\", args }]))\n\n /** Download/apply all of the latest FarmBot API JSON resources (plants,\n * account info, etc.) to the device. */\n sync = (args = {}) => this.send(rpcRequest([{ kind: \"sync\", args }]));\n\n /**\n * Set the current position of the given axis to 0.\n * Example: Sending `bot.setZero(\"x\")` at x: 255 will translate position\n * 255 to 0, causing that position to be x: 0.\n */\n setZero = (axis: Corpus.ALLOWED_AXIS) => {\n return this.send(rpcRequest([{\n kind: \"zero\",\n args: { axis }\n }]));\n }\n\n /**\n * Set user ENV vars (usually used by 3rd-party Farmware plugins).\n * Set value to `undefined` to unset.\n */\n setUserEnv = (configs: Dictionary<(string | undefined)>) => {\n const body = Object\n .keys(configs)\n .map(function (label): Corpus.Pair {\n return {\n kind: \"pair\",\n args: { label, value: (configs[label] || Misc.NULL) }\n };\n });\n return this.send(rpcRequest([{ kind: \"set_user_env\", args: {}, body }]));\n }\n\n sendMessage = (message_type: Corpus.ALLOWED_MESSAGE_TYPES,\n message: string,\n channels: Corpus.ALLOWED_CHANNEL_NAMES[] = []) => {\n this.send(rpcRequest([{\n kind: \"send_message\",\n args: {\n message_type,\n message\n },\n body: channels.map(channel_name => ({\n kind: \"channel\",\n args: {\n channel_name\n }\n }))\n }]));\n }\n\n /** Control servos on pins 4 and 5. */\n setServoAngle = (args: { pin_number: number; pin_value: number; }) => {\n const result = this.send(rpcRequest([{ kind: \"set_servo_angle\", args }]));\n\n // Celery script can't validate `pin_number` and `pin_value` the way we need\n // for `set_servo_angle`. We will send the RPC command off, but also\n // crash the client to aid debugging.\n if (![4, 5, 6, 11].includes(args.pin_number)) {\n throw new Error(\"Servos only work on pins 4 and 5\");\n }\n\n if (args.pin_value > 180 || args.pin_value < 0) {\n throw new Error(\"Pin value outside of 0...180 range\");\n }\n\n return result;\n }\n\n /**\n * Find the axis extents using encoder, motor, or end-stop feedback.\n * Will set a new home position and a new axis length for the given axis.\n */\n calibrate = (args: { axis: Corpus.ALLOWED_AXIS }) => {\n return this.send(rpcRequest([{ kind: \"calibrate\", args }]));\n }\n\n lua = (lua: string) => {\n return this.send(rpcRequest([\n { kind: \"lua\", args: { lua } }\n ]));\n }\n /**\n * Retrieves all of the event handlers for a particular event.\n * Returns an empty array if the event did not exist.\n */\n event = (name: string) => {\n this._events[name] = this._events[name] || [];\n return this._events[name];\n }\n\n on = (event: string, value: Function, once = false) => {\n this.event(event).push({ value, once, event });\n }\n\n emit = (event: string, data: {}) => {\n const nextArray: CallbackWrapper[] = [];\n\n this.event(event)\n .concat(this.event(\"*\"))\n .forEach(function (handler) {\n try {\n handler.value(data, event);\n if (!handler.once && handler.event === event) {\n nextArray.push(handler);\n }\n } catch (e) {\n const msg = `Exception thrown while handling '${event}' event.`;\n console.warn(msg);\n console.dir(e);\n }\n });\n\n if (nextArray.length === 0) {\n delete this._events[event];\n } else {\n this._events[event] = nextArray;\n }\n }\n\n /** Dictionary of all relevant MQTT channels the bot uses. */\n get channel() {\n const deviceName = this.config.mqttUsername;\n return {\n /** From the browser, usually. */\n toDevice: `bot/${deviceName}/${MqttChanName.fromClients}`,\n /** From farmbot */\n toClient: `bot/${deviceName}/${MqttChanName.fromDevice}`,\n status: `bot/${deviceName}/${MqttChanName.status}`,\n logs: `bot/${deviceName}/${MqttChanName.logs}`,\n sync: `bot/${deviceName}/${MqttChanName.sync}/#`,\n /** Read only */\n pong: `bot/${deviceName}/pong/#`,\n /** Write only: bot/${deviceName}/ping/${timestamp} */\n ping: (tStamp: number) => `bot/${deviceName}/ping/${tStamp}`\n };\n }\n\n /** Low-level means of sending MQTT packets. Does not check format. Does not\n * acknowledge confirmation. Probably not the one you want. */\n publish = (msg: Corpus.RpcRequest, important = true): void => {\n if (this.client) {\n this.emit(FbjsEventName.sent, msg);\n /** SEE: https://github.com/mqttjs/MQTT.js#client */\n this.client.publish(this.channel.toDevice, JSON.stringify(msg));\n } else {\n if (important) {\n throw new Error(\"Not connected to server\");\n }\n }\n }\n\n /** Low-level means of sending MQTT RPC commands to the bot. Acknowledges\n * receipt of message, but does not check formatting. Consider using higher\n * level methods like .moveRelative(), .calibrate(), etc....\n */\n send = (input: Corpus.RpcRequest): RpcResponse => {\n return new Promise((resolve, reject) => {\n\n this.publish(input);\n\n function handler(response: Corpus.RpcOk | Corpus.RpcError) {\n switch (response.kind) {\n case \"rpc_ok\": return resolve(response);\n case \"rpc_error\":\n const reason = (response.body || [])\n .map(x => x.args.message)\n .join(\", \");\n return reject(new Error(\"Problem sending RPC command: \" + reason));\n default:\n console.dir(response);\n throw new Error(\"Got a bad CeleryScript node.\");\n }\n }\n\n this.on(input.args.label, handler, true);\n });\n }\n\n /** Main entry point for all MQTT packets. */\n _onmessage = (chan: string, buffer: Uint8Array) => {\n const original = bufferToString(buffer);\n const segments = chan.split(Misc.MQTT_DELIM);\n const { emit } = this;\n\n try {\n const msg = JSON.parse(original);\n\n if (segments[0] == MqttChanName.publicBroadcast) {\n return emit(MqttChanName.publicBroadcast, msg);\n }\n\n switch (segments[2]) {\n case MqttChanName.logs: return emit(FbjsEventName.logs, msg);\n case MqttChanName.status: return emit(FbjsEventName.status, msg);\n case MqttChanName.sync: return emit(FbjsEventName.sync, msg);\n case MqttChanName.pong:\n return emit(segments[3], msg);\n default:\n const ev = hasLabel(msg) ? msg.args.label : FbjsEventName.malformed;\n return emit(ev, msg);\n }\n } catch (error) {\n console\n .dir({ text: \"Could not parse inbound message from MQTT.\", error });\n emit(FbjsEventName.malformed, original);\n }\n }\n\n ping = (timeout = 10000, now = timestamp()): Promise => {\n this.setConfig(\"LAST_PING_OUT\", now);\n return this.doPing(now, timeout);\n }\n\n // STEP 0: Subscribe to `bot/device_23/pong/#`\n // STEP 0: Send `bot/device_23/ping/3123123`\n // STEP 0: Receive `bot/device_23/pong/3123123`\n private doPing = (startedAt: number, timeout: number): Promise => {\n const timeoutPromise =\n new Promise((_, rej) => setTimeout(() => rej(-0), timeout));\n const pingPromise = new Promise((res, _) => {\n const ok = () => {\n const t = timestamp();\n this.setConfig(\"LAST_PING_IN\", t);\n res(t - startedAt);\n };\n this.on(\"\" + startedAt, ok, true);\n const chan = this.channel.ping(startedAt);\n if (this.client) {\n this.client.publish(chan, JSON.stringify(startedAt));\n }\n });\n\n return Promise.race([timeoutPromise, pingPromise]);\n }\n\n /** Bootstrap the device onto the MQTT broker. */\n connect = () => {\n const { mqttUsername, token, mqttServer } = this.config;\n const reconnectPeriod: number = Misc.RECONNECT_THROTTLE_MS;\n const client = connect(mqttServer, {\n clean: true,\n clientId: `FBJS-${Farmbot.VERSION}-${genUuid()}`,\n password: token,\n protocolId: \"MQTT\",\n protocolVersion: 4,\n reconnectPeriod,\n username: mqttUsername,\n });\n this.client = client;\n this.resources = new ResourceAdapter(this, this.config.mqttUsername);\n client.on(\"message\", this._onmessage);\n client.on(\"offline\", () => this.emit(FbjsEventName.offline, {}));\n client.on(\"connect\", () => this.emit(FbjsEventName.online, {}));\n const channels = [\n this.channel.logs,\n this.channel.status,\n this.channel.sync,\n this.channel.toClient,\n this.channel.pong\n ];\n client.subscribe(channels);\n return new Promise((resolve, _reject) => {\n if (this.client) {\n this.client.once(\"connect\", () => resolve(this));\n } else {\n throw new Error(\"Please connect first.\");\n }\n });\n }\n}\n","export * from \"./util/coordinate\";\nexport * from \"./util/is_celery_script\";\nexport * from \"./util/is_node\";\nexport * from \"./util/pick\";\nexport * from \"./util/rpc_request\";\nexport * from \"./util/uuid\";\n\nexport function stringToBuffer(str: string) {\n const regular_array = str.split(\"\").map(x => x.charCodeAt(0));\n const data16 = new Uint8Array(regular_array);\n return data16;\n}\n\ndeclare const util: { TextDecoder: typeof TextDecoder };\n\ninterface DecoderLike {\n decode(input: Uint8Array): string;\n}\n\nfunction newDecoder(): DecoderLike {\n if (typeof util !== \"undefined\" && util.TextDecoder) {\n return new util.TextDecoder()\n }\n\n if (typeof window !== \"undefined\" && window.TextDecoder) {\n return new window.TextDecoder();\n }\n\n return {\n decode(buffer) {\n const chars: string[] = [];\n buffer.forEach(x => chars.push(String.fromCharCode(x)));\n return chars.join(\"\");\n }\n };\n}\n\nconst td = newDecoder();\n/** We originally called buffer.toString(),\n * but that suffers from inconsistent behavior\n * between environments, leading to testing\n * difficulty. */\nexport const bufferToString = (b: Uint8Array) => td.decode(b);\n","import { Coordinate } from \"..\";\n\nexport function coordinate(x: number, y: number, z: number): Coordinate {\n return { kind: \"coordinate\", args: { x, y, z } };\n}\n","import { CeleryNode } from \"..\";\n\nconst isObj = (o: unknown) => !!(o && typeof o === \"object\");\nconst hasKind = (o: any) => typeof o.kind === \"string\";\nconst hasArgs = (o: any) => isObj(o) && !!o.args;\n\nexport function isCeleryScript(x: unknown): x is CeleryNode {\n return isObj(x) && hasKind(x) && hasArgs(x);\n}\n\nexport function hasLabel(x: unknown) {\n if (isCeleryScript(x)) {\n return typeof (x.args as any).label === \"string\";\n } else {\n return false;\n }\n}\n","export function isNode() {\n return typeof window === \"undefined\";\n}\n","export function pick(target: any, value: string, fallback: T) {\n const result = target[value];\n return (typeof result === undefined) ? fallback : result;\n}\n","import { RpcRequestBodyItem } from \"..\";\nimport { uuid } from \"./uuid\";\nimport { RpcRequest } from \"../corpus\";\n\nexport enum Priority {\n HIGHEST = 9000,\n NORMAL = 600,\n LOWEST = 300,\n}\n\nexport const rpcRequest =\n (body: RpcRequestBodyItem[], priority = Priority.NORMAL): RpcRequest => ({\n kind: \"rpc_request\",\n args: {\n label: uuid(),\n priority\n },\n body\n })\n","\nexport function uuid() {\n const template = \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\";\n const replaceChar = function (c: string) {\n const r = Math.random() * 16 | 0;\n const v = c === \"x\" ? r : r & 0x3 | 0x8;\n return v.toString(16);\n };\n return template.replace(/[xy]/g, replaceChar);\n}\n","import { APIToken } from \"./interfaces\";\nimport { isNode } from \"./util\";\n\ndeclare var atob: (i: string) => string;\ndeclare var global: typeof window;\n\nexport interface FarmBotInternalConfig {\n speed: number;\n token: string;\n secure: boolean;\n mqttServer: string;\n mqttUsername: string;\n LAST_PING_OUT: number;\n LAST_PING_IN: number;\n}\n\nexport interface FarmbotConstructorParams extends Partial {\n /** All inputs are optional, except for `token`. */\n token: string;\n}\n\nconst ERR_TOKEN_PARSE = \"Unable to parse token. Is it properly formatted?\";\n\nexport const CONFIG_DEFAULTS = {\n speed: 100,\n};\n\nconst ERR_MISSING_MQTT_USERNAME = \"MISSING_MQTT_USERNAME\";\nexport const FIX_ATOB_FIRST =\n `NOTE TO NODEJS USERS:\n\nThis library requires an 'atob()' function.\nPlease fix this first.\nSOLUTION: https://github.com/FarmBot/farmbot-js/issues/33`;\n\nconst parseToken = (input: string): APIToken => {\n try {\n return JSON.parse(atob(input.split(\".\")[1]));\n } catch (e) {\n console.warn(e);\n throw new Error(ERR_TOKEN_PARSE);\n }\n};\n\nexport const generateConfig = (input: FarmbotConstructorParams): FarmBotInternalConfig => {\n if (isNode() && !global.atob) { throw new Error(FIX_ATOB_FIRST); }\n const t = parseToken(input.token);\n\n return {\n speed: input.speed || CONFIG_DEFAULTS.speed,\n token: input.token,\n secure: input.secure === false ? false : true,\n mqttServer: isNode() ? `mqtt://${t.mqtt}:1883` : t.mqtt_ws,\n mqttUsername: t.bot || ERR_MISSING_MQTT_USERNAME,\n LAST_PING_OUT: 0,\n LAST_PING_IN: 0,\n };\n}\n","import { uuid } from \"..\";\nimport {\n DeletionRequest,\n FarmbotLike,\n MqttLike,\n RpcResponse\n} from \"./interfaces\";\nimport {\n outboundChanFor,\n resolveOrReject\n} from \"./support\";\nimport { rejectRpc } from \"./reject_rpc\";\nimport { TaggedResource } from \"./tagged_resource\";\n\nexport class ResourceAdapter {\n constructor(public parent: FarmbotLike, public username: string) { }\n\n destroy = (r: DeletionRequest) => {\n const { client } = this.parent;\n return (client ? this.doDestroy(client, r.kind, r.id) : rejectRpc());\n }\n\n save = (resource: TaggedResource) => {\n const { client } = this.parent;\n return (client ? this.doSave(client, resource) : rejectRpc());\n }\n\n destroyAll = (req: DeletionRequest[]) => Promise.all(req.map(r => this.destroy(r)));\n\n private doDestroy = (client: MqttLike,\n kind: DeletionRequest[\"kind\"],\n id: number): Promise => {\n\n return new Promise((res, rej) => {\n const requestId = uuid();\n this.parent.on(requestId, resolveOrReject(res, rej));\n client.publish(outboundChanFor(this.username, \"destroy\", kind, requestId, id), \"\");\n });\n }\n\n private doSave =\n (client: MqttLike, r: TaggedResource): Promise => {\n return new Promise((res, rej) => {\n const uid = uuid();\n this.parent.on(uid, resolveOrReject(res, rej));\n const chan =\n outboundChanFor(this.username, \"save\", r.kind, uid, r.body.id);\n client.publish(chan, JSON.stringify(r.body));\n });\n }\n}\n","import { RpcResponse, ResourceName } from \"./interfaces\";\nimport { RpcError } from \"..\";\n\ntype OpType = \"destroy\" | \"save\";\n\nexport const outboundChanFor =\n (username: string, op: OpType, kind: ResourceName, uuid: string, id = 0): string => {\n const segments = [`bot`, username, `resources_v0`, op, kind, uuid, id];\n return segments.join(\"/\");\n };\n\n// Auto-reject if client is not connected yet.\nexport const internalError: RpcError = {\n kind: \"rpc_error\",\n args: { label: \"BROWSER_LEVEL_FAILURE\" },\n body: [\n {\n kind: \"explanation\",\n args: { message: \"Tried to perform batch operation before connect.\" }\n }\n ]\n};\n\nexport const resolveOrReject = (res: Function, rej: Function) => {\n return (m: RpcResponse) => (m.kind == \"rpc_ok\" ? res : rej)(m);\n}\n","import { internalError } from \"./support\";\nimport { RpcError } from \"../corpus\";\n\nexport const rejectRpc = (): Promise => Promise.reject(internalError);\n","export enum MqttChanName {\n fromApi = \"from_api\",\n fromClients = \"from_clients\",\n fromDevice = \"from_device\",\n logs = \"logs\",\n status = \"status\",\n sync = \"sync\",\n /** THIS ONE IS SPECIAL. */\n publicBroadcast = \"public_broadcast\",\n pong = \"pong\"\n}\n\n/** Not to be confused with MqttChanNames or\n * MQTT.js event names */\nexport enum FbjsEventName {\n /** State tree update. */\n status = \"status\",\n /** When a log is received */\n logs = \"logs\",\n /** When an unexpected message is received */\n malformed = \"malformed\",\n /** Unreliable. */\n offline = \"offline\",\n /** Fired on connect. */\n online = \"online\",\n /** Fires when the API sends an MQTT message to users. */\n publicBroadcast = \"public_broadcast\",\n /** Fires after any message is sent from current client. */\n sent = \"sent\",\n /** Used by resource auto-sync. */\n sync = \"sync\",\n /** When a key is removed from the device state tree. */\n remove = \"remove\",\n}\n\nexport enum Misc {\n /** Channel delimiter for MQTT channels. */\n MQTT_DELIM = \"/\",\n /** A null value when dealing with empty `pair` nodes in CeleryScript. */\n NULL = \"null\",\n /** Reconnect interval for MQTT.js */\n RECONNECT_THROTTLE_MS = 1000,\n}\n","/** Returns a timestamp in ms. */\nexport function timestamp() {\n return Math.round((new Date()).getTime() / 100);\n}\n\n// type RejectFn = (reason?: any) => void;\n// type ResolveFn = (value?: T | PromiseLike) => void;\n\n// interface Executor {\n// (x: (resolve: ResolveFn, reject: RejectFn) => void): Promise;\n// }\n\n// export function timeoutPromise(time: number, executor: Executor): Promise {\n// return new Promise(executor);\n// }\n","import { NumberConfigKey } from \"./resources/configs/firmware\";\n\nexport type Primitive = string | number | boolean;\n\n/** Everything the farmbot knows about itself at a given moment in time. */\nexport interface BotStateTree {\n /** Microcontroller configuration and settings. */\n mcu_params: McuParams;\n /** Cartesian coordinates of the bot. */\n location_data: LocationData;\n /** Lookup table, indexed by number for pin status */\n pins: Pins;\n /** User definable config settings. */\n configuration: Configuration;\n /** READ ONLY meta data about the FarmBot device. */\n readonly informational_settings: InformationalSettings;\n /** Bag of misc. ENV vars that any Farmware author can use. */\n user_env: Dictionary<(string | undefined)>;\n /** When you're really curious about how a long-running\n * task (like FarmBot OS update downloads) is going to take. */\n jobs: Dictionary<(JobProgress | undefined)>;\n /** List of user accessible processes running on the bot. */\n process_info: { farmwares: Dictionary; };\n gpio_registry: { [pin: number]: string | undefined } | undefined;\n}\n\n/** Microcontroller board. */\nexport type FirmwareHardware =\n | \"none\"\n | \"arduino\"\n | \"express_k10\"\n | \"express_k11\"\n | \"farmduino_k14\"\n | \"farmduino_k15\"\n | \"farmduino_k16\"\n | \"farmduino\";\n\n/** FarmBot motor and encoder positions. */\nexport type LocationName =\n | \"position\"\n | \"scaled_encoders\"\n | \"raw_encoders\";\n\nexport type AxisState =\n | \"idle\"\n | \"begin\"\n | \"accelerate\"\n | \"cruise\"\n | \"decelerate\"\n | \"stop\"\n | \"crawl\";\n\nexport interface LocationData {\n position: Record;\n scaled_encoders: Record;\n raw_encoders: Record;\n load?: Record;\n axis_states?: Record;\n}\n\n/** Job progress status. */\nexport type ProgressStatus =\n | \"complete\"\n | \"working\"\n | \"error\";\n\nexport type JobProgress =\n | PercentageProgress\n | BytesProgress;\n\ninterface JobProgressBase {\n status: ProgressStatus;\n type: string;\n file_type: string;\n time: string;\n updated_at: number;\n}\n\n/** Percent job progress. */\nexport interface PercentageProgress extends JobProgressBase {\n unit: \"percent\";\n percent: number;\n}\n\n/** Bytes job progress. */\nexport interface BytesProgress extends JobProgressBase {\n unit: \"bytes\";\n bytes: number;\n}\n\n/** Identified FarmBot OS problem. */\nexport interface Alert {\n id?: number;\n created_at: number;\n problem_tag: string;\n priority: number;\n slug: string;\n}\n\n/**\n * Configs (inputs) requested by a Farmware.\n * Can be namespaced and supplied to a run Farmware command.\n * Also used in FarmBot Web App Farmware page form builder.\n */\nexport type FarmwareConfig = Record<\"name\" | \"label\" | \"value\", string>;\n\n/**\n * The Farmware manifest is a JSON file published by Farmware authors.\n * It is used by FarmBot OS to perform installation and upgrades.\n */\nexport interface FarmwareManifest {\n /** \"2.0\" */\n farmware_manifest_version: string;\n /** Farmware name. */\n package: string;\n /** Farmware version. */\n package_version: string;\n /** Farmware description (optional). */\n description: string;\n /** Farmware author. */\n author: string;\n /** Farmware language, eg: `python` (optional). */\n language: string;\n /** The thing that will run the Farmware eg: `python`. */\n executable: string;\n /** Command line args (combined into a string) passed to `executable`. */\n args: string;\n /** Dictionary of `FarmwareConfig` with number (i.e., \"1\") keys. (optional) */\n config: Dictionary;\n /** Required FarmBot OS version to run the Farmware, i.e., \">=8.0.0\" */\n farmbot_os_version_requirement: string;\n /** Required Farmware Tools version. Use \">=0.0.0\" for latest version. */\n farmware_tools_version_requirement: string;\n /** Farmware manifest URL (optional). */\n url: string;\n /** Zipped Farmware files URL. */\n zip: string;\n}\n\nexport enum Encoder {\n unknown = -1,\n quadrature,\n differential\n}\n\n/** Microcontroller firmware hardware setting names. */\nexport type McuParamName = NumberConfigKey;\n\n/** Microcontroller configuration and settings. */\nexport type McuParams = Partial>;\n\n/** Bot axis names. */\nexport type Xyz = \"x\" | \"y\" | \"z\";\n/** 3 dimensional vector. */\nexport type Vector3 = Record;\n\n/** GPIO pin value record. */\nexport interface Pin {\n mode: number;\n value: number;\n}\n\n/** Lookup for pin status, indexed by pin number. */\nexport type Pins = Dictionary;\n\n/** FarmBot OS configs. */\nexport interface FullConfiguration {\n arduino_debug_messages: number;\n boot_sequence_id?: number;\n firmware_debug_log?: boolean;\n firmware_hardware: FirmwareHardware;\n firmware_input_log: boolean;\n firmware_output_log: boolean;\n firmware_path?: string;\n fw_auto_update: number;\n os_auto_update: number;\n sequence_body_log: boolean;\n sequence_complete_log: boolean;\n sequence_init_log: boolean;\n update_channel?: string;\n safe_height?: number;\n soil_height?: number;\n gantry_height?: number;\n}\n\n/** FarmBot OS configs. */\nexport type Configuration = Partial;\n\n/** FarmBot OS config names. */\nexport type ConfigurationName = keyof Configuration;\n\n/** The possible values for the sync_status property on informational_settings */\nexport type SyncStatus =\n | \"booting\"\n | \"maintenance\"\n | \"sync_error\"\n | \"sync_now\"\n | \"synced\"\n | \"syncing\"\n | \"unknown\";\n\n/** Various FarmBot OS status data. */\nexport interface InformationalSettings {\n /** System uptime in seconds. */\n uptime?: number;\n /** Percentage of disk space used. */\n disk_usage?: number;\n /** CPU utilization (percent). */\n cpu_usage?: number;\n /** Scheduler utilization (percent). */\n scheduler_usage?: number;\n /** Megabytes of RAM used. */\n memory_usage?: number;\n /** CPU Temperature (C) of the device running FBOS (RPi). */\n soc_temp?: number;\n /** WiFi signal strength (dBm). */\n wifi_level?: number;\n /** WiFi signal strength (percent). */\n wifi_level_percent?: number;\n /** FBOS commit hash. */\n controller_commit?: string;\n /** Current version of FarmBot OS. */\n controller_version?: string | undefined;\n /** Current uuid of FarmBot OS firmware. */\n controller_uuid?: string | undefined;\n /** Arduino/Farmduino firmware version. */\n firmware_version?: string | undefined;\n /** If the RPi is throttled and/or having WiFi issues. */\n throttled?: string | undefined;\n /** Farmbot's private IP address */\n private_ip?: string | undefined;\n /** The message to be displayed on the frontend for sync status. */\n sync_status?: SyncStatus | undefined;\n /** Microcontroller status (move in progress, etc.) */\n busy: boolean;\n /** Microcontroller status */\n idle?: boolean;\n /** Emergency stop status. */\n locked: boolean;\n /** FBOS commit hash. */\n commit: string;\n /** Microcontroller firmware commit hash. */\n firmware_commit: string;\n /** FBOS device type (rpi3, etc.). */\n target: string;\n /** FBOS env (prod, dev, etc.). */\n env: string;\n /** FBOS node name. */\n node_name: string;\n /** FBOS is beta? */\n currently_on_beta?: boolean;\n /** FBOS update available? */\n update_available?: boolean;\n /** CSV list of available camera device numbers (/dev/video#). */\n video_devices?: string;\n}\n\nexport type MQTTEventName = \"connect\" | \"message\";\n\nexport interface Dictionary { [key: string]: T; }\n\nexport interface APIToken {\n /** LEGACY ISSUES AHEAD: PLEASE READ:\n * This is the *host* of MQTT server. A host is *not* the same thing as\n * a URL. This property is only useful for NodeJS users.*/\n mqtt: string;\n\n /** Fully formed URL (port, protocol, host) pointing to the MQTT\n * websocket server. */\n mqtt_ws: string;\n\n /** UUID of current bot, eg: \"device_1\". */\n bot: string;\n}\n","import {\n Curve,\n Crop,\n DeviceAccountSettings,\n FarmEvent,\n FarmwareEnv,\n FarmwareInstallation,\n Folder,\n GenericPointer,\n Image,\n Log,\n Peripheral,\n PinBinding,\n PlantPointer,\n PlantTemplate,\n PointGroup,\n Regimen,\n SavedGarden,\n Sensor,\n SensorReading,\n SequenceResource,\n Telemetry,\n Tool,\n ToolSlotPointer,\n User,\n WebcamFeed,\n WeedPointer,\n WizardStepResult,\n} from \"./api_resources\";\nimport { FbosConfig } from \"./configs/fbos\";\nimport { FirmwareConfig } from \"./configs/firmware\";\nimport { WebAppConfig } from \"./configs/web_app\";\nimport { Alert } from \"../interfaces\";\n\nexport type ResourceName =\n | \"Alert\"\n | \"Crop\"\n | \"Curve\"\n | \"Device\"\n | \"FarmEvent\"\n | \"FarmwareEnv\"\n | \"FarmwareInstallation\"\n | \"FbosConfig\"\n | \"FirmwareConfig\"\n | \"Folder\"\n | \"Image\"\n | \"Log\"\n | \"Peripheral\"\n | \"PinBinding\"\n | \"Plant\"\n | \"PlantTemplate\"\n | \"Point\"\n | \"PointGroup\"\n | \"Regimen\"\n | \"SavedGarden\"\n | \"Sensor\"\n | \"SensorReading\"\n | \"Sequence\"\n | \"Telemetry\"\n | \"Tool\"\n | \"User\"\n | \"WebAppConfig\"\n | \"WizardStepResult\"\n | \"WebcamFeed\";\n\nexport interface TaggedResourceBase {\n kind: ResourceName;\n /** Unique identifier and index key.\n * We can't use the object's `id` attribute as a local index key because\n * unsaved objects don't have one.\n */\n uuid: string;\n body: object;\n /** Indicates if the resource is saved, saving or dirty.\n * `undefined` denotes that the resource is saved. */\n specialStatus: SpecialStatus;\n}\n\n/** Denotes special status of resource */\nexport enum SpecialStatus {\n /** The local copy is different than the one on the remote end. */\n DIRTY = \"DIRTY\",\n /** The local copy is being saved on the remote end right now? */\n SAVING = \"SAVING\",\n /** API and FE are in sync. Using \"\" for now because its falsey like old\n * `undefined` value */\n SAVED = \"\"\n}\n\nexport interface RestResource\n extends TaggedResourceBase {\n kind: T;\n body: U;\n}\n\nexport type TaggedResource =\n | TaggedAlert\n | TaggedCrop\n | TaggedCurve\n | TaggedDevice\n | TaggedFarmEvent\n | TaggedFarmwareEnv\n | TaggedFarmwareInstallation\n | TaggedFbosConfig\n | TaggedFirmwareConfig\n | TaggedFolder\n | TaggedImage\n | TaggedLog\n | TaggedPeripheral\n | TaggedPinBinding\n | TaggedPlantTemplate\n | TaggedPoint\n | TaggedPointGroup\n | TaggedRegimen\n | TaggedSavedGarden\n | TaggedSensor\n | TaggedSensorReading\n | TaggedSequence\n | TaggedTelemetry\n | TaggedTool\n | TaggedUser\n | TaggedWebAppConfig\n | TaggedWizardStepResult\n | TaggedWebcamFeed;\n\ntype PointUnion =\n | GenericPointer\n | PlantPointer\n | ToolSlotPointer\n | WeedPointer;\n\nexport type TaggedAlert = RestResource<\"Alert\", Alert>;\nexport type TaggedCrop = RestResource<\"Crop\", Crop>;\nexport type TaggedCurve = RestResource<\"Curve\", Curve>;\nexport type TaggedDevice = RestResource<\"Device\", DeviceAccountSettings>;\nexport type TaggedFolder = RestResource<\"Folder\", Folder>;\nexport type TaggedFarmEvent = RestResource<\"FarmEvent\", FarmEvent>;\nexport type TaggedFarmwareEnv = RestResource<\"FarmwareEnv\", FarmwareEnv>;\nexport type TaggedFarmwareInstallation = RestResource<\"FarmwareInstallation\", FarmwareInstallation>;\nexport type TaggedFbosConfig = RestResource<\"FbosConfig\", FbosConfig>;\nexport type TaggedFirmwareConfig = RestResource<\"FirmwareConfig\", FirmwareConfig>;\nexport type TaggedGenericPointer = RestResource<\"Point\", GenericPointer>;\nexport type TaggedImage = RestResource<\"Image\", Image>;\nexport type TaggedLog = RestResource<\"Log\", Log>;\nexport type TaggedPeripheral = RestResource<\"Peripheral\", Peripheral>;\nexport type TaggedPinBinding = RestResource<\"PinBinding\", PinBinding>;\nexport type TaggedPlantPointer = RestResource<\"Point\", PlantPointer>;\nexport type TaggedPlantTemplate = RestResource<\"PlantTemplate\", PlantTemplate>;\nexport type TaggedPoint = RestResource<\"Point\", PointUnion>;\nexport type TaggedPointGroup = RestResource<\"PointGroup\", PointGroup>;\nexport type TaggedRegimen = RestResource<\"Regimen\", Regimen>;\nexport type TaggedSavedGarden = RestResource<\"SavedGarden\", SavedGarden>;\nexport type TaggedSensor = RestResource<\"Sensor\", Sensor>;\nexport type TaggedSensorReading = RestResource<\"SensorReading\", SensorReading>;\nexport type TaggedSequence = RestResource<\"Sequence\", SequenceResource>;\nexport type TaggedTelemetry = RestResource<\"Telemetry\", Telemetry>;\nexport type TaggedTool = RestResource<\"Tool\", Tool>;\nexport type TaggedToolSlotPointer = RestResource<\"Point\", ToolSlotPointer>;\nexport type TaggedUser = RestResource<\"User\", User>;\nexport type TaggedWebAppConfig = RestResource<\"WebAppConfig\", WebAppConfig>;\nexport type TaggedWebcamFeed = RestResource<\"WebcamFeed\", WebcamFeed>;\nexport type TaggedWizardStepResult = RestResource<\"WizardStepResult\", WizardStepResult>;\nexport type TaggedWeedPointer = RestResource<\"Point\", WeedPointer>;\n\nexport type PointerType =\n | TaggedToolSlotPointer\n | TaggedGenericPointer\n | TaggedPlantPointer\n | TaggedWeedPointer;\n","// This is a stub for developers who do not have a module loader or are\n// prototyping one-off scripts in a browser.\nwindow.fbjs = require(\"./index.ts\");\n"],"names":["$b8E1b$mqtt","require","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","hasOwnProperty","defineProperty","enumerable","get","$parcel$export","e","n","v","s","set","configurable","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","$h19jY","$fTGM0","$3tZ8P","$jOzD0","$bFr0L","$c639c2a4041df2b3$export$5bd6772f122cb888","$c639c2a4041df2b3$export$642ebf9ec2e6a14a","$c639c2a4041df2b3$export$59b5878345794ac6","$b92d2bf8eb506f9b$export$3ab9a2df6016a88a","$01gfL","$8i5S2","$iwcyJ","$f5H0j","$dPMce","$7tZ6d","$byyGl","$aWv1W","Farmbot","input","_this","getConfig","config","setConfig","value","installFarmware","url","send","rpcRequest","kind","args","updateFarmware","pkg","package","removeFarmware","installFirstPartyFarmware","powerOff","reboot","rebootFirmware","checkUpdates","resetOS","publish","resetMCU","flashFirmware","firmware_name","emergencyLock","rpc","Priority","HIGHEST","emergencyUnlock","execSequence","sequence_id","body","execScript","label","envVars","home","findHome","moveAbsolute","x","y","z","speed","CONFIG_DEFAULTS","location","coordinate","offset","moveRelative","writePin","readPin","togglePin","readStatus","takePhoto","sync","setZero","axis","setUserEnv","configs","map","Misc","NULL","sendMessage","message_type","message","channels","channel_name","setServoAngle","result","includes","pin_number","pin_value","calibrate","lua","event","name","_events","on","once","push","emit","data","nextArray","concat","handler","console","warn","dir","length","msg","important","client","FbjsEventName","sent","channel","toDevice","JSON","stringify","Promise","resolve","reject","response","join","_onmessage","chan","buffer","original","bufferToString","segments","split","MQTT_DELIM","parse","MqttChanName","publicBroadcast","logs","status","pong","ev","hasLabel","malformed","error","text","ping","timeout","now","timestamp","doPing","startedAt","race","_","rej","setTimeout","res","t","connect","_a","mqttUsername","token","mqttServer","reconnectPeriod","RECONNECT_THROTTLE_MS","clean","clientId","VERSION","uuid","password","protocolId","protocolVersion","username","resources","ResourceAdapter","offline","online","toClient","subscribe","_reject","generateConfig","prototype","deviceName","fromClients","fromDevice","tStamp","$e6ce52d33b3b9851$export$1e95461c937e230d","$e6ce52d33b3b9851$export$4f75cc6593308bd6","$3SNLU","$4svrT","str","regular_array","charCodeAt","Uint8Array","$e6ce52d33b3b9851$var$td","util","TextDecoder","window","decode","chars","String","fromCharCode","b","$60948eee8fcc500d$export$bf56ff1a05c69b9a","$869dc5c8a17d7708$export$7b28645421dfad14","$869dc5c8a17d7708$export$939ea909fc0c90e4","$869dc5c8a17d7708$var$isObj","o","$2d3d05e3f1851e01$export$8ee0fc9ee280b4ee","$33f22c0e5ae5fa1f$export$357523c63a2253b9","target","fallback","$003cb3b035fb32f9$export$300334f671c43555","$003cb3b035fb32f9$export$d6d466271de85642","priority","NORMAL","$d7b4f5289284df15$export$31b40729666a4ae0","template","replace","c","r","Math","random","toString","$afc8ae5bc0bbdf6a$export$429fe2716bb77ce4","$afc8ae5bc0bbdf6a$export$2eafab8a593352a4","$afc8ae5bc0bbdf6a$var$parseToken","atob","isNode","secure","mqtt","mqtt_ws","bot","LAST_PING_OUT","LAST_PING_IN","$a1256c8ef829f998$export$61d38aff960bd05b","$kGTNw","$d1UZh","parent","destroy","doDestroy","rejectRpc","save","resource","doSave","destroyAll","req","all","requestId","resolveOrReject","outboundChanFor","uid","$f103032c79b02b9d$export$282f68fea638d11","$f103032c79b02b9d$export$bcbf15ce904d591a","$f103032c79b02b9d$export$cbefd47f9f016f08","op","m","$97c792dbbae05474$export$d53e1703f9959ce0","internalError","$572aa2e43a4df30f$export$51316fc5e371191b","$572aa2e43a4df30f$export$9758e930bdf73341","$572aa2e43a4df30f$export$4b3033a0406d3b","$7f77641fb0661547$export$fc00ee57782020aa","round","Date","getTime","$289381f16f78a587$export$a50aceb0e02a00aa","Encoder","$02312b41c59a57c7$export$d3ccc720d6d43811","SpecialStatus","fbjs"],"version":3,"file":"farmbot_single_file.js.map","sourceRoot":"../"} \ No newline at end of file +{"mappings":"A,I,E,Q,Q,S,E,C,C,C,E,O,O,I,C,G,O,C,S,C,E,Y,G,A,e,G,E,c,C,I,O,c,C,E,E,C,W,C,E,I,W,O,C,C,E,A,C,E,G,C,C,S,E,C,C,C,C,C,C,C,E,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,uEAAuE;AACvE,4CAA4C;AAC5C,OAAO,IAAI,CAAX,EAAA,Q,gD","sources":["","src/index.ts","src/corpus.ts","src/farmbot.ts","src/util.ts","src/util/coordinate.ts","src/util/is_celery_script.ts","src/util/is_node.ts","src/util/pick.ts","src/util/rpc_request.ts","src/util/uuid.ts","src/config.ts","src/resources/resource_adapter.ts","src/resources/support.ts","src/resources/reject_rpc.ts","src/constants.ts","src/util/time.ts","src/interfaces.ts","src/resources/tagged_resource.ts","src/farmbot_single_file.js"],"sourcesContent":["var $b8E1b$mqtt = require(\"mqtt\");\n\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n }\n });\n });\n\n return dest;\n}\n\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequire1c57\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequire1c57\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nparcelRegister(\"gwFY1\", function(module, exports) {\n\nvar $h19jY = parcelRequire(\"h19jY\");\n\nvar $fTGM0 = parcelRequire(\"fTGM0\");\n\nvar $3tZ8P = parcelRequire(\"3tZ8P\");\n\nvar $jOzD0 = parcelRequire(\"jOzD0\");\n\nvar $bFr0L = parcelRequire(\"bFr0L\");\n$parcel$exportWildcard(module.exports, $h19jY);\n$parcel$exportWildcard(module.exports, $fTGM0);\n$parcel$exportWildcard(module.exports, $3tZ8P);\n$parcel$exportWildcard(module.exports, $jOzD0);\n$parcel$exportWildcard(module.exports, $bFr0L);\n\n});\nparcelRegister(\"h19jY\", function(module, exports) {\n\n$parcel$export(module.exports, \"LATEST_VERSION\", () => $c639c2a4041df2b3$export$5bd6772f122cb888);\n$parcel$export(module.exports, \"DIGITAL\", () => $c639c2a4041df2b3$export$642ebf9ec2e6a14a);\n$parcel$export(module.exports, \"ANALOG\", () => $c639c2a4041df2b3$export$59b5878345794ac6);\n// THIS INTERFACE WAS AUTO GENERATED ON 2023-07-27\n// DO NOT EDIT THIS FILE.\n// IT WILL BE OVERWRITTEN ON EVERY CELERYSCRIPT UPGRADE.\nvar $c639c2a4041df2b3$export$5bd6772f122cb888 = 20180209;\nvar $c639c2a4041df2b3$export$642ebf9ec2e6a14a = 0;\nvar $c639c2a4041df2b3$export$59b5878345794ac6 = 1;\n\n});\n\nparcelRegister(\"fTGM0\", function(module, exports) {\n\n$parcel$export(module.exports, \"Farmbot\", () => $b92d2bf8eb506f9b$export$3ab9a2df6016a88a);\n\nparcelRequire(\"jOzD0\");\nvar $01gfL = parcelRequire(\"01gfL\");\nvar $8i5S2 = parcelRequire(\"8i5S2\");\nvar $iwcyJ = parcelRequire(\"iwcyJ\");\nparcelRequire(\"gwFY1\");\nvar $jOzD0 = parcelRequire(\"jOzD0\");\n\nvar $f5H0j = parcelRequire(\"f5H0j\");\n\nvar $dPMce = parcelRequire(\"dPMce\");\n\nvar $7tZ6d = parcelRequire(\"7tZ6d\");\n\nvar $byyGl = parcelRequire(\"byyGl\");\n\nvar $aWv1W = parcelRequire(\"aWv1W\");\n\nvar $01gfL = parcelRequire(\"01gfL\");\nvar $b92d2bf8eb506f9b$export$3ab9a2df6016a88a = /** @class */ function() {\n function Farmbot(input) {\n var _this = this;\n /** Get a Farmbot Constructor Parameter. */ this.getConfig = function(key) {\n return _this.config[key];\n };\n /** Set a Farmbot Constructor Parameter. */ this.setConfig = function(key, value) {\n _this.config[key] = value;\n };\n /**\n * Installs a \"Farmware\" (plugin) onto the bot's SD card.\n * URL must point to a valid Farmware manifest JSON document.\n */ this.installFarmware = function(url) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"install_farmware\",\n args: {\n url: url\n }\n }\n ]));\n };\n /**\n * Checks for updates on a particular Farmware plugin when given the name of\n * a Farmware. `updateFarmware(\"take-photo\")`\n */ this.updateFarmware = function(pkg) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"update_farmware\",\n args: {\n package: pkg\n }\n }\n ]));\n };\n /** Uninstall a Farmware plugin. */ this.removeFarmware = function(pkg) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"remove_farmware\",\n args: {\n package: pkg\n }\n }\n ]));\n };\n /**\n * Installs \"Farmware\" (plugins) authored by FarmBot, Inc.\n * onto the bot's SD card.\n */ this.installFirstPartyFarmware = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"install_first_party_farmware\",\n args: {}\n }\n ]));\n };\n /**\n * Deactivate FarmBot OS completely (shutdown).\n * Useful before unplugging the power.\n */ this.powerOff = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"power_off\",\n args: {}\n }\n ]));\n };\n /** Restart FarmBot OS. */ this.reboot = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"reboot\",\n args: {\n package: \"farmbot_os\"\n }\n }\n ]));\n };\n /** Reinitialize the FarmBot microcontroller firmware. */ this.rebootFirmware = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"reboot\",\n args: {\n package: \"arduino_firmware\"\n }\n }\n ]));\n };\n /** Check for new versions of FarmBot OS.\n * Downloads and installs if available. */ this.checkUpdates = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"check_updates\",\n args: {\n package: \"farmbot_os\"\n }\n }\n ]));\n };\n /** THIS WILL RESET THE SD CARD, deleting all non-factory data!\n * Be careful!! */ this.resetOS = function() {\n return _this.publish((0, $01gfL.rpcRequest)([\n {\n kind: \"factory_reset\",\n args: {\n package: \"farmbot_os\"\n }\n }\n ]));\n };\n /** WARNING: will reset all firmware (hardware) settings! */ this.resetMCU = function() {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"factory_reset\",\n args: {\n package: \"arduino_firmware\"\n }\n }\n ]));\n };\n this.flashFirmware = function(/** one of: \"arduino\"|\"express_k10\"|\"farmduino_k14\"|\"farmduino\" */ firmware_name) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"flash_firmware\",\n args: {\n package: firmware_name\n }\n }\n ]));\n };\n /**\n * Lock the bot from moving (E-STOP). Turns off peripherals and motors. This\n * also will pause running regimens and cause any running sequences to exit.\n */ this.emergencyLock = function() {\n var body = [\n {\n kind: \"emergency_lock\",\n args: {}\n }\n ];\n var rpc = (0, $01gfL.rpcRequest)(body, (0, $01gfL.Priority).HIGHEST);\n return _this.send(rpc);\n };\n /** Unlock the bot when the user says it is safe. */ this.emergencyUnlock = function() {\n var body = [\n {\n kind: \"emergency_unlock\",\n args: {}\n }\n ];\n var rpc = (0, $01gfL.rpcRequest)(body, (0, $01gfL.Priority).HIGHEST);\n return _this.send(rpc);\n };\n /** Execute a sequence by its ID on the FarmBot API. */ this.execSequence = function(sequence_id, body) {\n if (body === void 0) body = [];\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"execute\",\n args: {\n sequence_id: sequence_id\n },\n body: body\n }\n ]));\n };\n /** Run an installed Farmware plugin on the SD Card. */ this.execScript = function(/** Name of the Farmware. */ label, /** Optional ENV vars to pass the Farmware. */ envVars) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"execute_script\",\n args: {\n label: label\n },\n body: envVars\n }\n ]));\n };\n /** Bring a particular axis (or all of them) to position 0 in Z Y X order. */ this.home = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"home\",\n args: args\n }\n ]));\n };\n /** Use end stops or encoders to figure out where 0,0,0 is in Z Y X axis\n * order. WON'T WORK WITHOUT ENCODERS OR END STOPS! A blockage or stall\n * during this command will set that position as zero. Use carefully. */ this.findHome = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"find_home\",\n args: args\n }\n ]));\n };\n /** Move FarmBot to an absolute point. */ this.moveAbsolute = function(args) {\n var x = args.x, y = args.y, z = args.z;\n var speed = args.speed || (0, $f5H0j.CONFIG_DEFAULTS).speed;\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"move_absolute\",\n args: {\n location: (0, $8i5S2.coordinate)(x, y, z),\n offset: (0, $8i5S2.coordinate)(0, 0, 0),\n speed: speed\n }\n }\n ]));\n };\n /** Move FarmBot to position relative to its current position. */ this.moveRelative = function(args) {\n var x = args.x, y = args.y, z = args.z;\n var speed = args.speed || (0, $f5H0j.CONFIG_DEFAULTS).speed;\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"move_relative\",\n args: {\n x: x,\n y: y,\n z: z,\n speed: speed\n }\n }\n ]));\n };\n /** Set a GPIO pin to a particular value. */ this.writePin = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"write_pin\",\n args: args\n }\n ]));\n };\n /** Read the value of a GPIO pin. Will create a SensorReading if it's\n * a sensor. */ this.readPin = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"read_pin\",\n args: args\n }\n ]));\n };\n /** Reverse the value of a digital pin. */ this.togglePin = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"toggle_pin\",\n args: args\n }\n ]));\n };\n /** Read the status of the bot. Should not be needed unless you are first\n * logging in to the device, since the device pushes new states out on\n * every update. */ this.readStatus = function(args) {\n if (args === void 0) args = {};\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"read_status\",\n args: args\n }\n ]));\n };\n /** Snap a photo and send to the API for post processing. */ this.takePhoto = function(args) {\n if (args === void 0) args = {};\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"take_photo\",\n args: args\n }\n ]));\n };\n /** Download/apply all of the latest FarmBot API JSON resources (plants,\n * account info, etc.) to the device. */ this.sync = function(args) {\n if (args === void 0) args = {};\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"sync\",\n args: args\n }\n ]));\n };\n /**\n * Set the current position of the given axis to 0.\n * Example: Sending `bot.setZero(\"x\")` at x: 255 will translate position\n * 255 to 0, causing that position to be x: 0.\n */ this.setZero = function(axis) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"zero\",\n args: {\n axis: axis\n }\n }\n ]));\n };\n /**\n * Set user ENV vars (usually used by 3rd-party Farmware plugins).\n * Set value to `undefined` to unset.\n */ this.setUserEnv = function(configs) {\n var body = Object.keys(configs).map(function(label) {\n return {\n kind: \"pair\",\n args: {\n label: label,\n value: configs[label] || (0, $7tZ6d.Misc).NULL\n }\n };\n });\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"set_user_env\",\n args: {},\n body: body\n }\n ]));\n };\n this.sendMessage = function(message_type, message, channels) {\n if (channels === void 0) channels = [];\n _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"send_message\",\n args: {\n message_type: message_type,\n message: message\n },\n body: channels.map(function(channel_name) {\n return {\n kind: \"channel\",\n args: {\n channel_name: channel_name\n }\n };\n })\n }\n ]));\n };\n /** Control servos on pins 4 and 5. */ this.setServoAngle = function(args) {\n var result = _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"set_servo_angle\",\n args: args\n }\n ]));\n // Celery script can't validate `pin_number` and `pin_value` the way we need\n // for `set_servo_angle`. We will send the RPC command off, but also\n // crash the client to aid debugging.\n if (![\n 4,\n 5,\n 6,\n 11\n ].includes(args.pin_number)) throw new Error(\"Servos only work on pins 4 and 5\");\n if (args.pin_value > 180 || args.pin_value < 0) throw new Error(\"Pin value outside of 0...180 range\");\n return result;\n };\n /**\n * Find the axis extents using encoder, motor, or end-stop feedback.\n * Will set a new home position and a new axis length for the given axis.\n */ this.calibrate = function(args) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"calibrate\",\n args: args\n }\n ]));\n };\n this.lua = function(lua) {\n return _this.send((0, $01gfL.rpcRequest)([\n {\n kind: \"lua\",\n args: {\n lua: lua\n }\n }\n ]));\n };\n /**\n * Retrieves all of the event handlers for a particular event.\n * Returns an empty array if the event did not exist.\n */ this.event = function(name) {\n _this._events[name] = _this._events[name] || [];\n return _this._events[name];\n };\n this.on = function(event, value, once) {\n if (once === void 0) once = false;\n _this.event(event).push({\n value: value,\n once: once,\n event: event\n });\n };\n this.emit = function(event, data) {\n var nextArray = [];\n _this.event(event).concat(_this.event(\"*\")).forEach(function(handler) {\n try {\n handler.value(data, event);\n if (!handler.once && handler.event === event) nextArray.push(handler);\n } catch (e) {\n var msg = \"Exception thrown while handling '\".concat(event, \"' event.\");\n console.warn(msg);\n console.dir(e);\n }\n });\n if (nextArray.length === 0) delete _this._events[event];\n else _this._events[event] = nextArray;\n };\n /** Low-level means of sending MQTT packets. Does not check format. Does not\n * acknowledge confirmation. Probably not the one you want. */ this.publish = function(msg, important) {\n if (important === void 0) important = true;\n if (_this.client) {\n _this.emit((0, $7tZ6d.FbjsEventName).sent, msg);\n /** SEE: https://github.com/mqttjs/MQTT.js#client */ _this.client.publish(_this.channel.toDevice, JSON.stringify(msg));\n } else {\n if (important) throw new Error(\"Not connected to server\");\n }\n };\n /** Low-level means of sending MQTT RPC commands to the bot. Acknowledges\n * receipt of message, but does not check formatting. Consider using higher\n * level methods like .moveRelative(), .calibrate(), etc....\n */ this.send = function(input) {\n return new Promise(function(resolve, reject) {\n _this.publish(input);\n function handler(response) {\n switch(response.kind){\n case \"rpc_ok\":\n return resolve(response);\n case \"rpc_error\":\n var reason = (response.body || []).map(function(x) {\n return x.args.message;\n }).join(\", \");\n return reject(new Error(\"Problem sending RPC command: \" + reason));\n default:\n console.dir(response);\n throw new Error(\"Got a bad CeleryScript node.\");\n }\n }\n _this.on(input.args.label, handler, true);\n });\n };\n /** Main entry point for all MQTT packets. */ this._onmessage = function(chan, buffer) {\n var original = (0, $jOzD0.bufferToString)(buffer);\n var segments = chan.split((0, $7tZ6d.Misc).MQTT_DELIM);\n var emit = _this.emit;\n try {\n var msg = JSON.parse(original);\n if (segments[0] == (0, $7tZ6d.MqttChanName).publicBroadcast) return emit((0, $7tZ6d.MqttChanName).publicBroadcast, msg);\n switch(segments[2]){\n case (0, $7tZ6d.MqttChanName).logs:\n return emit((0, $7tZ6d.FbjsEventName).logs, msg);\n case (0, $7tZ6d.MqttChanName).status:\n return emit((0, $7tZ6d.FbjsEventName).status, msg);\n case (0, $7tZ6d.MqttChanName).sync:\n return emit((0, $7tZ6d.FbjsEventName).sync, msg);\n case (0, $7tZ6d.MqttChanName).pong:\n return emit(segments[3], msg);\n default:\n var ev = (0, $byyGl.hasLabel)(msg) ? msg.args.label : (0, $7tZ6d.FbjsEventName).malformed;\n return emit(ev, msg);\n }\n } catch (error) {\n console.dir({\n text: \"Could not parse inbound message from MQTT.\",\n error: error\n });\n emit((0, $7tZ6d.FbjsEventName).malformed, original);\n }\n };\n this.ping = function(timeout, now) {\n if (timeout === void 0) timeout = 10000;\n if (now === void 0) now = (0, $aWv1W.timestamp)();\n _this.setConfig(\"LAST_PING_OUT\", now);\n return _this.doPing(now, timeout);\n };\n // STEP 0: Subscribe to `bot/device_23/pong/#`\n // STEP 0: Send `bot/device_23/ping/3123123`\n // STEP 0: Receive `bot/device_23/pong/3123123`\n this.doPing = function(startedAt, timeout) {\n var timeoutPromise = new Promise(function(_, rej) {\n return setTimeout(function() {\n return rej(-0);\n }, timeout);\n });\n var pingPromise = new Promise(function(res, _) {\n var ok = function() {\n var t = (0, $aWv1W.timestamp)();\n _this.setConfig(\"LAST_PING_IN\", t);\n res(t - startedAt);\n };\n _this.on(\"\" + startedAt, ok, true);\n var chan = _this.channel.ping(startedAt);\n if (_this.client) _this.client.publish(chan, JSON.stringify(startedAt));\n });\n return Promise.race([\n timeoutPromise,\n pingPromise\n ]);\n };\n /** Bootstrap the device onto the MQTT broker. */ this.connect = function() {\n var _a = _this.config, mqttUsername = _a.mqttUsername, token = _a.token, mqttServer = _a.mqttServer;\n var reconnectPeriod = (0, $7tZ6d.Misc).RECONNECT_THROTTLE_MS;\n var client = (0, $b8E1b$mqtt.connect)(mqttServer, {\n clean: true,\n clientId: \"FBJS-\".concat(Farmbot.VERSION, \"-\").concat((0, $iwcyJ.uuid)()),\n password: token,\n protocolId: \"MQTT\",\n protocolVersion: 4,\n reconnectPeriod: reconnectPeriod,\n username: mqttUsername\n });\n _this.client = client;\n _this.resources = new (0, $dPMce.ResourceAdapter)(_this, _this.config.mqttUsername);\n client.on(\"message\", _this._onmessage);\n client.on(\"offline\", function() {\n return _this.emit((0, $7tZ6d.FbjsEventName).offline, {});\n });\n client.on(\"connect\", function() {\n return _this.emit((0, $7tZ6d.FbjsEventName).online, {});\n });\n var channels = [\n _this.channel.logs,\n _this.channel.status,\n _this.channel.sync,\n _this.channel.toClient,\n _this.channel.pong\n ];\n client.subscribe(channels);\n return new Promise(function(resolve, _reject) {\n if (_this.client) _this.client.once(\"connect\", function() {\n return resolve(_this);\n });\n else throw new Error(\"Please connect first.\");\n });\n };\n this._events = {};\n this.config = (0, $f5H0j.generateConfig)(input);\n this.resources = new (0, $dPMce.ResourceAdapter)(this, this.config.mqttUsername);\n }\n Object.defineProperty(Farmbot.prototype, \"channel\", {\n /** Dictionary of all relevant MQTT channels the bot uses. */ get: function() {\n var deviceName = this.config.mqttUsername;\n return {\n /** From the browser, usually. */ toDevice: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).fromClients),\n /** From farmbot */ toClient: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).fromDevice),\n status: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).status),\n logs: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).logs),\n sync: \"bot/\".concat(deviceName, \"/\").concat((0, $7tZ6d.MqttChanName).sync, \"/#\"),\n /** Read only */ pong: \"bot/\".concat(deviceName, \"/pong/#\"),\n /** Write only: bot/${deviceName}/ping/${timestamp} */ ping: function(tStamp) {\n return \"bot/\".concat(deviceName, \"/ping/\").concat(tStamp);\n }\n };\n },\n enumerable: false,\n configurable: true\n });\n Farmbot.VERSION = \"15.8.3\";\n return Farmbot;\n}();\n\n});\nparcelRegister(\"jOzD0\", function(module, exports) {\n\n$parcel$export(module.exports, \"stringToBuffer\", () => $e6ce52d33b3b9851$export$1e95461c937e230d);\n$parcel$export(module.exports, \"bufferToString\", () => $e6ce52d33b3b9851$export$4f75cc6593308bd6);\n\nvar $8i5S2 = parcelRequire(\"8i5S2\");\n\nvar $byyGl = parcelRequire(\"byyGl\");\n\nvar $3SNLU = parcelRequire(\"3SNLU\");\n\nvar $4svrT = parcelRequire(\"4svrT\");\n\nvar $01gfL = parcelRequire(\"01gfL\");\n\nvar $iwcyJ = parcelRequire(\"iwcyJ\");\nfunction $e6ce52d33b3b9851$export$1e95461c937e230d(str) {\n var regular_array = str.split(\"\").map(function(x) {\n return x.charCodeAt(0);\n });\n var data16 = new Uint8Array(regular_array);\n return data16;\n}\nfunction $e6ce52d33b3b9851$var$newDecoder() {\n if (typeof util !== \"undefined\" && util.TextDecoder) return new util.TextDecoder();\n if (typeof window !== \"undefined\" && window.TextDecoder) return new window.TextDecoder();\n return {\n decode: function(buffer) {\n var chars = [];\n buffer.forEach(function(x) {\n return chars.push(String.fromCharCode(x));\n });\n return chars.join(\"\");\n }\n };\n}\nvar $e6ce52d33b3b9851$var$td = $e6ce52d33b3b9851$var$newDecoder();\nvar $e6ce52d33b3b9851$export$4f75cc6593308bd6 = function(b) {\n return $e6ce52d33b3b9851$var$td.decode(b);\n};\n$parcel$exportWildcard(module.exports, $8i5S2);\n$parcel$exportWildcard(module.exports, $byyGl);\n$parcel$exportWildcard(module.exports, $3SNLU);\n$parcel$exportWildcard(module.exports, $4svrT);\n$parcel$exportWildcard(module.exports, $01gfL);\n$parcel$exportWildcard(module.exports, $iwcyJ);\n\n});\nparcelRegister(\"8i5S2\", function(module, exports) {\n\n$parcel$export(module.exports, \"coordinate\", () => $60948eee8fcc500d$export$bf56ff1a05c69b9a);\nfunction $60948eee8fcc500d$export$bf56ff1a05c69b9a(x, y, z) {\n return {\n kind: \"coordinate\",\n args: {\n x: x,\n y: y,\n z: z\n }\n };\n}\n\n});\n\nparcelRegister(\"byyGl\", function(module, exports) {\n\n$parcel$export(module.exports, \"isCeleryScript\", () => $869dc5c8a17d7708$export$7b28645421dfad14);\n$parcel$export(module.exports, \"hasLabel\", () => $869dc5c8a17d7708$export$939ea909fc0c90e4);\nvar $869dc5c8a17d7708$var$isObj = function(o) {\n return !!(o && typeof o === \"object\");\n};\nvar $869dc5c8a17d7708$var$hasKind = function(o) {\n return typeof o.kind === \"string\";\n};\nvar $869dc5c8a17d7708$var$hasArgs = function(o) {\n return $869dc5c8a17d7708$var$isObj(o) && !!o.args;\n};\nfunction $869dc5c8a17d7708$export$7b28645421dfad14(x) {\n return $869dc5c8a17d7708$var$isObj(x) && $869dc5c8a17d7708$var$hasKind(x) && $869dc5c8a17d7708$var$hasArgs(x);\n}\nfunction $869dc5c8a17d7708$export$939ea909fc0c90e4(x) {\n if ($869dc5c8a17d7708$export$7b28645421dfad14(x)) return typeof x.args.label === \"string\";\n else return false;\n}\n\n});\n\nparcelRegister(\"3SNLU\", function(module, exports) {\n\n$parcel$export(module.exports, \"isNode\", () => $2d3d05e3f1851e01$export$8ee0fc9ee280b4ee);\nfunction $2d3d05e3f1851e01$export$8ee0fc9ee280b4ee() {\n return typeof window === \"undefined\";\n}\n\n});\n\nparcelRegister(\"4svrT\", function(module, exports) {\n\n$parcel$export(module.exports, \"pick\", () => $33f22c0e5ae5fa1f$export$357523c63a2253b9);\nfunction $33f22c0e5ae5fa1f$export$357523c63a2253b9(target, value, fallback) {\n var result = target[value];\n return result;\n}\n\n});\n\nparcelRegister(\"01gfL\", function(module, exports) {\n\n$parcel$export(module.exports, \"Priority\", () => $003cb3b035fb32f9$export$300334f671c43555);\n$parcel$export(module.exports, \"rpcRequest\", () => $003cb3b035fb32f9$export$d6d466271de85642);\n\nvar $iwcyJ = parcelRequire(\"iwcyJ\");\nvar $003cb3b035fb32f9$export$300334f671c43555;\n(function(Priority) {\n Priority[Priority[\"HIGHEST\"] = 9000] = \"HIGHEST\";\n Priority[Priority[\"NORMAL\"] = 600] = \"NORMAL\";\n Priority[Priority[\"LOWEST\"] = 300] = \"LOWEST\";\n})($003cb3b035fb32f9$export$300334f671c43555 || ($003cb3b035fb32f9$export$300334f671c43555 = {}));\nvar $003cb3b035fb32f9$export$d6d466271de85642 = function(body, priority) {\n if (priority === void 0) priority = $003cb3b035fb32f9$export$300334f671c43555.NORMAL;\n return {\n kind: \"rpc_request\",\n args: {\n label: (0, $iwcyJ.uuid)(),\n priority: priority\n },\n body: body\n };\n};\n\n});\nparcelRegister(\"iwcyJ\", function(module, exports) {\n\n$parcel$export(module.exports, \"uuid\", () => $d7b4f5289284df15$export$31b40729666a4ae0);\nfunction $d7b4f5289284df15$export$31b40729666a4ae0() {\n var template = \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\";\n var replaceChar = function(c) {\n var r = Math.random() * 16 | 0;\n var v = c === \"x\" ? r : r & 0x3 | 0x8;\n return v.toString(16);\n };\n return template.replace(/[xy]/g, replaceChar);\n}\n\n});\n\n\n\nparcelRegister(\"f5H0j\", function(module, exports) {\n\n$parcel$export(module.exports, \"CONFIG_DEFAULTS\", () => $afc8ae5bc0bbdf6a$export$429fe2716bb77ce4);\n$parcel$export(module.exports, \"generateConfig\", () => $afc8ae5bc0bbdf6a$export$2eafab8a593352a4);\nparcelRequire(\"jOzD0\");\nvar $3SNLU = parcelRequire(\"3SNLU\");\nvar $afc8ae5bc0bbdf6a$var$ERR_TOKEN_PARSE = \"Unable to parse token. Is it properly formatted?\";\nvar $afc8ae5bc0bbdf6a$export$429fe2716bb77ce4 = {\n speed: 100\n};\nvar $afc8ae5bc0bbdf6a$var$ERR_MISSING_MQTT_USERNAME = \"MISSING_MQTT_USERNAME\";\nvar $afc8ae5bc0bbdf6a$export$ddc74f6374f2ef10 = \"NOTE TO NODEJS USERS:\\n\\nThis library requires an 'atob()' function.\\nPlease fix this first.\\nSOLUTION: https://github.com/FarmBot/farmbot-js/issues/33\";\nvar $afc8ae5bc0bbdf6a$var$parseToken = function(input) {\n try {\n return JSON.parse(atob(input.split(\".\")[1]));\n } catch (e) {\n console.warn(e);\n throw new Error($afc8ae5bc0bbdf6a$var$ERR_TOKEN_PARSE);\n }\n};\nvar $afc8ae5bc0bbdf6a$export$2eafab8a593352a4 = function(input) {\n if ((0, $3SNLU.isNode)() && !$parcel$global.atob) throw new Error($afc8ae5bc0bbdf6a$export$ddc74f6374f2ef10);\n var t = $afc8ae5bc0bbdf6a$var$parseToken(input.token);\n return {\n speed: input.speed || $afc8ae5bc0bbdf6a$export$429fe2716bb77ce4.speed,\n token: input.token,\n secure: input.secure === false ? false : true,\n mqttServer: (0, $3SNLU.isNode)() ? \"mqtt://\".concat(t.mqtt, \":1883\") : t.mqtt_ws,\n mqttUsername: t.bot || $afc8ae5bc0bbdf6a$var$ERR_MISSING_MQTT_USERNAME,\n LAST_PING_OUT: 0,\n LAST_PING_IN: 0\n };\n};\n\n});\n\nparcelRegister(\"dPMce\", function(module, exports) {\n\n$parcel$export(module.exports, \"ResourceAdapter\", () => $a1256c8ef829f998$export$61d38aff960bd05b);\nparcelRequire(\"gwFY1\");\nvar $iwcyJ = parcelRequire(\"iwcyJ\");\n\nvar $kGTNw = parcelRequire(\"kGTNw\");\n\nvar $d1UZh = parcelRequire(\"d1UZh\");\nvar $a1256c8ef829f998$export$61d38aff960bd05b = /** @class */ function() {\n function ResourceAdapter(parent, username) {\n var _this = this;\n this.parent = parent;\n this.username = username;\n this.destroy = function(r) {\n var client = _this.parent.client;\n return client ? _this.doDestroy(client, r.kind, r.id) : (0, $d1UZh.rejectRpc)();\n };\n this.save = function(resource) {\n var client = _this.parent.client;\n return client ? _this.doSave(client, resource) : (0, $d1UZh.rejectRpc)();\n };\n this.destroyAll = function(req) {\n return Promise.all(req.map(function(r) {\n return _this.destroy(r);\n }));\n };\n this.doDestroy = function(client, kind, id) {\n return new Promise(function(res, rej) {\n var requestId = (0, $iwcyJ.uuid)();\n _this.parent.on(requestId, (0, $kGTNw.resolveOrReject)(res, rej));\n client.publish((0, $kGTNw.outboundChanFor)(_this.username, \"destroy\", kind, requestId, id), \"\");\n });\n };\n this.doSave = function(client, r) {\n return new Promise(function(res, rej) {\n var uid = (0, $iwcyJ.uuid)();\n _this.parent.on(uid, (0, $kGTNw.resolveOrReject)(res, rej));\n var chan = (0, $kGTNw.outboundChanFor)(_this.username, \"save\", r.kind, uid, r.body.id);\n client.publish(chan, JSON.stringify(r.body));\n });\n };\n }\n return ResourceAdapter;\n}();\n\n});\nparcelRegister(\"kGTNw\", function(module, exports) {\n\n$parcel$export(module.exports, \"outboundChanFor\", () => $f103032c79b02b9d$export$282f68fea638d11);\n$parcel$export(module.exports, \"internalError\", () => $f103032c79b02b9d$export$bcbf15ce904d591a);\n$parcel$export(module.exports, \"resolveOrReject\", () => $f103032c79b02b9d$export$cbefd47f9f016f08);\nvar $f103032c79b02b9d$export$282f68fea638d11 = function(username, op, kind, uuid, id) {\n if (id === void 0) id = 0;\n var segments = [\n \"bot\",\n username,\n \"resources_v0\",\n op,\n kind,\n uuid,\n id\n ];\n return segments.join(\"/\");\n};\nvar $f103032c79b02b9d$export$bcbf15ce904d591a = {\n kind: \"rpc_error\",\n args: {\n label: \"BROWSER_LEVEL_FAILURE\"\n },\n body: [\n {\n kind: \"explanation\",\n args: {\n message: \"Tried to perform batch operation before connect.\"\n }\n }\n ]\n};\nvar $f103032c79b02b9d$export$cbefd47f9f016f08 = function(res, rej) {\n return function(m) {\n return (m.kind == \"rpc_ok\" ? res : rej)(m);\n };\n};\n\n});\n\nparcelRegister(\"d1UZh\", function(module, exports) {\n\n$parcel$export(module.exports, \"rejectRpc\", () => $97c792dbbae05474$export$d53e1703f9959ce0);\n\nvar $kGTNw = parcelRequire(\"kGTNw\");\nvar $97c792dbbae05474$export$d53e1703f9959ce0 = function() {\n return Promise.reject((0, $kGTNw.internalError));\n};\n\n});\n\n\nparcelRegister(\"7tZ6d\", function(module, exports) {\n\n$parcel$export(module.exports, \"MqttChanName\", () => $572aa2e43a4df30f$export$51316fc5e371191b);\n$parcel$export(module.exports, \"FbjsEventName\", () => $572aa2e43a4df30f$export$9758e930bdf73341);\n$parcel$export(module.exports, \"Misc\", () => $572aa2e43a4df30f$export$4b3033a0406d3b);\nvar $572aa2e43a4df30f$export$51316fc5e371191b;\n(function(MqttChanName) {\n MqttChanName[\"fromApi\"] = \"from_api\";\n MqttChanName[\"fromClients\"] = \"from_clients\";\n MqttChanName[\"fromDevice\"] = \"from_device\";\n MqttChanName[\"logs\"] = \"logs\";\n MqttChanName[\"status\"] = \"status\";\n MqttChanName[\"sync\"] = \"sync\";\n /** THIS ONE IS SPECIAL. */ MqttChanName[\"publicBroadcast\"] = \"public_broadcast\";\n MqttChanName[\"pong\"] = \"pong\";\n})($572aa2e43a4df30f$export$51316fc5e371191b || ($572aa2e43a4df30f$export$51316fc5e371191b = {}));\nvar $572aa2e43a4df30f$export$9758e930bdf73341;\n(function(FbjsEventName) {\n /** State tree update. */ FbjsEventName[\"status\"] = \"status\";\n /** When a log is received */ FbjsEventName[\"logs\"] = \"logs\";\n /** When an unexpected message is received */ FbjsEventName[\"malformed\"] = \"malformed\";\n /** Unreliable. */ FbjsEventName[\"offline\"] = \"offline\";\n /** Fired on connect. */ FbjsEventName[\"online\"] = \"online\";\n /** Fires when the API sends an MQTT message to users. */ FbjsEventName[\"publicBroadcast\"] = \"public_broadcast\";\n /** Fires after any message is sent from current client. */ FbjsEventName[\"sent\"] = \"sent\";\n /** Used by resource auto-sync. */ FbjsEventName[\"sync\"] = \"sync\";\n /** When a key is removed from the device state tree. */ FbjsEventName[\"remove\"] = \"remove\";\n})($572aa2e43a4df30f$export$9758e930bdf73341 || ($572aa2e43a4df30f$export$9758e930bdf73341 = {}));\nvar $572aa2e43a4df30f$export$4b3033a0406d3b;\n(function(Misc) {\n /** Channel delimiter for MQTT channels. */ Misc[\"MQTT_DELIM\"] = \"/\";\n /** A null value when dealing with empty `pair` nodes in CeleryScript. */ Misc[\"NULL\"] = \"null\";\n /** Reconnect interval for MQTT.js */ Misc[Misc[\"RECONNECT_THROTTLE_MS\"] = 1000] = \"RECONNECT_THROTTLE_MS\";\n})($572aa2e43a4df30f$export$4b3033a0406d3b || ($572aa2e43a4df30f$export$4b3033a0406d3b = {}));\n\n});\n\nparcelRegister(\"aWv1W\", function(module, exports) {\n\n$parcel$export(module.exports, \"timestamp\", () => $7f77641fb0661547$export$fc00ee57782020aa);\n/** Returns a timestamp in ms. */ function $7f77641fb0661547$export$fc00ee57782020aa() {\n return Math.round(new Date().getTime() / 100);\n} // type RejectFn = (reason?: any) => void;\n // type ResolveFn = (value?: T | PromiseLike) => void;\n // interface Executor {\n // (x: (resolve: ResolveFn, reject: RejectFn) => void): Promise;\n // }\n // export function timeoutPromise(time: number, executor: Executor): Promise {\n // return new Promise(executor);\n // }\n\n});\n\n\nparcelRegister(\"3tZ8P\", function(module, exports) {\n\n$parcel$export(module.exports, \"Encoder\", () => $289381f16f78a587$export$a50aceb0e02a00aa);\nvar $289381f16f78a587$export$a50aceb0e02a00aa;\n(function(Encoder) {\n Encoder[Encoder[\"unknown\"] = -1] = \"unknown\";\n Encoder[Encoder[\"quadrature\"] = 0] = \"quadrature\";\n Encoder[Encoder[\"differential\"] = 1] = \"differential\";\n})($289381f16f78a587$export$a50aceb0e02a00aa || ($289381f16f78a587$export$a50aceb0e02a00aa = {}));\n\n});\n\nparcelRegister(\"bFr0L\", function(module, exports) {\n\n$parcel$export(module.exports, \"SpecialStatus\", () => $02312b41c59a57c7$export$d3ccc720d6d43811);\n/** Denotes special status of resource */ var $02312b41c59a57c7$export$d3ccc720d6d43811;\n(function(SpecialStatus) {\n /** The local copy is different than the one on the remote end. */ SpecialStatus[\"DIRTY\"] = \"DIRTY\";\n /** The local copy is being saved on the remote end right now? */ SpecialStatus[\"SAVING\"] = \"SAVING\";\n /** API and FE are in sync. Using \"\" for now because its falsey like old\n * `undefined` value */ SpecialStatus[\"SAVED\"] = \"\";\n})($02312b41c59a57c7$export$d3ccc720d6d43811 || ($02312b41c59a57c7$export$d3ccc720d6d43811 = {}));\n\n});\n\n\n// This is a stub for developers who do not have a module loader or are\n// prototyping one-off scripts in a browser.\n\nwindow.fbjs = (parcelRequire(\"gwFY1\"));\n\n\n//# sourceMappingURL=farmbot_single_file.js.map\n","export * from \"./corpus\";\nexport * from \"./farmbot\";\nexport * from \"./interfaces\";\nexport * from \"./util\";\nexport * from \"./resources/tagged_resource\";\n","\n// THIS INTERFACE WAS AUTO GENERATED ON 2023-07-27\n// DO NOT EDIT THIS FILE.\n// IT WILL BE OVERWRITTEN ON EVERY CELERYSCRIPT UPGRADE.\n\nexport const LATEST_VERSION = 20180209;\nexport const DIGITAL = 0;\nexport const ANALOG = 1;\nexport type CSBoolean = boolean;\nexport type CSFloat = number;\nexport type CSInteger = number;\nexport type CSString = string;\nexport type ALLOWED_ASSERTION_TYPES = \"abort\" |\n \"abort_recover\" |\n \"continue\" |\n \"recover\";\nexport type ALLOWED_AXIS = \"all\" |\n \"x\" |\n \"y\" |\n \"z\";\nexport type ALLOWED_CHANNEL_NAMES = \"email\" |\n \"espeak\" |\n \"ticker\" |\n \"toast\";\nexport type ALLOWED_MESSAGE_TYPES = \"assertion\" |\n \"busy\" |\n \"debug\" |\n \"error\" |\n \"fun\" |\n \"info\" |\n \"success\" |\n \"warn\";\nexport type ALLOWED_OPS = \"<\" |\n \">\" |\n \"is\" |\n \"is_undefined\" |\n \"not\";\nexport type ALLOWED_PACKAGES = \"arduino_firmware\" |\n \"farmbot_os\";\nexport type ALLOWED_PIN_IO_MODES = \"input\" |\n \"input_pullup\" |\n \"output\";\nexport type ALLOWED_PIN_MODES = 0 |\n 1;\nexport type ALLOWED_SPECIAL_VALUE = \"current_location\" |\n \"safe_height\" |\n \"soil_height\";\nexport type AllowedPinTypes = \"BoxLed3\" |\n \"BoxLed4\" |\n \"Peripheral\" |\n \"Sensor\";\nexport type Color = \"blue\" |\n \"gray\" |\n \"green\" |\n \"orange\" |\n \"pink\" |\n \"purple\" |\n \"red\" |\n \"yellow\";\nexport type DataChangeType = \"add\" |\n \"remove\" |\n \"update\";\nexport type LegalArgString = \"_else\" |\n \"_then\" |\n \"assertion_type\" |\n \"axis\" |\n \"axis_operand\" |\n \"channel_name\" |\n \"data_value\" |\n \"default_value\" |\n \"depth\" |\n \"label\" |\n \"lhs\" |\n \"locals\" |\n \"location\" |\n \"lua\" |\n \"message\" |\n \"message_type\" |\n \"milliseconds\" |\n \"number\" |\n \"offset\" |\n \"op\" |\n \"package\" |\n \"pin_id\" |\n \"pin_io_mode\" |\n \"pin_mode\" |\n \"pin_number\" |\n \"pin_type\" |\n \"pin_value\" |\n \"point_group_id\" |\n \"pointer_id\" |\n \"pointer_type\" |\n \"priority\" |\n \"radius\" |\n \"resource\" |\n \"resource_id\" |\n \"resource_type\" |\n \"rhs\" |\n \"sequence_id\" |\n \"speed\" |\n \"speed_setting\" |\n \"string\" |\n \"tool_id\" |\n \"url\" |\n \"value\" |\n \"variance\" |\n \"version\" |\n \"x\" |\n \"y\" |\n \"z\";\nexport type LegalKindString = \"Assertion\" |\n \"AxisAddition\" |\n \"AxisOverwrite\" |\n \"Calibrate\" |\n \"ChangeOwnership\" |\n \"Channel\" |\n \"CheckUpdates\" |\n \"Coordinate\" |\n \"EmergencyLock\" |\n \"EmergencyUnlock\" |\n \"Execute\" |\n \"ExecuteScript\" |\n \"Explanation\" |\n \"FactoryReset\" |\n \"FindHome\" |\n \"FlashFirmware\" |\n \"Home\" |\n \"Identifier\" |\n \"If\" |\n \"InstallFarmware\" |\n \"InstallFirstPartyFarmware\" |\n \"InternalEntryPoint\" |\n \"InternalFarmEvent\" |\n \"InternalRegimen\" |\n \"LocationPlaceholder\" |\n \"Lua\" |\n \"Move\" |\n \"MoveAbsolute\" |\n \"MoveRelative\" |\n \"NamedPin\" |\n \"Nothing\" |\n \"NumberPlaceholder\" |\n \"Numeric\" |\n \"Pair\" |\n \"ParameterApplication\" |\n \"ParameterDeclaration\" |\n \"Point\" |\n \"PointGroup\" |\n \"PowerOff\" |\n \"Random\" |\n \"ReadPin\" |\n \"ReadStatus\" |\n \"Reboot\" |\n \"RemoveFarmware\" |\n \"Resource\" |\n \"ResourcePlaceholder\" |\n \"ResourceUpdate\" |\n \"RpcError\" |\n \"RpcOk\" |\n \"RpcRequest\" |\n \"SafeZ\" |\n \"ScopeDeclaration\" |\n \"SendMessage\" |\n \"Sequence\" |\n \"SetPinIoMode\" |\n \"SetServoAngle\" |\n \"SetUserEnv\" |\n \"SpecialValue\" |\n \"SpeedOverwrite\" |\n \"Sync\" |\n \"TakePhoto\" |\n \"Text\" |\n \"TextPlaceholder\" |\n \"TogglePin\" |\n \"Tool\" |\n \"UpdateFarmware\" |\n \"UpdateResource\" |\n \"VariableDeclaration\" |\n \"Wait\" |\n \"WritePin\" |\n \"Zero\";\nexport type LegalSequenceKind = \"_if\" |\n \"assertion\" |\n \"calibrate\" |\n \"change_ownership\" |\n \"check_updates\" |\n \"emergency_lock\" |\n \"emergency_unlock\" |\n \"execute\" |\n \"execute_script\" |\n \"factory_reset\" |\n \"find_home\" |\n \"flash_firmware\" |\n \"home\" |\n \"install_farmware\" |\n \"install_first_party_farmware\" |\n \"lua\" |\n \"move\" |\n \"move_absolute\" |\n \"move_relative\" |\n \"power_off\" |\n \"read_pin\" |\n \"read_status\" |\n \"reboot\" |\n \"remove_farmware\" |\n \"send_message\" |\n \"set_pin_io_mode\" |\n \"set_servo_angle\" |\n \"set_user_env\" |\n \"sync\" |\n \"take_photo\" |\n \"toggle_pin\" |\n \"update_farmware\" |\n \"update_resource\" |\n \"wait\" |\n \"write_pin\" |\n \"zero\";\nexport type PlantStage = \"active\" |\n \"harvested\" |\n \"pending\" |\n \"planned\" |\n \"planted\" |\n \"removed\" |\n \"sprouted\";\nexport type PointType = \"GenericPointer\" |\n \"Plant\" |\n \"ToolSlot\" |\n \"Weed\";\nexport type lhs = \"pin0\" |\n \"pin1\" |\n \"pin10\" |\n \"pin11\" |\n \"pin12\" |\n \"pin13\" |\n \"pin14\" |\n \"pin15\" |\n \"pin16\" |\n \"pin17\" |\n \"pin18\" |\n \"pin19\" |\n \"pin2\" |\n \"pin20\" |\n \"pin21\" |\n \"pin22\" |\n \"pin23\" |\n \"pin24\" |\n \"pin25\" |\n \"pin26\" |\n \"pin27\" |\n \"pin28\" |\n \"pin29\" |\n \"pin3\" |\n \"pin30\" |\n \"pin31\" |\n \"pin32\" |\n \"pin33\" |\n \"pin34\" |\n \"pin35\" |\n \"pin36\" |\n \"pin37\" |\n \"pin38\" |\n \"pin39\" |\n \"pin4\" |\n \"pin40\" |\n \"pin41\" |\n \"pin42\" |\n \"pin43\" |\n \"pin44\" |\n \"pin45\" |\n \"pin46\" |\n \"pin47\" |\n \"pin48\" |\n \"pin49\" |\n \"pin5\" |\n \"pin50\" |\n \"pin51\" |\n \"pin52\" |\n \"pin53\" |\n \"pin54\" |\n \"pin55\" |\n \"pin56\" |\n \"pin57\" |\n \"pin58\" |\n \"pin59\" |\n \"pin6\" |\n \"pin60\" |\n \"pin61\" |\n \"pin62\" |\n \"pin63\" |\n \"pin64\" |\n \"pin65\" |\n \"pin66\" |\n \"pin67\" |\n \"pin68\" |\n \"pin69\" |\n \"pin7\" |\n \"pin8\" |\n \"pin9\" |\n \"x\" |\n \"y\" |\n \"z\";\nexport type resource_type = \"Device\" |\n \"GenericPointer\" |\n \"Peripheral\" |\n \"Plant\" |\n \"Point\" |\n \"Sensor\" |\n \"Sequence\" |\n \"ToolSlot\" |\n \"Weed\";\nexport type AssertionBodyItem = never;\n/** assertion\n\n Tag properties: *. */\nexport interface Assertion {\n comment?: string | undefined;\n kind: \"assertion\";\n args: {\n _then: Execute |\n Nothing;\n assertion_type: ALLOWED_ASSERTION_TYPES;\n lua: CSString;\n }\n body?: AssertionBodyItem[] | undefined;\n}\n\nexport type IfBodyItem = (Pair);\n/** _if\n\n Tag properties: *. */\nexport interface If {\n comment?: string | undefined;\n kind: \"_if\";\n args: {\n _else: Execute |\n Nothing;\n _then: Execute |\n Nothing;\n lhs: CSString |\n NamedPin;\n op: ALLOWED_OPS;\n rhs: CSInteger;\n }\n body?: IfBodyItem[] | undefined;\n}\n\nexport type CalibrateBodyItem = never;\n/** calibrate\n\n Tag properties: firmware_user, function. */\nexport interface Calibrate {\n comment?: string | undefined;\n kind: \"calibrate\";\n args: {\n axis: ALLOWED_AXIS;\n }\n body?: CalibrateBodyItem[] | undefined;\n}\n\nexport type ChangeOwnershipBodyItem = (Pair);\n/** change_ownership\nNot a commonly used node. May be removed without notice.\n Tag properties: api_writer, cuts_power, disk_user, function, network_user. */\nexport interface ChangeOwnership {\n comment?: string | undefined;\n kind: \"change_ownership\";\n args: {\n }\n body?: ChangeOwnershipBodyItem[] | undefined;\n}\n\nexport type ChannelBodyItem = never;\n/** channel\nSpecifies a communication path for log messages.\n Tag properties: data. */\nexport interface Channel {\n comment?: string | undefined;\n kind: \"channel\";\n args: {\n channel_name: ALLOWED_CHANNEL_NAMES;\n }\n body?: ChannelBodyItem[] | undefined;\n}\n\nexport type CheckUpdatesBodyItem = never;\n/** check_updates\n\n Tag properties: cuts_power, disk_user, function, network_user. */\nexport interface CheckUpdates {\n comment?: string | undefined;\n kind: \"check_updates\";\n args: {\n package: CSString;\n }\n body?: CheckUpdatesBodyItem[] | undefined;\n}\n\nexport type CoordinateBodyItem = never;\n/** coordinate\n\n Tag properties: data, location_like. */\nexport interface Coordinate {\n comment?: string | undefined;\n kind: \"coordinate\";\n args: {\n x: CSInteger |\n CSFloat;\n y: CSInteger |\n CSFloat;\n z: CSInteger |\n CSFloat;\n }\n body?: CoordinateBodyItem[] | undefined;\n}\n\nexport type EmergencyLockBodyItem = never;\n/** emergency_lock\n\n Tag properties: control_flow, firmware_user, function. */\nexport interface EmergencyLock {\n comment?: string | undefined;\n kind: \"emergency_lock\";\n args: {\n }\n body?: EmergencyLockBodyItem[] | undefined;\n}\n\nexport type EmergencyUnlockBodyItem = never;\n/** emergency_unlock\n\n Tag properties: firmware_user, function. */\nexport interface EmergencyUnlock {\n comment?: string | undefined;\n kind: \"emergency_unlock\";\n args: {\n }\n body?: EmergencyUnlockBodyItem[] | undefined;\n}\n\nexport type ExecuteScriptBodyItem = (Pair);\n/** execute_script\n\n Tag properties: *. */\nexport interface ExecuteScript {\n comment?: string | undefined;\n kind: \"execute_script\";\n args: {\n label: CSString;\n }\n body?: ExecuteScriptBodyItem[] | undefined;\n}\n\nexport type ExecuteBodyItem = (ParameterApplication);\n/** execute\n\n Tag properties: *. */\nexport interface Execute {\n comment?: string | undefined;\n kind: \"execute\";\n args: {\n sequence_id: CSInteger;\n }\n body?: ExecuteBodyItem[] | undefined;\n}\n\nexport type ExplanationBodyItem = never;\n/** explanation\n\n Tag properties: data. */\nexport interface Explanation {\n comment?: string | undefined;\n kind: \"explanation\";\n args: {\n message: CSString;\n }\n body?: ExplanationBodyItem[] | undefined;\n}\n\nexport type FactoryResetBodyItem = never;\n/** factory_reset\n\n Tag properties: cuts_power, function. */\nexport interface FactoryReset {\n comment?: string | undefined;\n kind: \"factory_reset\";\n args: {\n package: CSString;\n }\n body?: FactoryResetBodyItem[] | undefined;\n}\n\nexport type FindHomeBodyItem = never;\n/** find_home\n\n Tag properties: firmware_user, function. */\nexport interface FindHome {\n comment?: string | undefined;\n kind: \"find_home\";\n args: {\n axis: ALLOWED_AXIS;\n speed: CSInteger;\n }\n body?: FindHomeBodyItem[] | undefined;\n}\n\nexport type FlashFirmwareBodyItem = never;\n/** flash_firmware\n\n Tag properties: api_writer, disk_user, firmware_user, function, network_user. */\nexport interface FlashFirmware {\n comment?: string | undefined;\n kind: \"flash_firmware\";\n args: {\n package: CSString;\n }\n body?: FlashFirmwareBodyItem[] | undefined;\n}\n\nexport type HomeBodyItem = never;\n/** home\n\n Tag properties: firmware_user, function. */\nexport interface Home {\n comment?: string | undefined;\n kind: \"home\";\n args: {\n axis: ALLOWED_AXIS;\n speed: CSInteger;\n }\n body?: HomeBodyItem[] | undefined;\n}\n\nexport type IdentifierBodyItem = never;\n/** identifier\n\n Tag properties: data. */\nexport interface Identifier {\n comment?: string | undefined;\n kind: \"identifier\";\n args: {\n label: CSString;\n }\n body?: IdentifierBodyItem[] | undefined;\n}\n\nexport type InstallFarmwareBodyItem = never;\n/** install_farmware\n\n Tag properties: api_writer, disk_user, function, network_user. */\nexport interface InstallFarmware {\n comment?: string | undefined;\n kind: \"install_farmware\";\n args: {\n url: CSString;\n }\n body?: InstallFarmwareBodyItem[] | undefined;\n}\n\nexport type InstallFirstPartyFarmwareBodyItem = never;\n/** install_first_party_farmware\n\n Tag properties: function, network_user. */\nexport interface InstallFirstPartyFarmware {\n comment?: string | undefined;\n kind: \"install_first_party_farmware\";\n args: {\n }\n body?: InstallFirstPartyFarmwareBodyItem[] | undefined;\n}\n\nexport type InternalFarmEventBodyItem = (ParameterApplication);\n/** internal_farm_event\n\n Tag properties: . */\nexport interface InternalFarmEvent {\n comment?: string | undefined;\n kind: \"internal_farm_event\";\n args: {\n }\n body?: InternalFarmEventBodyItem[] | undefined;\n}\n\nexport type InternalRegimenBodyItem = (ParameterApplication |\n ParameterDeclaration |\n VariableDeclaration);\n/** internal_regimen\n\n Tag properties: . */\nexport interface InternalRegimen {\n comment?: string | undefined;\n kind: \"internal_regimen\";\n args: {\n }\n body?: InternalRegimenBodyItem[] | undefined;\n}\n\nexport type MoveRelativeBodyItem = never;\n/** move_relative\n\n Tag properties: firmware_user, function. */\nexport interface MoveRelative {\n comment?: string | undefined;\n kind: \"move_relative\";\n args: {\n speed: CSInteger;\n x: CSInteger |\n CSFloat;\n y: CSInteger |\n CSFloat;\n z: CSInteger |\n CSFloat;\n }\n body?: MoveRelativeBodyItem[] | undefined;\n}\n\nexport type NothingBodyItem = never;\n/** nothing\n\n Tag properties: data, function. */\nexport interface Nothing {\n comment?: string | undefined;\n kind: \"nothing\";\n args: {\n }\n body?: NothingBodyItem[] | undefined;\n}\n\nexport type PairBodyItem = never;\n/** pair\n\n Tag properties: data. */\nexport interface Pair {\n comment?: string | undefined;\n kind: \"pair\";\n args: {\n label: CSString;\n value: CSString |\n CSInteger |\n CSBoolean;\n }\n body?: PairBodyItem[] | undefined;\n}\n\nexport type ParameterApplicationBodyItem = never;\n/** parameter_application\n\n Tag properties: control_flow, function, scope_writer. */\nexport interface ParameterApplication {\n comment?: string | undefined;\n kind: \"parameter_application\";\n args: {\n data_value: Coordinate |\n Identifier |\n LocationPlaceholder |\n NumberPlaceholder |\n Numeric |\n Point |\n Resource |\n ResourcePlaceholder |\n Text |\n TextPlaceholder |\n Tool |\n PointGroup;\n label: CSString;\n }\n body?: ParameterApplicationBodyItem[] | undefined;\n}\n\nexport type ParameterDeclarationBodyItem = never;\n/** parameter_declaration\n\n Tag properties: scope_writer. */\nexport interface ParameterDeclaration {\n comment?: string | undefined;\n kind: \"parameter_declaration\";\n args: {\n default_value: Coordinate |\n Identifier |\n LocationPlaceholder |\n NumberPlaceholder |\n Numeric |\n Point |\n Resource |\n ResourcePlaceholder |\n Text |\n TextPlaceholder |\n Tool;\n label: CSString;\n }\n body?: ParameterDeclarationBodyItem[] | undefined;\n}\n\nexport type PointBodyItem = never;\n/** point\n\n Tag properties: data, location_like. */\nexport interface Point {\n comment?: string | undefined;\n kind: \"point\";\n args: {\n pointer_id: CSInteger;\n pointer_type: PointType;\n }\n body?: PointBodyItem[] | undefined;\n}\n\nexport type PowerOffBodyItem = never;\n/** power_off\n\n Tag properties: cuts_power, function. */\nexport interface PowerOff {\n comment?: string | undefined;\n kind: \"power_off\";\n args: {\n }\n body?: PowerOffBodyItem[] | undefined;\n}\n\nexport type ReadStatusBodyItem = never;\n/** read_status\n\n Tag properties: function. */\nexport interface ReadStatus {\n comment?: string | undefined;\n kind: \"read_status\";\n args: {\n }\n body?: ReadStatusBodyItem[] | undefined;\n}\n\nexport type RebootBodyItem = never;\n/** reboot\n\n Tag properties: cuts_power, firmware_user, function. */\nexport interface Reboot {\n comment?: string | undefined;\n kind: \"reboot\";\n args: {\n package: CSString;\n }\n body?: RebootBodyItem[] | undefined;\n}\n\nexport type RemoveFarmwareBodyItem = never;\n/** remove_farmware\n\n Tag properties: function. */\nexport interface RemoveFarmware {\n comment?: string | undefined;\n kind: \"remove_farmware\";\n args: {\n package: CSString;\n }\n body?: RemoveFarmwareBodyItem[] | undefined;\n}\n\nexport type RpcErrorBodyItem = (Explanation);\n/** rpc_error\n\n Tag properties: data. */\nexport interface RpcError {\n comment?: string | undefined;\n kind: \"rpc_error\";\n args: {\n label: CSString;\n }\n body?: RpcErrorBodyItem[] | undefined;\n}\n\nexport type RpcOkBodyItem = never;\n/** rpc_ok\n\n Tag properties: data. */\nexport interface RpcOk {\n comment?: string | undefined;\n kind: \"rpc_ok\";\n args: {\n label: CSString;\n }\n body?: RpcOkBodyItem[] | undefined;\n}\n\nexport type RpcRequestBodyItem = (If |\n Assertion |\n Calibrate |\n ChangeOwnership |\n CheckUpdates |\n EmergencyLock |\n EmergencyUnlock |\n Execute |\n ExecuteScript |\n FactoryReset |\n FindHome |\n FlashFirmware |\n Home |\n InstallFarmware |\n InstallFirstPartyFarmware |\n Lua |\n Move |\n MoveAbsolute |\n MoveRelative |\n PowerOff |\n ReadPin |\n ReadStatus |\n Reboot |\n RemoveFarmware |\n SendMessage |\n SetPinIoMode |\n SetServoAngle |\n SetUserEnv |\n Sync |\n TakePhoto |\n TogglePin |\n UpdateFarmware |\n UpdateResource |\n Wait |\n WritePin |\n Zero);\n/** rpc_request\n\n Tag properties: *. */\nexport interface RpcRequest {\n comment?: string | undefined;\n kind: \"rpc_request\";\n args: {\n label: CSString;\n priority: CSInteger;\n }\n body?: RpcRequestBodyItem[] | undefined;\n}\n\nexport type ScopeDeclarationBodyItem = (ParameterDeclaration |\n VariableDeclaration);\n/** scope_declaration\n\n Tag properties: scope_writer. */\nexport interface ScopeDeclaration {\n comment?: string | undefined;\n kind: \"scope_declaration\";\n args: {\n }\n body?: ScopeDeclarationBodyItem[] | undefined;\n}\n\nexport type SendMessageBodyItem = (Channel);\n/** send_message\n\n Tag properties: function. */\nexport interface SendMessage {\n comment?: string | undefined;\n kind: \"send_message\";\n args: {\n message: CSString;\n message_type: ALLOWED_MESSAGE_TYPES;\n }\n body?: SendMessageBodyItem[] | undefined;\n}\n\nexport type SequenceBodyItem = (If |\n Assertion |\n Calibrate |\n ChangeOwnership |\n CheckUpdates |\n EmergencyLock |\n EmergencyUnlock |\n Execute |\n ExecuteScript |\n FactoryReset |\n FindHome |\n FlashFirmware |\n Home |\n InstallFarmware |\n InstallFirstPartyFarmware |\n Lua |\n Move |\n MoveAbsolute |\n MoveRelative |\n PowerOff |\n ReadPin |\n ReadStatus |\n Reboot |\n RemoveFarmware |\n SendMessage |\n SetPinIoMode |\n SetServoAngle |\n SetUserEnv |\n Sync |\n TakePhoto |\n TogglePin |\n UpdateFarmware |\n UpdateResource |\n Wait |\n WritePin |\n Zero);\n/** sequence\n\n Tag properties: *. */\nexport interface Sequence {\n comment?: string | undefined;\n kind: \"sequence\";\n args: {\n locals: ScopeDeclaration;\n version: CSInteger;\n }\n body?: SequenceBodyItem[] | undefined;\n}\n\nexport type SetServoAngleBodyItem = never;\n/** set_servo_angle\n\n Tag properties: firmware_user, function. */\nexport interface SetServoAngle {\n comment?: string | undefined;\n kind: \"set_servo_angle\";\n args: {\n pin_number: CSInteger |\n NamedPin;\n pin_value: CSInteger;\n }\n body?: SetServoAngleBodyItem[] | undefined;\n}\n\nexport type SetPinIoModeBodyItem = never;\n/** set_pin_io_mode\n\n Tag properties: firmware_user, function. */\nexport interface SetPinIoMode {\n comment?: string | undefined;\n kind: \"set_pin_io_mode\";\n args: {\n pin_io_mode: ALLOWED_PIN_IO_MODES;\n pin_number: CSInteger |\n NamedPin;\n }\n body?: SetPinIoModeBodyItem[] | undefined;\n}\n\nexport type SetUserEnvBodyItem = (Pair);\n/** set_user_env\n\n Tag properties: disk_user, function. */\nexport interface SetUserEnv {\n comment?: string | undefined;\n kind: \"set_user_env\";\n args: {\n }\n body?: SetUserEnvBodyItem[] | undefined;\n}\n\nexport type SyncBodyItem = never;\n/** sync\n\n Tag properties: disk_user, function, network_user. */\nexport interface Sync {\n comment?: string | undefined;\n kind: \"sync\";\n args: {\n }\n body?: SyncBodyItem[] | undefined;\n}\n\nexport type TakePhotoBodyItem = never;\n/** take_photo\n\n Tag properties: disk_user, function. */\nexport interface TakePhoto {\n comment?: string | undefined;\n kind: \"take_photo\";\n args: {\n }\n body?: TakePhotoBodyItem[] | undefined;\n}\n\nexport type TextBodyItem = never;\n/** text\n\n Tag properties: . */\nexport interface Text {\n comment?: string | undefined;\n kind: \"text\";\n args: {\n string: CSString;\n }\n body?: TextBodyItem[] | undefined;\n}\n\nexport type TogglePinBodyItem = never;\n/** toggle_pin\n\n Tag properties: firmware_user, function. */\nexport interface TogglePin {\n comment?: string | undefined;\n kind: \"toggle_pin\";\n args: {\n pin_number: CSInteger |\n NamedPin;\n }\n body?: TogglePinBodyItem[] | undefined;\n}\n\nexport type ToolBodyItem = never;\n/** tool\n\n Tag properties: api_validated, data, location_like. */\nexport interface Tool {\n comment?: string | undefined;\n kind: \"tool\";\n args: {\n tool_id: CSInteger;\n }\n body?: ToolBodyItem[] | undefined;\n}\n\nexport type UpdateFarmwareBodyItem = never;\n/** update_farmware\n\n Tag properties: api_validated, function, network_user. */\nexport interface UpdateFarmware {\n comment?: string | undefined;\n kind: \"update_farmware\";\n args: {\n package: CSString;\n }\n body?: UpdateFarmwareBodyItem[] | undefined;\n}\n\nexport type VariableDeclarationBodyItem = never;\n/** variable_declaration\n\n Tag properties: function, scope_writer. */\nexport interface VariableDeclaration {\n comment?: string | undefined;\n kind: \"variable_declaration\";\n args: {\n data_value: Coordinate |\n Identifier |\n LocationPlaceholder |\n NumberPlaceholder |\n Numeric |\n Point |\n Resource |\n ResourcePlaceholder |\n Text |\n TextPlaceholder |\n Tool |\n PointGroup;\n label: CSString;\n }\n body?: VariableDeclarationBodyItem[] | undefined;\n}\n\nexport type WaitBodyItem = never;\n/** wait\n\n Tag properties: function. */\nexport interface Wait {\n comment?: string | undefined;\n kind: \"wait\";\n args: {\n milliseconds: CSInteger;\n }\n body?: WaitBodyItem[] | undefined;\n}\n\nexport type ZeroBodyItem = never;\n/** zero\n\n Tag properties: firmware_user, function. */\nexport interface Zero {\n comment?: string | undefined;\n kind: \"zero\";\n args: {\n axis: ALLOWED_AXIS;\n }\n body?: ZeroBodyItem[] | undefined;\n}\n\nexport type NamedPinBodyItem = never;\n/** named_pin\n\n Tag properties: api_validated, data, firmware_user, function, rpi_user. */\nexport interface NamedPin {\n comment?: string | undefined;\n kind: \"named_pin\";\n args: {\n pin_id: CSInteger;\n pin_type: AllowedPinTypes;\n }\n body?: NamedPinBodyItem[] | undefined;\n}\n\nexport type MoveAbsoluteBodyItem = never;\n/** move_absolute\n\n Tag properties: firmware_user, function. */\nexport interface MoveAbsolute {\n comment?: string | undefined;\n kind: \"move_absolute\";\n args: {\n location: Tool |\n Coordinate |\n Point |\n Identifier;\n offset: Coordinate;\n speed: CSInteger;\n }\n body?: MoveAbsoluteBodyItem[] | undefined;\n}\n\nexport type WritePinBodyItem = never;\n/** write_pin\n\n Tag properties: firmware_user, function, rpi_user. */\nexport interface WritePin {\n comment?: string | undefined;\n kind: \"write_pin\";\n args: {\n pin_mode: ALLOWED_PIN_MODES;\n pin_number: CSInteger |\n NamedPin;\n pin_value: CSInteger;\n }\n body?: WritePinBodyItem[] | undefined;\n}\n\nexport type ReadPinBodyItem = never;\n/** read_pin\n\n Tag properties: firmware_user, function, rpi_user. */\nexport interface ReadPin {\n comment?: string | undefined;\n kind: \"read_pin\";\n args: {\n label: CSString;\n pin_mode: ALLOWED_PIN_MODES;\n pin_number: CSInteger |\n NamedPin;\n }\n body?: ReadPinBodyItem[] | undefined;\n}\n\nexport type ResourceUpdateBodyItem = never;\n/** resource_update\n\n Tag properties: api_writer, function, network_user. */\nexport interface ResourceUpdate {\n comment?: string | undefined;\n kind: \"resource_update\";\n args: {\n label: CSString;\n resource_id: CSInteger;\n resource_type: resource_type;\n value: CSString |\n CSInteger |\n CSBoolean;\n }\n body?: ResourceUpdateBodyItem[] | undefined;\n}\n\nexport type ResourceBodyItem = never;\n/** resource\n\n Tag properties: network_user. */\nexport interface Resource {\n comment?: string | undefined;\n kind: \"resource\";\n args: {\n resource_id: CSInteger;\n resource_type: resource_type;\n }\n body?: ResourceBodyItem[] | undefined;\n}\n\nexport type ResourcePlaceholderBodyItem = never;\n/** resource_placeholder\n\n Tag properties: . */\nexport interface ResourcePlaceholder {\n comment?: string | undefined;\n kind: \"resource_placeholder\";\n args: {\n resource_type: resource_type;\n }\n body?: ResourcePlaceholderBodyItem[] | undefined;\n}\n\nexport type NumberPlaceholderBodyItem = never;\n/** number_placeholder\n\n Tag properties: . */\nexport interface NumberPlaceholder {\n comment?: string | undefined;\n kind: \"number_placeholder\";\n args: {\n }\n body?: NumberPlaceholderBodyItem[] | undefined;\n}\n\nexport type TextPlaceholderBodyItem = never;\n/** text_placeholder\n\n Tag properties: . */\nexport interface TextPlaceholder {\n comment?: string | undefined;\n kind: \"text_placeholder\";\n args: {\n }\n body?: TextPlaceholderBodyItem[] | undefined;\n}\n\nexport type LocationPlaceholderBodyItem = never;\n/** location_placeholder\n\n Tag properties: . */\nexport interface LocationPlaceholder {\n comment?: string | undefined;\n kind: \"location_placeholder\";\n args: {\n }\n body?: LocationPlaceholderBodyItem[] | undefined;\n}\n\nexport type UpdateResourceBodyItem = (Pair);\n/** update_resource\n\n Tag properties: api_writer, function, network_user. */\nexport interface UpdateResource {\n comment?: string | undefined;\n kind: \"update_resource\";\n args: {\n resource: Identifier |\n Resource |\n Point;\n }\n body?: UpdateResourceBodyItem[] | undefined;\n}\n\nexport type PointGroupBodyItem = never;\n/** point_group\n\n Tag properties: data, list_like. */\nexport interface PointGroup {\n comment?: string | undefined;\n kind: \"point_group\";\n args: {\n point_group_id: CSInteger;\n }\n body?: PointGroupBodyItem[] | undefined;\n}\n\nexport type NumericBodyItem = never;\n/** numeric\n\n Tag properties: data. */\nexport interface Numeric {\n comment?: string | undefined;\n kind: \"numeric\";\n args: {\n number: CSInteger;\n }\n body?: NumericBodyItem[] | undefined;\n}\n\nexport type LuaBodyItem = (Pair);\n/** lua\n\n Tag properties: *. */\nexport interface Lua {\n comment?: string | undefined;\n kind: \"lua\";\n args: {\n lua: CSString;\n }\n body?: LuaBodyItem[] | undefined;\n}\n\nexport type SpecialValueBodyItem = never;\n/** special_value\n\n Tag properties: data. */\nexport interface SpecialValue {\n comment?: string | undefined;\n kind: \"special_value\";\n args: {\n label: CSString;\n }\n body?: SpecialValueBodyItem[] | undefined;\n}\n\nexport type AxisOverwriteBodyItem = never;\n/** axis_overwrite\n\n Tag properties: data. */\nexport interface AxisOverwrite {\n comment?: string | undefined;\n kind: \"axis_overwrite\";\n args: {\n axis: ALLOWED_AXIS;\n axis_operand: Coordinate |\n Identifier |\n Lua |\n Numeric |\n Point |\n Random |\n SpecialValue |\n Tool;\n }\n body?: AxisOverwriteBodyItem[] | undefined;\n}\n\nexport type AxisAdditionBodyItem = never;\n/** axis_addition\n\n Tag properties: data. */\nexport interface AxisAddition {\n comment?: string | undefined;\n kind: \"axis_addition\";\n args: {\n axis: ALLOWED_AXIS;\n axis_operand: Coordinate |\n Identifier |\n Lua |\n Numeric |\n Point |\n Random |\n SpecialValue |\n Tool;\n }\n body?: AxisAdditionBodyItem[] | undefined;\n}\n\nexport type SpeedOverwriteBodyItem = never;\n/** speed_overwrite\n\n Tag properties: data. */\nexport interface SpeedOverwrite {\n comment?: string | undefined;\n kind: \"speed_overwrite\";\n args: {\n axis: ALLOWED_AXIS;\n speed_setting: Lua |\n Numeric;\n }\n body?: SpeedOverwriteBodyItem[] | undefined;\n}\n\nexport type SafeZBodyItem = never;\n/** safe_z\n\n Tag properties: data. */\nexport interface SafeZ {\n comment?: string | undefined;\n kind: \"safe_z\";\n args: {\n }\n body?: SafeZBodyItem[] | undefined;\n}\n\nexport type RandomBodyItem = never;\n/** random\n\n Tag properties: data. */\nexport interface Random {\n comment?: string | undefined;\n kind: \"random\";\n args: {\n variance: CSInteger;\n }\n body?: RandomBodyItem[] | undefined;\n}\n\nexport type MoveBodyItem = (AxisAddition |\n AxisOverwrite |\n SafeZ |\n SpeedOverwrite);\n/** move\n\n Tag properties: firmware_user, function. */\nexport interface Move {\n comment?: string | undefined;\n kind: \"move\";\n args: {\n }\n body?: MoveBodyItem[] | undefined;\n}\nexport type CeleryNode = Assertion |\n AxisAddition |\n AxisOverwrite |\n Calibrate |\n ChangeOwnership |\n Channel |\n CheckUpdates |\n Coordinate |\n EmergencyLock |\n EmergencyUnlock |\n Execute |\n ExecuteScript |\n Explanation |\n FactoryReset |\n FindHome |\n FlashFirmware |\n Home |\n Identifier |\n If |\n InstallFarmware |\n InstallFirstPartyFarmware |\n InternalFarmEvent |\n InternalRegimen |\n LocationPlaceholder |\n Lua |\n Move |\n MoveAbsolute |\n MoveRelative |\n NamedPin |\n Nothing |\n NumberPlaceholder |\n Numeric |\n Pair |\n ParameterApplication |\n ParameterDeclaration |\n Point |\n PointGroup |\n PowerOff |\n Random |\n ReadPin |\n ReadStatus |\n Reboot |\n RemoveFarmware |\n Resource |\n ResourcePlaceholder |\n ResourceUpdate |\n RpcError |\n RpcOk |\n RpcRequest |\n SafeZ |\n ScopeDeclaration |\n SendMessage |\n Sequence |\n SetPinIoMode |\n SetServoAngle |\n SetUserEnv |\n SpecialValue |\n SpeedOverwrite |\n Sync |\n TakePhoto |\n Text |\n TextPlaceholder |\n TogglePin |\n Tool |\n UpdateFarmware |\n UpdateResource |\n VariableDeclaration |\n Wait |\n WritePin |\n Zero;\n","import * as Corpus from \"./corpus\";\nimport {\n connect,\n MqttClient\n} from \"mqtt\";\nimport {\n rpcRequest,\n coordinate,\n uuid as genUuid\n} from \"./util\";\nimport { Dictionary, Vector3 } from \"./interfaces\";\nimport { ReadPin, WritePin, bufferToString } from \".\";\nimport {\n FarmBotInternalConfig as Conf,\n FarmbotConstructorParams,\n generateConfig,\n CONFIG_DEFAULTS\n} from \"./config\";\nimport { ResourceAdapter } from \"./resources/resource_adapter\";\nimport { MqttChanName, FbjsEventName, Misc } from \"./constants\";\nimport { hasLabel } from \"./util/is_celery_script\";\nimport { timestamp } from \"./util/time\";\nimport { Priority } from \"./util/rpc_request\";\n\ntype RpcResponse = Promise;\n\n/*\n * Clarification for several terms used:\n * * Farmware: Plug-ins for FarmBot OS. Sometimes referred to as `scripts`.\n * * Microcontroller: Directly controls and interfaces with motors,\n * peripherals, sensors, etc. May be on an Arduino or Farmduino board.\n * Mostly referred to as `arduino`, but also `mcu`.\n */\n\n/** Meta data that wraps an event callback */\ninterface CallbackWrapper {\n once: boolean;\n event: string;\n value: Function;\n}\n\nexport class Farmbot {\n /** Storage area for all event handlers */\n private _events: Dictionary;\n private config: Conf;\n public client?: MqttClient;\n public resources: ResourceAdapter;\n static VERSION = \"15.8.3\";\n\n constructor(input: FarmbotConstructorParams) {\n this._events = {};\n this.config = generateConfig(input);\n this.resources = new ResourceAdapter(this, this.config.mqttUsername);\n }\n\n /** Get a Farmbot Constructor Parameter. */\n getConfig = (key: U): Conf[U] => this.config[key];\n\n /** Set a Farmbot Constructor Parameter. */\n setConfig = (key: U, value: Conf[U]) => {\n this.config[key] = value;\n }\n\n /**\n * Installs a \"Farmware\" (plugin) onto the bot's SD card.\n * URL must point to a valid Farmware manifest JSON document.\n */\n installFarmware = (url: string) => {\n return this.send(rpcRequest([{ kind: \"install_farmware\", args: { url } }]));\n }\n\n /**\n * Checks for updates on a particular Farmware plugin when given the name of\n * a Farmware. `updateFarmware(\"take-photo\")`\n */\n updateFarmware = (pkg: string) => {\n return this.send(rpcRequest([{\n kind: \"update_farmware\",\n args: { package: pkg }\n }]));\n }\n\n /** Uninstall a Farmware plugin. */\n removeFarmware = (pkg: string) => {\n return this.send(rpcRequest([{\n kind: \"remove_farmware\",\n args: {\n package: pkg\n }\n }]));\n }\n\n /**\n * Installs \"Farmware\" (plugins) authored by FarmBot, Inc.\n * onto the bot's SD card.\n */\n installFirstPartyFarmware = () => {\n return this.send(rpcRequest([{\n kind: \"install_first_party_farmware\",\n args: {}\n }]));\n }\n\n /**\n * Deactivate FarmBot OS completely (shutdown).\n * Useful before unplugging the power.\n */\n powerOff = () => {\n return this.send(rpcRequest([{ kind: \"power_off\", args: {} }]));\n }\n\n /** Restart FarmBot OS. */\n reboot = () => {\n return this.send(rpcRequest([\n { kind: \"reboot\", args: { package: \"farmbot_os\" } }\n ]));\n }\n\n /** Reinitialize the FarmBot microcontroller firmware. */\n rebootFirmware = () => {\n return this.send(rpcRequest([\n { kind: \"reboot\", args: { package: \"arduino_firmware\" } }\n ]));\n }\n\n /** Check for new versions of FarmBot OS.\n * Downloads and installs if available. */\n checkUpdates = () => {\n return this.send(rpcRequest([\n { kind: \"check_updates\", args: { package: \"farmbot_os\" } }\n ]));\n }\n\n /** THIS WILL RESET THE SD CARD, deleting all non-factory data!\n * Be careful!! */\n resetOS = (): void => {\n return this.publish(rpcRequest([\n { kind: \"factory_reset\", args: { package: \"farmbot_os\" } }\n ]));\n }\n\n /** WARNING: will reset all firmware (hardware) settings! */\n resetMCU = () => {\n return this.send(rpcRequest([\n { kind: \"factory_reset\", args: { package: \"arduino_firmware\" } }\n ]));\n }\n\n flashFirmware = (\n /** one of: \"arduino\"|\"express_k10\"|\"farmduino_k14\"|\"farmduino\" */\n firmware_name: string) => {\n return this.send(rpcRequest([{\n kind: \"flash_firmware\",\n args: {\n package: firmware_name\n }\n }]));\n }\n\n /**\n * Lock the bot from moving (E-STOP). Turns off peripherals and motors. This\n * also will pause running regimens and cause any running sequences to exit.\n */\n emergencyLock = () => {\n const body: Corpus.RpcRequestBodyItem[] =\n [{ kind: \"emergency_lock\", args: {} }];\n const rpc = rpcRequest(body, Priority.HIGHEST);\n\n return this.send(rpc);\n }\n\n /** Unlock the bot when the user says it is safe. */\n emergencyUnlock = () => {\n const body: Corpus.RpcRequestBodyItem[] =\n [{ kind: \"emergency_unlock\", args: {} }];\n const rpc = rpcRequest(body, Priority.HIGHEST);\n\n return this.send(rpc);\n }\n /** Execute a sequence by its ID on the FarmBot API. */\n execSequence =\n (sequence_id: number, body: Corpus.ParameterApplication[] = []) => {\n return this.send(rpcRequest([\n { kind: \"execute\", args: { sequence_id }, body }\n ]));\n }\n\n /** Run an installed Farmware plugin on the SD Card. */\n execScript = (\n /** Name of the Farmware. */\n label: string,\n /** Optional ENV vars to pass the Farmware. */\n envVars?: Corpus.Pair[] | undefined) => {\n return this.send(rpcRequest([\n { kind: \"execute_script\", args: { label }, body: envVars }\n ]));\n }\n\n /** Bring a particular axis (or all of them) to position 0 in Z Y X order. */\n home = (args: { speed: number, axis: Corpus.ALLOWED_AXIS }) => {\n return this.send(rpcRequest([{ kind: \"home\", args }]));\n }\n\n /** Use end stops or encoders to figure out where 0,0,0 is in Z Y X axis\n * order. WON'T WORK WITHOUT ENCODERS OR END STOPS! A blockage or stall\n * during this command will set that position as zero. Use carefully. */\n findHome = (args: { speed: number, axis: Corpus.ALLOWED_AXIS }) => {\n return this.send(rpcRequest([{ kind: \"find_home\", args }]));\n }\n\n /** Move FarmBot to an absolute point. */\n moveAbsolute = (args: Vector3 & { speed?: number }) => {\n const { x, y, z } = args;\n const speed = args.speed || CONFIG_DEFAULTS.speed;\n return this.send(rpcRequest([\n {\n kind: \"move_absolute\",\n args: {\n location: coordinate(x, y, z),\n offset: coordinate(0, 0, 0),\n speed\n }\n }\n ]));\n }\n\n /** Move FarmBot to position relative to its current position. */\n moveRelative = (args: Vector3 & { speed?: number }) => {\n const { x, y, z } = args;\n const speed = args.speed || CONFIG_DEFAULTS.speed;\n return this.send(rpcRequest([\n { kind: \"move_relative\", args: { x, y, z, speed } }\n ]));\n }\n\n /** Set a GPIO pin to a particular value. */\n writePin = (args: WritePin[\"args\"]) => {\n return this.send(rpcRequest([{ kind: \"write_pin\", args }]));\n }\n\n /** Read the value of a GPIO pin. Will create a SensorReading if it's\n * a sensor. */\n readPin = (args: ReadPin[\"args\"]) => {\n return this.send(rpcRequest([{ kind: \"read_pin\", args }]));\n }\n\n /** Reverse the value of a digital pin. */\n togglePin = (args: { pin_number: number; }) => {\n return this.send(rpcRequest([{ kind: \"toggle_pin\", args }]));\n }\n\n /** Read the status of the bot. Should not be needed unless you are first\n * logging in to the device, since the device pushes new states out on\n * every update. */\n readStatus = (args = {}) => {\n return this.send(rpcRequest([{ kind: \"read_status\", args }]));\n }\n\n /** Snap a photo and send to the API for post processing. */\n takePhoto =\n (args = {}) => this.send(rpcRequest([{ kind: \"take_photo\", args }]))\n\n /** Download/apply all of the latest FarmBot API JSON resources (plants,\n * account info, etc.) to the device. */\n sync = (args = {}) => this.send(rpcRequest([{ kind: \"sync\", args }]));\n\n /**\n * Set the current position of the given axis to 0.\n * Example: Sending `bot.setZero(\"x\")` at x: 255 will translate position\n * 255 to 0, causing that position to be x: 0.\n */\n setZero = (axis: Corpus.ALLOWED_AXIS) => {\n return this.send(rpcRequest([{\n kind: \"zero\",\n args: { axis }\n }]));\n }\n\n /**\n * Set user ENV vars (usually used by 3rd-party Farmware plugins).\n * Set value to `undefined` to unset.\n */\n setUserEnv = (configs: Dictionary<(string | undefined)>) => {\n const body = Object\n .keys(configs)\n .map(function (label): Corpus.Pair {\n return {\n kind: \"pair\",\n args: { label, value: (configs[label] || Misc.NULL) }\n };\n });\n return this.send(rpcRequest([{ kind: \"set_user_env\", args: {}, body }]));\n }\n\n sendMessage = (message_type: Corpus.ALLOWED_MESSAGE_TYPES,\n message: string,\n channels: Corpus.ALLOWED_CHANNEL_NAMES[] = []) => {\n this.send(rpcRequest([{\n kind: \"send_message\",\n args: {\n message_type,\n message\n },\n body: channels.map(channel_name => ({\n kind: \"channel\",\n args: {\n channel_name\n }\n }))\n }]));\n }\n\n /** Control servos on pins 4 and 5. */\n setServoAngle = (args: { pin_number: number; pin_value: number; }) => {\n const result = this.send(rpcRequest([{ kind: \"set_servo_angle\", args }]));\n\n // Celery script can't validate `pin_number` and `pin_value` the way we need\n // for `set_servo_angle`. We will send the RPC command off, but also\n // crash the client to aid debugging.\n if (![4, 5, 6, 11].includes(args.pin_number)) {\n throw new Error(\"Servos only work on pins 4 and 5\");\n }\n\n if (args.pin_value > 180 || args.pin_value < 0) {\n throw new Error(\"Pin value outside of 0...180 range\");\n }\n\n return result;\n }\n\n /**\n * Find the axis extents using encoder, motor, or end-stop feedback.\n * Will set a new home position and a new axis length for the given axis.\n */\n calibrate = (args: { axis: Corpus.ALLOWED_AXIS }) => {\n return this.send(rpcRequest([{ kind: \"calibrate\", args }]));\n }\n\n lua = (lua: string) => {\n return this.send(rpcRequest([\n { kind: \"lua\", args: { lua } }\n ]));\n }\n /**\n * Retrieves all of the event handlers for a particular event.\n * Returns an empty array if the event did not exist.\n */\n event = (name: string) => {\n this._events[name] = this._events[name] || [];\n return this._events[name];\n }\n\n on = (event: string, value: Function, once = false) => {\n this.event(event).push({ value, once, event });\n }\n\n emit = (event: string, data: {}) => {\n const nextArray: CallbackWrapper[] = [];\n\n this.event(event)\n .concat(this.event(\"*\"))\n .forEach(function (handler) {\n try {\n handler.value(data, event);\n if (!handler.once && handler.event === event) {\n nextArray.push(handler);\n }\n } catch (e) {\n const msg = `Exception thrown while handling '${event}' event.`;\n console.warn(msg);\n console.dir(e);\n }\n });\n\n if (nextArray.length === 0) {\n delete this._events[event];\n } else {\n this._events[event] = nextArray;\n }\n }\n\n /** Dictionary of all relevant MQTT channels the bot uses. */\n get channel() {\n const deviceName = this.config.mqttUsername;\n return {\n /** From the browser, usually. */\n toDevice: `bot/${deviceName}/${MqttChanName.fromClients}`,\n /** From farmbot */\n toClient: `bot/${deviceName}/${MqttChanName.fromDevice}`,\n status: `bot/${deviceName}/${MqttChanName.status}`,\n logs: `bot/${deviceName}/${MqttChanName.logs}`,\n sync: `bot/${deviceName}/${MqttChanName.sync}/#`,\n /** Read only */\n pong: `bot/${deviceName}/pong/#`,\n /** Write only: bot/${deviceName}/ping/${timestamp} */\n ping: (tStamp: number) => `bot/${deviceName}/ping/${tStamp}`\n };\n }\n\n /** Low-level means of sending MQTT packets. Does not check format. Does not\n * acknowledge confirmation. Probably not the one you want. */\n publish = (msg: Corpus.RpcRequest, important = true): void => {\n if (this.client) {\n this.emit(FbjsEventName.sent, msg);\n /** SEE: https://github.com/mqttjs/MQTT.js#client */\n this.client.publish(this.channel.toDevice, JSON.stringify(msg));\n } else {\n if (important) {\n throw new Error(\"Not connected to server\");\n }\n }\n }\n\n /** Low-level means of sending MQTT RPC commands to the bot. Acknowledges\n * receipt of message, but does not check formatting. Consider using higher\n * level methods like .moveRelative(), .calibrate(), etc....\n */\n send = (input: Corpus.RpcRequest): RpcResponse => {\n return new Promise((resolve, reject) => {\n\n this.publish(input);\n\n function handler(response: Corpus.RpcOk | Corpus.RpcError) {\n switch (response.kind) {\n case \"rpc_ok\": return resolve(response);\n case \"rpc_error\":\n const reason = (response.body || [])\n .map(x => x.args.message)\n .join(\", \");\n return reject(new Error(\"Problem sending RPC command: \" + reason));\n default:\n console.dir(response);\n throw new Error(\"Got a bad CeleryScript node.\");\n }\n }\n\n this.on(input.args.label, handler, true);\n });\n }\n\n /** Main entry point for all MQTT packets. */\n _onmessage = (chan: string, buffer: Uint8Array) => {\n const original = bufferToString(buffer);\n const segments = chan.split(Misc.MQTT_DELIM);\n const { emit } = this;\n\n try {\n const msg = JSON.parse(original);\n\n if (segments[0] == MqttChanName.publicBroadcast) {\n return emit(MqttChanName.publicBroadcast, msg);\n }\n\n switch (segments[2]) {\n case MqttChanName.logs: return emit(FbjsEventName.logs, msg);\n case MqttChanName.status: return emit(FbjsEventName.status, msg);\n case MqttChanName.sync: return emit(FbjsEventName.sync, msg);\n case MqttChanName.pong:\n return emit(segments[3], msg);\n default:\n const ev = hasLabel(msg) ? msg.args.label : FbjsEventName.malformed;\n return emit(ev, msg);\n }\n } catch (error) {\n console\n .dir({ text: \"Could not parse inbound message from MQTT.\", error });\n emit(FbjsEventName.malformed, original);\n }\n }\n\n ping = (timeout = 10000, now = timestamp()): Promise => {\n this.setConfig(\"LAST_PING_OUT\", now);\n return this.doPing(now, timeout);\n }\n\n // STEP 0: Subscribe to `bot/device_23/pong/#`\n // STEP 0: Send `bot/device_23/ping/3123123`\n // STEP 0: Receive `bot/device_23/pong/3123123`\n private doPing = (startedAt: number, timeout: number): Promise => {\n const timeoutPromise =\n new Promise((_, rej) => setTimeout(() => rej(-0), timeout));\n const pingPromise = new Promise((res, _) => {\n const ok = () => {\n const t = timestamp();\n this.setConfig(\"LAST_PING_IN\", t);\n res(t - startedAt);\n };\n this.on(\"\" + startedAt, ok, true);\n const chan = this.channel.ping(startedAt);\n if (this.client) {\n this.client.publish(chan, JSON.stringify(startedAt));\n }\n });\n\n return Promise.race([timeoutPromise, pingPromise]);\n }\n\n /** Bootstrap the device onto the MQTT broker. */\n connect = () => {\n const { mqttUsername, token, mqttServer } = this.config;\n const reconnectPeriod: number = Misc.RECONNECT_THROTTLE_MS;\n const client = connect(mqttServer, {\n clean: true,\n clientId: `FBJS-${Farmbot.VERSION}-${genUuid()}`,\n password: token,\n protocolId: \"MQTT\",\n protocolVersion: 4,\n reconnectPeriod,\n username: mqttUsername,\n });\n this.client = client;\n this.resources = new ResourceAdapter(this, this.config.mqttUsername);\n client.on(\"message\", this._onmessage);\n client.on(\"offline\", () => this.emit(FbjsEventName.offline, {}));\n client.on(\"connect\", () => this.emit(FbjsEventName.online, {}));\n const channels = [\n this.channel.logs,\n this.channel.status,\n this.channel.sync,\n this.channel.toClient,\n this.channel.pong\n ];\n client.subscribe(channels);\n return new Promise((resolve, _reject) => {\n if (this.client) {\n this.client.once(\"connect\", () => resolve(this));\n } else {\n throw new Error(\"Please connect first.\");\n }\n });\n }\n}\n","export * from \"./util/coordinate\";\nexport * from \"./util/is_celery_script\";\nexport * from \"./util/is_node\";\nexport * from \"./util/pick\";\nexport * from \"./util/rpc_request\";\nexport * from \"./util/uuid\";\n\nexport function stringToBuffer(str: string) {\n const regular_array = str.split(\"\").map(x => x.charCodeAt(0));\n const data16 = new Uint8Array(regular_array);\n return data16;\n}\n\ndeclare const util: { TextDecoder: typeof TextDecoder };\n\ninterface DecoderLike {\n decode(input: Uint8Array): string;\n}\n\nfunction newDecoder(): DecoderLike {\n if (typeof util !== \"undefined\" && util.TextDecoder) {\n return new util.TextDecoder()\n }\n\n if (typeof window !== \"undefined\" && window.TextDecoder) {\n return new window.TextDecoder();\n }\n\n return {\n decode(buffer) {\n const chars: string[] = [];\n buffer.forEach(x => chars.push(String.fromCharCode(x)));\n return chars.join(\"\");\n }\n };\n}\n\nconst td = newDecoder();\n/** We originally called buffer.toString(),\n * but that suffers from inconsistent behavior\n * between environments, leading to testing\n * difficulty. */\nexport const bufferToString = (b: Uint8Array) => td.decode(b);\n","import { Coordinate } from \"..\";\n\nexport function coordinate(x: number, y: number, z: number): Coordinate {\n return { kind: \"coordinate\", args: { x, y, z } };\n}\n","import { CeleryNode } from \"..\";\n\nconst isObj = (o: unknown) => !!(o && typeof o === \"object\");\nconst hasKind = (o: any) => typeof o.kind === \"string\";\nconst hasArgs = (o: any) => isObj(o) && !!o.args;\n\nexport function isCeleryScript(x: unknown): x is CeleryNode {\n return isObj(x) && hasKind(x) && hasArgs(x);\n}\n\nexport function hasLabel(x: unknown) {\n if (isCeleryScript(x)) {\n return typeof (x.args as any).label === \"string\";\n } else {\n return false;\n }\n}\n","export function isNode() {\n return typeof window === \"undefined\";\n}\n","export function pick(target: any, value: string, fallback: T) {\n const result = target[value];\n return (typeof result === undefined) ? fallback : result;\n}\n","import { RpcRequestBodyItem } from \"..\";\nimport { uuid } from \"./uuid\";\nimport { RpcRequest } from \"../corpus\";\n\nexport enum Priority {\n HIGHEST = 9000,\n NORMAL = 600,\n LOWEST = 300,\n}\n\nexport const rpcRequest =\n (body: RpcRequestBodyItem[], priority = Priority.NORMAL): RpcRequest => ({\n kind: \"rpc_request\",\n args: {\n label: uuid(),\n priority\n },\n body\n })\n","\nexport function uuid() {\n const template = \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\";\n const replaceChar = function (c: string) {\n const r = Math.random() * 16 | 0;\n const v = c === \"x\" ? r : r & 0x3 | 0x8;\n return v.toString(16);\n };\n return template.replace(/[xy]/g, replaceChar);\n}\n","import { APIToken } from \"./interfaces\";\nimport { isNode } from \"./util\";\n\ndeclare var atob: (i: string) => string;\ndeclare var global: typeof window;\n\nexport interface FarmBotInternalConfig {\n speed: number;\n token: string;\n secure: boolean;\n mqttServer: string;\n mqttUsername: string;\n LAST_PING_OUT: number;\n LAST_PING_IN: number;\n}\n\nexport interface FarmbotConstructorParams extends Partial {\n /** All inputs are optional, except for `token`. */\n token: string;\n}\n\nconst ERR_TOKEN_PARSE = \"Unable to parse token. Is it properly formatted?\";\n\nexport const CONFIG_DEFAULTS = {\n speed: 100,\n};\n\nconst ERR_MISSING_MQTT_USERNAME = \"MISSING_MQTT_USERNAME\";\nexport const FIX_ATOB_FIRST =\n `NOTE TO NODEJS USERS:\n\nThis library requires an 'atob()' function.\nPlease fix this first.\nSOLUTION: https://github.com/FarmBot/farmbot-js/issues/33`;\n\nconst parseToken = (input: string): APIToken => {\n try {\n return JSON.parse(atob(input.split(\".\")[1]));\n } catch (e) {\n console.warn(e);\n throw new Error(ERR_TOKEN_PARSE);\n }\n};\n\nexport const generateConfig = (input: FarmbotConstructorParams): FarmBotInternalConfig => {\n if (isNode() && !global.atob) { throw new Error(FIX_ATOB_FIRST); }\n const t = parseToken(input.token);\n\n return {\n speed: input.speed || CONFIG_DEFAULTS.speed,\n token: input.token,\n secure: input.secure === false ? false : true,\n mqttServer: isNode() ? `mqtt://${t.mqtt}:1883` : t.mqtt_ws,\n mqttUsername: t.bot || ERR_MISSING_MQTT_USERNAME,\n LAST_PING_OUT: 0,\n LAST_PING_IN: 0,\n };\n}\n","import { uuid } from \"..\";\nimport {\n DeletionRequest,\n FarmbotLike,\n MqttLike,\n RpcResponse\n} from \"./interfaces\";\nimport {\n outboundChanFor,\n resolveOrReject\n} from \"./support\";\nimport { rejectRpc } from \"./reject_rpc\";\nimport { TaggedResource } from \"./tagged_resource\";\n\nexport class ResourceAdapter {\n constructor(public parent: FarmbotLike, public username: string) { }\n\n destroy = (r: DeletionRequest) => {\n const { client } = this.parent;\n return (client ? this.doDestroy(client, r.kind, r.id) : rejectRpc());\n }\n\n save = (resource: TaggedResource) => {\n const { client } = this.parent;\n return (client ? this.doSave(client, resource) : rejectRpc());\n }\n\n destroyAll = (req: DeletionRequest[]) => Promise.all(req.map(r => this.destroy(r)));\n\n private doDestroy = (client: MqttLike,\n kind: DeletionRequest[\"kind\"],\n id: number): Promise => {\n\n return new Promise((res, rej) => {\n const requestId = uuid();\n this.parent.on(requestId, resolveOrReject(res, rej));\n client.publish(outboundChanFor(this.username, \"destroy\", kind, requestId, id), \"\");\n });\n }\n\n private doSave =\n (client: MqttLike, r: TaggedResource): Promise => {\n return new Promise((res, rej) => {\n const uid = uuid();\n this.parent.on(uid, resolveOrReject(res, rej));\n const chan =\n outboundChanFor(this.username, \"save\", r.kind, uid, r.body.id);\n client.publish(chan, JSON.stringify(r.body));\n });\n }\n}\n","import { RpcResponse, ResourceName } from \"./interfaces\";\nimport { RpcError } from \"..\";\n\ntype OpType = \"destroy\" | \"save\";\n\nexport const outboundChanFor =\n (username: string, op: OpType, kind: ResourceName, uuid: string, id = 0): string => {\n const segments = [`bot`, username, `resources_v0`, op, kind, uuid, id];\n return segments.join(\"/\");\n };\n\n// Auto-reject if client is not connected yet.\nexport const internalError: RpcError = {\n kind: \"rpc_error\",\n args: { label: \"BROWSER_LEVEL_FAILURE\" },\n body: [\n {\n kind: \"explanation\",\n args: { message: \"Tried to perform batch operation before connect.\" }\n }\n ]\n};\n\nexport const resolveOrReject = (res: Function, rej: Function) => {\n return (m: RpcResponse) => (m.kind == \"rpc_ok\" ? res : rej)(m);\n}\n","import { internalError } from \"./support\";\nimport { RpcError } from \"../corpus\";\n\nexport const rejectRpc = (): Promise => Promise.reject(internalError);\n","export enum MqttChanName {\n fromApi = \"from_api\",\n fromClients = \"from_clients\",\n fromDevice = \"from_device\",\n logs = \"logs\",\n status = \"status\",\n sync = \"sync\",\n /** THIS ONE IS SPECIAL. */\n publicBroadcast = \"public_broadcast\",\n pong = \"pong\"\n}\n\n/** Not to be confused with MqttChanNames or\n * MQTT.js event names */\nexport enum FbjsEventName {\n /** State tree update. */\n status = \"status\",\n /** When a log is received */\n logs = \"logs\",\n /** When an unexpected message is received */\n malformed = \"malformed\",\n /** Unreliable. */\n offline = \"offline\",\n /** Fired on connect. */\n online = \"online\",\n /** Fires when the API sends an MQTT message to users. */\n publicBroadcast = \"public_broadcast\",\n /** Fires after any message is sent from current client. */\n sent = \"sent\",\n /** Used by resource auto-sync. */\n sync = \"sync\",\n /** When a key is removed from the device state tree. */\n remove = \"remove\",\n}\n\nexport enum Misc {\n /** Channel delimiter for MQTT channels. */\n MQTT_DELIM = \"/\",\n /** A null value when dealing with empty `pair` nodes in CeleryScript. */\n NULL = \"null\",\n /** Reconnect interval for MQTT.js */\n RECONNECT_THROTTLE_MS = 1000,\n}\n","/** Returns a timestamp in ms. */\nexport function timestamp() {\n return Math.round((new Date()).getTime() / 100);\n}\n\n// type RejectFn = (reason?: any) => void;\n// type ResolveFn = (value?: T | PromiseLike) => void;\n\n// interface Executor {\n// (x: (resolve: ResolveFn, reject: RejectFn) => void): Promise;\n// }\n\n// export function timeoutPromise(time: number, executor: Executor): Promise {\n// return new Promise(executor);\n// }\n","import { NumberConfigKey } from \"./resources/configs/firmware\";\n\nexport type Primitive = string | number | boolean;\n\n/** Everything the farmbot knows about itself at a given moment in time. */\nexport interface BotStateTree {\n /** Microcontroller configuration and settings. */\n mcu_params: McuParams;\n /** Cartesian coordinates of the bot. */\n location_data: LocationData;\n /** Lookup table, indexed by number for pin status */\n pins: Pins;\n /** User definable config settings. */\n configuration: Configuration;\n /** READ ONLY meta data about the FarmBot device. */\n readonly informational_settings: InformationalSettings;\n /** Bag of misc. ENV vars that any Farmware author can use. */\n user_env: Dictionary<(string | undefined)>;\n /** When you're really curious about how a long-running\n * task (like FarmBot OS update downloads) is going to take. */\n jobs: Dictionary<(JobProgress | undefined)>;\n /** List of user accessible processes running on the bot. */\n process_info: { farmwares: Dictionary; };\n gpio_registry: { [pin: number]: string | undefined } | undefined;\n}\n\n/** Microcontroller board. */\nexport type FirmwareHardware =\n | \"none\"\n | \"arduino\"\n | \"express_k10\"\n | \"express_k11\"\n | \"farmduino_k14\"\n | \"farmduino_k15\"\n | \"farmduino_k16\"\n | \"farmduino_k17\"\n | \"farmduino\";\n\n/** FarmBot motor and encoder positions. */\nexport type LocationName =\n | \"position\"\n | \"scaled_encoders\"\n | \"raw_encoders\";\n\nexport type AxisState =\n | \"idle\"\n | \"begin\"\n | \"accelerate\"\n | \"cruise\"\n | \"decelerate\"\n | \"stop\"\n | \"crawl\";\n\nexport interface LocationData {\n position: Record;\n scaled_encoders: Record;\n raw_encoders: Record;\n load?: Record;\n axis_states?: Record;\n}\n\n/** Job progress status. */\nexport type ProgressStatus =\n | \"complete\"\n | \"working\"\n | \"error\";\n\nexport type JobProgress =\n | PercentageProgress\n | BytesProgress;\n\ninterface JobProgressBase {\n status: ProgressStatus;\n type: string;\n file_type: string;\n time: string;\n updated_at: number;\n}\n\n/** Percent job progress. */\nexport interface PercentageProgress extends JobProgressBase {\n unit: \"percent\";\n percent: number;\n}\n\n/** Bytes job progress. */\nexport interface BytesProgress extends JobProgressBase {\n unit: \"bytes\";\n bytes: number;\n}\n\n/** Identified FarmBot OS problem. */\nexport interface Alert {\n id?: number;\n created_at: number;\n problem_tag: string;\n priority: number;\n slug: string;\n}\n\n/**\n * Configs (inputs) requested by a Farmware.\n * Can be namespaced and supplied to a run Farmware command.\n * Also used in FarmBot Web App Farmware page form builder.\n */\nexport type FarmwareConfig = Record<\"name\" | \"label\" | \"value\", string>;\n\n/**\n * The Farmware manifest is a JSON file published by Farmware authors.\n * It is used by FarmBot OS to perform installation and upgrades.\n */\nexport interface FarmwareManifest {\n /** \"2.0\" */\n farmware_manifest_version: string;\n /** Farmware name. */\n package: string;\n /** Farmware version. */\n package_version: string;\n /** Farmware description (optional). */\n description: string;\n /** Farmware author. */\n author: string;\n /** Farmware language, eg: `python` (optional). */\n language: string;\n /** The thing that will run the Farmware eg: `python`. */\n executable: string;\n /** Command line args (combined into a string) passed to `executable`. */\n args: string;\n /** Dictionary of `FarmwareConfig` with number (i.e., \"1\") keys. (optional) */\n config: Dictionary;\n /** Required FarmBot OS version to run the Farmware, i.e., \">=8.0.0\" */\n farmbot_os_version_requirement: string;\n /** Required Farmware Tools version. Use \">=0.0.0\" for latest version. */\n farmware_tools_version_requirement: string;\n /** Farmware manifest URL (optional). */\n url: string;\n /** Zipped Farmware files URL. */\n zip: string;\n}\n\nexport enum Encoder {\n unknown = -1,\n quadrature,\n differential\n}\n\n/** Microcontroller firmware hardware setting names. */\nexport type McuParamName = NumberConfigKey;\n\n/** Microcontroller configuration and settings. */\nexport type McuParams = Partial>;\n\n/** Bot axis names. */\nexport type Xyz = \"x\" | \"y\" | \"z\";\n/** 3 dimensional vector. */\nexport type Vector3 = Record;\n\n/** GPIO pin value record. */\nexport interface Pin {\n mode: number;\n value: number;\n}\n\n/** Lookup for pin status, indexed by pin number. */\nexport type Pins = Dictionary;\n\n/** FarmBot OS configs. */\nexport interface FullConfiguration {\n arduino_debug_messages: number;\n boot_sequence_id?: number;\n firmware_debug_log?: boolean;\n firmware_hardware: FirmwareHardware;\n firmware_input_log: boolean;\n firmware_output_log: boolean;\n firmware_path?: string;\n fw_auto_update: number;\n os_auto_update: number;\n sequence_body_log: boolean;\n sequence_complete_log: boolean;\n sequence_init_log: boolean;\n update_channel?: string;\n safe_height?: number;\n soil_height?: number;\n gantry_height?: number;\n}\n\n/** FarmBot OS configs. */\nexport type Configuration = Partial;\n\n/** FarmBot OS config names. */\nexport type ConfigurationName = keyof Configuration;\n\n/** The possible values for the sync_status property on informational_settings */\nexport type SyncStatus =\n | \"booting\"\n | \"maintenance\"\n | \"sync_error\"\n | \"sync_now\"\n | \"synced\"\n | \"syncing\"\n | \"unknown\";\n\n/** Various FarmBot OS status data. */\nexport interface InformationalSettings {\n /** System uptime in seconds. */\n uptime?: number;\n /** Percentage of disk space used. */\n disk_usage?: number;\n /** CPU utilization (percent). */\n cpu_usage?: number;\n /** Scheduler utilization (percent). */\n scheduler_usage?: number;\n /** Megabytes of RAM used. */\n memory_usage?: number;\n /** CPU Temperature (C) of the device running FBOS (RPi). */\n soc_temp?: number;\n /** WiFi signal strength (dBm). */\n wifi_level?: number;\n /** WiFi signal strength (percent). */\n wifi_level_percent?: number;\n /** FBOS commit hash. */\n controller_commit?: string;\n /** Current version of FarmBot OS. */\n controller_version?: string | undefined;\n /** Current uuid of FarmBot OS firmware. */\n controller_uuid?: string | undefined;\n /** Arduino/Farmduino firmware version. */\n firmware_version?: string | undefined;\n /** If the RPi is throttled and/or having WiFi issues. */\n throttled?: string | undefined;\n /** Farmbot's private IP address */\n private_ip?: string | undefined;\n /** The message to be displayed on the frontend for sync status. */\n sync_status?: SyncStatus | undefined;\n /** Microcontroller status (move in progress, etc.) */\n busy: boolean;\n /** Microcontroller status */\n idle?: boolean;\n /** Emergency stop status. */\n locked: boolean;\n /** FBOS commit hash. */\n commit: string;\n /** Microcontroller firmware commit hash. */\n firmware_commit: string;\n /** FBOS device type (rpi3, etc.). */\n target: string;\n /** FBOS env (prod, dev, etc.). */\n env: string;\n /** FBOS node name. */\n node_name: string;\n /** FBOS is beta? */\n currently_on_beta?: boolean;\n /** FBOS update available? */\n update_available?: boolean;\n /** CSV list of available camera device numbers (/dev/video#). */\n video_devices?: string;\n}\n\nexport type MQTTEventName = \"connect\" | \"message\";\n\nexport interface Dictionary { [key: string]: T; }\n\nexport interface APIToken {\n /** LEGACY ISSUES AHEAD: PLEASE READ:\n * This is the *host* of MQTT server. A host is *not* the same thing as\n * a URL. This property is only useful for NodeJS users.*/\n mqtt: string;\n\n /** Fully formed URL (port, protocol, host) pointing to the MQTT\n * websocket server. */\n mqtt_ws: string;\n\n /** UUID of current bot, eg: \"device_1\". */\n bot: string;\n}\n","import {\n Curve,\n Crop,\n DeviceAccountSettings,\n FarmEvent,\n FarmwareEnv,\n FarmwareInstallation,\n Folder,\n GenericPointer,\n Image,\n Log,\n Peripheral,\n PinBinding,\n PlantPointer,\n PlantTemplate,\n PointGroup,\n Regimen,\n SavedGarden,\n Sensor,\n SensorReading,\n SequenceResource,\n Telemetry,\n Tool,\n ToolSlotPointer,\n User,\n WebcamFeed,\n WeedPointer,\n WizardStepResult,\n} from \"./api_resources\";\nimport { FbosConfig } from \"./configs/fbos\";\nimport { FirmwareConfig } from \"./configs/firmware\";\nimport { WebAppConfig } from \"./configs/web_app\";\nimport { Alert } from \"../interfaces\";\n\nexport type ResourceName =\n | \"Alert\"\n | \"Crop\"\n | \"Curve\"\n | \"Device\"\n | \"FarmEvent\"\n | \"FarmwareEnv\"\n | \"FarmwareInstallation\"\n | \"FbosConfig\"\n | \"FirmwareConfig\"\n | \"Folder\"\n | \"Image\"\n | \"Log\"\n | \"Peripheral\"\n | \"PinBinding\"\n | \"Plant\"\n | \"PlantTemplate\"\n | \"Point\"\n | \"PointGroup\"\n | \"Regimen\"\n | \"SavedGarden\"\n | \"Sensor\"\n | \"SensorReading\"\n | \"Sequence\"\n | \"Telemetry\"\n | \"Tool\"\n | \"User\"\n | \"WebAppConfig\"\n | \"WizardStepResult\"\n | \"WebcamFeed\";\n\nexport interface TaggedResourceBase {\n kind: ResourceName;\n /** Unique identifier and index key.\n * We can't use the object's `id` attribute as a local index key because\n * unsaved objects don't have one.\n */\n uuid: string;\n body: object;\n /** Indicates if the resource is saved, saving or dirty.\n * `undefined` denotes that the resource is saved. */\n specialStatus: SpecialStatus;\n}\n\n/** Denotes special status of resource */\nexport enum SpecialStatus {\n /** The local copy is different than the one on the remote end. */\n DIRTY = \"DIRTY\",\n /** The local copy is being saved on the remote end right now? */\n SAVING = \"SAVING\",\n /** API and FE are in sync. Using \"\" for now because its falsey like old\n * `undefined` value */\n SAVED = \"\"\n}\n\nexport interface RestResource\n extends TaggedResourceBase {\n kind: T;\n body: U;\n}\n\nexport type TaggedResource =\n | TaggedAlert\n | TaggedCrop\n | TaggedCurve\n | TaggedDevice\n | TaggedFarmEvent\n | TaggedFarmwareEnv\n | TaggedFarmwareInstallation\n | TaggedFbosConfig\n | TaggedFirmwareConfig\n | TaggedFolder\n | TaggedImage\n | TaggedLog\n | TaggedPeripheral\n | TaggedPinBinding\n | TaggedPlantTemplate\n | TaggedPoint\n | TaggedPointGroup\n | TaggedRegimen\n | TaggedSavedGarden\n | TaggedSensor\n | TaggedSensorReading\n | TaggedSequence\n | TaggedTelemetry\n | TaggedTool\n | TaggedUser\n | TaggedWebAppConfig\n | TaggedWizardStepResult\n | TaggedWebcamFeed;\n\ntype PointUnion =\n | GenericPointer\n | PlantPointer\n | ToolSlotPointer\n | WeedPointer;\n\nexport type TaggedAlert = RestResource<\"Alert\", Alert>;\nexport type TaggedCrop = RestResource<\"Crop\", Crop>;\nexport type TaggedCurve = RestResource<\"Curve\", Curve>;\nexport type TaggedDevice = RestResource<\"Device\", DeviceAccountSettings>;\nexport type TaggedFolder = RestResource<\"Folder\", Folder>;\nexport type TaggedFarmEvent = RestResource<\"FarmEvent\", FarmEvent>;\nexport type TaggedFarmwareEnv = RestResource<\"FarmwareEnv\", FarmwareEnv>;\nexport type TaggedFarmwareInstallation = RestResource<\"FarmwareInstallation\", FarmwareInstallation>;\nexport type TaggedFbosConfig = RestResource<\"FbosConfig\", FbosConfig>;\nexport type TaggedFirmwareConfig = RestResource<\"FirmwareConfig\", FirmwareConfig>;\nexport type TaggedGenericPointer = RestResource<\"Point\", GenericPointer>;\nexport type TaggedImage = RestResource<\"Image\", Image>;\nexport type TaggedLog = RestResource<\"Log\", Log>;\nexport type TaggedPeripheral = RestResource<\"Peripheral\", Peripheral>;\nexport type TaggedPinBinding = RestResource<\"PinBinding\", PinBinding>;\nexport type TaggedPlantPointer = RestResource<\"Point\", PlantPointer>;\nexport type TaggedPlantTemplate = RestResource<\"PlantTemplate\", PlantTemplate>;\nexport type TaggedPoint = RestResource<\"Point\", PointUnion>;\nexport type TaggedPointGroup = RestResource<\"PointGroup\", PointGroup>;\nexport type TaggedRegimen = RestResource<\"Regimen\", Regimen>;\nexport type TaggedSavedGarden = RestResource<\"SavedGarden\", SavedGarden>;\nexport type TaggedSensor = RestResource<\"Sensor\", Sensor>;\nexport type TaggedSensorReading = RestResource<\"SensorReading\", SensorReading>;\nexport type TaggedSequence = RestResource<\"Sequence\", SequenceResource>;\nexport type TaggedTelemetry = RestResource<\"Telemetry\", Telemetry>;\nexport type TaggedTool = RestResource<\"Tool\", Tool>;\nexport type TaggedToolSlotPointer = RestResource<\"Point\", ToolSlotPointer>;\nexport type TaggedUser = RestResource<\"User\", User>;\nexport type TaggedWebAppConfig = RestResource<\"WebAppConfig\", WebAppConfig>;\nexport type TaggedWebcamFeed = RestResource<\"WebcamFeed\", WebcamFeed>;\nexport type TaggedWizardStepResult = RestResource<\"WizardStepResult\", WizardStepResult>;\nexport type TaggedWeedPointer = RestResource<\"Point\", WeedPointer>;\n\nexport type PointerType =\n | TaggedToolSlotPointer\n | TaggedGenericPointer\n | TaggedPlantPointer\n | TaggedWeedPointer;\n","// This is a stub for developers who do not have a module loader or are\n// prototyping one-off scripts in a browser.\nwindow.fbjs = require(\"./index.ts\");\n"],"names":["$b8E1b$mqtt","require","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","hasOwnProperty","defineProperty","enumerable","get","$parcel$export","e","n","v","s","set","configurable","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","$h19jY","$fTGM0","$3tZ8P","$jOzD0","$bFr0L","$c639c2a4041df2b3$export$5bd6772f122cb888","$c639c2a4041df2b3$export$642ebf9ec2e6a14a","$c639c2a4041df2b3$export$59b5878345794ac6","$b92d2bf8eb506f9b$export$3ab9a2df6016a88a","$01gfL","$8i5S2","$iwcyJ","$f5H0j","$dPMce","$7tZ6d","$byyGl","$aWv1W","Farmbot","input","_this","getConfig","config","setConfig","value","installFarmware","url","send","rpcRequest","kind","args","updateFarmware","pkg","package","removeFarmware","installFirstPartyFarmware","powerOff","reboot","rebootFirmware","checkUpdates","resetOS","publish","resetMCU","flashFirmware","firmware_name","emergencyLock","rpc","Priority","HIGHEST","emergencyUnlock","execSequence","sequence_id","body","execScript","label","envVars","home","findHome","moveAbsolute","x","y","z","speed","CONFIG_DEFAULTS","location","coordinate","offset","moveRelative","writePin","readPin","togglePin","readStatus","takePhoto","sync","setZero","axis","setUserEnv","configs","map","Misc","NULL","sendMessage","message_type","message","channels","channel_name","setServoAngle","result","includes","pin_number","pin_value","calibrate","lua","event","name","_events","on","once","push","emit","data","nextArray","concat","handler","console","warn","dir","length","msg","important","client","FbjsEventName","sent","channel","toDevice","JSON","stringify","Promise","resolve","reject","response","join","_onmessage","chan","buffer","original","bufferToString","segments","split","MQTT_DELIM","parse","MqttChanName","publicBroadcast","logs","status","pong","ev","hasLabel","malformed","error","text","ping","timeout","now","timestamp","doPing","startedAt","race","_","rej","setTimeout","res","t","connect","_a","mqttUsername","token","mqttServer","reconnectPeriod","RECONNECT_THROTTLE_MS","clean","clientId","VERSION","uuid","password","protocolId","protocolVersion","username","resources","ResourceAdapter","offline","online","toClient","subscribe","_reject","generateConfig","prototype","deviceName","fromClients","fromDevice","tStamp","$e6ce52d33b3b9851$export$1e95461c937e230d","$e6ce52d33b3b9851$export$4f75cc6593308bd6","$3SNLU","$4svrT","str","regular_array","charCodeAt","Uint8Array","$e6ce52d33b3b9851$var$td","util","TextDecoder","window","decode","chars","String","fromCharCode","b","$60948eee8fcc500d$export$bf56ff1a05c69b9a","$869dc5c8a17d7708$export$7b28645421dfad14","$869dc5c8a17d7708$export$939ea909fc0c90e4","$869dc5c8a17d7708$var$isObj","o","$2d3d05e3f1851e01$export$8ee0fc9ee280b4ee","$33f22c0e5ae5fa1f$export$357523c63a2253b9","target","fallback","$003cb3b035fb32f9$export$300334f671c43555","$003cb3b035fb32f9$export$d6d466271de85642","priority","NORMAL","$d7b4f5289284df15$export$31b40729666a4ae0","template","replace","c","r","Math","random","toString","$afc8ae5bc0bbdf6a$export$429fe2716bb77ce4","$afc8ae5bc0bbdf6a$export$2eafab8a593352a4","$afc8ae5bc0bbdf6a$var$parseToken","atob","isNode","secure","mqtt","mqtt_ws","bot","LAST_PING_OUT","LAST_PING_IN","$a1256c8ef829f998$export$61d38aff960bd05b","$kGTNw","$d1UZh","parent","destroy","doDestroy","rejectRpc","save","resource","doSave","destroyAll","req","all","requestId","resolveOrReject","outboundChanFor","uid","$f103032c79b02b9d$export$282f68fea638d11","$f103032c79b02b9d$export$bcbf15ce904d591a","$f103032c79b02b9d$export$cbefd47f9f016f08","op","m","$97c792dbbae05474$export$d53e1703f9959ce0","internalError","$572aa2e43a4df30f$export$51316fc5e371191b","$572aa2e43a4df30f$export$9758e930bdf73341","$572aa2e43a4df30f$export$4b3033a0406d3b","$7f77641fb0661547$export$fc00ee57782020aa","round","Date","getTime","$289381f16f78a587$export$a50aceb0e02a00aa","Encoder","$02312b41c59a57c7$export$d3ccc720d6d43811","SpecialStatus","fbjs"],"version":3,"file":"farmbot_single_file.js.map","sourceRoot":"../"} \ No newline at end of file diff --git a/dist/interfaces.d.ts b/dist/interfaces.d.ts index de1e201..d19336b 100644 --- a/dist/interfaces.d.ts +++ b/dist/interfaces.d.ts @@ -26,7 +26,7 @@ export interface BotStateTree { } | undefined; } /** Microcontroller board. */ -export type FirmwareHardware = "none" | "arduino" | "express_k10" | "express_k11" | "farmduino_k14" | "farmduino_k15" | "farmduino_k16" | "farmduino"; +export type FirmwareHardware = "none" | "arduino" | "express_k10" | "express_k11" | "farmduino_k14" | "farmduino_k15" | "farmduino_k16" | "farmduino_k17" | "farmduino"; /** FarmBot motor and encoder positions. */ export type LocationName = "position" | "scaled_encoders" | "raw_encoders"; export type AxisState = "idle" | "begin" | "accelerate" | "cruise" | "decelerate" | "stop" | "crawl"; diff --git a/package-lock.json b/package-lock.json index 28291b3..c839e12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "farmbot", - "version": "15.8.2", + "version": "15.8.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "farmbot", - "version": "15.8.2", + "version": "15.8.3", "license": "MIT", "dependencies": { "mqtt": "^5.1.4" diff --git a/package.json b/package.json index 859a861..17b3ec5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "farmbot", - "version": "15.8.2", + "version": "15.8.3", "description": "Farmbot Javascript client.", "browserslist": "defaults", "scripts": { diff --git a/src/farmbot.ts b/src/farmbot.ts index a089b6c..7fcd0bc 100644 --- a/src/farmbot.ts +++ b/src/farmbot.ts @@ -45,7 +45,7 @@ export class Farmbot { private config: Conf; public client?: MqttClient; public resources: ResourceAdapter; - static VERSION = "15.8.2"; + static VERSION = "15.8.3"; constructor(input: FarmbotConstructorParams) { this._events = {}; diff --git a/src/interfaces.ts b/src/interfaces.ts index 65409a9..dbfeb2e 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -33,6 +33,7 @@ export type FirmwareHardware = | "farmduino_k14" | "farmduino_k15" | "farmduino_k16" + | "farmduino_k17" | "farmduino"; /** FarmBot motor and encoder positions. */