-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathfrontexpress.min.js.map
1 lines (1 loc) · 35.8 KB
/
frontexpress.min.js.map
1
{"version":3,"file":"frontexpress.min.js","sources":["lib/router.js","lib/settings.js","lib/application.js","lib/methods.js","lib/middleware.js","lib/requester.js","lib/frontexpress.js"],"sourcesContent":["/**\n * Module dependencies.\n * @private\n */\n\nimport HTTP_METHODS from './methods';\nimport {toParameters} from './application';\nimport Middleware from './middleware';\n\n\n/**\n * Route object.\n * @private\n */\n\nexport class Route {\n\n\n /**\n * Initialize the route.\n *\n * @private\n */\n\n constructor(router, uriPart, method, middleware) {\n this.router = router;\n this.uriPart = uriPart;\n this.method = method;\n this.middleware = middleware;\n this.visited = false;\n }\n\n\n /**\n * Return route's uri.\n *\n * @private\n */\n\n get uri() {\n if (!this.uriPart && !this.method) {\n return undefined;\n }\n\n if (this.uriPart instanceof RegExp) {\n return this.uriPart;\n }\n\n if (this.router.baseUri instanceof RegExp) {\n return this.router.baseUri;\n }\n\n if (this.router.baseUri) {\n const baseUri = this.router.baseUri.trim();\n if (this.uriPart) {\n return ( baseUri + this.uriPart.trim()).replace(/\\/{2,}/, '/');\n }\n return baseUri;\n }\n\n return this.uriPart;\n }\n}\n\n\n/**\n * Router object.\n * @public\n */\n\nconst error_middleware_message = 'method takes at least a middleware';\nexport default class Router {\n\n\n /**\n * Initialize the router.\n *\n * @private\n */\n\n constructor(uri) {\n this._baseUri = uri;\n this._routes = [];\n }\n\n\n /**\n * Do some checks and set _baseUri.\n *\n * @private\n */\n\n set baseUri(uri) {\n if (!uri) {\n return;\n }\n\n if (!this._baseUri) {\n this._baseUri = uri;\n return;\n }\n\n if (typeof this._baseUri !== typeof uri) {\n throw new TypeError('router cannot mix regexp and uri');\n }\n }\n\n\n /**\n * Return router's _baseUri.\n *\n * @private\n */\n\n get baseUri() {\n return this._baseUri;\n }\n\n\n /**\n * Add a route to the router.\n *\n * @private\n */\n\n _add(route) {\n this._routes.push(route);\n return this;\n }\n\n\n /**\n * Gather routes from routers filtered by _uri_ and HTTP _method_.\n *\n * @private\n */\n\n routes(application, request) {\n request.params = request.params || {};\n const isRouteMatch = application.get('route matcher');\n return this._routes.filter((route) => {\n return isRouteMatch(request, route);\n });\n }\n\n\n /**\n * Gather visited routes from routers.\n *\n * @private\n */\n\n visited() {\n return this._routes.filter(route => route.visited);\n }\n\n\n /**\n * Use the given middleware function or object on this router.\n *\n * // middleware function\n * router.use((req, res, next) => {console.log('Hello')});\n *\n * // middleware object\n * router.use(new Middleware());\n *\n * @param {Middleware|Function} middleware object or function\n * @return {Router} for chaining\n *\n * @public\n */\n\n use(middleware) {\n if (!(middleware instanceof Middleware) && (typeof middleware !== 'function') ) {\n throw new TypeError(error_middleware_message);\n }\n\n this._add(new Route(this, undefined, undefined, middleware));\n\n return this;\n }\n\n\n /**\n * Use the given middleware function or object on this router for\n * all HTTP methods.\n *\n * // middleware function\n * router.all((req, res, next) => {console.log('Hello')});\n *\n * // middleware object\n * router.all(new Middleware());\n *\n * @param {Middleware|Function} middleware object or function\n * @return {Router} for chaining\n *\n * @public\n */\n\n all(...args) {\n const {middleware} = toParameters(args);\n if (!middleware) {\n throw new TypeError(error_middleware_message);\n }\n\n HTTP_METHODS.forEach((method) => {\n this[method.toLowerCase()](...args);\n });\n return this;\n }\n}\n\nHTTP_METHODS.forEach((method) => {\n\n\n /**\n * Use the given middleware function or object, with optional _uri_ on\n * HTTP methods: get, post, put, delete...\n * Default _uri_ is \"/\".\n *\n * // middleware function will be applied on path \"/\"\n * router.get((req, res, next) => {console.log('Hello')});\n *\n * // middleware object will be applied on path \"/\" and\n * router.get(new Middleware());\n *\n * // middleware function will be applied on path \"/user\"\n * router.post('/user', (req, res, next) => {console.log('Hello')});\n *\n * // middleware object will be applied on path \"/user\" and\n * router.post('/user', new Middleware());\n *\n * @param {String} uri\n * @param {Middleware|Function} middleware object or function\n * @return {Router} for chaining\n * @public\n */\n\n const methodName = method.toLowerCase();\n Router.prototype[methodName] = function(...args) {\n const {baseUri, middleware} = toParameters(args);\n if (!middleware) {\n throw new TypeError(error_middleware_message);\n }\n\n if (baseUri && this._baseUri && this._baseUri instanceof RegExp) {\n throw new TypeError('router cannot mix uri/regexp');\n }\n\n this._add(new Route(this, baseUri, method, middleware));\n\n return this;\n };\n});\n\nexport function routeMatcher(request, route) {\n // check if http method are equals\n if (route.method && route.method !== request.method) {\n return false;\n }\n\n\n // route and uri not defined always match\n if (!route.uri || !request.uri) {\n return true;\n }\n\n //remove query string and anchor from uri to test\n const match = /^(.*)\\?.*#.*|(.*)(?=\\?|#)|(.*[^\\?#])$/.exec(request.uri);\n const baseUriToCheck = match[1] || match[2] || match[3];\n\n // if route is a regexp path\n if (route.uri instanceof RegExp) {\n return baseUriToCheck.match(route.uri) !== null;\n }\n\n // if route is parameterized path\n if (route.uri.indexOf(':') !== -1) {\n\n const decodeParmeterValue = (v) => {\n return !isNaN(parseFloat(v)) && isFinite(v) ? (Number.isInteger(v) ? Number.parseInt(v, 10) : Number.parseFloat(v)) : v;\n };\n\n // figure out key names\n const keys = [];\n const keysRE = /:([^\\/\\?]+)\\??/g;\n let keysMatch = keysRE.exec(route.uri);\n while (keysMatch != null) {\n keys.push(keysMatch[1]);\n keysMatch = keysRE.exec(route.uri);\n }\n\n // change parameterized path to regexp\n const regExpUri = route.uri\n // :parameter?\n .replace(/\\/:[^\\/]+\\?/g, '(?:\\/([^\\/]+))?')\n // :parameter\n .replace(/:[^\\/]+/g, '([^\\/]+)')\n // escape all /\n .replace('/', '\\\\/');\n\n // checks if uri match\n const routeMatch = baseUriToCheck.match(new RegExp(`^${regExpUri}$`));\n if (!routeMatch) {\n return false;\n }\n\n // update params in request with keys\n request.params = Object.assign(request.params, keys.reduce((acc, key, index) => {\n let value = routeMatch[index + 1];\n if (value) {\n value = value.indexOf(',') !== -1 ? value.split(',').map(v => decodeParmeterValue(v)) : value = decodeParmeterValue(value);\n }\n acc[key] = value;\n return acc;\n }, {}));\n return true;\n }\n\n // if route is a simple path\n return route.uri === baseUriToCheck;\n}\n","/**\n * Module dependencies.\n * @private\n */\nimport {routeMatcher} from './router';\nimport Requester, {httpGetTransformer, httpPostPatchTransformer} from './requester';\n\n\nfunction errorIfNotFunction(toTest, message) {\n if(typeof toTest !== 'function') {\n throw new TypeError(message);\n }\n}\n\nfunction errorIfNotHttpTransformer(toTest) {\n if (!toTest || (!toTest.uri && !toTest.headers && !toTest.data)) {\n throw new TypeError('setting http transformer one of functions: uri, headers, data is missing');\n }\n}\n\n/**\n * Settings object.\n * @private\n */\n\nexport default class Settings {\n\n\n /**\n * Initialize the settings.\n *\n * - setup default configuration\n *\n * @private\n */\n\n constructor() {\n // default settings\n this.settings = {\n 'http requester': new Requester(),\n 'http GET transformer': httpGetTransformer,\n 'http POST transformer': httpPostPatchTransformer,\n 'http PATCH transformer': httpPostPatchTransformer,\n 'route matcher': routeMatcher\n };\n\n this.rules = {\n 'http requester': (requester) => {\n errorIfNotFunction(requester.fetch , 'setting http requester has no fetch function');\n },\n 'http GET transformer': (transformer) => {\n errorIfNotHttpTransformer(transformer);\n },\n 'http POST transformer': (transformer) => {\n errorIfNotHttpTransformer(transformer);\n },\n 'http PATCH transformer': (transformer) => {\n errorIfNotHttpTransformer(transformer);\n },\n 'route matcher': (routeMatcher) => {\n errorIfNotFunction(routeMatcher, 'setting route matcher is not a function');\n }\n };\n }\n\n\n /**\n * Assign `setting` to `val`\n *\n * @param {String} setting\n * @param {*} [val]\n * @private\n */\n\n set(name, value) {\n const checkRules = this.rules[name];\n if (checkRules) {\n checkRules(value);\n }\n this.settings[name] = value;\n }\n\n\n /**\n * Return `setting`'s value.\n *\n * @param {String} setting\n * @private\n */\n\n get(name) {\n return this.settings[name];\n }\n};\n","/**\n * Module dependencies.\n * @private\n */\n\nimport HTTP_METHODS from './methods';\nimport Settings from './settings';\nimport Router, {Route} from './router';\nimport Middleware from './middleware';\n\nconst DEFAULT = {callback: ()=>{}};\n\n/**\n * Application class.\n */\n\nexport default class Application {\n\n\n /**\n * Initialize the application.\n *\n * - setup default configuration\n *\n * @private\n */\n\n constructor() {\n this.routers = [];\n this.settings = new Settings();\n this.plugins = [];\n }\n\n\n /**\n * Assign `setting` to `val`, or return `setting`'s value.\n *\n * app.set('foo', 'bar');\n * app.set('foo');\n * // => \"bar\"\n *\n * @param {String} setting\n * @param {*} [val]\n * @return {app} for chaining\n * @public\n */\n\n set(...args) {\n // get behaviour\n if (args.length === 1) {\n return this.settings.get([args]);\n }\n\n // set behaviour\n this.settings.set(...args);\n\n return this;\n }\n\n\n /**\n * Listen for DOM initialization and history state changes.\n *\n * The callback function is called once the DOM has\n * the `document.readyState` equals to 'interactive'.\n *\n * app.listen(()=> {\n * console.log('App is listening requests');\n * console.log('DOM is ready!');\n * });\n *\n *\n * @param {Function} callback\n * @public\n */\n\n listen(callback=DEFAULT.callback) {\n const request = {method: 'GET', uri: window.location.pathname + window.location.search};\n const response = {status: 200, statusText: 'OK'};\n const currentRoutes = this._routes(request);\n\n this._callMiddlewareMethod('entered', currentRoutes, request);\n\n // manage history\n window.onpopstate = (event) => {\n if (event.state) {\n const {request, response} = event.state;\n [\n 'exited',\n 'entered',\n 'updated'\n ].forEach(middlewareMethod => this._callMiddlewareMethod(middlewareMethod, this._routes(request), request, response));\n }\n };\n\n // manage page loading/refreshing\n window.onbeforeunload = () => {\n this._callMiddlewareMethod('exited');\n };\n\n const whenPageIsInteractiveFn = () => {\n this.plugins.forEach(pluginObject => pluginObject.plugin(this));\n this._callMiddlewareMethod('updated', currentRoutes, request, response);\n callback(request, response);\n };\n\n document.onreadystatechange = () => {\n // DOM ready state\n if (document.readyState === 'interactive') {\n whenPageIsInteractiveFn();\n }\n };\n\n if (['interactive', 'complete'].indexOf(document.readyState) !== -1) {\n whenPageIsInteractiveFn();\n }\n }\n\n\n /**\n * Returns a new `Router` instance for the _uri_.\n * See the Router api docs for details.\n *\n * app.route('/');\n * // => new Router instance\n *\n * @param {String} uri\n * @return {Router} for chaining\n *\n * @public\n */\n\n route(uri) {\n const router = new Router(uri);\n this.routers.push(router);\n return router;\n }\n\n\n /**\n * Use the given middleware function or object, with optional _uri_.\n * Default _uri_ is \"/\".\n * Or use the given plugin\n *\n * // middleware function will be applied on path \"/\"\n * app.use((req, res, next) => {console.log('Hello')});\n *\n * // middleware object will be applied on path \"/\"\n * app.use(new Middleware());\n *\n * // use a plugin\n * app.use({\n * name: 'My plugin name',\n * plugin(application) {\n * // here plugin implementation\n * }\n * });\n *\n * @param {String} uri\n * @param {Middleware|Function|plugin} middleware object, middleware function, plugin\n * @return {app} for chaining\n *\n * @public\n */\n\n use(...args) {\n let {baseUri, router, middleware, plugin} = toParameters(args);\n if (plugin) {\n this.plugins.push(plugin);\n } else {\n if (router) {\n router.baseUri = baseUri;\n } else if (middleware) {\n router = new Router(baseUri);\n HTTP_METHODS.forEach((method) => {\n router[method.toLowerCase()](middleware);\n });\n } else {\n throw new TypeError('method takes at least a middleware or a router');\n }\n this.routers.push(router);\n }\n\n return this;\n }\n\n\n /**\n * Gather routes from all routers filtered by _uri_ and HTTP _method_.\n * See Router#routes() documentation for details.\n *\n * @private\n */\n\n _routes(request) {\n return this.routers.reduce((acc, router) => {\n acc.push(...router.routes(this, request));\n return acc;\n }, []);\n }\n\n\n /**\n * Call `Middleware` method or middleware function on _currentRoutes_.\n *\n * @private\n */\n\n _callMiddlewareMethod(meth, currentRoutes, request, response) {\n if (meth === 'exited') {\n // currentRoutes, request, response params not needed\n this.routers.forEach((router) => {\n router.visited().forEach((route) => {\n if (route.middleware.exited) {\n route.middleware.exited(route.visited);\n route.visited = null;\n }\n });\n });\n return;\n }\n\n currentRoutes.some((route) => {\n if (meth === 'updated') {\n route.visited = request;\n }\n\n if (route.middleware[meth]) {\n route.middleware[meth](request, response);\n if (route.middleware.next && !route.middleware.next()) {\n return true;\n }\n } else if (meth !== 'entered') {\n // calls middleware method\n let breakMiddlewareLoop = true;\n const next = () => {\n breakMiddlewareLoop = false;\n };\n route.middleware(request, response, next);\n if (breakMiddlewareLoop) {\n return true;\n }\n }\n\n return false;\n });\n }\n\n\n /**\n * Make an ajax request. Manage History#pushState if history object set.\n *\n * @private\n */\n\n _fetch(req, resolve=DEFAULT.callback, reject=DEFAULT.callback) {\n let {method, uri, headers, data, history} = req;\n\n const httpMethodTransformer = this.get(`http ${method} transformer`);\n if (httpMethodTransformer) {\n const {uri: _uriFn, headers: _headersFn, data: _dataFn } = httpMethodTransformer;\n Object.keys(httpMethodTransformer).forEach(k => {\n const fn = httpMethodTransformer[k];\n req[k] = fn ? fn({uri, headers, data}) : req[k];\n });\n }\n\n // calls middleware exited method\n this._callMiddlewareMethod('exited');\n\n // gathers all routes impacted by the uri\n const currentRoutes = this._routes(req);\n\n // calls middleware entered method\n this._callMiddlewareMethod('entered', currentRoutes, req);\n\n // invokes http request\n this.settings.get('http requester').fetch(req,\n (request, response) => {\n if (history) {\n window.history.pushState({request, response}, history.title, history.uri);\n }\n this._callMiddlewareMethod('updated', currentRoutes, request, response);\n resolve(request, response);\n },\n (request, response) => {\n this._callMiddlewareMethod('failed', currentRoutes, request, response);\n reject(request, response);\n });\n }\n}\n\nHTTP_METHODS.reduce((reqProto, method) => {\n\n\n /**\n * Use the given middleware function or object, with optional _uri_ on\n * HTTP methods: get, post, put, delete...\n * Default _uri_ is \"/\".\n *\n * // middleware function will be applied on path \"/\"\n * app.get((req, res, next) => {console.log('Hello')});\n *\n * // middleware object will be applied on path \"/\" and\n * app.get(new Middleware());\n *\n * // get a setting value\n * app.set('foo', 'bar');\n * app.get('foo');\n * // => \"bar\"\n *\n * @param {String} uri or setting\n * @param {Middleware|Function} middleware object or function\n * @return {app} for chaining\n * @public\n */\n\n const middlewareMethodName = method.toLowerCase();\n reqProto[middlewareMethodName] = function(...args) {\n let {baseUri, middleware, which} = toParameters(args);\n if (middlewareMethodName === 'get' && typeof which === 'string') {\n return this.settings.get(which);\n }\n if (!middleware) {\n throw new TypeError(`method takes a middleware ${middlewareMethodName === 'get' ? 'or a string' : ''}`);\n }\n const router = new Router();\n router[middlewareMethodName](baseUri, middleware);\n\n this.routers.push(router);\n\n return this;\n };\n\n /**\n * Ajax request (get, post, put, delete...).\n *\n * // HTTP GET method\n * httpGet('/route1');\n *\n * // HTTP GET method\n * httpGet({uri: '/route1', data: {'p1': 'val1'});\n * // uri invoked => /route1?p1=val1\n *\n * // HTTP GET method with browser history management\n * httpGet({uri: '/api/users', history: {state: {foo: \"bar\"}, title: 'users page', uri: '/view/users'});\n *\n * Samples above can be applied on other HTTP methods.\n *\n * @param {String|Object} uri or object containing uri, http headers, data, history\n * @param {Function} success callback\n * @param {Function} failure callback\n * @public\n */\n const httpMethodName = 'http'+method.charAt(0).toUpperCase() + method.slice(1).toLowerCase();\n reqProto[httpMethodName] = function(request, resolve=DEFAULT.callback, reject=DEFAULT.callback) {\n let {uri, headers, data, history} = request;\n if (!uri) {\n uri = request;\n }\n return this._fetch({\n uri,\n method,\n headers,\n data,\n history\n }, resolve, reject);\n };\n\n return reqProto;\n}, Application.prototype);\n\n\nexport function toParameters(args) {\n let baseUri, middleware, router, plugin, which;\n\n args.length === 1 ? [which,] = args : [baseUri, which,] = args;\n\n if (which instanceof Router) {\n router = which;\n } else if (which instanceof Middleware || typeof which === 'function') {\n middleware = which;\n } else if(which && which.plugin && typeof which.plugin === 'function') {\n plugin = which;\n }\n\n return {baseUri, middleware, router, plugin, which};\n}\n","/**\n * HTTP method list\n * @private\n */\n\n export default ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];\n // not supported yet\n // HEAD', 'CONNECT', 'OPTIONS', 'TRACE';\n","/**\n * Middleware object.\n * @public\n */\n\nexport default class Middleware {\n\n\n /**\n * Middleware initialization\n *\n * @param {String} middleware name\n */\n\n constructor(name='') {\n this.name = name;\n }\n\n /**\n * Invoked by the app before an ajax request is sent or\n * during the DOM loading (document.readyState === 'loading').\n * See Application#_callMiddlewareEntered documentation for details.\n *\n * Override this method to add your custom behaviour\n *\n * @param {Object} request\n * @public\n */\n\n entered(request) { }\n\n\n /**\n * Invoked by the app before a new ajax request is sent or before the DOM is unloaded.\n * See Application#_callMiddlewareExited documentation for details.\n *\n * Override this method to add your custom behaviour\n *\n * @param {Object} request\n * @public\n */\n\n exited(request) { }\n\n\n /**\n * Invoked by the app after an ajax request has responded or on DOM ready\n * (document.readyState === 'interactive').\n * See Application#_callMiddlewareUpdated documentation for details.\n *\n * Override this method to add your custom behaviour\n *\n * @param {Object} request\n * @param {Object} response\n * @public\n */\n\n updated(request, response) { }\n\n\n /**\n * Invoked by the app when an ajax request has failed.\n *\n * Override this method to add your custom behaviour\n *\n * @param {Object} request\n * @param {Object} response\n * @public\n */\n failed(request, response) { }\n\n\n /**\n * Allow the hand over to the next middleware object or function.\n *\n * Override this method and return `false` to break execution of\n * middleware chain.\n *\n * @return {Boolean} `true` by default\n *\n * @public\n */\n\n next() {\n return true;\n }\n}\n","/**\n * Module dependencies.\n * @private\n */\n\nexport default class Requester {\n\n /**\n * Make an ajax request.\n *\n * @param {Object} request\n * @param {Function} success callback\n * @param {Function} failure callback\n * @private\n */\n\n fetch(request, resolve, reject) {\n const {method, uri, headers=[], data} = request;\n\n const fail = ({status, statusText, errorThrown}) => {\n reject(\n request,\n {\n status,\n statusText,\n errorThrown,\n errors: `HTTP ${status} ${statusText?statusText:''}`\n }\n );\n };\n\n const xmlhttp = new XMLHttpRequest();\n xmlhttp.onreadystatechange = () => {\n if (xmlhttp.readyState === 4) { //XMLHttpRequest.DONE\n if (xmlhttp.status === 200) {\n resolve(\n request,\n {\n status: 200,\n statusText: 'OK',\n responseText: xmlhttp.responseText\n }\n );\n } else {\n fail({\n status: xmlhttp.status,\n statusText: xmlhttp.statusText\n });\n }\n }\n };\n try {\n xmlhttp.open(method, uri, true);\n Object.keys(headers).forEach((header) => xmlhttp.setRequestHeader(header, headers[header]));\n xmlhttp.send(data);\n } catch (errorThrown) {\n fail({errorThrown});\n }\n }\n}\n\nexport const httpGetTransformer = {\n uri({uri, headers, data}) {\n if (!data) {\n return uri;\n }\n let [uriWithoutAnchor, anchor] = [uri, ''];\n const match = /^(.*)(#.*)$/.exec(uri);\n if (match) {\n [,uriWithoutAnchor, anchor] = /^(.*)(#.*)$/.exec(uri);\n }\n\n return `${uriWithoutAnchor}${uriWithoutAnchor.indexOf('?') === -1 ? '?' : '&'}${encodeURIObject(data)}${anchor}`;\n }\n};\n\nconst encodeURIObject = (obj, branch=[], results=[]) => {\n if (obj instanceof Object) {\n Object.keys(obj).forEach(key => {\n const newBranch = new Array(...branch);\n newBranch.push(key);\n encodeURIObject(obj[key], newBranch, results);\n });\n return results.join('&');\n }\n\n if (branch.length>0){\n results.push(`${encodeURIComponent(branch[0])}${branch.slice(1).map(el => encodeURIComponent(`[${el}]`)).join('')}=${encodeURIComponent(obj)}`);\n } else if (typeof(obj) === 'string') {\n return obj.split('').map((c,idx) => `${idx}=${encodeURIComponent(c)}`).join('&');\n } else {\n return '';\n }\n};\n\nexport const httpPostPatchTransformer = {\n data({data}) {\n if (!data) {\n return data;\n }\n return encodeURIObject(data);\n },\n headers({uri, headers, data}) {\n const updatedHeaders = headers || {};\n if (!updatedHeaders['Content-Type']) {\n updatedHeaders['Content-Type'] = 'application/x-www-form-urlencoded';\n }\n return updatedHeaders;\n }\n};\n","/**\n * Module dependencies.\n */\n\nimport Application from './application';\nimport Router from './router';\nimport Middleware from './middleware';\n\n\n/**\n * Create a frontexpress application.\n *\n * @return {Function}\n * @api public\n */\n\nconst frontexpress = () => new Application();\n\n/**\n * Expose Router, Middleware constructors.\n */\nfrontexpress.Router = (baseUri) => new Router(baseUri);\nfrontexpress.Middleware = Middleware;\n\nexport default frontexpress;\n"],"names":["routeMatcher","request","route","method","uri","match","exec","baseUriToCheck","RegExp","indexOf","decodeParmeterValue","v","isNaN","parseFloat","isFinite","Number","isInteger","parseInt","keys","keysRE","keysMatch","push","regExpUri","replace","routeMatch","params","Object","assign","reduce","acc","key","index","value","split","map","errorIfNotFunction","toTest","message","TypeError","errorIfNotHttpTransformer","headers","data","toParameters","args","baseUri","middleware","router","plugin","which","length","Router","Middleware","name","response","Route","uriPart","visited","this","trim","_baseUri","_routes","application","isRouteMatch","get","filter","_add","undefined","forEach","toLowerCase","babelHelpers.typeof","methodName","prototype","Requester","resolve","reject","fail","status","statusText","errorThrown","xmlhttp","XMLHttpRequest","onreadystatechange","readyState","responseText","open","header","setRequestHeader","send","httpGetTransformer","uriWithoutAnchor","anchor","encodeURIObject","obj","branch","results","newBranch","Array","join","encodeURIComponent","slice","el","c","idx","httpPostPatchTransformer","updatedHeaders","Settings","settings","rules","requester","fetch","transformer","checkRules","DEFAULT","callback","Application","routers","plugins","set","window","location","pathname","search","currentRoutes","_callMiddlewareMethod","onpopstate","event","state","_this","middlewareMethod","onbeforeunload","whenPageIsInteractiveFn","pluginObject","document","routes","meth","some","next","breakMiddlewareLoop","exited","req","history","httpMethodTransformer","fn","k","pushState","title","reqProto","middlewareMethodName","charAt","toUpperCase","_fetch","frontexpress"],"mappings":"yCA+PA,SAAgBA,EAAaC,EAASC,MAE9BA,EAAMC,QAAUD,EAAMC,SAAWF,EAAQE,cAClC,MAKND,EAAME,MAAQH,EAAQG,WAChB,MAILC,EAAQ,wCAAwCC,KAAKL,EAAQG,KAC7DG,EAAiBF,EAAM,IAAMA,EAAM,IAAMA,EAAM,MAGjDH,EAAME,eAAeI,cACsB,OAApCD,EAAeF,MAAMH,EAAME,SAIN,IAA5BF,EAAME,IAAIK,QAAQ,KAAa,SAEzBC,EAAsB,SAACC,UACjBC,MAAMC,WAAWF,KAAOG,SAASH,GAAMI,OAAOC,UAAUL,GAAKI,OAAOE,SAASN,EAAG,IAAMI,OAAOF,WAAWF,GAAMA,GAIpHO,KACAC,EAAS,kBACXC,EAAYD,EAAOb,KAAKJ,EAAME,KACd,MAAbgB,KACEC,KAAKD,EAAU,MACRD,EAAOb,KAAKJ,EAAME,SAI5BkB,EAAYpB,EAAME,IAEHmB,QAAQ,eAAgB,iBAExBA,QAAQ,WAAY,WAEpBA,QAAQ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