maishu-router
Advanced tools
Comparing version 1.3.8 to 1.4.0
/*! | ||
* | ||
* maishu-router v1.3.2 | ||
* maishu-router v1.3.8 | ||
* | ||
*/ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"==typeof window?global:window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errors=void 0;const n=r(2);class i extends n.Errors{invalidRouteSegment(e){let t=new Error(`Route segment ${e} is invalid.`);return t.name=i.prototype.invalidRouteSegment.name,t}routeItemExists(e){let t=new Error(`Route '${e}' is exists.`);return t.name=i.prototype.routeItemExists.name,t}invalidPath(e){let t=new Error(`Path '${e}' is invalid path.`);return t.name=i.prototype.invalidPath.name,t}}t.errors=new i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Router=void 0;const n=r(2),i=r(0),s=r(6),u=r(7);t.Router=class{constructor(e,t){if(!e)throw i.errors.argumentNull("pattern");this.rules=t||{},this._pattern=e}match(e){let t=new s.PathSegment(e),r=this.createRouterItems(this._pattern);for(;;){let e=r.current.isWildcards?r.current.regexp.test(t.else):r.current.regexp.test(t.current);if(e){if(r.current.isWildcards){r.current.value=n.pathConcat(t.current,t.else);break}r.current.value=t.current}else{if(!e&&!r.current.isOption)return null;if(!e&&r.current.isOption){r.moveNext();continue}}if(!r.moveNext())break;if(!t.moveNext())break}let i={};for(let e=0;e<r.all.length;e++){let t=r.all[e].name,n=r.all[e].value;null!=t&&(i[t]=n)}return r.current.isWildcards||""==t.else?i:null}createRouterItems(e){var t=new u.RouterItems(e);for(let e=0;e<t.all.length;e++){let r=t.all[e].name;null!=r&&null!=this.rules[r]&&(t.all[e].regexp=this.rules[r])}return t}get pattern(){return this._pattern}}},function(e,t,r){(function(t){ | ||
/*! | ||
* ~ | ||
* maishu-toolkit v1.6.5 | ||
* https://github.com/ansiboy/toolkit | ||
* | ||
* Copyright (c) 2016-2018, shu mai <ansiboy@163.com> | ||
* Licensed under the MIT License. | ||
* | ||
*/ | ||
var r;"undefined"==typeof window||window,r=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s="./out/index.js")}({"./out/assign-deep.js": | ||
/*!****************************!*\ | ||
!*** ./out/assign-deep.js ***! | ||
\****************************/ | ||
/*! exports provided: objectAssignDeep, objectAssignDeepInto, withOptions */function(e,t,r){"use strict";function n(e){return null===e?"null":void 0===e?"undefined":"object"==typeof e?Array.isArray(e)?"array":"object":typeof e}function i(e){return"object"===n(e)?u(e):"array"===n(e)?s(e):e}function s(e){return e.map(i)}function u(e){const t={};for(const r in e)e.hasOwnProperty(r)&&(t[r]=i(e[r]));return t}function o(e,t=[],r={}){const i={arrayBehaviour:r.arrayBehaviour||"replace"},a=t.map(e=>e||{}),l=e||{};for(let e=0;e<a.length;e++){const t=a[e],r=Object.keys(t);for(let e=0;e<r.length;e++){const a=r[e],c=t[a],d=n(c),f=n(l[a]);if("object"===d)if("undefined"!==f){const e="object"===f?l[a]:{};l[a]=o({},[e,u(c)],i)}else l[a]=u(c);else if("array"===d)if("array"===f){const e=s(c);l[a]="merge"===i.arrayBehaviour?l[a].concat(e):e}else l[a]=s(c);else l[a]=c}}return l}function a(e,...t){return o(e,t)}function l(...e){return o({},e)}r.r(t),r.d(t,"objectAssignDeep",(function(){return a})),r.d(t,"objectAssignDeepInto",(function(){return l})),r.d(t,"withOptions",(function(){return c}));let c=function(e,t,r){return o(e,t,r)}},"./out/callback.js": | ||
/*!*************************!*\ | ||
!*** ./out/callback.js ***! | ||
\*************************/ | ||
/*! exports provided: Callback */function(e,t,r){"use strict";r.r(t),r.d(t,"Callback",(function(){return n}));class n{constructor(){this.funcs=new Array}add(e){this.funcs.push(e)}remove(e){this.funcs=this.funcs.filter(t=>t!=e)}fire(e){this.funcs.forEach(t=>t(e))}static create(){return new n}}},"./out/data.js": | ||
/*!*********************!*\ | ||
!*** ./out/data.js ***! | ||
\*********************/ | ||
/*! exports provided: DataSource, DataSourceSelectArguments */function(e,t,r){"use strict";r.r(t),r.d(t,"DataSource",(function(){return u})),r.d(t,"DataSourceSelectArguments",(function(){return o}));var n=r(/*! ./errors */"./out/errors.js"),i=r(/*! ./callback */"./out/callback.js");let s=Object.assign(n.errors,{dataSourceCanntInsert:()=>new Error("DataSource can not insert."),dataSourceCanntDelete:()=>new Error("DataSource can not delete."),dataSourceCanntUpdate:()=>new Error("DataSource can not update."),primaryKeyNull:e=>new Error(`Primary key named '${e}' value is null.`),queryResultTypeError:()=>new Error("Query result type error.")});class u{constructor(e){this.inserting=new i.Callback,this.inserted=new i.Callback,this.deleting=new i.Callback,this.deleted=new i.Callback,this.updating=new i.Callback,this.updated=new i.Callback,this.selecting=new i.Callback,this.selected=new i.Callback,this.error=new i.Callback,this.args=e,this.primaryKeys=e.primaryKeys||[]}get canDelete(){return null!=this.args.delete&&this.primaryKeys.length>0}get canInsert(){return null!=this.args.insert&&this.primaryKeys.length>0}get canUpdate(){return null!=this.args.update&&this.primaryKeys.length>0}executeInsert(e,t){return this.args.insert(e,t)}executeDelete(e,t){return this.args.delete(e,t)}executeUpdate(e,t){return this.args.update(e,t)}executeSelect(e){return e=e||{},this.args.select(e)}insert(e,t,r){if(!this.canInsert)throw s.dataSourceCanntInsert();if(!e)throw s.argumentNull("item");return"number"==typeof t&&(r=t,t=null),this.inserting.fire({sender:this,dataItem:e,index:r}),this.executeInsert(e,t).then(t=>(Object.assign(e,t),this.inserted.fire({sender:this,dataItem:e,index:r}),t)).catch(e=>{throw this.processError(e,"insert"),e})}delete(e,t){if(!this.canDelete)throw s.dataSourceCanntDelete();if(!e)throw s.argumentNull("item");return this.checkPrimaryKeys(e),this.deleting.fire({sender:this,dataItem:e}),this.executeDelete(e,t).then(t=>(this.deleted.fire({sender:this,dataItem:e}),t)).catch(e=>{throw this.processError(e,"delete"),e})}update(e,t){if(!this.canUpdate)throw s.dataSourceCanntUpdate();if(!e)throw s.argumentNull("item");return this.checkPrimaryKeys(e),this.updating.fire({sender:this,dataItem:e}),this.executeUpdate(e,t).then(t=>(Object.assign(e,t),this.updated.fire({sender:this,dataItem:e}),t)).catch(e=>{throw this.processError(e,"update"),e})}isSameItem(e,t){if(null==e)throw s.argumentNull("theItem");if(null==t)throw s.argumentNull("otherItem");if(0==this.primaryKeys.length)return e==t;this.checkPrimaryKeys(e),this.checkPrimaryKeys(t);for(let r of this.primaryKeys)if(e[r]!=t[r])return!1;return!0}checkPrimaryKeys(e){for(let t in e)if(null==e[t]&&this.primaryKeys.indexOf(t)>=0)throw s.primaryKeyNull(t)}select(e){return e=e||{},this.selecting.fire({sender:this,selectArguments:e}),this.executeSelect(e).then(t=>{let r,n;if(Array.isArray(t))r=t,n=t.length;else{if(void 0===t.dataItems||void 0===t.totalRowCount)throw s.queryResultTypeError();r=t.dataItems,n=t.totalRowCount}return this.selected.fire({sender:this,selectResult:{totalRowCount:n,dataItems:r},selectArguments:e}),{totalRowCount:n,dataItems:r}}).catch(e=>{throw this.processError(e,"select"),e})}processError(e,t){if(e.method=t,this.error.fire({sender:this,error:e}),!e.handled)throw e}}class o{constructor(){this.startRowIndex=0,this.maximumRows=2147483647}}},"./out/deep-equal.js": | ||
/*!***************************!*\ | ||
!*** ./out/deep-equal.js ***! | ||
\***************************/ | ||
/*! exports provided: deepEqual */function(e,t,r){"use strict";function n(e,t){if(e===t)return!0;if("object"==typeof e&&null!=e&&"object"==typeof t&&null!=t){if(Object.keys(e).length!=Object.keys(t).length)return!1;for(var r in e){if(!t.hasOwnProperty(r))return!1;if(!n(e[r],t[r]))return!1}return!0}return!1}r.r(t),r.d(t,"deepEqual",(function(){return n}))},"./out/errors.js": | ||
/*!***********************!*\ | ||
!*** ./out/errors.js ***! | ||
\***********************/ | ||
/*! exports provided: Errors, errors */function(e,t,r){"use strict";r.r(t),r.d(t,"Errors",(function(){return n})),r.d(t,"errors",(function(){return i}));class n{argumentNull(e){let t=new Error(`Argument ${e} cannt be null or emtpy.`);return t.name="argumentNull",t}routeDataFieldNull(e){let t=new Error(`The ${e} field of route data cannt be null.`);return t.name="routeDataFieldNull",t}argumentFieldNull(e,t){let r=new Error(`The ${e} field of ${t} cannt be null.`);return r.name="argumentFieldNull",r}argumentTypeIncorrect(e,t){let r=new Error(`Argument ${e} type error, expected type is ${t}.`);return r.name="argumentTypeIncorrect",r}}let i=new n},"./out/format.js": | ||
/*!***********************!*\ | ||
!*** ./out/format.js ***! | ||
\***********************/ | ||
/*! exports provided: formatDate, formatString */function(e,t,r){"use strict";function n(e,t){if("string"==typeof e)return e;let r=e;return t?`${r.getFullYear()}-${r.getMonth()}-${r.getDate()} ${r.getHours()+1}:${r.getMinutes()}`:`${r.getFullYear()}-${r.getMonth()}-${r.getDate()}`}function i(e,...t){let r=e;for(let e in t)r=r.replace("{"+e+"}",t[e]);return r}r.r(t),r.d(t,"formatDate",(function(){return n})),r.d(t,"formatString",(function(){return i}))},"./out/guid.js": | ||
/*!*********************!*\ | ||
!*** ./out/guid.js ***! | ||
\*********************/ | ||
/*! exports provided: guid */function(e,t,r){"use strict";function n(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}r.r(t),r.d(t,"guid",(function(){return n}))},"./out/html.js": | ||
/*!*********************!*\ | ||
!*** ./out/html.js ***! | ||
\*********************/ | ||
/*! exports provided: HTML */function(e,t,r){"use strict";r.r(t),r.d(t,"HTML",(function(){return i}));var n=r(/*! ./errors */"./out/errors.js");class i{static addClassName(e,t){if(null==e)throw n.errors.argumentNull("element");if(!t)throw n.errors.argumentNull("addonClassName");let r;if(r="string"==typeof e?e:e.className,r=r||"",console.assert(null!=t),r.indexOf(t)>=0)return r;let i=`${r} ${t}`;return"string"!=typeof e&&(e.className=i),i}static removeClassName(e,t){let r;return r="string"==typeof e?e:e.className||"",r.indexOf(t)<0||(r=r||"",r=r.replace(new RegExp(t,"g"),""),r=r.trim(),"string"!=typeof e&&(e.className=r)),r}}},"./out/index.js": | ||
/*!**********************!*\ | ||
!*** ./out/index.js ***! | ||
\**********************/ | ||
/*! exports provided: guid, pathConcat, Errors, errors, Callback, DataSource, DataSourceSelectArguments, parseUrl, deepEqual, objectAssignDeep, formatDate, formatString, HTML, ValueStore */function(e,t,r){"use strict";r.r(t);var n=r(/*! ./guid */"./out/guid.js");r.d(t,"guid",(function(){return n.guid}));var i=r(/*! ./path */"./out/path.js");r.d(t,"pathConcat",(function(){return i.pathConcat}));var s=r(/*! ./errors */"./out/errors.js");r.d(t,"Errors",(function(){return s.Errors})),r.d(t,"errors",(function(){return s.errors}));var u=r(/*! ./callback */"./out/callback.js");r.d(t,"Callback",(function(){return u.Callback}));var o=r(/*! ./data */"./out/data.js");r.d(t,"DataSource",(function(){return o.DataSource})),r.d(t,"DataSourceSelectArguments",(function(){return o.DataSourceSelectArguments}));var a=r(/*! ./url */"./out/url.js");r.d(t,"parseUrl",(function(){return a.parseUrl}));var l=r(/*! ./deep-equal */"./out/deep-equal.js");r.d(t,"deepEqual",(function(){return l.deepEqual}));var c=r(/*! ./assign-deep */"./out/assign-deep.js");r.d(t,"objectAssignDeep",(function(){return c.objectAssignDeep}));var d=r(/*! ./format */"./out/format.js");r.d(t,"formatDate",(function(){return d.formatDate})),r.d(t,"formatString",(function(){return d.formatString}));var f=r(/*! ./html */"./out/html.js");r.d(t,"HTML",(function(){return f.HTML}));var h=r(/*! ./value-store */"./out/value-store.js");r.d(t,"ValueStore",(function(){return h.ValueStore}))},"./out/path.js": | ||
/*!*********************!*\ | ||
!*** ./out/path.js ***! | ||
\*********************/ | ||
/*! exports provided: pathConcat */function(e,t,r){"use strict";function n(...e){if(0==(e=e||[]).length)return"";if(1==e.length)return e[0];let t=e.join("/");return t=t.replace(/(\/+|\\+)/g,"/"),t=t.replace("http:/","http://"),t=t.replace("https:/","https://"),t}r.r(t),r.d(t,"pathConcat",(function(){return n}))},"./out/url.js": | ||
/*!********************!*\ | ||
!*** ./out/url.js ***! | ||
\********************/ | ||
/*! exports provided: parseUrl */function(e,t,r){"use strict";function n(e){let t=e.indexOf("?");return t<0?{}:function(e){let t,r=/\+/g,n=/([^&=]+)=?([^&]*)/g,i=function(e){return decodeURIComponent(e.replace(r," "))},s={};for(;t=n.exec(e);)s[i(t[1])]=i(t[2]);return s}(e.substr(t+1))}r.r(t),r.d(t,"parseUrl",(function(){return n}))},"./out/value-store.js": | ||
/*!****************************!*\ | ||
!*** ./out/value-store.js ***! | ||
\****************************/ | ||
/*! exports provided: ValueStore */function(e,t,r){"use strict";r.r(t),r.d(t,"ValueStore",(function(){return n}));class n{constructor(e){this.items=new Array,this._value=e}attach(e,t){return void 0!==this.value&&e(this.value,t),this.add(e,t)}add(e,t){return this.items.push({func:e,sender:t}),e}remove(e){this.items=this.items.filter(t=>t.func!=e)}fire(e){this.items.forEach(t=>t.func(e,t.sender))}get value(){return void 0===this._value?null:this._value}set value(e){this._value=e,this.fire(e)}}}})},e.exports=r()}).call(this,r(5))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RouterItem=void 0;const n=r(0);t.RouterItem=class{constructor(e){this._isOption=!1,this._isWildcards=!1,this._name=null;let t=/[*|:|?]{0,1}(\S+)/.exec(e);if(!t)throw n.errors.invalidRouteSegment(e);switch(e[0]){case"*":this._isWildcards=!0,this._regexp=/\S+/,this._name=t[1];break;case":":this._regexp=/\S+/,this._name=t[1];break;case"?":this._regexp=/\S+/,this._name=t[1],this._isOption=!0;break;default:this._regexp=new RegExp(e)}}get isOption(){return this._isOption}get isWildcards(){return this._isWildcards}get name(){return this._name}get regexp(){return this._regexp}set regexp(e){this._regexp=e}get value(){return this._value}set value(e){this._value=e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createRouter=t.RouterItem=t.Router=void 0;const n=r(1);var i=r(1);Object.defineProperty(t,"Router",{enumerable:!0,get:function(){return i.Router}});var s=r(3);Object.defineProperty(t,"RouterItem",{enumerable:!0,get:function(){return s.RouterItem}}),t.createRouter=function(e,t){return new n.Router(e,t)}},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PathSegment=void 0;const n=r(0);t.PathSegment=class{constructor(e){if(this._index=0,this.segments=e.split("/").filter(e=>e),0==this.segments.length)throw n.errors.invalidPath(e)}reset(){this._index=0}moveNext(){return this._index>=this.segments.length-1?null:(this._index=this._index+1,this._index)}get current(){return this.segments[this._index]}get index(){return this._index}get else(){return(this.index>=this.segments.length-1?[]:this.segments.slice(this.index+1)).join("/")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RouterItems=void 0;const n=r(0),i=r(3);t.RouterItems=class{constructor(e){this._items=[],this._index=0;let t=e.split("/").filter(e=>e);for(let e=0;e<t.length;e++){let r=new i.RouterItem(t[e]);if(this._items.filter(e=>e.name==r.name).length>0)throw n.errors.routeItemExists(t[e]);this._items.push(r)}}get all(){return this._items}moveNext(){return this._index>=this._items.length-1?null:(this._index=this._index+1,this._index)}reset(){this._index=0}get index(){return this._index}get current(){return this._items[this._index]}}}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("maishu-toolkit"));else if("function"==typeof define&&define.amd)define(["maishu-toolkit"],t);else{var r="object"==typeof exports?t(require("maishu-toolkit")):t(e["maishu-toolkit"]);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"==typeof window?global:window,(function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errors=void 0;const n=r(2);class i extends n.Errors{invalidRouteSegment(e){let t=new Error(`Route segment ${e} is invalid.`);return t.name=i.prototype.invalidRouteSegment.name,t}routeItemExists(e){let t=new Error(`Route '${e}' is exists.`);return t.name=i.prototype.routeItemExists.name,t}invalidPath(e){let t=new Error(`Path '${e}' is invalid path.`);return t.name=i.prototype.invalidPath.name,t}}t.errors=new i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Router=void 0;const n=r(2),i=r(0),s=r(5),o=r(6);t.Router=class{constructor(e,t){if(!e)throw i.errors.argumentNull("pattern");this.rules=t||{},this._pattern=e}match(e){let t=new s.PathSegment(e),r=this.createRouterItems(this._pattern);for(;;){let e=t.else?n.pathConcat(t.current,t.else):t.current,i=r.current.isWildcards?r.current.regexp.test(e):r.current.regexp.test(t.current);if(i){if(r.current.isWildcards){r.current.value=e;break}r.current.value=t.current}else{if(!i&&!r.current.isOption)return null;if(!i&&r.current.isOption){r.moveNext();continue}}if(!r.moveNext())break;if(!t.moveNext())break}let i={};for(let e=0;e<r.all.length;e++){let t=r.all[e].name,n=r.all[e].value;null!=t&&(i[t]=n)}return r.current.isWildcards||""==t.else?i:null}createRouterItems(e){var t=new o.RouterItems(e);for(let e=0;e<t.all.length;e++){let r=t.all[e].name;null!=r&&null!=this.rules[r]&&(t.all[e].regexp=this.rules[r])}return t}get pattern(){return this._pattern}}},function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RouterItem=void 0;const n=r(0);t.RouterItem=class{constructor(e){this._isOption=!1,this._isWildcards=!1,this._name=null;let t=/[*|:|?]{0,1}(\S+)/.exec(e);if(!t)throw n.errors.invalidRouteSegment(e);switch(e[0]){case"*":this._isWildcards=!0,this._regexp=/\S+/,this._name=t[1];break;case":":this._regexp=/\S+/,this._name=t[1];break;case"?":this._regexp=/\S+/,this._name=t[1],this._isOption=!0;break;default:this._regexp=new RegExp(e)}}get isOption(){return this._isOption}get isWildcards(){return this._isWildcards}get name(){return this._name}get regexp(){return this._regexp}set regexp(e){this._regexp=e}get value(){return this._value}set value(e){this._value=e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createRouter=t.RouterItem=t.Router=void 0;const n=r(1);var i=r(1);Object.defineProperty(t,"Router",{enumerable:!0,get:function(){return i.Router}});var s=r(3);Object.defineProperty(t,"RouterItem",{enumerable:!0,get:function(){return s.RouterItem}}),t.createRouter=function(e,t){return new n.Router(e,t)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PathSegment=void 0;const n=r(0);t.PathSegment=class{constructor(e){if(this._index=0,this.segments=e.split("/").filter(e=>e),0==this.segments.length)throw n.errors.invalidPath(e)}reset(){this._index=0}moveNext(){return this._index>=this.segments.length-1?null:(this._index=this._index+1,this._index)}get current(){return this.segments[this._index]}get index(){return this._index}get else(){return(this.index>=this.segments.length-1?[]:this.segments.slice(this.index+1)).join("/")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RouterItems=void 0;const n=r(0),i=r(3);t.RouterItems=class{constructor(e){this._items=[],this._index=0;let t=e.split("/").filter(e=>e);for(let e=0;e<t.length;e++){let r=new i.RouterItem(t[e]);if(this._items.filter(e=>e.name==r.name).length>0)throw n.errors.routeItemExists(t[e]);this._items.push(r)}}get all(){return this._items}moveNext(){return this._index>=this._items.length-1?null:(this._index=this._index+1,this._index)}reset(){this._index=0}get index(){return this._index}get current(){return this._items[this._index]}}}])})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "maishu-router", | ||
"version": "1.3.8", | ||
"version": "1.4.0", | ||
"author": "shu mai", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
35314
361
2