Giter Club home page Giter Club logo

js-eden's Introduction

Construit Build Status

Either use our hosted version at http://jseden.dcs.warwick.ac.uk/construit or you can download JS-Eden from the github releases page and use it off-line.

Local Installation

Reasons to install locally?

  1. You prefer not to allow students internet access.
  2. Have a poor/unreliable internet connection.
  3. Wish to access local hardware such as Arduino.

A locally installed version can still connect to the online repository if there is an internet connection, but it will work without this and is presented as a desktop application instead of a web-site.

Download the latest release and extract it from the zip or tar.gz. If there is a binary version (for linux) then you can use this directly. Otherwise:

Windows

Install Node.js version 6.10 or newer. Install Git.

Afterwards, open a PowerShell in Administrator mode and cd into the folder extracted from the download and enter the following commands.

npm install -g windows-build-tools
npm install

If the above command produces an error then you may need to install Windows SDK 8.1 and try it again.

And to start Construit use:

npm start

We suggest you then make a desktop shortcut which does npm start in the correct working directory.

Linux

Either:

apt-get install npm
apt-get install git

or

dnf install npm
dnf install git

Then cd into the extracted jseden folder and run:

npm install

To start Construit run the following in the jseden directory

npm start

Arduino

If an Arduino is connected (by USB at present) then it should prompt you when you start js-eden. You must first have uploaded our firmware to the device using the Arduino IDE. The sketch file can be found in plugins/arduino/sketch.c.

Observables starting with arduino_ are created to correspond to pins on the device or configuration. For example:

arduino_d13 is ledOn;

Developers

A developer should fork the git repo or use git clone to get the latest but unstable version. Then, with nodejs installed, do an npm install.

You can then either test using the local app version with npm start or use npm run devserver to start a local web server on port 8000.

js-eden's People

Contributors

cranman avatar dependabot[bot] avatar elizabethhudnott avatar itsmonktastic avatar jonnyf avatar knicos avatar ruthrainbow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-eden's Issues

Inject script tags for include()

Currently we're using XHR for fetching EDEN code when include() is called. This works well in a hosted environment but when you're JsEden locally it forces you to have a webserver installed. If instead, the mechanism worked by injecting a script tag pointing to the file to be included, and a callback given on finishing loading this, it could work without requiring a webserver.

I think jQuery.getScript achieves this trivially: http://api.jquery.com/jQuery.getScript/

Ruby location set to DCS

The rb and rhtml files have ruby set in a dcs specific location that does not work on a standard non-dcs setup without modification.

Mutable values should be copied to prevent modification to shared data

E.g. right now

x = y = [1, 2, 3];
x[1] = 4;

In JS-Eden x and y refer to the same array, but in tkeden the modification to x isn't seen in y, they are totally separate values. The latter is the ideal behaviour when using dependency and agency, e.g.

x = [1, 2, 3];
y is x;
proc p : y { writeln("y changed"); }

Modifying x will silently cause changes to y, but p will not see the change because it was due to aliasing, not dependency or agency.

Next button in inputwindow does not work

It is possible to go backwards through commands with the "previous" button, but not forwards through them with the "next" button.

chromium (linux amd64)
Version 28.0.1500.52 Ubuntu 13.04 (28.0.1500.52-0ubuntu1.13.04.2)
js-eden v0.4.1-8-g74ab

include not working again

Example 1:

include("https://raw.githubusercontent.com/mudcube/MIDI.js/master/js/MIDI/AudioDetect.js");

JavaScript console response:

XMLHttpRequest cannot load https://raw.githubusercontent.com/mudcube/MIDI.js/master/js/MIDI/AudioDetect.js. The 'Access-Control-Allow-Origin' header has a value 'https://render.githubusercontent.com' that is not equal to the supplied origin. Origin 'http://emgroup.github.io' is therefore not allowed access.

Example 2:

include("http://mrcoles.com/piano/audio.js");

Response:

XMLHttpRequest cannot load http://mrcoles.com/piano/audio.js. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://emgroup.github.io' is therefore not allowed access.

JS-EDEN version: http://emgroup.github.io/js-eden/
Browser: Chrome 38.0.2125.111 m
OS: WIndows 7

Parsing Problem with Modulus (%) Operator

Test case:

b = 3;
writeln(5%b);

Result in github.io version: A parsing error message appears and afterwards the "Submit" button no longer functions to submit any further scripts. If a space is inserted after the % operator then the error does not occur. If the observable name b is replaced with a number then the error does not occur.

Result in construit version: The number 2 is written in the status bar, as expected.

Support notation switching

If we want to support further TkEden notations then some work needs to be done to support notation switching, e.g:

%eden
x = 2;

%donald
line l

This could be done by generating some kind of "higher order" parser that looks for tokens like %eden and hand off everything else to other parsers stored in an associative array:

parsers[notationName](code);

"...\\" doesn't parse

String literals terminating in a backslash escape sequence are not parsing correctly.

Example:

s = "";
writeln(s);

Result: parsing error message
Expected result: s should be the string containing a single backslash character.

Assigning a Function to an Observable Exposes Internals in Symbol List and Loses EDEN Definition

I don't know if this problem can be easily fixed but I'm going to log it's existence here anyway.

Example:

func f {
return 1;
}

g = f;

The symbol list displays:

g = function () { var args = new Symbol().assign(Array.prototype.slice.call(arguments)); return 1;}

Expected result:

The EDEN definition should be preserved, as if the following code had been executed.

func g {
return 1;
}

Taking care to relabel any recursive function calls appropriately.

Reduce Reduce Conflict in Eden translator

There is a R/R conflict in the Eden translator that causes sadness when trying to load the jugs model.

Good start to tackling this would be to update Jison so that we can get better output about the problem, and see if we can get rid of it.

Should not be able to use `is` with identifiers declared as auto.

The following code:

func f {
  auto x;
  x = 2;
  x is z;
}

In tkeden this is a parse error, in jseden the x is z the x is a global observable. This is confusing, in that the x inside the function can refer to two different things. It should be an error to try to use is with an auto.

Session Sharing

Support for sessions as a means of saving models and for collaborative development. Sessions need to be listed with projects and can become projects once saved and made static. New sessions can be blank or based upon an existing session/project. Sessions can also be deleted.

Precedence of ternary operator

Consider the result of the expression:

n = 2;
nmod3 = (n%3>=0) ? n%3 : 3+n%3;

In tkeden and http://jseden.dcs.warwick.ac.uk/construit/# nmod3 is assigned the value 2. In GitHub master it is assigned the value 4. This is equivalent to interpreting the right-hand side as:

((n%3>=0) ? n%3 : 3)+n%3

2 is the preferred result, intuitively, for compatibility with tkeden and older versions of JS-Eden and in line with other languages such as C (I think).

Triggered actions should fire immediately if they observe a defined observable

Requires #29 first.

This should have no output (which is currently true for JS-Eden):

proc p : a { writeln("a = " // str(a)); }

This should output "a = @" (not yet true for JS-Eden):

a = @;
proc p : a { writeln("a = " // str(a)); }

In JS-Eden, triggered actions currently don't fire until the first change to the observables they observe.

New bugs introduced in release 0.5.1

When running on the localhost using jseden-dev-server.js I get the following text displayed in an alert() popup in the browser, "SecurityError: failed to read the 'localStorage' property from 'Window': Access is denied for this document", and the JS-EDEN environment fails to initialize itself into a workable state (no input window).

Comment Characters Within Strings Parsed as Comment Characters

Example:

s = "##foo";

Result in JS-EDEN:

JS-EDEN produces a parsing error regarding a supposed missing semicolon. The semicolon that's present has been mistakenly perceived as being commented out.

Result in tkeden:

The code parses and when executed s is assigned the string containing two hash characters followed by the word foo.

Report error when include results in 404

E.g.

include("doesnotexist.jse");

Currently just puts "Loading doesnotexist.jse" into the top status bar. We should report an error using Eden.prototype.error that there was a problem fetching the included file.

Saved Views

Need to save regex searches as different views, ideally these would be saved on the server and work with session sharing.

Observables should have a concept of 'not yet defined'

In tkeden you can query to see all observables including "observables not yet defined". So e.g. you can do:

x = y;

At this point, x and y both have the value @, the difference is that y is "yet to be defined". This is different to completely unreferenced observables, e.g. z doesn't show up as an observable, and if you forget(&y); then y will show up in the list of observables either.

I think we can use the last modified by which tracks the last agent to modify, already existing on Symbol, but it will require some tests to make sure it works.

_view_xxx observables not forgotten when a view is discarded

I notice that when a view is closed using the new style X button (either on the window title bar or the Windows menu) it's _view_xxx observables still show up in Symbol List windows afterwards. I'm curious as to why that should be the case, since without the view existing anymore these observables don't have any active functionality anymore.

At first I wondered what would happen if I were to somehow create another view with the same name as the no longer existing one using createView. Would the new view be initialized to appear in the same position the old one was in when it was destroyed? Could that be a good reason for keeping the _view_xxx observables around?

I tried it out.

(1) I created a Symbol List view.
(2) I destroyed it using the X button on the view's title bar.
(3) I executed createView("view_0", "PlainHTML");

The following strange things happened.
(1) The Symbol List view reappeared, despite having previously been removed from both the "desktop" and the Windows menu.
(2) Additionally a new HTML view also appeared, though in the default position, not the position specified by the _view_view_0_xxx observables.
(3) A new entry appeared in the Windows menu that read "view_0 [PlainHTML]".
(4) Hovering over that new entry in the Windows menu highlighted the Symbol List view and not the HTML view.
(5) A subsequent assignment to the _view_view_0_width altered the size of the Symbol List view, not the HTML view.

Supporting tkeden's autocalc

In tkeden it is possible to prevent notification of dependencies and triggered actions of changes. E.g.

x is y;
y = "hello";
autocalc = 0;
y = "goodbye";
writeln(x);

prints out "goodbye".

Currently this isn't possible in JsEden. The solution is to have a single place for notifications to be buffered and fired depending on a setting (which could be made accessible via autocalc).

Combobox state loss

Every canvas redraw regenerates the options list causing the currently selected option to be reset.

forget function confuses script generator

Suspicious test case:

proc p : x {
y = x + 1;
}

x = 1;

At this point the system state contains:
x = 1;
y = 2;
and the definition of p.

Now proceed with:

forget("p");

The state now contains x = 1, y = 2 but no longer contains p. Now use the script generator plug-in to generate a script. The generated script only contains a definition for x and is not sufficient to restore the current value of y.

Symbol lookup table sometimes fails to update

e.g. enter these individually into the input window

x is b+c; ## (Successful)
x=23; ## (Successful)
x is b+c+1; ## (Successful)
x = 23; ## (Successful)

If you inspect the observable x in the SLT during this sequence of definitions, you will see that the original definition of x is still displayed after the explicit assignment to x has been made, so that the fact that x is no longer defined implicitly isn't registered. As far as the SLT is concerned, it appears that you can happily change the definition of x, but you can't change it to an explicity defined value.

Use new symbol table and code editor in JsEden interface

This page: http://trmonks.me.uk/projects/js-eden/timer.html has several things that http://trmonks.me.uk/projects/js-eden/eden.html could do with using. E.g. a sensibly implemented symbol table that only gets updates to the parts that have changed (instead of recreating the whole table), and a code editor with basic syntax highlighting and automatic indentation.

It might be easier to go the other way round and add more stuff to something like timer.html, e.g. a window for drawing donald, error reporting...

Procedures triggered for non-existent mouse pointer positions

From Peter Tomcsanyi

I wrote this code to allow the user to draw freehand:

old = 0;
picture = [];
proc pt:mouseX,mouseY {
  auto p;
  if (mousePressed) {
    p = Point(mouseX,mouseY);
    if (old != 0) {
      picture = picture // [Line(old.x,old.y,p.x,p.y)];
    }
    old = p;
  }
}

It is quite simple (but still needs some understanding of if statement and curly brackets) and I would suggest to use it as an introduction to handling mouse events (well, after the problem mentioned below will be corrected).
But the problem is that the lines are "steppy" (you can see better what I mean if you try out the code).
During the C1 meeting I have shown it to Elizabeth.
The point seems to be that whenever both the mouseX and mouseY coordinates change the proc pt is called twice - in the first call only mouseX has the new value and then in the second call also the mouseY has the new value. The result is a "step" (e.g. to west and then to the north) instead of a "diagonal" (to northwest).
I made a workaround that uses only each other event but it is then not so easy to explain:

old = 0;
picture = [];
n = 0;
proc pt:mouseX,mouseY {
  auto p;
  if (mousePressed && (n % 2 == 1)) {
    p = Point(mouseX,mouseY);
    if (old != 0) {
      picture = picture // [Line(old.x,old.y,p.x,p.y)];
    }
    old = p;
  }
  n = n+1;
}

So maybe mouseX and mouseY should be treated as a special "atomic" couple that is never being updated partly (or maybe it should be a Point value called MousePos to be compatible with mouseDown and mouseUp?).

ADM Plugin Doesn't Immediately Display as "loaded" When Loading via Plugin Listing View

Steps to reproduce:

  1. Open a Plugin Listing view
  2. Click on ADM

The ADM views are accessible from the New menu but the ADM still shows as "not loaded" in the Plugin Listing view. If you subsequently close the Plugin Listing view and open another Plugin Listing view then the ADM then shows as "loaded". The loaded status of other plugins (e.g. the State Listener plug-in) updates immediately when you click to load those plug-ins.

List comparisons bug

List pointers are being compared in javascript, not the contents. Similarly a list copy will copy the pointer and so shift modifications will affect both. Solution would be to iteratively compare and full copy.

Calling undefined functions

In tkeden if we define an observable in terms of something that doesn't yet exist, e.g.

a is f(2);
b = 10;

Then a takes the value @, and the next line causes b to take the value 10.

In JsEden the first line causes an type error when trying to call the value "undefined" as a function, so b remains undefined after attempting to execute these statements.

This can be fixed by changing the translator to use a higher order function for function calls so the following eden code:

f(2);

is translated to JavaScript like so:

call(f, 2);

call would then return undefined in cases where f were undefined.

Dealing with a chain of potentially failing operations might be more generalisable (basically Maybe monad!) but for now this would be cool.

Forgotten symbols persisting in the symbol list, observable list, etc

Steps to reproduce:

Declare, say for example:

x = 2;

Then bring up either a symbol list view or an observable list view and find x in the list.

Then issue the statement:

forget("x");

Notice that after executing the above statement x remains listed in the symbol list (or observable list) even though x no longer exists in the symbol table.

If you then subsequently refresh the symbol list by altering the regular expression specifying the symbols to search for then x disappears from view and will not appear again (unless x is subsequently redefined).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.