san-router
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("san-router",[],e):"object"==typeof exports?exports["san-router"]=e():t["san-router"]=e()}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,o){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist",e(e.s=6)}([function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){var r=(0,s.default)(t),o=(0,s.default)(e),n=r.path;if(0===n.indexOf("/"))return t;var i=n.split("/"),a=o.path.split("/");a.pop();for(var u=0;u<i.length;u++){var c=i[u];switch(c){case"..":a.pop();break;case".":break;default:a.push(c)}}return""!==a[0]&&a.unshift(""),a.join("/")+(r.queryString?"?"+r.queryString:"")}e.__esModule=!0,e.default=n;var i=r(1),s=o(i)},function(t,e,r){"use strict";function o(t){var e={};e.hash="";var r=t.indexOf("#");r>=0&&(e.hash=t.slice(r+1),t=t.slice(0,r)),e.queryString="";var o={};e.query=o;var n=t.indexOf("?");return n>=0&&(e.queryString=t.slice(n+1),t=t.slice(0,n),e.queryString.split("&").forEach(function(t){var e=t.indexOf("="),r="";e>0&&(r=t.slice(e+1),t=t.slice(0,e));var n=decodeURIComponent(t);r=decodeURIComponent(r),o.hasOwnProperty(n)?o[n]=[].concat(o[n],r):o[n]=r})),e.path=t,e}e.__esModule=!0,e.default=o},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=r(7),a=o(s),u=r(8),c=o(u),f=Symbol("eventPool"),p=function(){function t(){n(this,t)}return t.prototype.on=function(t,e,r,o){this[f]||(this[f]=Object.create(null)),this[f][t]||(this[f][t]=new c.default);var n=this[f][t];o=Object.assign({},o),r&&(o.thisObject=r),n.add(e,o)},t.prototype.once=function(t,e,r,o){o=Object.assign({},o),o.once=!0,this.on(t,e,r,o)},t.prototype.un=function(t,e,r){if(this[f]&&this[f][t]){var o=this[f][t];o.remove(e,r)}},t.prototype.fire=function(t,e){if(1===arguments.length&&"object"===("undefined"==typeof t?"undefined":i(t))&&(e=t,t=e.type),!t)throw new Error("No event type specified");if("*"===t)throw new Error("Cannot fire global event");var r=e instanceof a.default?e:new a.default(t,e);if(r.target=this,this[f]&&this[f][t]){var o=this[f][t];o.execute(r,this)}if(this[f]&&this[f]["*"]){var n=this[f]["*"];n.execute(r,this)}return r},t.prototype.destroyEvents=function(){if(this[f]){for(var t in this[f])this[f][t]&&this[f][t].dispose();this[f]=null}},t}();e.default=p},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var n=r(6),i=r(0),s=o(i);e.default={template:'<a href="{{href}}" onclick="return false;" on-click="clicker($event)" target="{{target}}" class="{{class}}" style="{{style}}"><slot></slot></a>',clicker:function(t){var e=this.data.get("href");"string"==typeof e&&n.router.locator.redirect(e.replace(/^#/,"")),t.preventDefault?t.preventDefault():t.returnValue=!1},computed:{href:function t(){var e=this.data.get("to");if("string"==typeof e){var t=(0,s.default)(e,n.router.locator.current);return"hash"===n.router.mode&&(t="#"+t),t}}}}},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(){var t=location.href.indexOf("#"),e=t<0?"/":location.href.slice(t+1);return e}e.__esModule=!0;var u=r(2),c=o(u),f=r(0),p=o(f),l=Symbol("hashchange_handler_key"),h=function(t){function e(){n(this,e);var r=i(this,t.call(this));return r.current=a(),r.referrer="",r[l]=function(){r.redirect(a())},r}return s(e,t),e.prototype.start=function(){window.addEventListener&&window.addEventListener("hashchange",this[l],!1),window.attachEvent&&window.attachEvent("onhashchange",this[l])},e.prototype.stop=function(){window.removeEventListener&&window.removeEventListener("hashchange",this[l],!1),window.detachEvent&&window.detachEvent("onhashchange",this[l])},e.prototype.redirect=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{force:!1};t=(0,p.default)(t,this.current);var r=this.current,o=t!==r;o?(this.referrer=r,this.current=t,location.hash=t):r=this.referrer,!o&&!e.force||e.silent||this.fire("redirect",{url:t,referrer:r})},e.prototype.reload=function(){this.redirect(this.current,{force:!0})},e}(c.default);e.default=h},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(){return location.pathname+location.search}e.__esModule=!0;var u=r(2),c=o(u),f=r(0),p=o(f),l=Symbol("popstate_handler_key"),h=function(t){function e(){n(this,e);var r=i(this,t.call(this));return r.current=a(),r.referrer="",r[l]=function(){r.referrer=r.current,r.current=a(),r.fire("redirect",{url:r.current,referrer:r.referrer})},r}return s(e,t),e.prototype.start=function(){window.addEventListener("popstate",this[l])},e.prototype.stop=function(){window.removeEventListener("popstate",this[l])},e.prototype.redirect=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{force:!1};t=(0,p.default)(t,this.current);var r=this.current,o=t!==r;o&&(this.referrer=r,this.current=t,history.pushState({},"",t)),!o&&!e.force||e.silent||this.fire("redirect",{url:t,referrer:r})},e.prototype.reload=function(){this.fire("redirect",{url:this.current,referrer:this.referrer})},e}(c.default);e.default=h,h.isSupport="pushState"in window.history},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Link=e.router=e.Router=e.version=void 0;var i=r(4),s=o(i),a=r(5),u=o(a),c=r(1),f=o(c),p=r(3),l=o(p),h=365611,d=function(){return(++h).toString()},y=(e.version="1.0.2",e.Router=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.mode,i=void 0===o?"hash":o;n(this,t),this.routes=[],this.routeAlives=[],this.listeners=[],this.locatorRedirectHandler=function(t){for(var r=(0,f.default)(t.url),o=0;o<e.routes.length;o++){var n=e.routes[o],i=n.rule.exec(r.path);if(i){for(var s=n.keys||[],a=1;a<i.length;a++)r.query[s[a]||a]=i[a];return r.referrer=t.referrer,void e.doRoute(n,r)}}for(var u=e.routeAlives.length;u--;)e.routeAlives[u].component.dispose(),e.routeAlives.splice(u,1)},this.setMode(i)}return t.prototype.listen=function(t){this.listeners.push(t)},t.prototype.unlisten=function(t){for(var e=this.listeners.length;e--;)this.listeners[e]===t&&this.listeners.splice(e,1)},t.prototype.doRoute=function(t,e){for(var r=0;r<this.listeners.length;r++)this.listeners[r].call(this,e,t.config);for(var o=!1,n=this.routeAlives.length;n--;){var i=this.routeAlives[n];i.id===t.id?(i.component.data.set("route",e),i.component._callHook("route"),o=!0):(i.component.dispose(),this.routeAlives.splice(n,1))}if(!o)if(t.Component){var s=new t.Component;s.data.set("route",e),s._callHook("route");var a=document.querySelector(t.target);a&&s.attach(a),this.routeAlives.push({component:s,id:t.id})}else t.handler.call(this,e)},t.prototype.add=function(t){var e=t.rule,r=t.handler,o=t.target,n=void 0===o?"#main":o,i=t.Component,s=[""];if("string"==typeof e){var a=e.replace(/\/:([a-z0-9_-]+)(?=\/|$)/g,function(t,e){return s.push(e),"/([a-z0-9_-]+)"});e=new RegExp("^"+a+"$","i")}if(!(e instanceof RegExp))throw new Error("Rule must be string or RegExp!");var u=d();return this.routes.push({id:u,rule:e,handler:r,keys:s,target:n,Component:i,config:t}),this},t.prototype.start=function(){return this.isStarted||(this.isStarted=!0,this.locator.on("redirect",this.locatorRedirectHandler),this.locator.start(),this.locator.reload()),this},t.prototype.stop=function(){return this.locator.un("redirect",this.locatorRedirectHandler),this.locator.stop(),this.isStarted=!1,this},t.prototype.setMode=function(t){if(t=t.toLowerCase(),this.mode!==t){this.mode=t;var e=!1;switch(this.isStarted&&(this.stop(),e=!0),t){case"hash":this.locator=new s.default;break;case"html5":this.locator=new u.default}return e&&this.start(),this}},t}());e.router=new y;e.Link=l.default},function(t,e,r){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(t){return"[object Object]"===Object.prototype.toString.call(t)},s=new Set(["type","target","preventDefault","isDefaultPrevented","stopPropagation","isPropagationStopped","stopImmediatePropagation","isImmediatePropagationStopped"]),a=function(){function t(e,r){o(this,t),"object"===("undefined"==typeof e?"undefined":n(e))&&(r=e,e=r.type),i(r)?Object.assign(this,r):r&&(this.data=r),e&&(this.type=e)}return t.prototype.isDefaultPrevented=function(){return!1},t.prototype.preventDefault=function(){this.isDefaultPrevented=function(){return!0}},t.prototype.isPropagationStopped=function(){return!1},t.prototype.stopPropagation=function(){this.isPropagationStopped=function(){return!0}},t.prototype.isImmediatePropagationStopped=function(){return!1},t.prototype.stopImmediatePropagation=function(){this.isImmediatePropagationStopped=function(){return!0},this.stopPropagation()},t.fromEvent=function(e,r){var o={type:e.type,preserveData:!1,syncState:!1};r=Object.assign(o,r);var n=new t(r.type);if(r.preserveData)for(var i in e)e.hasOwnProperty(i)&&!s.has(i)&&(n[i]=e[i]);return r.extend&&Object.assign(n,r.extend),r.syncState&&!function(){var t=n.preventDefault;n.preventDefault=function(){e.preventDefault(),t.call(this)};var r=e.stopPropagation;n.stopPropagation=function(){e.stopPropagation(),r.call(this)};var o=e.stopImmediatePropagation;n.stopImmediatePropagation=function(){e.stopImmediatePropagation(),o.call(this)}}(),n},t.delegate=function(e,r,o,n,i){var s="string"==typeof r,a={object:e,type:s?r:o},u={object:s?o:r,type:s?n:o},c=s?i:n;if(c=Object.assign({preserveData:!1},c),"function"==typeof a.object.on&&"function"==typeof u.object.on&&"function"==typeof u.object.fire){var f=function(e){var r=t.fromEvent(e,c);r.type=u.type,r.target=u.object,u.object.fire(u.type,r)};a.object.on(a.type,f)}},t}();e.default=a},function(t,e,r){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var n=Symbol("queue"),i=function(t,e,r){return t&&t.handler===e&&t.thisObject==r},s=function(){function t(){o(this,t),this[n]=[]}return t.prototype.add=function(t,e){if(t!==!1&&"function"!=typeof t)throw new Error("event handler must be a function or const false");for(var r=Object.assign({handler:t},e),o=0;o<this[n].length;o++){var s=this[n][o];if(i(s,t,r.thisObject))return}this[n].push(r)},t.prototype.remove=function(t,e){if(!t)return void this.clear();for(var r=0;r<this[n].length;r++){var o=this[n][r];if(i(o,t,e))return void(this[n][r]=null)}},t.prototype.clear=function(){this[n].length=0},t.prototype.execute=function(t,e){for(var r=this[n],o=0;o<r.length;o++){if("function"==typeof t.isImmediatePropagationStopped&&t.isImmediatePropagationStopped())return;var i=r[o];if(i){var s=i.handler;s===!1?("function"==typeof t.preventDefault&&t.preventDefault(),"function"==typeof t.stopPropagation&&t.stopPropagation()):s.call(i.thisObject||e,t),i.once&&this.remove(i.handler,i.thisObject)}}},t.prototype.length=function(){return this[n].filter(function(t){return!!t}).length},t.prototype.dispose=function(){this.clear(),this[n]=null},t}();e.default=s}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("san-router",[],e):"object"==typeof exports?exports["san-router"]=e():t["san-router"]=e()}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,o){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist",e(e.s=6)}([function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){var r=(0,s.default)(t),o=(0,s.default)(e),n=r.path;if(0===n.indexOf("/"))return t;var i=n.split("/"),a=o.path.split("/");a.pop();for(var u=0;u<i.length;u++){var c=i[u];switch(c){case"..":a.pop();break;case".":break;default:a.push(c)}}return""!==a[0]&&a.unshift(""),a.join("/")+(r.queryString?"?"+r.queryString:"")}e.__esModule=!0,e.default=n;var i=r(1),s=o(i)},function(t,e,r){"use strict";function o(t){var e={};e.hash="";var r=t.indexOf("#");r>=0&&(e.hash=t.slice(r+1),t=t.slice(0,r)),e.queryString="";var o={};e.query=o;var n=t.indexOf("?");return n>=0&&(e.queryString=t.slice(n+1),t=t.slice(0,n),e.queryString.split("&").forEach(function(t){var e=t.indexOf("="),r="";e>0&&(r=t.slice(e+1),t=t.slice(0,e));var n=decodeURIComponent(t);r=decodeURIComponent(r),o.hasOwnProperty(n)?o[n]=[].concat(o[n],r):o[n]=r})),e.path=t,e}e.__esModule=!0,e.default=o},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=r(7),a=o(s),u=r(8),c=o(u),f=Symbol("eventPool"),p=function(){function t(){n(this,t)}return t.prototype.on=function(t,e,r,o){this[f]||(this[f]=Object.create(null)),this[f][t]||(this[f][t]=new c.default);var n=this[f][t];o=Object.assign({},o),r&&(o.thisObject=r),n.add(e,o)},t.prototype.once=function(t,e,r,o){o=Object.assign({},o),o.once=!0,this.on(t,e,r,o)},t.prototype.un=function(t,e,r){if(this[f]&&this[f][t]){var o=this[f][t];o.remove(e,r)}},t.prototype.fire=function(t,e){if(1===arguments.length&&"object"===("undefined"==typeof t?"undefined":i(t))&&(e=t,t=e.type),!t)throw new Error("No event type specified");if("*"===t)throw new Error("Cannot fire global event");var r=e instanceof a.default?e:new a.default(t,e);if(r.target=this,this[f]&&this[f][t]){var o=this[f][t];o.execute(r,this)}if(this[f]&&this[f]["*"]){var n=this[f]["*"];n.execute(r,this)}return r},t.prototype.destroyEvents=function(){if(this[f]){for(var t in this[f])this[f][t]&&this[f][t].dispose();this[f]=null}},t}();e.default=p},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0;var n=r(6),i=r(0),s=o(i);e.default={template:'<a href="{{href}}" onclick="return false;" on-click="clicker($event)" target="{{target}}" class="{{class}}" style="{{style}}"><slot></slot></a>',clicker:function(t){var e=this.data.get("href");"string"==typeof e&&n.router.locator.redirect(e.replace(/^#/,"")),t.preventDefault?t.preventDefault():t.returnValue=!1},computed:{href:function t(){var e=this.data.get("to");if("string"==typeof e){var t=(0,s.default)(e,n.router.locator.current);return"hash"===n.router.mode&&(t="#"+t),t}}}}},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(){var t=location.href.indexOf("#"),e=t<0?"/":location.href.slice(t+1);return e}e.__esModule=!0;var u=r(2),c=o(u),f=r(0),p=o(f),l=Symbol("hashchange_handler_key"),h=function(t){function e(){n(this,e);var r=i(this,t.call(this));return r.current=a(),r.referrer="",r[l]=function(){r.redirect(a())},r}return s(e,t),e.prototype.start=function(){window.addEventListener&&window.addEventListener("hashchange",this[l],!1),window.attachEvent&&window.attachEvent("onhashchange",this[l])},e.prototype.stop=function(){window.removeEventListener&&window.removeEventListener("hashchange",this[l],!1),window.detachEvent&&window.detachEvent("onhashchange",this[l])},e.prototype.redirect=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{force:!1};t=(0,p.default)(t,this.current);var r=this.current,o=t!==r;o?(this.referrer=r,this.current=t,location.hash=t):r=this.referrer,!o&&!e.force||e.silent||this.fire("redirect",{url:t,referrer:r})},e.prototype.reload=function(){this.redirect(this.current,{force:!0})},e}(c.default);e.default=h},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(){return location.pathname+location.search}e.__esModule=!0;var u=r(2),c=o(u),f=r(0),p=o(f),l=Symbol("popstate_handler_key"),h=function(t){function e(){n(this,e);var r=i(this,t.call(this));return r.current=a(),r.referrer="",r[l]=function(){r.referrer=r.current,r.current=a(),r.fire("redirect",{url:r.current,referrer:r.referrer})},r}return s(e,t),e.prototype.start=function(){window.addEventListener("popstate",this[l])},e.prototype.stop=function(){window.removeEventListener("popstate",this[l])},e.prototype.redirect=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{force:!1};t=(0,p.default)(t,this.current);var r=this.current,o=t!==r;o&&(this.referrer=r,this.current=t,history.pushState({},"",t)),!o&&!e.force||e.silent||this.fire("redirect",{url:t,referrer:r})},e.prototype.reload=function(){this.fire("redirect",{url:this.current,referrer:this.referrer})},e}(c.default);e.default=h,h.isSupport="pushState"in window.history},function(t,e,r){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0,e.Link=e.router=e.Router=e.version=void 0;var i=r(4),s=o(i),a=r(5),u=o(a),c=r(1),f=o(c),p=r(3),l=o(p),h=365611,d=function(){return(++h).toString()},y=(e.version="1.0.3",e.Router=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.mode,i=void 0===o?"hash":o;n(this,t),this.routes=[],this.routeAlives=[],this.listeners=[],this.locatorRedirectHandler=function(t){for(var r=(0,f.default)(t.url),o=0;o<e.routes.length;o++){var n=e.routes[o],i=n.rule.exec(r.path);if(i){for(var s=n.keys||[],a=1;a<i.length;a++)r.query[s[a]||a]=i[a];return r.referrer=t.referrer,void e.doRoute(n,r)}}for(var u=e.routeAlives.length;u--;)e.routeAlives[u].component.dispose(),e.routeAlives.splice(u,1)},this.setMode(i)}return t.prototype.listen=function(t){this.listeners.push(t)},t.prototype.unlisten=function(t){for(var e=this.listeners.length;e--;)this.listeners[e]===t&&this.listeners.splice(e,1)},t.prototype.doRoute=function(t,e){for(var r=0;r<this.listeners.length;r++)this.listeners[r].call(this,e,t.config);for(var o=!1,n=this.routeAlives.length;n--;){var i=this.routeAlives[n];i.id===t.id?(i.component.data.set("route",e),i.component._callHook("route"),o=!0):(i.component.dispose(),this.routeAlives.splice(n,1))}if(!o)if(t.Component){var s=new t.Component;s.data.set("route",e),s._callHook("route");var a=document.querySelector(t.target);a&&s.attach(a),this.routeAlives.push({component:s,id:t.id})}else t.handler.call(this,e)},t.prototype.add=function(t){var e=t.rule,r=t.handler,o=t.target,n=void 0===o?"#main":o,i=t.Component,s=[""];if("string"==typeof e){var a=e.replace(/\/:([a-z0-9_-]+)(?=\/|$)/g,function(t,e){return s.push(e),"/([^/\\s]+)"});e=new RegExp("^"+a+"$","i")}if(!(e instanceof RegExp))throw new Error("Rule must be string or RegExp!");var u=d();return this.routes.push({id:u,rule:e,handler:r,keys:s,target:n,Component:i,config:t}),this},t.prototype.start=function(){return this.isStarted||(this.isStarted=!0,this.locator.on("redirect",this.locatorRedirectHandler),this.locator.start(),this.locator.reload()),this},t.prototype.stop=function(){return this.locator.un("redirect",this.locatorRedirectHandler),this.locator.stop(),this.isStarted=!1,this},t.prototype.setMode=function(t){if(t=t.toLowerCase(),this.mode!==t){this.mode=t;var e=!1;switch(this.isStarted&&(this.stop(),e=!0),t){case"hash":this.locator=new s.default;break;case"html5":this.locator=new u.default}return e&&this.start(),this}},t}());e.router=new y;e.Link=l.default},function(t,e,r){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(t){return"[object Object]"===Object.prototype.toString.call(t)},s=new Set(["type","target","preventDefault","isDefaultPrevented","stopPropagation","isPropagationStopped","stopImmediatePropagation","isImmediatePropagationStopped"]),a=function(){function t(e,r){o(this,t),"object"===("undefined"==typeof e?"undefined":n(e))&&(r=e,e=r.type),i(r)?Object.assign(this,r):r&&(this.data=r),e&&(this.type=e)}return t.prototype.isDefaultPrevented=function(){return!1},t.prototype.preventDefault=function(){this.isDefaultPrevented=function(){return!0}},t.prototype.isPropagationStopped=function(){return!1},t.prototype.stopPropagation=function(){this.isPropagationStopped=function(){return!0}},t.prototype.isImmediatePropagationStopped=function(){return!1},t.prototype.stopImmediatePropagation=function(){this.isImmediatePropagationStopped=function(){return!0},this.stopPropagation()},t.fromEvent=function(e,r){var o={type:e.type,preserveData:!1,syncState:!1};r=Object.assign(o,r);var n=new t(r.type);if(r.preserveData)for(var i in e)e.hasOwnProperty(i)&&!s.has(i)&&(n[i]=e[i]);return r.extend&&Object.assign(n,r.extend),r.syncState&&!function(){var t=n.preventDefault;n.preventDefault=function(){e.preventDefault(),t.call(this)};var r=e.stopPropagation;n.stopPropagation=function(){e.stopPropagation(),r.call(this)};var o=e.stopImmediatePropagation;n.stopImmediatePropagation=function(){e.stopImmediatePropagation(),o.call(this)}}(),n},t.delegate=function(e,r,o,n,i){var s="string"==typeof r,a={object:e,type:s?r:o},u={object:s?o:r,type:s?n:o},c=s?i:n;if(c=Object.assign({preserveData:!1},c),"function"==typeof a.object.on&&"function"==typeof u.object.on&&"function"==typeof u.object.fire){var f=function(e){var r=t.fromEvent(e,c);r.type=u.type,r.target=u.object,u.object.fire(u.type,r)};a.object.on(a.type,f)}},t}();e.default=a},function(t,e,r){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var n=Symbol("queue"),i=function(t,e,r){return t&&t.handler===e&&t.thisObject==r},s=function(){function t(){o(this,t),this[n]=[]}return t.prototype.add=function(t,e){if(t!==!1&&"function"!=typeof t)throw new Error("event handler must be a function or const false");for(var r=Object.assign({handler:t},e),o=0;o<this[n].length;o++){var s=this[n][o];if(i(s,t,r.thisObject))return}this[n].push(r)},t.prototype.remove=function(t,e){if(!t)return void this.clear();for(var r=0;r<this[n].length;r++){var o=this[n][r];if(i(o,t,e))return void(this[n][r]=null)}},t.prototype.clear=function(){this[n].length=0},t.prototype.execute=function(t,e){for(var r=this[n],o=0;o<r.length;o++){if("function"==typeof t.isImmediatePropagationStopped&&t.isImmediatePropagationStopped())return;var i=r[o];if(i){var s=i.handler;s===!1?("function"==typeof t.preventDefault&&t.preventDefault(),"function"==typeof t.stopPropagation&&t.stopPropagation()):s.call(i.thisObject||e,t),i.once&&this.remove(i.handler,i.thisObject)}}},t.prototype.length=function(){return this[n].filter(function(t){return!!t}).length},t.prototype.dispose=function(){this.clear(),this[n]=null},t}();e.default=s}])}); |
@@ -821,3 +821,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
*/ | ||
var version = exports.version = '1.0.2'; | ||
var version = exports.version = '1.0.3'; | ||
@@ -984,3 +984,3 @@ /** | ||
keys.push(key); | ||
return '/([a-z0-9_-]+)'; | ||
return '/([^/\\s]+)'; | ||
}); | ||
@@ -987,0 +987,0 @@ |
{ | ||
"name": "san-router", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Router for San", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -22,3 +22,3 @@ /** | ||
*/ | ||
export let version = '1.0.2'; | ||
export let version = '1.0.3'; | ||
@@ -167,3 +167,3 @@ /** | ||
keys.push(key); | ||
return '/([a-z0-9_-]+)'; | ||
return '/([^/\\s]+)'; | ||
} | ||
@@ -170,0 +170,0 @@ ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86948