@naanlang/naan 1.7.1 → 1.7.2

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.7.1+1";
39
+ var CurrentCacheName = "Naanlang-1.7.2+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.7.1+1] received new msgport for", sourceId, pubID, "-", pubVersion);
96
- if (pubVersion != "1.7.1+1") {
95
+ console.log("[1.7.2+1] received new msgport for", sourceId, pubID, "-", pubVersion);
96
+ if (pubVersion != "1.7.2+1") {
97
97
  if (upgradeMsgPorts) { // if not activated
98
- console.log("[1.7.1+1] update pending for", sourceId);
98
+ console.log("[1.7.2+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.7.1+1"
104
+ version: "1.7.2+1"
105
105
  });
106
- console.log("[1.7.1+1] update sent for:", sourceId);
106
+ console.log("[1.7.2+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.7.1+1] attempting skipWaiting");
137
+ console.log("[1.7.2+1] attempting skipWaiting");
138
138
  self.skipWaiting();
139
139
  } else if (msg.id == "terminate") { // termiante this SW now
140
- console.log("[1.7.1+1] terminated");
140
+ console.log("[1.7.2+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.7.1+1] msg received:", msg.text);
153
+ console.log("[1.7.2+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.7.1+1",
164
+ text: "port received by 1.7.2+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.7.1+1] requesting new msgport for", client.id);
181
+ console.log("[1.7.2+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.7.1+1] source gone:", sourceId);
227
+ console.log("[1.7.2+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.7.1+1] client gone:", clientId);
232
+ console.log("[1.7.2+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.7.1+1] deleting old cache:', cacheName);
266
+ console.log('[1.7.2+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.7.1+1] claiming clients');
272
+ console.log('[1.7.2+1] claiming clients');
273
273
  return (self.clients.claim());
274
274
  }).then(function() {
275
- console.log('[1.7.1+1] clients claimed');
275
+ console.log('[1.7.2+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.7.1+1",
318
+ version: "1.7.2+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.7.1+1] install");
366
+ console.log("[1.7.2+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.7.1+1] activate");
379
+ console.log("[1.7.2+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.7.1+1] matching clients:', urls.join(', '));
386
+ console.log('[1.7.2+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.7.1+1"
392
+ version: "1.7.2+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") !== "11fc8cf71f476b67053e1a89d5956596"
424
+ || url.search.length !== 0 && url.searchParams.get("naanver") !== "3bf8aca91851d612b349539bfba24f9c"
425
425
  || request.headers.get('range');
426
426
  if (url.pathname.startsWith("/run/")) {
427
427
  nocache = true;
@@ -455,7 +455,7 @@ self.addEventListener('fetch', function(event) {
455
455
  statusText: "Request Cancelled"
456
456
  }));
457
457
  }
458
- console.log("[1.7.1+1] fetch failed", request.url, e);
458
+ console.log("[1.7.2+1] fetch failed", request.url, e);
459
459
  return (new Response(undefined, {
460
460
  status: 404,
461
461
  statusText: "Fetch Failed"
@@ -151,7 +151,18 @@ closure ServiceWorker(pubID, pubVersion, local serv, callback) {
151
151
  message: "opened"
152
152
  })
153
153
  }
154
-
154
+
155
+ // update
156
+ //
157
+ // Go get the latest version of the service worker and update if changed.
158
+ //
159
+ serv.update = closure update(local err, reg) {
160
+ `(err, reg) = await(serv.reg.update())
161
+ if err
162
+ return (list(Error("service worker update failed", err)))
163
+ list(false, reg)
164
+ }
165
+
155
166
  // reload
156
167
  //
157
168
  // If a sevice worker is waiting, then terminate the old one and activate the new one -- which
@@ -426,6 +426,16 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
426
426
  result
427
427
  }
428
428
 
429
+ //
430
+ // init1
431
+ //
432
+ // Initialize a build worker.
433
+ //
434
+
435
+ function init1() {
436
+ require("../common").LiveImport()
437
+ }
438
+
429
439
  //
430
440
  // parseAndPack1
431
441
  //
@@ -434,7 +444,8 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
434
444
  // autoquoted to itself, a symbol. This can be used to detect build time vs. runtime.
435
445
 
436
446
  function parseAndPack1(text, fpath, options, operation,
437
- local util, lib, penv, naansym, dlogsym, pmod, pcomp, ournn, output, textout, annerror, annotations, package)
447
+ local util, lib, modid, penv, naansym, dlogsym, pmod, pcomp, ournn,
448
+ output, textout, annotations, package)
438
449
  {
439
450
  //
440
451
  // textline
@@ -453,6 +464,7 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
453
464
  lib = Naan.module.modlist().Lib.exports
454
465
  if !util || !lib
455
466
  return (list("Build packager cannot access support functions"))
467
+ modid = JSpath.basename(JSpath.dirname(fpath))
456
468
  //
457
469
  // The following crazy rigmarole is about customizing the ParsEnvironment so we can glean
458
470
  // enough information to build a package without actually executing the code. To do this we
@@ -469,7 +481,7 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
469
481
  pcomp = { } // our component object
470
482
  ournn.module = {
471
483
  build: function(modname, compname, proc) {
472
- pmod.id = module.id
484
+ pmod.id = modid
473
485
  pmod.exports = { }
474
486
  pcomp.name = compname
475
487
  call(proc, pmod, pcomp) // obtain manifest
@@ -513,23 +525,39 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
513
525
  //
514
526
  textout = ""
515
527
  try {
516
- if !pcomp.name
517
- annerror = "Component required to build package"
518
- else if output.errors.length > 0
519
- annerror = output.errors[0]
520
- annotations = output.annotations
521
- if annotations {
522
- if annotations.length == 0 { // empty annotations list
523
- if annerror
524
- annotations = [{ // first error becomes annotation
525
- row: 0
526
- column: 0
527
- text: annerror
528
- type: "error"
529
- }]
530
- else
531
- annotations = false } // no errors or annotations
528
+ if output.annotations.length == 0 && output.errors.length == 0
529
+ && (options.naanpack || options.jspack) { // actually building a package
530
+ if !pcomp.name {
531
+ //
532
+ // Some components cannot use a build function because they are too early in the
533
+ // boot process, but we still need a component. We look for NaanBuildComponent
534
+ // to define a dictionary with filename, name and manifest fields. For example,
535
+ // see Util:Module.nlg
536
+ //
537
+ pcomp = penv.evalq(car(compress(NaanBuildComponent)))
538
+ if !pcomp || !fpath.endsWith("/".concat(pcomp.filename))
539
+ output.errors.push("Build cannot package without component, use NaanBuildComponent?")
540
+ }
541
+ if output.errors.length == 0 {
542
+ package = util.pkgSave(compress(pcomp.name), pcomp.manifest)
543
+ if string(package) {
544
+ output.errors.push("Build cannot generate package: ".concat(package))
545
+ package = false
546
+ }
547
+ }
532
548
  }
549
+
550
+ annotations = output.annotations
551
+ if annotations.length == 0 { // empty annotations list
552
+ if output.errors.length > 0
553
+ annotations.push({ // first error becomes annotation
554
+ row: 0
555
+ column: 0
556
+ text: output.errors[0]
557
+ type: "error"
558
+ })
559
+ else
560
+ annotations = false } // no errors or annotations
533
561
  if output.errors.length > 0 || output.text.length > 0 {
534
562
  textline("-".repeat(79))
535
563
  textline("While processing ", fpath)
@@ -548,22 +576,6 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
548
576
  //
549
577
  // Build the package, if not just doing syntax checking
550
578
  //
551
- if options.naanpack || options.jspack { // actually building a package?
552
- if !pcomp.name {
553
- //
554
- // Some components cannot use a build function because they are too early in the
555
- // boot process, but we still need a component. We look for NaanBuildComponent
556
- // to define a dictionary with filename, name and manifest fields. For example,
557
- // see Util:Module.nlg
558
- //
559
- pcomp = penv.evalq(car(compress(NaanBuildComponent)))
560
- if !pcomp || !fpath.endsWith("/".concat(pcomp.filename))
561
- return (list("Build cannot package without component in ".concat(fpath), false, annotations, textout))
562
- }
563
- package = util.pkgSave(compress(pcomp.name), pcomp.manifest)
564
- if string(package)
565
- return (list("Build cannot generate package for ".concat(fpath), false, annotations, textout))
566
- }
567
579
  } catch {
568
580
  if true
569
581
  return (list("Packaging exception in ".concat(fpath, ": ", tostring(exception)), false, annotations, textout))
@@ -593,7 +605,7 @@ closure Builder(rules, operation, fs, srcpath, destpath, track, local build, gro
593
605
  if !build.parallel
594
606
  build.parallel = ExecutorParallel(track, { // create worker pool
595
607
  basename: "build"
596
- initeval: `(false, (parseAndPack1))
608
+ initeval: list(quote(init1()), `(init1, parseAndPack1))
597
609
  })
598
610
  result = build.parallel.rpc(parseAndPack1, list(text, fpath, options, operation))
599
611
  if !result.0 {
@@ -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.7.1+1 etc.
299
+ * NaanIDE_version.txt - [default] substitution file defining 1.7.2+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
@@ -624,7 +624,7 @@ exports.NaanControllerWeb = function() {
624
624
  statedoc.curversion = kStateCurrentVersion;
625
625
  statedoc.firstver = kStateFirstVersion;
626
626
  statedoc.licensee = "MIT-License";
627
- statedoc.verstring = "1.7.1+1";
627
+ statedoc.verstring = "1.7.2+1";
628
628
  statedoc.date = new Date().toISOString();
629
629
  statedoc.prefs = prefs;
630
630
  statedoc.naan = naanlib.saveState(false); // true to optimize, which is a bit slower
@@ -642,7 +642,7 @@ exports.NaanControllerWeb = function() {
642
642
  || statedoc.firstver > kStateCurrentVersion
643
643
  || statedoc.curversion < kStateFirstVersion
644
644
  || statedoc.licensee != "MIT-License"
645
- || statedoc.verstring != "1.7.1+1"
645
+ || statedoc.verstring != "1.7.2+1"
646
646
  || !(naanstate = statedoc.naan))
647
647
  {
648
648
  localStorage.removeItem("NaanState_Hosted");
@@ -705,7 +705,7 @@ exports.NaanControllerWeb = function() {
705
705
  op: "VsiteOpen",
706
706
  name: vsiteName,
707
707
  naancont: contSelf,
708
- title: vsiteName + " 1.7.1+1"
708
+ title: vsiteName + " 1.7.2+1"
709
709
  });
710
710
  }
711
711
  } catch (e) {
@@ -719,7 +719,7 @@ exports.NaanControllerWeb = function() {
719
719
  op: "VsiteClose",
720
720
  name: vsiteName,
721
721
  naancont: contSelf,
722
- title: vsiteName + " 1.7.1+1"
722
+ title: vsiteName + " 1.7.2+1"
723
723
  });
724
724
  }
725
725
  } catch (e) {
@@ -734,7 +734,7 @@ exports.NaanControllerWeb = function() {
734
734
  op: "VsiteVisibilityChange",
735
735
  name: vsiteName,
736
736
  naancont: contSelf,
737
- title: vsiteName + " 1.7.1+1",
737
+ title: vsiteName + " 1.7.2+1",
738
738
  hidden: window.document.visibilityState == "hidden",
739
739
  window: window
740
740
  });
@@ -749,8 +749,8 @@ exports.NaanControllerWeb = function() {
749
749
  naanlib.banner();
750
750
  var hostpath = window.location.origin.concat(naanlib.js.r("path").dirname(window.location.pathname));
751
751
  naanlib.start({
752
- cmd: 'App.version = "1.7.1+1";;\r\n'
753
- + 'App.cache = "b173565c63a43f623fb769868912eb9d";;\r\n'
752
+ cmd: 'App.version = "1.7.2+1";;\r\n'
753
+ + 'App.cache = "9e8f87aa915943862be39d701927fbd1";;\r\n'
754
754
  + 'Naan.module.requireQuery({ naanver: App.cache });;\r\n'
755
755
  + 'Naan.module.webparse("naan_init.nlg", "' + hostpath + '", { naanver: App.cache });;\r\n'
756
756
  });