Skip to content

Commit f5fd578

Browse files
chore(core): Export all symbols into global namespace for typescript importing
chore(*): Remove /// <ref path='...d.ts'>
1 parent b7da092 commit f5fd578

24 files changed

+56
-94
lines changed

Gruntfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ module.exports = function (grunt) {
170170

171171
grunt.registerTask('docs', 'Generate documentation to _doc', function() {
172172
promising(this,
173-
system('./node_modules/typedoc/bin/typedoc --experimentalDecorators --readme ./README.md --name "UI-Router" --theme ./typedoctheme --mode modules --module commonjs --target es5 --out _doc src')
173+
system('./node_modules/typedoc/bin/typedoc --experimentalDecorators --readme ./README.md --name "UI-Router" --theme ./typedoctheme --mode modules --module commonjs --target es5 --out _doc src typings/es6-shim/es6-shim.d.ts typings/angularjs/angular.d.ts')
174174
);
175175
});
176176

src/core.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
/// <reference path='../typings/angularjs/angular.d.ts' />
2-
/// <reference path='../typings/es6-shim/es6-shim.d.ts' />
31
/** @module core */ /** */
42

5-
import * as common from "./common/module";
6-
import * as params from "./params/module";
7-
import * as path from "./path/module";
8-
import * as resolve from "./resolve/module";
9-
import * as state from "./state/module";
10-
import * as transition from "./transition/module";
11-
import * as url from "./url/module";
12-
import * as view from "./view/module";
3+
export * from "./common/module";
4+
export * from "./params/module";
5+
export * from "./path/module";
6+
export * from "./resolve/module";
7+
export * from "./state/module";
8+
export * from "./transition/module";
9+
export * from "./url/module";
10+
export * from "./view/module";
1311

14-
export { common, params, path, resolve, state, transition, url, view };
1512
export { UIRouter } from "./router";

src/ng1.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/// <reference path='../typings/angularjs/angular.d.ts' />
2-
/// <reference path='../typings/es6-shim/es6-shim.d.ts' />
31
/**
42
* Main entry point for angular 1.x build
53
* @module ng1

src/ng1/services.ts

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
* @preferred
1010
*/
1111

12-
/// <reference path='../../typings/angularjs/angular.d.ts' />
13-
/// <reference path='../../typings/es6-shim/es6-shim.d.ts' />
14-
1512
/** for typedoc */
1613
import {UIRouter} from "../router";
1714
import {services} from "../common/coreservices";

src/ng1/stateDirectives.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/** @module state */ /** for typedoc */
2-
/// <reference path='../../typings/angularjs/angular.d.ts' />
32
import {extend, forEach, toJson} from "../common/common";
43
import {isString, isObject} from "../common/predicates";
54
import {UIViewData} from "./viewDirective";

src/ng1/stateEvents.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
/** for typedoc */
2121
import {IServiceProviderFactory} from "angular";
22-
import {StateService, StateProvider} from "../state/interface";
23-
import {TargetState} from "../state/module";
22+
import {TargetState, StateService, StateProvider} from "../state/module";
2423
import {Transition} from "../transition/transition";
2524

2625
/**
@@ -211,7 +210,7 @@ var $stateNotFound;
211210

212211
if (e.defaultPrevented) {
213212
return false;
214-
} else if (e.retry || $state.get(redirect.to)) {
213+
} else if (e.retry || !!$state.get(redirect.to)) {
215214
return e.retry && isFunction(e.retry.then) ? e.retry.then(redirectFn) : redirectFn();
216215
}
217216
}

src/ng2.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference path='../typings/es6-shim/es6-shim.d.ts' />
21
/**
32
* Main entry point for angular 2.x build
43
* @module ng2

src/params/module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @preferred doc
77
*/
88
/** for typedoc */
9+
export * from "./interface";
910
export * from "./param";
1011
export * from "./paramTypes";
1112
export * from "./stateParams";

src/path/node.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {RawParams} from "../params/interface";
66
import {Param} from "../params/module";
77
import {Resolvable, ResolveContext, ResolveInjector} from "../resolve/module";
88
import {ViewConfig} from "../view/interface";
9-
10-
export type Resolvables = { [key: string]: Resolvable };
9+
import {Resolvables} from "../resolve/interface";
1110

1211
export class Node {
1312
public paramSchema: Param[];

src/resolve/module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/** @module path */ /** for typedoc */
2+
export * from "./interface";
23
export * from "./resolvable";
34
export * from "./resolveContext";
45
export * from "./resolveInjector";

src/state/hooks/transitionManager.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {TreeChanges} from "../../transition/interface";
88
import {Transition} from "../../transition/transition";
99
import {TransitionRejection, RejectType} from "../../transition/rejectFactory";
1010

11-
import {StateService, StateDeclaration} from "../interface";
11+
import {StateDeclaration} from "../interface";
12+
import {StateService} from "../stateService";
1213
import {TargetState} from "../targetState";
1314
import {ViewHooks} from "./viewHooks";
1415
import {EnterExitHooks} from "./enterExitHooks";
@@ -115,9 +116,10 @@ export class TransitionManager {
115116
}
116117

117118
updateStateParams() {
118-
let {transition, $urlRouter, $state, $stateParams} = this;
119+
let transition = this.transition;
120+
let {$urlRouter, $state, $stateParams} = this;
119121
let options = transition.options();
120-
$state.params = transition.params();
122+
copy(transition.params(), $state.params);
121123
copy($state.params, $stateParams);
122124

123125
if (options.location && $state.$current.navigable) {

src/state/interface.ts

-33
Original file line numberDiff line numberDiff line change
@@ -318,43 +318,10 @@ export interface StateDeclaration {
318318
reloadOnSearch?: boolean;
319319
}
320320

321-
export interface StateParams {
322-
$digest: () => void;
323-
$inherit: (newParams, $current: State, $to: State) => StateParams;
324-
$set: (params, url) => boolean;
325-
$sync: () => StateParams;
326-
$off: () => StateParams;
327-
$raw: () => any;
328-
$localize: () => StateParams;
329-
$observe: (key, fn) => () => void;
330-
}
331-
332321
export interface HrefOptions {
333322
relative?: StateOrName;
334323
lossy?: boolean;
335324
inherit?: boolean;
336325
absolute?: boolean;
337326
}
338327

339-
export interface StateProvider {
340-
state(state: StateDeclaration): StateProvider;
341-
state(name: string, state: StateDeclaration): StateProvider;
342-
onInvalid(callback: Function): void;
343-
decorator(name: string, func: Function);
344-
}
345-
346-
export interface StateService {
347-
params: any; // TODO: StateParams
348-
current: StateDeclaration;
349-
$current: State;
350-
transition: Transition;
351-
reload (stateOrName: StateOrName): Promise<State>;
352-
target (identifier: StateOrName, params: ParamsOrArray, options: TransitionOptions): TargetState;
353-
go (to: StateOrName, params: RawParams, options: TransitionOptions): Promise<State>;
354-
transitionTo (to: StateOrName, toParams: ParamsOrArray, options: TransitionOptions): Promise<State>;
355-
is (stateOrName: StateOrName, params?: RawParams, options?: TransitionOptions): boolean;
356-
includes (stateOrName: StateOrName, params?: RawParams, options?: TransitionOptions): boolean;
357-
href (stateOrName: StateOrName, params?: RawParams, options?: HrefOptions): string;
358-
get (stateOrName: StateOrName, base?: StateOrName): (StateDeclaration|StateDeclaration[]);
359-
}
360-

src/state/module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/** @module state */ /** for typedoc */
2+
export * from "./interface";
23
export * from "./state";
34
export * from "./stateBuilder";
45
export * from "./hooks/transitionManager";

src/state/stateQueueManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {isString} from "../common/predicates";
44
import {StateDeclaration} from "./interface";
55
import {State} from "./module";
66
import {StateBuilder} from "./stateBuilder";
7-
import {StateService} from "./interface";
7+
import {StateService} from "./stateService";
88

99
export class StateQueueManager {
1010
queue: State[];

src/state/stateService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ export class StateService {
474474
* @returns {Object|Array} State configuration object or array of all objects.
475475
*/
476476
get(): StateDeclaration[];
477+
get(stateOrName: StateOrName): StateDeclaration;
477478
get(stateOrName: StateOrName, base: StateOrName): StateDeclaration;
478479
get(stateOrName?: StateOrName, base?: StateOrName): any {
479480
if (arguments.length === 0) return this.stateRegistry.get();

src/transition/module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @preferred
88
*/
99
/** for typedoc */
10+
export * from "./interface";
1011
export * from "./hookBuilder";
1112
export * from "./hookRegistry";
1213
export * from "./rejectFactory";

src/view/module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/** @module view */ /** for typedoc */
2+
export * from "./interface";
23
export * from "./templateFactory";
34
export * from "./view";

src/view/view.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class ViewService {
4444
*/
4545
deactivateViewConfig(viewConfig: ViewConfig) {
4646
trace.traceViewServiceEvent("<- Removing", viewConfig);
47-
removeFrom(this.viewConfigs, viewConfig)
47+
removeFrom(this.viewConfigs, viewConfig);
4848
};
4949

5050
activateViewConfig(viewConfig: ViewConfig) {

test/commonSpec.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
var module = angular.mock.module;
22
var uiRouter = require("angular-ui-router");
3-
var Glob = uiRouter.state.Glob;
4-
var common = uiRouter.common,
5-
defaults = common.defaults,
6-
filter = common.filter,
7-
is = common.is,
8-
eq = common.eq,
9-
not = common.not,
10-
pattern = common.pattern,
11-
val = common.val,
12-
isInjectable = common.isInjectable;
3+
var Glob = uiRouter.Glob,
4+
defaults = uiRouter.defaults,
5+
filter = uiRouter.filter,
6+
is = uiRouter.is,
7+
eq = uiRouter.eq,
8+
not = uiRouter.not,
9+
pattern = uiRouter.pattern,
10+
val = uiRouter.val,
11+
isInjectable = uiRouter.isInjectable;
1312

1413
describe('common', function() {
1514
describe('filter', function() {

test/globSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var uiRouter = require("angular-ui-router");
2-
var Glob = uiRouter.common.Glob;
2+
var Glob = uiRouter.Glob;
33

44
describe('Glob', function() {
55
it('should match glob strings', function() {

test/stateSpec.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
var module = angular.mock.module;
22
var uiRouter = require("angular-ui-router");
3-
var common = uiRouter.common;
4-
var RejectType = uiRouter.transition.RejectType;
5-
var extend = common.extend;
6-
var forEach = common.forEach;
7-
var services = common.services;
8-
var state = uiRouter.state;
9-
var StateMatcher = state.StateMatcher;
10-
var StateBuilder = uiRouter.state.StateBuilder;
11-
var TargetState = state.TargetState;
12-
var UrlMatcher = uiRouter.url.UrlMatcher;
3+
var RejectType = uiRouter.RejectType;
4+
var extend = uiRouter.extend;
5+
var forEach = uiRouter.forEach;
6+
var services = uiRouter.services;
7+
var StateMatcher = uiRouter.StateMatcher;
8+
var StateBuilder = uiRouter.StateBuilder;
9+
var TargetState = uiRouter.TargetState;
10+
var UrlMatcher = uiRouter.UrlMatcher;
1311

1412
describe('state helpers', function() {
1513

test/urlMatcherFactorySpec.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
var module = angular.mock.module;
2-
var uiRouter = require("angular-ui-router");
3-
var Param = uiRouter.params.Param;
4-
var UrlMatcher = uiRouter.url.UrlMatcher;
5-
var common = uiRouter.common;
6-
var prop = common.prop;
1+
var module = angular.mock.module;
2+
var uiRouter = require("angular-ui-router");
3+
var Param = uiRouter.Param;
4+
var UrlMatcher = uiRouter.UrlMatcher;
5+
var prop = uiRouter.prop;
6+
var map = uiRouter.map;
7+
var find = uiRouter.find;
78

89
beforeEach(function() {
910
var app = angular.module('ui.router.router.test', []);
@@ -425,8 +426,8 @@ describe("UrlMatcher", function () {
425426

426427
// Pass again through Param.value() for normalization (like transitionTo)
427428
var paramDefs = m.parameters();
428-
var values = common.map(parsed, function(val, key) {
429-
return common.find(paramDefs, function(def) { return def.id === key }).value(val);
429+
var values = map(parsed, function(val, key) {
430+
return find(paramDefs, function(def) { return def.id === key }).value(val);
430431
});
431432
expect(values).toEqualData(expected);
432433
}));

test/urlRouterSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var module = angular.mock.module;
22
var uiRouter = require("angular-ui-router");
3-
var UrlMatcher = uiRouter.url.UrlMatcher;
4-
var services = uiRouter.common.services;
3+
var UrlMatcher = uiRouter.UrlMatcher;
4+
var services = uiRouter.services;
55

66
describe("UrlRouter", function () {
77

tsconfig-ng2.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"files": [
1616
"src/ng2.ts",
17-
"src/justjs.ts"
17+
"src/justjs.ts",
18+
"typings/es6-shim/es6-shim.d.ts"
1819
]
1920
}

0 commit comments

Comments
 (0)