@naanlang/naan 1.6.0 → 1.7.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.
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/bin/index.js +2 -2
- package/dist/env_web.js +3 -32
- package/dist/naan.min.js +10 -10
- package/frameworks/browser/sworker.js +23 -23
- package/frameworks/browser/terminals.nlg +161 -212
- package/frameworks/browser/worker.nlg +78 -30
- package/frameworks/browser/workers.nlg +1 -1
- package/frameworks/browser/ws_client.nlg +23 -87
- package/frameworks/client/apiclient.nlg +91 -58
- package/frameworks/client/client.nlg +22 -2
- package/frameworks/client/psm_client.nlg +10 -14
- package/frameworks/client/relaycon.nlg +1 -1
- package/frameworks/common/common.nlg +13 -9
- package/frameworks/node/apiserver.nlg +1 -2
- package/frameworks/node/node.nlg +1 -0
- package/frameworks/node/pty.nlg +21 -21
- package/frameworks/node/shell.nlg +26 -3
- package/frameworks/node/worker.nlg +166 -84
- package/frameworks/node/ws_client.nlg +25 -84
- package/frameworks/project/build.nlg +83 -32
- package/frameworks/project/projects.nlg +2 -2
- package/frameworks/running/debugcom.nlg +20 -3
- package/frameworks/running/debugnub.nlg +16 -7
- package/frameworks/running/executors.nlg +36 -26
- package/frameworks/running/instances.nlg +34 -22
- package/frameworks/running/remote_req.nlg +6 -9
- package/frameworks/running/remote_res.nlg +2 -2
- package/frameworks/running/sourcecode.nlg +3 -2
- package/frameworks/running/taskexec.nlg +14 -57
- package/frameworks/service/imp.nlg +37 -5
- package/frameworks/service/nubnode.nlg +39 -8
- package/frameworks/service/nubweb.nlg +28 -10
- package/frameworks/storage/file_manager.nlg +3 -2
- package/lib/browser/env_web.js +10 -39
- package/lib/browser/env_webworker.js +1 -30
- package/lib/core/naanlib.js +10 -10
- package/lib/env_node.js +5 -22
- package/lib/env_nodeworker.js +8 -43
- 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/test/test_01_core.nlg +2 -2
- package/test/test_02_context.nlg +8 -8
- package/test/test_03_jsinterop.nlg +3 -3
- package/test/test_07_lingo.nlg +1 -1
|
@@ -24,22 +24,19 @@
|
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
closure RemoteRequester(destID, options, local track)
|
|
28
28
|
{
|
|
29
29
|
global(App)
|
|
30
|
-
options = merge({
|
|
31
|
-
name: "Remote Eval"
|
|
32
|
-
type: "RemoteRequester"
|
|
33
|
-
}, options)
|
|
34
30
|
|
|
35
31
|
// remoteReq
|
|
36
32
|
//
|
|
37
33
|
// Executes on our worker thread to return an execution instance that can be used to create a
|
|
38
34
|
// proxy for remote evaluation.
|
|
39
35
|
//
|
|
40
|
-
closure remoteReq(track, name,
|
|
36
|
+
closure remoteReq(track, name, local target) {
|
|
41
37
|
target = ExecutorBase(false, "proxy", options.name)
|
|
42
|
-
target.instanceID =
|
|
38
|
+
target.instanceID = App.imp.getUUID("RemoteRequester(${options.name}) instanceID")
|
|
39
|
+
|
|
43
40
|
|
|
44
41
|
target.sender = App.imp.register(target, {
|
|
45
42
|
name: options.name
|
|
@@ -94,8 +91,8 @@ function RemoteRequester(destID, options, local track)
|
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
options = merge({
|
|
97
|
-
name: "
|
|
98
|
-
|
|
94
|
+
name: "Remote Eval"
|
|
95
|
+
type: "Remote Requester"
|
|
99
96
|
}, options)
|
|
100
97
|
track = ExecutorTracker()
|
|
101
98
|
track.register(options.type, remoteReq)
|
|
@@ -32,8 +32,8 @@ closure RemoteResponder(destID, options, local remo, name)
|
|
|
32
32
|
type: "Remote Responder"
|
|
33
33
|
}, options)
|
|
34
34
|
remo = ExecutorBase(App.nide.track, "remote-responder", name)
|
|
35
|
-
remo.dispatcher = TaskDispatcher()
|
|
36
|
-
remo.instanceID = destID ||
|
|
35
|
+
remo.dispatcher = TaskDispatcher(false, false, "RemoteResponder")
|
|
36
|
+
remo.instanceID = destID || App.imp.getUUID("RemoteResponder(${options.name}) instanceID")
|
|
37
37
|
remo.sender = App.imp.register(remo, {
|
|
38
38
|
name: options.name
|
|
39
39
|
type: options.type
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
closure CodeManager(options, local coman, cache)
|
|
26
26
|
{
|
|
27
27
|
coman = modlist().CLI.exports.Utils(options)
|
|
28
|
-
coman.independent = new(nonce) // caches are ephemeral
|
|
29
28
|
|
|
30
29
|
// composite
|
|
31
30
|
//
|
|
@@ -70,6 +69,8 @@ closure CodeManager(options, local coman, cache)
|
|
|
70
69
|
else
|
|
71
70
|
modname = "<".concat(sym.namespace.tostring, ">") // create independent module
|
|
72
71
|
compname = "<".concat(sym, ">") // create independent component
|
|
72
|
+
if !coman.independent
|
|
73
|
+
coman.independent = new(nonce) // ephemeral cache
|
|
73
74
|
coman.independent[modname.concat(":-:", compname)] = CodeComposite(coman, sym, modname, compname)
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -114,7 +115,7 @@ closure CodeManager(options, local coman, cache)
|
|
|
114
115
|
coman.cacheAdd = function cacheAdd(cocode, manifest, local item, mandefs) {
|
|
115
116
|
for item in manifest
|
|
116
117
|
push(item.proc, mandefs)
|
|
117
|
-
|
|
118
|
+
cache = new(nonce)
|
|
118
119
|
cache.modname = cocode.modname
|
|
119
120
|
cache.compname = cocode.compname
|
|
120
121
|
cache.mandefs = mandefs
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
/*
|
|
14
14
|
* TaskDispatcher
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* a peer to ExecutorContext in executors.nlg.
|
|
16
|
+
* Create a dispatcher for remote evaluation. The return value is a closure that processes incoming
|
|
17
|
+
* messages. All arguments optional. This code is a peer to ExecutorContext in executors.nlg.
|
|
19
18
|
*
|
|
20
19
|
*/
|
|
21
20
|
|
|
22
|
-
closure TaskDispatcher(replier, coder, local contexts, gohome, util) {
|
|
21
|
+
closure TaskDispatcher(replier, coder, name, local contexts, gohome, util) {
|
|
23
22
|
global()
|
|
24
23
|
contexts = { }
|
|
25
24
|
gohome = makeActivator()
|
|
26
25
|
util = modlist().Util.exports
|
|
27
|
-
|
|
26
|
+
name = name || ""
|
|
27
|
+
|
|
28
28
|
// ContextCoder
|
|
29
29
|
//
|
|
30
30
|
// A context-specific coder allowing remote-initiated communication.
|
|
@@ -49,7 +49,7 @@ closure TaskDispatcher(replier, coder, local contexts, gohome, util) {
|
|
|
49
49
|
contextID: contextID
|
|
50
50
|
}, contexts[contextID].coder)
|
|
51
51
|
if error {
|
|
52
|
-
ErrorDebuglog("
|
|
52
|
+
ErrorDebuglog("Remoter(${name}).ContextCoder failed:", error)
|
|
53
53
|
exec = false
|
|
54
54
|
return (list(error))
|
|
55
55
|
}
|
|
@@ -74,7 +74,7 @@ closure TaskDispatcher(replier, coder, local contexts, gohome, util) {
|
|
|
74
74
|
xmsg: "error"
|
|
75
75
|
xid: data.xid
|
|
76
76
|
_guid: data._guid || undefined
|
|
77
|
-
error: "unknown operation"
|
|
77
|
+
error: "Remoter(${name}): unknown operation"
|
|
78
78
|
}
|
|
79
79
|
try {
|
|
80
80
|
restorens = makeActivator()
|
|
@@ -108,9 +108,9 @@ closure TaskDispatcher(replier, coder, local contexts, gohome, util) {
|
|
|
108
108
|
//
|
|
109
109
|
context = contexts[data.contextID]
|
|
110
110
|
if !context
|
|
111
|
-
reply.error = "unknown context"
|
|
111
|
+
reply.error = "Remoter(${name}): unknown context"
|
|
112
112
|
else if !context.namespace
|
|
113
|
-
reply.error = "namespace missing"
|
|
113
|
+
reply.error = "Remoter(${name}): namespace missing"
|
|
114
114
|
else {
|
|
115
115
|
context.activator()
|
|
116
116
|
reply.xmsg = "evaluated"
|
|
@@ -152,9 +152,9 @@ closure TaskDispatcher(replier, coder, local contexts, gohome, util) {
|
|
|
152
152
|
//
|
|
153
153
|
context = contexts[data.contextID]
|
|
154
154
|
if !context
|
|
155
|
-
reply.error = "unknown context"
|
|
155
|
+
reply.error = "Remoter(${name}): unknown context"
|
|
156
156
|
else if !context.namespace
|
|
157
|
-
reply.error = "namespace missing"
|
|
157
|
+
reply.error = "Remoter(${name}): namespace missing"
|
|
158
158
|
else {
|
|
159
159
|
context.activator()
|
|
160
160
|
reply.xmsg = "executed"
|
|
@@ -183,7 +183,7 @@ closure TaskDispatcher(replier, coder, local contexts, gohome, util) {
|
|
|
183
183
|
result = exception.toarray.map(function(x){tostring(x)}).join(" - ")
|
|
184
184
|
else
|
|
185
185
|
result = tostring(exception)
|
|
186
|
-
reply.error = "exception: "
|
|
186
|
+
reply.error = "Remoter(${name}) exception: ${result}"
|
|
187
187
|
}
|
|
188
188
|
} finally {
|
|
189
189
|
restorens()
|
|
@@ -193,46 +193,6 @@ closure TaskDispatcher(replier, coder, local contexts, gohome, util) {
|
|
|
193
193
|
};
|
|
194
194
|
|
|
195
195
|
|
|
196
|
-
/*
|
|
197
|
-
* TaskExecutor
|
|
198
|
-
*
|
|
199
|
-
* Install an executor for remote evaluation in worker threads. This uses the OnMessage protocol
|
|
200
|
-
* available in the env_xxx.js Naan controllers. The return value is false if OnMessage is not there
|
|
201
|
-
* or true on success.
|
|
202
|
-
*
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
|
-
closure TaskExecutor() {
|
|
206
|
-
|
|
207
|
-
// taskInstall
|
|
208
|
-
// Install the TaskDispatcher, and reload on state load.
|
|
209
|
-
//
|
|
210
|
-
function taskInstall() {
|
|
211
|
-
if !js.t.OnMessage
|
|
212
|
-
return (false) // false if not a worker
|
|
213
|
-
js.t.OnMessage(TaskDispatcher(js.t.ReplyMessage))
|
|
214
|
-
}()
|
|
215
|
-
LoadNotify(taskInstall)
|
|
216
|
-
|
|
217
|
-
// finis
|
|
218
|
-
|
|
219
|
-
true
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
/*
|
|
224
|
-
* TaskOnMessageHook
|
|
225
|
-
*
|
|
226
|
-
* OK, this is a kludge, but you call this function to specify a handler proc when a message
|
|
227
|
-
* comes in that we don't understand.
|
|
228
|
-
*
|
|
229
|
-
*/
|
|
230
|
-
|
|
231
|
-
function TaskOnMessageHook(hook) {
|
|
232
|
-
onMessageHook = hook
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
|
|
236
196
|
/*
|
|
237
197
|
* taxInit
|
|
238
198
|
*
|
|
@@ -241,14 +201,11 @@ function TaskOnMessageHook(hook) {
|
|
|
241
201
|
*/
|
|
242
202
|
|
|
243
203
|
function taxInit(local manifest) {
|
|
244
|
-
|
|
245
|
-
manifest = `(TaskDispatcher, TaskExecutor, TaskOnMessageHook, taxInit)
|
|
204
|
+
manifest = `(TaskDispatcher, TaskOnMessageHook, taxInit)
|
|
246
205
|
|
|
247
206
|
Naan.module.build(module.id, "taskexec", function(modobj, compobj) {
|
|
248
|
-
require("./running.nlg")
|
|
207
|
+
require("./running.nlg")
|
|
249
208
|
compobj.manifest = manifest
|
|
250
209
|
modobj.exports.TaskDispatcher = TaskDispatcher
|
|
251
|
-
modobj.exports.TaskExecutor = TaskExecutor
|
|
252
|
-
modobj.exports.TaskOnMessageHook = TaskOnMessageHook
|
|
253
210
|
})
|
|
254
211
|
} ();
|
|
@@ -35,8 +35,11 @@ closure Imp(us, local imp) {
|
|
|
35
35
|
name: "imp-generic"
|
|
36
36
|
type: "imp-type"
|
|
37
37
|
}, us)
|
|
38
|
+
imp.verbose = false
|
|
38
39
|
if !us.instanceID
|
|
39
|
-
us.instanceID =
|
|
40
|
+
us.instanceID = getUUID("Imp(${imp.us.name}) instanceID")
|
|
41
|
+
else if imp.verbose >= 1
|
|
42
|
+
debuglog("useUUID ${us.instanceID} for: Imp(${imp.us.name}) instanceID")
|
|
40
43
|
imp.direct = { } // direct-connected destinations
|
|
41
44
|
imp.pipes = { } // piped connections to destinations
|
|
42
45
|
imp.gateways = { } // routing gateways for next hop
|
|
@@ -395,17 +398,21 @@ closure Imp(us, local imp) {
|
|
|
395
398
|
function open() {
|
|
396
399
|
dest.handshake.reset()
|
|
397
400
|
dest.state = `connected
|
|
398
|
-
future(function() {
|
|
399
|
-
wait()
|
|
401
|
+
future(function(local error, newdid) {
|
|
402
|
+
`(error, newdid) = wait()
|
|
403
|
+
if error
|
|
404
|
+
return // didn't succeed (yet)
|
|
400
405
|
info.destID = destID
|
|
401
406
|
info.defaultID = dest.defaultID || undefined
|
|
402
407
|
info.name = dest.name
|
|
403
408
|
info.type = dest.type
|
|
404
409
|
info.meta = dest.meta
|
|
410
|
+
dest.conn.dispatchEvent("active", info)
|
|
405
411
|
imp.dispatchEvent("active", info)
|
|
406
412
|
}, 0)
|
|
407
413
|
if initiator
|
|
408
414
|
send_hello(destID) // start the handshake
|
|
415
|
+
dest.conn.dispatchEvent("opening", info)
|
|
409
416
|
imp.dispatchEvent("opening", info)
|
|
410
417
|
}
|
|
411
418
|
|
|
@@ -415,6 +422,7 @@ closure Imp(us, local imp) {
|
|
|
415
422
|
dest.state = `closed
|
|
416
423
|
if !initiator
|
|
417
424
|
dest.destID = undefined // ### reset for non-persistent clients
|
|
425
|
+
dest.conn.dispatchEvent("closed", info)
|
|
418
426
|
imp.dispatchEvent("closed", info)
|
|
419
427
|
}
|
|
420
428
|
|
|
@@ -423,6 +431,7 @@ closure Imp(us, local imp) {
|
|
|
423
431
|
if dest.state != `closed
|
|
424
432
|
close()
|
|
425
433
|
imp.pipes[destID] = undefined
|
|
434
|
+
dest.conn.dispatchEvent("destroyed", info)
|
|
426
435
|
imp.dispatchEvent("destroyed", info)
|
|
427
436
|
}
|
|
428
437
|
|
|
@@ -449,7 +458,7 @@ closure Imp(us, local imp) {
|
|
|
449
458
|
dest.info.services = [ service ]
|
|
450
459
|
destID = info.destID
|
|
451
460
|
if !destID {
|
|
452
|
-
destID =
|
|
461
|
+
destID = getUUID("imp temporary for requester") // temporary destID to be updated
|
|
453
462
|
dest.idsymbol = quote(destID)
|
|
454
463
|
}
|
|
455
464
|
imp.pipes[destID] = dest
|
|
@@ -459,6 +468,18 @@ closure Imp(us, local imp) {
|
|
|
459
468
|
dest.conn
|
|
460
469
|
}
|
|
461
470
|
|
|
471
|
+
// getUUID
|
|
472
|
+
//
|
|
473
|
+
// Get a UUID for the specified purpose, which is just a comment. This makes it easy to log
|
|
474
|
+
// UUID assignments for debugging.
|
|
475
|
+
//
|
|
476
|
+
imp.getUUID = function getUUID(purpose, local uuid) {
|
|
477
|
+
uuid = UUID()
|
|
478
|
+
if imp.verbose >= 1
|
|
479
|
+
debuglog("getUUID ${uuid} for: ${purpose}")
|
|
480
|
+
uuid
|
|
481
|
+
}
|
|
482
|
+
|
|
462
483
|
// requester
|
|
463
484
|
//
|
|
464
485
|
// Start a requester connection and initiate the handshake. The IMP will use the specified
|
|
@@ -522,7 +543,7 @@ closure Imp(us, local imp) {
|
|
|
522
543
|
debuglog("Imp.register: info.meta must be a dictionary if specified")
|
|
523
544
|
instanceID = info.instanceID
|
|
524
545
|
if !string(instanceID) || imp.direct[instanceID] {
|
|
525
|
-
instanceID =
|
|
546
|
+
instanceID = getUUID("imp.register(${info.name}) auto-assignment")
|
|
526
547
|
debuglog("Imp.register: instanceID ${info.instanceID} invalid or in use - replaced with ${instanceID}")
|
|
527
548
|
}
|
|
528
549
|
imp.direct[info.instanceID] = {
|
|
@@ -651,12 +672,23 @@ closure ImpConn(dispatcher, sender, wait, open, close, destroy,
|
|
|
651
672
|
global()
|
|
652
673
|
impco = new(object, this)
|
|
653
674
|
|
|
675
|
+
// reopen
|
|
676
|
+
//
|
|
677
|
+
// Reopen the connection with a delay to let events process.
|
|
678
|
+
//
|
|
679
|
+
impco.reopen = closure reopen() {
|
|
680
|
+
close()
|
|
681
|
+
sleep(10)
|
|
682
|
+
open()
|
|
683
|
+
}
|
|
684
|
+
|
|
654
685
|
impco.dispatch = dispatcher.proc
|
|
655
686
|
impco.send = sender.proc
|
|
656
687
|
impco.wait = wait.proc
|
|
657
688
|
impco.open = open.proc
|
|
658
689
|
impco.close = close.proc
|
|
659
690
|
impco.destroy = destroy.proc
|
|
691
|
+
Events(impco)
|
|
660
692
|
|
|
661
693
|
// finis
|
|
662
694
|
|
|
@@ -29,14 +29,14 @@ closure NodeWorkerNub(imp, options, local nownub) {
|
|
|
29
29
|
type: "node-worker-nub"
|
|
30
30
|
}, options)
|
|
31
31
|
nownub = new(object, this)
|
|
32
|
-
nownub.instanceID = imp.us.instanceID ||
|
|
33
|
-
nownub.dispatcher = require("naanlib:frameworks/running/taskexec.nlg").TaskDispatcher()
|
|
32
|
+
nownub.instanceID = imp.us.instanceID || imp.getUUID("NodeWorkerNub(${options.name}) instanceID")
|
|
33
|
+
nownub.dispatcher = require("naanlib:frameworks/running/taskexec.nlg").TaskDispatcher(false, false, "NodeWorkerNub")
|
|
34
34
|
|
|
35
35
|
// impReceive
|
|
36
36
|
//
|
|
37
37
|
// Receive a remote request and reply to it.
|
|
38
38
|
//
|
|
39
|
-
nownub.impReceive =
|
|
39
|
+
nownub.impReceive = closure impReceive(message, sourceID) {
|
|
40
40
|
if message.id == "targetin"
|
|
41
41
|
nownub.dispatcher(message.data, function(reply) {
|
|
42
42
|
nownub.sender(sourceID, {
|
|
@@ -45,7 +45,7 @@ closure NodeWorkerNub(imp, options, local nownub) {
|
|
|
45
45
|
})
|
|
46
46
|
})
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
// impUnknown
|
|
50
50
|
//
|
|
51
51
|
// Received an unknown destination notice from the other side.
|
|
@@ -55,12 +55,43 @@ closure NodeWorkerNub(imp, options, local nownub) {
|
|
|
55
55
|
debuglog("NodeWorkerNub.impUnknownID:", unknownID, "sourceID:", sourceID)
|
|
56
56
|
}
|
|
57
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
|
+
|
|
58
89
|
// message event
|
|
59
90
|
//
|
|
60
|
-
// Incoming data.
|
|
91
|
+
// Incoming data to the worker.
|
|
61
92
|
//
|
|
62
93
|
js.t.msgPort.on("message", function(msg) {
|
|
63
|
-
if msg.id == "naan-imp-
|
|
94
|
+
if msg.id == "naan-imp-in"
|
|
64
95
|
nownub.impconn.dispatch(new(msg.data))
|
|
65
96
|
})
|
|
66
97
|
|
|
@@ -75,14 +106,14 @@ closure NodeWorkerNub(imp, options, local nownub) {
|
|
|
75
106
|
})
|
|
76
107
|
nownub.impconn = imp.requester(function(data) {
|
|
77
108
|
js.t.msgPort.postMessage({ // send to main
|
|
78
|
-
id: "naan-imp-
|
|
109
|
+
id: "naan-imp-out"
|
|
79
110
|
data: data
|
|
80
111
|
})
|
|
81
112
|
list(false, { sent: true })
|
|
82
113
|
})
|
|
83
114
|
|
|
84
115
|
// finis
|
|
85
|
-
|
|
116
|
+
|
|
86
117
|
App.workerNub = nownub
|
|
87
118
|
};
|
|
88
119
|
|
|
@@ -29,14 +29,14 @@ closure WebWorkerNub(imp, options, local wonub) {
|
|
|
29
29
|
type: "web-worker-nub"
|
|
30
30
|
}, options)
|
|
31
31
|
wonub = new(object, this)
|
|
32
|
-
wonub.instanceID = imp.us.instanceID ||
|
|
33
|
-
wonub.dispatcher = require("naanlib:frameworks/running/taskexec.nlg").TaskDispatcher()
|
|
32
|
+
wonub.instanceID = imp.us.instanceID || imp.getUUID("WebWorkerNub(${options.name}) instanceID")
|
|
33
|
+
wonub.dispatcher = require("naanlib:frameworks/running/taskexec.nlg").TaskDispatcher(false, false, "WebWorkerNub")
|
|
34
34
|
|
|
35
35
|
// impReceive
|
|
36
36
|
//
|
|
37
37
|
// Receive a remote request and reply to it.
|
|
38
38
|
//
|
|
39
|
-
wonub.impReceive =
|
|
39
|
+
wonub.impReceive = closure impReceive(message, sourceID) {
|
|
40
40
|
if message.id == "targetin"
|
|
41
41
|
wonub.dispatcher(message.data, function(reply) {
|
|
42
42
|
wonub.sender(sourceID, {
|
|
@@ -45,7 +45,7 @@ closure WebWorkerNub(imp, options, local wonub) {
|
|
|
45
45
|
})
|
|
46
46
|
})
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
// impUnknown
|
|
50
50
|
//
|
|
51
51
|
// Received an unknown destination notice from the other side.
|
|
@@ -55,14 +55,32 @@ closure WebWorkerNub(imp, options, local wonub) {
|
|
|
55
55
|
debuglog("WebWorkerNub.impUnknownID:", unknownID, "sourceID:", sourceID)
|
|
56
56
|
}
|
|
57
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
|
+
|
|
58
76
|
// message event
|
|
59
77
|
//
|
|
60
|
-
// Incoming data.
|
|
78
|
+
// Incoming data to the worker.
|
|
61
79
|
//
|
|
62
80
|
js.w.addEventListener("message", function message(e, local msg) {
|
|
63
|
-
msg =
|
|
64
|
-
if msg.scope == "naan-imp-
|
|
65
|
-
wonub.impconn.dispatch(msg.data)
|
|
81
|
+
msg = e.data
|
|
82
|
+
if msg.scope == "naan-imp-in"
|
|
83
|
+
wonub.impconn.dispatch(new(msg.data))
|
|
66
84
|
})
|
|
67
85
|
|
|
68
86
|
// register our connects *after* the receivers are configured above
|
|
@@ -76,14 +94,14 @@ closure WebWorkerNub(imp, options, local wonub) {
|
|
|
76
94
|
})
|
|
77
95
|
wonub.impconn = imp.requester(function(data) {
|
|
78
96
|
js.w.postMessage({ // send to main
|
|
79
|
-
scope: "naan-imp-
|
|
97
|
+
scope: "naan-imp-out"
|
|
80
98
|
data: data
|
|
81
99
|
})
|
|
82
100
|
list(false, { sent: true })
|
|
83
101
|
})
|
|
84
102
|
|
|
85
103
|
// finis
|
|
86
|
-
|
|
104
|
+
|
|
87
105
|
App.workerNub = wonub
|
|
88
106
|
};
|
|
89
107
|
|
|
@@ -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
|
package/lib/browser/env_web.js
CHANGED
|
@@ -171,7 +171,7 @@ exports.NaanControllerWeb = function() {
|
|
|
171
171
|
if (repdex < 0)
|
|
172
172
|
termlist.push(terminal);
|
|
173
173
|
takePending(); // output all pending terminal messages
|
|
174
|
-
this.ioctl_event("term-attach",
|
|
174
|
+
this.ioctl_event("term-attach", terminal.guid);
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
//
|
|
@@ -186,7 +186,7 @@ exports.NaanControllerWeb = function() {
|
|
|
186
186
|
termlist.splice(repdex, 1);
|
|
187
187
|
if (termlist.length === 0)
|
|
188
188
|
replstate = terminal.StateSave(); // save ultimate repl state
|
|
189
|
-
this.ioctl_event("term-detach",
|
|
189
|
+
this.ioctl_event("term-detach", terminal.guid);
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
//
|
|
@@ -220,24 +220,6 @@ exports.NaanControllerWeb = function() {
|
|
|
220
220
|
}, 1);
|
|
221
221
|
};
|
|
222
222
|
|
|
223
|
-
var replyHook;
|
|
224
|
-
this.OnReplyHook = function OnReplyHook(proc) {
|
|
225
|
-
replyHook = proc;
|
|
226
|
-
return (proc);
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
this.ReplyMessage = function ReplyMessage(data) { // "remote" -> "local"
|
|
230
|
-
if (replyHook)
|
|
231
|
-
setTimeout(function() {
|
|
232
|
-
replyHook(data);
|
|
233
|
-
}, 1);
|
|
234
|
-
termlist.forEach(function(term) {
|
|
235
|
-
if (term.OnMessageOut)
|
|
236
|
-
term.OnMessageOut(data);
|
|
237
|
-
});
|
|
238
|
-
return (data);
|
|
239
|
-
};
|
|
240
|
-
|
|
241
223
|
var nideListener;
|
|
242
224
|
this.OnMessage = function OnMessage(proc) {
|
|
243
225
|
nideListener = proc;
|
|
@@ -425,6 +407,7 @@ exports.NaanControllerWeb = function() {
|
|
|
425
407
|
}
|
|
426
408
|
else if (msg.id == "targetin")
|
|
427
409
|
{
|
|
410
|
+
console.log("env_web targetin");
|
|
428
411
|
if (nideListener)
|
|
429
412
|
nideListener(msg.data); // target received a message
|
|
430
413
|
}
|
|
@@ -446,17 +429,6 @@ exports.NaanControllerWeb = function() {
|
|
|
446
429
|
return (msg);
|
|
447
430
|
};
|
|
448
431
|
|
|
449
|
-
//
|
|
450
|
-
// report messages back to opener
|
|
451
|
-
//
|
|
452
|
-
termSelf.OnMessageOut = function OnMessageOut(data) {
|
|
453
|
-
var msg = { // target is sending debug data
|
|
454
|
-
id: "targetout",
|
|
455
|
-
data: data
|
|
456
|
-
};
|
|
457
|
-
return (termSelf.OnMessage(msg));
|
|
458
|
-
};
|
|
459
|
-
|
|
460
432
|
//
|
|
461
433
|
// report debug messages back to opener
|
|
462
434
|
//
|
|
@@ -652,7 +624,7 @@ exports.NaanControllerWeb = function() {
|
|
|
652
624
|
statedoc.curversion = kStateCurrentVersion;
|
|
653
625
|
statedoc.firstver = kStateFirstVersion;
|
|
654
626
|
statedoc.licensee = "MIT-License";
|
|
655
|
-
statedoc.verstring = "1.
|
|
627
|
+
statedoc.verstring = "1.7.1+1";
|
|
656
628
|
statedoc.date = new Date().toISOString();
|
|
657
629
|
statedoc.prefs = prefs;
|
|
658
630
|
statedoc.naan = naanlib.saveState(false); // true to optimize, which is a bit slower
|
|
@@ -670,7 +642,7 @@ exports.NaanControllerWeb = function() {
|
|
|
670
642
|
|| statedoc.firstver > kStateCurrentVersion
|
|
671
643
|
|| statedoc.curversion < kStateFirstVersion
|
|
672
644
|
|| statedoc.licensee != "MIT-License"
|
|
673
|
-
|| statedoc.verstring != "1.
|
|
645
|
+
|| statedoc.verstring != "1.7.1+1"
|
|
674
646
|
|| !(naanstate = statedoc.naan))
|
|
675
647
|
{
|
|
676
648
|
localStorage.removeItem("NaanState_Hosted");
|
|
@@ -733,7 +705,7 @@ exports.NaanControllerWeb = function() {
|
|
|
733
705
|
op: "VsiteOpen",
|
|
734
706
|
name: vsiteName,
|
|
735
707
|
naancont: contSelf,
|
|
736
|
-
title: vsiteName + " 1.
|
|
708
|
+
title: vsiteName + " 1.7.1+1"
|
|
737
709
|
});
|
|
738
710
|
}
|
|
739
711
|
} catch (e) {
|
|
@@ -747,9 +719,8 @@ exports.NaanControllerWeb = function() {
|
|
|
747
719
|
op: "VsiteClose",
|
|
748
720
|
name: vsiteName,
|
|
749
721
|
naancont: contSelf,
|
|
750
|
-
title: vsiteName + " 1.
|
|
722
|
+
title: vsiteName + " 1.7.1+1"
|
|
751
723
|
});
|
|
752
|
-
termTextOut("\x1b[90m\x1b[3m".concat("\nwindow closed", "\x1b[0m\n"));
|
|
753
724
|
}
|
|
754
725
|
} catch (e) {
|
|
755
726
|
}
|
|
@@ -763,7 +734,7 @@ exports.NaanControllerWeb = function() {
|
|
|
763
734
|
op: "VsiteVisibilityChange",
|
|
764
735
|
name: vsiteName,
|
|
765
736
|
naancont: contSelf,
|
|
766
|
-
title: vsiteName + " 1.
|
|
737
|
+
title: vsiteName + " 1.7.1+1",
|
|
767
738
|
hidden: window.document.visibilityState == "hidden",
|
|
768
739
|
window: window
|
|
769
740
|
});
|
|
@@ -778,8 +749,8 @@ exports.NaanControllerWeb = function() {
|
|
|
778
749
|
naanlib.banner();
|
|
779
750
|
var hostpath = window.location.origin.concat(naanlib.js.r("path").dirname(window.location.pathname));
|
|
780
751
|
naanlib.start({
|
|
781
|
-
cmd: 'App.version = "1.
|
|
782
|
-
+ 'App.cache = "
|
|
752
|
+
cmd: 'App.version = "1.7.1+1";;\r\n'
|
|
753
|
+
+ 'App.cache = "b173565c63a43f623fb769868912eb9d";;\r\n'
|
|
783
754
|
+ 'Naan.module.requireQuery({ naanver: App.cache });;\r\n'
|
|
784
755
|
+ 'Naan.module.webparse("naan_init.nlg", "' + hostpath + '", { naanver: App.cache });;\r\n'
|
|
785
756
|
});
|