@naanlang/naan 1.0.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 +21 -0
- package/README.md +46 -0
- package/dist/env_web.js +431 -0
- package/dist/naan.min.js +73 -0
- package/frameworks/browser/browser.nlg +30 -0
- package/frameworks/browser/pouchdb/pouchdb.min.js +7 -0
- package/frameworks/browser/spark-md5/spark-md5.min.js +1 -0
- package/frameworks/browser/sworker.js +192 -0
- package/frameworks/browser/terminals.nlg +787 -0
- package/frameworks/browser/workers.nlg +386 -0
- package/frameworks/client/apiclient.nlg +183 -0
- package/frameworks/client/client.nlg +29 -0
- package/frameworks/client/psm_client.nlg +572 -0
- package/frameworks/common/common.nlg +464 -0
- package/frameworks/common/preferences.nlg +131 -0
- package/frameworks/common/repltools.nlg +100 -0
- package/frameworks/common/watching.nlg +97 -0
- package/frameworks/node/apiserver.nlg +399 -0
- package/frameworks/node/filesystem.nlg +1012 -0
- package/frameworks/node/gitter.nlg +234 -0
- package/frameworks/node/node.nlg +81 -0
- package/frameworks/node/psm_server.nlg +465 -0
- package/frameworks/node/worker.nlg +560 -0
- package/frameworks/project/build.nlg +1229 -0
- package/frameworks/project/jszip.js +30 -0
- package/frameworks/project/jszip.nlg +87 -0
- package/frameworks/project/proj_cliser.nlg +139 -0
- package/frameworks/project/proj_console.nlg +137 -0
- package/frameworks/project/proj_folder.nlg +143 -0
- package/frameworks/project/proj_lambda.nlg +137 -0
- package/frameworks/project/proj_static.nlg +138 -0
- package/frameworks/project/project.nlg +29 -0
- package/frameworks/project/projects.nlg +587 -0
- package/frameworks/project/uglifyjs.js +1 -0
- package/frameworks/project/uglifyjs.nlg +79 -0
- package/frameworks/running/debugcom.nlg +163 -0
- package/frameworks/running/debugnub.nlg +565 -0
- package/frameworks/running/debugutil.nlg +510 -0
- package/frameworks/running/executors.nlg +767 -0
- package/frameworks/running/running.nlg +151 -0
- package/frameworks/running/sourcecode.nlg +346 -0
- package/frameworks/running/taskexec.nlg +196 -0
- package/frameworks/storage/dbt_pouch.nlg +773 -0
- package/frameworks/storage/file_manager.nlg +772 -0
- package/frameworks/storage/psm.nlg +326 -0
- package/frameworks/storage/psm_dbtables.nlg +814 -0
- package/frameworks/storage/resources.nlg +445 -0
- package/frameworks/storage/storage.nlg +52 -0
- package/lib/browser/env_web.js +431 -0
- package/lib/browser/env_webworker.js +146 -0
- package/lib/browser/require.js +1653 -0
- package/lib/core/naanlib.js +73 -0
- package/lib/env_node.js +282 -0
- package/lib/env_nodeworker.js +165 -0
- package/lib/node_repl.js +25 -0
- package/lib/node_repl_init.nlg +52 -0
- package/package.json +13 -0
- package/plugins/gitClient/clientops.nlg +317 -0
- package/plugins/gitClient/gitClient.nlg +63 -0
- package/plugins/gitClient/gitutils.nlg +1331 -0
- package/plugins/gitClient/minimatch.js +945 -0
- package/plugins/gitClient/minimatch_license.txt +15 -0
- package/plugins/gitClient/minimatch_readme.md +208 -0
- package/plugins/nodeLib/nodeLib.nlg +26 -0
- package/plugins/nodeLib/node_cp.nlg +65 -0
- package/plugins/nodeLib/node_fs.nlg +137 -0
- package/plugins/nodeLib/node_https.nlg +172 -0
- package/plugins/nodeLib/node_util.nlg +180 -0
- package/plugins/serviceAws/aws/aws-sdk.min.js +88 -0
- package/plugins/serviceAws/aws/lambda_rest_index.js +122 -0
- package/plugins/serviceAws/aws/lambda_rest_init.nlg +58 -0
- package/plugins/serviceAws/aws/lambda_ws_index.js +498 -0
- package/plugins/serviceAws/aws/lambda_ws_init.nlg +49 -0
- package/plugins/serviceAws/aws_cloudwatchlogs.nlg +122 -0
- package/plugins/serviceAws/aws_cognito.nlg +76 -0
- package/plugins/serviceAws/aws_dynamo.nlg +509 -0
- package/plugins/serviceAws/aws_lambda.nlg +95 -0
- package/plugins/serviceAws/aws_s3.nlg +134 -0
- package/plugins/serviceAws/aws_utils.nlg +86 -0
- package/plugins/serviceAws/dbt_aws.nlg +769 -0
- package/plugins/serviceAws/lambda_naan_control.nlg +175 -0
- package/plugins/serviceAws/psm_aws.nlg +258 -0
- package/plugins/serviceAws/serviceAws.nlg +38 -0
- package/plugins/serviceGitHub/gitops.nlg +522 -0
- package/plugins/serviceGitHub/psm_github.nlg +205 -0
- package/plugins/serviceGitHub/serviceGitHub.nlg +65 -0
- package/plugins/serviceGitLab/gitops.nlg +528 -0
- package/plugins/serviceGitLab/psm_gitlab.nlg +205 -0
- package/plugins/serviceGitLab/serviceGitLab.nlg +65 -0
- package/test/harness.nlg +312 -0
- package/test/node_test.js +33 -0
- package/test/test_01_core.nlg +768 -0
- package/test/test_02_context.nlg +269 -0
- package/test/test_03_jsinterop.nlg +137 -0
- package/test/test_04_numerics.nlg +450 -0
- package/test/test_05_strings.nlg +63 -0
- package/test/test_06_lingoparse.nlg +500 -0
- package/test/test_07_lingo.nlg +623 -0
package/lib/env_node.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* env_node.js
|
|
3
|
+
* Naanlib
|
|
4
|
+
*
|
|
5
|
+
* Host Naan in the NodeJS REPL environment.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2017-2021 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
(function(exports){
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* NaanNodeREPL
|
|
17
|
+
*
|
|
18
|
+
* This is executes Naan with a NodeJS REPL.
|
|
19
|
+
*
|
|
20
|
+
* Currently defined options are:
|
|
21
|
+
* {
|
|
22
|
+
* replDisable: <boolean> // disable REPL and just respond to textCommand in API
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
exports.NaanNodeREPL = function NaanNodeREPL(options) {
|
|
28
|
+
|
|
29
|
+
"use strict";
|
|
30
|
+
/*jshint -W024 */
|
|
31
|
+
var undefined;
|
|
32
|
+
|
|
33
|
+
//
|
|
34
|
+
// Initialization
|
|
35
|
+
//
|
|
36
|
+
|
|
37
|
+
if (typeof(options) != 'object')
|
|
38
|
+
options = { };
|
|
39
|
+
var repl = require('repl');
|
|
40
|
+
var process = require('process');
|
|
41
|
+
var Naan = require('./core/naanlib');
|
|
42
|
+
var naanlib = new Naan.Naanlib();
|
|
43
|
+
var servSelf = this;
|
|
44
|
+
naanlib.js.t = this; // allow us to be accessed from Naan
|
|
45
|
+
var termops;
|
|
46
|
+
var outEnable = !options.replDisable;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
//==========================================================================
|
|
50
|
+
// API
|
|
51
|
+
//--------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
this.setRequire = function setRequire(req) { // override require function
|
|
54
|
+
naanlib.js.r = req;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
this.setDirectory = function setDirectory(path) { // override base directory
|
|
58
|
+
naanlib.js.d = path;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
this.textCommand = function textCommand(cmd) { // send a command without echo
|
|
62
|
+
outEnable = true;
|
|
63
|
+
naanlib.textLine(cmd);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
//==========================================================================
|
|
68
|
+
// NodeJS REPL Terminal Interface
|
|
69
|
+
//--------------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
//
|
|
72
|
+
// Prepare the NodeJS console.
|
|
73
|
+
//
|
|
74
|
+
|
|
75
|
+
function myEval(cmd, context, filename, callback)
|
|
76
|
+
{ // Node REPL does too much crap
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!options.replDisable)
|
|
80
|
+
{
|
|
81
|
+
var nprompt = repl.start({ prompt: 'Naan> ', eval: myEval});
|
|
82
|
+
|
|
83
|
+
nprompt.on('line', function(cmd) { // process raw command line
|
|
84
|
+
if (cmd.charAt(0) != ".") {
|
|
85
|
+
textToRemoteTerm(cmd);
|
|
86
|
+
naanlib.textLine(cmd + "\n");
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
//
|
|
91
|
+
// Hook the ^C interrupt
|
|
92
|
+
//
|
|
93
|
+
|
|
94
|
+
nprompt._events.SIGINT = function () {
|
|
95
|
+
naanlib.escape();
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
//
|
|
99
|
+
// Hook an exit command
|
|
100
|
+
//
|
|
101
|
+
|
|
102
|
+
nprompt.on('exit', function() {
|
|
103
|
+
process.exit();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//
|
|
108
|
+
// Interpreter's console/debug output
|
|
109
|
+
//
|
|
110
|
+
|
|
111
|
+
naanlib.onText(function (text, level) {
|
|
112
|
+
if (level) {
|
|
113
|
+
if (level >= 5)
|
|
114
|
+
console.log("\x1b[36m" + text + "\x1b[0m"); // cyan for builtin logging
|
|
115
|
+
else if (level >= 4)
|
|
116
|
+
console.log("\x1b[34m" + text + "\x1b[0m"); // blue for Naan function logging
|
|
117
|
+
else if (level >= 3)
|
|
118
|
+
console.log("\x1b[31m" + text + "\x1b[0m"); // light read for warnings
|
|
119
|
+
else if (level >= 2)
|
|
120
|
+
console.log("\x1b[32m" + text + "\x1b[0m"); // green for Naan.debug.debuglog logging
|
|
121
|
+
else
|
|
122
|
+
console.log("\x1b[31m\x1b[1m" + text + "\x1b[0m"); // heavy red for errors
|
|
123
|
+
if (termops)
|
|
124
|
+
{
|
|
125
|
+
setTimeout(function () {
|
|
126
|
+
termops.debugtext(text, level);
|
|
127
|
+
}, 1);
|
|
128
|
+
}
|
|
129
|
+
} else if (outEnable) {
|
|
130
|
+
process.stdout.write(text);
|
|
131
|
+
textToRemoteTerm(text);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
//==========================================================================
|
|
137
|
+
// Naan Remote Terminal Interface
|
|
138
|
+
//--------------------------------------------------------------------------
|
|
139
|
+
|
|
140
|
+
//
|
|
141
|
+
// Attach
|
|
142
|
+
//
|
|
143
|
+
// Attach a terminal controller to our interpreter.
|
|
144
|
+
//
|
|
145
|
+
|
|
146
|
+
this.Attach = function(tops) {
|
|
147
|
+
termops = tops;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
//
|
|
151
|
+
// Detach
|
|
152
|
+
//
|
|
153
|
+
// Detach the terminal from the interpreter.
|
|
154
|
+
//
|
|
155
|
+
|
|
156
|
+
this.Detach = function(tops) {
|
|
157
|
+
if (termops === tops)
|
|
158
|
+
termops = false;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
//
|
|
162
|
+
// OnMessage
|
|
163
|
+
//
|
|
164
|
+
// Respond to a message. Note that this calls Naan via timeouts to handle the use case that the
|
|
165
|
+
// messages are originating from the interpreter itself, so that it does not call itself back
|
|
166
|
+
// recurxsively. That would be Very Bad™.
|
|
167
|
+
//
|
|
168
|
+
|
|
169
|
+
this.ReplyMessage = function ReplyMessage(data) {
|
|
170
|
+
if (termops)
|
|
171
|
+
{
|
|
172
|
+
setTimeout(function () {
|
|
173
|
+
termops.messageout(data);
|
|
174
|
+
}, 1);
|
|
175
|
+
}
|
|
176
|
+
return (data);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
var nodeListener;
|
|
180
|
+
this.OnMessage = function OnMessage(proc) {
|
|
181
|
+
nodeListener = proc;
|
|
182
|
+
return (proc);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
this.ReplyDebugger = function ReplyDebugger(data) {
|
|
186
|
+
if (termops)
|
|
187
|
+
{
|
|
188
|
+
setTimeout(function () {
|
|
189
|
+
termops.debugout(data);
|
|
190
|
+
}, 1);
|
|
191
|
+
}
|
|
192
|
+
return (data);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
var debugListener;
|
|
196
|
+
this.OnDebugger = function OnDebugger(proc) {
|
|
197
|
+
debugListener = proc;
|
|
198
|
+
return (proc);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
//
|
|
202
|
+
// DispatchMessage
|
|
203
|
+
//
|
|
204
|
+
// Respond to a message. Note that this calls Naan via timeouts to handle the use case that the
|
|
205
|
+
// messages are originating from the interpreter itself, so that it does not call itself back
|
|
206
|
+
// recurxsively. That would be Very Bad™.
|
|
207
|
+
//
|
|
208
|
+
|
|
209
|
+
this.DispatchMessage = function(msg) {
|
|
210
|
+
if (msg.id == "interrupt")
|
|
211
|
+
{ // interrupt request from remote terminal
|
|
212
|
+
setTimeout(function () {
|
|
213
|
+
naanlib.escape(); // interrupt request from terminal
|
|
214
|
+
}, 1);
|
|
215
|
+
}
|
|
216
|
+
else if (msg.id == "keyline")
|
|
217
|
+
{ // typing from remote terminal
|
|
218
|
+
setTimeout(function () {
|
|
219
|
+
process.stdout.write(msg.text + "\r\n");
|
|
220
|
+
outEnable = true;
|
|
221
|
+
naanlib.textLine(msg.text); // keyboard text from terminal
|
|
222
|
+
}, 1);
|
|
223
|
+
}
|
|
224
|
+
else if (msg.id == "targetin")
|
|
225
|
+
{
|
|
226
|
+
setTimeout(function () {
|
|
227
|
+
if (nodeListener)
|
|
228
|
+
nodeListener(msg.data); // received a generic message
|
|
229
|
+
}, 1);
|
|
230
|
+
}
|
|
231
|
+
else if (msg.id == "debugin")
|
|
232
|
+
{
|
|
233
|
+
setTimeout(function () {
|
|
234
|
+
if (debugListener)
|
|
235
|
+
debugListener(msg.data); // received a debugger message
|
|
236
|
+
}, 1);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// textToRemoteTerm
|
|
241
|
+
//
|
|
242
|
+
// Echo text typed locally to any remote terminal(s) that might be attached.
|
|
243
|
+
|
|
244
|
+
function textToRemoteTerm(text) {
|
|
245
|
+
if (termops)
|
|
246
|
+
{
|
|
247
|
+
setTimeout(function () {
|
|
248
|
+
termops.textout(text);
|
|
249
|
+
}, 1);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
//
|
|
254
|
+
// Status updates
|
|
255
|
+
//
|
|
256
|
+
// Send status updates once per second while a terminal is attached.
|
|
257
|
+
//
|
|
258
|
+
|
|
259
|
+
setInterval(function() {
|
|
260
|
+
if (termops && termops.status)
|
|
261
|
+
{
|
|
262
|
+
var samples = naanlib.status(1);
|
|
263
|
+
if (samples.length > 0)
|
|
264
|
+
termops.status({
|
|
265
|
+
sample: samples[0]
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}, 1000);
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
//==========================================================================
|
|
272
|
+
// Start the Naan Interpreter
|
|
273
|
+
//--------------------------------------------------------------------------
|
|
274
|
+
|
|
275
|
+
naanlib.banner();
|
|
276
|
+
naanlib.start();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
})(typeof exports === 'undefined'? this.NaanNodeREPL={}: exports);
|
|
280
|
+
|
|
281
|
+
if (typeof(module) && typeof(module.exports))
|
|
282
|
+
module.exports = this.NaanNodeREPL; // export for NodeJS
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* env_nodeworker.js
|
|
3
|
+
* Naanlib
|
|
4
|
+
*
|
|
5
|
+
* Host Naan in the NodeJS worker thread environment.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2019-2021 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* NaanWorkerActivate
|
|
16
|
+
*
|
|
17
|
+
* Activate a new worker.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
exports.NaanWorkerActivate = function NaanWorkerActivate(cbReady) {
|
|
22
|
+
|
|
23
|
+
// initialize
|
|
24
|
+
|
|
25
|
+
var threads = require('worker_threads');
|
|
26
|
+
threads.parentPort.once('message', function (value) {
|
|
27
|
+
var naancon = new NaanControllerNodeWorker(value.hereIsYourPort);
|
|
28
|
+
cbReady(naancon);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* NaanControllerNodeWorker
|
|
33
|
+
*
|
|
34
|
+
* This is the Node worker that executes Naan.
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
function NaanControllerNodeWorker(msgPort) {
|
|
39
|
+
|
|
40
|
+
"use strict";
|
|
41
|
+
/*jshint -W024 */
|
|
42
|
+
var undefined;
|
|
43
|
+
|
|
44
|
+
//
|
|
45
|
+
// Initialization
|
|
46
|
+
//
|
|
47
|
+
|
|
48
|
+
var Naanlang = require('./core/naanlib');
|
|
49
|
+
var naanlib = new Naanlang.Naanlib();
|
|
50
|
+
var workSelf = this;
|
|
51
|
+
workSelf.anaan = naanlib.js.n;
|
|
52
|
+
naanlib.js.t = workSelf;
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
//==========================================================================
|
|
56
|
+
// API
|
|
57
|
+
//--------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
this.setRequire = function setRequire(req) { // override require function
|
|
60
|
+
naanlib.js.r = req;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
this.setDirectory = function setDirectory(path) { // override base directory
|
|
64
|
+
naanlib.js.d = path;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
this.textCommand = function textCommand(cmd) { // send a command
|
|
68
|
+
naanlib.textLine(cmd);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
//==========================================================================
|
|
73
|
+
// NodeJS Worker Terminal Interface
|
|
74
|
+
//--------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
naanlib.onText(function(text, level) {
|
|
77
|
+
if (level)
|
|
78
|
+
msgPort.postMessage({
|
|
79
|
+
id: "debugtext",
|
|
80
|
+
text: text,
|
|
81
|
+
level: level
|
|
82
|
+
});
|
|
83
|
+
else
|
|
84
|
+
msgPort.postMessage({
|
|
85
|
+
id: "textout",
|
|
86
|
+
text: text
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
setInterval(function() {
|
|
91
|
+
var samples = naanlib.status(1);
|
|
92
|
+
if (samples.length > 0)
|
|
93
|
+
msgPort.postMessage({ // periodic worker status
|
|
94
|
+
id: "status",
|
|
95
|
+
status: {
|
|
96
|
+
sample: samples[0]
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}, 1000);
|
|
100
|
+
|
|
101
|
+
workSelf.ReplyMessage = function ReplyMessage(data) {
|
|
102
|
+
msgPort.postMessage({ // worker is sending a message
|
|
103
|
+
id: "targetout",
|
|
104
|
+
data: data
|
|
105
|
+
});
|
|
106
|
+
return (data);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
var workerListener;
|
|
110
|
+
workSelf.OnMessage = function OnMessage(proc) {
|
|
111
|
+
workerListener = proc;
|
|
112
|
+
return (proc);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
workSelf.ReplyDebugger = function ReplyDebugger(data) {
|
|
116
|
+
msgPort.postMessage({ // target is sending debug data
|
|
117
|
+
id: "debugout",
|
|
118
|
+
data: data
|
|
119
|
+
});
|
|
120
|
+
return (data);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
var debugListener;
|
|
124
|
+
workSelf.OnDebugger = function OnDebugger(proc) {
|
|
125
|
+
debugListener = proc;
|
|
126
|
+
return (proc);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
msgPort.on("message", function(msg) {
|
|
130
|
+
if (msg.id == "interrupt")
|
|
131
|
+
naanlib.escape(); // interrupt request from terminal
|
|
132
|
+
else if (msg.id == "keyline")
|
|
133
|
+
naanlib.textLine(msg.text); // keyboard text from terminal
|
|
134
|
+
else if (msg.id == "start")
|
|
135
|
+
{ // start execution with optional state
|
|
136
|
+
if (typeof(__dirname) !== "undefined")
|
|
137
|
+
naanlib.js.h = naanlib.js.d; // set host directory path
|
|
138
|
+
if (msg.dirpath)
|
|
139
|
+
naanlib.js.d = msg.dirpath; // set owner directory path
|
|
140
|
+
naanlib.start({
|
|
141
|
+
state: msg.state,
|
|
142
|
+
cmd: msg.altcmd
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else if (msg.id == "import")
|
|
146
|
+
importScripts(msg.script); // load a JavaScript
|
|
147
|
+
else if (msg.id == "targetin")
|
|
148
|
+
{
|
|
149
|
+
if (workerListener)
|
|
150
|
+
workerListener(msg.data); // worker received a message
|
|
151
|
+
}
|
|
152
|
+
else if (msg.id == "debugin")
|
|
153
|
+
{
|
|
154
|
+
if (debugListener)
|
|
155
|
+
debugListener(msg.data); // target received a message
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
msgPort.postMessage({
|
|
160
|
+
id: "loaded" // initialization complete
|
|
161
|
+
});
|
|
162
|
+
naanlib.banner();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
};
|
package/lib/node_repl.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node_repl.js
|
|
3
|
+
* Naanlib
|
|
4
|
+
*
|
|
5
|
+
* Provide a Naan repl in Node.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2021 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
"use strict";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* Begin
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
var NaanNodeREPL = require('./env_node.js');
|
|
22
|
+
|
|
23
|
+
var naanrepl = new NaanNodeREPL();
|
|
24
|
+
naanrepl.setDirectory(__dirname);
|
|
25
|
+
naanrepl.textCommand("nodeparse('node_repl_init.nlg');;");
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node_repl_init.nlg
|
|
3
|
+
* Naanlib
|
|
4
|
+
*
|
|
5
|
+
* Initialize the Naan repl in Node.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2018-2021 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
loglevel(2);
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* debug
|
|
18
|
+
*
|
|
19
|
+
* Handy utility to enter the debugger just before an expression is evaluated.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
macro debug(expr) {
|
|
24
|
+
if atom(expr)
|
|
25
|
+
first(expr)
|
|
26
|
+
else {
|
|
27
|
+
expr = list(list(Naan.debug.debugger, 1), expr)
|
|
28
|
+
second(eval(expr)) }
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
* dcaller
|
|
34
|
+
*
|
|
35
|
+
* Report the caller of the specified function for debugging. By default this ignores lambda
|
|
36
|
+
* functions, but you can pass true for argument two to report them.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
function dcaller(proc, lambdaOK, local x, found) {
|
|
41
|
+
for x in stacktrace()
|
|
42
|
+
if procedure(list(x.0)) {
|
|
43
|
+
if !lambdaOK && lambda(x.1)
|
|
44
|
+
continue
|
|
45
|
+
if found && !proc
|
|
46
|
+
return (x.1) // found procedure name symbol
|
|
47
|
+
else if x.1 == dcaller
|
|
48
|
+
found = true
|
|
49
|
+
else if proc && x.1 == proc
|
|
50
|
+
proc = false }
|
|
51
|
+
false
|
|
52
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@naanlang/naan",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "Richard C. Zulch",
|
|
5
|
+
"description": "Naan™ software platform",
|
|
6
|
+
"main": "./lib/core/naanlib.js",
|
|
7
|
+
"browser": "./dist/naanlib.min.js",
|
|
8
|
+
"license" : "MIT",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node lib/node_repl.js",
|
|
11
|
+
"test": "node test/node_test.js"
|
|
12
|
+
}
|
|
13
|
+
}
|