Skip to content

Commit 0a19376

Browse files
refactor(imports): merge imports from ui-router-core
1 parent 2982613 commit 0a19376

File tree

12 files changed

+278
-301
lines changed

12 files changed

+278
-301
lines changed

src/ng1/directives/stateDirectives.ts

Lines changed: 203 additions & 181 deletions
Large diffs are not rendered by default.

src/ng1/directives/viewDirective.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
/** @module ng1_directives */ /** for typedoc */
2-
import { ng as angular } from '../../angular';
3-
import { IInterpolateService, IScope, ITranscludeFunction, IAugmentedJQuery,
4-
ICompileService, IControllerService, ITimeoutService } from "angular";
5-
6-
import {extend, unnestR, filter, tail} from "ui-router-core";
7-
import {isDefined, isFunction, isString} from "ui-router-core";
8-
import {trace} from "ui-router-core";
9-
import {ActiveUIView} from "ui-router-core";
2+
import { ng as angular } from "../../angular";
3+
import {
4+
IInterpolateService, IScope, ITranscludeFunction, IAugmentedJQuery,
5+
ICompileService, IControllerService, ITimeoutService
6+
} from "angular";
7+
8+
import {
9+
extend, unnestR, filter, tail, isDefined, isFunction, isString, trace, parse,
10+
ActiveUIView, TransitionService, ResolveContext, Transition, PathNode,
11+
Param, kebobString, HookRegOptions, ViewService, $QLike, Obj
12+
} from "ui-router-core";
1013
import {Ng1ViewConfig} from "../statebuilders/views";
11-
import {TransitionService} from "ui-router-core";
12-
import {parse} from "ui-router-core";
13-
import {ResolveContext} from "ui-router-core";
14-
import {Transition} from "ui-router-core";
15-
import {PathNode} from "ui-router-core";
16-
import {Param} from "ui-router-core";
17-
import {kebobString} from "ui-router-core";
18-
import {HookRegOptions} from "ui-router-core";
1914
import {Ng1Controller, Ng1StateDeclaration} from "../interface";
2015
import {getLocals} from "../services";
21-
import {ViewService} from "ui-router-core";
22-
import {$QLike} from "ui-router-core";
23-
import {Obj} from "ui-router-core";
2416

2517
/** @hidden */
2618
export type UIViewData = {

src/ng1/interface.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/** @module ng1 */ /** */
2-
import {StateDeclaration, _ViewDeclaration} from "ui-router-core";
3-
import {IInjectable} from "ui-router-core";
4-
import {Transition} from "ui-router-core";
5-
import {HookResult} from "ui-router-core";
2+
import { StateDeclaration, _ViewDeclaration, IInjectable, Transition, HookResult } from "ui-router-core";
63

74
/**
85
* The StateDeclaration object is used to define a state or nested state.

src/ng1/legacy/resolveService.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
/** @module ng1 */ /** */
2-
import {State} from "ui-router-core";
3-
import {PathNode} from "ui-router-core";
4-
import {ResolveContext} from "ui-router-core";
5-
import {Obj, mapObj} from "ui-router-core";
6-
import {resolvablesBuilder} from "ui-router-core";
2+
import { State, PathNode, ResolveContext, Obj, mapObj, resolvablesBuilder } from "ui-router-core";
73

84
/**
95
* Implementation of the legacy `$resolve` service for angular 1.

src/ng1/legacy/stateEvents.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@
1616
*
1717
* @module ng1_state_events
1818
*/ /** */
19-
import { ng as angular } from '../../angular';
19+
import { ng as angular } from "../../angular";
2020
import { IScope, IAngularEvent, IServiceProviderFactory } from "angular";
21-
22-
import {Obj} from "ui-router-core";
23-
import {TargetState} from "ui-router-core";
24-
import {StateService} from "ui-router-core";
25-
import {StateProvider} from "../stateProvider";
26-
import {Transition} from "ui-router-core";
27-
import {TransitionService} from "ui-router-core";
28-
import {UrlRouter} from "ui-router-core";
29-
import {HookResult} from "ui-router-core";
30-
import {UIInjector} from "ui-router-core";
21+
import {
22+
Obj, TargetState, StateService, Transition, TransitionService, UrlRouter, HookResult, UIInjector
23+
} from "ui-router-core";
24+
import { StateProvider } from "../stateProvider";
3125

3226
/**
3327
* An event broadcast on `$rootScope` when the state transition **begins**.
@@ -149,8 +143,8 @@ export var $stateChangeError: IAngularEvent;
149143
export var $stateNotFound: IAngularEvent;
150144

151145

152-
(function() {
153-
let {isFunction, isString} = angular;
146+
(function () {
147+
let { isFunction, isString } = angular;
154148

155149
function applyPairs(memo: Obj, keyValTuple: any[]) {
156150
let key: string, value: any;
@@ -210,15 +204,15 @@ export var $stateNotFound: IAngularEvent;
210204

211205
stateNotFoundHandler.$inject = ['$to$', '$from$', '$state', '$rootScope', '$urlRouter'];
212206
function stateNotFoundHandler($to$: TargetState, $from$: TargetState, injector: UIInjector): HookResult {
213-
let $state: StateService = injector.get('$state');
214-
let $rootScope: IScope = injector.get('$rootScope');
207+
let $state: StateService = injector.get('$state');
208+
let $rootScope: IScope = injector.get('$rootScope');
215209
let $urlRouter: UrlRouter = injector.get('$urlRouter');
216210

217211
interface StateNotFoundEvent extends IAngularEvent {
218212
retry: Promise<any>;
219213
}
220214

221-
let redirect = {to: $to$.identifier(), toParams: $to$.params(), options: $to$.options()};
215+
let redirect = { to: $to$.identifier(), toParams: $to$.params(), options: $to$.options() };
222216
let e = <StateNotFoundEvent> $rootScope.$broadcast('$stateNotFound', redirect, $from$.state(), $from$.params());
223217

224218
if (e.defaultPrevented || e.retry)
@@ -285,7 +279,7 @@ export var $stateNotFound: IAngularEvent;
285279
if (enabledStateEvents["$stateNotFound"])
286280
$stateProvider.onInvalid(stateNotFoundHandler);
287281
if (enabledStateEvents.$stateChangeStart)
288-
$transitions.onBefore({}, stateChangeStartHandler, {priority: 1000});
282+
$transitions.onBefore({}, stateChangeStartHandler, { priority: 1000 });
289283

290284
return {
291285
provider: $StateEventsProvider.prototype.instance

src/ng1/services.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,22 @@
1010
*/
1111

1212
/** for typedoc */
13-
import { ng as angular } from '../angular';
13+
import { ng as angular } from "../angular";
14+
import {
15+
IRootScopeService, IQService, ILocationService, ILocationProvider, IHttpService, ITemplateCacheService
16+
} from "angular";
17+
import {
18+
services, bindFunctions, removeFrom, applyPairs, prop, isObject, isString, trace,
19+
UIRouter, IInjectable, StateParams, TransitionService, StateService, UrlRouterProvider,
20+
UrlRouter, UrlMatcherFactory, ResolveContext, TypedMap
21+
} from "ui-router-core";
22+
import { resolveFactory } from "./legacy/resolveService";
23+
import { ng1ViewsBuilder, ng1ViewConfigFactory } from "./statebuilders/views";
24+
import { TemplateFactory } from "./templateFactory";
25+
import { StateProvider } from "./stateProvider";
26+
import { getStateHookBuilder } from "./statebuilders/onEnterExitRetain";
1427
import IInjectorService = angular.auto.IInjectorService;
15-
import { IRootScopeService, IQService, ILocationService, ILocationProvider, IHttpService, ITemplateCacheService } from 'angular';
16-
17-
import {UIRouter} from "ui-router-core";
18-
import {services, $InjectorLike} from "ui-router-core";
19-
import {bindFunctions, removeFrom, applyPairs, IInjectable} from "ui-router-core";
20-
import {TypedMap} from "ui-router-core"; // has or is using
21-
import {prop} from "ui-router-core";
22-
import {isObject, isString} from "ui-router-core";
23-
import {resolveFactory} from "./legacy/resolveService";
24-
import {trace} from "ui-router-core";
25-
import {ng1ViewsBuilder, ng1ViewConfigFactory} from "./statebuilders/views";
26-
import {TemplateFactory} from "./templateFactory";
27-
import {StateParams} from "ui-router-core";
28-
import {TransitionService} from "ui-router-core";
29-
import {StateService} from "ui-router-core";
30-
import {StateProvider} from "./stateProvider";
31-
import {UrlRouterProvider, UrlRouter} from "ui-router-core";
32-
import {UrlMatcherFactory} from "ui-router-core";
33-
import {getStateHookBuilder} from "./statebuilders/onEnterExitRetain";
34-
import {ResolveContext} from "ui-router-core";
28+
// has or is using
3529

3630
/** @hidden */
3731
let app = angular.module("ui.router.angular1", []);

src/ng1/stateFilters.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/** @module state */ /** for typedoc */
22

3-
import { ng as angular } from '../angular';
4-
import {Obj} from "ui-router-core";
5-
import {StateService} from "ui-router-core";
6-
import {StateOrName} from "ui-router-core";
3+
import { ng as angular } from "../angular";
4+
import { Obj, StateService, StateOrName } from "ui-router-core";
75

86
/**
97
* @ngdoc filter

src/ng1/stateProvider.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/** @module ng1 */ /** for typedoc */
2-
import {isObject} from "ui-router-core";
3-
import {bindFunctions} from "ui-router-core";
4-
import {BuilderFunction} from "ui-router-core";
5-
import {StateRegistry} from "ui-router-core";
6-
import {Ng1StateDeclaration} from "./interface";
7-
import {StateService, OnInvalidCallback} from "ui-router-core";
2+
import {
3+
isObject, bindFunctions, BuilderFunction, StateRegistry, StateService, OnInvalidCallback
4+
} from "ui-router-core";
5+
import { Ng1StateDeclaration } from "./interface";
86

97
/**
108
* @ngdoc object

src/ng1/statebuilders/onEnterExitRetain.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
/** @module ng1 */ /** */
2-
import {State} from "ui-router-core";
3-
import {TransitionStateHookFn, HookResult} from "ui-router-core";
4-
import {Transition} from "ui-router-core";
5-
import {services} from "ui-router-core";
6-
import {getLocals} from "../services";
7-
import {ResolveContext} from "ui-router-core";
8-
import {extend} from "ui-router-core";
9-
import {BuilderFunction} from "ui-router-core";
2+
import {
3+
State, TransitionStateHookFn, HookResult, Transition, services, ResolveContext, extend, BuilderFunction
4+
} from "ui-router-core";
5+
import { getLocals } from "../services";
106

117
/**
128
* This is a [[StateBuilder.builder]] function for angular1 `onEnter`, `onExit`,

src/ng1/statebuilders/views.ts

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
/** @module ng1 */ /** */
2-
import { ng as angular } from '../../angular';
2+
import { ng as angular } from "../../angular";
3+
import {
4+
State, Obj, pick, forEach, anyTrueR, unnestR, tail, extend, kebobString,
5+
isArray, isInjectable, isDefined, isString, isObject, services, trace,
6+
ViewConfig, ViewService, ViewConfigFactory, PathNode, ResolveContext, Resolvable, RawParams
7+
} from "ui-router-core";
8+
import { Ng1ViewDeclaration } from "../interface";
9+
import { TemplateFactory } from "../templateFactory";
310
import IInjectorService = angular.auto.IInjectorService;
411

5-
import {State} from "ui-router-core";
6-
import {Obj, pick, forEach, anyTrueR, unnestR, tail, extend} from "ui-router-core";
7-
import {kebobString} from "ui-router-core";
8-
import {ViewConfig} from "ui-router-core";
9-
import {Ng1ViewDeclaration} from "../interface";
10-
import {ViewService, ViewConfigFactory} from "ui-router-core";
11-
import {isArray, isInjectable, isDefined, isString, isObject} from "ui-router-core";
12-
import {services} from "ui-router-core";
13-
import {trace} from "ui-router-core";
14-
import {PathNode} from "ui-router-core";
15-
import {TemplateFactory} from "../templateFactory";
16-
import {ResolveContext} from "ui-router-core";
17-
import {Resolvable} from "ui-router-core";
18-
import {RawParams} from "ui-router-core";
19-
2012
export const ng1ViewConfigFactory: ViewConfigFactory = (path, view) =>
2113
[new Ng1ViewConfig(path, view)];
2214

@@ -36,8 +28,8 @@ export function ng1ViewsBuilder(state: State) {
3628
nonCompKeys = tplKeys.concat(ctrlKeys),
3729
allKeys = compKeys.concat(nonCompKeys);
3830

39-
let views: { [key:string]: Ng1ViewDeclaration } = {},
40-
viewsObject = state.views || {"$default": pick(state, allKeys)};
31+
let views: { [key: string]: Ng1ViewDeclaration } = {},
32+
viewsObject = state.views || { "$default": pick(state, allKeys) };
4133

4234
forEach(viewsObject, function (config: Ng1ViewDeclaration, name: string) {
4335
// Account for views: { "": { template... } }
@@ -53,9 +45,9 @@ export function ng1ViewsBuilder(state: State) {
5345
}
5446

5547
// Dynamically build a template like "<component-name input1='::$resolve.foo'></component-name>"
56-
config.templateProvider = ['$injector', function($injector: IInjectorService) {
48+
config.templateProvider = ['$injector', function ($injector: IInjectorService) {
5749
const resolveFor = (key: string) =>
58-
config.bindings && config.bindings[key] || key;
50+
config.bindings && config.bindings[key] || key;
5951
const prefix = angular.version.minor >= 3 ? "::" : "";
6052
const attributeTpl = (input: BindingTuple) => {
6153
var attrName = kebobString(input.name);
@@ -93,12 +85,12 @@ interface BindingTuple {
9385
// for ng 1.2 style, process the scope: { input: "=foo" }
9486
// for ng 1.3 through ng 1.5, process the component's bindToController: { input: "=foo" } object
9587
const scopeBindings = (bindingsObj: Obj) => Object.keys(bindingsObj || {})
96-
// [ 'input', [ '=foo', '=', 'foo' ] ]
97-
.map(key => [key, /^([=<@])[?]?(.*)/.exec(bindingsObj[key])])
98-
// skip malformed values
99-
.filter(tuple => isDefined(tuple) && isDefined(tuple[1]))
100-
// { name: ('foo' || 'input'), type: '=' }
101-
.map(tuple => ({ name: tuple[1][2] || tuple[0], type: tuple[1][1] } as BindingTuple));
88+
// [ 'input', [ '=foo', '=', 'foo' ] ]
89+
.map(key => [key, /^([=<@])[?]?(.*)/.exec(bindingsObj[key])])
90+
// skip malformed values
91+
.filter(tuple => isDefined(tuple) && isDefined(tuple[1]))
92+
// { name: ('foo' || 'input'), type: '=' }
93+
.map(tuple => ({ name: tuple[1][2] || tuple[0], type: tuple[1][1] } as BindingTuple));
10294

10395
// Given a directive definition, find its object input attributes
10496
// Use different properties, depending on the type of directive (component, bindToController, normal)
@@ -122,7 +114,8 @@ export class Ng1ViewConfig implements ViewConfig {
122114
template: string;
123115
locals: any; // TODO: delete me
124116

125-
constructor(public path: PathNode[], public viewDecl: Ng1ViewDeclaration) { }
117+
constructor(public path: PathNode[], public viewDecl: Ng1ViewDeclaration) {
118+
}
126119

127120
load() {
128121
let $q = services.$q;

src/ng1/templateFactory.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/** @module view */ /** for typedoc */
2-
import {isArray, isDefined, isFunction} from "ui-router-core";
3-
import {services} from "ui-router-core";
4-
import {Ng1ViewDeclaration} from "./interface";
5-
import {IInjectable, tail} from "ui-router-core";
6-
import {ResolveContext} from "ui-router-core";
7-
import {Resolvable} from "ui-router-core";
8-
import {RawParams} from "ui-router-core";
2+
import {
3+
isArray, isDefined, isFunction, services, IInjectable, tail, ResolveContext, Resolvable, RawParams
4+
} from "ui-router-core";
5+
import { Ng1ViewDeclaration } from "./interface";
96

107
/**
118
* Service which manages loading of templates from a ViewConfig.

src/ng1/viewScroll.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @module ng1 */ /** */
2-
import { ng as angular } from '../angular';
3-
import {IServiceProviderFactory} from "angular";
2+
import { ng as angular } from "../angular";
3+
import { IServiceProviderFactory } from "angular";
44
import IAnchorScrollService = angular.IAnchorScrollService;
55
import ITimeoutService = angular.ITimeoutService;
66

0 commit comments

Comments
 (0)