recycleactor commited on
Commit
85b7646
·
verified ·
1 Parent(s): 49844f3

Upload server.js

Browse files
Files changed (1) hide show
  1. server.js +11 -1
server.js CHANGED
@@ -83,8 +83,10 @@ function jsWrapper(serverBase, baseUrl, transpiledCode, needRegenerator) {
83
  "if(typeof window.fetch==='function')return;" +
84
  "function H(h){this.map={};if(!h)return;for(var k in h)if(h.hasOwnProperty(k))this.map[k.toLowerCase()]=String(h[k]);}" +
85
  "H.prototype.get=function(k){return this.map[String(k).toLowerCase()]||null;};" +
 
86
  "function R(b,o){this._body=b||'';this.status=o&&o.status||200;this.statusText=o&&o.statusText||'OK';this.headers=new H(o&&o.headers||{});this.ok=this.status>=200&&this.status<300;}" +
87
  "R.prototype.text=function(){return Promise.resolve(String(this._body));};" +
 
88
  "window.fetch=function(u,opt){opt=opt||{};return new Promise(function(resolve,reject){try{var x=new XMLHttpRequest();x.open((opt.method||'GET'),u,true);var h=opt.headers||{};for(var k in h)if(h.hasOwnProperty(k))x.setRequestHeader(k,h[k]);x.onreadystatechange=function(){if(x.readyState===4){resolve(new R(x.responseText,{status:x.status||0,statusText:x.statusText||'',headers:{}}));}};x.onerror=function(){reject(new Error('Network error'));};x.send(opt.body||null);}catch(e){reject(e);}});};" +
89
  '})();'
90
 
@@ -125,12 +127,20 @@ function jsWrapper(serverBase, baseUrl, transpiledCode, needRegenerator) {
125
  'if(!document.__es5_proxy_patch){' +
126
  'document.__es5_proxy_patch=1;' +
127
  'var origAppend=Element.prototype.appendChild;' +
128
- 'Element.prototype.appendChild=function(node){' +
 
129
  'if(node&&node.tagName==="SCRIPT"&&node.src){' +
130
  'var a=abs(node.src);var o2=origin(a);if(__es5_active)allow[o2]=1;allow[o2]=1;if(allow[o2]&&__es5_server&&node.src.indexOf(__es5_server)===-1){node.src=__es5_server+"/p?url="+encodeURIComponent(a);}' +
131
  '}' +
 
 
 
132
  'return origAppend.call(this,node);' +
133
  '};' +
 
 
 
 
134
  '}' +
135
  '}catch(e){}' +
136
  'try{if(window.__es5CssVarsApply)window.__es5CssVarsApply();}catch(e){}' +
 
83
  "if(typeof window.fetch==='function')return;" +
84
  "function H(h){this.map={};if(!h)return;for(var k in h)if(h.hasOwnProperty(k))this.map[k.toLowerCase()]=String(h[k]);}" +
85
  "H.prototype.get=function(k){return this.map[String(k).toLowerCase()]||null;};" +
86
+ "H.prototype.has=function(k){return this.map.hasOwnProperty(String(k).toLowerCase());};" +
87
  "function R(b,o){this._body=b||'';this.status=o&&o.status||200;this.statusText=o&&o.statusText||'OK';this.headers=new H(o&&o.headers||{});this.ok=this.status>=200&&this.status<300;}" +
88
  "R.prototype.text=function(){return Promise.resolve(String(this._body));};" +
89
+ "R.prototype.json=function(){return Promise.resolve(String(this._body)).then(JSON.parse);};" +
90
  "window.fetch=function(u,opt){opt=opt||{};return new Promise(function(resolve,reject){try{var x=new XMLHttpRequest();x.open((opt.method||'GET'),u,true);var h=opt.headers||{};for(var k in h)if(h.hasOwnProperty(k))x.setRequestHeader(k,h[k]);x.onreadystatechange=function(){if(x.readyState===4){resolve(new R(x.responseText,{status:x.status||0,statusText:x.statusText||'',headers:{}}));}};x.onerror=function(){reject(new Error('Network error'));};x.send(opt.body||null);}catch(e){reject(e);}});};" +
91
  '})();'
92
 
 
127
  'if(!document.__es5_proxy_patch){' +
128
  'document.__es5_proxy_patch=1;' +
129
  'var origAppend=Element.prototype.appendChild;' +
130
+ 'var origInsertBefore=Element.prototype.insertBefore;' +
131
+ 'function patchNode(node){' +
132
  'if(node&&node.tagName==="SCRIPT"&&node.src){' +
133
  'var a=abs(node.src);var o2=origin(a);if(__es5_active)allow[o2]=1;allow[o2]=1;if(allow[o2]&&__es5_server&&node.src.indexOf(__es5_server)===-1){node.src=__es5_server+"/p?url="+encodeURIComponent(a);}' +
134
  '}' +
135
+ '}' +
136
+ 'Element.prototype.appendChild=function(node){' +
137
+ 'patchNode(node);' +
138
  'return origAppend.call(this,node);' +
139
  '};' +
140
+ 'Element.prototype.insertBefore=function(node, child){' +
141
+ 'patchNode(node);' +
142
+ 'return origInsertBefore.call(this,node, child);' +
143
+ '};' +
144
  '}' +
145
  '}catch(e){}' +
146
  'try{if(window.__es5CssVarsApply)window.__es5CssVarsApply();}catch(e){}' +