@naanlang/naan 1.0.6 → 1.0.8

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.
Files changed (45) hide show
  1. package/LICENSE.md +3 -4
  2. package/README.md +20 -2
  3. package/bin/index.js +2 -2
  4. package/dist/env_web.js +91 -18
  5. package/dist/naan.min.js +7 -7
  6. package/frameworks/browser/browser.nlg +92 -3
  7. package/frameworks/browser/https_request.nlg +2 -2
  8. package/frameworks/browser/sworker.js +17 -17
  9. package/frameworks/browser/terminals.nlg +14 -12
  10. package/frameworks/browser/workers.nlg +13 -6
  11. package/frameworks/client/psm_client.nlg +1 -0
  12. package/frameworks/common/common.nlg +39 -8
  13. package/frameworks/node/filesystem.nlg +32 -26
  14. package/frameworks/node/gitter.nlg +9 -4
  15. package/frameworks/node/https_request.nlg +19 -14
  16. package/frameworks/project/build.nlg +187 -74
  17. package/frameworks/project/projects.nlg +42 -17
  18. package/frameworks/running/running.nlg +33 -11
  19. package/frameworks/running/taskexec.nlg +1 -1
  20. package/frameworks/storage/file_manager.nlg +2 -1
  21. package/frameworks/storage/psm.nlg +20 -4
  22. package/frameworks/storage/psm_dbtables.nlg +13 -3
  23. package/lib/browser/env_web.js +93 -20
  24. package/lib/browser/env_webworker.js +10 -0
  25. package/lib/core/naanlib.js +7 -7
  26. package/package.json +2 -1
  27. package/plugins/serviceAws/aws/aws-sdk-node.min.js +1 -1
  28. package/plugins/serviceAws/aws/aws-sdk.min.js +1 -1
  29. package/plugins/serviceAws/aws/lambda_ws_init.nlg +2 -1
  30. package/plugins/serviceAws/aws_dynamo.nlg +45 -26
  31. package/plugins/serviceAws/aws_dynextra.nlg +157 -32
  32. package/plugins/serviceAws/aws_lambda.nlg +4 -8
  33. package/plugins/serviceAws/aws_s3.nlg +74 -28
  34. package/plugins/serviceAws/aws_sqs.nlg +113 -0
  35. package/plugins/serviceAws/dbt_aws.nlg +73 -24
  36. package/plugins/serviceAws/psm_aws.nlg +30 -11
  37. package/plugins/serviceAws/serviceAws.nlg +2 -4
  38. package/plugins/serviceYC/generic_api.yaml +36 -0
  39. package/plugins/serviceYC/naanide-relay-index.js +148 -0
  40. package/plugins/serviceYC/serviceYC.nlg +59 -0
  41. package/plugins/serviceYC/yc_function.nlg +161 -0
  42. package/test/test_01_core.nlg +2 -2
  43. package/test/test_02_context.nlg +2 -2
  44. package/test/test_05_strings.nlg +11 -1
  45. package/test/test_06_lingoparse.nlg +43 -14
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
- Naan for NPM version 1.0.6-2 is released under the MIT License:
1
+ **Naan for NPM** version **1.0.8+1** is released under the MIT License:
2
2
 
3
- Copyright (c) 2017-2022 Zulch Laboratories, Inc.
3
+ Copyright (c) 2017-2023 Zulch Laboratories, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -17,5 +17,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -4,8 +4,8 @@
4
4
  Naan is an async-first software platform for rapid development.
5
5
 
6
6
  #### Release:
7
-      Naan for NPM version 1.0.6-2
8
-      Copyright (c) 2017-2022 Zulch Laboratories, Inc.
7
+      **Naan for NPM** version **1.0.8+1**
8
+      Copyright (c) 2017-2023 Zulch Laboratories, Inc.
9
9
 
10
10
  #### Features
11
11
  - **Naan** runs in NodeJS and web browsers using JavaScript
@@ -52,6 +52,24 @@ Naan prints the results of evaluating each expression with the REPL, but not
52
52
  by default with an expression or source file. The interactive flag overrides
53
53
  this to print the result of each expression in all cases.
54
54
 
55
+ ##### Example shell commands
56
+
57
+ Define a function, call it, and return the length of the base-10 result. First recursive and then tail recursive:
58
+
59
+ ```
60
+ % naan -e "function fact(x){if x>0 x*fact(x-1) else 1}(1000).length"
61
+ 2568
62
+ % naan -e "function factr(x,a){if x>0 factr(x-1,x*a) else a}(10000,1).length"
63
+ 35660
64
+ ```
65
+ Fetch your public IP from a website (NodeJS version 18 or later):
66
+
67
+ ```
68
+ % naan -e "new(await(await(js.g.fetch('http://ip.jsontest.com/')).1.json()).1)"
69
+ { ip: "64.201.122.183" }
70
+ ```
71
+
72
+
55
73
  ##### Shell scripting
56
74
 
57
75
  When installed globally, Naan can be used for shell scripts with the [Shebang](https://en.wikipedia.org/wiki/Shebang_(Unix))
package/bin/index.js CHANGED
@@ -58,11 +58,11 @@ process.argv.every((val, index) => {
58
58
  return (true);
59
59
  }
60
60
  if (val == "--version") {
61
- console.log("1.0.6");
61
+ console.log("1.0.8");
62
62
  process.exit(0);
63
63
  }
64
64
  if (val == "--buildno") {
65
- console.log("1.0.6-2");
65
+ console.log("1.0.8+1");
66
66
  process.exit(0);
67
67
  }
68
68
  if (val.substring(0,1) == "-") {
package/dist/env_web.js CHANGED
@@ -309,13 +309,75 @@ exports.NaanControllerWeb = function() {
309
309
  //
310
310
 
311
311
  this.VsiteRefresh = function VsiteRefresh(url_origin) {
312
- if (window.location.href.startsWith(url_origin)) {
312
+ if (vsiteName && window.location.href.startsWith(url_origin)) {
313
313
  window.location.reload(); // we have changed underneath
314
+ window.scroll(0,0); // Chrome 106 had flood pants 🤓
314
315
  return (true);
315
316
  }
316
317
  return (false);
317
318
  };
318
319
 
320
+ //==========================================================================
321
+ // Browser Console Terminal
322
+ //--------------------------------------------------------------------------
323
+
324
+ // Commands:
325
+ // Naanlang.debug(<text>) -- command line text entry
326
+ // Naanlang.int() -- interrupt and enter debugger
327
+ // Naanlang.detach() -- close the console terminal
328
+
329
+ var conDebTerm;
330
+
331
+ //
332
+ // ConsoleDebugTerminal
333
+ //
334
+ function ConsoleDebugTerminal() {
335
+ var termSelf = this;
336
+ //
337
+ // OnMessageOut
338
+ //
339
+ this.OnMessage = function OnMessage(msg) {
340
+ if (msg.id == "debugtext")
341
+ console.log("dbug-" + msg.level + " " + msg.text);
342
+ else if (msg.id == "textout")
343
+ console.log(msg.text);
344
+ };
345
+ //
346
+ // cmd
347
+ //
348
+ this.cmd = function cmd(keys) {
349
+ keys = keys.trim();
350
+ contSelf.Return(keys + "\n", termSelf);
351
+ return (keys);
352
+ };
353
+ //
354
+ // int
355
+ //
356
+ this.int = function int() {
357
+ contSelf.Interrupt();
358
+ };
359
+ }
360
+
361
+ //
362
+ // debug
363
+ //
364
+ function debug(text) {
365
+ if (!conDebTerm) {
366
+ conDebTerm = new ConsoleDebugTerminal();
367
+ contSelf.Attach(conDebTerm);
368
+ }
369
+ exports.debug = conDebTerm.cmd;
370
+ exports.int = conDebTerm.int;
371
+ exports.detach = function() {
372
+ contSelf.Detach(conDebTerm);
373
+ exports.debug = debug;
374
+ exports.int = undefined;
375
+ exports.detach = undefined;
376
+ conDebTerm = false;
377
+ };
378
+ return (conDebTerm.cmd(text));
379
+ }
380
+ exports.debug = debug;
319
381
 
320
382
  //==========================================================================
321
383
  // Clone Debug Interface
@@ -528,26 +590,34 @@ exports.NaanControllerWeb = function() {
528
590
  }
529
591
 
530
592
  function virtualOpen() {
531
- vsiteName = window.document.title; // consistent name at open and close
532
- if (window.opener && window.opener.Naanlang)
533
- window.opener.Naanlang.naancon.DispatchMessage({
534
- op: "VsiteOpen",
535
- name: vsiteName,
536
- naancont: contSelf,
537
- title: vsiteName + " $Version$"
538
- });
593
+ try {
594
+ if (window.opener && window.opener.Naanlang) {
595
+ vsiteName = window.document.title; // consistent name at open and close
596
+ window.opener.Naanlang.naancon.DispatchMessage({
597
+ op: "VsiteOpen",
598
+ name: vsiteName,
599
+ naancont: contSelf,
600
+ title: vsiteName + " $Version$"
601
+ });
602
+ }
603
+ } catch (e) {
604
+ }
539
605
  }
540
606
 
541
607
  function virtualClose() {
542
- if (window.opener && window.opener.Naanlang) {
543
- window.opener.Naanlang.naancon.DispatchMessage({
544
- op: "VsiteClose",
545
- name: vsiteName,
546
- naancont: contSelf,
547
- title: vsiteName + " $Version$"
548
- });
549
- termTextOut("\x1b[90m\x1b[3m".concat("\nwindow closed", "\x1b[0m\n"));
608
+ try {
609
+ if (window.opener && window.opener.Naanlang) {
610
+ window.opener.Naanlang.naancon.DispatchMessage({
611
+ op: "VsiteClose",
612
+ name: vsiteName,
613
+ naancont: contSelf,
614
+ title: vsiteName + " $Version$"
615
+ });
616
+ termTextOut("\x1b[90m\x1b[3m".concat("\nwindow closed", "\x1b[0m\n"));
617
+ }
618
+ } catch (e) {
550
619
  }
620
+ vsiteName = false; // window is going away
551
621
  }
552
622
 
553
623
  /*jshint sub:true */
@@ -556,7 +626,10 @@ exports.NaanControllerWeb = function() {
556
626
  naanlib.banner();
557
627
  var hostpath = naanlib.js.r("path").dirname(window.location.href);
558
628
  naanlib.start({
559
- cmd: 'Naan.module.webparse("naan_init.nlg", "' + hostpath + '"' + ');;\r\n'
629
+ cmd: 'App.version = "$Version$";;\r\n'
630
+ + 'App.cache = "$CacheBuster$";;\r\n'
631
+ + 'Naan.module.requireQuery({ naanver: App.cache });;\r\n'
632
+ + 'Naan.module.webparse("naan_init.nlg", "' + hostpath + '", { naanver: App.cache });;\r\n'
560
633
  });
561
634
  } else {
562
635
  if (!replstate) { // saved state but never opened a terminal