Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zayesh/stay

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zayesh/stay - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

6

build/stay.js
/**
* stay v0.1.6 build Oct 26 2015
* stay v0.1.7 build Nov 02 2015
* https://github.com/vanruesc/stay
* Copyright 2015 Raoul van Rueschen, Apache-2.0
* Copyright 2015 Raoul van Rüschen, Apache-2.0
*/

@@ -785,3 +785,3 @@ var Stay = (function () { 'use strict';

origin = document.origin ? document.origin : "null";
origin = document.origin ? document.origin : document.defaultView.location.origin ? document.defaultView.location.origin : "null";

@@ -788,0 +788,0 @@ // Only try to push in a server environment.

/**
* stay v0.1.6 build Oct 26 2015
* stay v0.1.7 build Nov 02 2015
* https://github.com/vanruesc/stay
* Copyright 2015 Raoul van Rueschen, Apache-2.0
* Copyright 2015 Raoul van Rüschen, Apache-2.0
*/
var Stay=function(){"use strict";function t(){this._listeners={}}function e(t){var e=document.createElement("a");return e.href=t,e.pathname}function i(e){var s=this;if(t.call(this),this.local=new RegExp("^"+location.protocol+"//"+location.host),this.exclusions=[],this.stderr=null,this.infix="/json",this.timeoutPost=6e4,this.timeoutGet=5e3,this.autoUpdate=!0,void 0!==e&&(void 0!==e.stderr&&(this.stderr=e.stderr),void 0!==e.infix&&(this.infix=e.infix),void 0!==e.timeoutPost&&(this.timeoutPost=e.timeoutPost),void 0!==e.timeoutGet&&(this.timeoutGet=e.timeoutGet),void 0!==e.autoUpdate&&(this.autoUpdate=e.autoUpdate)),this.locked=!1,this.backForward=!1,this.absolutePath=null,this.historyState=null,this.containers=[],this.intermediateContainer=null,this.navigationListeners=[],this.eventNavigate={type:"navigate"},this.eventReceive={type:"receive",response:null,status:0},this.eventLoad={type:"load"},void 0===XMLHttpRequest)throw new Error("XMLHttpRequest not supported.");this.xhr=new XMLHttpRequest,this.xhr.addEventListener("error",function(t){s.dispatchEvent(t)}),this.xhr.addEventListener("readystatechange",function(t){s._handleResponse(this,t)}),this.xhr.addEventListener("timeout",function(){var t={meta:{}};t.meta.title="Timeout Error",null!==s.stderr?t[s.stderr]="<p>"+i.Error.TIMEOUT+"</p>":console.error(i.Error.TIMEOUT),s.locked=!0,s.update(t)}),window.addEventListener("popstate",function(t){s.locked||null===t.state||(s.backForward=!0,s._navigate({href:t.state.url}))}),this._switchPage=function(t){var e=void 0!==t.preventDefault,i=!1;return"submit"===t.type?i=!0:t.metaKey||t.shiftKey||t.altKey||t.ctrlKey||(void 0!==t.which?i=1===t.which:void 0!==t.button&&(i=0===t.button)),i&&(e&&t.preventDefault(),s.locked||s._navigate(this)),!(i&&!e)},this.update({meta:{title:document.title,url:location.href}}),this._updateListeners()}return t.prototype.apply=function(e){e._listeners={},e.addEventListener=t.prototype.addEventListener,e.hasEventListener=t.prototype.hasEventListener,e.removeEventListener=t.prototype.removeEventListener,e.dispatchEvent=t.prototype.dispatchEvent},t.prototype.addEventListener=function(t,e){void 0===this._listeners[t]&&(this._listeners[t]=[]),-1===this._listeners[t].indexOf(e)&&this._listeners[t].push(e)},t.prototype.hasEventListener=function(t,e){return void 0!==this._listeners[t]&&-1!==this._listeners[t].indexOf(e)},t.prototype.removeEventListener=function(t,e){var i,s;s=this._listeners[t],void 0!==s&&(i=s.indexOf(e),-1!==i&&s.splice(i,1))},t.prototype.dispatchEvent=function(t){var e,i,s;if(s=this._listeners[t.type],void 0!==s)for(t.target=this,e=0,i=s.length;i>e;++e)s[e].call(this,t)},i.prototype=Object.create(t.prototype),i.prototype.constructor=i,i.prototype._navigate=function(t){var i,s,n,r=!1;this.locked=!0,t.action?(this.absolutePath=t.action,i=new FormData(t),r=!0):this.absolutePath=t.href,s=e(this.absolutePath),"/"!==s.charAt(0)&&(s="/"+s),n="/"===s?this.absolutePath.slice(0,this.absolutePath.length-1)+this.infix+s:this.absolutePath.replace(new RegExp(s),this.infix+s),this.eventNavigate.method=r?"POST":"GET",this.dispatchEvent(this.eventNavigate);try{this.xhr.open(this.eventNavigate.method,n,!0),r?(this.xhr.timeout=this.timeoutPost,this.xhr.send(i)):(this.xhr.timeout=this.timeoutGet,this.xhr.send())}catch(o){this.dispatchEvent(o)}},i.prototype._updateView=function(t){var e,s,n,r=!1;if(null===this.intermediateContainer)this.intermediateContainer=document.createElement("div");else for(;this.intermediateContainer.children.length>0;)this.intermediateContainer.removeChild(this.intermediateContainer.children[0]);for(e in t)if(n=t[e],"object"!=typeof n)if(s=this.containers[e],void 0===s&&(s=this.containers[e]=document.getElementById(e)),null!==s){for(;s.children.length>0;)s.removeChild(s.children[0]);for(this.intermediateContainer.innerHTML=n;this.intermediateContainer.children.length>0;)s.appendChild(this.intermediateContainer.children[0]);r=!0}else console.warn(i.Error.NO_CONTAINER,e);r&&this._updateListeners()},i.prototype.unbindListeners=function(){for(var t,e=this;this.navigationListeners.length>0;)t=this.navigationListeners.pop(),t[0].removeEventListener(t[1],e._switchPage)},i.prototype._updateListeners=function(){var t,e,i,s,n,r=this,o=document.getElementsByTagName("a"),a=document.getElementsByTagName("form");for(this.unbindListeners(),t=0,i=o.length;i>t;++t)if(this.local.test(o[t].href)){for(e=0,s=this.exclusions.length,n=!1;!n&&s>e;++e)this.exclusions[e].test(o[t].href)&&(n=!0);n||(o[t].addEventListener("click",r._switchPage),this.navigationListeners.push([o[t],"click"]))}for(t=0,i=a.length;i>t;++t)if(this.local.test(a[t].action)){for(e=0,s=this.exclusions.length,n=!1;!n&&s>e;++e)this.exclusions[e].test(a[t].action)&&(n=!0);n||(a[t].addEventListener("submit",r._switchPage),this.navigationListeners.push([a[t],"submit"]))}},i.prototype.update=function(t){var e;if(this._updateView(t),document.title=t.meta.title,t.meta.url&&(this.absolutePath=t.meta.url.replace(this.infix,"")),this.backForward)this.backForward=!1;else if(null===this.historyState||this.absolutePath!==this.historyState.url?this.historyState={url:this.absolutePath,time:Date.now(),changed:!0}:this.historyState.changed=!1,e=document.origin?document.origin:"null","null"!==e)try{this.historyState.changed?history.pushState(this.historyState,t.meta.title,this.absolutePath):history.replaceState(this.historyState,t.meta.title,this.absolutePath)}catch(i){console.warn(i)}this.eventReceive.response=null,this.dispatchEvent(this.eventLoad),this.locked=!1},i.prototype._handleResponse=function(t){var e={meta:{}};if(4===t.readyState){try{e=JSON.parse(t.responseText)}catch(s){e.meta.title="Parse Error",null!==this.stderr&&(e[this.stderr]="<p>"+i.Error.UNPARSABLE+"</p>"),console.error(i.Error.UNPARSABLE)}e.meta.url=t.responseURL,this.eventReceive.status=t.status,this.eventReceive.response=e,this.dispatchEvent(this.eventReceive),this.autoUpdate&&this.update(e)}},i.Error=Object.freeze({TIMEOUT:"The server didn't respond in time. Please try again later!",UNPARSABLE:"The received content could not be parsed.",NO_CONTAINER:"Couldn't find a container for:"}),i}();
var Stay=function(){"use strict";function t(){this._listeners={}}function e(t){var e=document.createElement("a");return e.href=t,e.pathname}function i(e){var s=this;if(t.call(this),this.local=new RegExp("^"+location.protocol+"//"+location.host),this.exclusions=[],this.stderr=null,this.infix="/json",this.timeoutPost=6e4,this.timeoutGet=5e3,this.autoUpdate=!0,void 0!==e&&(void 0!==e.stderr&&(this.stderr=e.stderr),void 0!==e.infix&&(this.infix=e.infix),void 0!==e.timeoutPost&&(this.timeoutPost=e.timeoutPost),void 0!==e.timeoutGet&&(this.timeoutGet=e.timeoutGet),void 0!==e.autoUpdate&&(this.autoUpdate=e.autoUpdate)),this.locked=!1,this.backForward=!1,this.absolutePath=null,this.historyState=null,this.containers=[],this.intermediateContainer=null,this.navigationListeners=[],this.eventNavigate={type:"navigate"},this.eventReceive={type:"receive",response:null,status:0},this.eventLoad={type:"load"},void 0===XMLHttpRequest)throw new Error("XMLHttpRequest not supported.");this.xhr=new XMLHttpRequest,this.xhr.addEventListener("error",function(t){s.dispatchEvent(t)}),this.xhr.addEventListener("readystatechange",function(t){s._handleResponse(this,t)}),this.xhr.addEventListener("timeout",function(){var t={meta:{}};t.meta.title="Timeout Error",null!==s.stderr?t[s.stderr]="<p>"+i.Error.TIMEOUT+"</p>":console.error(i.Error.TIMEOUT),s.locked=!0,s.update(t)}),window.addEventListener("popstate",function(t){s.locked||null===t.state||(s.backForward=!0,s._navigate({href:t.state.url}))}),this._switchPage=function(t){var e=void 0!==t.preventDefault,i=!1;return"submit"===t.type?i=!0:t.metaKey||t.shiftKey||t.altKey||t.ctrlKey||(void 0!==t.which?i=1===t.which:void 0!==t.button&&(i=0===t.button)),i&&(e&&t.preventDefault(),s.locked||s._navigate(this)),!(i&&!e)},this.update({meta:{title:document.title,url:location.href}}),this._updateListeners()}return t.prototype.apply=function(e){e._listeners={},e.addEventListener=t.prototype.addEventListener,e.hasEventListener=t.prototype.hasEventListener,e.removeEventListener=t.prototype.removeEventListener,e.dispatchEvent=t.prototype.dispatchEvent},t.prototype.addEventListener=function(t,e){void 0===this._listeners[t]&&(this._listeners[t]=[]),-1===this._listeners[t].indexOf(e)&&this._listeners[t].push(e)},t.prototype.hasEventListener=function(t,e){return void 0!==this._listeners[t]&&-1!==this._listeners[t].indexOf(e)},t.prototype.removeEventListener=function(t,e){var i,s;s=this._listeners[t],void 0!==s&&(i=s.indexOf(e),-1!==i&&s.splice(i,1))},t.prototype.dispatchEvent=function(t){var e,i,s;if(s=this._listeners[t.type],void 0!==s)for(t.target=this,e=0,i=s.length;i>e;++e)s[e].call(this,t)},i.prototype=Object.create(t.prototype),i.prototype.constructor=i,i.prototype._navigate=function(t){var i,s,n,r=!1;this.locked=!0,t.action?(this.absolutePath=t.action,i=new FormData(t),r=!0):this.absolutePath=t.href,s=e(this.absolutePath),"/"!==s.charAt(0)&&(s="/"+s),n="/"===s?this.absolutePath.slice(0,this.absolutePath.length-1)+this.infix+s:this.absolutePath.replace(new RegExp(s),this.infix+s),this.eventNavigate.method=r?"POST":"GET",this.dispatchEvent(this.eventNavigate);try{this.xhr.open(this.eventNavigate.method,n,!0),r?(this.xhr.timeout=this.timeoutPost,this.xhr.send(i)):(this.xhr.timeout=this.timeoutGet,this.xhr.send())}catch(o){this.dispatchEvent(o)}},i.prototype._updateView=function(t){var e,s,n,r=!1;if(null===this.intermediateContainer)this.intermediateContainer=document.createElement("div");else for(;this.intermediateContainer.children.length>0;)this.intermediateContainer.removeChild(this.intermediateContainer.children[0]);for(e in t)if(n=t[e],"object"!=typeof n)if(s=this.containers[e],void 0===s&&(s=this.containers[e]=document.getElementById(e)),null!==s){for(;s.children.length>0;)s.removeChild(s.children[0]);for(this.intermediateContainer.innerHTML=n;this.intermediateContainer.children.length>0;)s.appendChild(this.intermediateContainer.children[0]);r=!0}else console.warn(i.Error.NO_CONTAINER,e);r&&this._updateListeners()},i.prototype.unbindListeners=function(){for(var t,e=this;this.navigationListeners.length>0;)t=this.navigationListeners.pop(),t[0].removeEventListener(t[1],e._switchPage)},i.prototype._updateListeners=function(){var t,e,i,s,n,r=this,o=document.getElementsByTagName("a"),a=document.getElementsByTagName("form");for(this.unbindListeners(),t=0,i=o.length;i>t;++t)if(this.local.test(o[t].href)){for(e=0,s=this.exclusions.length,n=!1;!n&&s>e;++e)this.exclusions[e].test(o[t].href)&&(n=!0);n||(o[t].addEventListener("click",r._switchPage),this.navigationListeners.push([o[t],"click"]))}for(t=0,i=a.length;i>t;++t)if(this.local.test(a[t].action)){for(e=0,s=this.exclusions.length,n=!1;!n&&s>e;++e)this.exclusions[e].test(a[t].action)&&(n=!0);n||(a[t].addEventListener("submit",r._switchPage),this.navigationListeners.push([a[t],"submit"]))}},i.prototype.update=function(t){var e;if(this._updateView(t),document.title=t.meta.title,t.meta.url&&(this.absolutePath=t.meta.url.replace(this.infix,"")),this.backForward)this.backForward=!1;else if(null===this.historyState||this.absolutePath!==this.historyState.url?this.historyState={url:this.absolutePath,time:Date.now(),changed:!0}:this.historyState.changed=!1,e=document.origin?document.origin:document.defaultView.location.origin?document.defaultView.location.origin:"null","null"!==e)try{this.historyState.changed?history.pushState(this.historyState,t.meta.title,this.absolutePath):history.replaceState(this.historyState,t.meta.title,this.absolutePath)}catch(i){console.warn(i)}this.eventReceive.response=null,this.dispatchEvent(this.eventLoad),this.locked=!1},i.prototype._handleResponse=function(t){var e={meta:{}};if(4===t.readyState){try{e=JSON.parse(t.responseText)}catch(s){e.meta.title="Parse Error",null!==this.stderr&&(e[this.stderr]="<p>"+i.Error.UNPARSABLE+"</p>"),console.error(i.Error.UNPARSABLE)}e.meta.url=t.responseURL,this.eventReceive.status=t.status,this.eventReceive.response=e,this.dispatchEvent(this.eventReceive),this.autoUpdate&&this.update(e)}},i.Error=Object.freeze({TIMEOUT:"The server didn't respond in time. Please try again later!",UNPARSABLE:"The received content could not be parsed.",NO_CONTAINER:"Couldn't find a container for:"}),i}();
{
"name": "@zayesh/stay",
"version": "0.1.6",
"version": "0.1.7",
"description": "Stay is a small but effective library for the creation of dynamic xhr-driven web applications.",

@@ -18,3 +18,3 @@ "homepage": "https://github.com/vanruesc/stay",

"author": {
"name": "Raoul van Rueschen",
"name": "Raoul van Rüschen",
"email": "vanruesc@fh-brandenburg.de"

@@ -53,3 +53,3 @@ },

"engines": {
"node": ">= 0.10.0"
"node": ">= 0.12.0"
},

@@ -56,0 +56,0 @@

@@ -163,3 +163,3 @@ # Stay

## License
Copyright (c) 2015 Raoul van Rueschen
Copyright (c) 2015 Raoul van Rüschen
Licensed under the Apache 2.0 license.

@@ -647,3 +647,3 @@ import EventDispatcher from "@zayesh/eventdispatcher";

origin = document.origin ? document.origin : "null";
origin = document.origin ? document.origin : document.defaultView.location.origin ? document.defaultView.location.origin : "null";

@@ -650,0 +650,0 @@ // Only try to push in a server environment.

{
"name": "Stay API",
"description": "Stay is a small but effective library for the creation of dynamic xhr-driven web applications.",
"version": "0.1.6",
"version": "0.1.7",
"url": "https://github.com/vanruesc/stay",

@@ -6,0 +6,0 @@ "options": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc