@naanlang/naan 1.0.16 → 1.1.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 +4 -4
- package/dist/naan.min.js +6 -6
- package/frameworks/browser/https_request.nlg +23 -9
- package/frameworks/browser/sworker.js +26 -25
- package/frameworks/browser/terminals.nlg +56 -15
- package/frameworks/browser/ws_client.nlg +124 -0
- package/frameworks/client/apiclient.nlg +3 -2
- package/frameworks/client/psm_client.nlg +1 -1
- package/frameworks/client/relaycon.nlg +308 -0
- package/frameworks/common/common.nlg +1 -1
- package/frameworks/common/utils.nlg +40 -2
- package/frameworks/node/apiserver.nlg +342 -103
- package/frameworks/node/https_request.nlg +30 -5
- package/frameworks/node/node.nlg +60 -2
- package/frameworks/node/psm_server.nlg +9 -5
- package/frameworks/node/worker.nlg +22 -9
- package/frameworks/node/ws_client.nlg +127 -0
- package/frameworks/project/build.nlg +2 -2
- package/frameworks/project/projects.nlg +8 -2
- package/frameworks/running/debugnub.nlg +2 -2
- package/frameworks/running/debugutil.nlg +1 -1
- package/frameworks/running/executors.nlg +59 -12
- package/frameworks/running/sourcecode.nlg +2 -2
- package/frameworks/running/taskexec.nlg +23 -24
- package/frameworks/storage/dbt_pouch.nlg +8 -6
- package/frameworks/storage/file_manager.nlg +6 -3
- package/frameworks/storage/psm.nlg +3 -2
- package/frameworks/storage/psm_dbtables.nlg +53 -41
- package/frameworks/storage/resources.nlg +4 -2
- package/lib/browser/env_web.js +6 -6
- package/lib/browser/env_webworker.js +1 -1
- package/lib/core/naanlib.js +6 -6
- package/lib/env_node.js +97 -8
- package/lib/env_nodeworker.js +22 -4
- package/package.json +1 -1
- package/plugins/serviceAws/aws/lambda_rest_index.js +5 -1
- package/plugins/serviceAws/dbt_aws.nlg +2 -2
- package/plugins/serviceAws/psm_aws.nlg +2 -2
- package/test/test_01_core.nlg +30 -4
package/lib/env_node.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2017-
|
|
9
|
+
* Copyright (c) 2017-2024 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
* Currently defined options are:
|
|
21
21
|
* {
|
|
22
22
|
* replDisable: <boolean> // disable REPL and just respond to textCommand in API
|
|
23
|
+
* noWelcome: <boolean> // suppress the welcome banner/messages
|
|
24
|
+
* state: <object> // saved state to load
|
|
25
|
+
* require: <function> // use the specified require function
|
|
26
|
+
* import: <function> // use the specified import function
|
|
23
27
|
* }
|
|
24
28
|
*
|
|
25
29
|
*/
|
|
@@ -29,6 +33,14 @@ exports.NaanNodeREPL = function NaanNodeREPL(options) {
|
|
|
29
33
|
"use strict";
|
|
30
34
|
/*jshint -W024 */
|
|
31
35
|
var undefined;
|
|
36
|
+
|
|
37
|
+
//
|
|
38
|
+
// Persistent
|
|
39
|
+
//
|
|
40
|
+
|
|
41
|
+
var
|
|
42
|
+
kStateFirstVersion = 200, // increment when losing backwards compatbility
|
|
43
|
+
kStateCurrentVersion = 200; // increment when adding features
|
|
32
44
|
|
|
33
45
|
//
|
|
34
46
|
// Initialization
|
|
@@ -48,7 +60,8 @@ exports.NaanNodeREPL = function NaanNodeREPL(options) {
|
|
|
48
60
|
var useConsoleOut = false;
|
|
49
61
|
if (outEnable && process.env["RUNKIT_ENDPOINT_URL"])
|
|
50
62
|
useConsoleOut = true; // use console.log for output in RunKit
|
|
51
|
-
|
|
63
|
+
var dontSaveUntilWorking; // true when state loaded, must be reset to save state again
|
|
64
|
+
var prefs = { };
|
|
52
65
|
|
|
53
66
|
//==========================================================================
|
|
54
67
|
// API
|
|
@@ -58,6 +71,10 @@ exports.NaanNodeREPL = function NaanNodeREPL(options) {
|
|
|
58
71
|
naanlib.js.r = req;
|
|
59
72
|
};
|
|
60
73
|
|
|
74
|
+
this.setImport = function setImport(imp) { // override import function
|
|
75
|
+
naanlib.js.i = imp;
|
|
76
|
+
};
|
|
77
|
+
|
|
61
78
|
this.setDirectory = function setDirectory(path) { // override base directory
|
|
62
79
|
naanlib.js.d = path;
|
|
63
80
|
};
|
|
@@ -94,11 +111,11 @@ exports.NaanNodeREPL = function NaanNodeREPL(options) {
|
|
|
94
111
|
|
|
95
112
|
if (!options.replDisable)
|
|
96
113
|
{
|
|
97
|
-
replServer = repl.start({ prompt: '
|
|
114
|
+
replServer = repl.start({ prompt: '', eval: myEval});
|
|
98
115
|
|
|
99
|
-
replServer.on('line', function(cmd) {
|
|
116
|
+
replServer.on('line', function(cmd) { // process raw command line
|
|
100
117
|
if (cmd.charAt(0) != ".") {
|
|
101
|
-
textToRemoteTerm(cmd);
|
|
118
|
+
textToRemoteTerm("\x1b[90m\x1b[3m".concat(cmd, "\x1b[0m\n"));
|
|
102
119
|
naanlib.textLine(cmd + "\n");
|
|
103
120
|
}
|
|
104
121
|
});
|
|
@@ -139,7 +156,8 @@ exports.NaanNodeREPL = function NaanNodeREPL(options) {
|
|
|
139
156
|
if (termops)
|
|
140
157
|
{
|
|
141
158
|
setTimeout(function () {
|
|
142
|
-
termops
|
|
159
|
+
if (termops) // avoid crashing if it went away during delay
|
|
160
|
+
termops.debugtext(text, level);
|
|
143
161
|
}, 1);
|
|
144
162
|
}
|
|
145
163
|
} else if (outEnable) {
|
|
@@ -237,7 +255,7 @@ exports.NaanNodeREPL = function NaanNodeREPL(options) {
|
|
|
237
255
|
else if (msg.id == "keyline")
|
|
238
256
|
{ // typing from remote terminal
|
|
239
257
|
setTimeout(function () {
|
|
240
|
-
process.stdout.write(msg.text
|
|
258
|
+
process.stdout.write("\x1b[90m\x1b[3m".concat(msg.text.trim(), "\x1b[0m\r\n"));
|
|
241
259
|
outEnable = true;
|
|
242
260
|
naanlib.textLine(msg.text); // keyboard text from terminal
|
|
243
261
|
}, 1);
|
|
@@ -288,14 +306,85 @@ exports.NaanNodeREPL = function NaanNodeREPL(options) {
|
|
|
288
306
|
}
|
|
289
307
|
}, 1000);
|
|
290
308
|
|
|
309
|
+
|
|
310
|
+
//==========================================================================
|
|
311
|
+
// State load/save
|
|
312
|
+
//--------------------------------------------------------------------------
|
|
313
|
+
|
|
314
|
+
// SavePref
|
|
315
|
+
//
|
|
316
|
+
// Save a persistent preference object that can be retrieved in the future.
|
|
317
|
+
//
|
|
318
|
+
this.SavePref = function SavePref(key, value) {
|
|
319
|
+
return (prefs[key] = value);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// LoadPref
|
|
323
|
+
//
|
|
324
|
+
// Load a previously-saved preference object for future retrieval.
|
|
325
|
+
//
|
|
326
|
+
this.LoadPref = function LoadPref(key) {
|
|
327
|
+
return (prefs[key]);
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// Working
|
|
331
|
+
//
|
|
332
|
+
// Note that the application is working, so it is safe to save state.
|
|
333
|
+
//
|
|
334
|
+
this.Working = function Working() {
|
|
335
|
+
dontSaveUntilWorking = false;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// MakeState
|
|
339
|
+
//
|
|
340
|
+
// Save our state into a new object.
|
|
341
|
+
//
|
|
342
|
+
this.MakeState = function MakeState() {
|
|
343
|
+
if (dontSaveUntilWorking)
|
|
344
|
+
return (false); // didn't get far enough to call Working()
|
|
345
|
+
var statedoc = {};
|
|
346
|
+
statedoc.curversion = kStateCurrentVersion;
|
|
347
|
+
statedoc.firstver = kStateFirstVersion;
|
|
348
|
+
statedoc.date = new Date().toISOString();
|
|
349
|
+
statedoc.prefs = prefs;
|
|
350
|
+
statedoc.naan = naanlib.saveState(true); // true to optimize, which is a bit slower
|
|
351
|
+
return (statedoc);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
// loadState
|
|
355
|
+
//
|
|
356
|
+
// Load our state from an object.
|
|
357
|
+
//
|
|
358
|
+
function loadState(statedoc) {
|
|
359
|
+
dontSaveUntilWorking = true; // make sure we don't store bad state
|
|
360
|
+
if (typeof(statedoc) != "object" || typeof(statedoc.naan) != "string"
|
|
361
|
+
|| statedoc.firstver > kStateCurrentVersion
|
|
362
|
+
|| statedoc.curversion < kStateFirstVersion)
|
|
363
|
+
{
|
|
364
|
+
return (false);
|
|
365
|
+
}
|
|
366
|
+
if (typeof(statedoc.prefs) == "object")
|
|
367
|
+
prefs = statedoc.prefs;
|
|
368
|
+
return (statedoc.naan);
|
|
369
|
+
}
|
|
370
|
+
|
|
291
371
|
|
|
292
372
|
//==========================================================================
|
|
293
373
|
// Start the Naan Interpreter
|
|
294
374
|
//--------------------------------------------------------------------------
|
|
375
|
+
if (options.require)
|
|
376
|
+
naanlib.js.r = options.require;
|
|
377
|
+
if (options.import)
|
|
378
|
+
naanlib.js.i = options.import;
|
|
295
379
|
var startOptions = {};
|
|
296
380
|
if (options.noWelcome)
|
|
297
381
|
startOptions.noWelcome = true;
|
|
298
|
-
|
|
382
|
+
else
|
|
383
|
+
naanlib.banner();
|
|
384
|
+
if (options.state)
|
|
385
|
+
startOptions.state = loadState(options.state);
|
|
386
|
+
if (options.cmd)
|
|
387
|
+
startOptions.cmd = options.cmd;
|
|
299
388
|
naanlib.start(startOptions);
|
|
300
389
|
};
|
|
301
390
|
|
package/lib/env_nodeworker.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2019-
|
|
9
|
+
* Copyright (c) 2019-2024 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -28,6 +28,18 @@ exports.NaanWorkerActivate = function NaanWorkerActivate(cbReady) {
|
|
|
28
28
|
cbReady(naancon);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
if (process.execArgv.includes("--inspect-brk"))
|
|
32
|
+
{
|
|
33
|
+
import("node:inspector").then(
|
|
34
|
+
function (inspector) {
|
|
35
|
+
inspector.open();
|
|
36
|
+
inspector.waitForDebugger();
|
|
37
|
+
/*jshint debug:true */
|
|
38
|
+
debugger;
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
/*
|
|
32
44
|
* NaanControllerNodeWorker
|
|
33
45
|
*
|
|
@@ -59,7 +71,11 @@ exports.NaanWorkerActivate = function NaanWorkerActivate(cbReady) {
|
|
|
59
71
|
this.setRequire = function setRequire(req) { // override require function
|
|
60
72
|
naanlib.js.r = req;
|
|
61
73
|
};
|
|
62
|
-
|
|
74
|
+
|
|
75
|
+
this.setImport = function setImport(imp) { // override import function
|
|
76
|
+
naanlib.js.i = imp;
|
|
77
|
+
};
|
|
78
|
+
|
|
63
79
|
this.setDirectory = function setDirectory(path) { // override base directory
|
|
64
80
|
naanlib.js.d = path;
|
|
65
81
|
};
|
|
@@ -140,7 +156,7 @@ exports.NaanWorkerActivate = function NaanWorkerActivate(cbReady) {
|
|
|
140
156
|
if (msg.altcmd)
|
|
141
157
|
naanlib.textLine(msg.altcmd);
|
|
142
158
|
/*
|
|
143
|
-
### already started ###
|
|
159
|
+
### already started by textLine() if not before ###
|
|
144
160
|
naanlib.start({
|
|
145
161
|
state: msg.state,
|
|
146
162
|
cmd: msg.altcmd
|
|
@@ -161,10 +177,12 @@ exports.NaanWorkerActivate = function NaanWorkerActivate(cbReady) {
|
|
|
161
177
|
}
|
|
162
178
|
});
|
|
163
179
|
|
|
180
|
+
naanlib.banner();
|
|
181
|
+
naanlib.start(false); // start explicitly
|
|
182
|
+
|
|
164
183
|
msgPort.postMessage({
|
|
165
184
|
id: "loaded" // initialization complete
|
|
166
185
|
});
|
|
167
|
-
naanlib.banner();
|
|
168
186
|
}
|
|
169
187
|
|
|
170
188
|
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2019-
|
|
9
|
+
* Copyright (c) 2019-2023 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -71,6 +71,10 @@ exports.handler = function awsHandler(event, context, callback) {
|
|
|
71
71
|
naanlib.js.r = req;
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
this.setImport = function setImport(imp) { // override import function
|
|
75
|
+
naanlib.js.i = imp;
|
|
76
|
+
};
|
|
77
|
+
|
|
74
78
|
this.setDirectory = function setDirectory(path) { // override base directory
|
|
75
79
|
naanlib.js.d = path;
|
|
76
80
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2020-
|
|
9
|
+
* Copyright (c) 2020-2024 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -318,7 +318,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
318
318
|
//
|
|
319
319
|
// For browsers, convert a ReadableStream to an array buffer.
|
|
320
320
|
//
|
|
321
|
-
|
|
321
|
+
closure readableStreamToArrayBuffer(stream, local result, reader, error, data, chunk) {
|
|
322
322
|
result = xnew(js.w.Uint8Array, 0)
|
|
323
323
|
reader = stream.getReader()
|
|
324
324
|
loop {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2020-
|
|
9
|
+
* Copyright (c) 2020-2024 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -202,7 +202,7 @@ closure psmaConnector(psm, local connClassID, connector, watch) {
|
|
|
202
202
|
info = {
|
|
203
203
|
classID: "AWS S3"
|
|
204
204
|
type: "AWS S3 bucket"
|
|
205
|
-
services: ["
|
|
205
|
+
services: ["NideDB", "NideFS"]
|
|
206
206
|
}
|
|
207
207
|
`(error, creds) = connector.vault.accessResource(resID)
|
|
208
208
|
if creds {
|
package/test/test_01_core.nlg
CHANGED
|
@@ -616,12 +616,12 @@ RegisterTestCategory("core", [
|
|
|
616
616
|
["oo;", "{ true: a, 0.3333333333333333: b }"],
|
|
617
617
|
|
|
618
618
|
//
|
|
619
|
-
// object getters
|
|
619
|
+
// object getters/setters
|
|
620
620
|
//
|
|
621
621
|
|
|
622
622
|
[ "oo=new(object);", "Object{0}" ],
|
|
623
|
-
[ "oo['..prop'] = function(
|
|
624
|
-
[ "oo['.=prop'] = function(value) { oo.value = value };>", "(function lambda (value) (Lib::set\\. oo (`` value) value))" ],
|
|
623
|
+
[ "oo@['..prop'] = function() { oo.value };>", "(function lambda false (`. oo value))" ],
|
|
624
|
+
[ "oo@['.=prop'] = function(value) { oo.value = value };>", "(function lambda (value) (Lib::set\\. oo (`` value) value))" ],
|
|
625
625
|
[ "oo.prop = 8;", "8" ],
|
|
626
626
|
[ "oo.prop;", "8" ],
|
|
627
627
|
[ "oo['prop'] = 9;", "9" ],
|
|
@@ -633,8 +633,34 @@ RegisterTestCategory("core", [
|
|
|
633
633
|
[ "xset(oo, 'prop', 11);", "11" ],
|
|
634
634
|
[ "oo.prop;", "11" ],
|
|
635
635
|
[ "oo.value;", "10" ],
|
|
636
|
-
[ "oo.*;", '("
|
|
636
|
+
[ "oo.*;", '("value", "prop")' ],
|
|
637
637
|
|
|
638
|
+
//
|
|
639
|
+
// object hierarchy
|
|
640
|
+
//
|
|
641
|
+
|
|
642
|
+
[ "oo=new(object);", "Object{0}" ],
|
|
643
|
+
[ "op=new(object);", "Object{0}" ],
|
|
644
|
+
[ "oc=new(object);", "Object{0}" ],
|
|
645
|
+
[ "oo@['.class'] = oc;", "Object{0}" ],
|
|
646
|
+
[ "oc@['.parent'] = op;", "Object{0}" ],
|
|
647
|
+
[ "op.print = function (x) { print(self.id) };>", "(function lambda (x) (print (`. self id)))" ],
|
|
648
|
+
[ "oo.id = `oo;", "oo" ],
|
|
649
|
+
[ "oc.id = `oc;", "oc" ],
|
|
650
|
+
[ "op.id = `op;", "op" ],
|
|
651
|
+
[ "oo.*", '("id")' ],
|
|
652
|
+
[ "oc.*", '("id")' ],
|
|
653
|
+
[ "op.*", '("print", "id")' ],
|
|
654
|
+
[ "oo.print()", "oo|oo" ],
|
|
655
|
+
|
|
656
|
+
[ "op@['..prop'] = function() { self.value };>", "(function lambda false (`. self value))" ],
|
|
657
|
+
[ "oc@['.=prop'] = function(value) { self.value = value };>", "(function lambda (value) (Lib::set\\. self (`` value) value))" ],
|
|
658
|
+
[ "op.prop = op55;", "op55" ],
|
|
659
|
+
[ "oo.prop;", "false" ],
|
|
660
|
+
[ "op.prop;", "op55" ],
|
|
661
|
+
[ "oo.prop = oo11;", "oo11" ],
|
|
662
|
+
[ "oo.prop;", "oo11" ],
|
|
663
|
+
[ "oc.prop;", "false" ],
|
|
638
664
|
|
|
639
665
|
//
|
|
640
666
|
// object hooks
|