1 | "use strict";
|
2 | var __extends = (this && this.__extends) || function (d, b) {
|
3 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
4 | function __() { this.constructor = d; }
|
5 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6 | };
|
7 | var async_1 = require('../src/facade/async');
|
8 | var collection_1 = require('../src/facade/collection');
|
9 | var lang_1 = require('../src/facade/lang');
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | var RouteParams = (function () {
|
42 | function RouteParams(params) {
|
43 | this.params = params;
|
44 | }
|
45 | RouteParams.prototype.get = function (param) { return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.params, param)); };
|
46 | return RouteParams;
|
47 | }());
|
48 | exports.RouteParams = RouteParams;
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | var RouteData = (function () {
|
83 | function RouteData(data) {
|
84 | if (data === void 0) { data = {}; }
|
85 | this.data = data;
|
86 | }
|
87 | RouteData.prototype.get = function (key) { return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.data, key)); };
|
88 | return RouteData;
|
89 | }());
|
90 | exports.RouteData = RouteData;
|
91 | exports.BLANK_ROUTE_DATA = new RouteData();
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 | var Instruction = (function () {
|
122 | function Instruction(component, child, auxInstruction) {
|
123 | this.component = component;
|
124 | this.child = child;
|
125 | this.auxInstruction = auxInstruction;
|
126 | }
|
127 | Object.defineProperty(Instruction.prototype, "urlPath", {
|
128 | get: function () { return lang_1.isPresent(this.component) ? this.component.urlPath : ''; },
|
129 | enumerable: true,
|
130 | configurable: true
|
131 | });
|
132 | Object.defineProperty(Instruction.prototype, "urlParams", {
|
133 | get: function () { return lang_1.isPresent(this.component) ? this.component.urlParams : []; },
|
134 | enumerable: true,
|
135 | configurable: true
|
136 | });
|
137 | Object.defineProperty(Instruction.prototype, "specificity", {
|
138 | get: function () {
|
139 | var total = '';
|
140 | if (lang_1.isPresent(this.component)) {
|
141 | total += this.component.specificity;
|
142 | }
|
143 | if (lang_1.isPresent(this.child)) {
|
144 | total += this.child.specificity;
|
145 | }
|
146 | return total;
|
147 | },
|
148 | enumerable: true,
|
149 | configurable: true
|
150 | });
|
151 | |
152 |
|
153 |
|
154 | Instruction.prototype.toRootUrl = function () { return this.toUrlPath() + this.toUrlQuery(); };
|
155 |
|
156 | Instruction.prototype._toNonRootUrl = function () {
|
157 | return this._stringifyPathMatrixAuxPrefixed() +
|
158 | (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
|
159 | };
|
160 | Instruction.prototype.toUrlQuery = function () { return this.urlParams.length > 0 ? ('?' + this.urlParams.join('&')) : ''; };
|
161 | |
162 |
|
163 |
|
164 |
|
165 | Instruction.prototype.replaceChild = function (child) {
|
166 | return new ResolvedInstruction(this.component, child, this.auxInstruction);
|
167 | };
|
168 | |
169 |
|
170 |
|
171 | Instruction.prototype.toUrlPath = function () {
|
172 | return this.urlPath + this._stringifyAux() +
|
173 | (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
|
174 | };
|
175 |
|
176 | Instruction.prototype.toLinkUrl = function () {
|
177 | return this.urlPath + this._stringifyAux() +
|
178 | (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '') + this.toUrlQuery();
|
179 | };
|
180 |
|
181 |
|
182 | Instruction.prototype._toLinkUrl = function () {
|
183 | return this._stringifyPathMatrixAuxPrefixed() +
|
184 | (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '');
|
185 | };
|
186 |
|
187 | Instruction.prototype._stringifyPathMatrixAuxPrefixed = function () {
|
188 | var primary = this._stringifyPathMatrixAux();
|
189 | if (primary.length > 0) {
|
190 | primary = '/' + primary;
|
191 | }
|
192 | return primary;
|
193 | };
|
194 |
|
195 | Instruction.prototype._stringifyMatrixParams = function () {
|
196 | return this.urlParams.length > 0 ? (';' + this.urlParams.join(';')) : '';
|
197 | };
|
198 |
|
199 | Instruction.prototype._stringifyPathMatrixAux = function () {
|
200 | if (lang_1.isBlank(this.component) && lang_1.isBlank(this.urlPath)) {
|
201 | return '';
|
202 | }
|
203 | return this.urlPath + this._stringifyMatrixParams() + this._stringifyAux();
|
204 | };
|
205 |
|
206 | Instruction.prototype._stringifyAux = function () {
|
207 | var routes = [];
|
208 | collection_1.StringMapWrapper.forEach(this.auxInstruction, function (auxInstruction, _) {
|
209 | routes.push(auxInstruction._stringifyPathMatrixAux());
|
210 | });
|
211 | if (routes.length > 0) {
|
212 | return '(' + routes.join('//') + ')';
|
213 | }
|
214 | return '';
|
215 | };
|
216 | return Instruction;
|
217 | }());
|
218 | exports.Instruction = Instruction;
|
219 |
|
220 |
|
221 |
|
222 | var ResolvedInstruction = (function (_super) {
|
223 | __extends(ResolvedInstruction, _super);
|
224 | function ResolvedInstruction(component, child, auxInstruction) {
|
225 | _super.call(this, component, child, auxInstruction);
|
226 | }
|
227 | ResolvedInstruction.prototype.resolveComponent = function () {
|
228 | return async_1.PromiseWrapper.resolve(this.component);
|
229 | };
|
230 | return ResolvedInstruction;
|
231 | }(Instruction));
|
232 | exports.ResolvedInstruction = ResolvedInstruction;
|
233 |
|
234 |
|
235 |
|
236 | var DefaultInstruction = (function (_super) {
|
237 | __extends(DefaultInstruction, _super);
|
238 | function DefaultInstruction(component, child) {
|
239 | _super.call(this, component, child, {});
|
240 | }
|
241 | DefaultInstruction.prototype.toLinkUrl = function () { return ''; };
|
242 |
|
243 | DefaultInstruction.prototype._toLinkUrl = function () { return ''; };
|
244 | return DefaultInstruction;
|
245 | }(ResolvedInstruction));
|
246 | exports.DefaultInstruction = DefaultInstruction;
|
247 |
|
248 |
|
249 |
|
250 | var UnresolvedInstruction = (function (_super) {
|
251 | __extends(UnresolvedInstruction, _super);
|
252 | function UnresolvedInstruction(_resolver, _urlPath, _urlParams) {
|
253 | if (_urlPath === void 0) { _urlPath = ''; }
|
254 | if (_urlParams === void 0) { _urlParams = []; }
|
255 | _super.call(this, null, null, {});
|
256 | this._resolver = _resolver;
|
257 | this._urlPath = _urlPath;
|
258 | this._urlParams = _urlParams;
|
259 | }
|
260 | Object.defineProperty(UnresolvedInstruction.prototype, "urlPath", {
|
261 | get: function () {
|
262 | if (lang_1.isPresent(this.component)) {
|
263 | return this.component.urlPath;
|
264 | }
|
265 | if (lang_1.isPresent(this._urlPath)) {
|
266 | return this._urlPath;
|
267 | }
|
268 | return '';
|
269 | },
|
270 | enumerable: true,
|
271 | configurable: true
|
272 | });
|
273 | Object.defineProperty(UnresolvedInstruction.prototype, "urlParams", {
|
274 | get: function () {
|
275 | if (lang_1.isPresent(this.component)) {
|
276 | return this.component.urlParams;
|
277 | }
|
278 | if (lang_1.isPresent(this._urlParams)) {
|
279 | return this._urlParams;
|
280 | }
|
281 | return [];
|
282 | },
|
283 | enumerable: true,
|
284 | configurable: true
|
285 | });
|
286 | UnresolvedInstruction.prototype.resolveComponent = function () {
|
287 | var _this = this;
|
288 | if (lang_1.isPresent(this.component)) {
|
289 | return async_1.PromiseWrapper.resolve(this.component);
|
290 | }
|
291 | return this._resolver().then(function (instruction) {
|
292 | _this.child = lang_1.isPresent(instruction) ? instruction.child : null;
|
293 | return _this.component = lang_1.isPresent(instruction) ? instruction.component : null;
|
294 | });
|
295 | };
|
296 | return UnresolvedInstruction;
|
297 | }(Instruction));
|
298 | exports.UnresolvedInstruction = UnresolvedInstruction;
|
299 | var RedirectInstruction = (function (_super) {
|
300 | __extends(RedirectInstruction, _super);
|
301 | function RedirectInstruction(component, child, auxInstruction, _specificity) {
|
302 | _super.call(this, component, child, auxInstruction);
|
303 | this._specificity = _specificity;
|
304 | }
|
305 | Object.defineProperty(RedirectInstruction.prototype, "specificity", {
|
306 | get: function () { return this._specificity; },
|
307 | enumerable: true,
|
308 | configurable: true
|
309 | });
|
310 | return RedirectInstruction;
|
311 | }(ResolvedInstruction));
|
312 | exports.RedirectInstruction = RedirectInstruction;
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 | var ComponentInstruction = (function () {
|
326 | |
327 |
|
328 |
|
329 | function ComponentInstruction(urlPath, urlParams, data, componentType /** TODO #9100 */, terminal, specificity, params, routeName) {
|
330 | if (params === void 0) { params = null; }
|
331 | this.urlPath = urlPath;
|
332 | this.urlParams = urlParams;
|
333 | this.componentType = componentType;
|
334 | this.terminal = terminal;
|
335 | this.specificity = specificity;
|
336 | this.params = params;
|
337 | this.routeName = routeName;
|
338 | this.reuse = false;
|
339 | this.routeData = lang_1.isPresent(data) ? data : exports.BLANK_ROUTE_DATA;
|
340 | }
|
341 | return ComponentInstruction;
|
342 | }());
|
343 | exports.ComponentInstruction = ComponentInstruction;
|
344 |
|
\ | No newline at end of file |