@angular-wave/angular.ts 0.0.66 → 0.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/animations/animate-js.js +4 -4
  5. package/src/animations/animate-swap.js +3 -0
  6. package/src/core/compile/compile.js +3 -3
  7. package/src/core/controller/controller.js +0 -5
  8. package/src/core/di/injector.js +9 -12
  9. package/src/core/di/internal-injector.js +113 -60
  10. package/src/core/interval/interval-factory.js +8 -1
  11. package/src/core/interval/interval.js +30 -16
  12. package/src/core/location/location.js +473 -626
  13. package/src/core/location/location.md +114 -0
  14. package/src/core/location/location.spec.js +1 -76
  15. package/src/core/parser/parse.js +1 -12
  16. package/src/core/parser/parse.spec.js +96 -110
  17. package/src/core/q/q.js +63 -65
  18. package/src/core/sce/sce.js +1 -3
  19. package/src/core/scope/scope.js +2 -5
  20. package/src/core/timeout/timeout.js +110 -111
  21. package/src/core/url-utils/url-utils.js +5 -0
  22. package/src/directive/input/input.js +32 -726
  23. package/src/directive/input/input.md +706 -0
  24. package/src/directive/options/options.js +2 -156
  25. package/src/directive/options/options.md +179 -0
  26. package/src/directive/select/select.js +55 -126
  27. package/src/directive/select/select.md +74 -0
  28. package/src/directive/show-hide/show-hide.js +13 -224
  29. package/src/directive/show-hide/show-hide.md +257 -0
  30. package/src/exts/messages/messages.js +2 -0
  31. package/src/filters/limit-to.spec.js +1 -1
  32. package/src/filters/order-by.spec.js +1 -1
  33. package/src/index.js +6 -2
  34. package/src/loader.js +7 -3
  35. package/src/public.js +1 -7
  36. package/src/router/params/param.js +54 -54
  37. package/src/router/path/path-utils.js +1 -0
  38. package/src/router/state/state-builder.js +2 -4
  39. package/src/router/state/state-service.js +1 -1
  40. package/src/router/state-provider.js +1 -1
  41. package/src/router/template-factory.js +10 -10
  42. package/src/router/url/url-service.js +11 -4
  43. package/src/services/anchor-scroll.js +3 -5
  44. package/src/services/browser.js +2 -9
  45. package/src/services/cache-factory.js +0 -67
  46. package/src/services/cache-factory.md +75 -0
  47. package/src/services/cookie-reader.js +36 -55
  48. package/src/services/http/http.js +62 -587
  49. package/src/services/http/http.md +413 -0
  50. package/src/services/http-backend/http-backend.js +19 -44
  51. package/src/services/template-request.js +1 -9
  52. package/src/shared/jqlite/jqlite.js +5 -70
  53. package/src/types.js +2 -4
  54. package/types/animations/animate-swap.d.ts +4 -7
  55. package/types/core/compile/compile.d.ts +6 -6
  56. package/types/core/controller/controller.d.ts +0 -5
  57. package/types/core/di/internal-injector.d.ts +73 -18
  58. package/types/core/exception-handler.d.ts +1 -1
  59. package/types/core/interval/interval-factory.d.ts +1 -1
  60. package/types/core/interval/interval.d.ts +4 -0
  61. package/types/core/location/location.d.ts +235 -166
  62. package/types/core/parser/parse.d.ts +1 -1
  63. package/types/core/q/q.d.ts +61 -40
  64. package/types/core/scope/scope.d.ts +5 -8
  65. package/types/core/timeout/timeout.d.ts +16 -26
  66. package/types/core/url-utils/url-utils.d.ts +4 -0
  67. package/types/directive/input/input.d.ts +19 -124
  68. package/types/directive/select/select.d.ts +7 -74
  69. package/types/directive/show-hide/show-hide.d.ts +11 -224
  70. package/types/loader.d.ts +4 -4
  71. package/types/router/params/param.d.ts +11 -0
  72. package/types/router/state/state-builder.d.ts +1 -2
  73. package/types/router/state/state-service.d.ts +2 -2
  74. package/types/router/state-provider.d.ts +2 -2
  75. package/types/router/template-factory.d.ts +15 -15
  76. package/types/router/url/url-service.d.ts +12 -12
  77. package/types/services/anchor-scroll.d.ts +1 -1
  78. package/types/services/browser.d.ts +0 -10
  79. package/types/services/cache-factory.d.ts +0 -67
  80. package/types/services/cookie-reader.d.ts +2 -10
  81. package/types/services/http/http.d.ts +53 -61
  82. package/types/services/http-backend/http-backend.d.ts +8 -31
  83. package/types/services/template-request.d.ts +1 -9
  84. package/types/shared/jqlite/jqlite.d.ts +11 -11
  85. package/types/types.d.ts +1 -9
@@ -86,47 +86,6 @@ function getReplace(config, arrayMode, isOptional, squash) {
86
86
  ).concat(replace);
87
87
  }
88
88
  export class Param {
89
- static values(params, values = {}) {
90
- const paramValues = {};
91
- for (const param of params) {
92
- paramValues[param.id] = param.value(values[param.id]);
93
- }
94
- return paramValues;
95
- }
96
- /**
97
- * Finds [[Param]] objects which have different param values
98
- *
99
- * Filters a list of [[Param]] objects to only those whose parameter values differ in two param value objects
100
- *
101
- * @param params: The list of Param objects to filter
102
- * @param values1: The first set of parameter values
103
- * @param values2: the second set of parameter values
104
- *
105
- * @returns any Param objects whose values were different between values1 and values2
106
- */
107
- static changed(params, values1 = {}, values2 = {}) {
108
- return params.filter(
109
- (param) => !param.type.equals(values1[param.id], values2[param.id]),
110
- );
111
- }
112
- /**
113
- * Checks if two param value objects are equal (for a set of [[Param]] objects)
114
- *
115
- * @param params The list of [[Param]] objects to check
116
- * @param values1 The first set of param values
117
- * @param values2 The second set of param values
118
- *
119
- * @returns true if the param values in values1 and values2 are equal
120
- */
121
- static equals(params, values1 = {}, values2 = {}) {
122
- return Param.changed(params, values1, values2).length === 0;
123
- }
124
- /** Returns true if a the parameter values are valid, according to the Param definitions */
125
- static validates(params, values = {}) {
126
- return params
127
- .map((param) => param.validates(values[param.id]))
128
- .reduce(allTrueR, true);
129
- }
130
89
  constructor(id, type, location, urlConfig, state) {
131
90
  const config = getParamDeclaration(id, location, state);
132
91
  type = getType(config, type, location, id, urlConfig.paramTypes);
@@ -157,20 +116,19 @@ export class Param {
157
116
  const arrayParamNomenclature = id.match(/\[\]$/) ? { array: true } : {};
158
117
  return Object.assign(arrayDefaults, arrayParamNomenclature, config).array;
159
118
  }
160
- Object.assign(this, {
161
- id,
162
- type,
163
- location,
164
- isOptional,
165
- dynamic,
166
- raw,
167
- squash,
168
- replace,
169
- inherit,
170
- array: arrayMode,
171
- config,
172
- });
119
+ this.isOptional = isOptional;
120
+ this.type = type;
121
+ this.location = location;
122
+ this.id = id;
123
+ this.dynamic = dynamic;
124
+ this.raw = raw;
125
+ this.squash = squash;
126
+ this.replace = replace;
127
+ this.inherit = inherit;
128
+ this.array = arrayMode;
129
+ this.config = config;
173
130
  }
131
+
174
132
  isDefaultValue(value) {
175
133
  return this.isOptional && this.type.equals(this.value(), value);
176
134
  }
@@ -227,4 +185,46 @@ export class Param {
227
185
  toString() {
228
186
  return `{Param:${this.id} ${this.type} squash: '${this.squash}' optional: ${this.isOptional}}`;
229
187
  }
188
+
189
+ static values(params, values = {}) {
190
+ const paramValues = {};
191
+ for (const param of params) {
192
+ paramValues[param.id] = param.value(values[param.id]);
193
+ }
194
+ return paramValues;
195
+ }
196
+ /**
197
+ * Finds [[Param]] objects which have different param values
198
+ *
199
+ * Filters a list of [[Param]] objects to only those whose parameter values differ in two param value objects
200
+ *
201
+ * @param params: The list of Param objects to filter
202
+ * @param values1: The first set of parameter values
203
+ * @param values2: the second set of parameter values
204
+ *
205
+ * @returns any Param objects whose values were different between values1 and values2
206
+ */
207
+ static changed(params, values1 = {}, values2 = {}) {
208
+ return params.filter(
209
+ (param) => !param.type.equals(values1[param.id], values2[param.id]),
210
+ );
211
+ }
212
+ /**
213
+ * Checks if two param value objects are equal (for a set of [[Param]] objects)
214
+ *
215
+ * @param params The list of [[Param]] objects to check
216
+ * @param values1 The first set of param values
217
+ * @param values2 The second set of param values
218
+ *
219
+ * @returns true if the param values in values1 and values2 are equal
220
+ */
221
+ static equals(params, values1 = {}, values2 = {}) {
222
+ return Param.changed(params, values1, values2).length === 0;
223
+ }
224
+ /** Returns true if a the parameter values are valid, according to the Param definitions */
225
+ static validates(params, values = {}) {
226
+ return params
227
+ .map((param) => param.validates(values[param.id]))
228
+ .reduce(allTrueR, true);
229
+ }
230
230
  }
@@ -74,6 +74,7 @@ export class PathUtils {
74
74
  */
75
75
  static inheritParams(fromPath, toPath, toKeys = []) {
76
76
  function nodeParamVals(path, state) {
77
+ /** @type {PathNode} */
77
78
  const node = find(path, propEq("state", state));
78
79
  return Object.assign({}, node && node.paramValues);
79
80
  }
@@ -17,9 +17,7 @@ const parseUrl = (url) => {
17
17
  const root = url.charAt(0) === "^";
18
18
  return { val: root ? url.substring(1) : url, root };
19
19
  };
20
- function nameBuilder(state) {
21
- return state.name;
22
- }
20
+
23
21
  function selfBuilder(state) {
24
22
  state.self.$$state = () => state;
25
23
  return state.self;
@@ -250,7 +248,7 @@ export class StateBuilder {
250
248
  return matcher.find(self.parentName(state)) || root();
251
249
  }
252
250
  this.builders = {
253
- name: [nameBuilder],
251
+ name: [(state) => state.name],
254
252
  self: [selfBuilder],
255
253
  parent: [parentBuilder],
256
254
  data: [dataBuilder],
@@ -190,7 +190,7 @@ export class StateService {
190
190
 
191
191
  /**
192
192
  *
193
- * @param {angular.Ng1StateDeclaration} definition
193
+ * @param {any} definition
194
194
  */
195
195
  state(definition) {
196
196
  if (!definition.name) {
@@ -155,7 +155,7 @@ export class StateProvider {
155
155
 
156
156
  /**
157
157
  *
158
- * @param {angular.Ng1StateDeclaration} definition
158
+ * @param {*} definition
159
159
  * @returns {StateProvider}
160
160
  */
161
161
  state(definition) {
@@ -27,10 +27,10 @@ export class TemplateFactory {
27
27
  "$q",
28
28
  "$injector",
29
29
  /**
30
- * @param {angular.IHttpService} $http
31
- * @param {angular.ITemplateCacheService} $templateCache
32
- * @param {angular.ITemplateRequestService} $templateRequest
33
- * @param {angular.IQService} $q
30
+ * @param {any} $http
31
+ * @param {any} $templateCache
32
+ * @param {any} $templateRequest
33
+ * @param {any} $q
34
34
  * @param {import("../core/di/internal-injector").InjectorService} $injector
35
35
  * @returns
36
36
  */
@@ -59,9 +59,9 @@ export class TemplateFactory {
59
59
  * The following properties are search in the specified order, and the first one
60
60
  * that is defined is used to create the template:
61
61
  *
62
- * @param {angular.Ng1ViewDeclaration} config
62
+ * @param {any} config
63
63
  * @param {any} params Parameters to pass to the template function.
64
- * @param {angular.ResolveContext} context The resolve context associated with the template's view
64
+ * @param {import("./resolve/resolve-context").ResolveContext} context The resolve context associated with the template's view
65
65
  *
66
66
  * @return {string|object} The template html as a string, or a promise for
67
67
  * that string,or `null` if no template is configured.
@@ -105,7 +105,7 @@ export class TemplateFactory {
105
105
  * Creates a template from a string or a function returning a string.
106
106
  *
107
107
  * @param {string | Function} template html template as a string or function that returns an html template as a string.
108
- * @param {angular.RawParams} [params] Parameters to pass to the template function.
108
+ * @param {any} [params] Parameters to pass to the template function.
109
109
  *
110
110
  * @return {string|object} The template html as a string, or a promise for that
111
111
  * string.
@@ -142,7 +142,7 @@ export class TemplateFactory {
142
142
  *
143
143
  * @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
144
144
  * @param {Function} injectFn a function used to invoke the template provider
145
- * @param {angular.ResolveContext} context
145
+ * @param {import("./resolve/resolve-context").ResolveContext} context
146
146
  * @return {string|Promise.<string>} The template html as a string, or a promise
147
147
  * for that string.
148
148
  */
@@ -173,8 +173,8 @@ export class TemplateFactory {
173
173
  * It analyses the component's bindings, then constructs a template that instantiates the component.
174
174
  * The template wires input and output bindings to resolves or from the parent component.
175
175
  *
176
- * @param {angular.IAugmentedJQuery} ngView {object} The parent ui-view (for binding outputs to callbacks)
177
- * @param {angular.ResolveContext} context The ResolveContext (for binding outputs to callbacks returned from resolves)
176
+ * @param {any} ngView {object} The parent ui-view (for binding outputs to callbacks)
177
+ * @param {import("./resolve/resolve-context").ResolveContext} context The ResolveContext (for binding outputs to callbacks returned from resolves)
178
178
  * @param {string} component {string} Component's name in camel case.
179
179
  * @param {any} [bindings] An object defining the component's bindings: {foo: '<'}
180
180
  * @return {string} The template as a string: "<component-name input1='::$resolve.foo'></component-name>".
@@ -92,6 +92,13 @@ export class UrlService {
92
92
  "$location",
93
93
  "$browser",
94
94
  "$rootScope",
95
+ /**
96
+ *
97
+ * @param {import('../../core/location/location').Location} $location
98
+ * @param {import('../../services/browser').Browser} $browser
99
+ * @param {import('../../core/scope/scope').Scope} $rootScope
100
+ * @returns
101
+ */
95
102
  ($location, $browser, $rootScope) => {
96
103
  this.$location = $location;
97
104
  this.$browser = $browser;
@@ -159,11 +166,11 @@ export class UrlService {
159
166
  * locationServices.url("/some/path?query=value#anchor", true);
160
167
  * ```
161
168
  *
162
- * @param {string} newUrl The new value for the URL.
169
+ * @param {string} [newUrl] The new value for the URL.
163
170
  * This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.
164
171
  * It should not include the protocol, site, port, or base path of an absolute HREF.
165
- * @param {boolean} replace When true, replaces the current history entry (instead of appending it) with this new url
166
- * @param {any} state The history's state object, i.e., pushState (if the LocationServices implementation supports it)
172
+ * @param {boolean} [replace] When true, replaces the current history entry (instead of appending it) with this new url
173
+ * @param {any} [state] The history's state object, i.e., pushState (if the LocationServices implementation supports it)
167
174
  *
168
175
  * @return the url (after potentially being processed)
169
176
  */
@@ -231,7 +238,7 @@ export class UrlService {
231
238
  hash: this.hash(),
232
239
  };
233
240
  /**
234
- * @type {MatchResult}
241
+ * @type {*}
235
242
  */
236
243
  const best = this.match(url);
237
244
  const applyResult = pattern([
@@ -18,13 +18,11 @@ export function AnchorScrollProvider() {
18
18
  "$rootScope",
19
19
  /**
20
20
  *
21
- * @param {angular.IRootScopeService} $location
22
- * @param {*} $rootScope
21
+ * @param {import('../core/location/location').Location} $location
22
+ * @param {import('../core/scope/scope').Scope} $rootScope
23
23
  * @returns
24
24
  */
25
25
  function ($location, $rootScope) {
26
- const { document } = window;
27
-
28
26
  // Helper function to get first anchor from a NodeList
29
27
  // (using `Array#some()` instead of `angular#forEach()` since it's more performant
30
28
  // and working in all supported browsers.)
@@ -117,7 +115,7 @@ export function AnchorScrollProvider() {
117
115
  if (newVal === oldVal && newVal === "") return;
118
116
 
119
117
  const action = () => $rootScope.$evalAsync(scroll);
120
- if (window.document.readyState === "complete") {
118
+ if (document.readyState === "complete") {
121
119
  // Force the action to be run async for consistent behavior
122
120
  // from the action's point of view
123
121
  // i.e. it will definitely not be in a $apply
@@ -291,8 +291,6 @@ export function Browser(taskTracker) {
291
291
  }
292
292
 
293
293
  /**
294
- * @typedef {import('../types').ServiceProvider} angular.BrowserProvider
295
- * @description
296
294
  * This object has two goals:
297
295
  *
298
296
  * - hide all the global state in the browser caused by the window object
@@ -300,13 +298,8 @@ export function Browser(taskTracker) {
300
298
  *
301
299
  * Remove this in the future
302
300
  */
303
-
304
- /**
305
- * @constructor
306
- * @this {angular.BrowserProvider}
307
- */
308
- export function BrowserProvider() {
309
- this.$get = [
301
+ export class BrowserProvider {
302
+ $get = [
310
303
  "$$taskTrackerFactory",
311
304
  /**
312
305
  * @param {import('../core/task-tracker-factory').TaskTracker} $$taskTrackerFactory
@@ -1,72 +1,5 @@
1
1
  import { extend, forEach, isUndefined, minErr } from "../shared/utils";
2
2
 
3
- /**
4
- * @ngdoc service
5
- * @name $cacheFactory
6
- *
7
- *
8
- * @description
9
- * Factory that constructs {@link $cacheFactory.Cache Cache} objects and gives access to
10
- * them.
11
- *
12
- * ```js
13
- *
14
- * let cache = $cacheFactory('cacheId');
15
- * expect($cacheFactory.get('cacheId')).toBe(cache);
16
- * expect($cacheFactory.get('noSuchCacheId')).not.toBeDefined();
17
- *
18
- * cache.put("key", "value");
19
- * cache.put("another key", "another value");
20
- *
21
- * // We've specified no options on creation
22
- * expect(cache.info()).toEqual({id: 'cacheId', size: 2});
23
- *
24
- * ```
25
- *
26
- *
27
- * @example
28
- <example module="cacheExampleApp" name="cache-factory">
29
- <file name="index.html">
30
- <div ng-controller="CacheController">
31
- <input ng-model="newCacheKey" placeholder="Key">
32
- <input ng-model="newCacheValue" placeholder="Value">
33
- <button ng-click="put(newCacheKey, newCacheValue)">Cache</button>
34
-
35
- <p ng-if="keys.length">Cached Values</p>
36
- <div ng-repeat="key in keys">
37
- <span ng-bind="key"></span>
38
- <span>: </span>
39
- <b ng-bind="cache.get(key)"></b>
40
- </div>
41
-
42
- <p>Cache Info</p>
43
- <div ng-repeat="(key, value) in cache.info()">
44
- <span ng-bind="key"></span>
45
- <span>: </span>
46
- <b ng-bind="value"></b>
47
- </div>
48
- </div>
49
- </file>
50
- <file name="script.js">
51
- angular.module('cacheExampleApp', []).
52
- controller('CacheController', ['$scope', '$cacheFactory', function($scope, $cacheFactory) {
53
- $scope.keys = [];
54
- $scope.cache = $cacheFactory('cacheId');
55
- $scope.put = function(key, value) {
56
- if (angular.isUndefined($scope.cache.get(key))) {
57
- $scope.keys.push(key);
58
- }
59
- $scope.cache.put(key, angular.isUndefined(value) ? null : value);
60
- };
61
- }]);
62
- </file>
63
- <file name="style.css">
64
- p {
65
- margin: 10px 0 3px;
66
- }
67
- </file>
68
- </example>
69
- */
70
3
  export function CacheFactoryProvider() {
71
4
  this.$get = function () {
72
5
  const caches = {};
@@ -0,0 +1,75 @@
1
+ /\*\*
2
+
3
+ - @ngdoc service
4
+ - @name $cacheFactory
5
+ -
6
+ -
7
+ - @description
8
+ - Factory that constructs {@link $cacheFactory.Cache Cache} objects and gives access to
9
+ - them.
10
+ -
11
+ - ```js
12
+
13
+ ```
14
+
15
+ -
16
+ - let cache = $cacheFactory('cacheId');
17
+ - expect($cacheFactory.get('cacheId')).toBe(cache);
18
+ - expect($cacheFactory.get('noSuchCacheId')).not.toBeDefined();
19
+ -
20
+ - cache.put("key", "value");
21
+ - cache.put("another key", "another value");
22
+ -
23
+ - // We've specified no options on creation
24
+ - expect(cache.info()).toEqual({id: 'cacheId', size: 2});
25
+ -
26
+ - ```
27
+
28
+ ```
29
+
30
+ -
31
+ -
32
+ - @example
33
+ <example module="cacheExampleApp" name="cache-factory">
34
+ <file name="index.html">
35
+ <div ng-controller="CacheController">
36
+ <input ng-model="newCacheKey" placeholder="Key">
37
+ <input ng-model="newCacheValue" placeholder="Value">
38
+ <button ng-click="put(newCacheKey, newCacheValue)">Cache</button>
39
+
40
+ <p ng-if="keys.length">Cached Values</p>
41
+ <div ng-repeat="key in keys">
42
+ <span ng-bind="key"></span>
43
+ <span>: </span>
44
+ <b ng-bind="cache.get(key)"></b>
45
+ </div>
46
+
47
+ <p>Cache Info</p>
48
+ <div ng-repeat="(key, value) in cache.info()">
49
+ <span ng-bind="key"></span>
50
+ <span>: </span>
51
+ <b ng-bind="value"></b>
52
+ </div>
53
+ </div>
54
+ </file>
55
+ <file name="script.js">
56
+ angular.module('cacheExampleApp', []).
57
+ controller('CacheController', ['$scope', '$cacheFactory', function($scope, $cacheFactory) {
58
+ $scope.keys = [];
59
+ $scope.cache = $cacheFactory('cacheId');
60
+ $scope.put = function(key, value) {
61
+ if (angular.isUndefined($scope.cache.get(key))) {
62
+ $scope.keys.push(key);
63
+ }
64
+ $scope.cache.put(key, angular.isUndefined(value) ? null : value);
65
+ };
66
+ }]);
67
+ </file>
68
+ <file name="style.css">
69
+ p {
70
+ margin: 10px 0 3px;
71
+ }
72
+ </file>
73
+
74
+ </example>
75
+ */
@@ -1,67 +1,48 @@
1
1
  import { isUndefined } from "../shared/utils";
2
2
 
3
+ let lastCookies = {};
4
+ let lastCookieString = "";
5
+
3
6
  /**
4
- *
5
- * @description
6
- * This is a private service for reading cookies used by $http and ngCookies
7
- *
8
- * @return {Object} a key/value map of the current cookies
7
+ * @returns {Object<String, String>} List of all cookies
9
8
  */
10
- export function $$CookieReader() {
11
- const rawDocument = window.document;
12
- let lastCookies = {};
13
- let lastCookieString = "";
14
-
15
- function safeGetCookie(rawDocument) {
16
- try {
17
- return rawDocument.cookie || "";
18
- } catch (e) {
19
- return "";
20
- }
21
- }
22
-
23
- function safeDecodeURIComponent(str) {
24
- try {
25
- return decodeURIComponent(str);
26
- } catch (e) {
27
- return str;
28
- }
29
- }
30
-
31
- return function () {
32
- let cookieArray;
33
- let cookie;
34
- let i;
35
- let index;
36
- let name;
37
- const currentCookieString = safeGetCookie(rawDocument);
9
+ export function getCookies() {
10
+ let cookieArray;
11
+ let cookie;
12
+ let i;
13
+ let index;
14
+ let name;
15
+ const currentCookieString = window.document.cookie;
38
16
 
39
- if (currentCookieString !== lastCookieString) {
40
- lastCookieString = currentCookieString;
41
- cookieArray = lastCookieString.split("; ");
42
- lastCookies = {};
17
+ if (currentCookieString !== lastCookieString) {
18
+ lastCookieString = currentCookieString;
19
+ cookieArray = lastCookieString.split("; ");
20
+ lastCookies = {};
43
21
 
44
- for (i = 0; i < cookieArray.length; i++) {
45
- cookie = cookieArray[i];
46
- index = cookie.indexOf("=");
47
- if (index > 0) {
48
- // ignore nameless cookies
49
- name = safeDecodeURIComponent(cookie.substring(0, index));
50
- // the first value that is seen for a cookie is the most
51
- // specific one. values for the same cookie name that
52
- // follow are for less specific paths.
53
- if (isUndefined(lastCookies[name])) {
54
- lastCookies[name] = safeDecodeURIComponent(
55
- cookie.substring(index + 1),
56
- );
57
- }
22
+ for (i = 0; i < cookieArray.length; i++) {
23
+ cookie = cookieArray[i];
24
+ index = cookie.indexOf("=");
25
+ if (index > 0) {
26
+ // ignore nameless cookies
27
+ name = safeDecodeURIComponent(cookie.substring(0, index));
28
+ // the first value that is seen for a cookie is the most
29
+ // specific one. values for the same cookie name that
30
+ // follow are for less specific paths.
31
+ if (isUndefined(lastCookies[name])) {
32
+ lastCookies[name] = safeDecodeURIComponent(
33
+ cookie.substring(index + 1),
34
+ );
58
35
  }
59
36
  }
60
37
  }
61
- return lastCookies;
62
- };
38
+ }
39
+ return lastCookies;
63
40
  }
64
41
 
65
- export function CookieReaderProvider() {
66
- this.$get = $$CookieReader;
42
+ function safeDecodeURIComponent(str) {
43
+ try {
44
+ return decodeURIComponent(str);
45
+ } catch (e) {
46
+ return str;
47
+ }
67
48
  }