@naanlang/naan 1.0.14 → 1.0.16

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.
@@ -36,7 +36,7 @@
36
36
  *
37
37
  */
38
38
 
39
- var CurrentCacheName = "Naanlang-1.0.14+1";
39
+ var CurrentCacheName = "Naanlang-1.0.16+1";
40
40
 
41
41
 
42
42
  //
@@ -92,18 +92,18 @@ var terminated; // flag that this service worker
92
92
  var pubVersion = event.data.hereIsMyVersion;
93
93
  var sourceId = event.source.id; // client id of sender of message
94
94
  msgPorts[sourceId] = msgport;
95
- console.log("[1.0.14+1] received new msgport for", sourceId, pubID, "-", pubVersion);
96
- if (pubVersion != "1.0.14+1") {
95
+ console.log("[1.0.16+1] received new msgport for", sourceId, pubID, "-", pubVersion);
96
+ if (pubVersion != "1.0.16+1") {
97
97
  if (upgradeMsgPorts) { // if not activated
98
- console.log("[1.0.14+1] update pending for", sourceId);
98
+ console.log("[1.0.16+1] update pending for", sourceId);
99
99
  upgradeMsgPorts[sourceId] = msgport;
100
100
  }
101
101
  else {
102
102
  msgport.postMessage({ // notify new version available
103
103
  id: "upgrade",
104
- version: "1.0.14+1"
104
+ version: "1.0.16+1"
105
105
  });
106
- console.log("[1.0.14+1] update sent for:", sourceId);
106
+ console.log("[1.0.16+1] update sent for:", sourceId);
107
107
  }
108
108
  }
109
109
  Reaper(); // clean up obsolete info
@@ -134,10 +134,10 @@ var terminated; // flag that this service worker
134
134
  msgport.onmessage = function(msg) {
135
135
  msg = msg.data;
136
136
  if (msg.id == "skipWaiting") { // try to activate this SW now
137
- console.log("[1.0.14+1] attempting skipWaiting");
137
+ console.log("[1.0.16+1] attempting skipWaiting");
138
138
  self.skipWaiting();
139
139
  } else if (msg.id == "terminate") { // termiante this SW now
140
- console.log("[1.0.14+1] terminated");
140
+ console.log("[1.0.16+1] terminated");
141
141
  terminate();
142
142
  } else if (msg.id == "abortURL") { // abort an I/O transaction
143
143
  var href = new URL(msg.url).href;
@@ -150,7 +150,7 @@ var terminated; // flag that this service worker
150
150
  } else if (msg.id == "response") // response from fetch request
151
151
  processResponse(msg);
152
152
  else if (msg.id == "text") // just log some text
153
- console.log("[1.0.14+1] msg received:", msg.text);
153
+ console.log("[1.0.16+1] msg received:", msg.text);
154
154
  };
155
155
 
156
156
  // send text to IDE log
@@ -161,7 +161,7 @@ var terminated; // flag that this service worker
161
161
  // don't clutter the log
162
162
  msgport.postMessage({
163
163
  id: "text",
164
- text: "port received by 1.0.14+1",
164
+ text: "port received by 1.0.16+1",
165
165
  });
166
166
  */
167
167
  if (--pending === 0)
@@ -178,7 +178,7 @@ var terminated; // flag that this service worker
178
178
  includeUncontrolled: true
179
179
  }).then(function(clientList) {
180
180
  clientList.every(function(client) {
181
- console.log("[1.0.14+1] requesting new msgport for", client.id);
181
+ console.log("[1.0.16+1] requesting new msgport for", client.id);
182
182
  ++pending;
183
183
  client.postMessage({ // tell client(s) we need this fetch source
184
184
  msg: "Naan_need_fetch_port",
@@ -224,12 +224,12 @@ function Reaper() {
224
224
  clients[clientList[clidex].id] = clientList[clidex];
225
225
  for (var sourceId in msgPorts)
226
226
  if (!clients[sourceId]) {
227
- console.log("[1.0.14+1] source gone:", sourceId);
227
+ console.log("[1.0.16+1] source gone:", sourceId);
228
228
  delete msgPorts[sourceId]; // no longer a source
229
229
  }
230
230
  for (var clientId in fetchPorts)
231
231
  if (!clients[clientId]) {
232
- console.log("[1.0.14+1] client gone:", clientId);
232
+ console.log("[1.0.16+1] client gone:", clientId);
233
233
  delete fetchPorts[clientId]; // no longer a client
234
234
  }
235
235
  for (var fqdex = 0; fqdex < fetchQueue.length; ++fqdex) {
@@ -263,16 +263,16 @@ function ClearCaches() {
263
263
  return (Promise.all(
264
264
  cacheNames.map(function(cacheName) {
265
265
  if (cacheName != CurrentCacheName) {
266
- console.log('[1.0.14+1] deleting old cache:', cacheName);
266
+ console.log('[1.0.16+1] deleting old cache:', cacheName);
267
267
  return (caches.delete(cacheName));
268
268
  }
269
269
  })
270
270
  ));
271
271
  }).then(function() { // claim all clients
272
- console.log('[1.0.14+1] claiming clients');
272
+ console.log('[1.0.16+1] claiming clients');
273
273
  return (self.clients.claim());
274
274
  }).then(function() {
275
- console.log('[1.0.14+1] clients claimed');
275
+ console.log('[1.0.16+1] clients claimed');
276
276
  return (Promise.resolve(true));
277
277
  });
278
278
  return (promise);
@@ -315,7 +315,7 @@ function GetClientResponse(event, urlpath) {
315
315
  msgport.postMessage({
316
316
  id: "fetch",
317
317
  seq: seqno,
318
- version: "1.0.14+1",
318
+ version: "1.0.16+1",
319
319
  request: {
320
320
  method: event.request.method,
321
321
  url: event.request.url
@@ -363,7 +363,7 @@ function GetClientResponse(event, urlpath) {
363
363
  */
364
364
 
365
365
  self.addEventListener('install', function(event) {
366
- console.log("[1.0.14+1] install");
366
+ console.log("[1.0.16+1] install");
367
367
  self.skipWaiting();
368
368
  });
369
369
 
@@ -376,20 +376,20 @@ self.addEventListener('install', function(event) {
376
376
  */
377
377
 
378
378
  self.addEventListener('activate', function(event) {
379
- console.log("[1.0.14+1] activate");
379
+ console.log("[1.0.16+1] activate");
380
380
  self.clients.matchAll({ // for debugging, list controlled clients
381
381
  includeUncontrolled: true
382
382
  }).then(function(clientList) {
383
383
  var urls = clientList.map(function(client) {
384
384
  return (client.url);
385
385
  });
386
- console.log('[1.0.14+1] matching clients:', urls.join(', '));
386
+ console.log('[1.0.16+1] matching clients:', urls.join(', '));
387
387
  });
388
388
  var promise = ClearCaches().then(function() {
389
389
  for (var sourceId in upgradeMsgPorts) {
390
390
  upgradeMsgPorts[sourceId].postMessage({ // notify new version available
391
391
  id: "upgrade",
392
- version: "1.0.14+1"
392
+ version: "1.0.16+1"
393
393
  });
394
394
  }
395
395
  upgradeMsgPorts = false;
@@ -421,7 +421,7 @@ self.addEventListener('fetch', function(event) {
421
421
  var promise;
422
422
  var url = new URL(request.url);
423
423
  var nocache = request.method != "GET"
424
- || url.search.length !== 0 && url.searchParams.get("naanver") !== "3551208545a0b7d226925e1a7a47bc6d"
424
+ || url.search.length !== 0 && url.searchParams.get("naanver") !== "b2535090f4e111466794eea676c7d7aa"
425
425
  || request.headers.get('range');
426
426
  if (url.pathname.startsWith("/run/")) {
427
427
  nocache = true;
@@ -454,7 +454,7 @@ self.addEventListener('fetch', function(event) {
454
454
  statusText: "Request Cancelled"
455
455
  }));
456
456
  }
457
- console.log("[1.0.14+1] fetch failed", request.url, e);
457
+ console.log("[1.0.16+1] fetch failed", request.url, e);
458
458
  return (new Response(undefined, {
459
459
  status: 404,
460
460
  statusText: "Fetch Failed"
@@ -393,7 +393,10 @@ closure TermLocal(track, name, workerID, options,
393
393
 
394
394
  listener.addEventListener("message", function(e, msg) {
395
395
  msg = new(e.data)
396
- if msg.id != "targetout" && msg.id != "loaded" {
396
+ if msg.id == "termination" {
397
+ destroy()
398
+ return }
399
+ else if msg.id != "targetout" && msg.id != "loaded" {
397
400
  if msg.id == "status"
398
401
  target.lastStatus = milliseconds()
399
402
  if target.msgQueue {
@@ -58,7 +58,7 @@
58
58
  * @ - the @ character stands in for a persistent, temporary directory within the
59
59
  * build folder that replaces srcpath or destpath. It can be used in fields that
60
60
  * are otherwise absolute: group.input, group.output, and template paths. Build
61
- * detects piplines formed from temporary files and processes them in order from
61
+ * detects pipelines formed from temporary files and processes them in order from
62
62
  * beginning to end.
63
63
  *
64
64
  * Templates:
@@ -83,7 +83,7 @@
83
83
  * jspack - convert to Naan JavaScript format
84
84
  * syntax - syntax check and copy
85
85
  * catenate - copy multiple input files into a single output file
86
- * zip - compressed catenate
86
+ * zip - compressed catenate (binary if only task, otherwise text mode)
87
87
  *
88
88
  * Dictionary structure:
89
89
  * {
@@ -159,7 +159,7 @@ closure Builder(rules, operation, fs, srcpath, destpath, local build, group, new
159
159
  }
160
160
  build.solotasks = { // solo-only tasks
161
161
  copy: true,
162
- unzip: true
162
+ unzip: true,
163
163
  }
164
164
 
165
165
  if rules.licfile
@@ -725,6 +725,7 @@ closure Builder(rules, operation, fs, srcpath, destpath, local build, group, new
725
725
  return
726
726
  }
727
727
  entry = {
728
+ tasks: group.tasks
728
729
  readpath: infile,
729
730
  writepath: outfile
730
731
  }
@@ -960,10 +961,12 @@ closure Builder(rules, operation, fs, srcpath, destpath, local build, group, new
960
961
 
961
962
  closure processOneFile(entry, local result, content, error) {
962
963
  ++pending.active
963
- future(function build1(local dirpath) {
964
+ future(function build1(local dirpath, readOptions) {
964
965
  if entry.depends
965
966
  entry.depends.done.wait() // wait for our precursor
966
967
  dirpath = JSpath.dirname(entry.writepath)
968
+ if entry.zip && entry.tasks.length == 1
969
+ readOptions = { encoding: "binary" } // just zip--no text processing
967
970
  if baddestpaths[dirpath]
968
971
  { } // error already reported
969
972
  else if ((`(error, result) = fs.mkdir(dirpath)) && error) {
@@ -983,7 +986,7 @@ closure Builder(rules, operation, fs, srcpath, destpath, local build, group, new
983
986
  if error // deepcopy returns a list of errors
984
987
  error = error.0 // but we're only doing one item
985
988
  }
986
- else if ((`(error, content) = fs.readFile(entry.readpath)) && !error) {
989
+ else if ((`(error, content) = fs.readFile(entry.readpath, readOptions)) && !error) {
987
990
  if entry.license
988
991
  `(content) = applySubstitutions(content, licFileDefs)
989
992
  if entry.version
@@ -296,7 +296,7 @@ closure projConnector(projman, projtype, local connector, watch) {
296
296
  *
297
297
  * Nide.proj/
298
298
  * nide_cliser.cfg - JSON definition of the project (see below)
299
- * NaanIDE_version.txt - [default] substitution file defining 1.0.14+1 etc.
299
+ * NaanIDE_version.txt - [default] substitution file defining 1.0.16+1 etc.
300
300
  * NaanIDE_version_builds.txt - [default] contains current build number as decimal string
301
301
  * build/ - [optional] default build output location
302
302
  * NaanIDE.lic - [optional] defines Zulch Laboratories, Inc. and other license info
@@ -62,7 +62,7 @@ closure DebugNub(local nub, debug, paused) {
62
62
  paused.wait = false // false: go back to ndb
63
63
  }
64
64
  else if msg.op == "pause"
65
- future(function(){ debugger() }, 1) // enter at convenient time
65
+ debugger()
66
66
  else if msg.op == "resume" || msg.op == "stop"
67
67
  || msg.op == "stepover" || msg.op == "stepinto" || msg.op == "stepout"
68
68
  paused.wait = msg.op
@@ -201,7 +201,7 @@ exports.NaanControllerWeb = function() {
201
201
  this.Interrupt = function Interrupt(terminal) {
202
202
  window.setTimeout(function () {
203
203
  naanlib.escape();
204
- }, 1);
204
+ }, 0);
205
205
  };
206
206
 
207
207
  //
@@ -526,7 +526,7 @@ exports.NaanControllerWeb = function() {
526
526
  statedoc.curversion = kStateCurrentVersion;
527
527
  statedoc.firstver = kStateFirstVersion;
528
528
  statedoc.licensee = "MIT-License";
529
- statedoc.verstring = "1.0.14+1";
529
+ statedoc.verstring = "1.0.16+1";
530
530
  statedoc.date = new Date().toISOString();
531
531
  statedoc.prefs = prefs;
532
532
  statedoc.naan = naanlib.saveState(false); // true to optimize, which is a bit slower
@@ -544,7 +544,7 @@ exports.NaanControllerWeb = function() {
544
544
  || statedoc.firstver > kStateCurrentVersion
545
545
  || statedoc.curversion < kStateFirstVersion
546
546
  || statedoc.licensee != "MIT-License"
547
- || statedoc.verstring != "1.0.14+1")
547
+ || statedoc.verstring != "1.0.16+1")
548
548
  {
549
549
  localStorage.removeItem("NaanState_Hosted");
550
550
  return (false);
@@ -603,7 +603,7 @@ exports.NaanControllerWeb = function() {
603
603
  op: "VsiteOpen",
604
604
  name: vsiteName,
605
605
  naancont: contSelf,
606
- title: vsiteName + " 1.0.14+1"
606
+ title: vsiteName + " 1.0.16+1"
607
607
  });
608
608
  }
609
609
  } catch (e) {
@@ -617,7 +617,7 @@ exports.NaanControllerWeb = function() {
617
617
  op: "VsiteClose",
618
618
  name: vsiteName,
619
619
  naancont: contSelf,
620
- title: vsiteName + " 1.0.14+1"
620
+ title: vsiteName + " 1.0.16+1"
621
621
  });
622
622
  termTextOut("\x1b[90m\x1b[3m".concat("\nwindow closed", "\x1b[0m\n"));
623
623
  }
@@ -632,8 +632,8 @@ exports.NaanControllerWeb = function() {
632
632
  naanlib.banner();
633
633
  var hostpath = naanlib.js.r("path").dirname(window.location.href);
634
634
  naanlib.start({
635
- cmd: 'App.version = "1.0.14+1";;\r\n'
636
- + 'App.cache = "7d35a97d7bea57c619edd042aaf5b648";;\r\n'
635
+ cmd: 'App.version = "1.0.16+1";;\r\n'
636
+ + 'App.cache = "268effa64ff3abbb3b2387089c918818";;\r\n'
637
637
  + 'Naan.module.requireQuery({ naanver: App.cache });;\r\n'
638
638
  + 'Naan.module.webparse("naan_init.nlg", "' + hostpath + '", { naanver: App.cache });;\r\n'
639
639
  });
@@ -114,6 +114,15 @@ exports.NaanControllerWebWorker = function NaanControllerWebWorker() {
114
114
  return (name);
115
115
  };
116
116
 
117
+ targSelf.Terminate = function Terminate(result) {
118
+ postMessage({ // terminate this worker from worker
119
+ id: "termination",
120
+ result: result
121
+ });
122
+ close();
123
+ return (result);
124
+ };
125
+
117
126
  onmessage = function(e) {
118
127
  var msg = e.data;
119
128
  if (msg.id == "interrupt")