@naanlang/naan 1.5.0 → 1.7.0
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/LICENSE.md +2 -2
- package/README.md +2 -2
- package/bin/index.js +7 -3
- package/dist/env_web.js +162 -48
- package/dist/naan.min.js +11 -11
- package/frameworks/browser/https_request.nlg +2 -2
- package/frameworks/browser/sworker.js +28 -26
- package/frameworks/browser/terminals.nlg +295 -737
- package/frameworks/browser/worker.nlg +295 -0
- package/frameworks/browser/workers.nlg +6 -6
- package/frameworks/browser/ws_client.nlg +15 -10
- package/frameworks/client/apiclient.nlg +211 -9
- package/frameworks/client/psm_client.nlg +10 -14
- package/frameworks/client/relaycon.nlg +87 -161
- package/frameworks/common/common.nlg +2 -0
- package/frameworks/common/events.nlg +101 -0
- package/frameworks/common/repltools.nlg +80 -1
- package/frameworks/node/apiserver.nlg +38 -246
- package/frameworks/node/filesystem.nlg +31 -6
- package/frameworks/node/http_request.nlg +34 -13
- package/frameworks/node/https_request.nlg +8 -3
- package/frameworks/node/node.nlg +3 -0
- package/frameworks/node/pty.nlg +346 -0
- package/frameworks/node/shell.nlg +26 -3
- package/frameworks/node/worker.nlg +504 -560
- package/frameworks/node/ws_client.nlg +2 -2
- package/frameworks/project/build.nlg +56 -14
- package/frameworks/project/projects.nlg +1 -1
- package/frameworks/running/debugcom.nlg +20 -3
- package/frameworks/running/debugnub.nlg +33 -11
- package/frameworks/running/executors.nlg +40 -285
- package/frameworks/running/instances.nlg +394 -0
- package/frameworks/running/remote_req.nlg +139 -0
- package/frameworks/running/remote_res.nlg +89 -0
- package/frameworks/running/sourcecode.nlg +3 -2
- package/frameworks/running/taskexec.nlg +16 -59
- package/frameworks/service/imp.nlg +751 -0
- package/frameworks/service/model.nlg +71 -0
- package/frameworks/service/nubnode.nlg +136 -0
- package/frameworks/service/nubweb.nlg +124 -0
- package/frameworks/service/service.nlg +28 -0
- package/frameworks/storage/file_manager.nlg +3 -2
- package/lib/browser/env_web.js +169 -55
- package/lib/browser/env_webworker.js +89 -31
- package/lib/core/naanlib.js +11 -11
- package/lib/env_node.js +186 -27
- package/lib/env_nodeworker.js +82 -44
- package/lib/node_server_init.nlg +149 -0
- package/lib/node_worker.js +36 -0
- package/lib/node_worker_init.nlg +43 -0
- package/package.json +1 -1
- package/plugins/openSearch/openSearch.nlg +3 -2
- package/plugins/openSearch/os_dynamo.nlg +3 -2
- package/plugins/serviceAws/aws_cloudwatchlogs.nlg +44 -2
- package/plugins/serviceAws/aws_dynamo.nlg +144 -63
- package/plugins/serviceAws/aws_utils.nlg +6 -11
- package/plugins/serviceAws/serviceAws.nlg +3 -2
- package/plugins/serviceNexara/speechrec.nlg +10 -6
- package/test/test_01_core.nlg +2 -2
- package/test/test_02_context.nlg +32 -9
- package/test/test_03_jsinterop.nlg +3 -3
- package/test/test_07_lingo.nlg +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* column positioning: // // !
|
|
7
7
|
*
|
|
8
|
-
* Copyright (c) 2023-
|
|
8
|
+
* Copyright (c) 2023-2026 by Richard C. Zulch
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
/*
|
|
14
14
|
* WebSocket
|
|
15
15
|
*
|
|
16
|
-
* Create a WebSocket client connection object
|
|
16
|
+
* Create a WebSocket client connection object.
|
|
17
17
|
*
|
|
18
18
|
* Required:
|
|
19
19
|
* host: <string> // host:port
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2019-
|
|
9
|
+
* Copyright (c) 2019-2026 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -426,7 +426,7 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
|
|
|
426
426
|
// autoquoted to itself, a symbol. This can be used to detect build time vs. runtime.
|
|
427
427
|
|
|
428
428
|
function parseAndPack1(text, fpath, options, operation,
|
|
429
|
-
local util, lib, penv, naansym, dlogsym, pmod, pcomp, output, textout, annerror, annotations, package)
|
|
429
|
+
local util, lib, penv, naansym, dlogsym, pmod, pcomp, ournn, output, textout, annerror, annotations, package)
|
|
430
430
|
{
|
|
431
431
|
//
|
|
432
432
|
// textline
|
|
@@ -445,20 +445,39 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
|
|
|
445
445
|
lib = Naan.module.modlist().Lib.exports
|
|
446
446
|
if !util || !lib
|
|
447
447
|
return (list("Build packager cannot access support functions"))
|
|
448
|
+
//
|
|
449
|
+
// The following crazy rigmarole is about customizing the ParsEnvironment so we can glean
|
|
450
|
+
// enough information to build a package without actually executing the code. To do this we
|
|
451
|
+
// replace the entire Naan.module collection of functions with just build, so the others do
|
|
452
|
+
// nothing. From that we collect the module and component names, plus the manifest. This
|
|
453
|
+
// also sets up a benign "exports" dictionary so module build can "go through the mtions"
|
|
454
|
+
// without modification.
|
|
455
|
+
//
|
|
448
456
|
penv = lib.ParsEnvironment(Dialect, "build-".concat(operation))
|
|
449
457
|
penv.evalq(letlocal(App)) // make local copy of App
|
|
450
458
|
penv.evalq(letlocal(js)) // make local copy of js
|
|
451
|
-
|
|
452
|
-
penv.evalq(assign(naansym,new(Naan))) // make it modifiable
|
|
459
|
+
ournn = new(Naan) // get modifiable Naan
|
|
453
460
|
pmod = { } // our module object
|
|
454
461
|
pcomp = { } // our component object
|
|
455
|
-
|
|
462
|
+
ournn.module = {
|
|
456
463
|
build: function(modname, compname, proc) {
|
|
457
|
-
pmod.id = module
|
|
464
|
+
pmod.id = module.id
|
|
465
|
+
pmod.exports = { }
|
|
458
466
|
pcomp.name = compname
|
|
459
467
|
call(proc, pmod, pcomp) // obtain manifest
|
|
460
468
|
}
|
|
461
469
|
}
|
|
470
|
+
naansym = penv.evalq(function(nn) {
|
|
471
|
+
assign(letlocal(Naan).0,nn)
|
|
472
|
+
`Naan
|
|
473
|
+
}(ournn)) // make Naan modifiable
|
|
474
|
+
penv.evalq(assign(letlocal(module).0, { // make local copy of module
|
|
475
|
+
exports: { }
|
|
476
|
+
}))
|
|
477
|
+
//
|
|
478
|
+
// Here we make a custom debuglog function that identifies the text without color and will
|
|
479
|
+
// write the output to the build log.
|
|
480
|
+
//
|
|
462
481
|
dlogsym = penv.evalq(letlocal(debuglog).0) // make local copy of debuglog
|
|
463
482
|
penv.evalq(function \.debuglog args { // redefine debuglog for capture
|
|
464
483
|
let (arg, spaced) {
|
|
@@ -471,8 +490,19 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
|
|
|
471
490
|
apply(textline, reverse(spaced))
|
|
472
491
|
} () })
|
|
473
492
|
penv.evalq(putproc(car(dlogsym), \.debuglog.proc))
|
|
493
|
+
//
|
|
494
|
+
// The NideBuild symbol is "debug" or "release", etc. or is simply autoquoted as the symbol
|
|
495
|
+
// itself when not building. This is used if the source needs different behavior at build
|
|
496
|
+
// time or run time.
|
|
497
|
+
//
|
|
474
498
|
penv.eval(append(quote(assign(compress("NideBuild"))), operation)) // NideBuild symbol is operation name string
|
|
499
|
+
//
|
|
500
|
+
// This is the actual meat of the matter, the parsing of the program text.
|
|
501
|
+
//
|
|
475
502
|
output = penv.parse(text) // parse and evaluate
|
|
503
|
+
//
|
|
504
|
+
// Output processing and error logging
|
|
505
|
+
//
|
|
476
506
|
textout = ""
|
|
477
507
|
try {
|
|
478
508
|
if !pcomp.name
|
|
@@ -507,20 +537,30 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
|
|
|
507
537
|
}
|
|
508
538
|
if output.errors.length > 0
|
|
509
539
|
return (list("errors in ".concat(fpath), false, annotations, textout))
|
|
540
|
+
//
|
|
541
|
+
// Build the package, if not just doing syntax checking
|
|
542
|
+
//
|
|
510
543
|
if options.naanpack || options.jspack { // actually building a package?
|
|
511
544
|
if !pcomp.name {
|
|
512
|
-
|
|
545
|
+
//
|
|
546
|
+
// Some components cannot use a build function because they are too early in the
|
|
547
|
+
// boot process, but we still need a component. We look for NaanBuildComponent
|
|
548
|
+
// to define a dictionary with filename, name and manifest fields. For example,
|
|
549
|
+
// see Util:Module.nlg
|
|
550
|
+
//
|
|
551
|
+
pcomp = penv.evalq(car(compress(NaanBuildComponent)))
|
|
513
552
|
if !pcomp || !fpath.endsWith("/".concat(pcomp.filename))
|
|
514
553
|
return (list("Build cannot package without component in ".concat(fpath), false, annotations, textout))
|
|
515
554
|
}
|
|
516
|
-
package =
|
|
555
|
+
package = util.pkgSave(compress(pcomp.name), pcomp.manifest)
|
|
556
|
+
if string(package)
|
|
557
|
+
return (list("Build cannot generate package for ".concat(fpath), false, annotations, textout))
|
|
517
558
|
}
|
|
518
559
|
} catch {
|
|
519
560
|
if true
|
|
520
561
|
return (list("Packaging exception in ".concat(fpath, ": ", tostring(exception)), false, annotations, textout))
|
|
521
562
|
} finally {
|
|
522
563
|
penv.destroy() // remove the namespace
|
|
523
|
-
debuglog("parseAndPack1 done", fpath)
|
|
524
564
|
}
|
|
525
565
|
if options.naanpack
|
|
526
566
|
package = (js.w||js.s||js.g).JSON.stringify(package) // doesn't have frameworks/common available
|
|
@@ -546,7 +586,7 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
|
|
|
546
586
|
build.parallel = ExecutorParallel(track, { // create worker pool
|
|
547
587
|
basename: "build"
|
|
548
588
|
initeval: `(false, (parseAndPack1))
|
|
549
|
-
})
|
|
589
|
+
})
|
|
550
590
|
result = build.parallel.rpc(parseAndPack1, list(text, fpath, options, operation))
|
|
551
591
|
if !result.0 {
|
|
552
592
|
result = result.1 // unpeel RPC result
|
|
@@ -1211,17 +1251,19 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
|
|
|
1211
1251
|
//
|
|
1212
1252
|
// Run the current build product by spawning a new worker.
|
|
1213
1253
|
//
|
|
1214
|
-
build.runSpawn = function runSpawn(local error, maintext, executor, vpath, site) {
|
|
1254
|
+
build.runSpawn = function runSpawn(local error, maintext, executor, vpath, site, dirpath) {
|
|
1215
1255
|
`(error, maintext) = fs.readFile(JSpath.join(build.destpath, build.runway.main))
|
|
1216
1256
|
if error
|
|
1217
1257
|
error = Error("Builder: cannot read main file", error)
|
|
1218
1258
|
else {
|
|
1259
|
+
dirpath = fs.path.resolve("/", fs.rootpath, build.destpath, build.runway.path || "")
|
|
1219
1260
|
`(error, executor) = track.spawn(build.runway.spawn.0, "${rules.name} ${build.version}", {
|
|
1220
|
-
workerID: "Run-${build.buildnum}"
|
|
1261
|
+
workerID: "Run-${build.version}+${build.buildnum}"
|
|
1221
1262
|
startup: {
|
|
1222
|
-
|
|
1223
|
-
dirpath:
|
|
1263
|
+
maintext: maintext
|
|
1264
|
+
dirpath: dirpath
|
|
1224
1265
|
}
|
|
1266
|
+
rootPath: dirpath
|
|
1225
1267
|
})
|
|
1226
1268
|
if error
|
|
1227
1269
|
error = Error("Builder: cannot spawn executor instance", error)
|
|
@@ -296,7 +296,7 @@ closure projConnector(projman, projtype, local connector, watch) {
|
|
|
296
296
|
*
|
|
297
297
|
* Nide.proj/
|
|
298
298
|
* nide_cliser.cfg - JSON definition of the project (see below)
|
|
299
|
-
* NaanIDE_version.txt - [default] substitution file defining 1.
|
|
299
|
+
* NaanIDE_version.txt - [default] substitution file defining 1.7.0+1 etc.
|
|
300
300
|
* NaanIDE_version_builds.txt - [default] contains current build number as decimal string
|
|
301
301
|
* build/ - [optional] default build output location
|
|
302
302
|
* NaanIDE.lic - [optional] defines Zulch Laboratories, Inc. and other license info
|
|
@@ -19,9 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
closure DebugCommand(executor, notify, local decom, excon) {
|
|
21
21
|
decom = new(object, this)
|
|
22
|
-
executor.DebugCmd({
|
|
23
|
-
op: "attach"
|
|
24
|
-
})
|
|
25
22
|
decom.executor = executor
|
|
26
23
|
|
|
27
24
|
// debugData
|
|
@@ -96,6 +93,24 @@ closure DebugCommand(executor, notify, local decom, excon) {
|
|
|
96
93
|
status
|
|
97
94
|
}
|
|
98
95
|
|
|
96
|
+
// query
|
|
97
|
+
// Send a status update back.
|
|
98
|
+
//
|
|
99
|
+
decom.query = function query() {
|
|
100
|
+
decom.executor.DebugCmd({
|
|
101
|
+
op: "query"
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// attach
|
|
106
|
+
// Attach our GUI to the low-level debugger
|
|
107
|
+
//
|
|
108
|
+
decom.attach = function attach() {
|
|
109
|
+
executor.DebugCmd({
|
|
110
|
+
op: "attach"
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
99
114
|
//
|
|
100
115
|
// Run control.
|
|
101
116
|
//
|
|
@@ -138,6 +153,8 @@ closure DebugCommand(executor, notify, local decom, excon) {
|
|
|
138
153
|
notify.runState(debugStatus())
|
|
139
154
|
}
|
|
140
155
|
|
|
156
|
+
attach()
|
|
157
|
+
|
|
141
158
|
// finis
|
|
142
159
|
|
|
143
160
|
decom
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* column positioning: // // !
|
|
7
7
|
*
|
|
8
|
-
* Copyright (c) 2021-
|
|
8
|
+
* Copyright (c) 2021-2026 by Richard C. Zulch
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -33,9 +33,9 @@ closure DebugNub(local nub, debug, paused) {
|
|
|
33
33
|
nub.codemgr = CodeManager()
|
|
34
34
|
nub.exenable = true
|
|
35
35
|
nub.watches = []
|
|
36
|
-
nub.contIDs = new(weakmap)
|
|
37
36
|
nub.stacks = { }
|
|
38
37
|
nub.usage = { }
|
|
38
|
+
paused = { }
|
|
39
39
|
|
|
40
40
|
// debugDepth
|
|
41
41
|
// Return the recursive debugging depth as an integer.
|
|
@@ -46,6 +46,18 @@ closure DebugNub(local nub, debug, paused) {
|
|
|
46
46
|
curdepth = 0
|
|
47
47
|
curdepth
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
// sendStatus
|
|
51
|
+
// Send current status to the far end.
|
|
52
|
+
//
|
|
53
|
+
function sendStatus() {
|
|
54
|
+
js.t.ReplyDebugger({
|
|
55
|
+
op: "status"
|
|
56
|
+
depth: debugDepth()
|
|
57
|
+
bpenable: debug.bpenable
|
|
58
|
+
exenable: nub.exenable
|
|
59
|
+
})
|
|
60
|
+
}
|
|
49
61
|
|
|
50
62
|
// onDebugger proc
|
|
51
63
|
// Process an incoming debugger command.
|
|
@@ -53,17 +65,13 @@ closure DebugNub(local nub, debug, paused) {
|
|
|
53
65
|
function onDebugger(msg) {
|
|
54
66
|
if msg.op == "attach" {
|
|
55
67
|
debug.setCommander(nub)
|
|
56
|
-
|
|
57
|
-
op: "status"
|
|
58
|
-
depth: debugDepth()
|
|
59
|
-
bpenable: debug.bpenable
|
|
60
|
-
exenable: nub.exenable
|
|
61
|
-
})
|
|
68
|
+
sendStatus()
|
|
62
69
|
}
|
|
63
70
|
else if msg.op == "detach" {
|
|
64
71
|
debug.setCommander(false)
|
|
65
72
|
paused.wait = false // false: go back to ndb
|
|
66
|
-
}
|
|
73
|
+
} else if msg.op == "query"
|
|
74
|
+
sendStatus()
|
|
67
75
|
else if msg.op == "pause"
|
|
68
76
|
debugger()
|
|
69
77
|
else if msg.op == "resume" || msg.op == "stop"
|
|
@@ -405,8 +413,17 @@ closure DebugNub(local nub, debug, paused) {
|
|
|
405
413
|
// Get the location of a procdef.
|
|
406
414
|
|
|
407
415
|
nub.procLoc = function procLoc(procdef, task, local comp, position) {
|
|
408
|
-
if !task
|
|
416
|
+
if !task {
|
|
417
|
+
if nub.procLocs[procdef]
|
|
418
|
+
return // use the cached value
|
|
409
419
|
task = rrrest(procdef)
|
|
420
|
+
if task {
|
|
421
|
+
if !nub.procLocs
|
|
422
|
+
nub.procLocs = new(weakmap) // make sure we have a weakmap
|
|
423
|
+
nub.procLocs[procdef] = procLoc(procdef, task) // cache a new location
|
|
424
|
+
return
|
|
425
|
+
}
|
|
426
|
+
}
|
|
410
427
|
comp = nub.codemgr.procComponent(procdef)
|
|
411
428
|
position = comp.textpos(procdef, task)
|
|
412
429
|
{
|
|
@@ -424,8 +441,11 @@ closure DebugNub(local nub, debug, paused) {
|
|
|
424
441
|
|
|
425
442
|
nub.getContID = function getContID(cont, local contID, frames) {
|
|
426
443
|
contID = nub.contIDs[cont]
|
|
427
|
-
if !contID
|
|
444
|
+
if !contID {
|
|
445
|
+
if !nub.contIDs
|
|
446
|
+
nub.contIDs = new(weakmap) // make sure we have a weakmap
|
|
428
447
|
nub.contIDs[cont] = contID = UUID()
|
|
448
|
+
}
|
|
429
449
|
frames = cont.stacktrace().toarray
|
|
430
450
|
if frames.slice(-1).0 == `interrupt
|
|
431
451
|
frames.pop()
|
|
@@ -580,6 +600,8 @@ closure DebugNub(local nub, debug, paused) {
|
|
|
580
600
|
frames = new(nub.stacks[contID])
|
|
581
601
|
else
|
|
582
602
|
frames = new(debug.frames)
|
|
603
|
+
if !array(frames)
|
|
604
|
+
return (false) // invalid frames array
|
|
583
605
|
loop {
|
|
584
606
|
if frames.length == 0
|
|
585
607
|
break
|