1 | "use strict";
|
2 | var __assign = (this && this.__assign) || function () {
|
3 | __assign = Object.assign || function(t) {
|
4 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5 | s = arguments[i];
|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7 | t[p] = s[p];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | return __assign.apply(this, arguments);
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | exports.UrlMatcherFactory = exports.ParamFactory = void 0;
|
15 | var common_1 = require("../common");
|
16 | var urlMatcher_1 = require("./urlMatcher");
|
17 | var params_1 = require("../params");
|
18 | var ParamFactory = (function () {
|
19 | function ParamFactory(router) {
|
20 | this.router = router;
|
21 | }
|
22 | ParamFactory.prototype.fromConfig = function (id, type, state) {
|
23 | return new params_1.Param(id, type, params_1.DefType.CONFIG, this.router.urlService.config, state);
|
24 | };
|
25 | ParamFactory.prototype.fromPath = function (id, type, state) {
|
26 | return new params_1.Param(id, type, params_1.DefType.PATH, this.router.urlService.config, state);
|
27 | };
|
28 | ParamFactory.prototype.fromSearch = function (id, type, state) {
|
29 | return new params_1.Param(id, type, params_1.DefType.SEARCH, this.router.urlService.config, state);
|
30 | };
|
31 | return ParamFactory;
|
32 | }());
|
33 | exports.ParamFactory = ParamFactory;
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | var UrlMatcherFactory = (function () {
|
41 |
|
42 | function UrlMatcherFactory(/** @internal */ router) {
|
43 | var _this = this;
|
44 | this.router = router;
|
45 |
|
46 | this.paramFactory = new ParamFactory(this.router);
|
47 |
|
48 | this.UrlMatcher = urlMatcher_1.UrlMatcher;
|
49 | this.Param = params_1.Param;
|
50 |
|
51 | this.caseInsensitive = function (value) { return _this.router.urlService.config.caseInsensitive(value); };
|
52 |
|
53 | this.defaultSquashPolicy = function (value) { return _this.router.urlService.config.defaultSquashPolicy(value); };
|
54 |
|
55 | this.strictMode = function (value) { return _this.router.urlService.config.strictMode(value); };
|
56 |
|
57 | this.type = function (name, definition, definitionFn) {
|
58 | return _this.router.urlService.config.type(name, definition, definitionFn) || _this;
|
59 | };
|
60 | }
|
61 | |
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | UrlMatcherFactory.prototype.compile = function (pattern, config) {
|
69 | var urlConfig = this.router.urlService.config;
|
70 |
|
71 | var params = config && !config.state && config.params;
|
72 | config = params ? __assign({ state: { params: params } }, config) : config;
|
73 | var globalConfig = {
|
74 | strict: urlConfig._isStrictMode,
|
75 | caseInsensitive: urlConfig._isCaseInsensitive,
|
76 | decodeParams: urlConfig._decodeParams,
|
77 | };
|
78 | return new urlMatcher_1.UrlMatcher(pattern, urlConfig.paramTypes, this.paramFactory, common_1.extend(globalConfig, config));
|
79 | };
|
80 | |
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | UrlMatcherFactory.prototype.isMatcher = function (object) {
|
88 |
|
89 | if (!common_1.isObject(object))
|
90 | return false;
|
91 | var result = true;
|
92 | common_1.forEach(urlMatcher_1.UrlMatcher.prototype, function (val, name) {
|
93 | if (common_1.isFunction(val))
|
94 | result = result && common_1.isDefined(object[name]) && common_1.isFunction(object[name]);
|
95 | });
|
96 | return result;
|
97 | };
|
98 |
|
99 | UrlMatcherFactory.prototype.$get = function () {
|
100 | var urlConfig = this.router.urlService.config;
|
101 | urlConfig.paramTypes.enqueue = false;
|
102 | urlConfig.paramTypes._flushTypeQueue();
|
103 | return this;
|
104 | };
|
105 | return UrlMatcherFactory;
|
106 | }());
|
107 | exports.UrlMatcherFactory = UrlMatcherFactory;
|
108 |
|
\ | No newline at end of file |