@naanlang/naan 1.6.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.
Files changed (50) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +1 -1
  3. package/bin/index.js +2 -2
  4. package/dist/env_web.js +3 -31
  5. package/dist/naan.min.js +10 -10
  6. package/frameworks/browser/sworker.js +23 -23
  7. package/frameworks/browser/terminals.nlg +44 -122
  8. package/frameworks/browser/worker.nlg +64 -24
  9. package/frameworks/browser/workers.nlg +1 -1
  10. package/frameworks/client/apiclient.nlg +73 -43
  11. package/frameworks/client/psm_client.nlg +10 -14
  12. package/frameworks/common/common.nlg +2 -0
  13. package/frameworks/node/apiserver.nlg +0 -1
  14. package/frameworks/node/node.nlg +1 -0
  15. package/frameworks/node/pty.nlg +21 -21
  16. package/frameworks/node/shell.nlg +26 -3
  17. package/frameworks/node/worker.nlg +153 -79
  18. package/frameworks/project/build.nlg +55 -13
  19. package/frameworks/project/projects.nlg +1 -1
  20. package/frameworks/running/debugcom.nlg +20 -3
  21. package/frameworks/running/debugnub.nlg +16 -7
  22. package/frameworks/running/executors.nlg +14 -12
  23. package/frameworks/running/instances.nlg +1 -0
  24. package/frameworks/running/remote_req.nlg +4 -8
  25. package/frameworks/running/remote_res.nlg +1 -1
  26. package/frameworks/running/sourcecode.nlg +3 -2
  27. package/frameworks/running/taskexec.nlg +14 -57
  28. package/frameworks/service/imp.nlg +15 -0
  29. package/frameworks/service/nubnode.nlg +35 -4
  30. package/frameworks/service/nubweb.nlg +22 -4
  31. package/frameworks/storage/file_manager.nlg +3 -2
  32. package/lib/browser/env_web.js +10 -38
  33. package/lib/browser/env_webworker.js +1 -30
  34. package/lib/core/naanlib.js +10 -10
  35. package/lib/env_node.js +5 -22
  36. package/lib/env_nodeworker.js +8 -43
  37. package/lib/node_server_init.nlg +149 -0
  38. package/lib/node_worker.js +36 -0
  39. package/lib/node_worker_init.nlg +43 -0
  40. package/package.json +1 -1
  41. package/plugins/openSearch/openSearch.nlg +3 -2
  42. package/plugins/openSearch/os_dynamo.nlg +3 -2
  43. package/plugins/serviceAws/aws_cloudwatchlogs.nlg +44 -2
  44. package/plugins/serviceAws/aws_dynamo.nlg +144 -63
  45. package/plugins/serviceAws/aws_utils.nlg +6 -11
  46. package/plugins/serviceAws/serviceAws.nlg +3 -2
  47. package/test/test_01_core.nlg +2 -2
  48. package/test/test_02_context.nlg +8 -8
  49. package/test/test_03_jsinterop.nlg +3 -3
  50. package/test/test_07_lingo.nlg +1 -1
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * column positioning: // // !
7
7
  *
8
- * Copyright (c) 2020-2024 by Richard C. Zulch
8
+ * Copyright (c) 2020-2026 by Richard C. Zulch
9
9
  *
10
10
  */
11
11
 
@@ -65,7 +65,7 @@ closure ExecutorBase(track, type, name, local exec) {
65
65
  exec.reverseDispatch = require("./taskexec.nlg").TaskDispatcher(function(data) {
66
66
  data.reverse = true
67
67
  exec.PostMessage(data)
68
- }, exec.contexts[data.contextID].coder)
68
+ }, exec.contexts[data.contextID].coder, "execReceived")
69
69
  data.reverse = false
70
70
  exec.reverseDispatch(data)
71
71
  return
@@ -73,7 +73,7 @@ closure ExecutorBase(track, type, name, local exec) {
73
73
  pending = exec.pending[data.xid]
74
74
  if !pending { // not waiting on message
75
75
  if data.xmsg == "xready"
76
- exec.pending.ready = true
76
+ exec.inst_ready = true
77
77
  if data.xmsg == "xattention"
78
78
  { }
79
79
  return
@@ -99,7 +99,7 @@ closure ExecutorBase(track, type, name, local exec) {
99
99
  // Communication has failed.
100
100
  //
101
101
  exec.execFailed = closure execFailed(error, local xid, pending) {
102
- exec.pending.error = error
102
+ exec.inst_error = error
103
103
  for `(xid, pending) in exec.pending
104
104
  pending.signal(list(error))
105
105
  }
@@ -112,7 +112,7 @@ closure ExecutorBase(track, type, name, local exec) {
112
112
  exec.execClosed = closure execClosed(error, local xid, pending) {
113
113
  for `(xid, pending) in exec.pending {
114
114
  pending.signal(list(error))
115
- pending[xid] = undefined
115
+ exec.pending[xid] = undefined
116
116
  }
117
117
  }
118
118
 
@@ -127,7 +127,7 @@ closure ExecutorBase(track, type, name, local exec) {
127
127
  retries = 0
128
128
  ms = milliseconds()
129
129
  delta = 1
130
- while !exec.pending.ready {
130
+ while !exec.inst_ready {
131
131
  `(error) = exec.PostMessage({
132
132
  xmsg: "xstart"
133
133
  })
@@ -135,8 +135,8 @@ closure ExecutorBase(track, type, name, local exec) {
135
135
  return (Error("exec.context failed", error))
136
136
  if ++retries > 100
137
137
  return (list(Error("timeout creating remote context", type, name)))
138
- if exec.pending.error
139
- return (list(Error("cannot create remote context", exec.pending.error)))
138
+ if exec.inst_error
139
+ return (list(Error("cannot create remote context", exec.inst_error)))
140
140
  sleep(delta)
141
141
  if delta < 100
142
142
  delta *= 2 }
@@ -566,13 +566,13 @@ closure ExecutorParallel(track, options, local maxcount, parallel, state, exqueu
566
566
  return (false) // already destroyed
567
567
  crValue = cancelResult
568
568
  maxcount = 0
569
- state.available = false
570
- parallel.contexts = false
571
569
  while state.workers.length > 0 {
572
570
  worker = state.workers.pop()
573
571
  parallel.contexts[worker] = false
574
572
  worker.destroy()
575
573
  }
574
+ state.available = false
575
+ parallel.contexts = false
576
576
  while exqueue.length > 0 {
577
577
  next = exqueue.pop()
578
578
  next.pending.signal(crValue)
@@ -604,8 +604,10 @@ closure ExecutorTracker(local xtrak) {
604
604
  // Notify the watchers by calling a named procedure
605
605
 
606
606
  closure notify(changes, local watch) {
607
- for watch in xtrak.watchers
608
- call(watch, changes)
607
+ future(function(){
608
+ for watch in xtrak.watchers
609
+ call(watch, changes)
610
+ }, 10)
609
611
  }
610
612
 
611
613
  // add
@@ -321,6 +321,7 @@ closure InTop(track, options, local intop, nlregex, str, error) {
321
321
  intop.execClosed(Error("instance closed"))
322
322
  track.delete(intop)
323
323
  termDetach()
324
+ sleep(10)
324
325
  App.imp.unregister(intop.instanceID)
325
326
  intop.instanceID = false
326
327
  }
@@ -24,20 +24,16 @@
24
24
  *
25
25
  */
26
26
 
27
- function RemoteRequester(destID, options, local track)
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, options, local target) {
36
+ closure remoteReq(track, name, local target) {
41
37
  target = ExecutorBase(false, "proxy", options.name)
42
38
  target.instanceID = UUID()
43
39
 
@@ -94,8 +90,8 @@ function RemoteRequester(destID, options, local track)
94
90
  }
95
91
 
96
92
  options = merge({
97
- name: "RemoteRequester"
98
- proxy: "proxy"
93
+ name: "Remote Eval"
94
+ type: "Remote Requester"
99
95
  }, options)
100
96
  track = ExecutorTracker()
101
97
  track.register(options.type, remoteReq)
@@ -32,7 +32,7 @@ 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()
35
+ remo.dispatcher = TaskDispatcher(false, false, "RemoteResponder")
36
36
  remo.instanceID = destID || UUID()
37
37
  remo.sender = App.imp.register(remo, {
38
38
  name: options.name
@@ -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
- cacne = new(nonce)
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
- * Create a dispatcher for remote evaluation. The replier argument is a function that accepts
17
- * outgoing messages. The return value is a closure that processes incomming messages. This code is
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("TaskDispatcher.ContextCoder failed:", error)
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: ".concat(result)
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").LiveImport()
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
  } ();
@@ -402,10 +402,12 @@ closure Imp(us, local imp) {
402
402
  info.name = dest.name
403
403
  info.type = dest.type
404
404
  info.meta = dest.meta
405
+ dest.conn.dispatchEvent("active", info)
405
406
  imp.dispatchEvent("active", info)
406
407
  }, 0)
407
408
  if initiator
408
409
  send_hello(destID) // start the handshake
410
+ dest.conn.dispatchEvent("opening", info)
409
411
  imp.dispatchEvent("opening", info)
410
412
  }
411
413
 
@@ -415,6 +417,7 @@ closure Imp(us, local imp) {
415
417
  dest.state = `closed
416
418
  if !initiator
417
419
  dest.destID = undefined // ### reset for non-persistent clients
420
+ dest.conn.dispatchEvent("closed", info)
418
421
  imp.dispatchEvent("closed", info)
419
422
  }
420
423
 
@@ -423,6 +426,7 @@ closure Imp(us, local imp) {
423
426
  if dest.state != `closed
424
427
  close()
425
428
  imp.pipes[destID] = undefined
429
+ dest.conn.dispatchEvent("destroyed", info)
426
430
  imp.dispatchEvent("destroyed", info)
427
431
  }
428
432
 
@@ -651,12 +655,23 @@ closure ImpConn(dispatcher, sender, wait, open, close, destroy,
651
655
  global()
652
656
  impco = new(object, this)
653
657
 
658
+ // reopen
659
+ //
660
+ // Reopen the connection with a delay to let events process.
661
+ //
662
+ impco.reopen = closure reopen() {
663
+ close()
664
+ sleep(10)
665
+ open()
666
+ }
667
+
654
668
  impco.dispatch = dispatcher.proc
655
669
  impco.send = sender.proc
656
670
  impco.wait = wait.proc
657
671
  impco.open = open.proc
658
672
  impco.close = close.proc
659
673
  impco.destroy = destroy.proc
674
+ Events(impco)
660
675
 
661
676
  // finis
662
677
 
@@ -30,13 +30,13 @@ closure NodeWorkerNub(imp, options, local nownub) {
30
30
  }, options)
31
31
  nownub = new(object, this)
32
32
  nownub.instanceID = imp.us.instanceID || UUID()
33
- nownub.dispatcher = require("naanlib:frameworks/running/taskexec.nlg").TaskDispatcher()
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 = function impReceive(message, sourceID) {
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,6 +55,37 @@ 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
91
  // Incoming data.
@@ -82,7 +113,7 @@ closure NodeWorkerNub(imp, options, local nownub) {
82
113
  })
83
114
 
84
115
  // finis
85
-
116
+
86
117
  App.workerNub = nownub
87
118
  };
88
119
 
@@ -30,13 +30,13 @@ closure WebWorkerNub(imp, options, local wonub) {
30
30
  }, options)
31
31
  wonub = new(object, this)
32
32
  wonub.instanceID = imp.us.instanceID || UUID()
33
- wonub.dispatcher = require("naanlib:frameworks/running/taskexec.nlg").TaskDispatcher()
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 = function impReceive(message, sourceID) {
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,6 +55,24 @@ 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
78
  // Incoming data.
@@ -83,7 +101,7 @@ closure WebWorkerNub(imp, options, local wonub) {
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-2024 by Richard C. Zulch
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
@@ -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.6.0+1";
627
+ statedoc.verstring = "1.7.0+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.6.0+1"
645
+ || statedoc.verstring != "1.7.0+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.6.0+1"
708
+ title: vsiteName + " 1.7.0+1"
737
709
  });
738
710
  }
739
711
  } catch (e) {
@@ -747,7 +719,7 @@ exports.NaanControllerWeb = function() {
747
719
  op: "VsiteClose",
748
720
  name: vsiteName,
749
721
  naancont: contSelf,
750
- title: vsiteName + " 1.6.0+1"
722
+ title: vsiteName + " 1.7.0+1"
751
723
  });
752
724
  termTextOut("\x1b[90m\x1b[3m".concat("\nwindow closed", "\x1b[0m\n"));
753
725
  }
@@ -763,7 +735,7 @@ exports.NaanControllerWeb = function() {
763
735
  op: "VsiteVisibilityChange",
764
736
  name: vsiteName,
765
737
  naancont: contSelf,
766
- title: vsiteName + " 1.6.0+1",
738
+ title: vsiteName + " 1.7.0+1",
767
739
  hidden: window.document.visibilityState == "hidden",
768
740
  window: window
769
741
  });
@@ -778,8 +750,8 @@ exports.NaanControllerWeb = function() {
778
750
  naanlib.banner();
779
751
  var hostpath = window.location.origin.concat(naanlib.js.r("path").dirname(window.location.pathname));
780
752
  naanlib.start({
781
- cmd: 'App.version = "1.6.0+1";;\r\n'
782
- + 'App.cache = "b39f039cddbcaf1570ae6008ea3bbeb6";;\r\n'
753
+ cmd: 'App.version = "1.7.0+1";;\r\n'
754
+ + 'App.cache = "1bae92ceb3cc5eb47f6dbe8e40ceeb9f";;\r\n'
783
755
  + 'Naan.module.requireQuery({ naanver: App.cache });;\r\n'
784
756
  + 'Naan.module.webparse("naan_init.nlg", "' + hostpath + '", { naanver: App.cache });;\r\n'
785
757
  });