@naanlang/naan 1.0.7 → 1.0.9

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 (50) 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 +86 -17
  5. package/dist/naan.min.js +7 -7
  6. package/frameworks/browser/browser.nlg +27 -3
  7. package/frameworks/browser/sworker.js +17 -17
  8. package/frameworks/browser/terminals.nlg +1 -1
  9. package/frameworks/browser/workers.nlg +8 -1
  10. package/frameworks/client/psm_client.nlg +2 -1
  11. package/frameworks/common/common.nlg +34 -6
  12. package/frameworks/node/filesystem.nlg +40 -33
  13. package/frameworks/node/gitter.nlg +9 -4
  14. package/frameworks/node/https_request.nlg +19 -14
  15. package/frameworks/node/psm_server.nlg +3 -3
  16. package/frameworks/project/build.nlg +182 -73
  17. package/frameworks/project/proj_console.nlg +1 -1
  18. package/frameworks/project/proj_lambda.nlg +1 -1
  19. package/frameworks/project/projects.nlg +5 -5
  20. package/frameworks/running/debugnub.nlg +1 -1
  21. package/frameworks/running/executors.nlg +1 -1
  22. package/frameworks/running/running.nlg +32 -10
  23. package/frameworks/running/sourcecode.nlg +2 -2
  24. package/frameworks/storage/csv.nlg +2 -2
  25. package/frameworks/storage/dbt_pouch.nlg +1 -1
  26. package/frameworks/storage/psm.nlg +21 -5
  27. package/frameworks/storage/psm_dbtables.nlg +4 -4
  28. package/frameworks/storage/resources.nlg +3 -2
  29. package/lib/browser/env_web.js +90 -21
  30. package/lib/core/naanlib.js +7 -7
  31. package/package.json +1 -1
  32. package/plugins/serviceAws/aws/aws-sdk-node.min.js +1 -1
  33. package/plugins/serviceAws/aws/aws-sdk.min.js +1 -1
  34. package/plugins/serviceAws/aws/lambda_ws_init.nlg +2 -1
  35. package/plugins/serviceAws/aws_dynamo.nlg +36 -29
  36. package/plugins/serviceAws/aws_dynextra.nlg +110 -5
  37. package/plugins/serviceAws/aws_lambda.nlg +4 -8
  38. package/plugins/serviceAws/aws_sqs.nlg +113 -0
  39. package/plugins/serviceAws/dbt_aws.nlg +2 -2
  40. package/plugins/serviceAws/serviceAws.nlg +1 -1
  41. package/plugins/serviceYC/generic_api.yaml +36 -0
  42. package/plugins/serviceYC/naanide-relay-index.js +148 -0
  43. package/plugins/serviceYC/serviceYC.nlg +59 -0
  44. package/plugins/serviceYC/yc_function.nlg +161 -0
  45. package/test/harness.nlg +2 -1
  46. package/test/test_01_core.nlg +2 -2
  47. package/test/test_02_context.nlg +2 -2
  48. package/test/test_05_strings.nlg +13 -1
  49. package/test/test_06_lingoparse.nlg +49 -14
  50. package/test/test_07_lingo.nlg +9 -9
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * column positioning: // // !
9
9
  *
10
- * Copyright (c) 2017-2021 by Richard C. Zulch
10
+ * Copyright (c) 2017-2023 by Richard C. Zulch
11
11
  *
12
12
  */
13
13
 
@@ -248,8 +248,8 @@ closure MakePSMutil(fs, local util) {
248
248
  // erase: <boolean> -- remove extraneous files in destination folders
249
249
  // force: <boolean> -- copy files even if older (default is only copy if new/newer)
250
250
  // follow: <boolean> -- follow links instead of treating them as files
251
- // preserve: <boolean> -- preserve file info where possible
252
- // (e.g. mtime/atime/mode/uid/gid on NodeJS)
251
+ // idmode: <boolean> -- preserve id/mode where possible
252
+ // times: <boolean> -- preserve time where possible
253
253
  // }
254
254
  //
255
255
  // Limitations:
@@ -336,7 +336,8 @@ closure MakePSMutil(fs, local util) {
336
336
  //
337
337
  // Pass 3 - copy files and links
338
338
  //
339
- asyncArray(copies, 10, closure cpfiles(entry, index, elements, local error, data, instat, outstat) {
339
+ asyncArray(copies, 10, closure cpfiles(entry, index, elements,
340
+ local error, data, dest, instat, outstat) {
340
341
  `(error, instat) = fs.info(entry.source, fsopt)
341
342
  if !error {
342
343
  `(error, outstat) = outfs.info(entry.dest)
@@ -348,6 +349,13 @@ closure MakePSMutil(fs, local util) {
348
349
  error = Error("deepcopy: can't overwrite", entry.dest)
349
350
  else if instat.type == "symlink" && !options.follow {
350
351
  `(error, data) = fs.readlink(entry.source)
352
+ if !error {
353
+ `(error, dest) = outfs.readlink(entry.dest) // get destination to compare links
354
+ if dest == data
355
+ return // symlink unchanged
356
+ outfs.delete(entry.dest)
357
+ error = false // ignore any destination errors
358
+ }
351
359
  if !error
352
360
  `(error, data) = outfs.symlink(data, entry.dest)
353
361
  }
@@ -355,8 +363,16 @@ closure MakePSMutil(fs, local util) {
355
363
  `(error, data) = fs.readFile(entry.source, { encoding: "binary"})
356
364
  if !error
357
365
  `(error, data) = outfs.writeFile(entry.dest, data, { encoding: "binary"})
358
- if !error && options.preserve
366
+ if !error && (options.idmode || options.times) {
367
+ if !options.idmode
368
+ instat.mode = instat.uid = instat.gid = false
369
+ if !options.times {
370
+ instat.mtimeMs = instat.mtime = false
371
+ instat.nodejs_stat.mtimeMs = instat.nodejs_stat.mtime = false
372
+ instat.nodejs_stat.atimeMs = instat.nodejs_stat.atime = false
373
+ }
359
374
  `(error) = outfs.setInfo(entry.dest, instat)
375
+ }
360
376
  }
361
377
  }
362
378
  if error
@@ -380,7 +396,7 @@ closure MakePSMutil(fs, local util) {
380
396
  *
381
397
  */
382
398
 
383
- closure MakePSM(dbname, local psm) {
399
+ closure MakePSM(dbname) {
384
400
  ResourceManager(dbname, "PSM_locations/")
385
401
  };
386
402
 
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * column positioning: // // !
8
8
  *
9
- * Copyright (c) 2020-2021 by Richard C. Zulch
9
+ * Copyright (c) 2020-2023 by Richard C. Zulch
10
10
  *
11
11
  */
12
12
 
@@ -36,7 +36,7 @@
36
36
  *
37
37
  */
38
38
 
39
- closure FSview(table, rootpath, local view, error) {
39
+ closure FSview(table, rootpath, local view) {
40
40
  if !table
41
41
  return (list(Error("invalid arguments")))
42
42
  view = new(object, this)
@@ -676,7 +676,7 @@ closure FSview(table, rootpath, local view, error) {
676
676
  }
677
677
  children: []
678
678
  }
679
- dbDirRecords(path, false, function(error, data, local item, result, slashdex, offset, finfo) {
679
+ dbDirRecords(path, false, function(error, data, local item, slashdex, offset, finfo) {
680
680
  if error
681
681
  return (callback(error))
682
682
  if data.rows.length == 0 && path != ""
@@ -716,7 +716,7 @@ closure FSview(table, rootpath, local view, error) {
716
716
  //
717
717
  // Read a directory at the specified path
718
718
 
719
- view.readir = closure readir(path, callback, local name, dirdict) {
719
+ view.readir = closure readir(path, callback) {
720
720
  dirList(path, { stat: true }, callback)
721
721
  }
722
722
 
@@ -181,9 +181,10 @@ closure ResourceManager(dbname, prefix, local reman, watch, result) {
181
181
  //
182
182
  // Return an array of labels for the registered connectors.
183
183
  reman.labels = function labels(local classID, labels) {
184
+ debuglog("ResourceManager.labels is broken")
184
185
  labels = []
185
186
  for remanID in reman.conns.*
186
- labels.push(reman.conns[classID].label)
187
+ labels.push(reman.conns[classID].label) // ### classID?
187
188
  labels
188
189
  }
189
190
 
@@ -329,7 +330,7 @@ closure ResourceTracker(reman, local retor, watch) {
329
330
  //
330
331
  // Update credentials for accessing a resource, returning the added credential record.
331
332
 
332
- retor.updateResource = function updateResource(resID, resource, local error, classI) {
333
+ retor.updateResource = function updateResource(resID, resource, local error, classID) {
333
334
  `(error, classID) = resourceClassID(resID)
334
335
  if error
335
336
  list(error)
@@ -311,11 +311,73 @@ exports.NaanControllerWeb = function() {
311
311
  this.VsiteRefresh = function VsiteRefresh(url_origin) {
312
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
@@ -458,7 +520,7 @@ exports.NaanControllerWeb = function() {
458
520
  statedoc.curversion = kStateCurrentVersion;
459
521
  statedoc.firstver = kStateFirstVersion;
460
522
  statedoc.licensee = "MIT-License";
461
- statedoc.verstring = "1.0.7+1";
523
+ statedoc.verstring = "1.0.9+1";
462
524
  statedoc.date = new Date().toISOString();
463
525
  statedoc.prefs = prefs;
464
526
  statedoc.naan = naanlib.saveState(false); // true to optimize, which is a bit slower
@@ -476,7 +538,7 @@ exports.NaanControllerWeb = function() {
476
538
  || statedoc.firstver > kStateCurrentVersion
477
539
  || statedoc.curversion < kStateFirstVersion
478
540
  || statedoc.licensee != "MIT-License"
479
- || statedoc.verstring != "1.0.7+1")
541
+ || statedoc.verstring != "1.0.9+1")
480
542
  {
481
543
  localStorage.removeItem("NaanState_Hosted");
482
544
  return (false);
@@ -528,27 +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 + " 1.0.7+1"
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 + " 1.0.9+1"
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 + " 1.0.7+1"
548
- });
549
- vsiteName = false; // window is going away
550
- 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 + " 1.0.9+1"
615
+ });
616
+ termTextOut("\x1b[90m\x1b[3m".concat("\nwindow closed", "\x1b[0m\n"));
617
+ }
618
+ } catch (e) {
551
619
  }
620
+ vsiteName = false; // window is going away
552
621
  }
553
622
 
554
623
  /*jshint sub:true */
@@ -557,8 +626,8 @@ exports.NaanControllerWeb = function() {
557
626
  naanlib.banner();
558
627
  var hostpath = naanlib.js.r("path").dirname(window.location.href);
559
628
  naanlib.start({
560
- cmd: 'App.version = "1.0.7+1";;\r\n'
561
- + 'App.cache = "cb-1.0.7+1";;\r\n'
629
+ cmd: 'App.version = "1.0.9+1";;\r\n'
630
+ + 'App.cache = "56a3661c1caa5c6ed3781ffcad84acf4";;\r\n'
562
631
  + 'Naan.module.requireQuery({ naanver: App.cache });;\r\n'
563
632
  + 'Naan.module.webparse("naan_init.nlg", "' + hostpath + '", { naanver: App.cache });;\r\n'
564
633
  });