goodrouter
Version:
a good router
1 lines • 31.4 kB
Source Map (JSON)
{"version":3,"file":"main.cjs","sources":["../transpiled/router-options.js","../transpiled/utils/string.js","../transpiled/route-node.js","../transpiled/template.js","../transpiled/router.js"],"sourcesContent":["/**\n * @description\n * Default options to be passed to the router\n */\nexport const defaultRouterOptions = {\n /**\n * @description\n * Default encoding function to use, this is the encodeUriComponent function by default\n *\n * @param decodedValue value to be encoded\n * @returns encoded value\n */\n parameterValueEncoder: (decodedValue) => encodeURIComponent(decodedValue),\n /**\n * @description\n * Default decoding function to use, this is the decodeURIComponent function by default\n *\n * @param encodedValue value to be decoded\n * @returns decoded value\n */\n parameterValueDecoder: (encodedValue) => decodeURIComponent(encodedValue),\n /**\n * Use `{` and `}` as a default for matching placeholders in the route templates.\n */\n parameterPlaceholderRE: /\\{(.*?)\\}/gu,\n /**\n * Assume a maximum parameter value length of 50\n */\n maximumParameterValueLength: 50,\n};\n//# sourceMappingURL=router-options.js.map","export function findCommonPrefixLength(stringLeft, stringRight) {\n const length = Math.min(stringLeft.length, stringRight.length);\n let index;\n for (index = 0; index < length; index++) {\n const charLeft = stringLeft.charAt(index);\n const charRight = stringRight.charAt(index);\n if (charLeft !== charRight) {\n break;\n }\n }\n return index;\n}\n//# sourceMappingURL=string.js.map","import { findCommonPrefixLength } from \"./utils/string.js\";\n/**\n * @description\n * This interface represents a node in the tree structure that holds all the node\n * for the routes\n */\nexport class RouteNode {\n anchor;\n hasParameter;\n routeKey;\n children;\n constructor(\n /**\n * @description\n * suffix that comes after the parameter value (if any!) of the path\n */\n anchor = \"\", \n /**\n * @description\n * does this node have a parameter value\n */\n hasParameter = false, \n /**\n * @description\n * key that identifies the route, if this is a leaf node for the route\n */\n routeKey = null, \n /**\n * @description\n * children that represent the rest of the path that needs to be matched\n */\n children = new Array()) {\n this.anchor = anchor;\n this.hasParameter = hasParameter;\n this.routeKey = routeKey;\n this.children = children;\n }\n addChild(childNode) {\n this.children.push(childNode);\n }\n removeChild(childNode) {\n const childIndex = this.children.indexOf(childNode);\n this.children.splice(childIndex, 1);\n }\n countChildren() {\n return this.children.length;\n }\n insert(routeKey, templatePairs) {\n const routeParameterNames = templatePairs\n .map(([, parameterName]) => parameterName)\n .filter((parameterName) => parameterName);\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let currentNode = this;\n for (let index = 0; index < templatePairs.length; index++) {\n const [anchor, parameterName] = templatePairs[index];\n const hasParameter = parameterName != null;\n const [commonPrefixLength, childNode] = currentNode.findSimilarChild(anchor, hasParameter);\n currentNode = currentNode.merge(childNode, anchor, hasParameter, index === templatePairs.length - 1 ? routeKey : null, routeParameterNames, commonPrefixLength);\n }\n return currentNode;\n }\n parse(path, maximumParameterValueLength) {\n const parameterValues = new Array();\n if (this.hasParameter) {\n // we are matching a parameter value! If the path's length is 0, there is no match, because a parameter value should have at least length 1\n if (path.length === 0) {\n return [null, []];\n }\n // look for the anchor in the path (note: indexOf is probably the most expensive operation!) If the anchor is empty, match the remainder of the path\n const index = this.anchor.length === 0\n ? path.length\n : path\n .substring(0, maximumParameterValueLength + this.anchor.length)\n .indexOf(this.anchor);\n if (index < 0) {\n return [null, []];\n }\n // get the parameter value\n const value = path.substring(0, index);\n // remove the matches part from the path\n path = path.substring(index + this.anchor.length);\n // add value to parameters\n parameterValues.push(value);\n }\n else {\n // if this node does not represent a parameter we expect the path to start with the `anchor`\n if (!path.startsWith(this.anchor)) {\n // this node does not match the path\n return [null, []];\n }\n // we successfully matches the node to the path, now remove the matched part from the path\n path = path.substring(this.anchor.length);\n }\n for (const childNode of this.children) {\n // find a route in every child node\n const [childRouteKey, childParameterValues] = childNode.parse(path, maximumParameterValueLength);\n // if a child node is matched, return that node instead of the current! So child nodes are matched first!\n if (childRouteKey != null) {\n return [childRouteKey, [...parameterValues, ...childParameterValues]];\n }\n }\n // if the node had a route name and there is no path left to match against then we found a route\n if (this.routeKey != null && path.length === 0) {\n return [this.routeKey, parameterValues];\n }\n // we did not found a route :-(\n return [null, []];\n }\n merge(childNode, anchor, hasParameter, routeKey, routeParameterNames, commonPrefixLength) {\n if (childNode == null) {\n return this.mergeNew(anchor, hasParameter, routeKey);\n }\n const commonPrefix = childNode.anchor.substring(0, commonPrefixLength);\n if (childNode.anchor === anchor) {\n return this.mergeJoin(childNode, routeKey);\n }\n else if (childNode.anchor === commonPrefix) {\n return this.mergeAddToChild(childNode, anchor, hasParameter, routeKey, routeParameterNames, commonPrefixLength);\n }\n else if (anchor === commonPrefix) {\n return this.mergeAddToNew(childNode, anchor, hasParameter, routeKey, routeParameterNames, commonPrefixLength);\n }\n else {\n return this.mergeIntermediate(childNode, anchor, hasParameter, routeKey, routeParameterNames, commonPrefixLength);\n }\n }\n mergeNew(anchor, hasParameter, routeKey) {\n const newNode = new RouteNode(anchor, hasParameter, routeKey);\n this.addChild(newNode);\n this.children.sort((a, b) => a.compare(b));\n return newNode;\n }\n mergeJoin(childNode, routeKey) {\n if (childNode.routeKey != null && routeKey != null) {\n throw new Error(\"ambiguous route\");\n }\n if (childNode.routeKey == null) {\n childNode.routeKey = routeKey;\n }\n return childNode;\n }\n mergeIntermediate(childNode, anchor, hasParameter, routeKey, routeParameterNames, commonPrefixLength) {\n this.removeChild(childNode);\n const newNode = new RouteNode(anchor.substring(commonPrefixLength), false, routeKey);\n childNode.anchor = childNode.anchor.substring(commonPrefixLength);\n childNode.hasParameter = false;\n const intermediateNode = new RouteNode(anchor.substring(0, commonPrefixLength), hasParameter);\n intermediateNode.addChild(childNode);\n intermediateNode.addChild(newNode);\n this.addChild(intermediateNode);\n this.children.sort((a, b) => a.compare(b));\n intermediateNode.children.sort((a, b) => a.compare(b));\n return newNode;\n }\n mergeAddToChild(childNode, anchor, hasParameter, routeKey, routeParameterNames, commonPrefixLength) {\n anchor = anchor.substring(commonPrefixLength);\n hasParameter = false;\n const [commonPrefixLength2, childNode2] = childNode.findSimilarChild(anchor, hasParameter);\n return childNode.merge(childNode2, anchor, hasParameter, routeKey, routeParameterNames, commonPrefixLength2);\n }\n mergeAddToNew(childNode, anchor, hasParameter, routeKey, routeParameterNames, commonPrefixLength) {\n const newNode = new RouteNode(anchor, hasParameter, routeKey);\n this.addChild(newNode);\n this.removeChild(childNode);\n childNode.anchor = childNode.anchor.substring(commonPrefixLength);\n childNode.hasParameter = false;\n newNode.addChild(childNode);\n this.children.sort((a, b) => a.compare(b));\n newNode.children.sort((a, b) => a.compare(b));\n return newNode;\n }\n findSimilarChild(anchor, hasParameter) {\n for (const childNode of this.children) {\n if (childNode.hasParameter !== hasParameter) {\n continue;\n }\n const commonPrefixLength = findCommonPrefixLength(anchor, childNode.anchor);\n if (commonPrefixLength === 0) {\n continue;\n }\n return [commonPrefixLength, childNode];\n }\n return [0, null];\n }\n compare(other) {\n if (!this.hasParameter && other.hasParameter)\n return -1;\n if (this.hasParameter && !other.hasParameter)\n return 1;\n if (this.anchor.length < other.anchor.length)\n return 1;\n if (this.anchor.length > other.anchor.length)\n return -1;\n if (this.anchor < other.anchor)\n return -1;\n if (this.anchor > other.anchor)\n return 1;\n return 0;\n }\n toJSON() {\n const json = {\n anchor: this.anchor,\n hasParameter: this.hasParameter,\n routeKey: this.routeKey,\n children: this.children.map((child) => child.toJSON()),\n };\n return json;\n }\n static fromJSON(json) {\n const node = new RouteNode(json.anchor, json.hasParameter, json.routeKey, json.children.map((child) => RouteNode.fromJSON(child)));\n return node;\n }\n}\n//# sourceMappingURL=route-node.js.map","/**\n * Take a route template and chops is in pieces! The first piece is a literal part of\n * the template. Then the name of a placeholder. Then a literal parts of the template again.\n * The first and the last elements are always literal strings taken from the template,\n * therefore the number of elements in the resulting iterable is always uneven!\n *\n * @param routeTemplate template to chop up\n * @param parameterPlaceholderRE regular expression to use when searching for parameter placeholders\n * @returns Iterable of strings, always an uneven number of elements.\n */\nexport function* parseTemplateParts(routeTemplate, parameterPlaceholderRE) {\n if (!parameterPlaceholderRE.global) {\n throw new Error(\"regular expression needs to be global\");\n }\n let match;\n let offsetIndex = 0;\n while ((match = parameterPlaceholderRE.exec(routeTemplate)) != null) {\n yield routeTemplate.substring(offsetIndex, parameterPlaceholderRE.lastIndex - match[0].length);\n yield match[1];\n offsetIndex = parameterPlaceholderRE.lastIndex;\n }\n yield routeTemplate.substring(offsetIndex);\n}\nexport function* parseTemplatePairs(routeTemplate, parameterPlaceholderRE) {\n const parts = parseTemplateParts(routeTemplate, parameterPlaceholderRE);\n let index = 0;\n let parameter = null;\n for (const part of parts) {\n if (index % 2 === 0) {\n yield [part, parameter];\n }\n else {\n parameter = part;\n }\n index++;\n }\n}\n//# sourceMappingURL=template.js.map","import { RouteNode } from \"./route-node.js\";\nimport { defaultRouterOptions } from \"./router-options.js\";\nimport { parseTemplatePairs } from \"./template.js\";\nexport var RouterMode;\n(function (RouterMode) {\n RouterMode[RouterMode[\"Client\"] = 2] = \"Client\";\n RouterMode[RouterMode[\"Server\"] = 4] = \"Server\";\n RouterMode[RouterMode[\"Bidirectional\"] = 6] = \"Bidirectional\";\n})(RouterMode || (RouterMode = {}));\n/**\n * @description\n * This is the actual router that contains all routes and does the actual routing\n *\n * @example\n * ```typescript\n * const router = new Router<string>();\n *\n * router.insertRoute(\"all-products\", \"/product/all\");\n * router.insertRoute(\"product-detail\", \"/product/{id}\");\n *\n * // And now we can parse routes!\n *\n * {\n * const [routeKey, routeParameters] = router.parseRoute(\"/not-found\");\n * assert.equal(routeKey, null);\n * assert.deepEqual(routeParameters, {});\n * }\n *\n * {\n * const [routeKey, routeParameters] = router.parseRoute(\"/product/all\");\n * assert.equal(routeKey, \"all-products\");\n * assert.deepEqual(routeParameters, {});\n * }\n *\n * {\n * const [routeKey, routeParameters] = router.parseRoute(\"/product/1\");\n * assert.equal(routeKey, \"product-detail\");\n * assert.deepEqual(routeParameters, { id: \"1\" });\n * }\n *\n * // And we can stringify routes\n *\n * {\n * const path = router.stringifyRoute(\n * \"all-products\",\n * });\n * assert.equal(path, \"/product/all\");\n * }\n *\n * {\n * const path = router.stringifyRoute(\n * \"product-detail\",\n * { id: \"2\" },\n * );\n * assert.equal(path, \"/product/2\");\n * }\n * ```\n */\nexport class Router {\n mode;\n constructor(options = {}, mode = RouterMode.Bidirectional) {\n this.mode = mode;\n this.options = {\n ...defaultRouterOptions,\n ...options,\n };\n }\n options;\n rootNode = new RouteNode();\n templatePairs = new Map();\n /**\n * @description\n * Adds a new route\n *\n * @param routeKey name of the route\n * @param routeTemplate template for the route, als defines parameters\n */\n insertRoute(routeKey, routeTemplate) {\n const templatePairs = [\n ...parseTemplatePairs(routeTemplate, this.options.parameterPlaceholderRE),\n ];\n if ((this.mode & RouterMode.Client) > 0) {\n this.templatePairs.set(routeKey, templatePairs);\n }\n if ((this.mode & RouterMode.Server) > 0) {\n this.rootNode.insert(routeKey, templatePairs);\n }\n return this;\n }\n /**\n * @description\n * Match the path against a known routes and parse the parameters in it\n *\n * @param path path to match\n * @returns tuple with the route name or null if no route found. Then the parameters\n */\n parseRoute(path) {\n if ((this.mode & RouterMode.Server) === 0) {\n throw new TypeError(\"Router needs to be in server mode to parse\");\n }\n const parameters = {};\n const [routeKey, parameterValues] = this.rootNode.parse(path, this.options.maximumParameterValueLength);\n if (routeKey == null) {\n return [null, {}];\n }\n const templatePairs = this.templatePairs.get(routeKey);\n if (templatePairs == null) {\n // this never happens\n return [null, {}];\n }\n for (let index = 0; index < parameterValues.length; index++) {\n const [, parameterName] = templatePairs[index + 1];\n if (parameterName == null) {\n // this never happens\n return [null, {}];\n }\n const parameterValue = parameterValues[index];\n parameters[parameterName] = this.options.parameterValueDecoder(parameterValue);\n }\n return [routeKey, parameters];\n }\n /**\n * @description\n * Convert a route to a path string.\n *\n * @param routeKey route to stringify\n * @param routeParameters parameters to include in the path\n * @returns string representing the route or null if the route is not found by name\n */\n stringifyRoute(routeKey, routeParameters = {}) {\n if ((this.mode & RouterMode.Client) === 0) {\n throw new TypeError(\"Router needs to be in client mode to stringify\");\n }\n let result = \"\";\n const templatePairs = this.templatePairs.get(routeKey);\n if (templatePairs == null) {\n return null;\n }\n for (let index = 0; index < templatePairs.length; index++) {\n const [parameterAnchor, parameterName] = templatePairs[index];\n if (parameterName != null) {\n const parameterValue = routeParameters[parameterName];\n result += this.options.parameterValueEncoder(parameterValue);\n }\n result += parameterAnchor;\n }\n return result;\n }\n saveToJson(mode = this.mode) {\n const rootNode = (this.mode & mode & RouterMode.Server) > 0 ? this.rootNode.toJSON() : undefined;\n const templatePairs = (this.mode & mode & RouterMode.Client) > 0 ? [...this.templatePairs] : undefined;\n return {\n rootNode,\n templatePairs,\n };\n }\n loadFromJson(json) {\n this.mode = RouterMode.Bidirectional;\n if (json.rootNode == null) {\n this.mode &= ~RouterMode.Server;\n }\n else {\n this.rootNode = RouteNode.fromJSON(json.rootNode);\n }\n if (json.templatePairs == null) {\n this.mode &= ~RouterMode.Client;\n }\n else {\n this.templatePairs = new Map(json.templatePairs);\n }\n return this;\n }\n}\n//# sourceMappingURL=router.js.map"],"names":["RouterMode"],"mappings":";;AAAA;AACA;AACA;AACA;AACY,MAAC,oBAAoB,GAAG;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,qBAAqB,EAAE,CAAC,YAAY,KAAK,kBAAkB,CAAC,YAAY,CAAC;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,qBAAqB,EAAE,CAAC,YAAY,KAAK,kBAAkB,CAAC,YAAY,CAAC;AAC7E;AACA;AACA;AACA,IAAI,sBAAsB,EAAE,aAAa;AACzC;AACA;AACA;AACA,IAAI,2BAA2B,EAAE,EAAE;AACnC;;AC7BO,SAAS,sBAAsB,CAAC,UAAU,EAAE,WAAW,EAAE;AAChE,IAAI,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;AAClE,IAAI,IAAI,KAAK;AACb,IAAI,KAAK,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE;AAC7C,QAAQ,MAAM,QAAQ,GAAG,UA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