@naanlang/naan 1.4.0 → 1.4.1

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 (39) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +1 -1
  3. package/bin/index.js +25 -15
  4. package/dist/naan.min.js +5 -5
  5. package/frameworks/browser/sworker.js +23 -23
  6. package/frameworks/browser/terminals.nlg +1 -1
  7. package/frameworks/client/psm_client.nlg +2 -0
  8. package/frameworks/client/relaycon.nlg +1 -1
  9. package/frameworks/common/common.nlg +5 -2
  10. package/frameworks/node/filesystem.nlg +5 -4
  11. package/frameworks/node/psm_server.nlg +1 -1
  12. package/frameworks/node/shell.nlg +134 -0
  13. package/frameworks/node/worker.nlg +1 -1
  14. package/frameworks/project/build.nlg +1 -1
  15. package/frameworks/project/projects.nlg +1 -1
  16. package/frameworks/running/debugnub.nlg +102 -12
  17. package/frameworks/running/debugutil.nlg +30 -13
  18. package/frameworks/running/running.nlg +2 -2
  19. package/frameworks/running/sourcecode.nlg +3 -1
  20. package/frameworks/storage/dbt_pouch.nlg +29 -16
  21. package/frameworks/storage/file_manager.nlg +1 -1
  22. package/frameworks/storage/psm_dbtables.nlg +21 -22
  23. package/frameworks/storage/resources.nlg +12 -4
  24. package/frameworks/storage/storage.nlg +2 -2
  25. package/lib/browser/env_web.js +6 -6
  26. package/lib/core/naanlib.js +5 -5
  27. package/package.json +1 -1
  28. package/plugins/gitClient/gitClient.nlg +3 -3
  29. package/plugins/openSearch/openSearch.nlg +2 -2
  30. package/plugins/serviceAws/psm_aws.nlg +4 -2
  31. package/plugins/serviceAws/serviceAws.nlg +1 -1
  32. package/plugins/serviceGC/gc_api.nlg +4 -4
  33. package/plugins/serviceGitHub/serviceGitHub.nlg +1 -1
  34. package/plugins/serviceGitLab/psm_gitlab.nlg +1 -1
  35. package/plugins/serviceGitLab/serviceGitLab.nlg +1 -1
  36. package/test/harness.nlg +9 -9
  37. package/test/test_01_core.nlg +24 -2
  38. package/test/test_02_context.nlg +1 -1
  39. package/plugins/serviceGC/russian_trusted_root_ca_pem.crt +0 -33
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * column positioning: // // !
8
8
  *
9
- * Copyright (c) 2021 by Richard C. Zulch
9
+ * Copyright (c) 2021-2024 by Richard C. Zulch
10
10
  *
11
11
  */
12
12
 
@@ -260,24 +260,33 @@ closure DebugRemote(commander, local remoter, here, there, library) {
260
260
  here.breakInfo = function breakInfo(bpid) {
261
261
  libBreakInfo(bpid)
262
262
  }
263
+
264
+ // usingContID
265
+ //
266
+ // Mark that the contID is being used.
267
+ //
268
+ here.usingContID = function usingContID(contID, usage) {
269
+ debugNub = car(compress("debugNub"))
270
+ debugNub.usingContID(contID, usage)
271
+ }
263
272
 
264
273
  // callstack
265
274
  //
266
- // Report current callstack.
275
+ // Report the specified fiber callstack or current debugger stack.
267
276
  //
268
- here.callStack = function callStack(local debugNub) {
277
+ here.callStack = function callStack(contID, local debugNub) {
269
278
  debugNub = car(compress("debugNub"))
270
- debugNub.callStack()
279
+ debugNub.callStack(contID)
271
280
  }
272
281
 
273
282
  // frameinfo
274
283
  //
275
- // Report information about the nth frame in the callStack.
284
+ // Report information about the nth frame in a fiber callstack or the current debugger stack.
276
285
  //
277
- here.frameinfo = function frameinfo(nth, local debugNub, frame, proctask, comp, position) {
286
+ here.frameinfo = function frameinfo(nth, contID, local debugNub, frame, proctask, comp, position) {
278
287
  debugNub = car(compress("debugNub"))
279
- frame = debugNub.nthFrame(nth)
280
- proctask = debugNub.procTask(frame)
288
+ frame = debugNub.nthFrame(nth, contID)
289
+ proctask = debugNub.procTask(frame, contID)
281
290
  comp = debugNub.codemgr.procComponent(proctask.0)
282
291
  position = comp.textpos(proctask.0, proctask.1)
283
292
  {
@@ -302,11 +311,11 @@ closure DebugRemote(commander, local remoter, here, there, library) {
302
311
  // The optional visible array is a preceding result of this function, where "visible=true"
303
312
  // can be applied to nested values to add recursive depth.
304
313
  //
305
- here.scopeinfo = function scopeinfo(nth, visible,
314
+ here.scopeinfo = function scopeinfo(nth, visible, contID
306
315
  local debugNub, frame, procsym, parent, proc, lex1, ex1, params, content, scope, level, level1)
307
316
  {
308
317
  debugNub = car(compress("debugNub"))
309
- frame = debugNub.nthFrame(nth)
318
+ frame = debugNub.nthFrame(nth, contID)
310
319
  procsym = frame.3.1
311
320
  parent = procsym@\.parent
312
321
  while parent {
@@ -370,11 +379,11 @@ closure DebugRemote(commander, local remoter, here, there, library) {
370
379
  // can be applied to nested values to add recursive depth. A stack frame index can be specified
371
380
  // to evaluate an expression in that context.
372
381
 
373
- here.watchInfo = function watchInfo(visible, nth,
382
+ here.watchInfo = function watchInfo(visible, nth, contID,
374
383
  local debugNub, values, content, watch, child1, error, value, level, expr)
375
384
  {
376
385
  debugNub = car(compress("debugNub"))
377
- values = debugNub.evalWatchesInFrame(nth)
386
+ values = debugNub.evalWatchesInFrame(nth, contID)
378
387
  visible = new(visible) // don't modify original
379
388
  content = []
380
389
  for watch in debugNub.watches {
@@ -417,8 +426,9 @@ closure DebugRemote(commander, local remoter, here, there, library) {
417
426
  //
418
427
  // List the current futures.
419
428
 
420
- here.futureslist = function futureslist(local debugNub, output, future, record, procsym) {
429
+ here.futureslist = closure futureslist(local debugNub, contIDs, output, future, record, procsym) {
421
430
  debugNub = car(compress("debugNub"))
431
+ contIDs = []
422
432
  output = []
423
433
  for future in futures() {
424
434
  if member(debugNub.pauser, future.waiting)
@@ -431,6 +441,7 @@ closure DebugRemote(commander, local remoter, here, there, library) {
431
441
  if procedure(future.execute) {
432
442
  procsym = future.execute.1
433
443
  record.execute = strcat(future.execute.0, space, procsym.namespace.tostring, "::", debugNub.procname(procsym))
444
+ record.execloc = debugNub.procLoc(future.execute)
434
445
  }
435
446
  else if future.execute
436
447
  record.execute = tostring(future.execute)
@@ -439,9 +450,15 @@ closure DebugRemote(commander, local remoter, here, there, library) {
439
450
  procsym = item.1
440
451
  strcat(item.0, space, procsym.namespace.tostring, "::", debugNub.procname(procsym))
441
452
  })
453
+ record.continuations = future.continuations.toarray.map(function(cont, local contID) {
454
+ contID = debugNub.getContID(cont)
455
+ contIDs.push(contID)
456
+ contID
457
+ })
442
458
  }
443
459
  output.push(record)
444
460
  }
461
+ debugNub.contGC(contIDs)
445
462
  output
446
463
  }
447
464
 
@@ -228,9 +228,9 @@ closure packageCoder(evalf, local coder) {
228
228
  coder.invokeMethod = closure invokeMethod(objectID, args, local obj) {
229
229
  obj = coder.mapDecoding[objectID]
230
230
  if obj
231
- list(false, eval(list(deref, obj, pop(args), args)))
231
+ eval(list(deref, obj, pop(args), args))
232
232
  else
233
- list(Error("object ${objectID} not found"))
233
+ throw("remoting error: object ${objectID} not found")
234
234
  }
235
235
 
236
236
  // finis
@@ -87,12 +87,14 @@ closure CodeManager(options, local coman, cache)
87
87
  output.push(false)
88
88
  continue
89
89
  }
90
+ if text.startsWith("!")
91
+ text = "(${text})" // no shell escapes here
90
92
  try {
91
93
  source = new(textstream, text.concat(" ;")) // avoid EOF
92
94
  if locals
93
95
  source.setsymbols(locals)
94
96
  registry = modlist().Lib.exports.Registry // dialect registry
95
- dialect = registry.findName(registry.dialects().0) // ### default dialecct
97
+ dialect = registry.findName(registry.dialects().0) // ### default dialect
96
98
  output.push(dialect.parse(source))
97
99
  } catch {
98
100
  if true {
@@ -34,13 +34,17 @@
34
34
  *
35
35
  */
36
36
 
37
- closure dapoTable(database, path, local table, prefix) {
37
+ closure dapoTable(database, rootpath, local table, prefix) {
38
38
  global()
39
+ if !database || !string(rootpath)
40
+ return (list(Error("invalid arguments")))
39
41
  table = new(object, this)
40
42
  table.type = database.type
41
43
  table.db = database
42
- table.path = path
43
- table.prefix = makePrefix(path)
44
+ if rootpath != "" && rootpath.slice(-1) != "/"
45
+ rootpath = rootpath.concat("/") // "" or "<path>/"
46
+ table.rootpath = rootpath
47
+ table.prefix = makePrefix(rootpath)
44
48
 
45
49
  // makePrefix
46
50
  //
@@ -80,7 +84,7 @@ closure dapoTable(database, path, local table, prefix) {
80
84
  return (syncAdapter(add, key, content, metadata))
81
85
  id = makeID(key)
82
86
  if !string(id)
83
- return (asyncResult(callback, id)) // error from makeID
87
+ return (asyncResult(callback, id)) // error from makeID
84
88
  if metadata && !dictionary(metadata)
85
89
  return (asyncResult(callback, Error("invalid arguments")))
86
90
  if !database.pouch
@@ -291,7 +295,7 @@ closure dapoTable(database, path, local table, prefix) {
291
295
  // only immediate children are listed, with directories at the end--and no metadata for them.
292
296
  //
293
297
 
294
- table.records = closure records(options, callback, local prefix, pouchOpts, output) {
298
+ table.records = closure records(options, callback, local prefix, prelen, pouchOpts, output) {
295
299
  if !callback
296
300
  return (syncAdapter(records, options))
297
301
  output = {
@@ -300,9 +304,11 @@ closure dapoTable(database, path, local table, prefix) {
300
304
  if !string(options.prefix)
301
305
  return (asyncResult(callback, Error("prefix option must be string")))
302
306
  output.prefix = options.prefix
303
- prefix = table.prefix.concat(makePrefix(options.prefix)) }
304
- else
307
+ prefix = table.prefix.concat(makePrefix(options.prefix))
308
+ prelen = options.prefix.length }
309
+ else {
305
310
  prefix = table.prefix
311
+ prelen = 0 }
306
312
  if !database.pouch
307
313
  return (asyncResult(callback, Error("database closed")))
308
314
  pouchOpts = {
@@ -321,19 +327,24 @@ closure dapoTable(database, path, local table, prefix) {
321
327
  key = obj.id.substring(table.prefix.length)
322
328
  else
323
329
  key = "*key error*" // should not happen
324
- if !options.deep {
325
- offset = key.indexOf("/", prefix.length)
326
- if offset >= 0 {
327
- key = key.substring(0, offset+1) // child directory name
328
- if !firstkids[key]
329
- firstkids[key] = key // first time we've seen this child directory
330
- else
331
- continue } } // ignore deeper child
332
330
  item = {
333
331
  key: key
334
332
  _id: obj.id
335
333
  _rev: obj.value.rev
336
334
  }
335
+ if !options.deep {
336
+ offset = key.indexOf("/", prelen) // start looking past options.prefix
337
+ if offset >= 0 { // directory child
338
+ if length(key) > offset+1 { // transitive child (not directory itself)
339
+ obj.doc = undefined // just record directory name
340
+ item._id = undefined
341
+ item._rev = undefined }
342
+ key = key.substring(0, offset+1) // child directory name
343
+ if !firstkids[key]
344
+ firstkids[key] = key // first time we've seen this child directory
345
+ else
346
+ continue // ignore deeper child
347
+ item.key = key } }
337
348
  if obj.doc { // docs were requested
338
349
  if obj.doc.content {
339
350
  item._md5 = HashMD5(obj.doc.content)
@@ -741,6 +752,8 @@ closure DbConnector(psm, local connClassID, connector, watch) {
741
752
  //
742
753
  // Connect to a database, returning a PSM view.
743
754
  connector.connect = function connect(resID, service, args, local error, creds, db, rootpath, table) {
755
+ if !resID || args && !tuple(args)
756
+ return (list(Error("invalid arguments")))
744
757
  `(error, creds) = connector.access(resID)
745
758
  if !error
746
759
  `(error, db) = PouchDB(creds)
@@ -751,7 +764,7 @@ closure DbConnector(psm, local connClassID, connector, watch) {
751
764
  else if service == "NideFS" {
752
765
  rootpath = args.0 // connect to a NideFS filesystem
753
766
  if !rootpath
754
- return (Error("mandatory rootpath missing"))
767
+ return (list(Error("mandatory rootpath missing")))
755
768
  `(error, table) = db.table(rootpath)
756
769
  if error
757
770
  list(error)
@@ -766,7 +766,7 @@ function fimaInit(local manifest) {
766
766
 
767
767
  manifest = `(FileManager, fimaStore, fimaInit)
768
768
 
769
- Naan.module.build(module.id, "fileManager", function(modobj, compobj) {
769
+ Naan.module.build(module.id, "file_manager", function(modobj, compobj) {
770
770
  require("./storage.nlg")
771
771
  commonWatching = require("../common/watching.nlg")
772
772
  compobj.manifest = manifest
@@ -38,10 +38,12 @@
38
38
 
39
39
  closure FSview(table, rootpath, local view) {
40
40
  global(JSpath)
41
- if !table
41
+ if !table || !string(rootpath)
42
42
  return (list(Error("invalid arguments")))
43
43
  view = new(object, this)
44
44
  view.table = table
45
+ if rootpath != "" && rootpath.slice(-1) != "/"
46
+ rootpath = rootpath.concat("/") // "" or "<path>/"
45
47
  view.rootpath = rootpath
46
48
  view.path = JSpath.posix // for view.path.join(), etc.
47
49
 
@@ -118,23 +120,21 @@ closure FSview(table, rootpath, local view) {
118
120
  // checkPathName
119
121
  //
120
122
  // Return a `(path, name) tuple for a directory, or false if callback executed due to error. The
121
- // name is the empty string if the path is empty. Path "/" has name "/". Otherwise the name is
122
- // the last segment of the path, omitting the trailing slash.
123
+ // name is the empty string if the path is empty. Path "/" has name "". Otherwise the name is the
124
+ // last segment of the path, omitting any trailing slash. A key invariant is that the information
125
+ // should be the same whether the pathname was part of the rootpath or specified in the source
126
+ // path to an operation. That is why this "steals" the rootpath name if needed.
123
127
  //
124
- function checkPathName(path, callback, local name, slashdex) {
125
- if path == ""
126
- name = ""
127
- else {
128
- if checkPath(path, callback)
129
- return (false) // non-string
130
- if path.slice(-1) != "/"
131
- path = path.concat("/") // force to be directory
132
- slashdex = path.lastIndexOf("/", path.length-2)
133
- if path == "/" || slashdex < 0
134
- name = path
135
- else
136
- name = path.slice(slashdex+1, -1) // omit trailing "/"
137
- }
128
+ function checkPathName(path, callback, local name) {
129
+ if checkPath(path, callback)
130
+ return (false) // non-string
131
+ if path != "" && path.slice(-1) != "/"
132
+ path = path.concat("/") // force to be directory
133
+ if path == "/" && rootpath != ""
134
+ name = rootpath // avoid making "//"
135
+ else
136
+ name = rootpath.concat(path)
137
+ name = name.split("/").slice(0,-1).pop() || "" // <|| ""> not needed
138
138
  list(path, name)
139
139
  }
140
140
 
@@ -683,7 +683,7 @@ closure FSview(table, rootpath, local view) {
683
683
  return // already executed callback with error
684
684
  dirdict = {
685
685
  name: name
686
- path: path
686
+ path: rootpath.concat(path)
687
687
  data: {
688
688
  platform: table.type
689
689
  semantics: "dbfs"
@@ -743,14 +743,13 @@ closure FSview(table, rootpath, local view) {
743
743
  `(path, name) = checkPathName(path, callback)
744
744
  if !path
745
745
  return // already executed callback with error
746
- options = { // ### might want to allow some options
746
+ options = merge({
747
747
  prefix: path
748
748
  deep: true
749
- }
750
- if name == "" && rootpath != ""
751
- name = rootpath.split("/").slice(0,-1).pop() || ""
749
+ }, options)
752
750
  treedict = {
753
751
  name: name
752
+ path: rootpath.concat(path)
754
753
  data: {
755
754
  platform: table.type
756
755
  semantics: "dbfs"
@@ -142,9 +142,14 @@ closure ResourceManager(dbname, prefix, local reman, watch, result) {
142
142
  reman.unWatch = watch.unWatch
143
143
  reman.dbname = dbname
144
144
  reman.conns = {}
145
- result = PouchDB(dbname)
145
+ try {
146
+ require("./dbt_pouch.nlg")
147
+ result = PouchDB(dbname)
148
+ } catch {
149
+ result = list(Error("PouchDB not available", exception))
150
+ }
146
151
  if result.0
147
- return (result) // can't access our vault database
152
+ return (list(result)) // can't access our vault database
148
153
  reman.db = result.1
149
154
 
150
155
  // vault
@@ -423,19 +428,22 @@ closure ResourceTracker(reman, local retor, watch) {
423
428
  // Start tracking resources.
424
429
  retor.open = function open() {
425
430
  if retor.classIdList
426
- return // already open
431
+ return (list(false, { open: true })) // already open
427
432
  watch.reset()
428
433
  retor.resids = { } // start empty
429
434
  retor.classIdList = []
430
435
  for classID in reman.connectors()
431
436
  addConnResources(classID)
432
437
  reman.watch(remanUpdateOnChange)
438
+ list(false, { ok: true })
433
439
  }
434
440
 
435
441
  // close
436
442
  //
437
443
  // stop tracking resources.
438
444
  retor.close = function close(local classID, connector) {
445
+ if !retor.classIdList
446
+ return (list(false, { open: false }))
439
447
  watch.reset()
440
448
  if retor.classIdList {
441
449
  for classID in retor.classIdList {
@@ -446,6 +454,7 @@ closure ResourceTracker(reman, local retor, watch) {
446
454
  }
447
455
  reman.unWatch(remanUpdateOnChange)
448
456
  retor.resids = false
457
+ list(false, { ok: true })
449
458
  }
450
459
 
451
460
  // finis
@@ -466,7 +475,6 @@ function rsrcInit(local manifest) {
466
475
 
467
476
  Naan.module.build(module.id, "resources", function(modobj, compobj) {
468
477
  require("./storage.nlg")
469
- require("./dbt_pouch.nlg")
470
478
  commonWatching = require("../common/watching.nlg")
471
479
  compobj.manifest = manifest
472
480
  module.exports.ResourceManager = ResourceManager
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * column positioning: // // !
8
8
  *
9
- * Copyright (c) 2020-2022 by Richard C. Zulch
9
+ * Copyright (c) 2020-2024 by Richard C. Zulch
10
10
  *
11
11
  */
12
12
 
@@ -26,7 +26,7 @@ function storInit(local manifest) {
26
26
  require("../common/common.nlg").LiveImport()
27
27
  require("../common/watching.nlg")
28
28
  compobj.manifest = manifest
29
- LoadComponentOnDemand(list(DbConnector, ListBrowserDBs, PouchDB), "./dbt_pouch.nlg")
29
+ LoadComponentOnDemand(list(DbConnector, ListBrowserDBs, PouchDB), "naanlib:storage/dbt_pouch.nlg")
30
30
 
31
31
 
32
32
  // storReload
@@ -536,7 +536,7 @@ exports.NaanControllerWeb = function() {
536
536
  statedoc.curversion = kStateCurrentVersion;
537
537
  statedoc.firstver = kStateFirstVersion;
538
538
  statedoc.licensee = "MIT-License";
539
- statedoc.verstring = "1.4.0+1";
539
+ statedoc.verstring = "1.4.1+1";
540
540
  statedoc.date = new Date().toISOString();
541
541
  statedoc.prefs = prefs;
542
542
  statedoc.naan = naanlib.saveState(false); // true to optimize, which is a bit slower
@@ -554,7 +554,7 @@ exports.NaanControllerWeb = function() {
554
554
  || statedoc.firstver > kStateCurrentVersion
555
555
  || statedoc.curversion < kStateFirstVersion
556
556
  || statedoc.licensee != "MIT-License"
557
- || statedoc.verstring != "1.4.0+1")
557
+ || statedoc.verstring != "1.4.1+1")
558
558
  {
559
559
  localStorage.removeItem("NaanState_Hosted");
560
560
  return (false);
@@ -613,7 +613,7 @@ exports.NaanControllerWeb = function() {
613
613
  op: "VsiteOpen",
614
614
  name: vsiteName,
615
615
  naancont: contSelf,
616
- title: vsiteName + " 1.4.0+1"
616
+ title: vsiteName + " 1.4.1+1"
617
617
  });
618
618
  }
619
619
  } catch (e) {
@@ -627,7 +627,7 @@ exports.NaanControllerWeb = function() {
627
627
  op: "VsiteClose",
628
628
  name: vsiteName,
629
629
  naancont: contSelf,
630
- title: vsiteName + " 1.4.0+1"
630
+ title: vsiteName + " 1.4.1+1"
631
631
  });
632
632
  termTextOut("\x1b[90m\x1b[3m".concat("\nwindow closed", "\x1b[0m\n"));
633
633
  }
@@ -642,8 +642,8 @@ exports.NaanControllerWeb = function() {
642
642
  naanlib.banner();
643
643
  var hostpath = window.location.origin.concat(naanlib.js.r("path").dirname(window.location.pathname));
644
644
  naanlib.start({
645
- cmd: 'App.version = "1.4.0+1";;\r\n'
646
- + 'App.cache = "233c1fed240ea5c0dd1c14562f30021b";;\r\n'
645
+ cmd: 'App.version = "1.4.1+1";;\r\n'
646
+ + 'App.cache = "e319a60c34bb3a4866dfc9f6c698b9aa";;\r\n'
647
647
  + 'Naan.module.requireQuery({ naanver: App.cache });;\r\n'
648
648
  + 'Naan.module.webparse("naan_init.nlg", "' + hostpath + '", { naanver: App.cache });;\r\n'
649
649
  });