Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"docs": "generate_docs",
"docs:publish": "generate_docs && publish_docs",
"prepublishOnly": "echo && echo DO NOT RUN npm publish. Instead, run npm run release && echo && echo && false",
"changelog": "update_changelog --include-core"
"changelog": "update_changelog --include-core",
"prepare": "husky"
},
"homepage": "https://ui-router.github.io/angular",
"contributors": [
Expand Down Expand Up @@ -52,7 +53,7 @@
"@uirouter/rx": "^1.0.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^21.0.2",
"@angular-devkit/build-angular": "^21.0.4",
"@angular/common": "^21.0.3",
"@angular/compiler": "^21.0.3",
"@angular/compiler-cli": "^21.0.3",
Expand All @@ -64,23 +65,18 @@
"@uirouter/core": "^6.1.2",
"@uirouter/publish-scripts": "2.6.4",
"@uirouter/rx": "^1.0.0",
"husky": "^7.0.4",
"husky": "^9.0.0",
"jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0",
"jest-preset-angular": "^16.0.0",
"jsdom": "^27.2.0",
"jsdom": "^27.4.0",
"ng-packagr": "^21.0.0",
"picomatch": "4.0.3",
"postcss": "^8.5.6",
"prettier": "^2.8.8",
"pretty-quick": "^3.3.1",
"prettier": "^3.4.0",
"pretty-quick": "^4.0.0",
"rxjs": "~7.8.2",
"schema-utils": "^4.3.3",
"ts-node": "10.9.2",
"tslib": "^2.8.1",
"tslint": "^6.1.0",
"typescript": "~5.9.3",
"vite": "7.2.6",
"zone.js": "~0.16.0"
},
"jest": {
Expand All @@ -95,11 +91,6 @@
"terser"
]
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
},
"docgen": {
"publishDir": "_ng2_docs",
"navigation": {
Expand Down
20 changes: 16 additions & 4 deletions src/directives/uiSref.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { UIRouter, extend, Obj, StateOrName, TransitionOptions, TargetState, isNumber, isNullOrUndefined } from '@uirouter/core';
import {
UIRouter,
extend,
Obj,
StateOrName,
TransitionOptions,
TargetState,
isNumber,
isNullOrUndefined,
} from '@uirouter/core';
import {
Directive,
Inject,
Expand All @@ -19,10 +28,13 @@ import { ReplaySubject, Subscription } from 'rxjs';
*/
@Directive({
selector: 'a[uiSref]',
standalone: true
standalone: true,
})
export class AnchorUISref {
constructor(public _el: ElementRef, public _renderer: Renderer2) {}
constructor(
public _el: ElementRef,
public _renderer: Renderer2
) {}

openInNewTab() {
return this._el.nativeElement.target === '_blank';
Expand Down Expand Up @@ -81,7 +93,7 @@ export class AnchorUISref {
@Directive({
selector: '[uiSref]',
exportAs: 'uiSref',
standalone: true
standalone: true,
})
export class UISref implements OnChanges {
/**
Expand Down
12 changes: 7 additions & 5 deletions src/directives/uiSrefActive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ import { Subscription } from 'rxjs';
*/
@Directive({
selector: '[uiSrefActive],[uiSrefActiveEq]',
hostDirectives: [{
directive: UISrefStatus,
outputs: ['uiSrefStatus']
}],
standalone: true
hostDirectives: [
{
directive: UISrefStatus,
outputs: ['uiSrefStatus'],
},
],
standalone: true,
})
export class UISrefActive {
private _classes: string[] = [];
Expand Down
4 changes: 2 additions & 2 deletions src/directives/uiSrefStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function mergeSrefStatus(left: SrefStatus, right: SrefStatus): SrefStatus {
@Directive({
selector: '[uiSrefStatus]',
exportAs: 'uiSrefStatus',
standalone: true
standalone: true,
})
export class UISrefStatus {
/** current statuses of the state/params the uiSref directive is linking to */
Expand Down Expand Up @@ -210,7 +210,7 @@ export class UISrefStatus {
// start -> (success|error)
const transEvents$: Observable<TransEvt> = this._globals.start$.pipe(
switchMap((trans: Transition) => {
const event = (evt: string) => ({ evt, trans } as TransEvt);
const event = (evt: string) => ({ evt, trans }) as TransEvt;

const transStart$ = of(event('start'));
const transResult = trans.promise.then(
Expand Down
2 changes: 1 addition & 1 deletion src/directives/uiView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface InputMapping {
*/
function ng2ComponentInputs<T>(mirror: ComponentMirror<T>): InputMapping[] {
return mirror.inputs.map((input) => ({ prop: input.templateName, token: input.templateName }));
};
}

/**
* A UI-Router viewport directive, which is filled in by a view (component) on a state.
Expand Down
27 changes: 14 additions & 13 deletions src/lazyLoad/lazyLoadNgModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ export function loadNgModule<T>(
moduleToLoad: ModuleTypeCallback<T>
): (transition: Transition, stateObject: StateDeclaration) => Promise<LazyLoadResult> {
return (transition: Transition, stateObject: StateDeclaration) => {

const ng2Injector = transition.injector().get(NATIVE_INJECTOR_TOKEN);

return loadModuleFactory(moduleToLoad, ng2Injector)
.then(moduleRef => applyNgModule(moduleRef, ng2Injector, stateObject));
return loadModuleFactory(moduleToLoad, ng2Injector).then((moduleRef) =>
applyNgModule(moduleRef, ng2Injector, stateObject)
);
};
}

Expand All @@ -79,7 +79,6 @@ export function loadModuleFactory<T>(
moduleToLoad: ModuleTypeCallback<T>,
ng2Injector: Injector
): Promise<NgModuleRef<T>> {

return Promise.resolve(moduleToLoad())
.then(_unwrapEsModuleDefault)
.then((t: Type<T>) => createNgModule(t, ng2Injector));
Expand Down Expand Up @@ -172,7 +171,11 @@ export function applyNgModule<T>(
*
* @internal
*/
export function multiProviderParentChildDelta<T>(parent: Injector, child: Injector, token: InjectionToken<T>): RootModule[] {
export function multiProviderParentChildDelta<T>(
parent: Injector,
child: Injector,
token: InjectionToken<T>
): RootModule[] {
const childVals: RootModule[] = child.get<RootModule[]>(token, []);
const parentVals: RootModule[] = parent.get<RootModule[]>(token, []);
return childVals.filter((val) => parentVals.indexOf(val) === -1);
Expand Down Expand Up @@ -214,11 +217,10 @@ export function loadComponent<T>(
callback: ComponentTypeCallback<T>
): (transition: Transition, stateObject: Ng2StateDeclaration) => Promise<LazyLoadResult> {
return (transition: Transition, stateObject: Ng2StateDeclaration) => {

return Promise.resolve(callback())
.then(_unwrapEsModuleDefault)
.then((component: Type<T>) => applyComponent(component, transition, stateObject))
}
.then((component: Type<T>) => applyComponent(component, transition, stateObject));
};
}

/**
Expand All @@ -236,14 +238,13 @@ export function applyComponent<T>(
transition: Transition,
stateObject: Ng2StateDeclaration
): LazyLoadResult {

if (!isStandalone(component)) throw new Error("Is not a standalone component.");
if (!isStandalone(component)) throw new Error('Is not a standalone component.');

const registry = transition.router.stateRegistry;
const current = stateObject.component;
stateObject.component = component || current;
const removed = registry.deregister(stateObject).map(child => child.self);
const children = removed.filter(i => i.name != stateObject.name);
const removed = registry.deregister(stateObject).map((child) => child.self);
const children = removed.filter((i) => i.name != stateObject.name);

return { states: [stateObject, ...children] }
return { states: [stateObject, ...children] };
}
5 changes: 4 additions & 1 deletion src/location/locationConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { UIRouter, is, BrowserLocationConfig } from '@uirouter/core';
import { LocationStrategy, PathLocationStrategy } from '@angular/common';

export class Ng2LocationConfig extends BrowserLocationConfig {
constructor(router: UIRouter, private _locationStrategy: LocationStrategy) {
constructor(
router: UIRouter,
private _locationStrategy: LocationStrategy
) {
super(router, is(PathLocationStrategy)(_locationStrategy));
}

Expand Down
6 changes: 5 additions & 1 deletion src/location/locationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { LocationStrategy } from '@angular/common';

/** A `LocationServices` that delegates to the Angular LocationStrategy */
export class Ng2LocationServices extends BaseLocationServices {
constructor(router: UIRouter, private _locationStrategy: LocationStrategy, isBrowser: boolean) {
constructor(
router: UIRouter,
private _locationStrategy: LocationStrategy,
isBrowser: boolean
) {
super(router, isBrowser);

this._locationStrategy.onPopState((evt) => {
Expand Down
6 changes: 3 additions & 3 deletions src/provideUiRouter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EnvironmentProviders, makeEnvironmentProviders } from "@angular/core";
import { locationStrategy, makeRootProviders, RootModule } from "./uiRouterNgModule";
import { _UIROUTER_INSTANCE_PROVIDERS, _UIROUTER_SERVICE_PROVIDERS } from "./providers";
import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';
import { locationStrategy, makeRootProviders, RootModule } from './uiRouterNgModule';
import { _UIROUTER_INSTANCE_PROVIDERS, _UIROUTER_SERVICE_PROVIDERS } from './providers';

/**
* Sets up providers necessary to enable UI-Router for the application. Intended as a replacement
Expand Down
6 changes: 5 additions & 1 deletion src/statebuilders/lazyLoad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@ import { loadComponent, loadNgModule } from '../lazyLoad/lazyLoadNgModule';
export function ng2LazyLoadBuilder(state: StateObject, parent: BuilderFunction) {
const loadComponentFn = state['loadComponent'];
const loadNgModuleFn = state['loadChildren'];
return loadComponentFn ? loadComponent(loadComponentFn) : loadNgModuleFn ? loadNgModule(loadNgModuleFn) : state.lazyLoad;
return loadComponentFn
? loadComponent(loadComponentFn)
: loadNgModuleFn
? loadNgModule(loadNgModuleFn)
: state.lazyLoad;
}
5 changes: 4 additions & 1 deletion src/statebuilders/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export class Ng2ViewConfig implements ViewConfig {
$id: number = id++;
loaded = true;

constructor(public path: PathNode[], public viewDecl: Ng2ViewDeclaration) {}
constructor(
public path: PathNode[],
public viewDecl: Ng2ViewDeclaration
) {}

load() {
return services.$q.when(this);
Expand Down
16 changes: 3 additions & 13 deletions src/uiRouterNgModule.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { UIROUTER_MODULE_TOKEN, UIROUTER_ROOT_MODULE } from './injectionTokens';
import { Ng2StateDeclaration } from './interface';
import {
NgModule,
ModuleWithProviders,
Provider,
Injector,
APP_INITIALIZER,
} from '@angular/core';
import { NgModule, ModuleWithProviders, Provider, Injector, APP_INITIALIZER } from '@angular/core';
import { LocationStrategy, HashLocationStrategy, PathLocationStrategy } from '@angular/common';
import { _UIROUTER_DIRECTIVES } from './directives/directives';
import { UrlRuleHandlerFn, TargetState, TargetStateDef, UIRouter, TransitionService } from '@uirouter/core';
Expand Down Expand Up @@ -43,9 +37,7 @@ export function makeRootProviders(module: RootModule): Provider[] {
}

export function makeChildProviders(module: StatesModule): Provider[] {
return [
{ provide: UIROUTER_MODULE_TOKEN, useValue: module, multi: true },
];
return [{ provide: UIROUTER_MODULE_TOKEN, useValue: module, multi: true }];
}

export function locationStrategy(useHash) {
Expand All @@ -70,9 +62,7 @@ export function locationStrategy(useHash) {
* This enables UI-Router to automatically register the states with the [[StateRegistry]] at bootstrap (and during lazy load).
*/
@NgModule({
imports: [
_UIROUTER_DIRECTIVES
],
imports: [_UIROUTER_DIRECTIVES],
exports: [_UIROUTER_DIRECTIVES],
})
export class UIRouterModule {
Expand Down
Loading