Skip to content

Commit

Permalink
chore(all): prepare release 0.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Aug 14, 2015
1 parent e11312e commit 81d91e9
Show file tree
Hide file tree
Showing 13 changed files with 687 additions and 678 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-route-recognizer",
"version": "0.6.1",
"version": "0.6.2",
"description": "A lightweight JavaScript library that matches paths against registered routes. It includes support for dynamic and star segments and nested handlers.",
"keywords": [
"aurelia",
Expand Down
60 changes: 30 additions & 30 deletions dist/amd/aurelia-route-recognizer.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module 'aurelia-route-recognizer' {
import core from 'core-js';
import * as core from 'core-js';
export interface RouteHandler {
name: string;
}
Expand All @@ -22,6 +22,31 @@ declare module 'aurelia-route-recognizer' {
repeat?: boolean;
}

// 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 {
constructor(charSpec: CharSpec);
get(charSpec: CharSpec): State;
put(charSpec: CharSpec): State;

// 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.
//
Expand All @@ -40,53 +65,28 @@ declare module 'aurelia-route-recognizer' {
// * `repeat`: true if the character specification can repeat
export class StaticSegment {
constructor(string: string);
eachChar(callback: (spec: CharSpec) => void): any;
eachChar(callback: ((spec: CharSpec) => void)): void;
regex(): string;
generate(params: Object, consumed: Object): string;
}
export class DynamicSegment {
constructor(name: string);
eachChar(callback: (spec: CharSpec) => void): any;
eachChar(callback: ((spec: CharSpec) => void)): void;
regex(): string;
generate(params: Object, consumed: Object): string;
}
export class StarSegment {
constructor(name: string);
eachChar(callback: (spec: CharSpec) => void): any;
eachChar(callback: ((spec: CharSpec) => void)): void;
regex(): string;
generate(params: Object, consumed: Object): string;
}
export class EpsilonSegment {
eachChar(callback: (spec: CharSpec) => void): any;
eachChar(callback: ((spec: CharSpec) => void)): void;
regex(): string;
generate(params: Object, consumed: Object): 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.
export class State {
constructor(charSpec: CharSpec);
get(charSpec: CharSpec): State;
put(charSpec: CharSpec): State;

// Find a list of child states matching the next character
match(ch: string): State[];
}

/**
* Class that parses route patterns and matches path strings.
*
Expand Down
182 changes: 89 additions & 93 deletions dist/amd/aurelia-route-recognizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,88 @@ define(['exports', 'core-js'], function (exports, _coreJs) {

exports.__esModule = true;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var _core = _interopRequireDefault(_coreJs);
var State = (function () {
function State(charSpec) {
_classCallCheck(this, State);

this.charSpec = charSpec;
this.nextStates = [];
}

State.prototype.get = function get(charSpec) {
for (var _iterator = this.nextStates, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;

if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}

var child = _ref;

var isEqual = child.charSpec.validChars === charSpec.validChars && child.charSpec.invalidChars === charSpec.invalidChars;

if (isEqual) {
return child;
}
}
};

State.prototype.put = function put(charSpec) {
var state = this.get(charSpec);

if (state) {
return state;
}

state = new State(charSpec);

this.nextStates.push(state);

if (charSpec.repeat) {
state.nextStates.push(state);
}

return state;
};

State.prototype.match = function match(ch) {
var nextStates = this.nextStates,
results = [],
child,
charSpec,
chars;

for (var i = 0, l = nextStates.length; i < l; i++) {
child = nextStates[i];

charSpec = child.charSpec;

if (typeof (chars = charSpec.validChars) !== 'undefined') {
if (chars.indexOf(ch) !== -1) {
results.push(child);
}
} else if (typeof (chars = charSpec.invalidChars) !== 'undefined') {
if (chars.indexOf(ch) === -1) {
results.push(child);
}
}
}

return results;
};

return State;
})();

exports.State = State;
;

var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'];

Expand All @@ -21,19 +98,19 @@ define(['exports', 'core-js'], function (exports, _coreJs) {
}

StaticSegment.prototype.eachChar = function eachChar(callback) {
for (var _iterator = this.string, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
for (var _iterator2 = this.string, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;

if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}

var ch = _ref;
var ch = _ref2;

callback({ validChars: ch });
}
Expand Down Expand Up @@ -122,87 +199,6 @@ define(['exports', 'core-js'], function (exports, _coreJs) {

exports.EpsilonSegment = EpsilonSegment;

var State = (function () {
function State(charSpec) {
_classCallCheck(this, State);

this.charSpec = charSpec;
this.nextStates = [];
}

State.prototype.get = function get(charSpec) {
for (var _iterator2 = this.nextStates, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;

if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
}

var child = _ref2;

var isEqual = child.charSpec.validChars === charSpec.validChars && child.charSpec.invalidChars === charSpec.invalidChars;

if (isEqual) {
return child;
}
}
};

State.prototype.put = function put(charSpec) {
var state = this.get(charSpec);

if (state) {
return state;
}

state = new State(charSpec);

this.nextStates.push(state);

if (charSpec.repeat) {
state.nextStates.push(state);
}

return state;
};

State.prototype.match = function match(ch) {
var nextStates = this.nextStates,
results = [],
child,
charSpec,
chars;

for (var i = 0, l = nextStates.length; i < l; i++) {
child = nextStates[i];

charSpec = child.charSpec;

if (typeof (chars = charSpec.validChars) !== 'undefined') {
if (chars.indexOf(ch) !== -1) {
results.push(child);
}
} else if (typeof (chars = charSpec.invalidChars) !== 'undefined') {
if (chars.indexOf(ch) === -1) {
results.push(child);
}
}
}

return results;
};

return State;
})();

exports.State = State;
;

var RouteRecognizer = (function () {
function RouteRecognizer() {
_classCallCheck(this, RouteRecognizer);
Expand Down
Loading

0 comments on commit 81d91e9

Please sign in to comment.