diff --git a/core/socket.js b/core/socket.js
index 1840b35e..8f115d73 100755
--- a/core/socket.js
+++ b/core/socket.js
@@ -302,7 +302,7 @@ var Socket = class Socket{
else {
payload_string = payload_string_maybe
}
- Socket.r_payload_grab_aux(robot_status, payload_string)
+ Socket.r_payload_grab_aux(robot_status, payload_string.toString()) //beware, sometimes payload_string is a buffer. This converts it to a string.
}
//called by both Socket.r_payload_grab AND DexterSim.process_next_instruction_r
diff --git a/core/storage.js b/core/storage.js
index 98bd5793..33064b37 100644
--- a/core/storage.js
+++ b/core/storage.js
@@ -227,47 +227,41 @@ module.exports.file_content = file_content //depricated
//callback passed err, and data.
//If error is non-null, its an error object or a string error message.
//if it is null, data is a string of the file content.
+//but beware, sometimes data is a BUFFER not a string.
+// data.toString() will convert a buffer to a string,
+//and just returns the string if data happens to be a string
function read_file_async(path, encoding="utf8", callback){
- let colon_pos = path.indexOf(":")
- if(colon_pos == -1) {
- path = make_full_path(path)
- fs.readFile(path, encoding, callback)
- }
- else {
- let dex_name_maybe = path.substring(0, colon_pos)
- let dex = Dexter[dex_name_maybe]
- if(dex){
- let dex_file_path = path.substring(colon_pos + 1)
- let the_callback = callback
- let the_path = path
- new Job({name: "dex_file_read",
- do_list: [
- dex.read_file(dex_file_path, "file_content"),
- function(){
- let cont = this.user_data.file_content
- if(typeof(cont) == "string"){
- the_callback(null, cont)
- }
- else {
- let err = new Error("Error getting file content for: " + the_path + " with error number: " + cont, the_path)
- the_callback(err, cont)
- }
- }
- ],
- when_stopped: function(){ //this code OUGHT to be called but as of apr 2019, if we error due to dexter not connected, then Job,.finish is never called so we don't call this method. Handle it in Job.stop_for_reason
- if(this.status_code == "errored"){
- if(window.Editor) { //won't hit in node, bu won't error either
- Editor.set_files_menu_to_path() //restore files menu to what it was before we tried to get the file off of dexter.
- }
+ if(is_dexter_path(path)){
+ let dex_file_path = path.substring(colon_pos + 1)
+ let the_callback = callback
+ let the_path = path
+ new Job({name: "dex_file_read",
+ do_list: [
+ dex.read_file(dex_file_path, "file_content"),
+ function(){
+ let cont = this.user_data.file_content
+ if(typeof(cont) == "string"){
+ the_callback(null, cont)
+ }
+ else {
+ let err = new Error("Error getting file content for: " + the_path + " with error number: " + cont, the_path)
+ the_callback(err, cont)
+ }
+ }
+ ],
+ when_stopped: function(){ //this code OUGHT to be called but as of apr 2019, if we error due to dexter not connected, then Job,.finish is never called so we don't call this method. Handle it in Job.stop_for_reason
+ if(this.status_code == "errored"){
+ if(window.Editor) { //won't hit in node, bu won't error either
+ Editor.set_files_menu_to_path() //restore files menu to what it was before we tried to get the file off of dexter.
}
}
- }).start()
- }
- else {
- path = make_full_path(path)
- fs.readFile(path, callback)
- }
- }
+ }
+ }).start()
+ }
+ else {
+ path = make_full_path(path)
+ fs.readFile(path, callback)
+ }
}
module.exports.read_file_async = read_file_async
@@ -355,49 +349,33 @@ function write_file_async(path, content, encoding="utf8", callback){
if (content === undefined) {
content = Editor.get_javascript()
}
- let colon_pos = path.indexOf(":")
- if(colon_pos == -1) {
- path = make_full_path(path)
- if(!callback) {
- let the_path = path
- callback = function(err){
- if(err){
- dde_error("write_file_async passed: " + the_path +
- "
Got error: " + err.message)
- }
- else { out("saved: " + the_path, undefined, true) }
+ if(!callback) {
+ let the_path = path
+ callback = function(err){
+ if(err){
+ dde_error("write_file_async passed: " + the_path +
+ "
Got error: " + err.message)
}
+ else { out("saved: " + the_path, undefined, true) }
}
- fs.writeFile(path, content, encoding, callback)
}
- else {
+ if(is_dexter_path(path)){
+ let colon_pos = path.indexOf(":") //will not return -1
let dex_name_maybe = path.substring(0, colon_pos)
- let dex = Dexter[dex_name_maybe]
- if(!callback) {
- let the_path = path
- callback = function(err){
- if(err){
- dde_error("write_file_async passed: " + the_path +
- "
Got error: " + err.message)
- }
- else { out("Saved: " + the_path, undefined, true) }
- }
- }
- if(dex){
- let dex_file_path = path.substring(colon_pos + 1)
- let the_callback = callback
- let the_path = path
- new Job({name: "dex_file_read",
- do_list: [
- dex.write_file(dex_file_path, content),
- callback //but never passes an error object. not good, but robot_status should contain an error, and error if there is one, else callback should be called with no error so it does what it should do when no error
- ]
- }).start()
- }
- else {
- path = make_full_path(path)
- fs.writeFile(path, content, encoding, callback)
- }
+ let dex = Dexter[dex_name_maybe] // will be a real robot
+ let dex_file_path = path.substring(colon_pos + 1)
+ let the_callback = callback
+ let the_path = path
+ new Job({name: "dex_file_read",
+ do_list: [
+ dex.write_file(dex_file_path, content),
+ callback //but never passes an error object. not good, but robot_status should contain an error, and error if there is one, else callback should be called with no error so it does what it should do when no error
+ ]
+ }).start()
+ }
+ else {
+ path = make_full_path(path)
+ fs.writeFile(path, content, encoding, callback)
}
}
@@ -523,6 +501,21 @@ function is_root_path(path){
else { return false }
//return starts_with_one_of(path, ["/", "C:", "D:", "E:", "F:", "G:"]) //C: etc. is for Windows OS.
}
+//returns true if its a path that isn't a top level, has a colon and the
+//substring between the beginning of the path and the colon names a defined dexter.
+//Beware that if the dexter is not defined YET, then this will return false.
+function is_dexter_path(path){
+ if(is_root_path(path)) { return false }
+ else {
+ let colon_pos = path.indexOf(":")
+ if(colon_pos == -1) { return false }
+ else {
+ let dex_name_maybe = path.substring(0, colon_pos)
+ if(Dexter[dex_name_maybe]) { return true }
+ else { return false}
+ }
+ }
+}
//______new load_files synchronous______
//verify all paths first before loading any of them because we want to error early.
diff --git a/doc/ref_man.html b/doc/ref_man.html
index bff98fe6..3b9f27de 100644
--- a/doc/ref_man.html
+++ b/doc/ref_man.html
@@ -104,7 +104,7 @@
read_file
- read_file
takes an argument of a file path,
+ read_file
is a function that takes an argument of a file path,
and returns a string of the content of the file.
Parameters:
path A string of a path to the file. Usually this will not start with a slash,
@@ -119,6 +119,11 @@
See load_files
for grabbing the file contents, then evaling it.
+
read_file
instead.
write_file
is a function that takes an argument of a file path
+ and a new content string. It sets the content of that file.write_file("junk.js")
Gives foo.js the content now in the editor.
This is the save_as functionality.write_file("junk.js", "new content")
Replaces the existing content
- of the given file with "new content".file_content
deprecatred and replaced by read_file
.file_content
deprecated and replaced by read_file
.file_content_async
deprecated and replace by read_file_async
Dexter.read_from_robot
deprecated and replaced by Dexter.read_file
.Dexter.write_to_robot
deprecated and replaced by Dexter.write_file
.
diff --git a/editor.js b/editor.js
index c182e8f3..fea86115 100644
--- a/editor.js
+++ b/editor.js
@@ -158,7 +158,8 @@ Editor.make_files_menu_path = function(folder, name) {
}
-//returns an array of folder and file name. The folder always ends with slash or colon.
+//returns an array of folder and file name.
+// The returned folder always ends with slash or colon.
Editor.path_to_folder_and_name = function(path){
let file_name_start_index = path.lastIndexOf("/")
if(file_name_start_index == -1) { file_name_start_index = path.lastIndexOf(":") } //happens with dexter0:foo.js
@@ -647,6 +648,7 @@ Editor.edit_file = function(path){ //path could be "new buffer"
dde_error(err.message)
}
else {
+ content = content.toString() //because sometimes the content passed in is buffer, not a string. This handles both.
Editor.edit_file_aux(the_path, content)
}
})
diff --git a/math/DXF.js b/math/DXF.js
index 080dc43d..c5025e31 100644
--- a/math/DXF.js
+++ b/math/DXF.js
@@ -2,6 +2,7 @@
//James Wigglesworth
//Started: 2_10_2017
//Updated: 1_26_19
+var txt = require("./txt.js") //doesn't work if its at the bottom so put it at top
var DXF = new function(){
@@ -1410,6 +1411,8 @@ this.dxf_to_instructions = function({
var Coor = require("./Coor.js")
var Vector = require("./Vector.js")
var Kin = require("./Kin.js")
+ //var txt = require("./txt.js") //doesn't work if its at the bottom, so put it at top
+
var {dde_error, warning, point_object_to_array, scale_point} = require("../core/utils.js")
var {read_file} = require("../core/storage.js")
diff --git a/math/txt.js b/math/txt.js
index 807e9cf7..29e1ce1a 100644
--- a/math/txt.js
+++ b/math/txt.js
@@ -3117,5 +3117,5 @@ var txt = new function(){
}
}
-module.exports.txt = txt
+module.exports = txt
diff --git a/package.json b/package.json
index 44438eec..1633934a 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "dexter_dev_env",
"productName": "dexter_dev_env",
- "version": "3.3.2",
+ "version": "3.3.3",
"release_date": "May 2, 2019",
"description": "Dexter Development Environment",
"author": "Fry",
diff --git a/three-revision-83.min.js b/three-revision-83.min.js
deleted file mode 100755
index 17605a89..00000000
--- a/three-revision-83.min.js
+++ /dev/null
@@ -1,861 +0,0 @@
-// threejs.org/license
-(function(l,oa){"object"===typeof exports&&"undefined"!==typeof module?oa(exports):"function"===typeof define&&define.amd?define(["exports"],oa):oa(l.THREE=l.THREE||{})})(this,function(l){function oa(){}function C(a,b){this.x=a||0;this.y=b||0}function ea(a,b,c,d,e,f,g,h,k,m){Object.defineProperty(this,"id",{value:Oe++});this.uuid=Q.generateUUID();this.name="";this.image=void 0!==a?a:ea.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:ea.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT=
-void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:1023;this.type=void 0!==h?h:1009;this.offset=new C(0,0);this.repeat=new C(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==m?m:3E3;this.version=0;this.onUpdate=null}function ga(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function Db(a,b,c){this.uuid=Q.generateUUID();this.width=
-a;this.height=b;this.scissor=new ga(0,0,a,b);this.scissorTest=!1;this.viewport=new ga(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=1006);this.texture=new ea(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function Eb(a,b,c){Db.call(this,a,b,c);this.activeMipMapLevel=
-this.activeCubeFace=0}function da(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function q(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function H(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);0