@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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* model.nlg
|
|
3
|
+
* Naanlib/frameworks/service
|
|
4
|
+
*
|
|
5
|
+
* Naan service model.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2023-2026 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* ServiceModel
|
|
16
|
+
*
|
|
17
|
+
* Model object for services, such as instance management. This is used to conceal architectural
|
|
18
|
+
* details from service users.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
closure ServiceModel(local model) {
|
|
23
|
+
global()
|
|
24
|
+
model = new(object, this)
|
|
25
|
+
model@\.class = new(object)
|
|
26
|
+
|
|
27
|
+
// add
|
|
28
|
+
//
|
|
29
|
+
// Add a location to our model with the specified name.
|
|
30
|
+
//
|
|
31
|
+
model@\.class.add = function add(name, local node) {
|
|
32
|
+
if !string(name) || name.trim() == ""
|
|
33
|
+
throw("ServiceModel.add: invalid name")
|
|
34
|
+
node = new(object)
|
|
35
|
+
node.id = name
|
|
36
|
+
node.parent = self
|
|
37
|
+
node@\.parent = self
|
|
38
|
+
self[name] = node
|
|
39
|
+
node
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// children
|
|
43
|
+
//
|
|
44
|
+
// List the ids of the children of the specified location, which is false for the root.
|
|
45
|
+
//
|
|
46
|
+
model@\.class.children = function children(parent) {
|
|
47
|
+
self.*.toarray.filter(function(id) { !id.startsWith(".") })
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// finis
|
|
51
|
+
|
|
52
|
+
model
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* modelInit
|
|
58
|
+
*
|
|
59
|
+
* Initialize the component.
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
function modelInit(local manifest) {
|
|
64
|
+
manifest = `(ServiceModel, modelInit)
|
|
65
|
+
|
|
66
|
+
Naan.module.build(module.id, "model", function(modobj, compobj) {
|
|
67
|
+
require("./service.nlg")
|
|
68
|
+
compobj.manifest = manifest
|
|
69
|
+
modobj.exports.ServiceModel = ServiceModel
|
|
70
|
+
})
|
|
71
|
+
} ();
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* nubnode.nlg
|
|
3
|
+
* Naanlib/frameworks/service
|
|
4
|
+
*
|
|
5
|
+
* Nub for node worker access to IMP.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2026 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* NodeWorkerNub
|
|
16
|
+
*
|
|
17
|
+
* NodeWorkerNub provides an IMP interface that runs on node workers. This allows the worker to
|
|
18
|
+
* communicate with the IMP network and the main thread. The worker IMP must be created before this.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
closure NodeWorkerNub(imp, options, local nownub) {
|
|
23
|
+
global(App,js)
|
|
24
|
+
if App.workerNub
|
|
25
|
+
return (App.workerNub) // singleton
|
|
26
|
+
|
|
27
|
+
options = merge({
|
|
28
|
+
name: "NodeWorkerNub"
|
|
29
|
+
type: "node-worker-nub"
|
|
30
|
+
}, options)
|
|
31
|
+
nownub = new(object, this)
|
|
32
|
+
nownub.instanceID = imp.us.instanceID || UUID()
|
|
33
|
+
nownub.dispatcher = require("naanlib:frameworks/running/taskexec.nlg").TaskDispatcher(false, false, "NodeWorkerNub")
|
|
34
|
+
|
|
35
|
+
// impReceive
|
|
36
|
+
//
|
|
37
|
+
// Receive a remote request and reply to it.
|
|
38
|
+
//
|
|
39
|
+
nownub.impReceive = closure impReceive(message, sourceID) {
|
|
40
|
+
if message.id == "targetin"
|
|
41
|
+
nownub.dispatcher(message.data, function(reply) {
|
|
42
|
+
nownub.sender(sourceID, {
|
|
43
|
+
id: "targetout",
|
|
44
|
+
data: reply
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// impUnknown
|
|
50
|
+
//
|
|
51
|
+
// Received an unknown destination notice from the other side.
|
|
52
|
+
//
|
|
53
|
+
nownub.impUnknown = function impUnknown(unknownID, sourceID, gateway) {
|
|
54
|
+
if !gateway
|
|
55
|
+
debuglog("NodeWorkerNub.impUnknownID:", unknownID, "sourceID:", sourceID)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// mainContext
|
|
59
|
+
//
|
|
60
|
+
// Convenience method to get the main thread and its remote context.
|
|
61
|
+
//
|
|
62
|
+
nownub.mainContext = function mainContext(local error, mtx, ctx) {
|
|
63
|
+
if !(mtx = nownub.mtx) {
|
|
64
|
+
`(error, mtx) = require("../running/remote_req.nlg").MainThread()
|
|
65
|
+
if error
|
|
66
|
+
return (list(error))
|
|
67
|
+
nownub.mtx = mtx
|
|
68
|
+
}
|
|
69
|
+
`(error, ctx) = mtx.context()
|
|
70
|
+
if error
|
|
71
|
+
list(error)
|
|
72
|
+
else
|
|
73
|
+
list(false, ctx, mtx)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// execProxy
|
|
77
|
+
//
|
|
78
|
+
// Get a proxy object for our executor on the main thread.
|
|
79
|
+
//
|
|
80
|
+
nownub.execProxy = closure execProxy(error, ctx, execID, exec) {
|
|
81
|
+
`(error, ctx) = mainContext()
|
|
82
|
+
if !error
|
|
83
|
+
`(error, execID) = ctx.eval(subatq(App.imp.pipes.destID.info.ourID, [list(`destID, nownub.instanceID)]))
|
|
84
|
+
if !error
|
|
85
|
+
`(error, exec) = ctx.eval(subatq(App.imp.direct.execID.obj, [list(`execID, execID)]))
|
|
86
|
+
list(error, exec)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// message event
|
|
90
|
+
//
|
|
91
|
+
// Incoming data.
|
|
92
|
+
//
|
|
93
|
+
js.t.msgPort.on("message", function(msg) {
|
|
94
|
+
if msg.id == "naan-imp-node"
|
|
95
|
+
nownub.impconn.dispatch(new(msg.data))
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
// register our connects *after* the receivers are configured above
|
|
99
|
+
|
|
100
|
+
nownub.sender = imp.register(nownub, {
|
|
101
|
+
name: options.name
|
|
102
|
+
type: options.type
|
|
103
|
+
meta: options.meta || undefined
|
|
104
|
+
instanceID: nownub.instanceID
|
|
105
|
+
services: [ "naan-node-worker" ]
|
|
106
|
+
})
|
|
107
|
+
nownub.impconn = imp.requester(function(data) {
|
|
108
|
+
js.t.msgPort.postMessage({ // send to main
|
|
109
|
+
id: "naan-imp-node",
|
|
110
|
+
data: data
|
|
111
|
+
})
|
|
112
|
+
list(false, { sent: true })
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
// finis
|
|
116
|
+
|
|
117
|
+
App.workerNub = nownub
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
/*
|
|
122
|
+
* nubnoInit
|
|
123
|
+
*
|
|
124
|
+
* Initialize the component.
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
function nubnoInit(local manifest) {
|
|
129
|
+
manifest = `(NodeWorkerNub, nubnoInit)
|
|
130
|
+
|
|
131
|
+
Naan.module.build(module.id, "nubnode", function(modobj, compobj) {
|
|
132
|
+
require("./service.nlg")
|
|
133
|
+
compobj.manifest = manifest
|
|
134
|
+
modobj.exports.NodeWorkerNub = NodeWorkerNub
|
|
135
|
+
})
|
|
136
|
+
} ();
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* nubweb.nlg
|
|
3
|
+
* Naanlib/frameworks/service
|
|
4
|
+
*
|
|
5
|
+
* Nub for web worker access to IMP.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2026 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* WebWorkerNub
|
|
16
|
+
*
|
|
17
|
+
* WebWorkerNub provides an IMP interface that runs on web workers. This allows the worker to
|
|
18
|
+
* communicate with the IMP network and the main thread. The worker IMP must be created before this.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
closure WebWorkerNub(imp, options, local wonub) {
|
|
23
|
+
global(App,js)
|
|
24
|
+
if App.workerNub
|
|
25
|
+
return (App.workerNub) // singleton
|
|
26
|
+
|
|
27
|
+
options = merge({
|
|
28
|
+
name: "WebWorkerNub"
|
|
29
|
+
type: "web-worker-nub"
|
|
30
|
+
}, options)
|
|
31
|
+
wonub = new(object, this)
|
|
32
|
+
wonub.instanceID = imp.us.instanceID || UUID()
|
|
33
|
+
wonub.dispatcher = require("naanlib:frameworks/running/taskexec.nlg").TaskDispatcher(false, false, "WebWorkerNub")
|
|
34
|
+
|
|
35
|
+
// impReceive
|
|
36
|
+
//
|
|
37
|
+
// Receive a remote request and reply to it.
|
|
38
|
+
//
|
|
39
|
+
wonub.impReceive = closure impReceive(message, sourceID) {
|
|
40
|
+
if message.id == "targetin"
|
|
41
|
+
wonub.dispatcher(message.data, function(reply) {
|
|
42
|
+
wonub.sender(sourceID, {
|
|
43
|
+
id: "targetout",
|
|
44
|
+
data: reply
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// impUnknown
|
|
50
|
+
//
|
|
51
|
+
// Received an unknown destination notice from the other side.
|
|
52
|
+
//
|
|
53
|
+
wonub.impUnknown = function impUnknown(unknownID, sourceID, gateway) {
|
|
54
|
+
if !gateway
|
|
55
|
+
debuglog("WebWorkerNub.impUnknownID:", unknownID, "sourceID:", sourceID)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// mainContext
|
|
59
|
+
//
|
|
60
|
+
// Convenience method to get the main thread and its remote context.
|
|
61
|
+
//
|
|
62
|
+
wonub.mainContext = function mainContext(local error, mtx, ctx) {
|
|
63
|
+
if !(mtx = wonub.mtx) {
|
|
64
|
+
`(error, mtx) = require("../running/remote_req.nlg").MainThread()
|
|
65
|
+
if error
|
|
66
|
+
return (list(error))
|
|
67
|
+
wonub.mtx = mtx
|
|
68
|
+
}
|
|
69
|
+
`(error, ctx) = mtx.context()
|
|
70
|
+
if error
|
|
71
|
+
list(error)
|
|
72
|
+
else
|
|
73
|
+
list(false, ctx, mtx)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// message event
|
|
77
|
+
//
|
|
78
|
+
// Incoming data.
|
|
79
|
+
//
|
|
80
|
+
js.w.addEventListener("message", function message(e, local msg) {
|
|
81
|
+
msg = new(e.data)
|
|
82
|
+
if msg.scope == "naan-imp-web"
|
|
83
|
+
wonub.impconn.dispatch(msg.data)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// register our connects *after* the receivers are configured above
|
|
87
|
+
|
|
88
|
+
wonub.sender = imp.register(wonub, {
|
|
89
|
+
name: options.name
|
|
90
|
+
type: options.type
|
|
91
|
+
meta: options.meta || undefined
|
|
92
|
+
instanceID: wonub.instanceID
|
|
93
|
+
services: [ "naan-web-worker" ]
|
|
94
|
+
})
|
|
95
|
+
wonub.impconn = imp.requester(function(data) {
|
|
96
|
+
js.w.postMessage({ // send to main
|
|
97
|
+
scope: "naan-imp-web",
|
|
98
|
+
data: data
|
|
99
|
+
})
|
|
100
|
+
list(false, { sent: true })
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
// finis
|
|
104
|
+
|
|
105
|
+
App.workerNub = wonub
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/*
|
|
110
|
+
* nubweInit
|
|
111
|
+
*
|
|
112
|
+
* Initialize the component.
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
function nubweInit(local manifest) {
|
|
117
|
+
manifest = `(WebWorkerNub, nubweInit)
|
|
118
|
+
|
|
119
|
+
Naan.module.build(module.id, "nubweb", function(modobj, compobj) {
|
|
120
|
+
require("./service.nlg")
|
|
121
|
+
compobj.manifest = manifest
|
|
122
|
+
modobj.exports.WebWorkerNub = WebWorkerNub
|
|
123
|
+
})
|
|
124
|
+
} ();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* service.nlg
|
|
3
|
+
* Naanlib/frameworks/service
|
|
4
|
+
*
|
|
5
|
+
* Root component for services functionality.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2026 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* svcInit
|
|
16
|
+
*
|
|
17
|
+
* Initialize the service module.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
function svcInit(local manifest) {
|
|
22
|
+
manifest = `(svcInit)
|
|
23
|
+
|
|
24
|
+
Naan.module.build(module.id, "service", function(modobj, compobj) {
|
|
25
|
+
require("../common/common.nlg").LiveImport()
|
|
26
|
+
compobj.manifest = manifest
|
|
27
|
+
})
|
|
28
|
+
} ();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2020-
|
|
9
|
+
* Copyright (c) 2020-2026 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -31,6 +31,7 @@ closure FileManager(fs, options, local files, watch, opqueue, willgit, hadgit) {
|
|
|
31
31
|
watch = commonWatching.Watchable()
|
|
32
32
|
files.watch = watch.watch // watch for file changes
|
|
33
33
|
files.unWatch = watch.unwatch // stop watching for file changes
|
|
34
|
+
hadgit = { }
|
|
34
35
|
|
|
35
36
|
// compareNodes
|
|
36
37
|
//
|
|
@@ -460,7 +461,7 @@ closure FileManager(fs, options, local files, watch, opqueue, willgit, hadgit) {
|
|
|
460
461
|
unknownFiles = []
|
|
461
462
|
unknownFileStatus = {}
|
|
462
463
|
delgit = hadgit
|
|
463
|
-
hadgit = {}
|
|
464
|
+
hadgit = { }
|
|
464
465
|
willgit = false
|
|
465
466
|
for item in statlist {
|
|
466
467
|
hadgit[item.path] = 1
|