
// SwellRT bootstrap script

// A fake SwellRT object to register on ready handlers
// before the GWT module is loaded

window.swellrt = {

  onReady: function(handler) {
       if (!handler || typeof handler !== "function")
         return;
       
       if (!window._lh)
    	   window._lh = [];
    	   
       window._lh.push(handler);
      }
}

var scripts = document.getElementsByTagName('script');
var thisScript = scripts[scripts.length -1];


if (thisScript) {
  var p = document.createElement('a');
  p.href = thisScript.src;

  // Polyfill for ES6 proxy/reflect
  if (!window.Proxy || !window.Reflect) {
    var reflectSrc = p.protocol + "//" +p.host  + "/reflect.js";
    document.write("<script src='"+reflectSrc+"'></script>");
  }


  var scriptSrc = p.protocol + "//" +p.host  + "/swellrt_beta/swellrt_beta.nocache.js";
  document.write("<script src='"+scriptSrc+"'></script>");
}


@@ -113,17 +113,16 @@
  loaded%0A
-%0A
 window.s
@@ -239,16 +239,128 @@
 rn;%0A
+%0A
        
-%0A
+if (window.swellrt.runtime) %7B%0A          handler.apply(window, window.swellrt.runtime.get());%0A       %7D else %7B%0A   
     
@@ -383,17 +383,21 @@
 lh)%0A    
-%09
+     
    windo
@@ -415,14 +415,8 @@
 %0A   
- %09   %0A
     
@@ -442,24 +442,31 @@
 handler);%0A  
+     %7D%0A
     %7D%0A%7D%0A%0Avar
@@ -723,24 +723,36 @@
 .Reflect) %7B%0A
+    try %7B%0A  
     var refl
@@ -808,16 +808,18 @@
 s%22;%0A    
+  
 document
@@ -868,16 +868,87 @@
 ipt%3E%22);%0A
+    %7D catch (e) %7B%0A      console.log(%22No proxies supported: %22+e);%0A    %7D%0A
   %7D%0A%0A%0A  
@@ -1093,10 +1093,69 @@
 pt%3E%22);%0A%7D
-%0A
+ else %7B%0A  console.log(%22Unable to inject swellrt script!%22);%0A%7D
 %0A

Fix code launching onReady() handlers