Skip to content

Commit 0315233

Browse files
committed
Remove Url service rule customizers
1 parent 79cbb22 commit 0315233

File tree

14 files changed

+45
-223
lines changed

14 files changed

+45
-223
lines changed

@types/router/router.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ export class RouterProvider {
1616
/**
1717
* @type {number}
1818
*/
19-
lastStartedTransitionId: number;
19+
_lastStartedTransitionId: number;
2020
/**
2121
* @type {Queue<import("./transition/transition.js").Transition>}
2222
*/
23-
transitionHistory: Queue<import("./transition/transition.js").Transition>;
23+
_transitionHistory: Queue<import("./transition/transition.js").Transition>;
2424
/**
2525
* @type {Queue<import("./transition/transition.js").Transition>}
2626
*/
27-
successfulTransitions: Queue<import("./transition/transition.js").Transition>;
27+
_successfulTransitions: Queue<
28+
import("./transition/transition.js").Transition
29+
>;
2830
/**
2931
* @type {import("./state/interface.ts").StateDeclaration|undefined}
3032
*/

@types/router/state/state-builder.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ export class StateBuilder {
6464
matcher: import("./state-matcher.js").StateMatcher,
6565
urlService: ng.UrlService,
6666
);
67-
matcher: import("./state-matcher.js").StateMatcher;
68-
$injector: any;
69-
builders: {
67+
_matcher: import("./state-matcher.js").StateMatcher;
68+
_$injector: any;
69+
_builders: {
7070
name: ((state: any) => any)[];
7171
self: (typeof selfBuilder)[];
7272
parent: ((

@types/router/state/state-service.d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ export class StateProvider {
3434
* @deprecated This is a passthrough through to [[Router.$current]]
3535
*/
3636
get $current(): import("./state-object.js").StateObject;
37-
globals: import("../router.js").RouterProvider;
38-
transitionService: import("../transition/transition-service.js").TransitionProvider;
37+
/**
38+
* @type {ng.RouterProvider}
39+
*/
40+
globals: ng.RouterProvider;
41+
/**
42+
* @type {ng.TransitionProvider}
43+
*/
44+
transitionService: ng.TransitionProvider;
3945
stateRegistry: any;
4046
/** @type {ng.UrlService} */
4147
urlService: ng.UrlService;

@types/router/url/url-rules.d.ts

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -15,88 +15,6 @@ export class UrlRules {
1515
_rules: any[];
1616
_id: number;
1717
_urlRuleFactory: UrlRuleFactory;
18-
/**
19-
* Defines the initial state, path, or behavior to use when the app starts.
20-
*
21-
* This rule defines the initial/starting state for the application.
22-
*
23-
* This rule is triggered the first time the URL is checked (when the app initially loads).
24-
* The rule is triggered only when the url matches either `""` or `"/"`.
25-
*
26-
* Note: The rule is intended to be used when the root of the application is directly linked to.
27-
* When the URL is *not* `""` or `"/"` and doesn't match other rules, the [[otherwise]] rule is triggered.
28-
* This allows 404-like behavior when an unknown URL is deep-linked.
29-
*
30-
* #### Example:
31-
* Start app at `home` state.
32-
* ```js
33-
* .initial({ state: 'home' });
34-
* ```
35-
*
36-
* #### Example:
37-
* Start app at `/home` (by url)
38-
* ```js
39-
* .initial('/home');
40-
* ```
41-
*
42-
* #### Example:
43-
* When no other url rule matches, go to `home` state
44-
* ```js
45-
* .initial((matchValue, url, router) => {
46-
* console.log('initial state');
47-
* return { state: 'home' };
48-
* })
49-
* ```
50-
*
51-
* @param handler The initial state or url path, or a function which returns the state or url path (or performs custom logic).
52-
*/
53-
initial(handler: any): void;
54-
/**
55-
* Defines the state, url, or behavior to use when no other rule matches the URL.
56-
*
57-
* This rule is matched when *no other rule* matches.
58-
* It is generally used to handle unknown URLs (similar to "404" behavior, but on the client side).
59-
*
60-
* - If `handler` a string, it is treated as a url redirect
61-
*
62-
* #### Example:
63-
* When no other url rule matches, redirect to `/index`
64-
* ```js
65-
* .otherwise('/index');
66-
* ```
67-
*
68-
* - If `handler` is an object with a `state` property, the state is activated.
69-
*
70-
* #### Example:
71-
* When no other url rule matches, redirect to `home` and provide a `dashboard` parameter value.
72-
* ```js
73-
* .otherwise({ state: 'home', params: { dashboard: 'default' } });
74-
* ```
75-
*
76-
* - If `handler` is a function, the function receives the current url ([[UrlParts]]) and the [[UIRouter]] object.
77-
* The function can perform actions, and/or return a value.
78-
*
79-
* #### Example:
80-
* When no other url rule matches, manually trigger a transition to the `home` state
81-
* ```js
82-
* .otherwise((matchValue, urlParts, router) => {
83-
* router.stateService.go('home');
84-
* });
85-
* ```
86-
*
87-
* #### Example:
88-
* When no other url rule matches, go to `home` state
89-
* ```js
90-
* .otherwise((matchValue, urlParts, router) => {
91-
* return { state: 'home' };
92-
* });
93-
* ```
94-
*
95-
* @param handler The url path to redirect to, or a function which returns the url path (or performs custom logic).
96-
*/
97-
otherwise(handler: any): void;
98-
_otherwiseFn: import("./url-rule.js").BaseUrlRule;
99-
_sorted: boolean;
10018
/**
10119
* Remove a rule previously registered
10220
*
@@ -116,6 +34,7 @@ export class UrlRules {
11634
* @returns {() => void } a function that deregisters the rule
11735
*/
11836
rule(rule: any): () => void;
37+
_sorted: boolean;
11938
/**
12039
* Gets all registered rules
12140
*

src/router/hooks/update-globals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const updateGlobalState = (trans) => {
1818
const globals = trans._globals;
1919

2020
const transitionSuccessful = () => {
21-
globals.successfulTransitions.enqueue(trans);
21+
globals._successfulTransitions.enqueue(trans);
2222
globals.$current = trans.$to();
2323
globals.current = globals.$current.self;
2424
copy(trans.params(), globals.params);

src/router/router-test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
requireBase: false,
1717
rewriteLinks: false,
1818
};
19+
debugger;
1920
$stateProvider
2021
.state({
2122
name: "home",

src/router/router.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ export class RouterProvider {
2222
/**
2323
* @type {number}
2424
*/
25-
this.lastStartedTransitionId = -1;
25+
this._lastStartedTransitionId = -1;
2626

2727
/**
2828
* @type {Queue<import("./transition/transition.js").Transition>}
2929
*/
30-
this.transitionHistory = new Queue([], 1);
30+
this._transitionHistory = new Queue([], 1);
3131

3232
/**
3333
* @type {Queue<import("./transition/transition.js").Transition>}
3434
*/
35-
this.successfulTransitions = new Queue([], 1);
35+
this._successfulTransitions = new Queue([], 1);
3636

3737
/**
3838
* @type {import("./state/interface.ts").StateDeclaration|undefined}

src/router/state/state-builder.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ export class StateBuilder {
302302
* @param {ng.UrlService} urlService
303303
*/
304304
constructor(matcher, urlService) {
305-
this.matcher = matcher;
306-
this.$injector = undefined;
305+
this._matcher = matcher;
306+
this._$injector = undefined;
307307
const self = this;
308308

309309
const root = () => matcher.find("");
@@ -313,7 +313,7 @@ export class StateBuilder {
313313

314314
return matcher.find(self.parentName(state)) || root();
315315
}
316-
this.builders = {
316+
this._builders = {
317317
name: [(state) => state.name],
318318
self: [selfBuilder],
319319
parent: [parentBuilder],
@@ -336,7 +336,7 @@ export class StateBuilder {
336336
}
337337

338338
builder(name, fn) {
339-
const { builders } = this;
339+
const { _builders: builders } = this;
340340

341341
const array = builders[name] || [];
342342

@@ -359,7 +359,7 @@ export class StateBuilder {
359359
* @returns the built State object
360360
*/
361361
build(state) {
362-
const { matcher, builders } = this;
362+
const { _matcher: matcher, _builders: builders } = this;
363363

364364
const parent = this.parentName(state);
365365

src/router/state/state-matcher.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ export class StateMatcher {
3030
} else if (isStr && matchGlob) {
3131
const states = Object.values(this._states);
3232

33-
const matches = states.filter(
34-
(stateObj) =>
35-
stateObj._stateObjectCache.nameGlob &&
36-
stateObj._stateObjectCache.nameGlob.matches(name),
33+
const matches = states.filter((stateObj) =>
34+
stateObj._stateObjectCache.nameGlob?.matches(name),
3735
);
3836

3937
if (matches.length > 1) {

src/router/state/state-registry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class StateRegistryProvider {
7070
*/
7171
($injector) => {
7272
this.$injector = $injector;
73-
this.builder.$injector = $injector;
73+
this.builder._$injector = $injector;
7474

7575
return this;
7676
},

0 commit comments

Comments
 (0)