aurelia-route-recognizer
Advanced tools
Comparing version 1.0.0-beta.1.1.3 to 1.0.0-beta.1.2.0
{ | ||
"name": "aurelia-route-recognizer", | ||
"version": "1.0.0-beta.1.1.3", | ||
"version": "1.0.0-beta.1.2.0", | ||
"description": "A lightweight JavaScript library that matches paths against registered routes. It includes support for dynamic and star segments and nested handlers.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
var path = require('path'); | ||
var paths = require('./paths'); | ||
module.exports = { | ||
filename: '', | ||
filenameRelative: '', | ||
modules: '', | ||
sourceMap: true, | ||
sourceMapName: '', | ||
sourceRoot: '', | ||
moduleRoot: path.resolve('src').replace(/\\/g, '/'), | ||
moduleIds: false, | ||
experimental: false, | ||
comments: false, | ||
compact: false, | ||
code:true, | ||
stage:2, | ||
loose: "all", | ||
optional: [ | ||
"es7.decorators", | ||
"es7.classProperties" | ||
], | ||
plugins: [ | ||
"babel-dts-generator" | ||
], | ||
extra: { | ||
dts: { | ||
packageName: paths.packageName, | ||
typings: '', | ||
suppressModulePath: true, | ||
suppressComments: false, | ||
memberOutputFilter: /^_.*/ | ||
} | ||
} | ||
exports.base = function() { | ||
return { | ||
filename: '', | ||
filenameRelative: '', | ||
sourceMap: true, | ||
sourceRoot: '', | ||
moduleRoot: path.resolve('src').replace(/\\/g, '/'), | ||
moduleIds: false, | ||
comments: false, | ||
compact: false, | ||
code:true, | ||
presets: [ 'es2015-loose', 'stage-1'], | ||
plugins: [ | ||
'syntax-flow', | ||
'transform-decorators-legacy', | ||
['babel-dts-generator', { | ||
packageName: paths.packageName, | ||
typings: '', | ||
suppressModulePath: true, | ||
suppressComments: false, | ||
memberOutputFilter: /^_.*/ | ||
}], | ||
'transform-flow-strip-types' | ||
] | ||
}; | ||
} | ||
exports.commonjs = function() { | ||
var options = exports.base(); | ||
options.plugins.push('transform-es2015-modules-commonjs'); | ||
return options; | ||
}; | ||
exports.amd = function() { | ||
var options = exports.base(); | ||
options.plugins.push('transform-es2015-modules-amd'); | ||
return options; | ||
}; | ||
exports.system = function() { | ||
var options = exports.base(); | ||
options.plugins.push('transform-es2015-modules-systemjs'); | ||
return options; | ||
}; | ||
exports.es2015 = function() { | ||
var options = exports.base(); | ||
options.presets = ['stage-1'] | ||
return options; | ||
}; |
TN: | ||
SF:/Users/EisenbergEffect/Documents/GitHub/The Durandal Project/aurelia/route-recognizer/src/route-recognizer.js | ||
FN:20,(anonymous_2) | ||
FN:21,RouteRecognizer | ||
FN:34,add | ||
FN:38,(anonymous_5) | ||
FN:100,handlersFor | ||
FN:116,hasRoute | ||
FN:129,generate | ||
FN:181,recognize | ||
FN:239,RecognizeResults | ||
FN:249,parse | ||
FN:296,sortSolutions | ||
FN:297,(anonymous_13) | ||
FN:323,recognizeChar | ||
FN:334,findHandler | ||
FN:356,addSegment | ||
FN:358,(anonymous_17) | ||
FN:21,(anonymous_2) | ||
FN:22,RouteRecognizer | ||
FN:36,add | ||
FN:40,(anonymous_5) | ||
FN:103,handlersFor | ||
FN:120,hasRoute | ||
FN:134,generate | ||
FN:187,recognize | ||
FN:243,RecognizeResults | ||
FN:253,parse | ||
FN:300,sortSolutions | ||
FN:301,(anonymous_13) | ||
FN:327,recognizeChar | ||
FN:338,findHandler | ||
FN:360,addSegment | ||
FN:362,(anonymous_17) | ||
FNF:16 | ||
@@ -37,3 +37,5 @@ FNH:15 | ||
FNDA:135,(anonymous_17) | ||
DA:16,1 | ||
DA:1,1 | ||
DA:2,1 | ||
DA:3,1 | ||
DA:17,1 | ||
@@ -52,3 +54,3 @@ DA:18,20 | ||
DA:39,20 | ||
DA:41,20 | ||
DA:41,38 | ||
DA:42,40 | ||
@@ -58,5 +60,3 @@ DA:43,40 | ||
DA:47,38 | ||
DA:50,38 | ||
DA:51,38 | ||
DA:54,38 | ||
DA:55,38 | ||
@@ -80,2 +80,3 @@ DA:58,20 | ||
DA:104,2 | ||
DA:115,12 | ||
DA:116,16 | ||
@@ -99,3 +100,2 @@ DA:118,16 | ||
DA:144,1 | ||
DA:148,12 | ||
DA:149,9 | ||
@@ -205,68 +205,68 @@ DA:152,12 | ||
LH:141 | ||
BRDA:37,1,0,20 | ||
BRDA:37,1,1,20 | ||
BRDA:54,2,0,2 | ||
BRDA:54,2,1,38 | ||
BRDA:69,3,0,2 | ||
BRDA:69,3,1,18 | ||
BRDA:76,4,0,19 | ||
BRDA:76,4,1,1 | ||
BRDA:77,5,0,1 | ||
BRDA:77,5,1,18 | ||
BRDA:102,6,0,1 | ||
BRDA:102,6,1,3 | ||
BRDA:133,7,0,1 | ||
BRDA:133,7,1,15 | ||
BRDA:144,8,0,1 | ||
BRDA:144,8,1,28 | ||
BRDA:150,9,0,3 | ||
BRDA:150,9,1,25 | ||
BRDA:150,10,0,28 | ||
BRDA:150,10,1,27 | ||
BRDA:157,11,0,1 | ||
BRDA:157,11,1,11 | ||
BRDA:167,12,0,2 | ||
BRDA:167,12,1,10 | ||
BRDA:188,13,0,0 | ||
BRDA:188,13,1,9 | ||
BRDA:196,14,0,0 | ||
BRDA:196,14,1,9 | ||
BRDA:201,15,0,0 | ||
BRDA:201,15,1,9 | ||
BRDA:201,16,0,9 | ||
BRDA:201,16,1,8 | ||
BRDA:208,17,0,1 | ||
BRDA:208,17,1,97 | ||
BRDA:215,18,0,8 | ||
BRDA:215,18,1,0 | ||
BRDA:223,19,0,8 | ||
BRDA:223,19,1,1 | ||
BRDA:223,20,0,9 | ||
BRDA:223,20,1,8 | ||
BRDA:226,21,0,0 | ||
BRDA:226,21,1,8 | ||
BRDA:226,22,0,8 | ||
BRDA:226,22,1,0 | ||
BRDA:246,23,0,8 | ||
BRDA:246,23,1,0 | ||
BRDA:253,24,0,0 | ||
BRDA:253,24,1,20 | ||
BRDA:263,25,0,14 | ||
BRDA:263,25,1,26 | ||
BRDA:271,26,0,4 | ||
BRDA:271,26,1,22 | ||
BRDA:275,27,0,2 | ||
BRDA:275,27,1,20 | ||
BRDA:298,28,0,0 | ||
BRDA:298,28,1,0 | ||
BRDA:302,29,0,0 | ||
BRDA:302,29,1,0 | ||
BRDA:303,30,0,0 | ||
BRDA:303,30,1,0 | ||
BRDA:306,31,0,0 | ||
BRDA:306,31,1,0 | ||
BRDA:311,32,0,0 | ||
BRDA:311,32,1,0 | ||
BRDA:315,33,0,0 | ||
BRDA:315,33,1,0 | ||
BRDA:39,1,0,20 | ||
BRDA:39,1,1,20 | ||
BRDA:56,2,0,2 | ||
BRDA:56,2,1,38 | ||
BRDA:71,3,0,2 | ||
BRDA:71,3,1,18 | ||
BRDA:78,4,0,19 | ||
BRDA:78,4,1,1 | ||
BRDA:79,5,0,1 | ||
BRDA:79,5,1,18 | ||
BRDA:105,6,0,1 | ||
BRDA:105,6,1,3 | ||
BRDA:138,7,0,1 | ||
BRDA:138,7,1,15 | ||
BRDA:149,8,0,1 | ||
BRDA:149,8,1,28 | ||
BRDA:155,9,0,3 | ||
BRDA:155,9,1,25 | ||
BRDA:155,10,0,28 | ||
BRDA:155,10,1,27 | ||
BRDA:162,11,0,1 | ||
BRDA:162,11,1,11 | ||
BRDA:172,12,0,2 | ||
BRDA:172,12,1,10 | ||
BRDA:194,13,0,0 | ||
BRDA:194,13,1,9 | ||
BRDA:202,14,0,0 | ||
BRDA:202,14,1,9 | ||
BRDA:207,15,0,0 | ||
BRDA:207,15,1,9 | ||
BRDA:207,16,0,9 | ||
BRDA:207,16,1,8 | ||
BRDA:214,17,0,1 | ||
BRDA:214,17,1,97 | ||
BRDA:221,18,0,8 | ||
BRDA:221,18,1,0 | ||
BRDA:229,19,0,8 | ||
BRDA:229,19,1,1 | ||
BRDA:229,20,0,9 | ||
BRDA:229,20,1,8 | ||
BRDA:232,21,0,0 | ||
BRDA:232,21,1,8 | ||
BRDA:232,22,0,8 | ||
BRDA:232,22,1,0 | ||
BRDA:250,23,0,8 | ||
BRDA:250,23,1,0 | ||
BRDA:257,24,0,0 | ||
BRDA:257,24,1,20 | ||
BRDA:267,25,0,14 | ||
BRDA:267,25,1,26 | ||
BRDA:275,26,0,4 | ||
BRDA:275,26,1,22 | ||
BRDA:279,27,0,2 | ||
BRDA:279,27,1,20 | ||
BRDA:302,28,0,0 | ||
BRDA:302,28,1,0 | ||
BRDA:306,29,0,0 | ||
BRDA:306,29,1,0 | ||
BRDA:307,30,0,0 | ||
BRDA:307,30,1,0 | ||
BRDA:310,31,0,0 | ||
BRDA:310,31,1,0 | ||
BRDA:315,32,0,0 | ||
BRDA:315,32,1,0 | ||
BRDA:319,33,0,0 | ||
BRDA:319,33,1,0 | ||
BRF:66 | ||
@@ -281,3 +281,3 @@ BRH:46 | ||
FN:55,put | ||
FN:83,match | ||
FN:84,match | ||
FNF:5 | ||
@@ -290,3 +290,2 @@ FNH:5 | ||
FNDA:98,match | ||
DA:18,1 | ||
DA:19,1 | ||
@@ -299,10 +298,6 @@ DA:20,194 | ||
DA:30,1 | ||
DA:35,175 | ||
DA:36,175 | ||
DA:40,175 | ||
DA:41,1 | ||
DA:45,174 | ||
DA:48,174 | ||
DA:53,174 | ||
DA:54,18 | ||
DA:58,174 | ||
DA:63,98 | ||
@@ -320,4 +315,4 @@ DA:64,98 | ||
DA:81,98 | ||
LF:28 | ||
LH:28 | ||
LF:23 | ||
LH:23 | ||
BRDA:47,1,0,8 | ||
@@ -331,10 +326,10 @@ BRDA:47,1,1,1 | ||
BRDA:73,4,1,156 | ||
BRDA:91,5,0,66 | ||
BRDA:91,5,1,40 | ||
BRDA:92,6,0,60 | ||
BRDA:92,6,1,6 | ||
BRDA:95,7,0,40 | ||
BRDA:95,7,1,0 | ||
BRDA:96,8,0,37 | ||
BRDA:96,8,1,3 | ||
BRDA:92,5,0,66 | ||
BRDA:92,5,1,40 | ||
BRDA:93,6,0,60 | ||
BRDA:93,6,1,6 | ||
BRDA:96,7,0,40 | ||
BRDA:96,7,1,0 | ||
BRDA:97,8,0,37 | ||
BRDA:97,8,1,3 | ||
BRF:16 | ||
@@ -350,16 +345,16 @@ BRH:15 | ||
FN:47,generate | ||
FN:56,(anonymous_7) | ||
FN:57,DynamicSegment | ||
FN:63,eachChar | ||
FN:67,regex | ||
FN:71,generate | ||
FN:81,(anonymous_12) | ||
FN:82,StarSegment | ||
FN:88,eachChar | ||
FN:92,regex | ||
FN:96,generate | ||
FN:106,(anonymous_17) | ||
FN:111,eachChar | ||
FN:113,regex | ||
FN:117,generate | ||
FN:54,(anonymous_7) | ||
FN:55,DynamicSegment | ||
FN:61,eachChar | ||
FN:65,regex | ||
FN:69,generate | ||
FN:77,(anonymous_12) | ||
FN:78,StarSegment | ||
FN:84,eachChar | ||
FN:88,regex | ||
FN:92,generate | ||
FN:100,(anonymous_17) | ||
FN:105,eachChar | ||
FN:107,regex | ||
FN:111,generate | ||
FNF:19 | ||
@@ -388,3 +383,2 @@ FNH:16 | ||
DA:6,1 | ||
DA:25,1 | ||
DA:26,1 | ||
@@ -398,3 +392,2 @@ DA:27,20 | ||
DA:43,15 | ||
DA:47,1 | ||
DA:48,1 | ||
@@ -406,3 +399,2 @@ DA:49,14 | ||
DA:62,11 | ||
DA:66,1 | ||
DA:67,1 | ||
@@ -414,9 +406,8 @@ DA:68,4 | ||
DA:81,2 | ||
DA:85,1 | ||
DA:90,0 | ||
DA:94,0 | ||
LF:28 | ||
LH:26 | ||
LF:24 | ||
LH:22 | ||
BRF:0 | ||
BRH:0 | ||
end_of_record |
@@ -32,5 +32,6 @@ var gulp = require('gulp'); | ||
gulp.task('build-es6', function () { | ||
gulp.task('build-es2015', function () { | ||
return gulp.src(paths.output + jsName) | ||
.pipe(gulp.dest(paths.output + 'es6')); | ||
.pipe(to5(assign({}, compilerOptions.es2015()))) | ||
.pipe(gulp.dest(paths.output + 'es2015')); | ||
}); | ||
@@ -40,3 +41,3 @@ | ||
return gulp.src(paths.output + jsName) | ||
.pipe(to5(assign({}, compilerOptions, {modules:'common'}))) | ||
.pipe(to5(assign({}, compilerOptions.commonjs()))) | ||
.pipe(gulp.dest(paths.output + 'commonjs')); | ||
@@ -47,3 +48,3 @@ }); | ||
return gulp.src(paths.output + jsName) | ||
.pipe(to5(assign({}, compilerOptions, {modules:'amd'}))) | ||
.pipe(to5(assign({}, compilerOptions.amd()))) | ||
.pipe(gulp.dest(paths.output + 'amd')); | ||
@@ -54,3 +55,3 @@ }); | ||
return gulp.src(paths.output + jsName) | ||
.pipe(to5(assign({}, compilerOptions, {modules:'system'}))) | ||
.pipe(to5(assign({}, compilerOptions.system()))) | ||
.pipe(gulp.dest(paths.output + 'system')); | ||
@@ -62,3 +63,3 @@ }); | ||
.pipe(rename(paths.packageName + '.d.ts')) | ||
.pipe(gulp.dest(paths.output + 'es6')) | ||
.pipe(gulp.dest(paths.output + 'es2015')) | ||
.pipe(gulp.dest(paths.output + 'commonjs')) | ||
@@ -73,3 +74,3 @@ .pipe(gulp.dest(paths.output + 'amd')) | ||
'build-index', | ||
['build-es6', 'build-commonjs', 'build-amd', 'build-system'], | ||
['build-es2015', 'build-commonjs', 'build-amd', 'build-system'], | ||
'build-dts', | ||
@@ -76,0 +77,0 @@ callback |
declare module 'aurelia-route-recognizer' { | ||
import { buildQueryString, parseQueryString } from 'aurelia-path'; | ||
import { | ||
buildQueryString, | ||
parseQueryString | ||
} from 'aurelia-path'; | ||
export interface RouteHandler { | ||
@@ -25,18 +28,18 @@ name: string; | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
// subsequent states (`nextStates`). | ||
// | ||
// If a State is an accepting state, it will also have several additional | ||
// properties: | ||
// | ||
// * `regex`: A regular expression that is used to extract parameters from paths | ||
// that reached this accepting state. | ||
// * `handlers`: Information on how to convert the list of captures into calls | ||
// to registered handlers with the specified parameters. | ||
// * `types`: How many static, dynamic, or star segments in this route. Used to | ||
// decide which route to use if multiple registered routes match a path. | ||
// | ||
// Currently, State is implemented naively by looping over `nextStates` and | ||
// comparing a character specification against a character. A more efficient | ||
// implementation would use a hash of keys pointing at one or more next states. | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
// subsequent states (`nextStates`). | ||
// | ||
// If a State is an accepting state, it will also have several additional | ||
// properties: | ||
// | ||
// * `regex`: A regular expression that is used to extract parameters from paths | ||
// that reached this accepting state. | ||
// * `handlers`: Information on how to convert the list of captures into calls | ||
// to registered handlers with the specified parameters. | ||
// * `types`: How many static, dynamic, or star segments in this route. Used to | ||
// decide which route to use if multiple registered routes match a path. | ||
// | ||
// Currently, State is implemented naively by looping over `nextStates` and | ||
// comparing a character specification against a character. A more efficient | ||
// implementation would use a hash of keys pointing at one or more next states. | ||
export class State { | ||
@@ -47,22 +50,22 @@ constructor(charSpec: CharSpec); | ||
// Find a list of child states matching the next character | ||
// Find a list of child states matching the next character | ||
match(ch: string): State[]; | ||
} | ||
// A Segment represents a segment in the original route description. | ||
// Each Segment type provides an `eachChar` and `regex` method. | ||
// | ||
// The `eachChar` method invokes the callback with one or more character | ||
// specifications. A character specification consumes one or more input | ||
// characters. | ||
// | ||
// The `regex` method returns a regex fragment for the segment. If the | ||
// segment is a dynamic or star segment, the regex fragment also includes | ||
// a capture. | ||
// | ||
// A character specification contains: | ||
// | ||
// * `validChars`: a String with a list of all valid characters, or | ||
// * `invalidChars`: a String with a list of all invalid characters | ||
// * `repeat`: true if the character specification can repeat | ||
// A Segment represents a segment in the original route description. | ||
// Each Segment type provides an `eachChar` and `regex` method. | ||
// | ||
// The `eachChar` method invokes the callback with one or more character | ||
// specifications. A character specification consumes one or more input | ||
// characters. | ||
// | ||
// The `regex` method returns a regex fragment for the segment. If the | ||
// segment is a dynamic or star segment, the regex fragment also includes | ||
// a capture. | ||
// | ||
// A character specification contains: | ||
// | ||
// * `validChars`: a String with a list of all valid characters, or | ||
// * `invalidChars`: a String with a list of all invalid characters | ||
// * `repeat`: true if the character specification can repeat | ||
export class StaticSegment { | ||
@@ -98,2 +101,8 @@ constructor(string: string); | ||
*/ | ||
/** | ||
* Class that parses route patterns and matches path strings. | ||
* | ||
* @class RouteRecognizer | ||
* @constructor | ||
*/ | ||
export class RouteRecognizer { | ||
@@ -145,5 +154,2 @@ constructor(); | ||
} | ||
class RecognizeResults { | ||
constructor(queryParams: Object); | ||
} | ||
} |
define(['exports', 'aurelia-path'], function (exports, _aureliaPath) { | ||
'use strict'; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.RouteRecognizer = exports.EpsilonSegment = exports.StarSegment = exports.DynamicSegment = exports.StaticSegment = exports.State = undefined; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
var State = (function () { | ||
var State = exports.State = function () { | ||
function State(charSpec) { | ||
@@ -80,6 +87,4 @@ _classCallCheck(this, State); | ||
return State; | ||
})(); | ||
}(); | ||
exports.State = State; | ||
var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\']; | ||
@@ -89,3 +94,3 @@ | ||
var StaticSegment = (function () { | ||
var StaticSegment = exports.StaticSegment = function () { | ||
function StaticSegment(string) { | ||
@@ -114,7 +119,5 @@ _classCallCheck(this, StaticSegment); | ||
return StaticSegment; | ||
})(); | ||
}(); | ||
exports.StaticSegment = StaticSegment; | ||
var DynamicSegment = (function () { | ||
var DynamicSegment = exports.DynamicSegment = function () { | ||
function DynamicSegment(name) { | ||
@@ -140,7 +143,5 @@ _classCallCheck(this, DynamicSegment); | ||
return DynamicSegment; | ||
})(); | ||
}(); | ||
exports.DynamicSegment = DynamicSegment; | ||
var StarSegment = (function () { | ||
var StarSegment = exports.StarSegment = function () { | ||
function StarSegment(name) { | ||
@@ -166,7 +167,5 @@ _classCallCheck(this, StarSegment); | ||
return StarSegment; | ||
})(); | ||
}(); | ||
exports.StarSegment = StarSegment; | ||
var EpsilonSegment = (function () { | ||
var EpsilonSegment = exports.EpsilonSegment = function () { | ||
function EpsilonSegment() { | ||
@@ -187,7 +186,5 @@ _classCallCheck(this, EpsilonSegment); | ||
return EpsilonSegment; | ||
})(); | ||
}(); | ||
exports.EpsilonSegment = EpsilonSegment; | ||
var RouteRecognizer = (function () { | ||
var RouteRecognizer = exports.RouteRecognizer = function () { | ||
function RouteRecognizer() { | ||
@@ -242,4 +239,4 @@ _classCallCheck(this, RouteRecognizer); | ||
var routeNames = Array.isArray(routeName) ? routeName : [routeName]; | ||
for (var i = 0; i < routeNames.length; i++) { | ||
this.names[routeNames[i]] = { | ||
for (var _i2 = 0; _i2 < routeNames.length; _i2++) { | ||
this.names[routeNames[_i2]] = { | ||
segments: segments, | ||
@@ -307,3 +304,3 @@ handlers: handlers | ||
var queryString = _aureliaPath.buildQueryString(routeParams); | ||
var queryString = (0, _aureliaPath.buildQueryString)(routeParams); | ||
output += queryString ? '?' + queryString : ''; | ||
@@ -324,3 +321,3 @@ | ||
normalizedPath = normalizedPath.substr(0, queryStart); | ||
queryParams = _aureliaPath.parseQueryString(queryString); | ||
queryParams = (0, _aureliaPath.parseQueryString)(queryString); | ||
} | ||
@@ -348,5 +345,5 @@ | ||
var solutions = []; | ||
for (var i = 0, l = states.length; i < l; i++) { | ||
if (states[i].handlers) { | ||
solutions.push(states[i]); | ||
for (var _i3 = 0, _l = states.length; _i3 < _l; _i3++) { | ||
if (states[_i3].handlers) { | ||
solutions.push(states[_i3]); | ||
} | ||
@@ -368,6 +365,4 @@ } | ||
return RouteRecognizer; | ||
})(); | ||
}(); | ||
exports.RouteRecognizer = RouteRecognizer; | ||
var RecognizeResults = function RecognizeResults(queryParams) { | ||
@@ -374,0 +369,0 @@ _classCallCheck(this, RecognizeResults); |
declare module 'aurelia-route-recognizer' { | ||
import { buildQueryString, parseQueryString } from 'aurelia-path'; | ||
import { | ||
buildQueryString, | ||
parseQueryString | ||
} from 'aurelia-path'; | ||
export interface RouteHandler { | ||
@@ -25,18 +28,18 @@ name: string; | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
// subsequent states (`nextStates`). | ||
// | ||
// If a State is an accepting state, it will also have several additional | ||
// properties: | ||
// | ||
// * `regex`: A regular expression that is used to extract parameters from paths | ||
// that reached this accepting state. | ||
// * `handlers`: Information on how to convert the list of captures into calls | ||
// to registered handlers with the specified parameters. | ||
// * `types`: How many static, dynamic, or star segments in this route. Used to | ||
// decide which route to use if multiple registered routes match a path. | ||
// | ||
// Currently, State is implemented naively by looping over `nextStates` and | ||
// comparing a character specification against a character. A more efficient | ||
// implementation would use a hash of keys pointing at one or more next states. | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
// subsequent states (`nextStates`). | ||
// | ||
// If a State is an accepting state, it will also have several additional | ||
// properties: | ||
// | ||
// * `regex`: A regular expression that is used to extract parameters from paths | ||
// that reached this accepting state. | ||
// * `handlers`: Information on how to convert the list of captures into calls | ||
// to registered handlers with the specified parameters. | ||
// * `types`: How many static, dynamic, or star segments in this route. Used to | ||
// decide which route to use if multiple registered routes match a path. | ||
// | ||
// Currently, State is implemented naively by looping over `nextStates` and | ||
// comparing a character specification against a character. A more efficient | ||
// implementation would use a hash of keys pointing at one or more next states. | ||
export class State { | ||
@@ -47,22 +50,22 @@ constructor(charSpec: CharSpec); | ||
// Find a list of child states matching the next character | ||
// Find a list of child states matching the next character | ||
match(ch: string): State[]; | ||
} | ||
// A Segment represents a segment in the original route description. | ||
// Each Segment type provides an `eachChar` and `regex` method. | ||
// | ||
// The `eachChar` method invokes the callback with one or more character | ||
// specifications. A character specification consumes one or more input | ||
// characters. | ||
// | ||
// The `regex` method returns a regex fragment for the segment. If the | ||
// segment is a dynamic or star segment, the regex fragment also includes | ||
// a capture. | ||
// | ||
// A character specification contains: | ||
// | ||
// * `validChars`: a String with a list of all valid characters, or | ||
// * `invalidChars`: a String with a list of all invalid characters | ||
// * `repeat`: true if the character specification can repeat | ||
// A Segment represents a segment in the original route description. | ||
// Each Segment type provides an `eachChar` and `regex` method. | ||
// | ||
// The `eachChar` method invokes the callback with one or more character | ||
// specifications. A character specification consumes one or more input | ||
// characters. | ||
// | ||
// The `regex` method returns a regex fragment for the segment. If the | ||
// segment is a dynamic or star segment, the regex fragment also includes | ||
// a capture. | ||
// | ||
// A character specification contains: | ||
// | ||
// * `validChars`: a String with a list of all valid characters, or | ||
// * `invalidChars`: a String with a list of all invalid characters | ||
// * `repeat`: true if the character specification can repeat | ||
export class StaticSegment { | ||
@@ -98,2 +101,8 @@ constructor(string: string); | ||
*/ | ||
/** | ||
* Class that parses route patterns and matches path strings. | ||
* | ||
* @class RouteRecognizer | ||
* @constructor | ||
*/ | ||
export class RouteRecognizer { | ||
@@ -145,5 +154,2 @@ constructor(); | ||
} | ||
class RecognizeResults { | ||
constructor(queryParams: Object); | ||
} | ||
} |
declare module 'aurelia-route-recognizer' { | ||
import { buildQueryString, parseQueryString } from 'aurelia-path'; | ||
import { | ||
buildQueryString, | ||
parseQueryString | ||
} from 'aurelia-path'; | ||
export interface RouteHandler { | ||
@@ -25,18 +28,18 @@ name: string; | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
// subsequent states (`nextStates`). | ||
// | ||
// If a State is an accepting state, it will also have several additional | ||
// properties: | ||
// | ||
// * `regex`: A regular expression that is used to extract parameters from paths | ||
// that reached this accepting state. | ||
// * `handlers`: Information on how to convert the list of captures into calls | ||
// to registered handlers with the specified parameters. | ||
// * `types`: How many static, dynamic, or star segments in this route. Used to | ||
// decide which route to use if multiple registered routes match a path. | ||
// | ||
// Currently, State is implemented naively by looping over `nextStates` and | ||
// comparing a character specification against a character. A more efficient | ||
// implementation would use a hash of keys pointing at one or more next states. | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
// subsequent states (`nextStates`). | ||
// | ||
// If a State is an accepting state, it will also have several additional | ||
// properties: | ||
// | ||
// * `regex`: A regular expression that is used to extract parameters from paths | ||
// that reached this accepting state. | ||
// * `handlers`: Information on how to convert the list of captures into calls | ||
// to registered handlers with the specified parameters. | ||
// * `types`: How many static, dynamic, or star segments in this route. Used to | ||
// decide which route to use if multiple registered routes match a path. | ||
// | ||
// Currently, State is implemented naively by looping over `nextStates` and | ||
// comparing a character specification against a character. A more efficient | ||
// implementation would use a hash of keys pointing at one or more next states. | ||
export class State { | ||
@@ -47,22 +50,22 @@ constructor(charSpec: CharSpec); | ||
// Find a list of child states matching the next character | ||
// Find a list of child states matching the next character | ||
match(ch: string): State[]; | ||
} | ||
// A Segment represents a segment in the original route description. | ||
// Each Segment type provides an `eachChar` and `regex` method. | ||
// | ||
// The `eachChar` method invokes the callback with one or more character | ||
// specifications. A character specification consumes one or more input | ||
// characters. | ||
// | ||
// The `regex` method returns a regex fragment for the segment. If the | ||
// segment is a dynamic or star segment, the regex fragment also includes | ||
// a capture. | ||
// | ||
// A character specification contains: | ||
// | ||
// * `validChars`: a String with a list of all valid characters, or | ||
// * `invalidChars`: a String with a list of all invalid characters | ||
// * `repeat`: true if the character specification can repeat | ||
// A Segment represents a segment in the original route description. | ||
// Each Segment type provides an `eachChar` and `regex` method. | ||
// | ||
// The `eachChar` method invokes the callback with one or more character | ||
// specifications. A character specification consumes one or more input | ||
// characters. | ||
// | ||
// The `regex` method returns a regex fragment for the segment. If the | ||
// segment is a dynamic or star segment, the regex fragment also includes | ||
// a capture. | ||
// | ||
// A character specification contains: | ||
// | ||
// * `validChars`: a String with a list of all valid characters, or | ||
// * `invalidChars`: a String with a list of all invalid characters | ||
// * `repeat`: true if the character specification can repeat | ||
export class StaticSegment { | ||
@@ -98,2 +101,8 @@ constructor(string: string); | ||
*/ | ||
/** | ||
* Class that parses route patterns and matches path strings. | ||
* | ||
* @class RouteRecognizer | ||
* @constructor | ||
*/ | ||
export class RouteRecognizer { | ||
@@ -145,5 +154,2 @@ constructor(); | ||
} | ||
class RecognizeResults { | ||
constructor(queryParams: Object); | ||
} | ||
} |
'use strict'; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.RouteRecognizer = exports.EpsilonSegment = exports.StarSegment = exports.DynamicSegment = exports.StaticSegment = exports.State = undefined; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _aureliaPath = require('aurelia-path'); | ||
var State = (function () { | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var State = exports.State = function () { | ||
function State(charSpec) { | ||
@@ -81,6 +84,4 @@ _classCallCheck(this, State); | ||
return State; | ||
})(); | ||
}(); | ||
exports.State = State; | ||
var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\']; | ||
@@ -90,3 +91,3 @@ | ||
var StaticSegment = (function () { | ||
var StaticSegment = exports.StaticSegment = function () { | ||
function StaticSegment(string) { | ||
@@ -115,7 +116,5 @@ _classCallCheck(this, StaticSegment); | ||
return StaticSegment; | ||
})(); | ||
}(); | ||
exports.StaticSegment = StaticSegment; | ||
var DynamicSegment = (function () { | ||
var DynamicSegment = exports.DynamicSegment = function () { | ||
function DynamicSegment(name) { | ||
@@ -141,7 +140,5 @@ _classCallCheck(this, DynamicSegment); | ||
return DynamicSegment; | ||
})(); | ||
}(); | ||
exports.DynamicSegment = DynamicSegment; | ||
var StarSegment = (function () { | ||
var StarSegment = exports.StarSegment = function () { | ||
function StarSegment(name) { | ||
@@ -167,7 +164,5 @@ _classCallCheck(this, StarSegment); | ||
return StarSegment; | ||
})(); | ||
}(); | ||
exports.StarSegment = StarSegment; | ||
var EpsilonSegment = (function () { | ||
var EpsilonSegment = exports.EpsilonSegment = function () { | ||
function EpsilonSegment() { | ||
@@ -188,7 +183,5 @@ _classCallCheck(this, EpsilonSegment); | ||
return EpsilonSegment; | ||
})(); | ||
}(); | ||
exports.EpsilonSegment = EpsilonSegment; | ||
var RouteRecognizer = (function () { | ||
var RouteRecognizer = exports.RouteRecognizer = function () { | ||
function RouteRecognizer() { | ||
@@ -243,4 +236,4 @@ _classCallCheck(this, RouteRecognizer); | ||
var routeNames = Array.isArray(routeName) ? routeName : [routeName]; | ||
for (var i = 0; i < routeNames.length; i++) { | ||
this.names[routeNames[i]] = { | ||
for (var _i2 = 0; _i2 < routeNames.length; _i2++) { | ||
this.names[routeNames[_i2]] = { | ||
segments: segments, | ||
@@ -308,3 +301,3 @@ handlers: handlers | ||
var queryString = _aureliaPath.buildQueryString(routeParams); | ||
var queryString = (0, _aureliaPath.buildQueryString)(routeParams); | ||
output += queryString ? '?' + queryString : ''; | ||
@@ -325,3 +318,3 @@ | ||
normalizedPath = normalizedPath.substr(0, queryStart); | ||
queryParams = _aureliaPath.parseQueryString(queryString); | ||
queryParams = (0, _aureliaPath.parseQueryString)(queryString); | ||
} | ||
@@ -349,5 +342,5 @@ | ||
var solutions = []; | ||
for (var i = 0, l = states.length; i < l; i++) { | ||
if (states[i].handlers) { | ||
solutions.push(states[i]); | ||
for (var _i3 = 0, _l = states.length; _i3 < _l; _i3++) { | ||
if (states[_i3].handlers) { | ||
solutions.push(states[_i3]); | ||
} | ||
@@ -369,6 +362,4 @@ } | ||
return RouteRecognizer; | ||
})(); | ||
}(); | ||
exports.RouteRecognizer = RouteRecognizer; | ||
var RecognizeResults = function RecognizeResults(queryParams) { | ||
@@ -375,0 +366,0 @@ _classCallCheck(this, RecognizeResults); |
declare module 'aurelia-route-recognizer' { | ||
import { buildQueryString, parseQueryString } from 'aurelia-path'; | ||
import { | ||
buildQueryString, | ||
parseQueryString | ||
} from 'aurelia-path'; | ||
export interface RouteHandler { | ||
@@ -25,18 +28,18 @@ name: string; | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
// subsequent states (`nextStates`). | ||
// | ||
// If a State is an accepting state, it will also have several additional | ||
// properties: | ||
// | ||
// * `regex`: A regular expression that is used to extract parameters from paths | ||
// that reached this accepting state. | ||
// * `handlers`: Information on how to convert the list of captures into calls | ||
// to registered handlers with the specified parameters. | ||
// * `types`: How many static, dynamic, or star segments in this route. Used to | ||
// decide which route to use if multiple registered routes match a path. | ||
// | ||
// Currently, State is implemented naively by looping over `nextStates` and | ||
// comparing a character specification against a character. A more efficient | ||
// implementation would use a hash of keys pointing at one or more next states. | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
// subsequent states (`nextStates`). | ||
// | ||
// If a State is an accepting state, it will also have several additional | ||
// properties: | ||
// | ||
// * `regex`: A regular expression that is used to extract parameters from paths | ||
// that reached this accepting state. | ||
// * `handlers`: Information on how to convert the list of captures into calls | ||
// to registered handlers with the specified parameters. | ||
// * `types`: How many static, dynamic, or star segments in this route. Used to | ||
// decide which route to use if multiple registered routes match a path. | ||
// | ||
// Currently, State is implemented naively by looping over `nextStates` and | ||
// comparing a character specification against a character. A more efficient | ||
// implementation would use a hash of keys pointing at one or more next states. | ||
export class State { | ||
@@ -47,22 +50,22 @@ constructor(charSpec: CharSpec); | ||
// Find a list of child states matching the next character | ||
// Find a list of child states matching the next character | ||
match(ch: string): State[]; | ||
} | ||
// A Segment represents a segment in the original route description. | ||
// Each Segment type provides an `eachChar` and `regex` method. | ||
// | ||
// The `eachChar` method invokes the callback with one or more character | ||
// specifications. A character specification consumes one or more input | ||
// characters. | ||
// | ||
// The `regex` method returns a regex fragment for the segment. If the | ||
// segment is a dynamic or star segment, the regex fragment also includes | ||
// a capture. | ||
// | ||
// A character specification contains: | ||
// | ||
// * `validChars`: a String with a list of all valid characters, or | ||
// * `invalidChars`: a String with a list of all invalid characters | ||
// * `repeat`: true if the character specification can repeat | ||
// A Segment represents a segment in the original route description. | ||
// Each Segment type provides an `eachChar` and `regex` method. | ||
// | ||
// The `eachChar` method invokes the callback with one or more character | ||
// specifications. A character specification consumes one or more input | ||
// characters. | ||
// | ||
// The `regex` method returns a regex fragment for the segment. If the | ||
// segment is a dynamic or star segment, the regex fragment also includes | ||
// a capture. | ||
// | ||
// A character specification contains: | ||
// | ||
// * `validChars`: a String with a list of all valid characters, or | ||
// * `invalidChars`: a String with a list of all invalid characters | ||
// * `repeat`: true if the character specification can repeat | ||
export class StaticSegment { | ||
@@ -98,2 +101,8 @@ constructor(string: string); | ||
*/ | ||
/** | ||
* Class that parses route patterns and matches path strings. | ||
* | ||
* @class RouteRecognizer | ||
* @constructor | ||
*/ | ||
export class RouteRecognizer { | ||
@@ -145,5 +154,2 @@ constructor(); | ||
} | ||
class RecognizeResults { | ||
constructor(queryParams: Object); | ||
} | ||
} |
@@ -1,7 +0,11 @@ | ||
System.register(['aurelia-path'], function (_export) { | ||
'use strict'; | ||
'use strict'; | ||
System.register(['aurelia-path'], function (_export, _context) { | ||
var buildQueryString, parseQueryString, State, specials, escapeRegex, StaticSegment, DynamicSegment, StarSegment, EpsilonSegment, RouteRecognizer, RecognizeResults; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
@@ -117,3 +121,3 @@ function parse(route, names, types) { | ||
execute: function () { | ||
State = (function () { | ||
_export('State', State = function () { | ||
function State(charSpec) { | ||
@@ -190,3 +194,3 @@ _classCallCheck(this, State); | ||
return State; | ||
})(); | ||
}()); | ||
@@ -198,3 +202,3 @@ _export('State', State); | ||
StaticSegment = (function () { | ||
_export('StaticSegment', StaticSegment = function () { | ||
function StaticSegment(string) { | ||
@@ -223,7 +227,7 @@ _classCallCheck(this, StaticSegment); | ||
return StaticSegment; | ||
})(); | ||
}()); | ||
_export('StaticSegment', StaticSegment); | ||
DynamicSegment = (function () { | ||
_export('DynamicSegment', DynamicSegment = function () { | ||
function DynamicSegment(name) { | ||
@@ -249,7 +253,7 @@ _classCallCheck(this, DynamicSegment); | ||
return DynamicSegment; | ||
})(); | ||
}()); | ||
_export('DynamicSegment', DynamicSegment); | ||
StarSegment = (function () { | ||
_export('StarSegment', StarSegment = function () { | ||
function StarSegment(name) { | ||
@@ -275,7 +279,7 @@ _classCallCheck(this, StarSegment); | ||
return StarSegment; | ||
})(); | ||
}()); | ||
_export('StarSegment', StarSegment); | ||
EpsilonSegment = (function () { | ||
_export('EpsilonSegment', EpsilonSegment = function () { | ||
function EpsilonSegment() { | ||
@@ -296,7 +300,7 @@ _classCallCheck(this, EpsilonSegment); | ||
return EpsilonSegment; | ||
})(); | ||
}()); | ||
_export('EpsilonSegment', EpsilonSegment); | ||
RouteRecognizer = (function () { | ||
_export('RouteRecognizer', RouteRecognizer = function () { | ||
function RouteRecognizer() { | ||
@@ -351,4 +355,4 @@ _classCallCheck(this, RouteRecognizer); | ||
var routeNames = Array.isArray(routeName) ? routeName : [routeName]; | ||
for (var i = 0; i < routeNames.length; i++) { | ||
this.names[routeNames[i]] = { | ||
for (var _i2 = 0; _i2 < routeNames.length; _i2++) { | ||
this.names[routeNames[_i2]] = { | ||
segments: segments, | ||
@@ -455,5 +459,5 @@ handlers: handlers | ||
var solutions = []; | ||
for (var i = 0, l = states.length; i < l; i++) { | ||
if (states[i].handlers) { | ||
solutions.push(states[i]); | ||
for (var _i3 = 0, _l = states.length; _i3 < _l; _i3++) { | ||
if (states[_i3].handlers) { | ||
solutions.push(states[_i3]); | ||
} | ||
@@ -475,3 +479,3 @@ } | ||
return RouteRecognizer; | ||
})(); | ||
}()); | ||
@@ -478,0 +482,0 @@ _export('RouteRecognizer', RouteRecognizer); |
@@ -299,55 +299,2 @@ { | ||
{ | ||
"id": 104, | ||
"name": "RecognizeResults", | ||
"kind": 128, | ||
"kindString": "Class", | ||
"flags": {}, | ||
"children": [ | ||
{ | ||
"id": 105, | ||
"name": "constructor", | ||
"kind": 512, | ||
"kindString": "Constructor", | ||
"flags": {}, | ||
"signatures": [ | ||
{ | ||
"id": 106, | ||
"name": "new RecognizeResults", | ||
"kind": 16384, | ||
"kindString": "Constructor signature", | ||
"flags": {}, | ||
"parameters": [ | ||
{ | ||
"id": 107, | ||
"name": "queryParams", | ||
"kind": 32768, | ||
"kindString": "Parameter", | ||
"flags": {}, | ||
"type": { | ||
"type": "reference", | ||
"name": "Object" | ||
} | ||
} | ||
], | ||
"type": { | ||
"type": "reference", | ||
"name": "RecognizeResults", | ||
"id": 104, | ||
"moduleName": "\"aurelia-route-recognizer\"" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"groups": [ | ||
{ | ||
"title": "Constructors", | ||
"kind": 512, | ||
"children": [ | ||
105 | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"id": 85, | ||
@@ -1491,3 +1438,2 @@ "name": "RouteRecognizer", | ||
78, | ||
104, | ||
85, | ||
@@ -1494,0 +1440,0 @@ 62, |
@@ -0,1 +1,5 @@ | ||
### 1.0.0-beta.1.2.0 (2016-03-22) | ||
* Update to Babel 6 | ||
### 1.0.0-beta.1.1.3 (2016-03-02) | ||
@@ -2,0 +6,0 @@ |
@@ -22,8 +22,11 @@ var isparta = require('isparta'); | ||
babelPreprocessor: { | ||
'babelPreprocessor': { | ||
options: { | ||
loose: babelOptions.loose, | ||
stage: babelOptions.stage, | ||
optional: babelOptions.optional, | ||
sourceMap: 'inline' | ||
sourceMap: 'inline', | ||
presets: [ 'es2015-loose', 'stage-1'], | ||
plugins: [ | ||
'syntax-flow', | ||
'transform-decorators-legacy', | ||
'transform-flow-strip-types' | ||
] | ||
} | ||
@@ -30,0 +33,0 @@ }, |
{ | ||
"name": "aurelia-route-recognizer", | ||
"version": "1.0.0-beta.1.1.3", | ||
"version": "1.0.0-beta.1.2.0", | ||
"description": "A lightweight JavaScript library that matches paths against registered routes. It includes support for dynamic and star segments and nested handlers.", | ||
@@ -49,8 +49,17 @@ "keywords": [ | ||
"aurelia-tools": "0.1.16", | ||
"babel-dts-generator": "^0.2.17", | ||
"babel-dts-generator": "^0.4.7", | ||
"babel-eslint": "^4.1.1", | ||
"babel-plugin-syntax-flow": "^6.5.0", | ||
"babel-plugin-transform-decorators-legacy": "^1.3.4", | ||
"babel-plugin-transform-es2015-modules-amd": "^6.6.5", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.7.0", | ||
"babel-plugin-transform-es2015-modules-systemjs": "^6.6.5", | ||
"babel-plugin-transform-flow-strip-types": "^6.7.0", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-es2015-loose": "^7.0.0", | ||
"babel-preset-stage-1": "^6.5.0", | ||
"conventional-changelog": "0.0.11", | ||
"del": "^1.1.0", | ||
"gulp": "^3.8.10", | ||
"gulp-babel": "^5.2.1", | ||
"gulp-babel": "^6.1.2", | ||
"gulp-bump": "^0.3.1", | ||
@@ -69,3 +78,3 @@ "gulp-concat": "^2.5.2", | ||
"karma": "^0.13.21", | ||
"karma-babel-preprocessor": "^5.2.2", | ||
"karma-babel-preprocessor": "^6.0.1", | ||
"karma-chrome-launcher": "0.1.12", | ||
@@ -72,0 +81,0 @@ "karma-coverage": "github:douglasduteil/karma-coverage#next", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
415760
43
5779