linny-r 1.1.14 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,6 +13,9 @@ so as to be platform-independent and 100% transparent open source (under the MIT
13
13
  The software comprises a server that runs on **Node.js**,
14
14
  and a graphical user interface (GUI) that runs in any modern browser.
15
15
 
16
+ These <a href="https://sysmod.tbm.tudelft.nl/linny-r/docs/?68" target="_blank">instruction videos</a>
17
+ published on YouTube give an idea of what Linny-R can do.
18
+
16
19
  User documentation for Linny-R is still scant, but it is growing. You can contribute yourself (in "wiki fashion")
17
20
  via the official user documentation site <a href="https://linny-r.info" target="_blank">https://linny-r.info</a>.
18
21
  Technical documentation will be developed on GitHub: https://github.com/pwgbots/linny-r/wiki
@@ -22,7 +25,7 @@ Technical documentation will be developed on GitHub: https://github.com/pwgbots/
22
25
  Linny-R is developed as a JavaScript package, and requires that **Node.js** is installed on your computer.
23
26
  This software can be downloaded from <a href="https://nodejs.org" target="_blank">https://nodejs.org</a>.
24
27
  Make sure that you choose the correct installer for your computer.
25
- Linny-R is developed using the _current_ release. Presently (October 2022) this is 18.11.0.
28
+ Linny-R is developed using the _current_ release. Presently (October 2022) this is 19.0.0.
26
29
 
27
30
  Run the installer and accept the default settings.
28
31
  There is **no** need to install the optional _Tools for Native Modules_.
@@ -33,7 +36,7 @@ Verify the installation by typing:
33
36
 
34
37
  ``node --version``
35
38
 
36
- The response should be the version number of Node.js, for example: v18.11.0.
39
+ The response should be the version number of Node.js, for example: v19.0.0.
37
40
 
38
41
  ## Installing Linny-R
39
42
  It is advisable to install Linny-R in a directory on your computer, not in a cloud.
@@ -166,8 +169,8 @@ Open the Command Line Interface (CLI) of your computer, change to your `WORKING_
166
169
  This response should be something similar to:
167
170
 
168
171
  <pre>
169
- Node.js server for Linny-R version 1.1.11
170
- Node.js version: v18.11.0
172
+ Node.js server for Linny-R version 1.1.14
173
+ Node.js version: v19.0.0
171
174
  ... etc.
172
175
  </pre>
173
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linny-r",
3
- "version": "1.1.14",
3
+ "version": "1.1.16",
4
4
  "description": "Executable graphical language with WYSIWYG editor for MILP models",
5
5
  "main": "server.js",
6
6
  "scripts": {
package/server.js CHANGED
@@ -77,7 +77,8 @@ function getVersionInfo() {
77
77
  }
78
78
  try {
79
79
  const
80
- json = child_process.execSync('npm show linny-r time version --json'),
80
+ json = child_process.execSync(
81
+ 'npm show linny-r time version --json', {timeout: 1000}),
81
82
  obj = JSON.parse(json);
82
83
  info.latest = obj.version;
83
84
  info.latest_time = new Date(Date.parse(obj.time[info.latest]));
@@ -433,7 +434,7 @@ function repositoryByName(name) {
433
434
  while(rbn.length < 2) rbn.push('');
434
435
  if(rbn[0] === name) return rbn;
435
436
  }
436
- console.log(`ERROR: Repository "${name}" not found`);
437
+ console.log(`ERROR: Repository "${name}" not registered on this computer`);
437
438
  return false;
438
439
  }
439
440
 
@@ -476,7 +477,7 @@ function repoAdd(res, sp) {
476
477
  url = 'https://' + (url ? url.trim() : '');
477
478
  let i = url.length - 1;
478
479
  while(url[i] === '/') i--;
479
- url = url.substring(0, i);
480
+ url = url.substring(0, i+1);
480
481
  try {
481
482
  test = new URL(url);
482
483
  } catch(err) {
@@ -485,12 +486,13 @@ function repoAdd(res, sp) {
485
486
  // Error callback function is used twice, so define it here
486
487
  const noConnection = (error, res) => {
487
488
  console.log(error);
488
- servePlainText(res, 'ERROR: Failed to connect to ' + url);
489
+ servePlainText(res, connectionErrorText('Failed to connect to ' + url));
489
490
  };
490
491
  // Verify that the URL points to a Linny-R repository
491
492
  postRequest(url, {action: 'id'},
492
493
  // The `on_ok` function
493
494
  (data, res) => {
495
+ data = data.toString();
494
496
  // Response should be the URL of the repository
495
497
  if(data !== url) {
496
498
  servePlainText(res, 'WARNING: Not a Linny-R repository');
@@ -504,6 +506,7 @@ function repoAdd(res, sp) {
504
506
  postRequest(url, {action: 'access', repo: rname, token: token},
505
507
  // The `on_ok` function
506
508
  (data, res) => {
509
+ data = data.toString();
507
510
  if(data !== 'Authenticated') {
508
511
  servePlainText(res, data);
509
512
  return;
@@ -511,7 +514,7 @@ function repoAdd(res, sp) {
511
514
  list = fs.readFileSync(
512
515
  WORKSPACE.repositories, 'utf8').split('\n');
513
516
  for(let i = 0; i < list.length; i++) {
514
- nu = entry.trim().split('|');
517
+ const nu = list[i].trim().split('|');
515
518
  if(nu[0] !== 'local host') {
516
519
  if(nu[0] == rname) {
517
520
  servePlainText(res,
@@ -594,8 +597,8 @@ function repoDir(res, rname) {
594
597
  // The `on_error` function
595
598
  (error, res) => {
596
599
  console.log(error);
597
- servePlainText(res,
598
- `ERROR: Failed to access remote repository "${rname}"`);
600
+ servePlainText(res, connectionErrorText(
601
+ `Failed to access remote repository "${rname}"`));
599
602
  },
600
603
  res);
601
604
  } else {
@@ -749,7 +752,7 @@ function repoAccess(res, rname, rtoken) {
749
752
  // The `on_error` function
750
753
  (error, res) => {
751
754
  console.log(error);
752
- servePlainText(res, 'ERROR: Failed to connect to' + r[1]);
755
+ servePlainText(res, connectionErrorText('Failed to connect to' + r[1]));
753
756
  },
754
757
  res);
755
758
  }
@@ -806,7 +809,7 @@ function repoStore(res, rname, mname, mxml) {
806
809
  // The `on_error` function
807
810
  (error, res) => {
808
811
  console.log(error);
809
- servePlainText(res, 'ERROR: Failed to connect to' + r[1]);
812
+ servePlainText(res, connectionErrorText('Failed to connect to' + r[1]));
810
813
  },
811
814
  res);
812
815
  } else {
@@ -868,7 +871,7 @@ function loadData(res, url) {
868
871
  getTextFromURL(url,
869
872
  (data, res) => servePlainText(res, data),
870
873
  (error, res) => servePlainText(res,
871
- `ERROR: Failed to get data from <tt>${url}</tt>`),
874
+ connectionErrorText(`Failed to get data from <tt>${url}</tt>`)),
872
875
  res);
873
876
  } catch(err) {
874
877
  console.log(err);
@@ -1376,6 +1379,10 @@ function formData(obj) {
1376
1379
  return fields.join('&');
1377
1380
  }
1378
1381
 
1382
+ function connectionErrorText(msg) {
1383
+ return 'WARNING: ' + msg + ' - Please check your internet connection';
1384
+ }
1385
+
1379
1386
  //
1380
1387
  // Functions used during initialization
1381
1388
  //
@@ -2019,10 +2019,9 @@ class LinnyRModel {
2019
2019
  this.timeout_period = Math.max(0,
2020
2020
  safeStrToInt(nodeContentByTag(node, 'timeout-period')));
2021
2021
  // Legacy models have tag "optimization-period" instead of "block-length"
2022
- const bl_tag = nodeContentByTag(node, 'block-length') ||
2022
+ const bl_str = nodeContentByTag(node, 'block-length') ||
2023
2023
  nodeContentByTag(node, 'optimization-period');
2024
- this.block_length = Math.max(1,
2025
- safeStrToInt(nodeContentByTag(node, bl_tag)));
2024
+ this.block_length = Math.max(1, safeStrToInt(node, bl_str));
2026
2025
  this.start_period = Math.max(1,
2027
2026
  safeStrToInt(nodeContentByTag(node, 'start-period')));
2028
2027
  this.end_period = Math.max(1,